Skip to content

Commit

Permalink
Don't transfer import source ranges to static properties or method calls
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Jun 13, 2019
1 parent 1011a53 commit 2eea884
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,10 @@ private Expression findStaticMethodImportFromModule(Expression method, Expressio
if (expression != null) return expression;
expression = findStaticPropertyAccessorGivenArgs(importNode.getType(), getPropNameForAccessor(importNode.getFieldName()), args);
if (expression != null) {
return new StaticMethodCallExpression(importNode.getType(), importNode.getFieldName(), args);
// GRECLIPSE edit
//return new StaticMethodCallExpression(importNode.getType(), importNode.getFieldName(), args);
return newStaticMethodCallX(importNode.getType(), importNode.getFieldName(), args);
// GRECLIPSE end
}
}
// look for one of these:
Expand All @@ -509,7 +512,10 @@ private Expression findStaticMethodImportFromModule(Expression method, Expressio
if (expression != null) return expression;
expression = findStaticPropertyAccessorGivenArgs(importNode.getType(), importNode.getFieldName(), args);
if (expression != null) {
return new StaticMethodCallExpression(importNode.getType(), prefix(name) + capitalize(importNode.getFieldName()), args);
// GRECLIPSE edit
//return new StaticMethodCallExpression(importNode.getType(), prefix(name) + capitalize(importNode.getFieldName()), args);
return newStaticMethodCallX(importNode.getType(), prefix(name) + capitalize(importNode.getFieldName()), args);
// GRECLIPSE end
}
}
}
Expand All @@ -527,7 +533,10 @@ private Expression findStaticMethodImportFromModule(Expression method, Expressio
if (expression != null) return expression;
expression = findStaticPropertyAccessorGivenArgs(starImportType, getPropNameForAccessor(name), args);
if (expression != null) {
return new StaticMethodCallExpression(starImportType, name, args);
// GRECLIPSE edit
//return new StaticMethodCallExpression(starImportType, name, args);
return newStaticMethodCallX(starImportType, name, args);
// GRECLIPSE end
}
}
}
Expand Down Expand Up @@ -567,9 +576,15 @@ private Expression findStaticPropertyAccessor(ClassNode staticImportType, String
if (accessor == null && hasStaticProperty(staticImportType, propName)) {
// args will be replaced
if (inLeftExpression)
accessor = new StaticMethodCallExpression(staticImportType, accessorName, ArgumentListExpression.EMPTY_ARGUMENTS);
// GRECLIPSE edit
//accessor = new StaticMethodCallExpression(staticImportType, accessorName, ArgumentListExpression.EMPTY_ARGUMENTS);
accessor = newStaticMethodCallX(staticImportType, accessorName, ArgumentListExpression.EMPTY_ARGUMENTS);
// GRECLIPSE end
else
accessor = new PropertyExpression(new ClassExpression(staticImportType), propName);
// GRECLIPSE edit
//accessor = new PropertyExpression(new ClassExpression(staticImportType), propName);
accessor = newStaticPropertyX(staticImportType, propName);
// GRECLIPSE end
}
return accessor;
}
Expand Down Expand Up @@ -600,7 +615,10 @@ private static Expression findStaticField(ClassNode staticImportType, String fie
if (staticImportType.isPrimaryClassNode() || staticImportType.isResolved()) {
FieldNode field = getField(staticImportType, fieldName);
if (field != null && field.isStatic())
return new PropertyExpression(new ClassExpression(staticImportType), fieldName);
// GRECLIPSE edit
//return new PropertyExpression(new ClassExpression(staticImportType), fieldName);
return newStaticPropertyX(staticImportType, fieldName);
// GRECLIPSE end
}
return null;
}
Expand All @@ -626,12 +644,25 @@ private static FieldNode getField(ClassNode classNode, String fieldName) {
private static Expression findStaticMethod(ClassNode staticImportType, String methodName, Expression args) {
if (staticImportType.isPrimaryClassNode() || staticImportType.isResolved()) {
if (staticImportType.hasPossibleStaticMethod(methodName, args)) {
return new StaticMethodCallExpression(staticImportType, methodName, args);
// GRECLIPSE edit
//return new StaticMethodCallExpression(staticImportType, methodName, args);
return newStaticMethodCallX(staticImportType, methodName, args);
// GRECLIPSE end
}
}
return null;
}

// GRECLIPSE add
private static PropertyExpression newStaticPropertyX(ClassNode type, String name) {
return new PropertyExpression(new ClassExpression(type.getPlainNodeReference()), name);
}

private static StaticMethodCallExpression newStaticMethodCallX(ClassNode type, String name, Expression args) {
return new StaticMethodCallExpression(type.getPlainNodeReference(), name, args);
}
// GRECLIPSE end

protected SourceUnit getSourceUnit() {
return source;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,10 @@ private Expression findStaticMethodImportFromModule(Expression method, Expressio
if (expression != null) return expression;
expression = findStaticPropertyAccessorGivenArgs(importNode.getType(), getPropNameForAccessor(importNode.getFieldName()), args);
if (expression != null) {
return new StaticMethodCallExpression(importNode.getType(), importNode.getFieldName(), args);
// GRECLIPSE edit
//return new StaticMethodCallExpression(importNode.getType(), importNode.getFieldName(), args);
return newStaticMethodCallX(importNode.getType(), importNode.getFieldName(), args);
// GRECLIPSE end
}
}
// look for one of these:
Expand All @@ -517,7 +520,10 @@ private Expression findStaticMethodImportFromModule(Expression method, Expressio
if (expression != null) return expression;
expression = findStaticPropertyAccessorGivenArgs(importClass, importMember, args);
if (expression != null) {
return new StaticMethodCallExpression(importClass, prefix(name) + capitalize(importMember), args);
// GRECLIPSE edit
//return new StaticMethodCallExpression(importClass, prefix(name) + capitalize(importMember), args);
return newStaticMethodCallX(importClass, prefix(name) + capitalize(importMember), args);
// GRECLIPSE end
}
}
}
Expand All @@ -535,7 +541,10 @@ private Expression findStaticMethodImportFromModule(Expression method, Expressio
if (expression != null) return expression;
expression = findStaticPropertyAccessorGivenArgs(starImportType, getPropNameForAccessor(name), args);
if (expression != null) {
return new StaticMethodCallExpression(starImportType, name, args);
// GRECLIPSE edit
//return new StaticMethodCallExpression(starImportType, name, args);
return newStaticMethodCallX(starImportType, name, args);
// GRECLIPSE end
}
}
}
Expand Down Expand Up @@ -564,9 +573,15 @@ private Expression findStaticPropertyAccessor(ClassNode staticImportType, String
if (accessor == null && hasStaticProperty(staticImportType, propName)) {
// args will be replaced
if (inLeftExpression)
accessor = new StaticMethodCallExpression(staticImportType, accessorName, ArgumentListExpression.EMPTY_ARGUMENTS);
// GRECLIPSE edit
//accessor = new StaticMethodCallExpression(staticImportType, accessorName, ArgumentListExpression.EMPTY_ARGUMENTS);
accessor = newStaticMethodCallX(staticImportType, accessorName, ArgumentListExpression.EMPTY_ARGUMENTS);
// GRECLIPSE end
else
accessor = new PropertyExpression(new ClassExpression(staticImportType), propName);
// GRECLIPSE edit
//accessor = new PropertyExpression(new ClassExpression(staticImportType), propName);
accessor = newStaticPropertyX(staticImportType, propName);
// GRECLIPSE end
}
return accessor;
}
Expand All @@ -582,20 +597,36 @@ private static Expression findStaticField(ClassNode staticImportType, String fie
if (staticImportType.isPrimaryClassNode() || staticImportType.isResolved()) {
FieldNode field = getField(staticImportType, fieldName);
if (field != null && field.isStatic())
return new PropertyExpression(new ClassExpression(staticImportType), fieldName);
// GRECLIPSE edit
//return new PropertyExpression(new ClassExpression(staticImportType), fieldName);
return newStaticPropertyX(staticImportType, fieldName);
// GRECLIPSE end
}
return null;
}

