Skip to content

Commit

Permalink
Eclipse 4.10 (M1) JDT Patch for Groovy-Eclipse: JDT commit e4fef6c
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Oct 16, 2018
1 parent d38875c commit 4874d03
Show file tree
Hide file tree
Showing 2,092 changed files with 1,184,957 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public abstract class GroovyCompilerTestSuite {
protected static final long JDK8 = ClassFileConstants.JDK1_8;
protected static final long JDK9 = ClassFileConstants.JDK9 ;
protected static final long JDK10 = ClassFileConstants.JDK10 ;
protected static final long JDK11 = ClassFileConstants.JDK11 ;
protected static final long JDK11 = (55L << 16) + ClassFileConstants.MINOR_VERSION_0;
protected static final List<Long> JDKs = Collections.unmodifiableList(Arrays.asList(JDK7, JDK8, JDK9, JDK10, JDK11));

@Parameters(name = "Java {1}")
Expand Down
4 changes: 2 additions & 2 deletions docs/Getting-Started-with-Groovy-Eclipse-Source-Code.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ mvn -Pe47 clean install

Replace e47 with a different option to build it for another Eclipse version:

* e49
* e48
* e47
* e49
* e4.10

Tests will be executed as part of the build. To skip them, append this option to the command: `-Dmaven.test.skip=true`.

Expand Down
8 changes: 4 additions & 4 deletions docs/Manual-Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ These are old instructions for setting up a Groovy-Eclipse development environme

### Get the Base Eclipse Package

Groovy-Eclipse is intended to be developed using Eclipse. Download and install [the "Eclipse IDE for Eclipse Committers" package (4.7 Oxygen)](http://www.eclipse.org/downloads/packages/eclipse-ide-eclipse-committers/oxygen2) for your operating system.
Groovy-Eclipse is intended to be developed using Eclipse. Download and install [the "Eclipse IDE for Eclipse Committers" package](http://www.eclipse.org/downloads/packages/release/2018-09/r/eclipse-ide-eclipse-committers) for your operating system.

### Install Groovy-Eclipse

On the Eclipse menu bar, select *Help -> Install New Software...*. In the *Install* window, paste the Groovy-Eclipse update site `http://dist.springsource.org/snapshot/GRECLIPSE/e4.7` into the *Work with:* field and press enter. Check the boxes next to "Groovy-Eclipse" and "Extra Groovy compilers", then click the *Next* button a couple of times, accept the license agreement, and let Eclipse restart.
On the Eclipse menu bar, select *Help -> Install New Software...*. In the *Install* window, paste the Groovy-Eclipse update site `http://dist.springsource.org/snapshot/GRECLIPSE/e4.9` into the *Work with:* field and press enter. Check the boxes next to "Groovy-Eclipse" and "Extra Groovy compilers", then click the *Next* button a couple of times, accept the license agreement, and let Eclipse restart.

### Setup Groovy-Eclipse Compiler

On the Eclipse menu bar, select *Window -> Preferences*. In the *Preferences* window, go to *Groovy -> Compiler*. Click the *Switch to 2.4.13* button, and let Eclipse restart.
On the Eclipse menu bar, select *Window -> Preferences*. In the *Preferences* window, go to *Groovy -> Compiler*. Click the *Switch to 2.4.15* button, and let Eclipse restart.

### Install Execution Environment Descriptions

On the Eclipse menu bar, select *Help -> Install New Software...*. In the *Install* window, select `Neon - http://download.eclipse.org/releases/neon` from the *Work with:* field and enter "exeuction" in the filter. Check the boxes next to "API Tools Execution Environment Descriptions", and click the *Next* button a couple of times, accept the license agreement, and let Eclipse restart.
On the Eclipse menu bar, select *Help -> Install New Software...*. In the *Install* window, select `2018-09 - http://download.eclipse.org/releases/2018-09` from the *Work with:* field and enter "exeuction" in the filter. Check the boxes next to "API Tools Execution Environment Descriptions", and click the *Next* button a couple of times, accept the license agreement, and let Eclipse restart.

![API Baseline](images/eclipse-api-tools-execution-environment.png)

Expand Down
27 changes: 26 additions & 1 deletion groovy-eclipse.setup
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
defaultValue="Oxygen"
storageURI="scope://Workspace"
label="Target Platform">
<choice
value="2018-12"
label="Eclipse 4.10 (2018-12)"/>
<choice
value="2018-09"
label="Eclipse 4.9 (2018-09)"/>
Expand Down Expand Up @@ -119,7 +122,15 @@
</setupTask>
<setupTask
xsi:type="setup.p2:P2Task"
filter="(| (scope.product.version.name=2018-09) (scope.product.version.name=latest) (scope.product.version.name=latest.released))">
filter="(| (scope.product.version.name=2018-12) (scope.product.version.name=latest))">
<requirement
name="org.codehaus.groovy.m2eclipse.feature.feature.group"/>
<repository
url="http://dist.springsource.org/snapshot/GRECLIPSE/e4.10"/>
</setupTask>
<setupTask
xsi:type="setup.p2:P2Task"
filter="(| (scope.product.version.name=2018-09) (scope.product.version.name=latest.released))">
<requirement
name="org.codehaus.groovy.m2eclipse.feature.feature.group"/>
<repository
Expand Down Expand Up @@ -194,6 +205,13 @@
<sourceLocator
rootFolder="${git.clone.Groovy-Eclipse.location}/Site-org.codehaus.groovy.eclipse"/>
</setupTask>
<setupTask
xsi:type="projects:ProjectsImportTask"
filter="(eclipse.target.platform=2018-12)">
<sourceLocator
rootFolder="${git.clone.Groovy-Eclipse.location}/jdt-patch/e410"
locateNestedProjects="true"/>
</setupTask>
<setupTask
xsi:type="projects:ProjectsImportTask"
filter="(eclipse.target.platform=2018-09)">
Expand Down Expand Up @@ -232,6 +250,13 @@
name="org.eclipse.m2e.sdk.feature.feature.group"/>
<requirement
name="org.eclipse.test.feature.group"/>
<repositoryList
name="2018-12">
<repository
url="http://download.eclipse.org/releases/2018-12"/>
<repository
url="http://download.eclipse.org/eclipse/updates/4.10milestones"/>
</repositoryList>
<repositoryList
name="2018-09">
<repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import org.eclipse.jdt.core.JavaCore
import org.eclipse.jdt.core.JavaModelException
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants
import org.eclipse.jdt.core.refactoring.descriptors.JavaRefactoringDescriptor
import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility
import org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType
import org.eclipse.jdt.internal.corext.util.Strings
import org.eclipse.jdt.internal.ui.JavaPlugin
import org.eclipse.jdt.internal.ui.util.CoreUtility
Expand Down Expand Up @@ -70,24 +68,21 @@ abstract class RefactoringTestSuite {

@BeforeClass
static final void setUpTestSuite() {
fWasOptions = JavaCore.getOptions()
fWasAutobuild = CoreUtility.setAutoBuilding(false)

Hashtable<String, String> options = TestOptions.getDefaultOptions()
options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, '4')
options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB)
options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, String.valueOf(9999))
options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, '0')

JavaCore.setOptions(options)
fWasOptions = JavaCore.getOptions()
TestOptions.defaultOptions.with {
put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, '4')
put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.TAB)
put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, String.valueOf(9999))
put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, '0')
JavaCore.setOptions(it)
}
TestOptions.initializeCodeGenerationOptions()
JavaPlugin.getDefault().codeTemplateStore.load()
JavaPlugin.getDefault().getCodeTemplateStore().load()

