Search in sources :

Example 6 with InstrumentationClassFinder

use of com.intellij.compiler.instrumentation.InstrumentationClassFinder in project intellij-community by JetBrains.

the class ClassProcessingBuilder method createInstrumentationClassFinder.

// utility methods
public static InstrumentationClassFinder createInstrumentationClassFinder(@Nullable JpsSdk<?> sdk, Collection<File> platformCp, Collection<File> cp, final OutputConsumer outputConsumer) throws MalformedURLException {
    final URL[] platformUrls;
    int index = 0;
    if (sdk != null && JpsJavaSdkType.getJavaVersion(sdk) >= 9) {
        platformUrls = new URL[1 + platformCp.size()];
        platformUrls[index++] = InstrumentationClassFinder.createJDKPlatformUrl(sdk.getHomePath());
    } else {
        platformUrls = new URL[platformCp.size()];
    }
    for (File file : platformCp) {
        platformUrls[index++] = file.toURI().toURL();
    }
    final URL[] urls = new URL[cp.size()];
    index = 0;
    for (File file : cp) {
        urls[index++] = file.toURI().toURL();
    }
    return new InstrumentationClassFinder(platformUrls, urls) {

        protected InputStream lookupClassBeforeClasspath(String internalClassName) {
            final BinaryContent content = outputConsumer.lookupClassBytes(internalClassName.replace("/", "."));
            if (content != null) {
                return new ByteArrayInputStream(content.getBuffer(), content.getOffset(), content.getLength());
            }
            return null;
        }
    };
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InstrumentationClassFinder(com.intellij.compiler.instrumentation.InstrumentationClassFinder) File(java.io.File) URL(java.net.URL)

Aggregations

InstrumentationClassFinder (com.intellij.compiler.instrumentation.InstrumentationClassFinder)6 File (java.io.File)3 ProgressMessage (org.jetbrains.jps.incremental.messages.ProgressMessage)2 JpsDummyElement (org.jetbrains.jps.model.JpsDummyElement)2 PsiClassWriter (com.intellij.compiler.PsiClassWriter)1 FileSetCompileScope (com.intellij.compiler.impl.FileSetCompileScope)1 CantRunException (com.intellij.execution.CantRunException)1 ExecutionException (com.intellij.execution.ExecutionException)1 PropertiesReferenceManager (com.intellij.lang.properties.PropertiesReferenceManager)1 PropertiesFile (com.intellij.lang.properties.psi.PropertiesFile)1 CompileContext (com.intellij.openapi.compiler.CompileContext)1 CompileStatusNotification (com.intellij.openapi.compiler.CompileStatusNotification)1 Document (com.intellij.openapi.editor.Document)1 Module (com.intellij.openapi.module.Module)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 FormEditingUtil (com.intellij.uiDesigner.FormEditingUtil)1 AsmCodeGenerator (com.intellij.uiDesigner.compiler.AsmCodeGenerator)1 FormErrorInfo (com.intellij.uiDesigner.compiler.FormErrorInfo)1 GridConstraints (com.intellij.uiDesigner.core.GridConstraints)1 PreviewNestedFormLoader (com.intellij.uiDesigner.make.PreviewNestedFormLoader)1