use of org.eclipse.jdt.internal.core.CancelableProblemFactory in project che by eclipse.
the class CheCompilationUnitResolver method resolve.
public static CompilationUnitDeclaration resolve(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, IJavaProject javaProject, List classpaths, NodeSearcher nodeSearcher, Map options, WorkingCopyOwner owner, int flags, IProgressMonitor monitor) throws JavaModelException {
CompilationUnitDeclaration unit = null;
INameEnvironmentWithProgress environment = null;
CancelableProblemFactory problemFactory = null;
CheCompilationUnitResolver resolver = null;
try {
if (javaProject == null) {
FileSystem.Classpath[] allEntries = new FileSystem.Classpath[classpaths.size()];
classpaths.toArray(allEntries);
environment = new NameEnvironmentWithProgress(allEntries, null, monitor);
} else {
environment = new CancelableNameEnvironment((JavaProject) javaProject, owner, monitor);
}
problemFactory = new CancelableProblemFactory(monitor);
CompilerOptions compilerOptions = CompilationUnitResolver.getCompilerOptions(options, (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0);
boolean ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
compilerOptions.ignoreMethodBodies = ignoreMethodBodies;
resolver = new CheCompilationUnitResolver(environment, CompilationUnitResolver.getHandlingPolicy(), compilerOptions, CompilationUnitResolver.getRequestor(), problemFactory, monitor, javaProject != null);
boolean analyzeAndGenerateCode = !ignoreMethodBodies;
unit = resolver.resolve(// no existing compilation unit declaration
null, sourceUnit, nodeSearcher, // method verification
true, // analyze code
analyzeAndGenerateCode, // generate code
analyzeAndGenerateCode);
if (resolver.hasCompilationAborted) {
// the bindings could not be resolved due to missing types in name environment
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=86541
CompilationUnitDeclaration unitDeclaration = CompilationUnitResolver.parse(sourceUnit, nodeSearcher, options, flags);
if (unit != null) {
final int problemCount = unit.compilationResult.problemCount;
if (problemCount != 0) {
unitDeclaration.compilationResult.problems = new CategorizedProblem[problemCount];
System.arraycopy(unit.compilationResult.problems, 0, unitDeclaration.compilationResult.problems, 0, problemCount);
unitDeclaration.compilationResult.problemCount = problemCount;
}
} else if (resolver.abortProblem != null) {
unitDeclaration.compilationResult.problemCount = 1;
unitDeclaration.compilationResult.problems = new CategorizedProblem[] { resolver.abortProblem };
}
return unitDeclaration;
}
if (NameLookup.VERBOSE && environment instanceof CancelableNameEnvironment) {
CancelableNameEnvironment cancelableNameEnvironment = (CancelableNameEnvironment) environment;
//$NON-NLS-1$ //$NON-NLS-2$
System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + cancelableNameEnvironment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms");
//$NON-NLS-1$ //$NON-NLS-2$
System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + cancelableNameEnvironment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms");
}
return unit;
} finally {
if (environment != null) {
// don't hold a reference to this external object
environment.setMonitor(null);
}
if (problemFactory != null) {
// don't hold a reference to this external object
problemFactory.monitor = null;
}
}
}
use of org.eclipse.jdt.internal.core.CancelableProblemFactory in project che by eclipse.
the class CodenvyCompilationUnitResolver method resolve.
public static CompilationUnitDeclaration resolve(org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, IJavaProject javaProject, INameEnvironment environment, Map options, int flags, IProgressMonitor monitor) throws JavaModelException {
CompilationUnitDeclaration unit = null;
// INameEnvironmentWithProgress environment = null;
CancelableProblemFactory problemFactory = null;
CodenvyCompilationUnitResolver resolver = null;
try {
// if (javaProject == null) {
// FileSystem.Classpath[] allEntries = new FileSystem.Classpath[classpaths.size()];
// classpaths.toArray(allEntries);
// environment = new NameEnvironmentWithProgress(allEntries, null, monitor);
// } else {
// environment = new CancelableNameEnvironment((JavaProject) javaProject, owner, monitor);
// }
problemFactory = new CancelableProblemFactory(monitor);
CompilerOptions compilerOptions = CompilationUnitResolver.getCompilerOptions(options, (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0);
boolean ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
compilerOptions.ignoreMethodBodies = ignoreMethodBodies;
resolver = new CodenvyCompilationUnitResolver(environment, CompilationUnitResolver.getHandlingPolicy(), compilerOptions, CompilationUnitResolver.getRequestor(), problemFactory, monitor, javaProject != null);
boolean analyzeAndGenerateCode = !ignoreMethodBodies;
unit = resolver.resolve(// no existing compilation unit declaration
null, sourceUnit, null, // method verification
true, // analyze code
analyzeAndGenerateCode, // generate code
analyzeAndGenerateCode);
if (resolver.hasCompilationAborted) {
// the bindings could not be resolved due to missing types in name environment
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=86541
CompilationUnitDeclaration unitDeclaration = CompilationUnitResolver.parse(sourceUnit, null, options, flags);
if (unit != null) {
final int problemCount = unit.compilationResult.problemCount;
if (problemCount != 0) {
unitDeclaration.compilationResult.problems = new CategorizedProblem[problemCount];
System.arraycopy(unit.compilationResult.problems, 0, unitDeclaration.compilationResult.problems, 0, problemCount);
unitDeclaration.compilationResult.problemCount = problemCount;
}
} else if (resolver.abortProblem != null) {
unitDeclaration.compilationResult.problemCount = 1;
unitDeclaration.compilationResult.problems = new CategorizedProblem[] { resolver.abortProblem };
}
return unitDeclaration;
}
if (NameLookup.VERBOSE && environment instanceof CancelableNameEnvironment) {
CancelableNameEnvironment cancelableNameEnvironment = (CancelableNameEnvironment) environment;
//$NON-NLS-1$ //$NON-NLS-2$
System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + cancelableNameEnvironment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms");
//$NON-NLS-1$ //$NON-NLS-2$
System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + cancelableNameEnvironment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms");
}
return unit;
} finally {
if (environment != null) {
// don't hold a reference to this external object
// environment.setMonitor(null);
}
if (problemFactory != null) {
// don't hold a reference to this external object
problemFactory.monitor = null;
}
}
}
Aggregations