Skip to content

Commit

Permalink
Fix for #1041: do not load classpath from non-Java project
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Feb 27, 2020
1 parent 6916785 commit 7cb997f
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ public void acceptResult(CompilationResult compilationResult) {
};
}

private static boolean isTestSource(IJavaProject project, ICompilationUnit cu) {
private static boolean isTestSource(ICompilationUnit cu) {
// GROOVY add
if (JavaProject.hasJavaNature(cu.getJavaProject().getProject()) && cu.getResource() != null)
// GROOVY end
try {
// GROOVY add
if (cu.getResource() == null) return false;
// GROOVY end
IClasspathEntry[] resolvedClasspath = project.getResolvedClasspath(true);
IClasspathEntry[] resolvedClasspath = cu.getJavaProject().getResolvedClasspath(true);
final IPath resourcePath = cu.getResource().getFullPath();
for (IClasspathEntry e : resolvedClasspath) {
if (e.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
Expand Down Expand Up @@ -255,7 +255,7 @@ public static CompilationUnitDeclaration process(
CompilationUnitProblemFinder problemFinder = null;
CompilationUnitDeclaration unit = null;
try {
environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor, !isTestSource(unitElement.getJavaProject(), unitElement));
environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor, !isTestSource(unitElement));
problemFactory = new CancelableProblemFactory(monitor);
CompilerOptions compilerOptions = getCompilerOptions(project.getOptions(true), creatingAST, ((reconcileFlags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0));
boolean ignoreMethodBodies = (reconcileFlags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ public void acceptResult(CompilationResult compilationResult) {
};
}

private static boolean isTestSource(IJavaProject project, ICompilationUnit cu) {
private static boolean isTestSource(ICompilationUnit cu) {
// GROOVY add
if (JavaProject.hasJavaNature(cu.getJavaProject().getProject()) && cu.getResource() != null)
// GROOVY end
try {
// GROOVY add
if (cu.getResource() == null) return false;
// GROOVY end
IClasspathEntry[] resolvedClasspath = project.getResolvedClasspath(true);
IClasspathEntry[] resolvedClasspath = cu.getJavaProject().getResolvedClasspath(true);
final IPath resourcePath = cu.getResource().getFullPath();
for (IClasspathEntry e : resolvedClasspath) {
if (e.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
Expand Down Expand Up @@ -255,7 +255,7 @@ public static CompilationUnitDeclaration process(
CompilationUnitProblemFinder problemFinder = null;
CompilationUnitDeclaration unit = null;
try {
environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor, !isTestSource(unitElement.getJavaProject(), unitElement));
environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor, !isTestSource(unitElement));
problemFactory = new CancelableProblemFactory(monitor);
CompilerOptions compilerOptions = getCompilerOptions(project.getOptions(true), creatingAST, ((reconcileFlags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0));
boolean ignoreMethodBodies = (reconcileFlags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ public void acceptResult(CompilationResult compilationResult) {
};
}

private static boolean isTestSource(IJavaProject project, ICompilationUnit cu) {
private static boolean isTestSource(ICompilationUnit cu) {
// GROOVY add
if (JavaProject.hasJavaNature(cu.getJavaProject().getProject()) && cu.getResource() != null)
// GROOVY end
try {
// GROOVY add
if (cu.getResource() == null) return false;
// GROOVY end
IClasspathEntry[] resolvedClasspath = project.getResolvedClasspath(true);
IClasspathEntry[] resolvedClasspath = cu.getJavaProject().getResolvedClasspath(true);
final IPath resourcePath = cu.getResource().getFullPath();
for (IClasspathEntry e : resolvedClasspath) {
if (e.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
Expand Down Expand Up @@ -255,7 +255,7 @@ public static CompilationUnitDeclaration process(
CompilationUnitProblemFinder problemFinder = null;
CompilationUnitDeclaration unit = null;
try {
environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor, !isTestSource(unitElement.getJavaProject(), unitElement));
environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor, !isTestSource(unitElement));
problemFactory = new CancelableProblemFactory(monitor);
CompilerOptions compilerOptions = getCompilerOptions(project.getOptions(true), creatingAST, ((reconcileFlags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0));
boolean ignoreMethodBodies = (reconcileFlags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ public void acceptResult(CompilationResult compilationResult) {
};
}

private static boolean isTestSource(IJavaProject project, ICompilationUnit cu) {
private static boolean isTestSource(ICompilationUnit cu) {
// GROOVY add
if (JavaProject.hasJavaNature(cu.getJavaProject().getProject()) && cu.getResource() != null)
// GROOVY end
try {
// GROOVY add
if (cu.getResource() == null) return false;
// GROOVY end
IClasspathEntry[] resolvedClasspath = project.getResolvedClasspath(true);
IClasspathEntry[] resolvedClasspath = cu.getJavaProject().getResolvedClasspath(true);
final IPath resourcePath = cu.getResource().getFullPath();
for (IClasspathEntry e : resolvedClasspath) {
if (e.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
Expand Down Expand Up @@ -255,7 +255,7 @@ public static CompilationUnitDeclaration process(
CompilationUnitProblemFinder problemFinder = null;
CompilationUnitDeclaration unit = null;
try {
environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor, !isTestSource(unitElement.getJavaProject(), unitElement));
environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor, !isTestSource(unitElement));
problemFactory = new CancelableProblemFactory(monitor);
CompilerOptions compilerOptions = getCompilerOptions(project.getOptions(true), creatingAST, ((reconcileFlags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0));
boolean ignoreMethodBodies = (reconcileFlags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ public void acceptResult(CompilationResult compilationResult) {
};
}

private static boolean isTestSource(IJavaProject project, ICompilationUnit cu) {
private static boolean isTestSource(ICompilationUnit cu) {
// GROOVY add
if (JavaProject.hasJavaNature(cu.getJavaProject().getProject()) && cu.getResource() != null)
// GROOVY end
try {
// GROOVY add
if (cu.getResource() == null) return false;
// GROOVY end
IClasspathEntry[] resolvedClasspath = project.getResolvedClasspath(true);
IClasspathEntry[] resolvedClasspath = cu.getJavaProject().getResolvedClasspath(true);
final IPath resourcePath = cu.getResource().getFullPath();
for (IClasspathEntry e : resolvedClasspath) {
if (e.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
Expand Down Expand Up @@ -255,7 +255,7 @@ public static CompilationUnitDeclaration process(
CompilationUnitProblemFinder problemFinder = null;
CompilationUnitDeclaration unit = null;
try {
environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor, !isTestSource(unitElement.getJavaProject(), unitElement));
environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor, !isTestSource(unitElement));
problemFactory = new CancelableProblemFactory(monitor);
CompilerOptions compilerOptions = getCompilerOptions(project.getOptions(true), creatingAST, ((reconcileFlags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0));
boolean ignoreMethodBodies = (reconcileFlags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ public void acceptResult(CompilationResult compilationResult) {
};
}

private static boolean isTestSource(IJavaProject project, ICompilationUnit cu) {
private static boolean isTestSource(ICompilationUnit cu) {
// GROOVY add
if (JavaProject.hasJavaNature(cu.getJavaProject().getProject()) && cu.getResource() != null)
// GROOVY end
try {
// GROOVY add
if (cu.getResource() == null) return false;
// GROOVY end
IClasspathEntry[] resolvedClasspath = project.getResolvedClasspath(true);
IClasspathEntry[] resolvedClasspath = cu.getJavaProject().getResolvedClasspath(true);
final IPath resourcePath = cu.getResource().getFullPath();
for (IClasspathEntry e : resolvedClasspath) {
if (e.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
Expand Down Expand Up @@ -255,7 +255,7 @@ public static CompilationUnitDeclaration process(
CompilationUnitProblemFinder problemFinder = null;
CompilationUnitDeclaration unit = null;
try {
environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor, !isTestSource(unitElement.getJavaProject(), unitElement));
environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor, !isTestSource(unitElement));
problemFactory = new CancelableProblemFactory(monitor);
CompilerOptions compilerOptions = getCompilerOptions(project.getOptions(true), creatingAST, ((reconcileFlags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0));
boolean ignoreMethodBodies = (reconcileFlags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ public void acceptResult(CompilationResult compilationResult) {
};
}

private static boolean isTestSource(IJavaProject project, ICompilationUnit cu) {
private static boolean isTestSource(ICompilationUnit cu) {
// GROOVY add
if (JavaProject.hasJavaNature(cu.getJavaProject().getProject()) && cu.getResource() != null)
// GROOVY end
try {
// GROOVY add
if (cu.getResource() == null) return false;
// GROOVY end
IClasspathEntry[] resolvedClasspath = project.getResolvedClasspath(true);
IClasspathEntry[] resolvedClasspath = cu.getJavaProject().getResolvedClasspath(true);
final IPath resourcePath = cu.getResource().getFullPath();
for (IClasspathEntry e : resolvedClasspath) {
if (e.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
Expand Down Expand Up @@ -255,7 +255,7 @@ public static CompilationUnitDeclaration process(
CompilationUnitProblemFinder problemFinder = null;
CompilationUnitDeclaration unit = null;
try {
environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor, !isTestSource(unitElement.getJavaProject(), unitElement));
environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor, !isTestSource(unitElement));
problemFactory = new CancelableProblemFactory(monitor);
CompilerOptions compilerOptions = getCompilerOptions(project.getOptions(true), creatingAST, ((reconcileFlags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0));
boolean ignoreMethodBodies = (reconcileFlags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
Expand Down

0 comments on commit 7cb997f

Please sign in to comment.