fgJavaTestProject = JavaProjectHelper.createGroovyProject('TestProject', 'bin')
fgRoot = JavaProjectHelper.addSourceContainer(fgJavaTestProject, 'src')
fgPackageP = fgRoot.createPackageFragment('p', true, null)

StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORCOMMENT_ID, '/**\n * ${tags}\n */', null)
}

@AfterClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Import-Package: org.codehaus.groovy.eclipse.codebrowsing.requestor,
org.eclipse.debug.internal.ui,
org.eclipse.debug.internal.ui.preferences,
org.eclipse.debug.ui.console,
org.eclipse.jdt.internal.core.manipulation,
org.eclipse.jdt.internal.debug.ui.actions,
org.eclipse.jdt.junit.wizards,
org.eclipse.jdt.launching,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,42 @@ import org.eclipse.jdt.core.IPackageFragmentRoot
import org.eclipse.jdt.core.JavaCore
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants
import org.eclipse.jdt.groovy.core.util.ReflectionUtils
import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility
import org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType
import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogFieldGroup
import org.eclipse.jdt.ui.PreferenceConstants
import org.eclipse.jdt.ui.wizards.NewElementWizardPage
import org.eclipse.jdt.ui.wizards.NewTypeWizardPage
import org.junit.Before
import org.junit.Test

