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

COVERAGE SUMMARY FOR SOURCE FILE [XMLDoubleClickStrategy.java]

nameclass, %method, %block, %line, %
XMLDoubleClickStrategy.java0%   (0/1)0%   (0/5)0%   (0/168)0%   (0/63)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class XMLDoubleClickStrategy0%   (0/1)0%   (0/5)0%   (0/168)0%   (0/63)
XMLDoubleClickStrategy (): void 0%   (0/1)0%   (0/3)0%   (0/1)
doubleClicked (ITextViewer): void 0%   (0/1)0%   (0/19)0%   (0/7)
selectComment (int): boolean 0%   (0/1)0%   (0/83)0%   (0/31)
selectRange (int, int): void 0%   (0/1)0%   (0/14)0%   (0/4)
selectWord (int): boolean 0%   (0/1)0%   (0/49)0%   (0/20)

1package de.uka.ipd.sdq.pcm.gmf.resource.editors;
2 
3import org.eclipse.jface.text.BadLocationException;
4import org.eclipse.jface.text.IDocument;
5import org.eclipse.jface.text.ITextDoubleClickStrategy;
6import org.eclipse.jface.text.ITextViewer;
7 
8public class XMLDoubleClickStrategy implements ITextDoubleClickStrategy {
9        protected ITextViewer fText;
10 
11        public void doubleClicked(ITextViewer part) {
12                int pos = part.getSelectedRange().x;
13 
14                if (pos < 0)
15                        return;
16 
17                fText = part;
18 
19                if (!selectComment(pos)) {
20                        selectWord(pos);
21                }
22        }
23        protected boolean selectComment(int caretPos) {
24                IDocument doc = fText.getDocument();
25                int startPos, endPos;
26 
27                try {
28                        int pos = caretPos;
29                        char c = ' ';
30 
31                        while (pos >= 0) {
32                                c = doc.getChar(pos);
33                                if (c == '\\') {
34                                        pos -= 2;
35                                        continue;
36                                }
37                                if (c == Character.LINE_SEPARATOR || c == '\"')
38                                        break;
39                                --pos;
40                        }
41 
42                        if (c != '\"')
43                                return false;
44 
45                        startPos = pos;
46 
47                        pos = caretPos;
48                        int length = doc.getLength();
49                        c = ' ';
50 
51                        while (pos < length) {
52                                c = doc.getChar(pos);
53                                if (c == Character.LINE_SEPARATOR || c == '\"')
54                                        break;
55                                ++pos;
56                        }
57                        if (c != '\"')
58                                return false;
59 
60                        endPos = pos;
61 
62                        int offset = startPos + 1;
63                        int len = endPos - offset;
64                        fText.setSelectedRange(offset, len);
65                        return true;
66                } catch (BadLocationException x) {
67                }
68 
69                return false;
70        }
71        protected boolean selectWord(int caretPos) {
72 
73                IDocument doc = fText.getDocument();
74                int startPos, endPos;
75 
76                try {
77 
78                        int pos = caretPos;
79                        char c;
80 
81                        while (pos >= 0) {
82                                c = doc.getChar(pos);
83                                if (!Character.isJavaIdentifierPart(c))
84                                        break;
85                                --pos;
86                        }
87 
88                        startPos = pos;
89 
90                        pos = caretPos;
91                        int length = doc.getLength();
92 
93                        while (pos < length) {
94                                c = doc.getChar(pos);
95                                if (!Character.isJavaIdentifierPart(c))
96                                        break;
97                                ++pos;
98                        }
99 
100                        endPos = pos;
101                        selectRange(startPos, endPos);
102                        return true;
103 
104                } catch (BadLocationException x) {
105                }
106 
107                return false;
108        }
109 
110        private void selectRange(int startPos, int stopPos) {
111                int offset = startPos + 1;
112                int length = stopPos - offset;
113                fText.setSelectedRange(offset, length);
114        }
115}

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