Search in sources :

Example 1 with AsmCodeGenerator

use of com.intellij.uiDesigner.compiler.AsmCodeGenerator in project intellij-community by JetBrains.

the class AsmCodeGeneratorTest method testIdeadev14081.

public void testIdeadev14081() throws Exception {
    // NOTE: That doesn't really reproduce the bug as it's dependent on a particular instrumentation sequence used during form preview
    // (the nested form is instrumented with a new AsmCodeGenerator instance directly in the middle of instrumentation of the current form)
    final String testDataPath = PluginPathManager.getPluginHomePath("ui-designer") + File.separatorChar + "testData" + File.separatorChar + File.separatorChar + "formEmbedding" + File.separatorChar + "Ideadev14081" + File.separatorChar;
    AsmCodeGenerator embeddedClassGenerator = initCodeGenerator("Embedded.form", "Embedded", testDataPath);
    byte[] embeddedPatchedData = getVerifiedPatchedData(embeddedClassGenerator);
    myClassFinder.addClassDefinition("Embedded", embeddedPatchedData);
    myNestedFormLoader.registerNestedForm("Embedded.form", testDataPath + "Embedded.form");
    AsmCodeGenerator mainClassGenerator = initCodeGenerator("Main.form", "Main", testDataPath);
    byte[] mainPatchedData = getVerifiedPatchedData(mainClassGenerator);
    /*
    FileOutputStream fos = new FileOutputStream("C:\\yole\\FormPreview27447\\MainPatched.class");
    fos.write(mainPatchedData);
    fos.close();
    */
    myClassFinder.addClassDefinition("Main", mainPatchedData);
    final Class mainClass = myClassFinder.getLoader().loadClass("Main");
    Object instance = mainClass.newInstance();
    assert instance != null : mainClass;
}
Also used : AsmCodeGenerator(com.intellij.uiDesigner.compiler.AsmCodeGenerator)

Example 2 with AsmCodeGenerator

use of com.intellij.uiDesigner.compiler.AsmCodeGenerator in project intellij-community by JetBrains.

the class AsmCodeGeneratorTest method testIncompatibleTypeField.

public void testIncompatibleTypeField() throws Exception {
    AsmCodeGenerator generator = initCodeGenerator("TestIncompatibleTypeField.form", "BindingTest");
    assertEquals("Cannot bind: Incompatible types. Cannot assign javax.swing.JPanel to field BindingTest.myStringField", generator.getErrors()[0].getErrorMessage());
}
Also used : AsmCodeGenerator(com.intellij.uiDesigner.compiler.AsmCodeGenerator)

Example 3 with AsmCodeGenerator

use of com.intellij.uiDesigner.compiler.AsmCodeGenerator in project intellij-community by JetBrains.

the class AsmCodeGeneratorTest method testPrimitiveField.

public void testPrimitiveField() throws Exception {
    AsmCodeGenerator generator = initCodeGenerator("TestPrimitiveField.form", "BindingTest");
    assertEquals("Cannot bind: field is of primitive type: BindingTest.myIntField", generator.getErrors()[0].getErrorMessage());
}
Also used : AsmCodeGenerator(com.intellij.uiDesigner.compiler.AsmCodeGenerator)

Example 4 with AsmCodeGenerator

use of com.intellij.uiDesigner.compiler.AsmCodeGenerator in project intellij-community by JetBrains.

the class AsmCodeGeneratorTest method testStaticField.

public void testStaticField() throws Exception {
    AsmCodeGenerator generator = initCodeGenerator("TestStaticField.form", "BindingTest");
    assertEquals("Cannot bind: field is static: BindingTest.myStaticField", generator.getErrors()[0].getErrorMessage());
}
Also used : AsmCodeGenerator(com.intellij.uiDesigner.compiler.AsmCodeGenerator)

Example 5 with AsmCodeGenerator

use of com.intellij.uiDesigner.compiler.AsmCodeGenerator in project intellij-community by JetBrains.

the class AsmCodeGeneratorTest method loadAndPatchClass.

private Class loadAndPatchClass(final String formFileName, final String className) throws Exception {
    final AsmCodeGenerator codeGenerator = initCodeGenerator(formFileName, className);
    byte[] patchedData = getVerifiedPatchedData(codeGenerator);
    /*
    FileOutputStream fos = new FileOutputStream("C:\\yole\\FormPreview27447\\MainPatched.class");
    fos.write(patchedData);
    fos.close();
    */
    myClassFinder.addClassDefinition(className, patchedData);
    return myClassFinder.getLoader().loadClass(className);
}
Also used : AsmCodeGenerator(com.intellij.uiDesigner.compiler.AsmCodeGenerator)

Aggregations

AsmCodeGenerator (com.intellij.uiDesigner.compiler.AsmCodeGenerator)10 PsiClassWriter (com.intellij.compiler.PsiClassWriter)2 FormErrorInfo (com.intellij.uiDesigner.compiler.FormErrorInfo)2 File (java.io.File)2 ClassWriter (org.jetbrains.org.objectweb.asm.ClassWriter)2 FileSetCompileScope (com.intellij.compiler.impl.FileSetCompileScope)1 InstrumentationClassFinder (com.intellij.compiler.instrumentation.InstrumentationClassFinder)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 CodeGenerationException (com.intellij.uiDesigner.compiler.CodeGenerationException)1 LwRootContainer (com.intellij.uiDesigner.lw.LwRootContainer)1 PreviewNestedFormLoader (com.intellij.uiDesigner.make.PreviewNestedFormLoader)1