Commit 48cf5c46 authored by Kristof Szabados's avatar Kristof Szabados
Browse files

removed line ending whitespaces.


Signed-off-by: Kristof Szabados's avatarKristof Szabados <Kristof.Szabados@ericsson.com>
parent 6b206fce
......@@ -13,7 +13,7 @@ import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*
*
* @author Kristof Szabados
*/
public class Activator extends AbstractUIPlugin {
......@@ -41,7 +41,7 @@ public class Activator extends AbstractUIPlugin {
/**
* Sets the default singleton instance of this plug-in,
* that later can be used to access plug-in specific preference settings.
*
*
* @param activator the single instance of this plug-in class.
* */
private static void setDefault(final Activator activator) {
......
......@@ -52,7 +52,7 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation;
/**
* A class for utilities used by the refactoring classes.
* TODO needed? used consistently?
*
*
* @author Viktor Varga
*/
public class Utils {
......@@ -86,7 +86,7 @@ public class Utils {
final IEditorInput input = editor.getEditorInput();
if (!(input instanceof IFileEditorInput)) {
TITANDebugConsole.getConsole().newMessageStream()
.println("Utils.extractFile() during refactoring " +
.println("Utils.extractFile() during refactoring " +
refactoringName + ": IEditorInput is not an IFileEditorInput. ");
return null;
}
......@@ -102,7 +102,7 @@ public class Utils {
TTCN3Editor editor;
if (editorPart == null || !(editorPart instanceof TTCN3Editor)) {
TITANDebugConsole.getConsole().newMessageStream()
.println("Utils.updateASTForProjectActiveInEditor() during refactoring " +
.println("Utils.updateASTForProjectActiveInEditor() during refactoring " +
refactoringName + ": Only for TTCN3 editors!");
return;
} else {// TODO not needed else
......@@ -120,7 +120,7 @@ public class Utils {
if (job == null) {
TITANDebugConsole.getConsole().newMessageStream()
.println("Utils.updateASTForProjectActiveInEditor() during refactoring " +
refactoringName + ": WorkspaceJob to report outdating could not be created for project: " + selProject);
refactoringName + ": WorkspaceJob to report outdating could not be created for project: " + selProject);
return;
}
try {
......@@ -134,7 +134,7 @@ public class Utils {
if (job == null) {
TITANDebugConsole.getConsole().newMessageStream()
.println("Utils.updateASTForProjectActiveInEditor() during refactoring " +
refactoringName + ": WorkspaceJob to reanalyze project could not be created for project: " + selProject);
refactoringName + ": WorkspaceJob to reanalyze project could not be created for project: " + selProject);
return;
}
try {
......@@ -171,7 +171,7 @@ public class Utils {
* This needs to be saved before {@link Refactoring#createChange(org.eclipse.core.runtime.IProgressMonitor)} returns,
* because a successful refactoring operation clears the affected objects' list in the Change object.
* @param refactoringName The name of the operation
*
*
* */
public static void updateASTAfterRefactoring(final RefactoringWizard wiz, final Object[] affectedObjects, final String refactoringName) {
if (wiz.getChange() == null || wiz.getChange().getAffectedObjects() == null) {
......@@ -246,7 +246,7 @@ public class Utils {
* <p>
* Use an instance of this class as a parameter of the
* {@link ProgressMonitorDialog#run(boolean, boolean, IRunnableWithProgress)} method.
*
*
* */
private static class UpdateASTOp implements IRunnableWithProgress {
......@@ -276,16 +276,16 @@ public class Utils {
final WorkspaceJob job = projectSourceParser.analyzeAll();
if (job == null) {
TITANDebugConsole.getConsole().newMessageStream()
.println("Utils.updateASTOp: WorkspaceJob to analyze project could not be created for project "
+ proj.getName() + ", during the refactoring: " + name);
.println("Utils.updateASTOp: WorkspaceJob to analyze project could not be created for project "
+ proj.getName() + ", during the refactoring: " + name);
return;
}
try {
job.join();
} catch (InterruptedException e) {
TITANDebugConsole.getConsole().newMessageStream()
.println("Utils.updateASTOp: Error during semantic analysis of the project: "
+ proj.getName() + ", during the refactoring: " + name);
.println("Utils.updateASTOp: Error during semantic analysis of the project: "
+ proj.getName() + ", during the refactoring: " + name);
return;
}
if (monitor.isCanceled()) {
......
......@@ -206,7 +206,7 @@ class ChangeCreator {
job.schedule();
return job;
}
public int insertField(final TTCN3_Set_Seq_Choice_BaseType ss, final ILocateableNode node, final MultiTextEdit rootEdit, int vmLen) {
final Location nodeLocation = node.getLocation();
......@@ -238,7 +238,7 @@ class ChangeCreator {
private final NavigableSet<ILocateableNode> locations;
private final Type type;
DefinitionVisitor(final Type type) {
locations = new TreeSet<ILocateableNode>(new LocationComparator());
this.type = type;
......@@ -250,7 +250,6 @@ class ChangeCreator {
@Override
public int visit(final IVisitableNode node) {
if (node instanceof Def_Type && ((Def_Type)node).getType(CompilationTimeStamp.getBaseTimestamp()).equals(type)) {
final Definition d = (Definition)node;
locations.add(d);
......@@ -271,7 +270,6 @@ class ChangeCreator {
return V_CONTINUE;
}
}
/**
* Compares {@link ILocateableNode}s by comparing the file paths as strings.
......
......@@ -49,8 +49,8 @@ public class InsertFieldActionFromEditor extends AbstractHandler {
return null;
}
final IStructuredSelection structSelection = new StructuredSelection(selectedFile);
final InsertFieldRefactoring refactoring = new InsertFieldRefactoring(structSelection, null);
final InsertFieldRefactoring refactoring = new InsertFieldRefactoring(structSelection, null);
//open wizard
final InsertFieldWizard wiz = new InsertFieldWizard(refactoring, refactoring.getSelection());
final RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(wiz);
......
......@@ -50,9 +50,7 @@ public class InsertFieldRefactoring extends Refactoring {
private final Definition selection;
private final Set<IProject> projects = new HashSet<IProject>();
private final IStructuredSelection iselection;
private final Settings settings;
private Object[] affectedObjects; //the list of objects affected by the change
......@@ -76,7 +74,7 @@ public class InsertFieldRefactoring extends Refactoring {
public Definition getSelection() {
return selection;
}
public Object[] getAffectedObjects() {
return affectedObjects;
}
......@@ -135,12 +133,11 @@ public class InsertFieldRefactoring extends Refactoring {
throws CoreException, OperationCanceledException {
return new RefactoringStatus();
}
public Settings getSettings() {
return settings;
}
@Override
public Change createChange(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
if (iselection == null) {
......@@ -216,7 +213,7 @@ public class InsertFieldRefactoring extends Refactoring {
}
}
public static class Settings {
private String type;
private Identifier id;
......
......@@ -53,7 +53,7 @@ class ChangeCreator {
private static Map<Module, List<Module>> moduleImports = new HashMap<Module, List<Module>>();
// out
private Change change;
ChangeCreator(final IFile selectedFile, final MoveFunctionSettings settings, final List<FunctionData> functions, final IProject project) {
this.selectedFile = selectedFile;
......@@ -61,7 +61,7 @@ class ChangeCreator {
this.functions = functions;
this.project = project;
}
ChangeCreator(final IFile selectedFile, final MoveFunctionSettings settings, final List<FunctionData> functions, final IProject project, final Map<Module, List<Module>> mi) {
this.selectedFile = selectedFile;
this.settings = settings;
......@@ -82,7 +82,7 @@ class ChangeCreator {
if (selectedFile == null) {
return;
}
change = createFileChange(selectedFile);
}
......@@ -100,7 +100,7 @@ class ChangeCreator {
if (functions.isEmpty()) {
return null;
}
if (settings.getExcludedModuleNames() != null && settings.getExcludedModuleNames().matcher(module.getIdentifier().getTtcnName()).matches()) {
return null;
}
......@@ -113,7 +113,7 @@ class ChangeCreator {
if (noDestination) {
return null;
}
CompositeChange cc = null;
if (module instanceof TTCN3Module) {
cc = new CompositeChange("Moving functions from: "+module.getFullName());
......@@ -121,7 +121,7 @@ class ChangeCreator {
else {
return null;
}
final TextFileChange tfc = new TextFileChange(toVisit.getName(), toVisit);
cc.add(tfc);
final MultiTextEdit rootEdit = new MultiTextEdit();
......@@ -130,15 +130,15 @@ class ChangeCreator {
if(function.getFinalDestination() == null || !function.isToBeMoved()) {
continue;
}
final TextFileChange tfcDestination = new TextFileChange(function.getFinalDestination().getModule().getName(), (IFile) function.getFinalDestination().getModule().getLocation().getFile());
final MultiTextEdit rootEdit2 = new MultiTextEdit();
tfcDestination.setEdit(rootEdit2);
cc.add(tfcDestination);
final int length = function.getDefiniton().getLocation().getEndOffset() - function.getDefiniton().getLocation().getOffset();
final DeleteEdit deleteEdit = new DeleteEdit(function.getDefiniton().getLocation().getOffset(), length);
rootEdit.addChild(deleteEdit);
if (!moduleImports.containsKey(function.getFinalDestination().getModule())) {
rootEdit.addChild(deleteEdit);
if (!moduleImports.containsKey(function.getFinalDestination().getModule())) {
moduleImports.put(function.getFinalDestination().getModule(), new ArrayList<Module>());
}
final InsertEdit importEdit = insertMissingImports(function.getFinalDestination().getModule(), function.getUsedModules());
......@@ -169,22 +169,22 @@ class ChangeCreator {
}
return cc;
}
private InsertEdit insertMissingImports(final Module destinationModule, final List<Module> usedModules) {
final List<Module> importedModules = destinationModule.getImportedModules();
String importText = "";
for (final Module m : usedModules) {
if (!importedModules.contains(m)
&& !m.equals(destinationModule)
if (!importedModules.contains(m)
&& !m.equals(destinationModule)
&& !moduleImports.get(destinationModule).contains(m)) {
importText += "import from "+m.getIdentifier().getTtcnName()+" all;\n ";
moduleImports.get(destinationModule).add(m);
}
}
final TextFileChange insertImports = new TextFileChange(destinationModule.getName(),
(IFile)destinationModule.getLocation().getFile());
final TextFileChange insertImports = new TextFileChange(destinationModule.getName(),
(IFile)destinationModule.getLocation().getFile());
final MultiTextEdit rootEdit = new MultiTextEdit();
insertImports.setEdit(rootEdit);
int offset = destinationModule.getLocation().getEndOffset();
......@@ -202,27 +202,27 @@ class ChangeCreator {
}
return new InsertEdit(offset, importText);
}
private void findFunctionUses(final FunctionData function) {
final ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(project);
for(final Module m : projectSourceParser.getModules()) {
if (!m.equals(function.getFinalDestination().getModule())) {
final ModuleVisitor vis = new ModuleVisitor(function.getDefiniton());
m.accept(vis);
if (vis.getIsUsed()
& !m.getImportedModules().contains(function.getFinalDestination().getModule())
if (vis.getIsUsed()
& !m.getImportedModules().contains(function.getFinalDestination().getModule())
& !m.equals(function.getFinalDestination().getModule())) {
function.addUsedBy(m);
}
}
}
}
private static class ModuleVisitor extends ASTVisitor {
private final Def_Function function;
private final Def_Function function;
private boolean isUsed;
public ModuleVisitor(final Def_Function function) {
this.function = function;
this.isUsed = false;
......@@ -238,7 +238,7 @@ class ChangeCreator {
}
return V_CONTINUE;
}
public boolean getIsUsed() {
return isUsed;
}
......
......@@ -26,7 +26,7 @@ public class FunctionData implements Comparable<FunctionData> {
private Destination finalDestination;
private MoveFunctionMethod method;
private final List<Module> usedBy;
public FunctionData(final Def_Function definiton, final String functionBody) {
this.definiton = definiton;
this.functionBody = functionBody;
......@@ -35,78 +35,78 @@ public class FunctionData implements Comparable<FunctionData> {
usedModules = new ArrayList<Module>();
usedBy = new ArrayList<Module>();
}
public void setToBeMoved(final boolean toBeMoved) {
this.toBeMoved = toBeMoved;
}
public void setModule(final Module module) {
this.module = module;
}
public void addDestination(final Module destination, final Integer rating, final int newImports) {
destinations.add(new Destination(destination, rating, this, newImports));
}
public void addUsedModule(final Module module) {
usedModules.add(module);
}
public void addUsedModules(final List<Module> modules) {
usedModules.addAll(modules);
}
public void addUsedBy(final Module m) {
usedBy.add(m);
}
public void setUsedModules(final List<Module> modules) {
usedModules = modules;
}
public void setFinalDestination(final Destination destination) {
this.finalDestination = destination;
if(destination != null) {
destination.setFunctionData(this);
}
}
public void setRefactoringMethod(final MoveFunctionMethod rMethod) {
this.method = rMethod;
}
public Def_Function getDefiniton() {
return definiton;
}
public String getFunctionBody() {
return functionBody;
}
public boolean isToBeMoved() {
return toBeMoved;
}
public List<Destination> getDestinations() {
return destinations;
}
public Module getModule() {
return module;
}
public List<Module> getUsedModules() {
return usedModules;
}
public List<Module> getUsedBy() {
return usedBy;
}
public Destination getFinalDestination() {
return finalDestination;
}
public MoveFunctionMethod getRefactoringMethod() {
return method;
}
......@@ -115,11 +115,11 @@ public class FunctionData implements Comparable<FunctionData> {
public int compareTo(final FunctionData arg0) {
return this.getDefiniton().getIdentifier().getDisplayName().compareToIgnoreCase(arg0.getDefiniton().getIdentifier().getDisplayName());
}
public void clearDestinations() {
destinations.clear();
}
}
class Destination implements Comparable<Destination> {
......@@ -127,47 +127,47 @@ class Destination implements Comparable<Destination> {
private int rating;
private FunctionData functionData;
private int newImports;
public Destination() {
}
public Destination(final Module module, final int rating, final FunctionData functionData, final int newImports) {
this.module = module;
this.rating = rating;
this.functionData = functionData;
this.newImports = newImports;
}
public Module getModule() {
return module;
}
public int getRating() {
return rating;
}
public FunctionData getFunctionData() {
return functionData;
}
public int getNewImports() {
return newImports;
}
public void setModule(final Module module) {
this.module = module;
}
public void setRating(final int rating) {
this.rating = rating;
}
public void setFunctionData(final FunctionData functionData) {
this.functionData = functionData;
}
public void setNewImports(final int newImports) {
this.newImports = newImports;
}
......
......@@ -65,11 +65,11 @@ import org.eclipse.titan.designer.productUtilities.ProductConstants;
* @author Bianka Bekefi
* */
public class MoveFunctionRefactoring extends Refactoring {
public static final String PROJECTCONTAINSERRORS = "The project `{0}'' contains errors, which might corrupt the result of the refactoring";
public static final String PROJECTCONTAINSTTCNPPFILES = "The project `{0}'' contains .ttcnpp files, which might corrupt the result of the refactoring";
private static final String ONTHEFLYANALAYSISDISABLED = "The on-the-fly analysis is disabled, there is semantic information present to work on";
private final Set<IProject> projects = new HashSet<IProject>();
private Module destinationModule;
private final List<Module> selectedModules = new ArrayList<Module>();
......@@ -84,7 +84,7 @@ public class MoveFunctionRefactoring extends Refactoring {
super();
this.structSelection = selection;
this.settings = settings;
final Iterator<?> it = selection.iterator();
while (it.hasNext()) {
final Object o = it.next();
......@@ -94,19 +94,19 @@ public class MoveFunctionRefactoring extends Refactoring {
}
}
}
@Override
public RefactoringStatus checkInitialConditions(final IProgressMonitor pm)
throws CoreException, OperationCanceledException {
result = new RefactoringStatus();
try{
pm.beginTask("Checking preconditions...", 2);
final IPreferencesService prefs = Platform.getPreferencesService();//PreferenceConstants.USEONTHEFLYPARSING
if (! prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEONTHEFLYPARSING, false, null)) {
result.addError(ONTHEFLYANALAYSISDISABLED);
}
// check that there are no ttcnpp files in the
// project
for (final IProject project : projects) {
......@@ -114,21 +114,21 @@ public class MoveFunctionRefactoring extends Refactoring {
result.addError(MessageFormat.format(PROJECTCONTAINSTTCNPPFILES, project));
}
}
pm.worked(1);
// check that there are no error markers in the
// project
for (final IProject project : projects) {
final IMarker[] markers = project.findMarkers(null, true, IResource.DEPTH_INFINITE);
for (final IMarker marker : markers) {
if (IMarker.SEVERITY_ERROR == marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR)) {
result.addError(MessageFormat.format(PROJECTCONTAINSERRORS, project));
break;
}
}
}