diff --git a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/pom.xml b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/pom.xml index c6c3df5da3..7b8dacb83d 100644 --- a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/pom.xml +++ b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/pom.xml @@ -1,7 +1,7 @@ 4.0.0 - ../pom.xml + ../pom.xml org.codehaus.groovy.eclipse org.codehaus.groovy.eclipse.base-test.parent 2.9.2-SNAPSHOT @@ -10,4 +10,4 @@ org.eclipse.jdt.groovy.core.tests.compiler 3.3.100-SNAPSHOT eclipse-plugin - + \ No newline at end of file diff --git a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java index 404a5521fc..a80970b63c 100644 --- a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java +++ b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java @@ -59,8 +59,7 @@ import org.eclipse.jdt.internal.core.search.indexing.BinaryIndexer; public abstract class AbstractRegressionTest extends AbstractCompilerTest implements StopableTestCase { - // javac comparison related types, fields and methods - see runJavac for - // details + // javac comparison related types, fields and methods - see runJavac for details static class JavacCompiler { String rootDirectoryPath; String javacPathName; @@ -121,6 +120,8 @@ static class JavacCompiler { this.version = JavaCore.VERSION_1_6; } else if (rawVersion.indexOf("1.7") != -1) { this.version = JavaCore.VERSION_1_7; + } else if (rawVersion.indexOf("1.8") != -1) { + this.version = JavaCore.VERSION_1_8; } else { throw new RuntimeException("unknown javac version: " + rawVersion); } @@ -821,6 +822,8 @@ protected void compileAndDeploy(String source, String directoryName, String clas buffer.append("\" -1.6"); } else if (this.complianceLevel == ClassFileConstants.JDK1_7) { buffer.append("\" -1.7"); + } else if (this.complianceLevel == JDK1_8) { + buffer.append("\" -1.8"); } buffer .append(" -preserveAllLocals -nowarn -g -classpath \"") diff --git a/base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/search/TypeInferencingVisitorWithRequestor.java b/base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/search/TypeInferencingVisitorWithRequestor.java index 64069b1c8e..ae02442606 100644 --- a/base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/search/TypeInferencingVisitorWithRequestor.java +++ b/base/org.eclipse.jdt.groovy.core/src/org/eclipse/jdt/groovy/search/TypeInferencingVisitorWithRequestor.java @@ -877,7 +877,6 @@ public void visitImports(ModuleNode node) { try { if (type != null) { visitClassReference(type); - // FIXADE this is a bit messy, shoud use existing infra to push and pop completeExpressionStack.push(imp); if (imp.getFieldNameExpr() != null) { primaryTypeStack.push(type); @@ -885,11 +884,6 @@ public void visitImports(ModuleNode node) { dependentDeclarationStack.pop(); dependentTypeStack.pop(); } - - // if (imp.getAliasExpr() != null) { - // primaryTypeStack.push(type); - // imp.getAliasExpr().visit(this); - // } completeExpressionStack.pop(); } } catch (VisitCompleted e) { @@ -1001,9 +995,7 @@ public void visitBinaryExpression(BinaryExpression node) { toVisitPrimary.visit(this); - ClassNode primaryExprType; - - primaryExprType = primaryTypeStack.pop(); + ClassNode primaryExprType = primaryTypeStack.pop(); if (isAssignment) { assignmentStorer.storeAssignment(node, scopes.peek(), primaryExprType); } @@ -1013,10 +1005,12 @@ public void visitBinaryExpression(BinaryExpression node) { completeExpressionStack.pop(); // type of the entire expression ClassNode completeExprType = primaryExprType; - ClassNode dependentExprType = primaryTypeStack.pop(); - if (!isAssignment) { +// TODO: Is it an illegal state to have either as null? +assert primaryExprType != null && dependentExprType != null; + + if (!isAssignment && primaryExprType != null && dependentExprType != null) { // type of RHS of binary expression // find the type of the complete expression String associatedMethod = findBinaryOperatorName(node.getOperation().getText()); @@ -1024,13 +1018,11 @@ public void visitBinaryExpression(BinaryExpression node) { // another special case. // In 1.8 and later, Groovy will not go through the // MOP for standard arithmetic operations on numbers - completeExprType = dependentExprType.equals(VariableScope.STRING_CLASS_NODE) ? VariableScope.STRING_CLASS_NODE - : primaryExprType; + completeExprType = dependentExprType.equals(VariableScope.STRING_CLASS_NODE) ? VariableScope.STRING_CLASS_NODE : primaryExprType; } else if (associatedMethod != null) { // there is an overloadable method associated with this operation // convert to a constant expression and infer type - TypeLookupResult result = lookupExpressionType(new ConstantExpression(associatedMethod), primaryExprType, false, - scopes.peek()); + TypeLookupResult result = lookupExpressionType(new ConstantExpression(associatedMethod), primaryExprType, false, scopes.peek()); completeExprType = result.type; if (associatedMethod.equals("getAt") && result.declaringType.equals(VariableScope.DGM_CLASS_NODE)) { // special case getAt coming from DGM. @@ -1069,13 +1061,8 @@ public void visitBinaryExpression(BinaryExpression node) { } /** - * Make assumption that no one has overloaded the basic arithmetic operations on numbers These operations will bypass the mop in - * most situations anyway - * - * @param text - * @param primaryExprType - * @param dependentExprType - * @return + * Make assumption that no one has overloaded the basic arithmetic operations on numbers. + * These operations will bypass the mop in most situations anyway. */ private boolean isArithmeticOperationOnNumberOrStringOrList(String text, ClassNode lhs, ClassNode rhs) { if (text.length() != 1) { @@ -2029,8 +2016,10 @@ private void handleCompleteExpression(Expression node, ClassNode exprType, Class private void postVisit(Expression node, ClassNode type, ClassNode declaringType, ASTNode declaration) { if (isPrimaryExpression(node)) { + assert type != null; primaryTypeStack.push(type); } else if (isDependentExpression(node)) { + // TODO: null has been seen here for type; is that okay? dependentTypeStack.push(type); dependentDeclarationStack.push(new Tuple(declaringType, declaration)); } @@ -2180,7 +2169,7 @@ private MethodNode findMethodNode(IMethod method) { try { if (method.isConstructor()) { List constructors = clazz.getDeclaredConstructors(); - if (constructors.size() == 0) { + if (constructors == null || constructors.isEmpty()) { return null; } String[] jdtParamTypes = method.getParameterTypes() == null ? NO_PARAMS : method.getParameterTypes(); @@ -2415,8 +2404,8 @@ private boolean isPrimaryExpression(Expression node) { TernaryExpression prop = (TernaryExpression) complete; return prop.getTrueExpression() == node; } else if (complete instanceof ForStatement) { - // this check is used to store the type of the collection expression so that it can be assigned to the for loop - // variable + // this check is used to store the type of the collection expression + // so that it can be assigned to the for loop variable ForStatement prop = (ForStatement) complete; return prop.getCollectionExpression() == node; } else if (complete instanceof ListExpression) { @@ -2460,8 +2449,8 @@ private boolean isPrimaryExpression(Expression node) { *
  • property/field (ie- right part) of an attribute expression * * - * Note that for statements and ternary expressions do not have any dependent expression even though they have primary - * expressions + * Note that for statements and ternary expressions do not have any dependent + * expression even though they have primary expressions. * * @param node expression node to check * @return true iff the node is the primary expression in an expression pair. diff --git a/ide-test/org.codehaus.groovy.eclipse.codebrowsing.test/src/org/codehaus/groovy/eclipse/codebrowsing/tests/CodeSelectImportsTests.groovy b/ide-test/org.codehaus.groovy.eclipse.codebrowsing.test/src/org/codehaus/groovy/eclipse/codebrowsing/tests/CodeSelectImportsTests.groovy index 0983c13159..9bea6d1901 100644 --- a/ide-test/org.codehaus.groovy.eclipse.codebrowsing.test/src/org/codehaus/groovy/eclipse/codebrowsing/tests/CodeSelectImportsTests.groovy +++ b/ide-test/org.codehaus.groovy.eclipse.codebrowsing.test/src/org/codehaus/groovy/eclipse/codebrowsing/tests/CodeSelectImportsTests.groovy @@ -48,6 +48,7 @@ final class CodeSelectImportsTests extends BrowsingTestCase { void testCodeSelectOnImportType2() { String source = '''\ import java.lang.Thread.State + import java.util.regex.Pattern Pattern p = ~/123/ '''.stripIndent() diff --git a/ide-test/org.codehaus.groovy.eclipse.refactoring.test/.classpath b/ide-test/org.codehaus.groovy.eclipse.refactoring.test/.classpath index 0d03e3b624..d743f992ef 100644 --- a/ide-test/org.codehaus.groovy.eclipse.refactoring.test/.classpath +++ b/ide-test/org.codehaus.groovy.eclipse.refactoring.test/.classpath @@ -1,7 +1,11 @@ - + + + + + diff --git a/ide/org.codehaus.groovy.eclipse.ant/.classpath b/ide/org.codehaus.groovy.eclipse.ant/.classpath index 261a4ad976..53eb1326bd 100644 --- a/ide/org.codehaus.groovy.eclipse.ant/.classpath +++ b/ide/org.codehaus.groovy.eclipse.ant/.classpath @@ -1,7 +1,7 @@ - + diff --git a/ide/org.codehaus.groovy.eclipse.ant/.gitignore b/ide/org.codehaus.groovy.eclipse.ant/.gitignore index 5e56e040ec..d1ab919e0b 100644 --- a/ide/org.codehaus.groovy.eclipse.ant/.gitignore +++ b/ide/org.codehaus.groovy.eclipse.ant/.gitignore @@ -1 +1,2 @@ /bin +/bin-ant diff --git a/ide/org.codehaus.groovy.eclipse.ant/META-INF/MANIFEST.MF b/ide/org.codehaus.groovy.eclipse.ant/META-INF/MANIFEST.MF index 8ce6734977..2f9db0ef10 100644 --- a/ide/org.codehaus.groovy.eclipse.ant/META-INF/MANIFEST.MF +++ b/ide/org.codehaus.groovy.eclipse.ant/META-INF/MANIFEST.MF @@ -4,6 +4,8 @@ Bundle-SymbolicName: org.codehaus.groovy.eclipse.ant;singleton:=true Bundle-Name: Groovy Ant support Bundle-Vendor: Codehaus.org Bundle-Version: 2.9.2.qualifier +Bundle-ClassPath: ., + groovyAntEclipse.jar Require-Bundle: org.eclipse.core.runtime, org.eclipse.ant.core, org.apache.ant;bundle-version="1.7.0", diff --git a/ide/org.codehaus.groovy.eclipse.ant/build.properties b/ide/org.codehaus.groovy.eclipse.ant/build.properties index 299c5852b4..1a6e66de29 100644 --- a/ide/org.codehaus.groovy.eclipse.ant/build.properties +++ b/ide/org.codehaus.groovy.eclipse.ant/build.properties @@ -1,25 +1,15 @@ -############################################################################### -# Copyright (c) 2007, 2009 Codehaus.org, SpringSource, and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Andrew Eisenberg - modified for Groovy Eclipse 2.0 -############################################################################### source.. = src/ output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml,\ +source.groovyAntEclipse.jar = src-ant/ +output.groovyAntEclipse.jar = bin-ant/ + +bin.includes = .,\ groovyAntEclipse.jar,\ + META-INF/,\ + plugin.xml,\ about.html -jars.compile.order = .,\ - groovyAntEclipse.jar -source.groovyAntEclipse.jar = src-ant/ -output.groovyAntEclipse.jar = bin/ -compilerArg=-nowarn src.includes = about.html -jars.extra.classpath=platform:/plugin/org.eclipse.jdt.core/jdtCompilerAdapter.jar +compilerArg=-nowarn +jars.compile.order=.,groovyAntEclipse.jar +jars.extra.classpath=platform:/plugin/org.eclipse.jdt.core/jdtCompilerAdapter.jar diff --git a/ide/org.codehaus.groovy.eclipse.ant/groovyAntEclipse.jar b/ide/org.codehaus.groovy.eclipse.ant/groovyAntEclipse.jar deleted file mode 100644 index 84bc4d5543..0000000000 Binary files a/ide/org.codehaus.groovy.eclipse.ant/groovyAntEclipse.jar and /dev/null differ diff --git a/ide/org.codehaus.groovy.eclipse.ant/src-ant/org/codehaus/groovy/eclipse/ant/GroovyCompilerAdapter.java b/ide/org.codehaus.groovy.eclipse.ant/src-ant/org/codehaus/groovy/eclipse/ant/GroovyCompilerAdapter.java index ef1cf3764f..69c45d6127 100644 --- a/ide/org.codehaus.groovy.eclipse.ant/src-ant/org/codehaus/groovy/eclipse/ant/GroovyCompilerAdapter.java +++ b/ide/org.codehaus.groovy.eclipse.ant/src-ant/org/codehaus/groovy/eclipse/ant/GroovyCompilerAdapter.java @@ -1,16 +1,20 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Codehaus.org, SpringSource, and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html +/* + * Copyright 2009-2016 the original author or authors. * - * Contributors: - * Andrew Eisenberg - modified for Groovy Eclipse 2.0 - *******************************************************************************/ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.codehaus.groovy.eclipse.ant; - import java.io.File; import java.lang.reflect.Method; @@ -24,12 +28,11 @@ import org.eclipse.jdt.core.JDTCompilerAdapter; /** - * * @author Andrew Eisenberg * @created Jul 10, 2010 */ public class GroovyCompilerAdapter extends JDTCompilerAdapter implements CompilerAdapter { - + @Override public void setJavac(Javac javac) { super.setJavac(javac); @@ -37,31 +40,30 @@ public void setJavac(Javac javac) { File[] groovyFiles = getGroovyFiles(javac); if (groovyFiles.length > 0) { // now log... - for (int i = 0; i < groovyFiles.length; i++) { + for (int i = 0, n = groovyFiles.length; i < n; i += 1) { javac.log("Compiling " + groovyFiles.length + " groovy source file" + (groovyFiles.length == 1 ? "" : "s") + (destDir != null ? " to " + destDir : "")); String filename = groovyFiles[i].getAbsolutePath(); javac.log(filename); } - + File[] newCompileList = new File[groovyFiles.length + compileList.length]; System.arraycopy(compileList, 0, newCompileList, 0, compileList.length); System.arraycopy(groovyFiles, 0, newCompileList, compileList.length, groovyFiles.length); compileList = newCompileList; } } - + protected File[] getGroovyFiles(Javac javac) { String[] list = javac.getSrcdir().list(); File destDir = javac.getDestdir(); - File[] sourceFiles = new File[0]; + File[] sourceFiles = new File[0]; for (int i = 0; i < list.length; i++) { File srcDir = javac.getProject().resolveFile(list[i]); if (!srcDir.exists()) { - throw new BuildException("srcdir \"" - + srcDir.getPath() - + "\" does not exist!", javac.getLocation()); + throw new BuildException( + "srcdir \"" + srcDir.getPath() + "\" does not exist!", javac.getLocation()); } DirectoryScanner ds = getDirectoryScanner(srcDir, javac); @@ -79,23 +81,16 @@ protected File[] getGroovyFiles(Javac javac) { } return sourceFiles; } - - /** - * @param srcDir - * @return - */ + private DirectoryScanner getDirectoryScanner(File srcDir, Javac javac) { try { Method getDirectoryScannerMethod = MatchingTask.class.getDeclaredMethod("getDirectoryScanner", File.class); getDirectoryScannerMethod.setAccessible(true); return (DirectoryScanner) getDirectoryScannerMethod.invoke(javac, srcDir); } catch (Exception e) { - throw new BuildException("Problem finding directory scanner for srcdir \"" - + srcDir.getPath() - + "\"", e); + throw new BuildException("Problem finding directory scanner for srcdir \"" + srcDir.getPath() + "\"", e); } } - } @@ -105,25 +100,22 @@ public String[] mapFileName(String sourceFileName) { if (sourceFileName != null) { if (sourceFileName.endsWith(".groovy")) { return new String[] { - extractVariablePart(sourceFileName, ".groovy".length()) - + ".class" }; + extractVariablePart(sourceFileName, ".groovy".length()) + ".class" + }; } } return null; } - + private String extractVariablePart(String name, int postfixLength) { - return name.substring(0, - name.length() - postfixLength); + return name.substring(0, name.length() - postfixLength); } - public void setFrom(String from) { - // noop + // no-op } public void setTo(String to) { - // noop + // no-op } - } diff --git a/ide/org.codehaus.groovy.eclipse.ant/src-ant/org/codehaus/groovy/eclipse/ant/GroovyJDTCompileTask.java b/ide/org.codehaus.groovy.eclipse.ant/src-ant/org/codehaus/groovy/eclipse/ant/GroovyJDTCompileTask.java index 114e9057a6..702bf13907 100644 --- a/ide/org.codehaus.groovy.eclipse.ant/src-ant/org/codehaus/groovy/eclipse/ant/GroovyJDTCompileTask.java +++ b/ide/org.codehaus.groovy.eclipse.ant/src-ant/org/codehaus/groovy/eclipse/ant/GroovyJDTCompileTask.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Codehaus.org, SpringSource, and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html +/* + * Copyright 2009-2016 the original author or authors. * - * Contributors: - * Andrew Eisenberg - modified for Groovy Eclipse 2.0 - *******************************************************************************/ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.codehaus.groovy.eclipse.ant; import java.io.File; @@ -17,43 +22,29 @@ import org.apache.tools.ant.util.SourceFileScanner; /** - * The ant task that calls the JDT Compiler for groovy. - *

    - * This task takes the same arguments as the Javac task - * - * + * The Ant task that calls the JDT Compiler for groovy. + *

    + * This task takes the same arguments as the Javac task. + * * @author Andrew Eisenberg * @created Jul 6, 2009 - * */ public class GroovyJDTCompileTask extends Javac { - public GroovyJDTCompileTask() { - } - protected void scanDir(File srcDir, File destDir, String[] files) { GlobPatternMapper m = new GlobPatternMapper(); - m.setFrom("*.java"); //$NON-NLS-1$ - m.setTo("*.class"); //$NON-NLS-1$ + m.setFrom("*.java"); + m.setTo("*.class"); SourceFileScanner sfs = new SourceFileScanner(this); File[] newJavaFiles = sfs.restrictAsFiles(files, srcDir, destDir, m); - - m.setFrom("*.groovy"); //$NON-NLS-1$ + m.setFrom("*.groovy"); File[] newGroovyFiles = sfs.restrictAsFiles(files, srcDir, destDir, m); - if (newJavaFiles.length > 0 || newGroovyFiles.length > 0) { - - File[] newCompileList - = new File[compileList.length + newJavaFiles.length + newGroovyFiles.length]; - - System.arraycopy(compileList, 0, newCompileList, 0, - compileList.length); - System.arraycopy(newJavaFiles, 0, newCompileList, - compileList.length, newJavaFiles.length); - System.arraycopy(newGroovyFiles, 0, newCompileList, - compileList.length+newJavaFiles.length, newGroovyFiles.length); + File[] newCompileList = new File[compileList.length + newJavaFiles.length + newGroovyFiles.length]; + System.arraycopy(compileList, 0, newCompileList, 0, compileList.length); + System.arraycopy(newJavaFiles, 0, newCompileList, compileList.length, newJavaFiles.length); + System.arraycopy(newGroovyFiles, 0, newCompileList, compileList.length+newJavaFiles.length, newGroovyFiles.length); compileList = newCompileList; } - } } diff --git a/ide/org.codehaus.groovy.eclipse.ant/src/org/codehaus/groovy/eclipse/ant/Activator.java b/ide/org.codehaus.groovy.eclipse.ant/src/org/codehaus/groovy/eclipse/ant/Activator.java index f00c5e1dea..c94b6cdbe5 100644 --- a/ide/org.codehaus.groovy.eclipse.ant/src/org/codehaus/groovy/eclipse/ant/Activator.java +++ b/ide/org.codehaus.groovy.eclipse.ant/src/org/codehaus/groovy/eclipse/ant/Activator.java @@ -1,55 +1,46 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Codehaus.org, SpringSource, and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html +/* + * Copyright 2009-2016 the original author or authors. * - * Contributors: - * Andrew Eisenberg - modified for Groovy Eclipse 2.0 - *******************************************************************************/ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.codehaus.groovy.eclipse.ant; import org.eclipse.core.runtime.Plugin; import org.osgi.framework.BundleContext; /** - * The activator class controls the plug-in life cycle + * The activator class controls the plug-in life cycle. */ public class Activator extends Plugin { - public static final String PLUGIN_ID = "org.codehaus.groovy.eclipse.ant"; //$NON-NLS-1$ - - private static Activator plugin; - - public Activator() { - } + public static final String PLUGIN_ID = "org.codehaus.groovy.eclipse.ant"; - /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } + private static Activator plugin; - /* - * (non-Javadoc) - * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + /** + * Returns the shared instance. + */ + public static Activator getDefault() { + return plugin; + } } diff --git a/ide/org.codehaus.groovy.eclipse.astviews/build.properties b/ide/org.codehaus.groovy.eclipse.astviews/build.properties index b6b720c74e..1e9c6f2c5c 100644 --- a/ide/org.codehaus.groovy.eclipse.astviews/build.properties +++ b/ide/org.codehaus.groovy.eclipse.astviews/build.properties @@ -1,30 +1,17 @@ -############################################################################### -# Copyright 2003-2009 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -############################################################################### -bin.includes = plugin.xml,\ - META-INF/,\ - icons/,\ - . -jars.compile.order = . source.. = src/ output.. = bin/ -src.includes = icons/ -#customBuildCallbacks=customBuildCallbacks.xml +bin.includes = .,\ + META-INF/,\ + plugin.xml,\ + about.html,\ + about_files/,\ + icons/ +src.includes = about.html,\ + about_files/,\ + icons/ -sourceFileExtensions=*.java, *.groovy compilerAdapter=org.codehaus.groovy.eclipse.ant.GroovyCompilerAdapter +sourceFileExtensions=*.java,*.groovy compilerAdapter.useLog=true -compilerArg=-nowarn \ No newline at end of file +compilerArg=-nowarn diff --git a/ide/org.codehaus.groovy.eclipse.astviews/customBuildCallbacks.xml b/ide/org.codehaus.groovy.eclipse.astviews/customBuildCallbacks.xml deleted file mode 100644 index da575abd2b..0000000000 --- a/ide/org.codehaus.groovy.eclipse.astviews/customBuildCallbacks.xml +++ /dev/null @@ -1,212 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ide/org.codehaus.groovy.eclipse.astviews/pom.xml b/ide/org.codehaus.groovy.eclipse.astviews/pom.xml index 80079c9b55..23b5b85ef7 100644 --- a/ide/org.codehaus.groovy.eclipse.astviews/pom.xml +++ b/ide/org.codehaus.groovy.eclipse.astviews/pom.xml @@ -1,49 +1,45 @@ - - 4.0.0 - - ../../pom.xml - org.codehaus.groovy.eclipse - org.codehaus.groovy.eclipse.parent - 2.9.2-SNAPSHOT - - org.codehaus.groovy.eclipse - org.codehaus.groovy.eclipse.astviews - 2.9.2-SNAPSHOT - eclipse-plugin - - - - - - org.eclipse.tycho - tycho-compiler-plugin - ${tycho-version} - - - groovy-eclipse-compiler - - - - - - org.codehaus.groovy - groovy-eclipse-compiler - ${groovy-eclipse-compiler-version} - - - - org.codehaus.groovy - groovy-eclipse-batch - ${groovy-eclipse-batch-version} - - - - - + + 4.0.0 + + ../../pom.xml + org.codehaus.groovy.eclipse + org.codehaus.groovy.eclipse.parent + 2.9.2-SNAPSHOT + + org.codehaus.groovy.eclipse + org.codehaus.groovy.eclipse.astviews + 2.9.2-SNAPSHOT + eclipse-plugin + + + + org.eclipse.tycho + tycho-compiler-plugin + ${tycho-version} + + + groovy-eclipse-compiler + + + + + + org.codehaus.groovy + groovy-eclipse-compiler + ${groovy-eclipse-compiler-version} + + + + org.codehaus.groovy + groovy-eclipse-batch + ${groovy-eclipse-batch-version} + + + + + \ No newline at end of file diff --git a/ide/org.codehaus.groovy.eclipse.codeassist.completion/src/org/codehaus/groovy/eclipse/codeassist/requestor/CompletionNodeFinder.java b/ide/org.codehaus.groovy.eclipse.codeassist.completion/src/org/codehaus/groovy/eclipse/codeassist/requestor/CompletionNodeFinder.java index f1ae29956f..a75b78db44 100644 --- a/ide/org.codehaus.groovy.eclipse.codeassist.completion/src/org/codehaus/groovy/eclipse/codeassist/requestor/CompletionNodeFinder.java +++ b/ide/org.codehaus.groovy.eclipse.codeassist.completion/src/org/codehaus/groovy/eclipse/codeassist/requestor/CompletionNodeFinder.java @@ -144,8 +144,6 @@ public ContentAssistContext findContentAssistContext(GroovyCompilationUnit unit) return context; } - -// @Override @Override public void visitImports(ModuleNode node) { PackageNode packageNode = node.getPackage(); diff --git a/ide/org.codehaus.groovy.eclipse.dsl/src/org/codehaus/groovy/eclipse/dsl/contributions/DSLContributionGroup.java b/ide/org.codehaus.groovy.eclipse.dsl/src/org/codehaus/groovy/eclipse/dsl/contributions/DSLContributionGroup.java index 7dd763bead..e6a671c3fd 100644 --- a/ide/org.codehaus.groovy.eclipse.dsl/src/org/codehaus/groovy/eclipse/dsl/contributions/DSLContributionGroup.java +++ b/ide/org.codehaus.groovy.eclipse.dsl/src/org/codehaus/groovy/eclipse/dsl/contributions/DSLContributionGroup.java @@ -1,13 +1,18 @@ -/******************************************************************************* - * Copyright (c) 2011 Codehaus.org, SpringSource, and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html +/* + * Copyright 2009-2016 the original author or authors. * - * Contributors: - * Andrew Eisenberg - Initial implemenation - *******************************************************************************/ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.codehaus.groovy.eclipse.dsl.contributions; import groovy.lang.Closure; @@ -43,7 +48,7 @@ * A contribution group will determine the set of contribution elements (eg- * extra methods, properties, templates, etc) that are added to a particular type * when the attached pointcut matches. - * + * * @author andrew * @created Nov 17, 2010 */ @@ -63,26 +68,26 @@ public class DSLContributionGroup extends ContributionGroup { private VariableScope scope; - + // provider that is set for the entire contribution group // individual contributions can override private String provider = null; - + private ResolverCache resolver; - + private Map> bindings; private ClassNode currentType; - + private Map wormhole; private boolean staticScope; - + private boolean isPrimaryExpression; public DSLContributionGroup(@SuppressWarnings("rawtypes") Closure contributionClosure) { this.contributionClosure = contributionClosure; - + if (contributionClosure != null) { contributionClosure.setDelegate(this); contributionClosure.setResolveStrategy(Closure.DELEGATE_FIRST); @@ -99,7 +104,7 @@ public List getContributions(GroovyDSLDContext pattern, Bi try { this.contributions = new ArrayList(); this.scope = pattern.getCurrentScope(); - this.resolver = pattern.getResolverCache(); + this.resolver = pattern.getResolverCache(); this.bindings = matches.getBindings(); this.currentType = pattern.getCurrentType(); this.wormhole = scope.getWormhole(); @@ -123,7 +128,7 @@ public List getContributions(GroovyDSLDContext pattern, Bi } } - + @Override public Object getProperty(String property) { if ("wormhole".equals(property)) { @@ -139,7 +144,7 @@ public Object getProperty(String property) { } return bindings.get(property); } - + void setDelegateType(Object arg) { ClassNode delegate = asClassNode(arg); if (delegate != null) { @@ -147,14 +152,14 @@ void setDelegateType(Object arg) { scope.addVariable("delegate", delegate, VariableScope.CLOSURE_CLASS); scope.addVariable("getDelegate", delegate, VariableScope.CLOSURE_CLASS); contributions.add(new EmptyContributionElement(currentType)); - + if (isPrimaryExpression) { // must save for later currentType = delegate; } } } - + private ClassNode asClassNode(Object value) { if (value == null) { return null; @@ -175,13 +180,13 @@ private ClassNode asClassNode(Object value) { */ void method(Map args) { String name = asString(args.get("name")); - + Object value = args.get("type"); String returnType = value == null ? "java.lang.Object" : asString(value); - + value = args.get("declaringType"); String declaringType = value == null ? getTypeName(currentType) : asString(value); - + value = args.get("provider"); String provider = value == null ? this.provider : asString(value); // might be null value = args.get("doc"); @@ -189,7 +194,7 @@ void method(Map args) { boolean useNamedArgs = asBoolean(args.get("useNamedArgs")); boolean noParens = asBoolean(args.get("noParens")); - + ParameterContribution[] params = extractParams(args, "params"); ParameterContribution[] namedParams = extractParams(args, "namedParams"); ParameterContribution[] optionalParams = extractParams(args, "optionalParams"); @@ -204,6 +209,7 @@ void method(Map args) { private ParameterContribution[] extractParams(Map args, String paramKind) { Object value; + @SuppressWarnings("unchecked") Map paramsMap = (Map) args.get(paramKind); ParameterContribution[] params; if (paramsMap != null) { @@ -212,7 +218,6 @@ private ParameterContribution[] extractParams(Map args, String p for (Entry entry : paramsMap.entrySet()) { value = entry.getValue(); String type = value == null ? "java.lang.Object" : asString(value); - params[i++] = new ParameterContribution(asString(entry.getKey()), type); } } else { @@ -221,14 +226,10 @@ private ParameterContribution[] extractParams(Map args, String p return params; } - /** - * @param object - * @return - */ private boolean asBoolean(Object object) { if (object == null) { return false; - } + } if (object instanceof Boolean) { return (Boolean) object; } @@ -237,25 +238,24 @@ private boolean asBoolean(Object object) { str.equalsIgnoreCase("yes"); } - - + + /** * Called by closure to add a property - * @param args */ void property(Map args) { String name = asString(args.get("name")); - + Object value = args.get("type"); String type = value == null ? NO_TYPE : asString(value); - + value = args.get("declaringType"); String declaringType = value == null ? getTypeName(currentType) : asString(value); - + value = args.get("provider"); String provider = value == null ? this.provider : asString(value); // might be null String doc = asString(args.get("doc")); // might be null - + boolean isStatic = isStatic(args); boolean isDeprecated = isDeprecated(args); if (!staticScope || (staticScope && isStatic)) { @@ -266,12 +266,10 @@ void property(Map args) { /** * stub...will be used later to add templates - * @param args */ void template(Map args) { - } - + void delegatesTo(Map args) { String name = asString(args.get("type")); boolean isStatic = isStatic(args); @@ -279,6 +277,7 @@ void delegatesTo(Map args) { boolean asCategory = getBoolean("asCategory", args); boolean useNamed = getBoolean("useNamed", args); boolean noParens = getBoolean("noParens", args); + @SuppressWarnings("unchecked") List except = (List) args.get("except"); ClassNode type = this.resolver.resolve(name); internalDelegatesTo(type, useNamed, isStatic, asCategory, isDeprecated, except, noParens); @@ -300,7 +299,7 @@ void delegatesTo(Class clazz) { } delegatesTo(resolved); } - + /** * invoked by the closure * takes an expression and adds all members of its type to the augmented @@ -313,11 +312,11 @@ void delegatesTo(AnnotatedNode expr) { void delegatesToUseNamedArgs(String className) { delegatesToUseNamedArgs(this.resolver.resolve(className)); } - + void delegatesToUseNamedArgs(Class clazz) { delegatesToUseNamedArgs(this.resolver.resolve(clazz.getCanonicalName())); } - + /** * invoked by the closure * takes an expression and adds all members of its type to the augmented @@ -326,7 +325,7 @@ void delegatesToUseNamedArgs(Class clazz) { void delegatesToUseNamedArgs(AnnotatedNode expr) { internalDelegatesTo(expr, true, false, false, false, null, false); } - + void delegatesToCategory(String className) { delegatesToCategory(this.resolver.resolve(className)); } @@ -334,7 +333,7 @@ void delegatesToCategory(String className) { void delegatesToCategory(Class clazz) { delegatesToCategory(this.resolver.resolve(clazz.getCanonicalName())); } - + /** * invoked by the closure * takes an expression and adds all members of its type to the augmented @@ -346,8 +345,6 @@ void delegatesToCategory(AnnotatedNode expr) { /** * Convert a {@link ClassNode} into a string that includes type parameters - * @param clazz - * @return */ static String getTypeName(ClassNode clazz) { StringBuilder sb = new StringBuilder(); @@ -379,7 +376,7 @@ private void internalDelegatesTo(AnnotatedNode expr, boolean useNamedArgs, boole } else { // invalid if (GroovyLogManager.manager.hasLoggers()) { - GroovyLogManager.manager.log(TraceCategory.DSL, + GroovyLogManager.manager.log(TraceCategory.DSL, "Cannot invoke delegatesTo() on an invalid object: " + expr); } return; @@ -387,7 +384,7 @@ private void internalDelegatesTo(AnnotatedNode expr, boolean useNamedArgs, boole if (!type.getName().equals(Object.class.getName())) { // use this to resolve parameterized types GenericsMapper mapper = GenericsMapper.gatherGenerics(type, type.redirect()); - + // naked variants of getter and setter methods must be added at the end // FIXADE why??? List accessorContribs = new ArrayList(1); @@ -406,23 +403,23 @@ private void internalDelegatesTo(AnnotatedNode expr, boolean useNamedArgs, boole } // FIXADE TODO combine with #delegateToCategoryMethod - private void delegateToNonCategoryMethod(boolean useNamedArgs, boolean isStatic, ClassNode type, MethodNode method, ClassNode resolvedReturnType, boolean isDeprecated, + private void delegateToNonCategoryMethod(boolean useNamedArgs, boolean isStatic, ClassNode type, MethodNode method, ClassNode resolvedReturnType, boolean isDeprecated, List accessorContribs, boolean noParens) { String name = method.getName(); - + contributions.add(new MethodContributionElement(name, toParameterContribution(method.getParameters()), NO_PARAMS, NO_PARAMS, getTypeName(resolvedReturnType), getTypeName(type), (method.isStatic() || isStatic), provider, null, useNamedArgs, noParens, isDeprecated, DEFAULT_RELEVANCE_MULTIPLIER)); - + // also add the associated property if applicable String prefix; if ((prefix = isAccessor(method, name, false)) != null) { - accessorContribs.add(new PropertyContributionElement(Character.toLowerCase(name.charAt(prefix.length())) + name.substring(prefix.length()+1), getTypeName(resolvedReturnType), + accessorContribs.add(new PropertyContributionElement(Character.toLowerCase(name.charAt(prefix.length())) + name.substring(prefix.length()+1), getTypeName(resolvedReturnType), getTypeName(method.getDeclaringClass()), (method.isStatic() || isStatic), provider, null, isDeprecated, DEFAULT_RELEVANCE_MULTIPLIER)); } } - private void delegateToCategoryMethod(boolean useNamedArgs, boolean isStatic, ClassNode type, MethodNode method, ClassNode resolvedReturnType, boolean isDeprecated, + private void delegateToCategoryMethod(boolean useNamedArgs, boolean isStatic, ClassNode type, MethodNode method, ClassNode resolvedReturnType, boolean isDeprecated, List accessorContribs, boolean noParens) { String name = method.getName(); if (method.getParameters() != null && method.getParameters().length > 0) { @@ -435,7 +432,7 @@ NO_PARAMS, NO_PARAMS, getTypeName(resolvedReturnType), getTypeName(type), isStat // also add the associated property if applicable String prefix; if ((prefix = isAccessor(method, name, true)) != null) { - accessorContribs.add(new PropertyContributionElement(Character.toLowerCase(name.charAt(prefix.length())) + name.substring(prefix.length()+1), getTypeName(resolvedReturnType), + accessorContribs.add(new PropertyContributionElement(Character.toLowerCase(name.charAt(prefix.length())) + name.substring(prefix.length()+1), getTypeName(resolvedReturnType), getTypeName(method.getDeclaringClass()), (method.isStatic() || isStatic), provider, null, isDeprecated, DEFAULT_RELEVANCE_MULTIPLIER)); } } @@ -477,12 +474,12 @@ private ParameterContribution[] toParameterContributionRemoveFirst(Parameter[] p return new ParameterContribution[0]; } } - - + + void provider(Object args) { provider = args == null ? null : asString(args); } - + /** * @param args map passed in from the call to method or property * @return true iff the static argument is passed in. @@ -494,7 +491,7 @@ private boolean isStatic(Map args) { private boolean isDeprecated(Map args) { return getBoolean("isDeprecated", args); } - + private boolean getBoolean(String name, Map args) { Object maybeStatic = args.get(name); if (maybeStatic == null) { @@ -505,15 +502,12 @@ private boolean getBoolean(String name, Map args) { return Boolean.getBoolean(maybeStatic.toString()); } } - + /** * Converts an object into a string - * @param value - * @return */ private String asString(Object value) { if (value == null) { -// return "null"; return null; } else if (value instanceof String) { return (String) value; @@ -535,7 +529,7 @@ private String asString(Object value) { return value.toString(); } } - + /** * Logs a message to the groovy console log if open * @param msg diff --git a/ide/org.codehaus.groovy.eclipse.quickfix/src/org/codehaus/groovy/eclipse/quickassist/AssignStatementToNewLocalProposal.java b/ide/org.codehaus.groovy.eclipse.quickfix/src/org/codehaus/groovy/eclipse/quickassist/AssignStatementToNewLocalProposal.java index 2ca76211fb..cec8878727 100644 --- a/ide/org.codehaus.groovy.eclipse.quickfix/src/org/codehaus/groovy/eclipse/quickassist/AssignStatementToNewLocalProposal.java +++ b/ide/org.codehaus.groovy.eclipse.quickfix/src/org/codehaus/groovy/eclipse/quickassist/AssignStatementToNewLocalProposal.java @@ -1,7 +1,5 @@ /* - * Copyright 2012 SpringSource, a division of VMware, Inc - * - * Daniel and Stephanie - Initial API and implementation + * Copyright 2009-2016 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. @@ -17,9 +15,7 @@ */ package org.codehaus.groovy.eclipse.quickassist; - import org.codehaus.groovy.eclipse.refactoring.core.convert.AssignStatementToNewLocalRefactoring; - import org.codehaus.jdt.groovy.model.GroovyCompilationUnit; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.internal.ui.JavaPluginImages; @@ -31,68 +27,65 @@ /** * Assigns a statement to a new local variable. eg. "new Point(2,3)" becomes "def temp = new Point(2,3)" - * - * @author Stephanie Van Dyk sevandyk@gmail.com + * + * @author Stephanie Van Dyk * @created April 12, 2012 */ -public class AssignStatementToNewLocalProposal extends - AbstractGroovyCompletionProposal { +public class AssignStatementToNewLocalProposal extends AbstractGroovyCompletionProposal { - private final GroovyCompilationUnit unit; - private final int length; - private final int offset; + protected final GroovyCompilationUnit unit; + protected final int offset; + protected final int length; - - private AssignStatementToNewLocalRefactoring assignStatementRefactoring; + private AssignStatementToNewLocalRefactoring assignStatementRefactoring; - public AssignStatementToNewLocalProposal(IInvocationContext context) { - super(context); - ICompilationUnit compUnit = context.getCompilationUnit(); - if (compUnit instanceof GroovyCompilationUnit) { - this.unit = (GroovyCompilationUnit) compUnit; - } else { - this.unit = null; - } - length = context.getSelectionLength(); - offset = context.getSelectionOffset(); - } + public AssignStatementToNewLocalProposal(IInvocationContext context) { + super(context); + ICompilationUnit compUnit = context.getCompilationUnit(); + if (compUnit instanceof GroovyCompilationUnit) { + this.unit = (GroovyCompilationUnit) compUnit; + } else { + this.unit = null; + } + offset = context.getSelectionOffset(); + length = context.getSelectionLength(); + } - public int getRelevance() { - return 0; - } + public int getRelevance() { + return 0; + } - public void apply(IDocument document) { - assignStatementRefactoring.applyRefactoring(document); - } + public void apply(IDocument document) { + assignStatementRefactoring.applyRefactoring(document); + } - public Point getSelection(IDocument document) { - return assignStatementRefactoring.getNewSelection(); - } + public Point getSelection(IDocument document) { + return assignStatementRefactoring.getNewSelection(); + } - public String getAdditionalProposalInfo() { - return getDisplayString(); - } + public String getAdditionalProposalInfo() { + return getDisplayString(); + } - public String getDisplayString() { - return "Assign statement to new local variable."; - } + public String getDisplayString() { + return "Assign statement to new local variable."; + } - public IContextInformation getContextInformation() { - return new ContextInformation(getImage(), getDisplayString(), - getDisplayString()); - } + public IContextInformation getContextInformation() { + return new ContextInformation(getImage(), getDisplayString(), getDisplayString()); + } - @Override - protected String getImageBundleLocation() { - return JavaPluginImages.IMG_CORRECTION_CHANGE; - } + @Override + protected String getImageBundleLocation() { + return JavaPluginImages.IMG_CORRECTION_CHANGE; + } - @Override - public boolean hasProposals() { - if (unit == null) { + @Override + public boolean hasProposals() { + if (unit == null) { return false; } - assignStatementRefactoring = new AssignStatementToNewLocalRefactoring(unit, offset); + assignStatementRefactoring = new AssignStatementToNewLocalRefactoring(unit, offset); return assignStatementRefactoring.isApplicable(); - } + } } diff --git a/ide/org.codehaus.groovy.eclipse.refactoring/build.properties b/ide/org.codehaus.groovy.eclipse.refactoring/build.properties index 7650b8f0a5..081a9634a0 100644 --- a/ide/org.codehaus.groovy.eclipse.refactoring/build.properties +++ b/ide/org.codehaus.groovy.eclipse.refactoring/build.properties @@ -1,31 +1,15 @@ -############################################################################### -# Copyright 2003-2009 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -############################################################################### -source.. = src/ -output.. = bin/ +source.. = src/ +output.. = bin/ + bin.includes = plugin.xml,\ META-INF/,\ .,\ about.html,\ about_files/ +src.includes = about.html,\ + about_files/ -#customBuildCallbacks=customBuildCallbacks.xml - -sourceFileExtensions=*.java, *.groovy compilerAdapter=org.codehaus.groovy.eclipse.ant.GroovyCompilerAdapter +sourceFileExtensions=*.java,*.groovy compilerAdapter.useLog=true compilerArg=-nowarn -src.includes = about.html,\ - about_files/ diff --git a/ide/org.codehaus.groovy.eclipse.refactoring/customBuildCallbacks.xml b/ide/org.codehaus.groovy.eclipse.refactoring/customBuildCallbacks.xml deleted file mode 100644 index 8baa4e3270..0000000000 --- a/ide/org.codehaus.groovy.eclipse.refactoring/customBuildCallbacks.xml +++ /dev/null @@ -1,184 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ide/org.codehaus.groovy.eclipse.ui/build.properties b/ide/org.codehaus.groovy.eclipse.ui/build.properties index 76849a6ac5..e6159c4d30 100644 --- a/ide/org.codehaus.groovy.eclipse.ui/build.properties +++ b/ide/org.codehaus.groovy.eclipse.ui/build.properties @@ -1,18 +1,7 @@ -############################################################################### -# Copyright 2003-2009 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -############################################################################### +source.. = jdt_src_patched/,\ + src/ +output.. = bin/ + bin.includes = .,\ META-INF/,\ plugin.xml,\ @@ -20,16 +9,8 @@ bin.includes = .,\ about.html,\ about_files/,\ schema/ - src.includes = schema/,\ about.html,\ about_files/ -jars.compile.order = . -source.. = jdt_src_patched/,\ - src/ -output.. = bin/ -sourceFileExtensions=*.java, *.groovy -compilerAdapter=org.codehaus.groovy.eclipse.ant.GroovyCompilerAdapter -compilerAdapter.useLog=true compilerArg=-nowarn diff --git a/ide/org.codehaus.groovy.eclipse.ui/customBuildCallbacks.xml b/ide/org.codehaus.groovy.eclipse.ui/customBuildCallbacks.xml deleted file mode 100644 index 838cd7a0d5..0000000000 --- a/ide/org.codehaus.groovy.eclipse.ui/customBuildCallbacks.xml +++ /dev/null @@ -1,178 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ide/org.codehaus.groovy.eclipse.ui/src/org/codehaus/groovy/eclipse/editor/GroovyEditor.java b/ide/org.codehaus.groovy.eclipse.ui/src/org/codehaus/groovy/eclipse/editor/GroovyEditor.java index 335a6a8a05..91cdbd86f9 100644 --- a/ide/org.codehaus.groovy.eclipse.ui/src/org/codehaus/groovy/eclipse/editor/GroovyEditor.java +++ b/ide/org.codehaus.groovy.eclipse.ui/src/org/codehaus/groovy/eclipse/editor/GroovyEditor.java @@ -77,7 +77,6 @@ import org.eclipse.jdt.internal.ui.search.IOccurrencesFinder; import org.eclipse.jdt.internal.ui.search.IOccurrencesFinder.OccurrenceLocation; import org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner; -import org.eclipse.jdt.internal.ui.text.JavaPartitionScanner; import org.eclipse.jdt.internal.ui.text.JavaWordFinder; import org.eclipse.jdt.internal.ui.text.Symbols; import org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener; @@ -541,9 +540,8 @@ public void verifyKey(VerifyEvent event) { */ private boolean shouldCloseCurly(IDocument document, int offset, ITypedRegion partition, char peer) throws BadLocationException { - if (offset < 2 - || !(JavaPartitionScanner.JAVA_STRING.equals(partition.getType()) || GroovyPartitionScanner.GROOVY_MULTILINE_STRINGS - .equals(partition.getType()))) { + if (offset < 2 || !(IJavaPartitions.JAVA_STRING.equals(partition.getType()) || + GroovyPartitionScanner.GROOVY_MULTILINE_STRINGS.equals(partition.getType()))) { return false; } @@ -969,26 +967,24 @@ public ModuleNode getModuleNode() { } } - @SuppressWarnings("rawtypes") - @Override - public Object getAdapter(Class required) { + @Override @SuppressWarnings("unchecked") + public T getAdapter(Class required) { if (IResource.class == required || IFile.class == required) { - return this.getFile(); + return (T) this.getFile(); } if (GroovyCompilationUnit.class == required || ICompilationUnit.class == required || CompilationUnit.class == required) { - return super.getInputJavaElement(); + return (T) super.getInputJavaElement(); } if (ModuleNode.class == required) { - return this.getModuleNode(); + return (T) this.getModuleNode(); } - - // The new variant test in e43 which addresses bug 391253 means groovy doesn't get an outline (it must fail the - // isCalledByOutline() test but I haven't investigated deeply) + // new variant test in e43 which addresses bug 391253 means groovy doesn't get an outline + // (it must fail the isCalledByOutline() test but I haven't investigated deeply) if (IContentOutlinePage.class.equals(required)) { if (fOutlinePage == null && getSourceViewer() != null) fOutlinePage= createOutlinePage(); - return fOutlinePage; + return (T) fOutlinePage; } return super.getAdapter(required); } @@ -1125,9 +1121,9 @@ public IStatus run(IProgressMonitor progressMonitor) { return Status.CANCEL_STATUS; // Add occurrence annotations - int length = fLocations.length; - Map annotationMap = new HashMap(length); - for (int i = 0; i < length; i++) { + int n = fLocations.length; + Map annotationMap = new HashMap(n); + for (int i = 0; i < n; i += 1) { if (isCanceled(progressMonitor)) return Status.CANCEL_STATUS; @@ -1149,14 +1145,11 @@ public IStatus run(IProgressMonitor progressMonitor) { ((IAnnotationModelExtension) annotationModel).replaceAnnotations(getOccurrenceAnnotations(), annotationMap); } else { myRemoveOccurrenceAnnotations(); - Iterator iter = annotationMap.entrySet().iterator(); - while (iter.hasNext()) { - Map.Entry mapEntry = (Map.Entry) iter.next(); - annotationModel.addAnnotation((Annotation) mapEntry.getKey(), (Position) mapEntry.getValue()); + for (Map.Entry mapEntry : annotationMap.entrySet()) { + annotationModel.addAnnotation(mapEntry.getKey(), mapEntry.getValue()); } } - setOccurrenceAnnotations((Annotation[]) annotationMap.keySet().toArray( - new Annotation[annotationMap.keySet().size()])); + setOccurrenceAnnotations(annotationMap.keySet().toArray(new Annotation[annotationMap.keySet().size()])); } return Status.OK_STATUS; @@ -1429,7 +1422,7 @@ public VerifyKeyListener getGroovyBracketInserter() { */ public GroovyOutlinePage getOutlinePage() { if (page == null) { - IContentOutlinePage outlinePage = (IContentOutlinePage) getAdapter(IContentOutlinePage.class); + IContentOutlinePage outlinePage = getAdapter(IContentOutlinePage.class); if (outlinePage instanceof GroovyOutlinePage) { page = (GroovyOutlinePage) outlinePage; } diff --git a/jdt-patch/e46/Feature-org.codehaus.groovy.jdt.patch/.project b/jdt-patch/e46/Feature-org.codehaus.groovy.jdt.patch/.project index 03dfef9e42..25326f2f86 100644 --- a/jdt-patch/e46/Feature-org.codehaus.groovy.jdt.patch/.project +++ b/jdt-patch/e46/Feature-org.codehaus.groovy.jdt.patch/.project @@ -1,14 +1,9 @@ Feature-org.codehaus.groovy.jdt.patch - - - org.eclipse.pde.FeatureBuilder - - diff --git a/jdt-patch/e46/Feature-org.codehaus.groovy.jdt.patch/build.properties b/jdt-patch/e46/Feature-org.codehaus.groovy.jdt.patch/build.properties index a68bbe3b55..964061ffe0 100644 --- a/jdt-patch/e46/Feature-org.codehaus.groovy.jdt.patch/build.properties +++ b/jdt-patch/e46/Feature-org.codehaus.groovy.jdt.patch/build.properties @@ -1,18 +1,7 @@ -############################################################################### -# Copyright (c) 2009 Codehaus.org, SpringSource, and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Andrew Eisenberg - modified for Groovy Eclipse 2.0 -############################################################################### -bin.includes = feature.xml,\ - feature.properties,\ +bin.includes = feature.properties,\ + feature.xml,\ license.html -src.includes = feature.properties,\ +src.includes = build.properties,\ + feature.properties,\ feature.xml,\ - license.html,\ - build.properties,\ - .project + license.html diff --git a/jdt-patch/e46/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java b/jdt-patch/e46/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java index e94278f91a..5d83e48c8c 100644 --- a/jdt-patch/e46/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java +++ b/jdt-patch/e46/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java @@ -623,12 +623,16 @@ public void resolve(IGenericType suppliedType) { this.superTypesOnly = true; reportHierarchy(this.builder.getType(), null, binaryTypeBinding); } else { - org.eclipse.jdt.core.ICompilationUnit cu = ((SourceTypeElementInfo)suppliedType).getHandle().getCompilationUnit(); - if (cu != null) { - HashSet localTypes = new HashSet(); - localTypes.add(cu.getPath().toString()); - this.superTypesOnly = true; - resolve(new Openable[] {(Openable)cu}, localTypes, null); + // GROOVY edit -- added null check + IType it = ((SourceTypeElementInfo)suppliedType).getHandle(); + if (it != null) { + org.eclipse.jdt.core.ICompilationUnit cu = it.getCompilationUnit(); + if (cu != null) { + HashSet localTypes = new HashSet(); + localTypes.add(cu.getPath().toString()); + this.superTypesOnly = true; + resolve(new Openable[] {(Openable)cu}, localTypes, null); + } } } } catch (AbortCompilation e) { // ignore this exception for now since it typically means we cannot find java.lang.Object