Commit 139f333a authored by Romain Bioteau's avatar Romain Bioteau

BS-6723 + BS-8455

Improve groovy refactoring
Do not add dependencies for new declared variables
parent 8a9d91a2
......@@ -461,4 +461,11 @@
version="0.0.0"
unpack="false"/>
<plugin
id="org.bonitasoft.studio.refactoring"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>
......@@ -46,9 +46,10 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.compare;bundle-version="1.2.2",
org.eclipse.emf.compare.diff;bundle-version="1.2.2",
org.eclipse.emf.compare.match,
org.bonitasoft.studio.refactoring;bundle-version="6.3.0",
assertj-core;bundle-version="1.5.0";resolution:=optional,
org.junit;bundle-version="4.11.0";resolution:=optional,
org.mockito;bundle-version="1.9.5";resolution:=optional,
assertj-core;bundle-version="1.5.0";resolution:=optional
org.mockito;bundle-version="1.9.5";resolution:=optional
Bundle-ActivationPolicy: lazy
Import-Package: org.bonitasoft.engine.api,
org.bonitasoft.engine.bpm,
......
......@@ -22,9 +22,6 @@ import java.util.List;
import org.bonitasoft.studio.actors.i18n.Messages;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.common.refactoring.AbstractRefactorOperation;
import org.bonitasoft.studio.common.refactoring.AbstractScriptExpressionRefactoringAction;
import org.bonitasoft.studio.common.refactoring.RefactoringOperationType;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.diagram.custom.repository.ProcessConfigurationFileStore;
import org.bonitasoft.studio.diagram.custom.repository.ProcessConfigurationRepositoryStore;
......@@ -36,12 +33,16 @@ import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.process.AbstractProcess;
import org.bonitasoft.studio.model.process.Actor;
import org.bonitasoft.studio.model.process.ProcessPackage;
import org.bonitasoft.studio.refactoring.core.AbstractRefactorOperation;
import org.bonitasoft.studio.refactoring.core.AbstractScriptExpressionRefactoringAction;
import org.bonitasoft.studio.refactoring.core.RefactoringOperationType;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jdt.core.IJavaProject;
/**
* @author Aurelie Zara
......
......@@ -31,9 +31,11 @@ Require-Bundle: org.eclipse.gmf.runtime.lite.svg;bundle-version="1.0.0",
org.eclipse.jface.databinding;bundle-version="1.5.0",
org.eclipse.gmf.runtime.draw2d.ui.render;bundle-version="1.4.1",
org.eclipse.gmf.runtime.draw2d.ui.render.awt;bundle-version="1.4.1",
org.eclipse.gmf.runtime.diagram.ui.actions
org.eclipse.gmf.runtime.diagram.ui.actions,
org.bonitasoft.studio.refactoring;bundle-version="6.3.0"
Export-Package: org.bonitasoft.studio.common,
org.bonitasoft.studio.common.diagram.palette,
org.bonitasoft.studio.common.diagram.refactoring,
org.bonitasoft.studio.common.diagram.tools,
org.bonitasoft.studio.common.editPolicies,
org.bonitasoft.studio.common.figures,
......
......@@ -14,7 +14,7 @@
* 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.common.refactoring;
package org.bonitasoft.studio.common.diagram.refactoring;
import java.util.List;
......@@ -22,15 +22,21 @@ import org.bonitasoft.studio.common.ExpressionConstants;
import org.bonitasoft.studio.common.Messages;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.common.emf.tools.WidgetHelper;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.expression.ExpressionPackage;
import org.bonitasoft.studio.model.form.Widget;
import org.bonitasoft.studio.refactoring.core.AbstractRefactorOperation;
import org.bonitasoft.studio.refactoring.core.AbstractScriptExpressionRefactoringAction;
import org.bonitasoft.studio.refactoring.core.RefactoringOperationType;
import org.bonitasoft.studio.refactoring.core.WidgetScriptExpressionRefactoringAction;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jdt.core.IJavaProject;
/**
* @author Aurelie Zara
......@@ -104,4 +110,5 @@ public class RemoveWidgetReferencesOperation extends AbstractRefactorOperation {
refactoredScriptExpression, compoundCommand, domain,
operationType);
}
}
......@@ -22,10 +22,10 @@ import java.util.ArrayList;
import java.util.List;
import org.bonitasoft.studio.common.Messages;
import org.bonitasoft.studio.common.diagram.refactoring.RemoveWidgetReferencesOperation;
import org.bonitasoft.studio.common.dialog.OutlineDialog;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.refactoring.RemoveWidgetReferencesOperation;
import org.bonitasoft.studio.model.form.Widget;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
......
......@@ -40,7 +40,12 @@ Require-Bundle: org.eclipse.core.runtime,
org.mockito;bundle-version="1.9.5";resolution:=optional,
org.eclipse.compare;bundle-version="3.5.202",
assertj-core;bundle-version="1.5.0";resolution:=optional,
org.bonitasoft.studio.model.assertions;bundle-version="6.3.0";resolution:=optional
org.bonitasoft.studio.model.assertions;bundle-version="6.3.0";resolution:=optional,
org.codehaus.groovy.eclipse.core,
org.codehaus.groovy;bundle-version="1.8.6",
org.eclipse.jdt.groovy.core,
org.codehaus.groovy.eclipse.codeassist.completion,
org.eclipse.xtext.ui
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Import-Package: org.bonitasoft.engine.bpm.bar,
......@@ -70,7 +75,6 @@ Export-Package: org.bonitasoft.studio.common,
org.bonitasoft.studio.common.perspectives,
org.bonitasoft.studio.common.platform.tools,
org.bonitasoft.studio.common.properties,
org.bonitasoft.studio.common.refactoring,
org.bonitasoft.studio.common.views,
org.bonitasoft.studio.common.widgets
Bundle-ClassPath: .,
......
......@@ -5,18 +5,17 @@
* 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
* 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/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.common;
import java.util.Date;
import java.util.List;
......@@ -35,36 +34,36 @@ import org.bonitasoft.studio.model.process.XMLType;
/**
* @author Romain Bioteau
*
*
*/
public class DataUtil {
public static String getTechnicalTypeFor(Data data) {
DataType type = data.getDataType() ;
if(data.isMultiple()){
return List.class.getName() ;
}
if (data instanceof JavaObjectData) {
return ((JavaObjectData) data).getClassName() ;
}else if (type instanceof DateType) {
return Date.class.getName();
} else if (type instanceof StringType) {
return String.class.getName();
} else if (type instanceof IntegerType) {
return Integer.class.getName();
} else if (type instanceof FloatType) {
return Float.class.getName();
} else if (type instanceof LongType) {
return Long.class.getName();
} else if (type instanceof DoubleType) {
return Double.class.getName();
} else if (type instanceof BooleanType) {
return Boolean.class.getName();
} else if (type instanceof EnumType) {
return String.class.getName() ;
} else if (type instanceof XMLType) {
return String.class.getName();
}
return null;
}
public static String getTechnicalTypeFor(Data data) {
DataType type = data.getDataType();
if (data.isMultiple()) {
return List.class.getName();
}
if (data instanceof JavaObjectData) {
return ((JavaObjectData) data).getClassName();
} else if (type instanceof DateType) {
return Date.class.getName();
} else if (type instanceof StringType) {
return String.class.getName();
} else if (type instanceof IntegerType) {
return Integer.class.getName();
} else if (type instanceof FloatType) {
return Float.class.getName();
} else if (type instanceof LongType) {
return Long.class.getName();
} else if (type instanceof DoubleType) {
return Double.class.getName();
} else if (type instanceof BooleanType) {
return Boolean.class.getName();
} else if (type instanceof EnumType) {
return String.class.getName();
} else if (type instanceof XMLType) {
return String.class.getName();
}
return null;
}
}
......@@ -38,7 +38,8 @@ Require-Bundle: org.eclipse.ui,
assertj-core;bundle-version="1.5.0";resolution:=optional,
org.bonitasoft.studio.model.assertions;bundle-version="6.3.0";resolution:=optional,
org.mockito;bundle-version="1.9.5";resolution:=optional,
org.powermock;resolution:=optional
org.powermock;resolution:=optional,
org.bonitasoft.studio.refactoring;bundle-version="6.3.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: org.bonitasoft.studio.data.attachment.repository,
......@@ -53,3 +54,4 @@ Export-Package: org.bonitasoft.studio.data.attachment.repository,
org.bonitasoft.studio.data.util
Import-Package: org.bonitasoft.engine.bpm.bar,
org.bonitasoft.engine.bpm.document
......@@ -7,13 +7,13 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.Collections;
import org.bonitasoft.studio.common.refactoring.RefactoringOperationType;
import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.expression.ExpressionFactory;
import org.bonitasoft.studio.model.parameter.Parameter;
import org.bonitasoft.studio.model.parameter.ParameterFactory;
import org.bonitasoft.studio.model.process.Data;
import org.bonitasoft.studio.model.process.ProcessFactory;
import org.bonitasoft.studio.refactoring.core.RefactoringOperationType;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.ecore.EObject;
import org.junit.After;
......
......@@ -20,7 +20,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import org.bonitasoft.studio.common.ExpressionConstants;
import org.bonitasoft.studio.common.emf.tools.ExpressionHelper;
import org.bonitasoft.studio.common.refactoring.RefactoringOperationType;
import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.expression.ExpressionFactory;
import org.bonitasoft.studio.model.expression.Operation;
......@@ -30,6 +29,7 @@ import org.bonitasoft.studio.model.process.Data;
import org.bonitasoft.studio.model.process.ProcessFactory;
import org.bonitasoft.studio.model.process.Task;
import org.bonitasoft.studio.model.process.util.ProcessAdapterFactory;
import org.bonitasoft.studio.refactoring.core.RefactoringOperationType;
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
......
......@@ -5,10 +5,10 @@ package org.bonitasoft.studio.data.operation;
import java.util.List;
import org.bonitasoft.studio.common.refactoring.AbstractScriptExpressionRefactoringAction;
import org.bonitasoft.studio.common.refactoring.RefactoringOperationType;
import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.process.Data;
import org.bonitasoft.studio.refactoring.core.AbstractScriptExpressionRefactoringAction;
import org.bonitasoft.studio.refactoring.core.RefactoringOperationType;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.EditingDomain;
......
......@@ -25,9 +25,7 @@ import org.bonitasoft.studio.common.DataUtil;
import org.bonitasoft.studio.common.ExpressionConstants;
import org.bonitasoft.studio.common.emf.tools.ExpressionHelper;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.common.refactoring.AbstractRefactorOperation;
import org.bonitasoft.studio.common.refactoring.AbstractScriptExpressionRefactoringAction;
import org.bonitasoft.studio.common.refactoring.RefactoringOperationType;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.data.i18n.Messages;
import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.expression.ExpressionPackage;
......@@ -36,6 +34,9 @@ import org.bonitasoft.studio.model.process.Data;
import org.bonitasoft.studio.model.process.MultiInstantiation;
import org.bonitasoft.studio.model.process.Pool;
import org.bonitasoft.studio.model.process.ProcessPackage;
import org.bonitasoft.studio.refactoring.core.AbstractRefactorOperation;
import org.bonitasoft.studio.refactoring.core.AbstractScriptExpressionRefactoringAction;
import org.bonitasoft.studio.refactoring.core.RefactoringOperationType;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.command.CompoundCommand;
......@@ -46,6 +47,7 @@ import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jdt.core.IJavaProject;
/**
* @author Romain Bioteau
......
......@@ -29,7 +29,6 @@ import org.bonitasoft.studio.common.jface.CustomWizardDialog;
import org.bonitasoft.studio.common.jface.DataStyledTreeLabelProvider;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.properties.AbstractBonitaDescriptionSection;
import org.bonitasoft.studio.common.refactoring.RefactoringOperationType;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.data.DataPlugin;
import org.bonitasoft.studio.data.commands.MoveDataCommand;
......@@ -43,6 +42,7 @@ import org.bonitasoft.studio.model.process.DataAware;
import org.bonitasoft.studio.model.process.Element;
import org.bonitasoft.studio.model.process.Lane;
import org.bonitasoft.studio.model.process.ProcessPackage;
import org.bonitasoft.studio.refactoring.core.RefactoringOperationType;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.operations.OperationHistoryFactory;
import org.eclipse.core.databinding.ObservablesManager;
......
......@@ -27,7 +27,6 @@ import org.bonitasoft.studio.common.DatasourceConstants;
import org.bonitasoft.studio.common.IBonitaVariableContext;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.refactoring.RefactoringOperationType;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.data.DataPlugin;
import org.bonitasoft.studio.data.i18n.Messages;
......@@ -38,6 +37,7 @@ import org.bonitasoft.studio.model.process.Data;
import org.bonitasoft.studio.model.process.ProcessFactory;
import org.bonitasoft.studio.model.process.ProcessPackage;
import org.bonitasoft.studio.pics.Pics;
import org.bonitasoft.studio.refactoring.core.RefactoringOperationType;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
......
......@@ -1247,6 +1247,7 @@ public class DataWizardPage extends WizardPage implements IBonitaVariableContext
className = List.class.getName();
}
if (!defaultValue.isReturnTypeFixed()) {
returnTypeObservable.setValue(null);
returnTypeObservable.setValue(className);
} else {
Object value = returnTypeObservable.getValue();
......
......@@ -20,9 +20,10 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.gmf.runtime.diagram.ui.properties;bundle-version="1.4.0",
org.bonitasoft.studio.migration;bundle-version="1.0.0",
org.eclipse.emf.codegen,
org.bonitasoft.studio.refactoring;bundle-version="6.3.0",
org.fest-assert;bundle-version="1.4.2";resolution:=optional,
org.mockito;bundle-version="1.9.5";resolution:=optional,
org.junit;bundle-version="4.8.2";resolution:=optional
org.junit;bundle-version="4.11.0";resolution:=optional
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.bonitasoft.studio.diagram.form.custom.clipboard,
......
......@@ -22,10 +22,10 @@ import java.util.ArrayList;
import java.util.List;
import org.bonitasoft.studio.common.Messages;
import org.bonitasoft.studio.common.diagram.refactoring.RemoveWidgetReferencesOperation;
import org.bonitasoft.studio.common.dialog.OutlineDialog;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.refactoring.RemoveWidgetReferencesOperation;
import org.bonitasoft.studio.model.form.Widget;
import org.bonitasoft.studio.model.process.Element;
import org.bonitasoft.studio.model.process.diagram.form.edit.parts.FormEditPart;
......
......@@ -38,7 +38,8 @@ Require-Bundle: org.eclipse.ui,
org.bonitasoft.studio.diagram.custom;bundle-version="1.0.0",
org.junit;bundle-version="4.11.0";resolution:=optional,
assertj-core;bundle-version="1.5.0";resolution:=optional,
org.bonitasoft.studio.model.assertions;bundle-version="6.3.0";resolution:=optional
org.bonitasoft.studio.model.assertions;bundle-version="6.3.0";resolution:=optional,
org.bonitasoft.studio.refactoring;bundle-version="6.3.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Localization: plugin
......
......@@ -23,16 +23,17 @@ import org.bonitasoft.studio.common.ExpressionConstants;
import org.bonitasoft.studio.common.emf.tools.ExpressionHelper;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.common.emf.tools.WidgetHelper;
import org.bonitasoft.studio.common.refactoring.AbstractRefactorOperation;
import org.bonitasoft.studio.common.refactoring.AbstractScriptExpressionRefactoringAction;
import org.bonitasoft.studio.common.refactoring.RefactoringOperationType;
import org.bonitasoft.studio.common.refactoring.WidgetScriptExpressionRefactoringAction;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.form.properties.i18n.Messages;
import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.expression.ExpressionPackage;
import org.bonitasoft.studio.model.form.FormFactory;
import org.bonitasoft.studio.model.form.Widget;
import org.bonitasoft.studio.model.process.ProcessPackage;
import org.bonitasoft.studio.refactoring.core.AbstractRefactorOperation;
import org.bonitasoft.studio.refactoring.core.AbstractScriptExpressionRefactoringAction;
import org.bonitasoft.studio.refactoring.core.RefactoringOperationType;
import org.bonitasoft.studio.refactoring.core.WidgetScriptExpressionRefactoringAction;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.ecore.EObject;
......@@ -40,6 +41,7 @@ import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jdt.core.IJavaProject;
/**
* @author Romain Bioteau
......
......@@ -28,7 +28,8 @@ Require-Bundle: org.eclipse.ui,
org.junit;bundle-version="4.8.2";resolution:=optional,
org.mockito;bundle-version="1.9.5";resolution:=optional,
org.powermock;bundle-version="1.5.2";resolution:=optional,
assertj-core;bundle-version="1.5.0";resolution:=optional
assertj-core;bundle-version="1.5.0";resolution:=optional,
org.bonitasoft.studio.refactoring;bundle-version="6.3.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: org.bonitasoft.studio.expression.editor,
......
......@@ -35,7 +35,6 @@ import org.bonitasoft.studio.common.extension.BonitaStudioExtensionRegistryManag
import org.bonitasoft.studio.common.jface.SWTBotConstants;
import org.bonitasoft.studio.common.jface.databinding.validator.EmptyInputValidator;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.refactoring.AbstractRefactorOperation;
import org.bonitasoft.studio.expression.editor.ExpressionEditorPlugin;
import org.bonitasoft.studio.expression.editor.autocompletion.AutoCompletionField;
import org.bonitasoft.studio.expression.editor.autocompletion.BonitaContentProposalAdapter;
......@@ -59,6 +58,7 @@ import org.bonitasoft.studio.model.form.TextFormField;
import org.bonitasoft.studio.model.form.Widget;
import org.bonitasoft.studio.pics.Pics;
import org.bonitasoft.studio.pics.PicsConstants;
import org.bonitasoft.studio.refactoring.core.AbstractRefactorOperation;
import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.UpdateValueStrategy;
......
......@@ -43,4 +43,4 @@ evaluationResults=Evaluation results
testGroovyScriptDialogDescription=For each data below a value is needed in order to evaluate the groovy script.
nameHelp=The name of the script corresponds to the generated Groovy class which encloses it, See Groovy documentation for more information.
scriptNameAlreadyExists=A script with the same name already exists.
warningAssigningAVariableWithSameNameAsProcessVariable={0} is a process variable and should not be used in a declaration statement.
\ No newline at end of file
......@@ -6,14 +6,14 @@
* 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
* 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/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.groovy.ui;
......@@ -24,60 +24,96 @@ public final class Messages extends NLS {
private static final String BUNDLE_NAME = "messages";//$NON-NLS-1$
public static String testButtonLabel;
public static String functionDocTitle;
public static String functionTitle;
public static String categoriesTitle;
public static String saveWizardPageTitle;
public static String saveWizardPageMessage;
public static String saveWizardPageDescription;
public static String nameLabel;
public static String overwriteQuestionTitle;
public static String overwriteQuestionMessage;
public static String openScriptWizardPage_title;
public static String openScriptWizardPage_desc;
public static String removeScriptLabel;
public static String confirmScriptDeleteTitle;
public static String confirmScriptDeleteMessage;
public static String openScriptLabel;
public static String noProcessVariableAvailable;
public static String saveSuccesfullTitle;
public static String saveSuccesfullMessage;
public static String processVariableLabel;
public static String selectData;
public static String groovyDocumentationLink;
public static String browseJava;
public static String wrongName;
public static String scriptNameMustBeValid;
public static String createScript;
public static String scriptNameDialogTitle;
public static String scriptNameDialogMessage;
public static String warning;
public static String warningMessageSystemExit;
public static String scriptEvaluation ;
public static String scriptEvaluation;
public static String returnType;
public static String add;
public static String remove;
public static String automaticResolution;
public static String SelectProcessVariableLabel;
public static String SelectBonitasVariableLabel;
public static String unknownVariableLabel;
public static String groovyUnresolved;
public static String manageGroovyScripts;
public static String evaluationResults;
public static String testGroovyScriptDialogDescription;
public static String testGroovyScriptDialogDescription;
public static String nameHelp;
public static String nameHelp;
public static String scriptNameAlreadyExists;
public static String scriptNameAlreadyExists;
public static String wrongNameLowCase;
public static String wrongNameLowCase;
public static String warningAssigningAVariableWithSameNameAsProcessVariable;
private Messages() {
// Do not instantiate
......@@ -86,4 +122,4 @@ public final class Messages extends NLS {
static {
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
}
\ No newline at end of file
}
......@@ -17,6 +17,7 @@ package org.bonitasoft.studio.groovy.ui.job;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
......@@ -26,126 +27,117 @@ import org.bonitasoft.studio.expression.editor.ExpressionEditorService;
import org.bonitasoft.studio.expression.editor.provider.IExpressionProvider;
import org.bonitasoft.studio.groovy.GroovyUtil;
import org.bonitasoft.studio.groovy.ScriptVariable;
import org.bonitasoft.studio.groovy.ui.Activator;
import org.bonitasoft.studio.model.expression.Expression;
import org.codehaus.groovy.ast.Variable;
import org.codehaus.groovy.ast.stmt.BlockStatement;
import org.codehaus.groovy.eclipse.codeassist.requestor.CompletionNodeFinder;
import org.codehaus.groovy.eclipse.codeassist.requestor.ContentAssistContext;
import org.codehaus.jdt.groovy.model.GroovyCompilationUnit;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.FindReplaceDocumentAdapter;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jdt.core.JavaModelException;
/**
* @author Romain Bioteau
*/
public class ComputeScriptDependenciesJob extends Job {
private final Map<String, List<EObject>> cache;
private List<ScriptVariable> nodes;
private EObject context;
private IDocument document;
public ComputeScriptDependenciesJob(final IDocument document) {
super(ComputeScriptDependenciesJob.class.getName());
cache = new HashMap<String, List<EObject>>();
this.document = document;
}
@Override
protected IStatus run(final IProgressMonitor monitor) {
final String expression = document.get();
if (cache.get(expression) == null) {
final Set<String> foundVariable = new HashSet<String>();
final FindReplaceDocumentAdapter finder = new FindReplaceDocumentAdapter(document);
for (final ScriptVariable f : nodes) {
IRegion index;
try {
index = finder.find(0, f.getName(), true, true, true, false);
while (index != null && !foundVariable.contains(f.getName())) {
if (index != null && !isInAStringExpression(f.getName(),index,expression)) {
foundVariable.add(f.getName());
}