Java 类com.intellij.uiDesigner.compiler.FormErrorInfo 实例源码

项目:intellij-ce-playground    文件:PreviewNestedFormLoader.java   
private void generateStubClass(final LwRootContainer rootContainer, final String generatedClassName) throws IOException,
                                                                                                            CodeGenerationException {
  @NonNls ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
  cw.visit(Opcodes.V1_1, Opcodes.ACC_PUBLIC, generatedClassName, null, "java/lang/Object", ArrayUtil.EMPTY_STRING_ARRAY);

  cw.visitField(Opcodes.ACC_PUBLIC, PreviewFormAction.PREVIEW_BINDING_FIELD, "Ljavax/swing/JComponent;", null, null);

  @NonNls MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
  mv.visitCode();
  mv.visitVarInsn(Opcodes.ALOAD, 0);
  mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
  mv.visitInsn(Opcodes.RETURN);
  mv.visitMaxs(1, 1);
  mv.visitEnd();

  cw.visitEnd();

  ByteArrayInputStream bais = new ByteArrayInputStream(cw.toByteArray());
  AsmCodeGenerator acg = new AsmCodeGenerator(rootContainer, myFinder, this, true, new PsiClassWriter(myModule));
  byte[] data = acg.patchClass(bais);
  FormErrorInfo[] errors = acg.getErrors();
  if (errors.length > 0) {
    throw new CodeGenerationException(errors [0].getComponentId(), errors [0].getErrorMessage());
  }

  FileOutputStream fos = new FileOutputStream(new File(myTempPath, generatedClassName + ".class"));
  try {
    fos.write(data);
  }
  finally {
    fos.close();
  }
}
项目:intellij-ce-playground    文件:Form2SourceCompiler.java   
private static void addError(final CompileContext context, final FormErrorInfo e, final VirtualFile formFile) {
  if (formFile != null) {
    FormElementNavigatable navigatable = new FormElementNavigatable(context.getProject(), formFile, e.getComponentId());
    context.addMessage(CompilerMessageCategory.ERROR,
                       formFile.getPresentableUrl() + ": " + e.getErrorMessage(), 
                       formFile.getUrl(), -1, -1, navigatable);
  }
  else {
    context.addMessage(CompilerMessageCategory.ERROR, e.getErrorMessage(), null, -1, -1);
  }
}
项目:intellij-ce-playground    文件:AsmCodeGeneratorTest.java   
private static byte[] getVerifiedPatchedData(final AsmCodeGenerator codeGenerator) {
  byte[] patchedData = codeGenerator.getPatchedData();
  FormErrorInfo[] errors = codeGenerator.getErrors();
  FormErrorInfo[] warnings = codeGenerator.getWarnings();
  if (errors.length == 0 && warnings.length == 0) {
    assertNotNull("Class patching failed but no errors or warnings were returned", patchedData);
  }
  else if (errors.length > 0) {
    assertTrue(errors[0].getErrorMessage(), false);
  }
  else {
    assertTrue(warnings[0].getErrorMessage(), false);
  }
  return patchedData;
}
项目:tools-idea    文件:Form2ByteCodeCompiler.java   
private static void addMessage(final CompileContext context,
                        final FormErrorInfo e,
                        final VirtualFile formFile,
                        final CompilerMessageCategory severity) {
  if (formFile != null) {
    FormElementNavigatable navigatable = new FormElementNavigatable(context.getProject(), formFile, e.getComponentId());
    context.addMessage(severity,
                       formFile.getPresentableUrl() + ": " + e.getErrorMessage(),
                       formFile.getUrl(), -1, -1, navigatable);
  }
  else {
    context.addMessage(severity, e.getErrorMessage(), null, -1, -1);
  }
}
项目:tools-idea    文件:PreviewNestedFormLoader.java   
private void generateStubClass(final LwRootContainer rootContainer, final String generatedClassName) throws IOException,
                                                                                                            CodeGenerationException {
  @NonNls ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
  cw.visit(Opcodes.V1_1, Opcodes.ACC_PUBLIC, generatedClassName, null, "java/lang/Object", ArrayUtil.EMPTY_STRING_ARRAY);

  cw.visitField(Opcodes.ACC_PUBLIC, PreviewFormAction.PREVIEW_BINDING_FIELD, "Ljavax/swing/JComponent;", null, null);

  @NonNls MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
  mv.visitCode();
  mv.visitVarInsn(Opcodes.ALOAD, 0);
  mv.visitMethodInsn(Opcodes.INVOKESPECIAL,
          "java/lang/Object",
          "<init>",
          "()V");
  mv.visitInsn(Opcodes.RETURN);
  mv.visitMaxs(1, 1);
  mv.visitEnd();

  cw.visitEnd();

  ByteArrayInputStream bais = new ByteArrayInputStream(cw.toByteArray());
  AsmCodeGenerator acg = new AsmCodeGenerator(rootContainer, myFinder, this, true, new PsiClassWriter(myModule));
  byte[] data = acg.patchClass(bais);
  FormErrorInfo[] errors = acg.getErrors();
  if (errors.length > 0) {
    throw new CodeGenerationException(errors [0].getComponentId(), errors [0].getErrorMessage());
  }

  FileOutputStream fos = new FileOutputStream(new File(myTempPath, generatedClassName + ".class"));
  try {
    fos.write(data);
  }
  finally {
    fos.close();
  }
}
项目:tools-idea    文件:Form2SourceCompiler.java   
private static void addError(final CompileContext context, final FormErrorInfo e, final VirtualFile formFile) {
  if (formFile != null) {
    FormElementNavigatable navigatable = new FormElementNavigatable(context.getProject(), formFile, e.getComponentId());
    context.addMessage(CompilerMessageCategory.ERROR,
                       formFile.getPresentableUrl() + ": " + e.getErrorMessage(), 
                       formFile.getUrl(), -1, -1, navigatable);
  }
  else {
    context.addMessage(CompilerMessageCategory.ERROR, e.getErrorMessage(), null, -1, -1);
  }
}
项目:tools-idea    文件:AsmCodeGeneratorTest.java   
private static byte[] getVerifiedPatchedData(final AsmCodeGenerator codeGenerator) {
  byte[] patchedData = codeGenerator.getPatchedData();
  FormErrorInfo[] errors = codeGenerator.getErrors();
  FormErrorInfo[] warnings = codeGenerator.getWarnings();
  if (errors.length == 0 && warnings.length == 0) {
    assertNotNull("Class patching failed but no errors or warnings were returned", patchedData);
  }
  else if (errors.length > 0) {
    assertTrue(errors[0].getErrorMessage(), false);
  }
  else {
    assertTrue(warnings[0].getErrorMessage(), false);
  }
  return patchedData;
}
项目:consulo-ui-designer    文件:Form2ByteCodeCompiler.java   
private static void addMessage(final CompileContext context, final FormErrorInfo e, final VirtualFile formFile, final CompilerMessageCategory severity)
{
    if(formFile != null)
    {
        FormElementNavigatable navigatable = new FormElementNavigatable(context.getProject(), formFile, e.getComponentId());
        context.addMessage(severity, formFile.getPresentableUrl() + ": " + e.getErrorMessage(), formFile.getUrl(), -1, -1, navigatable);
    }
    else
    {
        context.addMessage(severity, e.getErrorMessage(), null, -1, -1);
    }
}
项目:consulo-ui-designer    文件:PreviewNestedFormLoader.java   
private void generateStubClass(final LwRootContainer rootContainer, final String generatedClassName) throws IOException,
                                                                                                            CodeGenerationException {
  @NonNls ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
  cw.visit(Opcodes.V1_1, Opcodes.ACC_PUBLIC, generatedClassName, null, "java/lang/Object", ArrayUtil.EMPTY_STRING_ARRAY);

  cw.visitField(Opcodes.ACC_PUBLIC, PreviewFormAction.PREVIEW_BINDING_FIELD, "Ljavax/swing/JComponent;", null, null);

  @NonNls MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
  mv.visitCode();
  mv.visitVarInsn(Opcodes.ALOAD, 0);
  mv.visitMethodInsn(Opcodes.INVOKESPECIAL,
          "java/lang/Object",
          "<init>",
          "()V",
    false);
  mv.visitInsn(Opcodes.RETURN);
  mv.visitMaxs(1, 1);
  mv.visitEnd();

  cw.visitEnd();

  ByteArrayInputStream bais = new ByteArrayInputStream(cw.toByteArray());
  AsmCodeGenerator acg = new AsmCodeGenerator(rootContainer, myFinder, this, true, new PsiClassWriter(myModule));
  byte[] data = acg.patchClass(bais);
  FormErrorInfo[] errors = acg.getErrors();
  if (errors.length > 0) {
    throw new CodeGenerationException(errors [0].getComponentId(), errors [0].getErrorMessage());
  }

  FileOutputStream fos = new FileOutputStream(new File(myTempPath, generatedClassName + ".class"));
  try {
    fos.write(data);
  }
  finally {
    fos.close();
  }
}
项目:consulo-ui-designer    文件:Form2SourceCompiler.java   
private static void addError(final CompileContext context, final FormErrorInfo e, final VirtualFile formFile) {
  if (formFile != null) {
    FormElementNavigatable navigatable = new FormElementNavigatable(context.getProject(), formFile, e.getComponentId());
    context.addMessage(CompilerMessageCategory.ERROR,
                       formFile.getPresentableUrl() + ": " + e.getErrorMessage(),
                       formFile.getUrl(), -1, -1, navigatable);
  }
  else {
    context.addMessage(CompilerMessageCategory.ERROR, e.getErrorMessage(), null, -1, -1);
  }
}
项目:consulo-ui-designer    文件:AsmCodeGeneratorTest.java   
private static byte[] getVerifiedPatchedData(final AsmCodeGenerator codeGenerator) {
  byte[] patchedData = codeGenerator.getPatchedData();
  FormErrorInfo[] errors = codeGenerator.getErrors();
  FormErrorInfo[] warnings = codeGenerator.getWarnings();
  if (errors.length == 0 && warnings.length == 0) {
    assertNotNull("Class patching failed but no errors or warnings were returned", patchedData);
  }
  else if (errors.length > 0) {
    assertTrue(errors[0].getErrorMessage(), false);
  }
  else {
    assertTrue(warnings[0].getErrorMessage(), false);
  }
  return patchedData;
}
项目:tools-idea    文件:Form2ByteCodeCompiler.java   
private static void addMessage(final CompileContext context,
                        final String s,
                        final VirtualFile formFile,
                        final CompilerMessageCategory severity) {
  addMessage(context, new FormErrorInfo(null, s), formFile, severity);
}
项目:consulo-ui-designer    文件:FormSourceCodeGenerator.java   
public FormSourceCodeGenerator(@NotNull final Project project)
{
    myProject = project;
    myErrors = new ArrayList<FormErrorInfo>();
    myConfiguration = GuiDesignerConfiguration.getInstance(project);
}
项目:consulo-ui-designer    文件:FormSourceCodeGenerator.java   
public ArrayList<FormErrorInfo> getErrors()
{
    return myErrors;
}
项目:consulo-ui-designer    文件:Form2ByteCodeCompiler.java   
private static void addMessage(final CompileContext context, final String s, final VirtualFile formFile, final CompilerMessageCategory severity)
{
    addMessage(context, new FormErrorInfo(null, s), formFile, severity);
}