MCPcopy Index your code
hub / github.com/processing/processing / startTracking

Method startTracking

java/src/processing/mode/java/debug/LineID.java:133–158  ·  view source on GitHub ↗

Attach a Document to enable line number tracking when editing. The position to track is before the first non-whitespace character on the line. Edits happening before that position will cause the line number to update accordingly. Multiple #startTracking calls will replace the tracked

(Document doc)

Source from the content-addressed store, hash-verified

131 * @param doc the {@link Document} to use for line number tracking
132 */
133 public synchronized void startTracking(Document doc) {
134 //System.out.println("tracking: " + this);
135 if (doc == null) {
136 return; // null arg
137 }
138 if (doc == this.doc) {
139 return; // already tracking that doc
140 }
141 try {
142 Element line = doc.getDefaultRootElement().getElement(lineIdx);
143 if (line == null) {
144 return; // line doesn't exist
145 }
146 String lineText = doc.getText(line.getStartOffset(), line.getEndOffset() - line.getStartOffset());
147 // set tracking position at (=before) first non-white space character on line,
148 // or, if the line consists of entirely white spaces, just before the newline
149 // character
150 pos = doc.createPosition(line.getStartOffset() + nonWhiteSpaceOffset(lineText));
151 this.doc = doc;
152 doc.addDocumentListener(this);
153 } catch (BadLocationException ex) {
154 Messages.loge(null, ex);
155 pos = null;
156 this.doc = null;
157 }
158 }
159
160
161 /**

Callers 3

LineHighlightMethod · 0.80
LineBreakpointMethod · 0.80

Calls 5

nonWhiteSpaceOffsetMethod · 0.95
logeMethod · 0.95
addDocumentListenerMethod · 0.80
getStartOffsetMethod · 0.65
getTextMethod · 0.45

Tested by

no test coverage detected