// Original source code: http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/wizardapi/NewTypeWizardTest.java?revision=1.8
final class NewGroovyTypeWizardTests extends GroovyEclipseTestSuite {

// FIXKDV: the wizard has some options/controls that probably shouldn't be there

@Before
void setUp() {
setJavaPreference(PreferenceConstants.CODEGEN_ADD_COMMENTS, 'false')
setJavaPreference(PreferenceConstants.CODEGEN_USE_OVERRIDE_ANNOTATION, 'true')
setJavaPreference(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, '4')
setJavaPreference(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE)

String newFileTemplate = '${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}'
StubUtility.setCodeTemplate(CodeTemplateContextType.NEWTYPE_ID, newFileTemplate, null)
StubUtility.setCodeTemplate(CodeTemplateContextType.TYPECOMMENT_ID, '/**\n * Type\n */', null)
StubUtility.setCodeTemplate(CodeTemplateContextType.FILECOMMENT_ID, '/**\n * File\n */', null)
StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORCOMMENT_ID, '/**\n * Constructor\n */', null)
StubUtility.setCodeTemplate(CodeTemplateContextType.METHODCOMMENT_ID, '/**\n * Method\n */', null)
StubUtility.setCodeTemplate(CodeTemplateContextType.OVERRIDECOMMENT_ID, '/**\n * Overridden\n */', null)
StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, '${body_statement}', null)
StubUtility.setCodeTemplate(CodeTemplateContextType.CONSTRUCTORSTUB_ID, '${body_statement}', null)
StubUtility.setCodeTemplate(CodeTemplateContextType.CLASSBODY_ID, '/* class body */\n', null)
StubUtility.setCodeTemplate(CodeTemplateContextType.INTERFACEBODY_ID, '/* interface body */\n', null)
StubUtility.setCodeTemplate(CodeTemplateContextType.ENUMBODY_ID, '/* enum body */\n', null)
StubUtility.setCodeTemplate(CodeTemplateContextType.ANNOTATIONBODY_ID, '/* annotation body */\n', null)
Class stubUtility, codeTemplateContextType
try {
stubUtility = Class.forName('org.eclipse.jdt.internal.core.manipulation.StubUtility')
codeTemplateContextType = Class.forName('org.eclipse.jdt.internal.core.manipulation.CodeTemplateContextType')
} catch (ClassNotFoundException e) {
stubUtility = Class.forName('org.eclipse.jdt.internal.corext.codemanipulation.StubUtility')
codeTemplateContextType = Class.forName('org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType')
}
stubUtility.setCodeTemplate(codeTemplateContextType.NEWTYPE_ID, '${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}', null)
stubUtility.setCodeTemplate(codeTemplateContextType.TYPECOMMENT_ID, '/**\n * Type\n */', null)
stubUtility.setCodeTemplate(codeTemplateContextType.FILECOMMENT_ID, '/**\n * File\n */', null)
stubUtility.setCodeTemplate(codeTemplateContextType.CONSTRUCTORCOMMENT_ID, '/**\n * Constructor\n */', null)
stubUtility.setCodeTemplate(codeTemplateContextType.METHODCOMMENT_ID, '/**\n * Method\n */', null)
stubUtility.setCodeTemplate(codeTemplateContextType.OVERRIDECOMMENT_ID, '/**\n * Overridden\n */', null)
stubUtility.setCodeTemplate(codeTemplateContextType.METHODSTUB_ID, '${body_statement}', null)
stubUtility.setCodeTemplate(codeTemplateContextType.CONSTRUCTORSTUB_ID, '${body_statement}', null)
stubUtility.setCodeTemplate(codeTemplateContextType.CLASSBODY_ID, '/* class body */\n', null)
stubUtility.setCodeTemplate(codeTemplateContextType.INTERFACEBODY_ID, '/* interface body */\n', null)
stubUtility.setCodeTemplate(codeTemplateContextType.ENUMBODY_ID, '/* enum body */\n', null)
stubUtility.setCodeTemplate(codeTemplateContextType.ANNOTATIONBODY_ID, '/* annotation body */\n', null)
}

