aboutsummaryrefslogtreecommitdiff
path: root/src/eclipseAgent
diff options
context:
space:
mode:
authorRawi01 <Rawi01@users.noreply.github.com>2020-04-14 09:15:31 +0200
committerRawi01 <Rawi01@users.noreply.github.com>2020-04-14 09:22:10 +0200
commit91cd859b72c89a47bbe145c00a9e7c1b20a5e657 (patch)
tree955470f3bed9c4f2a17f1c8f9b4049cdecf90ff3 /src/eclipseAgent
parent94440a8bd73f176637a9890dc10df67d26615674 (diff)
downloadlombok-91cd859b72c89a47bbe145c00a9e7c1b20a5e657.tar.gz
lombok-91cd859b72c89a47bbe145c00a9e7c1b20a5e657.tar.bz2
lombok-91cd859b72c89a47bbe145c00a9e7c1b20a5e657.zip
[fixes #2286] Set source range for vararg arrays
Diffstat (limited to 'src/eclipseAgent')
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java11
-rwxr-xr-xsrc/eclipseAgent/lombok/launch/PatchFixesHider.java7
2 files changed, 18 insertions, 0 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
index 756c23fa..95d42c2c 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
@@ -103,6 +103,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
patchIdentifierEndReparse(sm);
patchRetrieveEllipsisStartPosition(sm);
patchRetrieveRightBraceOrSemiColonPosition(sm);
+ patchRetrieveProperRightBracketPosition(sm);
patchSetGeneratedFlag(sm);
patchDomAstReparseIssues(sm);
patchHideGeneratedNodes(sm);
@@ -445,6 +446,16 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
// .transplant().request(StackRequest.RETURN_VALUE, StackRequest.PARAM2).build());
}
+ private static void patchRetrieveProperRightBracketPosition(ScriptManager sm) {
+ sm.addScript(ScriptBuilder.wrapMethodCall()
+ .target(new MethodTarget("org.eclipse.jdt.core.dom.ASTConverter", "extractSubArrayType", "org.eclipse.jdt.core.dom.ArrayType", "org.eclipse.jdt.core.dom.ArrayType", "int", "int"))
+ .methodToWrap(new Hook("org.eclipse.jdt.core.dom.ASTConverter", "retrieveProperRightBracketPosition", "int", "int", "int"))
+ .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "fixRetrieveProperRightBracketPosition", "int", "int", "org.eclipse.jdt.core.dom.ArrayType"))
+ .requestExtra(StackRequest.PARAM1)
+ .transplant()
+ .build());
+ }
+
private static void patchSetGeneratedFlag(ScriptManager sm) {
sm.addScript(ScriptBuilder.addField()
.targetClass("org.eclipse.jdt.internal.compiler.ast.ASTNode")
diff --git a/src/eclipseAgent/lombok/launch/PatchFixesHider.java b/src/eclipseAgent/lombok/launch/PatchFixesHider.java
index 563beab1..deab0be1 100755
--- a/src/eclipseAgent/lombok/launch/PatchFixesHider.java
+++ b/src/eclipseAgent/lombok/launch/PatchFixesHider.java
@@ -38,6 +38,7 @@ import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.dom.ArrayType;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.search.SearchMatch;
@@ -517,6 +518,12 @@ final class PatchFixesHider {
return -1;
}
+ public static int fixRetrieveProperRightBracketPosition(int retVal, ArrayType arrayType) {
+ if (retVal != -1 || arrayType == null) return retVal;
+ if (isGenerated(arrayType)) return arrayType.getStartPosition() + arrayType.getLength() - 1;
+ return -1;
+ }
+
public static final int ALREADY_PROCESSED_FLAG = 0x800000; //Bit 24
public static boolean checkBit24(Object node) throws Exception {