Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1443

no AST when groovy compiler report compilation errors

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0
    • None
    • None

    Description

      When the compiler reports an error through an exception the code in GroovyProject doesn't get the AST built during the initial phases.
      Here is the patch for the class GroovyProject that allows to get the AST built even if an exception occured.
      I also added a catch for some hard error for which we should inform the user through a marker on the project.

      private void compileGroovyFiles(final ChangeSet changeSet, final boolean generateClassFiles) {
      CompilationUnit compilationUnit = createCompilationUnit("");
      compilationUnit.addSources(changeSet.fileNamesToBuild());
      try

      { // call the compiler compilationUnit.compile(generateClassFiles ? Phases.ALL : Phases.CANONICALIZATION); }

      catch (CompilationFailedException e)

      { handleCompilationError(changeSet.getFilesToBuild(), e); }

      catch(NoClassDefFoundError e)

      { GroovyPlugin.log(e); // TODO should add marker in project or similar }

      // update project info that maps source files to compiled class info
      CompileUnit compileUnit = compilationUnit.getAST();
      updateClassNameModuleNodeMap(compileUnit.getModules());
      }

      Attachments

        Activity

          People

            jshickey Scott Hickey
            lwi Louis Foucart
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: