Commit 24f4ec89 authored by Romain Bioteau's avatar Romain Bioteau Committed by GitHub

fix(groovy) update groovy snapshot to fix completion (#874)

Closes BS-17664
parent 7b956571
......@@ -76,6 +76,6 @@ public class ContractConstraintEditor extends GroovyEditor {
}
protected GroovyColorManager getColorManager() {
return new GroovyColorManager();
return GroovyPlugin.getDefault().getTextTools().getColorManager();
}
}
......@@ -17,12 +17,14 @@ package org.bonitasoft.studio.contract.ui.property.constraint.edit.editor;
import java.net.MalformedURLException;
import java.util.List;
import org.bonitasoft.studio.common.ExpressionConstants;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.contract.ContractPlugin;
import org.bonitasoft.studio.contract.core.constraint.ConstraintInputIndexer;
import org.bonitasoft.studio.contract.i18n.Messages;
import org.bonitasoft.studio.contract.ui.property.constraint.edit.editor.contentassist.ContractInputCompletionProposalComputer;
import org.bonitasoft.studio.expression.editor.filter.AvailableExpressionTypeFilter;
import org.bonitasoft.studio.groovy.ui.viewer.GroovySourceViewerFactory;
import org.bonitasoft.studio.groovy.ui.viewer.GroovyViewer;
import org.bonitasoft.studio.model.process.ContractConstraint;
......@@ -41,6 +43,7 @@ import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
......@@ -84,6 +87,7 @@ public class ContractConstraintExpressionWizardPage extends WizardPage implement
@Override
public void dispose() {
if (groovyViewer != null) {
groovyViewer.enbaleSyntaxHighligthing();
groovyViewer.dispose();
}
super.dispose();
......@@ -107,13 +111,16 @@ public class ContractConstraintExpressionWizardPage extends WizardPage implement
getSourceViewer().getTextWidget().setData(ContractInputCompletionProposalComputer.INPUTS, inputs);
getSourceViewer().getDocument().addDocumentListener(this);
expressionContentObservable = EMFObservables.observeValue(constraint, ProcessPackage.Literals.CONTRACT_CONSTRAINT__EXPRESSION);
expressionContentObservable = EMFObservables.observeValue(constraint,
ProcessPackage.Literals.CONTRACT_CONSTRAINT__EXPRESSION);
final IObservableList inputsObservable = EMFObservables.observeList(constraint, ProcessPackage.Literals.CONTRACT_CONSTRAINT__INPUT_NAMES);
final IObservableList inputsObservable = EMFObservables.observeList(constraint,
ProcessPackage.Literals.CONTRACT_CONSTRAINT__INPUT_NAMES);
inputIndexer = new ConstraintInputIndexer(constraint, inputs, viewer.getGroovyCompilationUnit());
getSourceViewer().getDocument().set(expressionContentObservable.getValue().toString());
context.addValidationStatusProvider(new ConstraintExpressionEditorValidator(expressionContentObservable, inputsObservable, viewer
.getGroovyCompilationUnit(), new CompilationProblemRequestor()));
context.addValidationStatusProvider(
new ConstraintExpressionEditorValidator(expressionContentObservable, inputsObservable, viewer
.getGroovyCompilationUnit(), new CompilationProblemRequestor()));
final CLabel contentAssistHint = new CLabel(container, SWT.NONE);
contentAssistHint.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).create());
......@@ -127,11 +134,13 @@ public class ContractConstraintExpressionWizardPage extends WizardPage implement
protected GroovyViewer createSourceViewer(final Composite container) {
groovyViewer = groovyViewerFactory.createSourceViewer(container, editorFactory.newInstance());
groovyViewer.disableSyntaxHighligthing();
ContractContainer contractContainer = null;
if (!inputs.isEmpty()) {
contractContainer = ModelHelper.getFirstContainerOfType(inputs.get(0), ContractContainer.class);
}
groovyViewer.setContext(null, contractContainer, null, null);
groovyViewer.setContext(null, contractContainer,
new ViewerFilter[] { new AvailableExpressionTypeFilter(ExpressionConstants.CONTRACT_INPUT_TYPE) }, null);
return groovyViewer;
}
......@@ -158,9 +167,11 @@ public class ContractConstraintExpressionWizardPage extends WizardPage implement
}
}
public boolean performFinish(final ContractConstraint constraintToUpdate, final IPropertySourceProvider propertySourceProvider) {
public boolean performFinish(final ContractConstraint constraintToUpdate,
final IPropertySourceProvider propertySourceProvider) {
final IPropertySource constraintPropertySource = propertySourceProvider.getPropertySource(constraintToUpdate);
constraintPropertySource.setPropertyValue(ProcessPackage.Literals.CONTRACT_CONSTRAINT__EXPRESSION, constraint.getExpression());
constraintPropertySource.setPropertyValue(ProcessPackage.Literals.CONTRACT_CONSTRAINT__EXPRESSION,
constraint.getExpression());
if (inputIndexer != null) {
try {
inputIndexer.join();
......@@ -169,7 +180,8 @@ public class ContractConstraintExpressionWizardPage extends WizardPage implement
return false;
}
}
constraintPropertySource.setPropertyValue(ProcessPackage.Literals.CONTRACT_CONSTRAINT__INPUT_NAMES, constraint.getInputNames());
constraintPropertySource.setPropertyValue(ProcessPackage.Literals.CONTRACT_CONSTRAINT__INPUT_NAMES,
constraint.getInputNames());
return true;
}
......
......@@ -57,15 +57,6 @@
languageProviderClass="org.bonitasoft.studio.groovy.ui.providers.GroovyScriptLanguageProvider">
</scriptLanguage>
</extension>
<extension
point="org.codehaus.groovy.eclipse.codeassist.completion.completionProposalFilter">
<proposalFilter
proposalFilter="org.bonitasoft.studio.groovy.ui.contentassist.BonitaProposalFilter">
<appliesTo
projectNature="org.bonitasoft.studio.common.repository.bonitaNature">
</appliesTo>
</proposalFilter>
</extension>
<extension
point="org.bonitasoft.studio.configuration.synchronizer">
<synchronier
......
package org.bonitasoft.studio.groovy.ui.contentassist;
import java.util.List;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.groovy.ScriptVariable;
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.ast.Variable;
import org.codehaus.jdt.groovy.model.GroovyCompilationUnit;
import org.eclipse.jdt.groovy.search.AbstractSimplifiedTypeLookup;
import org.eclipse.jdt.groovy.search.VariableScope;
public class BonitaConstantsTypeLookup extends AbstractSimplifiedTypeLookup {
public static List<ScriptVariable> bonitaVariables;
@Override
protected TypeAndDeclaration lookupTypeAndDeclaration(final ClassNode declaringType, final String name, final VariableScope scope) {
final org.codehaus.groovy.ast.VariableScope variableScope = scope.getEnclosingModuleNode().getStatementBlock().getVariableScope();
final Variable variable = variableScope.getDeclaredVariable(name);
if (variable != null) {
return new TypeAndDeclaration(variable.getType(), variable.getOriginType());
}
return null;
protected TypeAndDeclaration lookupTypeAndDeclaration(final ClassNode declaringType, final String name,
final VariableScope scope) {
return bonitaVariables == null ? null : bonitaVariables.stream()
.filter(v -> v.getName().equals(name))
.findFirst()
.map(v -> {
ClassLoader cl = RepositoryManager.getInstance().getCurrentRepository().createProjectClassloader(null);
try {
ClassNode type = new ClassNode(cl.loadClass(v.getType()));
return new TypeAndDeclaration(type, null);
} catch (ClassNotFoundException e) {
BonitaStudioLog.error(e);
}
return null;
})
.orElse(null);
}
@Override
public void initialize(final GroovyCompilationUnit unit, final VariableScope topScope) {
}
public static void setBonitaVariables(List<ScriptVariable> nodes) {
bonitaVariables = nodes;
}
}
/**
* Copyright (C) 2010 BonitaSoft S.A.
* BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.groovy.ui.contentassist;
import java.util.ArrayList;
import java.util.List;
import org.codehaus.groovy.eclipse.codeassist.processors.IProposalFilter;
import org.codehaus.groovy.eclipse.codeassist.proposals.GroovyMethodProposal;
import org.codehaus.groovy.eclipse.codeassist.proposals.IGroovyProposal;
import org.codehaus.groovy.eclipse.codeassist.requestor.ContentAssistContext;
import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext;
/**
* @author Romain Bioteau
*/
public class BonitaProposalFilter implements IProposalFilter {
/*
* (non-Javadoc)
* @see org.codehaus.groovy.eclipse.codeassist.processors.IProposalFilter#filterProposals(java.util.List,
* org.codehaus.groovy.eclipse.codeassist.requestor.ContentAssistContext, org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext)
*/
@Override
public List<IGroovyProposal> filterProposals(final List<IGroovyProposal> proposals,
final ContentAssistContext assist, final JavaContentAssistInvocationContext context) {
final List<IGroovyProposal> filteredProposals = new ArrayList<IGroovyProposal>();
for (final IGroovyProposal p : proposals) {
if (p instanceof GroovyMethodProposal) {
if (!(((GroovyMethodProposal) p).getMethod().getDeclaringClass().getName().equals("org.codehaus.groovy.runtime.DefaultGroovyMethods")
|| ((GroovyMethodProposal) p).getMethod().getDeclaringClass().getName()
.equals("org.codehaus.groovy.runtime.DefaultGroovyStaticMethods"))) {
filteredProposals.add(p);
}
} else {
filteredProposals.add(p);
}
}
return filteredProposals;
}
}
......@@ -38,6 +38,7 @@ import org.bonitasoft.studio.expression.editor.viewer.SelectDependencyDialog;
import org.bonitasoft.studio.groovy.GroovyPlugin;
import org.bonitasoft.studio.groovy.ScriptVariable;
import org.bonitasoft.studio.groovy.ui.Messages;
import org.bonitasoft.studio.groovy.ui.contentassist.BonitaConstantsTypeLookup;
import org.bonitasoft.studio.groovy.ui.dialog.BonitaVariableLabelProvider;
import org.bonitasoft.studio.groovy.ui.dialog.GroovyEditorDocumentationDialogTray;
import org.bonitasoft.studio.groovy.ui.dialog.TestGroovyScriptDialog;
......@@ -515,6 +516,7 @@ public class GroovyScriptExpressionEditor extends SelectionAwareExpressionEditor
dependencyJob.setContext(context);
nodes.addAll(groovyViewer.getProvidedVariables(context, filters));
dependencyJob.setNodes(nodes);
BonitaConstantsTypeLookup.setBonitaVariables(nodes);
final InputLengthValidator lenghtValidator = new InputLengthValidator("", GroovyViewer.MAX_SCRIPT_LENGTH);
String content = inputExpression.getContent();
......
......@@ -24,11 +24,9 @@ import org.codehaus.groovy.eclipse.editor.GroovyColorManager;
import org.codehaus.groovy.eclipse.editor.GroovyConfiguration;
import org.codehaus.groovy.eclipse.editor.GroovyPartitionScanner;
import org.eclipse.jdt.groovy.core.util.ReflectionUtils;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory;
import org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor;
import org.eclipse.jdt.ui.text.IJavaPartitions;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.ContentAssistant;
......@@ -94,12 +92,4 @@ public class BonitaGroovyConfiguration extends GroovyConfiguration {
return assistant;
}
private IDialogSettings getSettings(final String sectionName) {
IDialogSettings settings = JavaPlugin.getDefault().getDialogSettings().getSection(sectionName);
if (settings == null) {
settings = JavaPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
}
return settings;
}
}
......@@ -15,12 +15,12 @@
package org.bonitasoft.studio.groovy.ui.viewer;
import org.codehaus.groovy.eclipse.editor.GroovyColorManager;
import org.codehaus.groovy.eclipse.GroovyPlugin;
import org.codehaus.groovy.eclipse.editor.GroovyEditor;
import org.codehaus.groovy.eclipse.editor.GroovyTextTools;
import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds;
import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
/**
......@@ -28,10 +28,6 @@ import org.eclipse.ui.texteditor.ITextEditorActionConstants;
*/
public class BonitaGroovyEditor extends GroovyEditor {
public BonitaGroovyEditor(final IPreferenceStore store) {
setPreferenceStore(store);
}
@Override
public void editorContextMenuAboutToShow(final IMenuManager menu) {
menu.dispose();
......@@ -84,7 +80,8 @@ public class BonitaGroovyEditor extends GroovyEditor {
@Override
public JavaSourceViewerConfiguration createJavaSourceViewerConfiguration() {
return new BonitaGroovyConfiguration(new GroovyColorManager(), getPreferenceStore(), this);
GroovyTextTools textTools = GroovyPlugin.getDefault().getTextTools();
return new BonitaGroovyConfiguration(textTools.getColorManager(), getPreferenceStore(), this);
}
}
......@@ -144,7 +144,8 @@ public class DummyEditorSite implements IEditorSite {
*/
@Override
public IWorkbenchPage getPage() {
return PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null ? PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() : null;
return PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null
? PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() : null;
}
/*
......
......@@ -47,22 +47,19 @@ import org.bonitasoft.studio.model.configuration.Configuration;
import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.parameter.Parameter;
import org.bonitasoft.studio.model.process.AbstractProcess;
import org.codehaus.groovy.eclipse.GroovyPlugin;
import org.codehaus.groovy.eclipse.core.preferences.PreferenceConstants;
import org.codehaus.groovy.eclipse.editor.GroovyEditor;
import org.codehaus.jdt.groovy.model.GroovyCompilationUnit;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.javaeditor.ASTProvider;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jface.text.ITextListener;
import org.eclipse.jface.text.TextEvent;
import org.eclipse.jface.text.source.CompositeRuler;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.jface.text.source.SourceViewer;
......@@ -76,6 +73,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.ISources;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.Workbench;
import org.eclipse.ui.part.FileEditorInput;
......@@ -102,8 +100,6 @@ public class GroovyViewer implements IDocumentListener {
private List<ScriptVariable> nodes;
private GroovyFileStore tmpGroovyFileStore;
private Set<String> knowVariables;
private boolean isPageFlowContext;
......@@ -133,9 +129,7 @@ public class GroovyViewer implements IDocumentListener {
public GroovyViewer(final Composite mainComposite, final IEditorInput input, final GroovyEditor groovyEditor,
boolean restrictScriptSize) {
this.restrictScriptSize = restrictScriptSize;
final IPreferenceStore groovyStore = org.codehaus.groovy.eclipse.GroovyPlugin.getDefault().getPreferenceStore();
groovyStore.setDefault(PreferenceConstants.GROOVY_SEMANTIC_HIGHLIGHTING, false);
groovyStore.setValue(PreferenceConstants.GROOVY_SEMANTIC_HIGHLIGHTING, false);
enbaleSyntaxHighligthing();
if (input == null) {
final ProvidedGroovyRepositoryStore store = RepositoryManager.getInstance()
.getRepositoryStore(ProvidedGroovyRepositoryStore.class);
......@@ -151,7 +145,7 @@ public class GroovyViewer implements IDocumentListener {
}
editor = groovyEditor;
if (editor == null) {
editor = new BonitaGroovyEditor(GroovyPlugin.getDefault().getPreferenceStore());
editor = new BonitaGroovyEditor();
}
try {
groovyEditorContext = createGroovyEditorContext();
......@@ -159,7 +153,11 @@ public class GroovyViewer implements IDocumentListener {
groovyEditorContext.set(ISources.ACTIVE_SITE_NAME, site);
editor.init(site, this.input);
editor.doSave(Repository.NULL_PROGRESS_MONITOR);
ASTProvider astProvider = JavaPlugin.getDefault().getASTProvider();
org.eclipse.jdt.groovy.core.util.ReflectionUtils.executePrivateMethod(ASTProvider.class,
"activeJavaEditorChanged", new Class[] { IWorkbenchPart.class }, astProvider, new Object[] { editor });
editor.createPartControl(mainComposite);
} catch (final Exception e1) {
BonitaStudioLog.error(e1);
}
......@@ -169,25 +167,6 @@ public class GroovyViewer implements IDocumentListener {
styledText.setTextLimit(MAX_SCRIPT_LENGTH);
}
getSourceViewer().addTextListener(new ITextListener() {
private boolean isReconciling;
@Override
public void textChanged(final TextEvent event) {
if (!isReconciling) {
isReconciling = true;
try {
JavaModelUtil.reconcile(editor.getGroovyCompilationUnit());
} catch (final JavaModelException e) {
} finally {
isReconciling = false;
}
}
}
});
styledText.setData(BONITA_KEYWORDS_DATA_KEY, getProvidedVariables(null, null));
styledText.addFocusListener(new FocusListener() {
......@@ -376,4 +355,16 @@ public class GroovyViewer implements IDocumentListener {
}
public void disableSyntaxHighligthing() {
final IPreferenceStore groovyStore = org.codehaus.groovy.eclipse.GroovyPlugin.getDefault().getPreferenceStore();
groovyStore.setDefault(PreferenceConstants.GROOVY_SEMANTIC_HIGHLIGHTING, false);
groovyStore.setValue(PreferenceConstants.GROOVY_SEMANTIC_HIGHLIGHTING, false);
}
public void enbaleSyntaxHighligthing() {
final IPreferenceStore groovyStore = org.codehaus.groovy.eclipse.GroovyPlugin.getDefault().getPreferenceStore();
groovyStore.setDefault(PreferenceConstants.GROOVY_SEMANTIC_HIGHLIGHTING, true);
groovyStore.setValue(PreferenceConstants.GROOVY_SEMANTIC_HIGHLIGHTING, true);
}
}
......@@ -34,7 +34,8 @@ Require-Bundle: org.eclipse.ui,
org.bonitasoft.studio.designer;bundle-version="7.1.0",
org.bonitasoft.studio.validation.common;bundle-version="7.1.0",
assertj-core;bundle-version="1.5.0";resolution:=optional,
org.bonitasoft.studio.contract;bundle-version="7.1.0"
org.bonitasoft.studio.contract;bundle-version="7.1.0",
org.eclipse.jdt.groovy.core;bundle-version="2.9.2"
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
......
......@@ -168,7 +168,7 @@
<unit id="org.eclipse.xpand.sdk.feature.group" version="2.2.0.v201605260315"/>
<unit id="org.eclipse.xsd.sdk.feature.group" version="2.13.0.v20170609-0928"/>
<unit id="org.eclipse.xtext.sdk.feature.group" version="2.12.0.v20170519-1412"/>
<repository location="http://download.eclipse.org/releases/oxygen/"/>
<repository location="http://repositories.rd.lan/p2/7.6"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="slicer" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.babel.nls_datatools_es.feature.group" version="4.7.0.v20170819060001"/>
......
......@@ -4,7 +4,7 @@
<target includeMode="feature" name="mirrored" sequenceNumber="153">
<locations>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="slicer" includeSource="true" type="InstallableUnit">
<repository location="http://repositories.rd.lan/p2/7.6"/>
<repository location="http://repositories.rd.lan/p2/7.6.1"/>
<unit id="org.apache.log4j" version="1.2.15.v201012070815"/>
<unit id="org.eclipse.swtbot.eclipse.feature.group" version="2.6.0.201706141832"/>
<unit id="org.eclipse.swtbot.eclipse.gef.feature.group" version="2.6.0.201706141832"/>
......
......@@ -126,7 +126,7 @@
<plugin>
<groupId>org.jboss.tools.tycho-plugins</groupId>
<artifactId>target-platform-utils</artifactId>
<version>${tychoVersion}</version>
<version>1.0.1-SNAPSHOT</version>
<executions>
<execution>
<phase>package</phase>
......@@ -135,7 +135,7 @@
</goals>
<configuration>
<executionEnvironment>JavaSE-1.8</executionEnvironment>
<includeSources>true</includeSources>
<!-- <includeSources>true</includeSources> -->
<outputRepository>${project.build.directory}/mirror</outputRepository>
</configuration>
</execution>
......
......@@ -19,7 +19,7 @@
<platform.version>${project.parent.version}</platform.version>
<theme.builder.version>1.1.0</theme.builder.version>
<watchdog.version>7.2.0</watchdog.version>
<p2MirrorUrl>http://repositories.rd.lan/p2/7.6</p2MirrorUrl>
<p2MirrorUrl>http://repositories.rd.lan/p2/7.6.1</p2MirrorUrl>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment