Program: 185288
Project: 185288
Buggy source:
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();
    }
  }
  if (problemReporter.referenceContext == null) {
    problemReporter.referenceContext=new ReferenceContextImpl(compilationResult);
  }
  if (compilationUnit == null) {
    if (eclipseFile != null && eclipseFile.getProject().isAccessible() && !JavaCore.create(eclipseFile.getProject()).isOnClasspath(eclipseFile)) {
      compilerOptions.groovyCompilerConfigScript=null;
    }
    compilationUnit=unitFactory.get();
  }
  char[] sourceCode=Optional.ofNullable(iCompilationUnit.getContents()).orElse(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;
}

Fixed version (ground truth):
public CompilationUnitDeclaration dietParse(ICompilationUnit iCompilationUnit,CompilationResult compilationResult){
  String fileName=String.valueOf(iCompilationUnit.getFileName());
  final IPath filePath=new Path(fileName);
  final IFile eclipseFile;
  final boolean isScript;
  if (filePath.segmentCount() > 1 && ResourcesPlugin.getPlugin() != null) {
    eclipseFile=ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);
    IPath location=eclipseFile.getLocation();
    if (location != null) {
      fileName=location.toFile().getAbsolutePath();
    }
    isScript=isScript(eclipseFile,compilerOptions.groovyProjectName);
  }
 else {
    eclipseFile=null;
    isScript=false;
  }
  if (problemReporter.referenceContext == null) {
    problemReporter.referenceContext=new ReferenceContextImpl(compilationResult);
  }
  if (compilationUnit == null) {
    if (isScript || (eclipseFile != null && eclipseFile.getProject().isAccessible() && !JavaCore.create(eclipseFile.getProject()).isOnClasspath(eclipseFile))) {
      compilerOptions.groovyCompilerConfigScript=null;
    }
    compilationUnit=unitFactory.get();
  }
  char[] sourceCode=Optional.ofNullable(iCompilationUnit.getContents()).orElse(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);
    }
  }
  if (isScript) {
    gcuDeclaration.tagAsScript();
  }
  if (debugRequestor != null) {
    debugRequestor.acceptCompilationUnitDeclaration(gcuDeclaration);
  }
  return gcuDeclaration;
}