EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.pcm.dialogs.stoex]

COVERAGE SUMMARY FOR SOURCE FILE [AbstractGrammarBasedViewerConfiguration.java]

nameclass, %method, %block, %line, %
AbstractGrammarBasedViewerConfiguration.java0%   (0/2)0%   (0/9)0%   (0/154)0%   (0/38)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AbstractGrammarBasedViewerConfiguration0%   (0/1)0%   (0/5)0%   (0/80)0%   (0/22)
AbstractGrammarBasedViewerConfiguration (IAnnotationModel, Parameter [], Clas... 0%   (0/1)0%   (0/18)0%   (0/7)
getAnnotationHover (ISourceViewer): IAnnotationHover 0%   (0/1)0%   (0/6)0%   (0/1)
getContentAssistant (ISourceViewer): IContentAssistant 0%   (0/1)0%   (0/28)0%   (0/7)
getKeywordScanner (): ITokenScanner 0%   (0/1)0%   (0/8)0%   (0/1)
getPresentationReconciler (ISourceViewer): IPresentationReconciler 0%   (0/1)0%   (0/20)0%   (0/6)
     
class AnnotationHover0%   (0/1)0%   (0/4)0%   (0/74)0%   (0/16)
AnnotationHover (IAnnotationModel): void 0%   (0/1)0%   (0/6)0%   (0/3)
getHoverInfo (ISourceViewer, int): String 0%   (0/1)0%   (0/64)0%   (0/11)
getHoverInfo (ITextViewer, IRegion): String 0%   (0/1)0%   (0/2)0%   (0/1)
getHoverRegion (ITextViewer, int): IRegion 0%   (0/1)0%   (0/2)0%   (0/1)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.pcm.dialogs.stoex;
5 
6import java.util.ArrayList;
7import java.util.Iterator;
8 
9import org.eclipse.jface.text.IDocument;
10import org.eclipse.jface.text.IRegion;
11import org.eclipse.jface.text.ITextHover;
12import org.eclipse.jface.text.ITextViewer;
13import org.eclipse.jface.text.contentassist.ContentAssistant;
14import org.eclipse.jface.text.contentassist.IContentAssistant;
15import org.eclipse.jface.text.presentation.IPresentationReconciler;
16import org.eclipse.jface.text.presentation.PresentationReconciler;
17import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
18import org.eclipse.jface.text.rules.ITokenScanner;
19import org.eclipse.jface.text.source.Annotation;
20import org.eclipse.jface.text.source.IAnnotationHover;
21import org.eclipse.jface.text.source.IAnnotationModel;
22import org.eclipse.jface.text.source.ISourceViewer;
23import org.eclipse.jface.text.source.SourceViewerConfiguration;
24 
25import de.uka.ipd.sdq.pcm.repository.Parameter;
26 
27/**
28 * @author Snowball
29 * 
30 */
31public class AbstractGrammarBasedViewerConfiguration extends SourceViewerConfiguration {
32 
33        private IAnnotationModel annotationModel;
34        private Class myLexerClass;
35        private ITokenMapper myMapper;
36        private Parameter[] context = null;
37        private ContentAssistant myAssistant;
38 
39        /**
40         * 
41         */
42        public AbstractGrammarBasedViewerConfiguration(IAnnotationModel annotationModel, Parameter[] context, Class lexerClass, ITokenMapper myMapper) {
43                this.annotationModel = annotationModel;
44                this.myLexerClass = lexerClass;
45                this.myMapper = myMapper;
46                this.context = context;
47        }
48 
49        /*
50         * (non-Javadoc)
51         * 
52         * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
53         */
54        @Override
55        public IPresentationReconciler getPresentationReconciler(
56                        ISourceViewer sourceViewer) {
57                PresentationReconciler reconciler = new PresentationReconciler();
58 
59                DefaultDamagerRepairer dr = new DefaultDamagerRepairer(
60                                getKeywordScanner());
61                reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
62                reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
63 
64                return reconciler;
65        }
66 
67        @Override
68        public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
69                return new AnnotationHover(annotationModel);
70        }
71 
72        private ITokenScanner getKeywordScanner() {
73                return new ANTLRTokenScannerAdapter(myLexerClass,myMapper);
74        }
75 
76        @Override
77        public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
78                if (myAssistant == null){
79                        myAssistant = new ContentAssistant();
80                        myAssistant.setContentAssistProcessor(new StoExCompletionProcessor(context),
81                                        IDocument.DEFAULT_CONTENT_TYPE);
82                        myAssistant.setAutoActivationDelay(1);
83                        myAssistant.enableAutoActivation(true);
84                }
85                return myAssistant;
86        }
87}
88 
89// annotation hover manager
90class AnnotationHover implements IAnnotationHover, ITextHover {
91        private IAnnotationModel fAnnotationModel;
92 
93        public AnnotationHover(IAnnotationModel annotationModel) {
94                this.fAnnotationModel = annotationModel;
95        }
96 
97        public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
98                Iterator ite = fAnnotationModel.getAnnotationIterator();
99 
100                ArrayList all = new ArrayList();
101 
102                while (ite.hasNext()) {
103                        Annotation a = (Annotation) ite.next();
104                        if (a instanceof Annotation) {
105                                all.add(((Annotation) a).getText());
106                        }
107                }
108 
109                StringBuffer total = new StringBuffer();
110                for (int x = 0; x < all.size(); x++) {
111                        String str = (String) all.get(x);
112                        total.append(" " + str + (x == (all.size() - 1) ? "" : "\n"));
113                }
114 
115                return total.toString();
116        }
117 
118        public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
119                return null;
120        }
121 
122        public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
123                return null;
124        }
125}

[all classes][de.uka.ipd.sdq.pcm.dialogs.stoex]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov