Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNodeMatchKind.java')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNodeMatchKind.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNodeMatchKind.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNodeMatchKind.java
index ff4a186f9d3..20acf3266c5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNodeMatchKind.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNodeMatchKind.java
@@ -48,12 +48,18 @@ public class ASTNodeMatchKind {
* Returns whether the node matches the selection.
*/
public boolean matches(ASTNode node, int selOffset, int selLength) {
- if (fNamesOnly && node instanceof IASTName == false) {
- return false;
- }
-
- final int nodeOffset= node.getOffset();
- final int nodeLength= node.getLength();
+ return isAcceptableNode(node) && rangeMatches(node.getOffset(), node.getLength(), selOffset, selLength);
+ }
+
+ public boolean isAcceptableNode(ASTNode astNode) {
+ return !fNamesOnly || astNode instanceof IASTName;
+ }
+
+ /**
+ * Returns whether the node range matches the selection.
+ */
+ public boolean rangeMatches(final int nodeOffset, final int nodeLength, int selOffset,
+ int selLength) {
switch(fRelation) {
case EXACT:
return selOffset == nodeOffset && selLength == nodeLength;
@@ -63,7 +69,7 @@ public class ASTNodeMatchKind {
return nodeOffset <= selOffset && selOffset+selLength <= nodeOffset+nodeLength;
default:
assert false;
- return false;
+ return false;
}
}

Back to the top