From ef70e3bbca3b387deaeb7e917c4cb8bf69e05c57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Mon, 23 Dec 2024 10:23:32 +0200 Subject: [PATCH] Simplify JavaDoubleClickSelector There is no need to shadow Character methods. Static import them and use directly. --- .../ui/text/java/JavaDoubleClickSelector.java | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaDoubleClickSelector.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaDoubleClickSelector.java index 40cc1b01a45..5007067a2aa 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaDoubleClickSelector.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaDoubleClickSelector.java @@ -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; @@ -28,7 +32,7 @@ public class JavaDoubleClickSelector extends DefaultTextDoubleClickStrategy { /** * Detects java words depending on the source level. In 1.4 mode, detects - * [[:ID:]]*. In 1.5 mode, it also detects + * [[:ID:]]* and * @\s*[[:IDS:]][[:ID:]]*. * * Character class definitions: @@ -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! @@ -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; @@ -185,7 +177,7 @@ private boolean forward(char c, int offset) { fState= WS; return true; } - if (isIdentifierStart(c)) { + if (isJavaIdentifierStart(c)) { fEnd= offset; fState= IDS; return true; @@ -193,25 +185,25 @@ private boolean forward(char c, int offset) { 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;