Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 174222

Summary: EMF CodeGen/Jet: generated code with compile errors is not saved but a runtime error is thrown
Product: [Modeling] EMF Reporter: Martin Taal <mtaal>
Component: CoreAssignee: Marcelo Paternostro <marcelop>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3    
Version: 2.3.0   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Martin Taal CLA 2007-02-14 15:07:44 EST
Build ID: 3.3M4

Steps To Reproduce:
Jet throws a runtimeexception when it generates a java file with compile errors, it is easier if the java source is still written to a file because then errors in templates can more easily be identified.


More information:
Here is a part of an emft newsgroup exchange:

By Ed:
A similar type of issue came up in the GMF newsgroup and in that case it wasn't really even an error in the generated code but simply a redundant semicolon that was configured to be treated as a warning.    The issue arises here in ASTFacadeHelper:

      public ASTJCompilationUnit createCompilationUnit(String name, String contents)
      {
        // set source
        char[] contentAsCharArray = contents.toCharArray();
        ASTParser astParser = createASTParser();
        astParser.setSource(contentAsCharArray);

        // parse
        CompilationUnit astCompilationUnit = (CompilationUnit)astParser.createAST(null);

        // display errors if any
        if (astCompilationUnit.getProblems().length > 0)
        {
          // TODO do a better job with reporting errors     
          String problems = logCompilationErrors(astCompilationUnit.getProblems());
         
          // NAME may be passed as name - do not show it
          if (name != null && !"".equals(name) && !"NAME".equals(name))
          {
            problems = name + ":" + problems;
          }
         
          // stop merging and report problems
          throw new RuntimeException(problems);
        }
Comment 1 Marcelo Paternostro CLA 2007-04-04 21:00:40 EDT
The changes are committed to CVS.

Now when you generate a new file, it will be written even if it has compilation errors.  If this new file is being merged over an existing one, the error is displayed on the Dialog Box, as described on:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=181099
Comment 2 Nick Boldt CLA 2007-04-05 09:58:22 EDT
Fixed in I200704050200.
Comment 3 Nick Boldt CLA 2008-01-28 16:40:22 EST
Move to verified as per bug 206558.