Search in sources :

Example 1 with Filter

use of lombok.patcher.Filter in project lombok by rzwitserloot.

the class EclipsePatcher method registerPatchScripts.

private static void registerPatchScripts(Instrumentation instrumentation, boolean reloadExistingClasses, boolean ecjOnly, Class<?> launchingContext) {
    ScriptManager sm = new ScriptManager();
    sm.registerTransformer(instrumentation);
    sm.setFilter(new Filter() {

        @Override
        public boolean shouldTransform(ClassLoader loader, String className, Class<?> classBeingDefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) {
            if (!(loader instanceof URLClassLoader))
                return true;
            ClassLoader parent = loader.getParent();
            if (parent == null)
                return true;
            return !parent.getClass().getName().startsWith("org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader");
        }
    });
    final boolean forceBaseResourceNames = !"".equals(System.getProperty("shadow.override.lombok", ""));
    sm.setTransplantMapper(new TransplantMapper() {

        public String mapResourceName(int classFileFormatVersion, String resourceName) {
            if (classFileFormatVersion < 50 || forceBaseResourceNames)
                return resourceName;
            return "Class50/" + resourceName;
        }
    });
    if (!ecjOnly) {
        EclipseLoaderPatcher.patchEquinoxLoaders(sm, launchingContext);
        patchCatchReparse(sm);
        patchIdentifierEndReparse(sm);
        patchRetrieveEllipsisStartPosition(sm);
        patchRetrieveRightBraceOrSemiColonPosition(sm);
        patchSetGeneratedFlag(sm);
        patchDomAstReparseIssues(sm);
        patchHideGeneratedNodes(sm);
        patchPostCompileHookEclipse(sm);
        patchFixSourceTypeConverter(sm);
        patchDisableLombokForCodeFormatterAndCleanup(sm);
        patchListRewriteHandleGeneratedMethods(sm);
        patchSyntaxAndOccurrencesHighlighting(sm);
        patchSortMembersOperation(sm);
        patchExtractInterface(sm);
        patchAboutDialog(sm);
        patchEclipseDebugPatches(sm);
    } else {
        patchPostCompileHookEcj(sm);
    }
    patchAvoidReparsingGeneratedCode(sm);
    patchLombokizeAST(sm);
    patchEcjTransformers(sm, ecjOnly);
    patchExtensionMethod(sm, ecjOnly);
    patchRenameField(sm);
    if (reloadExistingClasses)
        sm.reloadClasses(instrumentation);
}
Also used : ProtectionDomain(java.security.ProtectionDomain) Filter(lombok.patcher.Filter) TransplantMapper(lombok.patcher.TransplantMapper) URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader) ScriptManager(lombok.patcher.ScriptManager)

Aggregations

URLClassLoader (java.net.URLClassLoader)1 ProtectionDomain (java.security.ProtectionDomain)1 Filter (lombok.patcher.Filter)1 ScriptManager (lombok.patcher.ScriptManager)1 TransplantMapper (lombok.patcher.TransplantMapper)1