Program: 185355
Project: 185355
Buggy source:
public CompilationUnitDeclaration dietParse(ICompilationUnit sourceUnit,CompilationResult compilationResult){
  char[] sourceCode=sourceUnit.getContents();
  if (sourceCode == null) {
    sourceCode=CharOperation.NO_CHAR;
  }
  ErrorCollector errorCollector=new GroovyErrorCollectorForJDT(compilationUnit.getConfiguration());
  String filepath=null;
  char[] fileName=sourceUnit.getFileName();
  if (sourceUnit instanceof org.eclipse.jdt.internal.compiler.batch.CompilationUnit) {
    filepath=String.valueOf(((org.eclipse.jdt.internal.compiler.batch.CompilationUnit)sourceUnit).fileName);
  }
 else {
    filepath=String.valueOf(fileName);
  }
  IPath path=new Path(filepath);
  IFile eclipseFile=null;
  if (ResourcesPlugin.getPlugin() != null && path.segmentCount() >= 2) {
    eclipseFile=ResourcesPlugin.getWorkspace().getRoot().getFile(path);
    final IPath location=eclipseFile.getLocation();
    if (location != null) {
      filepath=location.toFile().getAbsolutePath();
    }
  }
  SourceUnit groovySourceUnit=new EclipseSourceUnit(eclipseFile,filepath,String.valueOf(sourceCode),compilationUnit.getConfiguration(),compilationUnit.getClassLoader(),errorCollector,this.resolver);
  groovySourceUnit.isReconcile=compilationUnit.isReconcile;
  GroovyCompilationUnitDeclaration gcuDeclaration=new GroovyCompilationUnitDeclaration(problemReporter,compilationResult,sourceCode.length,compilationUnit,groovySourceUnit,compilerOptions);
  compilationResult.lineSeparatorPositions=GroovyUtils.getSourceLineSeparatorsIn(sourceCode);
  compilationUnit.addSource(groovySourceUnit);
  if (requestor instanceof Compiler) {
    if (((Compiler)requestor).requestor instanceof BatchImageBuilder) {
      BuildNotifier notifier=((BatchImageBuilder)((Compiler)requestor).requestor).notifier;
      if (notifier != null) {
        compilationUnit.setProgressListener(new ProgressListenerImpl(notifier));
      }
    }
  }
  gcuDeclaration.processToPhase(Phases.CONVERSION);
  if (gcuDeclaration.getModuleNode() != null) {
    gcuDeclaration.populateCompilationUnitDeclaration();
    for (    TypeDeclaration decl : gcuDeclaration.types) {
      resolver.record((GroovyTypeDeclaration)decl);
    }
  }
  String projectName=compilerOptions.groovyProjectName;
  if (projectName != null && eclipseFile != null) {
    ScriptFolderSelector scriptFolderSelector=scriptFolderSelectorCache.get(projectName);
    if (scriptFolderSelector == null) {
      scriptFolderSelector=new ScriptFolderSelector(ResourcesPlugin.getWorkspace().getRoot().getProject(projectName));
      scriptFolderSelectorCache.put(projectName,scriptFolderSelector);
    }
    if (scriptFolderSelector.isScript(eclipseFile)) {
      gcuDeclaration.tagAsScript();
    }
  }
  if (debugRequestor != null) {
    debugRequestor.acceptCompilationUnitDeclaration(gcuDeclaration);
  }
  return gcuDeclaration;
}

Fixed version (ground truth):
public CompilationUnitDeclaration dietParse(ICompilationUnit iCompilationUnit,CompilationResult compilationResult){
  String fileName=String.valueOf(iCompilationUnit.getFileName());
  IPath filePath=new Path(fileName);
  IFile eclipseFile=null;
  if (filePath.segmentCount() > 1 && ResourcesPlugin.getPlugin() != null) {
    eclipseFile=ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);
    IPath location=eclipseFile.getLocation();
    if (location != null) {
      fileName=location.toFile().getAbsolutePath();
    }
  }
  char[] sourceCode=iCompilationUnit.getContents();
  if (sourceCode == null) {
    sourceCode=CharOperation.NO_CHAR;
  }
  SourceUnit sourceUnit=new EclipseSourceUnit(eclipseFile,fileName,String.valueOf(sourceCode),compilationUnit.isReconcile,compilationUnit.getConfiguration(),compilationUnit.getClassLoader(),new GroovyErrorCollectorForJDT(compilationUnit.getConfiguration()),resolver);
  compilationUnit.addSource(sourceUnit);
  if (requestor instanceof Compiler) {
    Compiler compiler=(Compiler)requestor;
    if (compiler.requestor instanceof AbstractImageBuilder) {
      AbstractImageBuilder builder=(AbstractImageBuilder)compiler.requestor;
      if (builder.notifier != null) {
        compilationUnit.setProgressListener(new ProgressListenerImpl(builder.notifier));
      }
      if (eclipseFile != null) {
        SourceFile sourceFile=(SourceFile)builder.fromIFile(eclipseFile);
        if (sourceFile != null) {
          compilationUnit.getConfiguration().setTargetDirectory(sourceFile.getOutputLocation().toFile());
        }
      }
    }
 else     if (compiler.requestor instanceof BatchCompilerRequestor) {
      Main main=ReflectionUtils.getPrivateField(BatchCompilerRequestor.class,"String_Node_Str",compiler.requestor);
      if (main != null && main.destinationPath != null && main.destinationPath != Main.NONE) {
        compilationUnit.getConfiguration().setTargetDirectory(main.destinationPath);
      }
    }
  }
  compilationResult.lineSeparatorPositions=GroovyUtils.getSourceLineSeparatorsIn(sourceCode);
  GroovyCompilationUnitDeclaration gcuDeclaration=new GroovyCompilationUnitDeclaration(problemReporter,compilationResult,sourceCode.length,compilationUnit,sourceUnit,compilerOptions);
  gcuDeclaration.processToPhase(Phases.CONVERSION);
  if (gcuDeclaration.getModuleNode() != null) {
    gcuDeclaration.populateCompilationUnitDeclaration();
    for (    TypeDeclaration decl : gcuDeclaration.types) {
      resolver.record((GroovyTypeDeclaration)decl);
    }
  }
  String projectName=compilerOptions.groovyProjectName;
  if (projectName != null && eclipseFile != null) {
    ScriptFolderSelector scriptFolderSelector=scriptFolderSelectorCache.computeIfAbsent(projectName,GroovyParser::newScriptFolderSelector);
    if (scriptFolderSelector.isScript(eclipseFile)) {
      gcuDeclaration.tagAsScript();
    }
  }
  if (debugRequestor != null) {
    debugRequestor.acceptCompilationUnitDeclaration(gcuDeclaration);
  }
  return gcuDeclaration;
}