Skip to content

Commit

Permalink
minor stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Mar 30, 2021
1 parent 8a5c8ff commit c5a442a
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -935,9 +935,9 @@ public void testClashingPackageAndType_1214() throws Exception {
env.addGroovyClass(paths[1], "com.acme.Foo", "xyz",
"print 'abc'");

boolean conflictIsError = (JavaCore.getPlugin().getBundle().getVersion().compareTo(Version.parseVersion("3.19")) >= 0);

incrementalBuild(paths[0]);
Version jdt = JavaCore.getPlugin().getBundle().getVersion();
boolean conflictIsError = (jdt.getMajor() > 3 || jdt.getMinor() >= 19);
expectingSpecificProblemFor(cuPath, new Problem("", "The type Foo collides with a package", cuPath, 31, 34,
CategorizedProblem.CAT_TYPE, (conflictIsError ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING)));
expectingCompiledClasses("com.acme.Foo", "xyz");
Expand Down Expand Up @@ -3552,15 +3552,21 @@ public void testMultiProjectDependenciesMainAndTest2() throws Exception {

fullBuild();
// TODO: expectingNoProblems(); // no cycle error; build order could be ProjectA:main, ProjectB:main, ProjectA:test, ProjectB:test
Version jdt = JavaCore.getPlugin().getBundle().getVersion();
boolean newCycleError = (jdt.getMajor() > 3 || jdt.getMinor() >= 20);
expectingProblemsFor(projectA, Arrays.asList(
"Problem : One or more cycles were detected in the build path of project 'ProjectA'. The paths towards the cycle and cycle are:\n" +
"->{ProjectA, ProjectB} [ resource : </ProjectA> range : <-1,-1> category : <10> severity : <2>]",
"Problem : " + (newCycleError
? "One or more cycles were detected in the build path of project 'ProjectA'. The paths towards the cycle and cycle are:\n->"
: "A cycle was detected in the build path of project 'ProjectA'. The cycle consists of projects ") +
"{ProjectA, ProjectB} [ resource : </ProjectA> range : <-1,-1> category : <10> severity : <2>]",
"Problem : The project cannot be built until build path errors are resolved" +
" [ resource : </ProjectA> range : <-1,-1> category : <10> severity : <2>]"
));
expectingProblemsFor(projectB, Arrays.asList(
"Problem : One or more cycles were detected in the build path of project 'ProjectB'. The paths towards the cycle and cycle are:\n" +
"->{ProjectA, ProjectB} [ resource : </ProjectB> range : <-1,-1> category : <10> severity : <2>]",
"Problem : " + (newCycleError
? "One or more cycles were detected in the build path of project 'ProjectB'. The paths towards the cycle and cycle are:\n->"
: "A cycle was detected in the build path of project 'ProjectB'. The cycle consists of projects ") +
"{ProjectA, ProjectB} [ resource : </ProjectB> range : <-1,-1> category : <10> severity : <2>]",
"Problem : The project cannot be built until build path errors are resolved " +
"[ resource : </ProjectB> range : <-1,-1> category : <10> severity : <2>]"
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public void returnStatementAdded(final ReturnStatement returnStatement) {
checkReturnType(returnStatement);
if (typeCheckingContext.getEnclosingClosure() != null) {
addClosureReturnType(getType(returnStatement.getExpression()));
*/
*/
ClassNode returnType = checkReturnType(returnStatement);
if (typeCheckingContext.getEnclosingClosure() != null) {
addClosureReturnType(returnType);
Expand Down Expand Up @@ -4792,12 +4792,12 @@ protected ClassNode getResultType(ClassNode left, int op, ClassNode right, Binar
}
}
// GRECLIPSE add
if (GeneralUtils.isOrImplements(rightRedirect, Collection_TYPE)) {
if (isOrImplements(rightRedirect, Collection_TYPE)) {
if (leftRedirect.isArray()) {
return leftRedirect;
}
if (GeneralUtils.isOrImplements(leftRedirect, Collection_TYPE) &&
rightExpression instanceof ListExpression && isEmptyCollection(rightExpression)) {
if (isOrImplements(leftRedirect, Collection_TYPE)
&& rightExpression instanceof ListExpression && isEmptyCollection(rightExpression)) {
return left;
}
}
Expand Down
1 change: 1 addition & 0 deletions base/org.eclipse.jdt.groovy.core/META-INF/eclipse.inf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jarprocessor.exclude.children=true
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2020 the original author or authors.
* Copyright 2009-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -49,7 +49,6 @@
import org.codehaus.groovy.ast.stmt.Statement;
import org.codehaus.groovy.eclipse.core.GroovyCore;
import org.codehaus.groovy.eclipse.core.util.VisitCompleteException;
import org.codehaus.groovy.runtime.DefaultGroovyMethods;
import org.eclipse.jdt.groovy.core.util.ArrayUtils;
import org.eclipse.jdt.groovy.core.util.DepthFirstVisitor;
import org.eclipse.jdt.groovy.core.util.GroovyUtils;
Expand Down Expand Up @@ -136,15 +135,15 @@ public void visitMethod(MethodNode node) {

ClassNode returnType = node.getReturnType();
if (returnType != null /*&& !returnType.isPrimitive()*/) { // allow primitives to be found to stop the visit
int n, offset = -1;
int offset = -1;

if (returnType.getEnd() < 1) {
// constrain the return type's start offset using generics or annotations
ASTNode last = ArrayUtils.lastElement(node.getGenericsTypes());
if (last != null) {
offset = last.getEnd() + 1;
} else if ((n = node.getAnnotations().size()) > 0) {
for (int i = (n - 1); i >= 0; i -= 1) {
} else if (!node.getAnnotations().isEmpty()) {
for (int i = (node.getAnnotations().size() - 1); i >= 0; i -= 1) {
// find the rightmost annotation with end source position info
int end = GroovyUtils.lastElement(node.getAnnotations().get(i)).getEnd() + 1;
if (end > 0) {
Expand Down Expand Up @@ -405,8 +404,7 @@ private void checkSupers(ClassNode node) {
source = src.substring(offset - node.getStart());
} catch (Exception err) {
GroovyCore.logException(String.format(
"Error checking super-types at offset %d in file / index %d of:%n%s%n%s",
offset, offset - node.getStart(), src, DefaultGroovyMethods.dump(node)), err);
"Error checking super-types at offset %d in file / index %d of:%n%s%n%s", offset, offset - node.getStart(), src, node), err);
return;
}

Expand Down
1 change: 0 additions & 1 deletion ide/org.codehaus.groovy.eclipse.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Export-Package: org.codehaus.groovy.eclipse.core,
org.codehaus.groovy.eclipse.core.model,
org.codehaus.groovy.eclipse.core.preferences,
org.codehaus.groovy.eclipse.core.search,
org.codehaus.groovy.eclipse.core.templates,
org.codehaus.groovy.eclipse.core.util
Import-Package: org.eclipse.debug.core;resolution:=optional,
org.eclipse.eclemma.core.launching;resolution:=optional,
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2020 the original author or authors.
* Copyright 2009-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,7 +24,6 @@
import org.codehaus.groovy.ast.Parameter;
import org.codehaus.groovy.ast.PropertyNode;
import org.codehaus.groovy.eclipse.codebrowsing.elements.IGroovyResolvedElement;
import org.codehaus.groovy.runtime.StringGroovyMethods;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Adapters;
import org.eclipse.jdt.core.IJavaElement;
Expand Down Expand Up @@ -109,18 +108,12 @@ public Object getHoverInfo2(final ITextViewer textViewer, final IRegion hoverReg
* an extraDoc.
*/
private boolean shouldComputeHover(final IJavaElement[] elements) {
if (elements != null && elements.length == 1) {
if (alwaysReturnInformation) {
return true;
}
if (elements[0] instanceof IGroovyResolvedElement) {
IGroovyResolvedElement resolvedElt = (IGroovyResolvedElement) elements[0];
if (StringGroovyMethods.asBoolean(resolvedElt.getExtraDoc())) {
return true;
}
}
}
return false;
return (elements != null && elements.length == 1 && (alwaysReturnInformation ||
(elements[0] instanceof IGroovyResolvedElement && isNotBlank(((IGroovyResolvedElement) elements[0]).getExtraDoc()))));
}

private static boolean isNotBlank(final String string) {
return (string != null && !string.trim().isEmpty());
}

/**
Expand Down

0 comments on commit c5a442a

Please sign in to comment.