private NewClassWizardPage clearModifiers(NewClassWizardPage wizardPage) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2017 the original author or authors.
* Copyright 2009-2018 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 @@ -15,12 +15,11 @@
*/
package org.codehaus.groovy.eclipse.quickassist;

import static org.eclipse.jdt.internal.corext.codemanipulation.StubUtility.getLineDelimiterPreference;

import org.codehaus.groovy.ast.ASTNode;
import org.codehaus.groovy.ast.expr.GStringExpression;
import org.codehaus.groovy.eclipse.codebrowsing.requestor.ASTNodeFinder;
import org.codehaus.groovy.eclipse.codebrowsing.requestor.Region;
import org.codehaus.groovy.eclipse.refactoring.core.utils.ASTTools;
import org.codehaus.jdt.groovy.model.GroovyCompilationUnit;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Assert;
Expand Down Expand Up @@ -91,7 +90,7 @@ public String getLineDelimiter(IDocument document, int line) {
}
} catch (BadLocationException ignore) {
}
return ending != null ? ending : getLineDelimiterPreference(getProject());
return ending != null ? ending : ASTTools.getLineDelimeter(getCompilationUnit());
}

public String getNodeText(ASTNode node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
import org.codehaus.groovy.eclipse.codebrowsing.selection.FindSurroundingNode;
import org.codehaus.groovy.eclipse.codebrowsing.selection.FindSurroundingNode.VisitKind;
import org.codehaus.groovy.eclipse.core.compiler.GroovySnippetParser;
import org.codehaus.jdt.groovy.model.GroovyCompilationUnit;
import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.compiler.util.Util;
import org.eclipse.jdt.internal.core.CompilationUnit;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.text.TextUtilities;
import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;

Expand All @@ -57,9 +57,12 @@
*/
public class ASTTools {

public static String getLineDelimeter(GroovyCompilationUnit unit) {
String hint = StubUtility.getLineDelimiterUsed(unit.getJavaProject());
return TextUtilities.determineLineDelimiter(String.valueOf(unit.getContents()), hint);
public static String getLineDelimeter(CompilationUnit unit) {
try {
return unit.findRecommendedLineSeparator();
} catch (JavaModelException e) {
return Util.LINE_SEPARATOR;
}
}

/**
Expand Down Expand Up @@ -194,7 +197,7 @@ public static IDocument getDocumentWithSystemLineBreak(String text) {
}
}
multiEdit.apply(document);
} catch (Exception e) {
} catch (Exception ignore) {
}
return document;
}
Expand All @@ -211,18 +214,6 @@ public static boolean hasMultipleReturnStatements(Statement statement) {
return returns.size() > 1;
}

private static class FindReturns extends ASTVisitorDecorator<List<ReturnStatement>> {
public FindReturns(List<ReturnStatement> container) {
super(container);
}

@Override
public void visitReturnStatement(ReturnStatement statement) {
container.add(statement);
super.visitReturnStatement(statement);
}
}

public static String getTextofNode(ASTNode node, IDocument document) {
TextSelection sel = new TextSelection(document, node.getStart(), node.getEnd() - node.getStart());
try {
Expand Down Expand Up @@ -306,4 +297,16 @@ public static IASTFragment getSelectionFragment(ModuleNode moduleNode, int selec
}
return selectionFragment;
}

private static class FindReturns extends ASTVisitorDecorator<List<ReturnStatement>> {
FindReturns(List<ReturnStatement> container) {
super(container);
}

@Override
public void visitReturnStatement(ReturnStatement statement) {
container.add(statement);
super.visitReturnStatement(statement);
}
}
}
Loading

1 comment on commit 4874d03

@eric-milles
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.