source: java/FramclipsePlugin/src/main/java/com/framsticks/framclipse/editors/folding/FramclipseFoldingAnnotation.java @ 193

Last change on this file since 193 was 193, checked in by Maciej Komosinski, 10 years ago

Set svn:eol-style native for all textual files

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/plain
File size: 1.6 KB
Line 
1package com.framsticks.framclipse.editors.folding;
2
3import java.util.List;
4
5import org.eclipse.jface.text.IDocument;
6import org.eclipse.jface.text.source.projection.ProjectionAnnotation;
7
8import com.framsticks.framclipse.internal.parser.ASTCodeSection;
9import com.framsticks.framclipse.internal.parser.ASTFunction;
10import com.framsticks.framclipse.internal.parser.ASTProperty;
11import com.framsticks.framclipse.internal.parser.ElementWithOffset;
12
13
14public class FramclipseFoldingAnnotation extends ProjectionAnnotation
15{
16        ElementWithOffset annotatedElement;
17       
18        public FramclipseFoldingAnnotation(ElementWithOffset element)
19        {
20                this.annotatedElement = element;
21        }
22       
23        public ElementWithOffset getAnnotatedElement()
24        {
25                return annotatedElement;
26        }
27       
28        public int getAnnotationLength()
29        {
30                int defaultLen = annotatedElement.getEndOffset() - annotatedElement.getBeginOffset() + 1;
31               
32                int lineSepLen = System.getProperty("line.separator").length();
33               
34                if(annotatedElement instanceof ASTFunction)
35                        return defaultLen + lineSepLen;
36               
37                if(annotatedElement instanceof ASTProperty)
38                        return defaultLen + lineSepLen;
39               
40                if(annotatedElement instanceof ASTCodeSection)
41                        return defaultLen + lineSepLen;
42               
43                return defaultLen;
44        }
45       
46        public boolean isEquivalent(FramclipseFoldingAnnotation annot, IDocument doc)
47        {
48                return annotatedElement.isEquivalent(annot.annotatedElement, doc);
49                       
50        }
51       
52        public FramclipseFoldingAnnotation hasEquivalent(List<FramclipseFoldingAnnotation> list, IDocument doc)
53        {
54                for(FramclipseFoldingAnnotation annot : list)
55                        if(annot.isEquivalent(this, doc))
56                                return annot;
57               
58                return null;
59        }
60}
Note: See TracBrowser for help on using the repository browser.