aboutsummaryrefslogtreecommitdiff
path: root/src/eclipseAgent/lombok/launch
diff options
context:
space:
mode:
Diffstat (limited to 'src/eclipseAgent/lombok/launch')
-rwxr-xr-xsrc/eclipseAgent/lombok/launch/PatchFixesHider.java40
1 files changed, 36 insertions, 4 deletions
diff --git a/src/eclipseAgent/lombok/launch/PatchFixesHider.java b/src/eclipseAgent/lombok/launch/PatchFixesHider.java
index 64e90db5..a2cda66c 100755
--- a/src/eclipseAgent/lombok/launch/PatchFixesHider.java
+++ b/src/eclipseAgent/lombok/launch/PatchFixesHider.java
@@ -35,12 +35,13 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IAnnotatable;
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IJavaElement;
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.dom.Type;
import org.eclipse.jdt.core.search.SearchMatch;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
@@ -51,6 +52,7 @@ import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ForeachStatement;
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.Scope;
@@ -192,15 +194,21 @@ final class PatchFixesHider {
/** Contains patch code to support {@code @Delegate} */
public static final class Delegate {
private static final Method HANDLE_DELEGATE_FOR_TYPE;
+ private static final Method GET_CHILDREN;
static {
Class<?> shadowed = Util.shadowLoadClass("lombok.eclipse.agent.PatchDelegatePortal");
HANDLE_DELEGATE_FOR_TYPE = Util.findMethod(shadowed, "handleDelegateForType", Object.class);
+ GET_CHILDREN = Util.findMethod(shadowed, "getChildren", Object.class, Object.class);
}
public static boolean handleDelegateForType(Object classScope) {
return (Boolean) Util.invokeMethod(HANDLE_DELEGATE_FOR_TYPE, classScope);
}
+
+ public static Object[] getChildren(Object returnValue, Object javaElement) {
+ return (Object[]) Util.invokeMethod(GET_CHILDREN, returnValue, javaElement);
+ }
}
/** Contains patch code to support {@code val} (eclipse specific) */
@@ -304,6 +312,26 @@ final class PatchFixesHider {
}
}
+ /** Contains patch code to support Javadoc for generated methods */
+ public static final class Javadoc {
+ private static final Method GET_HTML;
+ private static final Method PRINT_METHOD;
+
+ static {
+ Class<?> shadowed = Util.shadowLoadClass("lombok.eclipse.agent.PatchJavadoc");
+ GET_HTML = Util.findMethod(shadowed, "getHTMLContentFromSource", String.class, IJavaElement.class);
+ PRINT_METHOD = Util.findMethod(shadowed, "printMethod", AbstractMethodDeclaration.class, Integer.class, StringBuffer.class, TypeDeclaration.class);
+ }
+
+ public static String getHTMLContentFromSource(String original, IJavaElement member) {
+ return (String) Util.invokeMethod(GET_HTML, original, member);
+ }
+
+ public static StringBuffer printMethod(AbstractMethodDeclaration methodDeclaration, int tab, StringBuffer output, TypeDeclaration type) {
+ return (StringBuffer) Util.invokeMethod(PRINT_METHOD, methodDeclaration, tab, output, type);
+ }
+ }
+
/**
* Contains a mix of methods: ecj only, ecj+eclipse, and eclipse only. As a consequence, _EVERY_ method from here used for ecj MUST be
* transplanted, as ecj itself cannot load this class (signatures refer to things that don't exist in ecj-only mode).
@@ -504,6 +532,10 @@ final class PatchFixesHider {
return original == -1 ? end : original;
}
+ public static int fixRetrieveStartBlockPosition(int original, int start) {
+ return original == -1 ? start : original;
+ }
+
public static int fixRetrieveRightBraceOrSemiColonPosition(int original, int end) {
// if (original == -1) {
// Thread.dumpStack();
@@ -525,9 +557,9 @@ 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;
+ public static int fixRetrieveProperRightBracketPosition(int retVal, Type type) {
+ if (retVal != -1 || type == null) return retVal;
+ if (isGenerated(type)) return type.getStartPosition() + type.getLength() - 1;
return -1;
}