@@ -86,7 +86,7 @@ public SketchTextArea(PdeKeywords pdeKeywords) throws IOException {
86
86
installFeatures ();
87
87
}
88
88
89
- protected void installFeatures () throws IOException {
89
+ private void installFeatures () throws IOException {
90
90
setTheme (PreferencesData .get ("editor.syntax_theme" , "default" ));
91
91
92
92
setLinkGenerator (new DocLinkGenerator (pdeKeywords ));
@@ -96,7 +96,7 @@ protected void installFeatures() throws IOException {
96
96
setSyntaxEditingStyle (SYNTAX_STYLE_CPLUSPLUS );
97
97
}
98
98
99
- public void setTheme (String name ) throws IOException {
99
+ private void setTheme (String name ) throws IOException {
100
100
FileInputStream defaultXmlInputStream = null ;
101
101
try {
102
102
defaultXmlInputStream = new FileInputStream (new File (BaseNoGui .getContentFile ("lib" ), "theme/syntax/" + name + ".xml" ));
@@ -143,31 +143,26 @@ private void setSyntaxTheme(int tokenType, String id) {
143
143
144
144
// Removing the default focus traversal keys
145
145
// This is because the DefaultKeyboardFocusManager handles the keypress and consumes the event
146
- protected void fixControlTab () {
146
+ private void fixControlTab () {
147
147
removeCTRLTabFromFocusTraversal ();
148
148
149
149
removeCTRLSHIFTTabFromFocusTraversal ();
150
150
}
151
151
152
152
private void removeCTRLSHIFTTabFromFocusTraversal () {
153
153
KeyStroke ctrlShiftTab = KeyStroke .getKeyStroke ("ctrl shift TAB" );
154
- Set <AWTKeyStroke > backwardKeys = new HashSet <AWTKeyStroke >(this .getFocusTraversalKeys (KeyboardFocusManager .BACKWARD_TRAVERSAL_KEYS ));
154
+ Set <AWTKeyStroke > backwardKeys = new HashSet <>(this .getFocusTraversalKeys (KeyboardFocusManager .BACKWARD_TRAVERSAL_KEYS ));
155
155
backwardKeys .remove (ctrlShiftTab );
156
156
}
157
157
158
158
private void removeCTRLTabFromFocusTraversal () {
159
159
KeyStroke ctrlTab = KeyStroke .getKeyStroke ("ctrl TAB" );
160
- Set <AWTKeyStroke > forwardKeys = new HashSet <AWTKeyStroke >(this .getFocusTraversalKeys (KeyboardFocusManager .FORWARD_TRAVERSAL_KEYS ));
160
+ Set <AWTKeyStroke > forwardKeys = new HashSet <>(this .getFocusTraversalKeys (KeyboardFocusManager .FORWARD_TRAVERSAL_KEYS ));
161
161
forwardKeys .remove (ctrlTab );
162
162
this .setFocusTraversalKeys (KeyboardFocusManager .FORWARD_TRAVERSAL_KEYS , forwardKeys );
163
163
}
164
164
165
165
166
- @ Override
167
- public void select (int selectionStart , int selectionEnd ) {
168
- super .select (selectionStart , selectionEnd );
169
- }
170
-
171
166
public boolean isSelectionActive () {
172
167
return this .getSelectedText () != null ;
173
168
}
@@ -221,17 +216,6 @@ public void switchDocument(Document document, UndoManager newUndo) {
221
216
222
217
}
223
218
224
- @ Override
225
- protected JPopupMenu createPopupMenu () {
226
- JPopupMenu menu = super .createPopupMenu ();
227
- return menu ;
228
- }
229
-
230
- @ Override
231
- protected void configurePopupMenu (JPopupMenu popupMenu ) {
232
- super .configurePopupMenu (popupMenu );
233
- }
234
-
235
219
@ Override
236
220
protected RTAMouseListener createMouseListener () {
237
221
return new SketchTextAreaMouseListener (this );
@@ -242,7 +226,7 @@ public void getTextLine(int line, Segment segment) {
242
226
int offset = getLineStartOffset (line );
243
227
int end = getLineEndOffset (line );
244
228
getDocument ().getText (offset , end - offset , segment );
245
- } catch (BadLocationException e ) {
229
+ } catch (BadLocationException ignored ) {
246
230
}
247
231
}
248
232
@@ -271,16 +255,16 @@ public DocLinkGenerator(PdeKeywords pdeKeywords) {
271
255
272
256
@ Override
273
257
public LinkGeneratorResult isLinkAtOffset (RSyntaxTextArea textArea , final int offs ) {
258
+ Token token = textArea .modelToToken (offs );
259
+ if (token == null ) {
260
+ return null ;
261
+ }
274
262
275
- final Token token = textArea .modelToToken (offs );
276
-
277
- final String reference = pdeKeywords .getReference (token .getLexeme ());
278
-
279
- // LOG.fine("reference: " + reference + ", match: " + (token.getType() == TokenTypes.DATA_TYPE || token.getType() == TokenTypes.VARIABLE || token.getType() == TokenTypes.FUNCTION));
263
+ String reference = pdeKeywords .getReference (token .getLexeme ());
280
264
281
- if (token != null && ( reference != null || (token .getType () == TokenTypes .DATA_TYPE || token .getType () == TokenTypes .VARIABLE || token .getType () == TokenTypes .FUNCTION ) )) {
265
+ if (reference != null || (token .getType () == TokenTypes .DATA_TYPE || token .getType () == TokenTypes .VARIABLE || token .getType () == TokenTypes .FUNCTION )) {
282
266
283
- LinkGeneratorResult generatorResult = new LinkGeneratorResult () {
267
+ return new LinkGeneratorResult () {
284
268
285
269
@ Override
286
270
public int getSourceOffset () {
@@ -297,8 +281,6 @@ public HyperlinkEvent execute() {
297
281
return null ;
298
282
}
299
283
};
300
-
301
- return generatorResult ;
302
284
}
303
285
304
286
return null ;
@@ -316,7 +298,7 @@ private class SketchTextAreaMouseListener extends RTextAreaMutableCaretEvent {
316
298
private boolean isScanningForLinks ;
317
299
private int hoveredOverLinkOffset = -1 ;
318
300
319
- protected SketchTextAreaMouseListener (RTextArea textArea ) {
301
+ SketchTextAreaMouseListener (RTextArea textArea ) {
320
302
super (textArea );
321
303
insets = new Insets (0 , 0 , 0 , 0 );
322
304
}
@@ -458,7 +440,7 @@ private void stopScanningForLinks() {
458
440
if (isScanningForLinks ) {
459
441
Cursor c = getCursor ();
460
442
isScanningForLinks = false ;
461
- if (c != null && c .getType () == Cursor .HAND_CURSOR ) {
443
+ if (c .getType () == Cursor .HAND_CURSOR ) {
462
444
setCursor (Cursor .getPredefinedCursor (Cursor .TEXT_CURSOR ));
463
445
repaint (); // TODO: Repaint just the affected line.
464
446
}
0 commit comments