Skip to content

Commit

Permalink
Merge pull request #4 from groovy/master
Browse files Browse the repository at this point in the history
Catch up with master
  • Loading branch information
eric-milles authored Nov 3, 2016
2 parents fd30695 + 60da7b2 commit 93b1bbc
Show file tree
Hide file tree
Showing 28 changed files with 95 additions and 70 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.eclipse.jdt.groovy.core.tests.builder;singleton:=true
Bundle-Name: Builder Tests
Bundle-Vendor: Codehaus.org
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,6 @@ void doTest(ModuleNode module, StartAndEnd...sae) {
assertStartAndEnds(sae);
}

@Override
protected SourceUnit getSourceUnit() {
return null;
}

void assertStartAndEnds(StartAndEnd...sae) {
assertEquals("Wrong number expressions found", sae.length, allCollectedNodes.size());
ASTNode[] bexprs = allCollectedNodes.toArray(new ASTNode[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@
import org.codehaus.groovy.ast.expr.ListExpression;
import org.codehaus.groovy.ast.stmt.BlockStatement;
import org.codehaus.groovy.ast.stmt.Statement;
import org.codehaus.groovy.control.SourceUnit;
import org.codehaus.jdt.groovy.model.GroovyCompilationUnit;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;


/**
* @author Andrew Eisenberg
* @created May 9, 2011
Expand Down Expand Up @@ -135,13 +133,6 @@ public UniquenessVisitor(Expression exprToCheck) {

private final Expression exprToCheck;



@Override
protected SourceUnit getSourceUnit() {
return null;
}

@Override
public void visitListExpression(ListExpression expression) {
doCheck(expression);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.eclipse.jdt.groovy.core.tests.compiler;singleton:=true
Bundle-Name: Compiler Tests
Bundle-Vendor: Codehaus.org
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.batch.Main;

public class TestCase extends junit.framework.TestCase {
public abstract class TestCase extends junit.framework.TestCase {

// Filters
public static final String METHOD_PREFIX = "test";
Expand Down Expand Up @@ -621,7 +621,6 @@ public static List<Test> buildTestsList(Class<? extends Test> evaluationTestClas
*
* Note that this lis maybe reduced using some mechanisms detailed in {@link #buildTestsList(Class)} method.
*
* @param evaluationTestClass
* @return a {@link Test test suite}
*/
public static Test buildTestSuite(Class<? extends Test> evaluationTestClass) {
Expand All @@ -635,8 +634,6 @@ public static Test buildTestSuite(Class<? extends Test> evaluationTestClass) {
*
* Note that this lis maybe reduced using some mechanisms detailed in {@link #buildTestsList(Class)} method.
*
* @param evaluationTestClass
* @param suiteName
* @return a test suite ({@link Test})
*/
public static Test buildTestSuite(Class<? extends Test> evaluationTestClass, String suiteName) {
Expand All @@ -658,26 +655,23 @@ private static File createMemLogFile() {
try {
boolean fileExist = logFile.exists();
stream = new PrintStream(new FileOutputStream(logFile, true));
if (stream != null) {
if (fileExist) {
stream.println();
}
// Log date and time
Date date = new Date(System.currentTimeMillis());
stream.println("Tests:\t" + STORE_MEMORY);
stream.println("Date:\t" + DateFormat.getDateInstance(3).format(date));
stream.println("Time:\t" + DateFormat.getTimeInstance(3).format(date));
// Log columns title
stream.print("Class");
if (ALL_TESTS_LOG) stream.print("\tTest");
stream.print("\tUsed\tTotal\tMax");
if (fileExist) {
stream.println();
stream.close();
System.out.println("Log file " + logFile.getPath() + " opened.");
return logFile;
}
// Log date and time
Date date = new Date(System.currentTimeMillis());
stream.println("Tests:\t" + STORE_MEMORY);
stream.println("Date:\t" + DateFormat.getDateInstance(3).format(date));
stream.println("Time:\t" + DateFormat.getTimeInstance(3).format(date));
// Log columns title
stream.print("Class");
if (ALL_TESTS_LOG) stream.print("\tTest");
stream.print("\tUsed\tTotal\tMax");
stream.println();
System.out.println("Log file " + logFile.getPath() + " opened.");
return logFile;
} catch (FileNotFoundException e) {
// no log available for this statistic
System.err.println("Cannot open file " + logFile.getPath());
} finally {
if (stream != null) {
stream.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@ final class AnnotationsTests extends AbstractGroovyRegressionTest {
""".stripIndent().toString())
}

void testLocalAnnotationConstant() {
// there was an error because the variable expression VALUE was not recognized as constant
// see ResolveVisitor.transformInlineConstants(Expression)
String[] sources = [
'Main.groovy', '''
class Main {
public static final String VALUE = 'nls'
@SuppressWarnings(VALUE)
def method() {
}
}'''
]

runConformTest(sources)
}

void testTargetMetaAnnotation() {
String[] sources = [
'Anno.java', '''
Expand Down
2 changes: 1 addition & 1 deletion base/org.eclipse.jdt.groovy.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ Require-Bundle: org.codehaus.groovy,
org.eclipse.text
Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.jdt.groovy.core.util"
Bundle-Activator: org.eclipse.jdt.groovy.core.Activator
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Eclipse-RegisterBuddy: org.eclipse.jdt.core
2 changes: 1 addition & 1 deletion ide-test/org.codehaus.groovy.alltests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.codehaus.groovy.alltests;singleton:=true
Bundle-Name: Groovy Test Suites
Bundle-Version: 2.9.2.qualifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.codehaus.groovy.eclipse.codeassist.completion.test;singleton:=true
Bundle-Name: Groovy Content Assist Tests
Bundle-Version: 2.9.2.qualifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.codehaus.groovy.eclipse.codebrowsing.test;singleton:=true
Bundle-Name: Groovy Code Browsing Tests
Bundle-Version: 2.9.2.qualifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.codehaus.groovy.eclipse.core.test;singleton:=true
Bundle-Name: Groovy Core Tests
Bundle-Version: 2.9.2.qualifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.codehaus.groovy.eclipse.dsl.tests;singleton:=true
Bundle-Name: Groovy DSL Tests
Bundle-Version: 2.9.2.qualifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.codehaus.groovy.eclipse.junit.test;singleton:=true
Bundle-Name: Groovy JUnit Tests
Bundle-Version: 2.9.2.qualifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.codehaus.groovy.eclipse.quickfix.test;singleton:=true
Bundle-Name: Groovy Quick Fix Tests
Bundle-Version: 2.9.2.qualifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.codehaus.groovy.eclipse.refactoring.test;singleton:=true
Bundle-Name: Groovy Refactoring Tests
Bundle-Version: 2.9.2.qualifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.codehaus.groovy.eclipse.tests;singleton:=true
Bundle-Name: Groovy UI Tests
Bundle-Version: 2.9.2.qualifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,21 @@ final class SemanticHighlightingTests extends EclipseTestCase {
new HighlightedTypedPosition(contents.lastIndexOf('b)'), 1, PARAMETER))
}

void testMethodsAsProperties() {
String contents = '''\
import java.lang.management.ManagementFactory
// compact form:
ManagementFactory.runtimeMXBean.inputArguments
// expanded form:
ManagementFactory.getRuntimeMXBean().getInputArguments()
'''.stripIndent()
assertHighlighting(contents,
new HighlightedTypedPosition(contents.indexOf('runtimeMXBean'), 'runtimeMXBean'.length(), STATIC_CALL),
new HighlightedTypedPosition(contents.indexOf('inputArguments'), 'inputArguments'.length(), METHOD_CALL),
new HighlightedTypedPosition(contents.indexOf('getRuntimeMXBean'), 'getRuntimeMXBean'.length(), STATIC_CALL),
new HighlightedTypedPosition(contents.indexOf('getInputArguments'), 'getInputArguments'.length(), METHOD_CALL))
}

void testDefaultGroovyMethods() {
String contents = '["one", "two"].grep().first()'

Expand Down Expand Up @@ -983,7 +998,7 @@ final class SemanticHighlightingTests extends EclipseTestCase {

//

void assertHighlighting(String contents, HighlightedTypedPosition... expectedPositions) {
private void assertHighlighting(String contents, HighlightedTypedPosition... expectedPositions) {
GroovyCompilationUnit unit = openFile(contents)
checkStyles(unit, expectedPositions as List)
}
Expand Down Expand Up @@ -1011,9 +1026,6 @@ final class SemanticHighlightingTests extends EclipseTestCase {
h1.offset <=> h2.offset ?: h1.kind.ordinal() <=> h2.kind.ordinal()
}

assertEquals("All expected:\n${ -> expectedPositions.toListString()}\n\nAll actual:\n${ -> actualPositions.toListString()}", expectedPositions.size(), actualPositions.size())
for (i in 0..<actualPositions.size()) {
assertEquals("Should have had equal positions.\nAll expected:\n${ -> expectedPositions.toListString()}\n\nAll actual:\n${ -> actualPositions.toListString()}", expectedPositions[i], actualPositions[i])
}
assertEquals(expectedPositions.join('\n'), actualPositions.join('\n'))
}
}
2 changes: 1 addition & 1 deletion ide/org.codehaus.groovy.eclipse.ant/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.jdt.core;bundle-version="3.6.0"
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.codehaus.groovy.eclipse.ant.Activator
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.jdt.groovy.core;bundle-version="2.9.2"
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.codehaus.groovy.eclipse.astviews.Activator
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ Require-Bundle: org.codehaus.groovy;bundle-version="1.8.6",
org.eclipse.ui.workbench.texteditor
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.codehaus.groovy.eclipse.codeassist.GroovyContentAssistActivator
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ Require-Bundle: org.codehaus.groovy;bundle-version="1.8.6",
org.eclipse.jdt.groovy.core;bundle-version="2.9.2"
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.codehaus.groovy.eclipse.codebrowsing.GroovyBrowsingPlugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
2 changes: 1 addition & 1 deletion ide/org.codehaus.groovy.eclipse.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ Export-Package: org.codehaus.groovy.eclipse.core,
org.codehaus.groovy.eclipse.core.util
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.codehaus.groovy.eclipse.core.GroovyCoreActivator
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
2 changes: 1 addition & 1 deletion ide/org.codehaus.groovy.eclipse.dsl/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ Require-Bundle: org.codehaus.groovy;bundle-version="1.8.6",
org.eclipse.ui.ide
Bundle-ActivationPolicy: lazy;exclude:="org.codehaus.groovy.eclipse.dsl.earlystartup"
Bundle-Activator: org.codehaus.groovy.eclipse.dsl.GroovyDSLCoreActivator
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ Require-Bundle: org.codehaus.groovy;bundle-version="1.8.6",
org.eclipse.ui.workbench.texteditor
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.codehaus.groovy.eclipse.quickfix.GroovyQuickFixPlugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ Require-Bundle: org.codehaus.groovy;bundle-version="1.8.6",
org.eclipse.ui.workbench.texteditor;bundle-version="3.5.0"
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.codehaus.groovy.eclipse.refactoring.Activator
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
2 changes: 1 addition & 1 deletion ide/org.codehaus.groovy.eclipse.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ Require-Bundle: org.codehaus.groovy;bundle-version="1.8.6",
org.eclipse.ui.workbench.texteditor
Bundle-ActivationPolicy: lazy;exclude:="org.codehaus.groovy.eclipse.ui.decorators"
Bundle-Activator: org.codehaus.groovy.eclipse.GroovyPlugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class SemanticHighlightingReferenceRequestor extends SemanticReferenceReq
private boolean insideSlashy;
private boolean insideDollarSlashy;
private final GroovyCompilationUnit unit;
private static final boolean DEBUG = true;
private static final boolean DEBUG = false;

/**
* Contains positions in a non-overlapping, increasing lexical order
Expand Down Expand Up @@ -129,10 +129,8 @@ public VisitStatus acceptASTNode(ASTNode node, TypeLookupResult result, IJavaEle
} else if (node instanceof ConstantExpression) {
if (!(result.declaration instanceof MethodNode)) {
pos = handleConstantExpression((ConstantExpression) node);
} else if (result.isGroovy) {
pos = new HighlightedTypedPosition(node.getStart(), node.getLength(), HighlightKind.GROOVY_CALL);
} else if (enclosingElement instanceof ImportDeclaration) {
pos = new HighlightedTypedPosition(node.getStart(), node.getLength(), HighlightKind.STATIC_CALL);
} else {
pos = handleMethodReference((ConstantExpression) node, result, (enclosingElement instanceof ImportDeclaration));
}

} else if (node instanceof MapEntryExpression) {
Expand Down Expand Up @@ -254,6 +252,26 @@ private HighlightedTypedPosition handleMethodReference(MethodPointerExpression e
return new HighlightedTypedPosition(offset, length, kind);
}

private HighlightedTypedPosition handleMethodReference(ConstantExpression expr, TypeLookupResult result, boolean isStaticImport) {
MethodNode meth = (MethodNode) result.declaration;

HighlightKind kind = null;
if (result.isGroovy) {
kind = HighlightKind.GROOVY_CALL;
} else if (isStaticImport) {
kind = HighlightKind.STATIC_CALL;
} else if (!expr.getText().equals(meth.getName())) {
// property name did not match method name
// there won't be a [Static]MethodCallExpression
kind = !meth.isStatic() ? HighlightKind.METHOD_CALL : HighlightKind.STATIC_CALL;
}

if (kind != null) {
return new HighlightedTypedPosition(expr.getStart(), expr.getLength(), kind);
}
return null;
}

private HighlightedTypedPosition handleMapEntryExpression(MapEntryExpression expr) {
Expression key = expr.getKeyExpression();
if (key instanceof ConstantExpression) {
Expand Down
7 changes: 3 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
-->

<properties>
<tycho-version>0.19.0</tycho-version>
<tycho-extras-version>0.19.0</tycho-extras-version>
<tycho-version>0.26.0</tycho-version>
<tycho-extras-version>0.26.0</tycho-extras-version>

<!-- Version of greclipse maven compiler to use for building. (Some bundles,
mostly test related, have groovy code that can't be compiled with standard
Expand Down Expand Up @@ -137,10 +137,9 @@
<id>e46</id>
<layout>p2</layout>
<!-- TODO: after neon release change this: -->
<url>http://download.eclipse.org/eclipse/updates/4.6milestones</url>
<url>http://download.eclipse.org/eclipse/updates/4.6</url>
<!--
<url>http://download.eclipse.org/eclipse/updates/4.6milestones</url>
<url>http://download.eclipse.org/eclipse/updates/4.6</url>
-->
</repository>
<!-- <repository> <id>kepler</id> <layout>p2</layout> <url>http://download.eclipse.org/releases/luna</url>
Expand Down

0 comments on commit 93b1bbc

Please sign in to comment.