Skip to content

Commit

Permalink
Simplify JavaDoubleClickSelector
Browse files Browse the repository at this point in the history
There is no need to shadow Character methods. Static import them and use
directly.
  • Loading branch information
akurtakov committed Dec 23, 2024
1 parent 3d1afea commit ef70e3b
Showing 1 changed file with 14 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text.java;

import static java.lang.Character.isJavaIdentifierPart;
import static java.lang.Character.isJavaIdentifierStart;
import static java.lang.Character.isWhitespace;

import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DefaultTextDoubleClickStrategy;
import org.eclipse.jface.text.IDocument;
Expand All @@ -28,7 +32,7 @@ public class JavaDoubleClickSelector extends DefaultTextDoubleClickStrategy {

/**
* Detects java words depending on the source level. In 1.4 mode, detects
* <code>[[:ID:]]*</code>. In 1.5 mode, it also detects
* <code>[[:ID:]]*</code> and
* <code>@\s*[[:IDS:]][[:ID:]]*</code>.
*
* Character class definitions:
Expand Down Expand Up @@ -87,18 +91,6 @@ private boolean isAt(char c) {
return c == '@';
}

private boolean isIdentifierStart(char c) {
return Character.isJavaIdentifierStart(c);
}

private boolean isIdentifierPart(char c) {
return Character.isJavaIdentifierPart(c);
}

private boolean isWhitespace(char c) {
return Character.isWhitespace(c);
}

/**
* Try to add a character to the word going backward. Only call after
* forward calls!
Expand All @@ -121,24 +113,24 @@ private boolean backward(char c, int offset) {
fState= WS;
return true;
}
if (isIdentifierStart(c)) {
if (isJavaIdentifierStart(c)) {
fStart= offset;
fState= IDS;
return true;
}
if (isIdentifierPart(c)) {
if (isJavaIdentifierPart(c)) {
fStart= offset;
fState= ID;
return true;
}
return false;
case ID:
if (isIdentifierStart(c)) {
if (isJavaIdentifierStart(c)) {
fStart= offset;
fState= IDS;
return true;
}
if (isIdentifierPart(c)) {
if (isJavaIdentifierPart(c)) {
fStart= offset;
fState= ID;
return true;
Expand Down Expand Up @@ -185,33 +177,33 @@ private boolean forward(char c, int offset) {
fState= WS;
return true;
}
if (isIdentifierStart(c)) {
if (isJavaIdentifierStart(c)) {
fEnd= offset;
fState= IDS;
return true;
}
return false;
case IDS:
case ID:
if (isIdentifierStart(c)) {
if (isJavaIdentifierStart(c)) {
fEnd= offset;
fState= IDS;
return true;
}
if (isIdentifierPart(c)) {
if (isJavaIdentifierPart(c)) {
fEnd= offset;
fState= ID;
return true;
}
return false;
case UNKNOWN:
if (isIdentifierStart(c)) {
if (isJavaIdentifierStart(c)) {
fEnd= offset;
fState= IDS;
fAnchorState= fState;
return true;
}
if (isIdentifierPart(c)) {
if (isJavaIdentifierPart(c)) {
fEnd= offset;
fState= ID;
fAnchorState= fState;
Expand Down

0 comments on commit ef70e3b

Please sign in to comment.