Skip to content

Commit 5c5304c

Browse files
committed
move number recognition from RobotLexer to ResolverUtils, so it can work with variable name start with digit
1 parent d31baff commit 5c5304c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/com/millennialmedia/intellibot/psi/RobotLexer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,9 @@ private boolean isVariable(int position) {
343343
// potential start of variable
344344
if (isVariableStart(position)) {
345345
position += 2;
346-
if (isNumber(position))
347-
return false;
346+
// move number judgement in ResolveUtils
347+
// if (isNumber(position))
348+
// return false;
348349
int count = 1;
349350
while (count > 0 && position < this.endOffset && position >= 0) {
350351
if (isVariableEnd(position)) {

src/com/millennialmedia/intellibot/psi/ref/ResolverUtils.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public static PsiElement resolveKeywordFromFile(@Nullable String keywordText, @N
5555
}
5656

5757
private static final Pattern VARIABLE_BASENAME = Pattern.compile("([\\$\\@\\%\\&]\\{[a-zA-Z0-9 _]+)[^a-zA-Z0-9 _}].*");
58+
private static final Pattern VARIABLE_IS_NUMBER = Pattern.compile("\\$\\{[-+]?[0-9.]+\\b.*");
59+
5860
@Nullable
5961
public static PsiElement resolveVariableFromFile(@Nullable String variableText, @Nullable PsiFile file) {
6062
if (variableText == null) {
@@ -143,6 +145,10 @@ public static PsiElement resolveVariableFromStatement(@Nullable String variableT
143145
}
144146
}
145147
}
148+
if (VARIABLE_IS_NUMBER.matcher(variableText).matches()) {
149+
// just return something, for number it don't need resolving
150+
return parent;
151+
}
146152
return null;
147153
}
148154

0 commit comments

Comments
 (0)