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 [ANTLRTokenScannerAdapter.java]

nameclass, %method, %block, %line, %
ANTLRTokenScannerAdapter.java0%   (0/1)0%   (0/5)0%   (0/151)0%   (0/36)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ANTLRTokenScannerAdapter0%   (0/1)0%   (0/5)0%   (0/151)0%   (0/36)
ANTLRTokenScannerAdapter (Class, ITokenMapper): void 0%   (0/1)0%   (0/12)0%   (0/5)
getTokenLength (): int 0%   (0/1)0%   (0/3)0%   (0/1)
getTokenOffset (): int 0%   (0/1)0%   (0/3)0%   (0/1)
nextToken (): IToken 0%   (0/1)0%   (0/58)0%   (0/6)
setRange (IDocument, int, int): void 0%   (0/1)0%   (0/75)0%   (0/23)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.pcm.dialogs.stoex;
5 
6import java.lang.reflect.InvocationTargetException;
7 
8import org.antlr.runtime.ANTLRStringStream;
9import org.antlr.runtime.BaseRecognizer;
10import org.antlr.runtime.CharStream;
11import org.antlr.runtime.Lexer;
12import org.eclipse.jface.text.BadLocationException;
13import org.eclipse.jface.text.IDocument;
14import org.eclipse.jface.text.rules.IToken;
15import org.eclipse.jface.text.rules.ITokenScanner;
16 
17/**
18 * @author Steffen Becker
19 * 
20 */
21public class ANTLRTokenScannerAdapter implements ITokenScanner {
22 
23        int lastTokenLength = 0;
24 
25        private int tokenOffset;
26 
27        private Class<?> scannerClass;
28 
29        private Lexer scanner;
30 
31        private String currentInput;
32 
33        private IDocument currentDocument;
34 
35        private int baseOffset;
36 
37        private ITokenMapper myMapper;
38 
39        private int lastTokenOffset;
40 
41        /**
42         * 
43         */
44        public ANTLRTokenScannerAdapter(Class<?> scannerClass, ITokenMapper mapper) {
45                this.scannerClass = scannerClass;
46                this.myMapper = mapper;
47        }
48 
49        /*
50         * (non-Javadoc)
51         * 
52         * @see org.eclipse.jface.text.rules.ITokenScanner#getTokenLength()
53         */
54        public int getTokenLength() {
55                return lastTokenLength;
56        }
57 
58        /*
59         * (non-Javadoc)
60         * 
61         * @see org.eclipse.jface.text.rules.ITokenScanner#getTokenOffset()
62         */
63        public int getTokenOffset() {
64                return tokenOffset;
65        }
66 
67        /*
68         * (non-Javadoc)
69         * 
70         * @see org.eclipse.jface.text.rules.ITokenScanner#nextToken()
71         */
72        public IToken nextToken() {
73            tokenOffset = baseOffset + scanner.getCharIndex(); // Token starts at point where lexer is
74                ANTLRTokenWrapper wrapper = new ANTLRTokenWrapper(scanner.nextToken(), myMapper);
75            lastTokenLength = wrapper.getToken().getText() == null ? 0 : wrapper.getToken().getText().length();
76            tokenOffset += (scanner.getCharIndex() + baseOffset) - tokenOffset - lastTokenLength; // Correct the position in case of recognition exceptions
77            
78                wrapper.setIsWhitespace(wrapper.getToken().getChannel() == BaseRecognizer.HIDDEN);// Token is a Whitespace
79                return wrapper;
80        }
81 
82        /*
83         * (non-Javadoc)
84         * 
85         * @see org.eclipse.jface.text.rules.ITokenScanner#setRange(org.eclipse.jface.text.IDocument,
86         *      int, int)
87         */
88        public void setRange(IDocument document, int offset, int length) {
89                currentInput = ""; currentDocument = document;
90                try {
91                        currentInput = document.get(offset, length);
92                        lastTokenOffset = 0;
93                        tokenOffset = offset; 
94                        baseOffset = offset;
95                } catch (BadLocationException e1) {
96                        // TODO Auto-generated catch block
97                        e1.printStackTrace();
98                }
99                ANTLRStringStream reader = new ANTLRStringStream(currentInput);
100                try {
101                        scanner = (Lexer) scannerClass.getConstructor(CharStream.class)
102                                        .newInstance(new Object[] { reader });
103                } catch (IllegalArgumentException e) {
104                        // TODO Auto-generated catch block
105                        e.printStackTrace();
106                } catch (SecurityException e) {
107                        // TODO Auto-generated catch block
108                        e.printStackTrace();
109                } catch (InstantiationException e) {
110                        // TODO Auto-generated catch block
111                        e.printStackTrace();
112                } catch (IllegalAccessException e) {
113                        // TODO Auto-generated catch block
114                        e.printStackTrace();
115                } catch (InvocationTargetException e) {
116                        // TODO Auto-generated catch block
117                        e.printStackTrace();
118                } catch (NoSuchMethodException e) {
119                        // TODO Auto-generated catch block
120                        e.printStackTrace();
121                }
122        }
123 
124}

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