mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 05:19:41 +00:00
Fixed static access problem for AutocompleteProvider & generally
This commit is contained in:
1 parent
a106343a0e
commit
a5c02e6c94
2 files changed
+14
-4
No files matched your search
@@ -3583,7 +3583,7 @@ public class ScriptDocument {
|
||||
* This is a quick heuristic check - it may have false positives for operators
|
||||
* inside strings, but those are handled by the full parser.
|
||||
*/
|
||||
private boolean containsOperators(String expr) {
|
||||
public boolean containsOperators(String expr) {
|
||||
if (expr == null) return false;
|
||||
|
||||
boolean inString = false;
|
||||
|
||||
+13
-3
@@ -718,15 +718,25 @@ public class TypeResolver {
|
||||
return false;
|
||||
}
|
||||
|
||||
// First check if it's a variable/field (instance access)
|
||||
// If the identifier contains dots, parentheses, brackets, or operators, it's a complex expression
|
||||
// Complex expressions (method calls, field chains, arithmetic) are instance access by default
|
||||
if (identifier.contains(".") || identifier.contains("(") || identifier.contains("[") ||
|
||||
document.containsOperators(identifier)) {
|
||||
// For complex expressions, resolve as expression and check the result type
|
||||
TypeInfo exprType = document.resolveExpressionType(identifier, position);
|
||||
// Only static if the expression result is itself a ClassTypeInfo (e.g., Java.type("File"))
|
||||
return isStaticAccess(exprType, false);
|
||||
}
|
||||
|
||||
// Simple identifier - check if it's a variable/field (instance access)
|
||||
FieldInfo fieldInfo = document.resolveVariable(identifier, position);
|
||||
if (fieldInfo != null && fieldInfo.isResolved()) {
|
||||
// It's a variable - check if its type is a ClassTypeInfo
|
||||
return isStaticAccess(fieldInfo.getTypeInfo(), false);
|
||||
}
|
||||
|
||||
// Not a variable - check if it's a type name
|
||||
TypeInfo typeCheck = document.resolveExpressionType(identifier,position);
|
||||
// Not a variable - check if it's a type name by trying to resolve as type
|
||||
TypeInfo typeCheck = document.resolveType(identifier);
|
||||
boolean isType = typeCheck != null && typeCheck.isResolved();
|
||||
return isStaticAccess(typeCheck, isType);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user