private static Expression findStaticMethod(ClassNode staticImportType, String methodName, Expression args) {
if (staticImportType.isPrimaryClassNode() || staticImportType.isResolved()) {
if (staticImportType.hasPossibleStaticMethod(methodName, args)) {
return new StaticMethodCallExpression(staticImportType, methodName, args);
// GRECLIPSE edit
//return new StaticMethodCallExpression(staticImportType, methodName, args);
return newStaticMethodCallX(staticImportType, methodName, args);
// GRECLIPSE end
}
}
return null;
}

// GRECLIPSE add
private static PropertyExpression newStaticPropertyX(ClassNode type, String name) {
return new PropertyExpression(new ClassExpression(type.getPlainNodeReference()), name);
}

private static StaticMethodCallExpression newStaticMethodCallX(ClassNode type, String name, Expression args) {
return new StaticMethodCallExpression(type.getPlainNodeReference(), name, args);
}
// GRECLIPSE end

protected SourceUnit getSourceUnit() {
return source;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,10 @@ private Expression findStaticMethodImportFromModule(Expression method, Expressio
if (expression != null) return expression;
expression = findStaticPropertyAccessorGivenArgs(importNode.getType(), getPropNameForAccessor(importNode.getFieldName()), args);
if (expression != null) {
return new StaticMethodCallExpression(importNode.getType(), importNode.getFieldName(), args);
// GRECLIPSE edit
//return new StaticMethodCallExpression(importNode.getType(), importNode.getFieldName(), args);
return newStaticMethodCallX(importNode.getType(), importNode.getFieldName(), args);
// GRECLIPSE end
}
}
// look for one of these:
Expand All @@ -517,7 +520,10 @@ private Expression findStaticMethodImportFromModule(Expression method, Expressio
if (expression != null) return expression;
expression = findStaticPropertyAccessorGivenArgs(importClass, importMember, args);
if (expression != null) {
return new StaticMethodCallExpression(importClass, prefix(name) + capitalize(importMember), args);
// GRECLIPSE edit
//return new StaticMethodCallExpression(importClass, prefix(name) + capitalize(importMember), args);
return newStaticMethodCallX(importClass, prefix(name) + capitalize(importMember), args);
// GRECLIPSE end
}
}
}
Expand All @@ -535,7 +541,10 @@ private Expression findStaticMethodImportFromModule(Expression method, Expressio
if (expression != null) return expression;
expression = findStaticPropertyAccessorGivenArgs(starImportType, getPropNameForAccessor(name), args);
if (expression != null) {
return new StaticMethodCallExpression(starImportType, name, args);
// GRECLIPSE edit
//return new StaticMethodCallExpression(starImportType, name, args);
return newStaticMethodCallX(starImportType, name, args);
// GRECLIPSE end
}
}
}
Expand Down Expand Up @@ -564,9 +573,15 @@ private Expression findStaticPropertyAccessor(ClassNode staticImportType, String
if (accessor == null && hasStaticProperty(staticImportType, propName)) {
// args will be replaced
if (inLeftExpression)
accessor = new StaticMethodCallExpression(staticImportType, accessorName, ArgumentListExpression.EMPTY_ARGUMENTS);
// GRECLIPSE edit
//accessor = new StaticMethodCallExpression(staticImportType, accessorName, ArgumentListExpression.EMPTY_ARGUMENTS);
accessor = newStaticMethodCallX(staticImportType, accessorName, ArgumentListExpression.EMPTY_ARGUMENTS);
// GRECLIPSE end
else
accessor = new PropertyExpression(new ClassExpression(staticImportType), propName);
// GRECLIPSE edit
//accessor = new PropertyExpression(new ClassExpression(staticImportType), propName);
accessor = newStaticPropertyX(staticImportType, propName);
// GRECLIPSE end
}
return accessor;
}
Expand All @@ -582,20 +597,36 @@ private static Expression findStaticField(ClassNode staticImportType, String fie
if (staticImportType.isPrimaryClassNode() || staticImportType.isResolved()) {
FieldNode field = getField(staticImportType, fieldName);
if (field != null && field.isStatic())
return new PropertyExpression(new ClassExpression(staticImportType), fieldName);
// GRECLIPSE edit
//return new PropertyExpression(new ClassExpression(staticImportType), fieldName);
return newStaticPropertyX(staticImportType, fieldName);
// GRECLIPSE end
}
return null;
}

private static Expression findStaticMethod(ClassNode staticImportType, String methodName, Expression args) {
if (staticImportType.isPrimaryClassNode() || staticImportType.isResolved()) {
if (staticImportType.hasPossibleStaticMethod(methodName, args)) {
return new StaticMethodCallExpression(staticImportType, methodName, args);
// GRECLIPSE edit
//return new StaticMethodCallExpression(staticImportType, methodName, args);
return newStaticMethodCallX(staticImportType, methodName, args);
// GRECLIPSE end
}
}
return null;
}

// GRECLIPSE add
private static PropertyExpression newStaticPropertyX(ClassNode type, String name) {
return new PropertyExpression(new ClassExpression(type.getPlainNodeReference()), name);
}

private static StaticMethodCallExpression newStaticMethodCallX(ClassNode type, String name, Expression args) {
return new StaticMethodCallExpression(type.getPlainNodeReference(), name, args);
}
// GRECLIPSE end

protected SourceUnit getSourceUnit() {
return source;
}
Expand Down

0 comments on commit 2eea884

Please sign in to comment.