Cleanup dltk.ui bundle.
Mostly unneeded else clauses and autoformating but other small fixes
also while looking at the code.
Change-Id: I71bdb778985270192a2007c1b01cbc460295c1c5
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/core/plugins/org.eclipse.dltk.ui/META-INF/MANIFEST.MF b/core/plugins/org.eclipse.dltk.ui/META-INF/MANIFEST.MF
index 7c0cb4e..2d2f00e 100644
--- a/core/plugins/org.eclipse.dltk.ui/META-INF/MANIFEST.MF
+++ b/core/plugins/org.eclipse.dltk.ui/META-INF/MANIFEST.MF
@@ -108,3 +108,4 @@
org.eclipse.dltk.ui.wizards
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
+Automatic-Module-Name: org.eclipse.dltk.ui
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/Checks.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/Checks.java
index e396ce7..acfffd7 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/Checks.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/Checks.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
*
-
*******************************************************************************/
package org.eclipse.dltk.internal.corext.refactoring;
@@ -16,48 +15,49 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.dltk.core.DLTKCore;
-import org.eclipse.dltk.core.ScriptModelUtil;
-import org.eclipse.dltk.core.IScriptProject;
import org.eclipse.dltk.core.IModelElement;
import org.eclipse.dltk.core.IProjectFragment;
+import org.eclipse.dltk.core.IScriptProject;
import org.eclipse.dltk.core.ISourceModule;
import org.eclipse.dltk.core.ModelException;
+import org.eclipse.dltk.core.ScriptModelUtil;
import org.eclipse.dltk.internal.corext.refactoring.changes.RenameResourceChange;
import org.eclipse.dltk.internal.corext.refactoring.util.ResourceUtil;
import org.eclipse.dltk.internal.corext.util.Messages;
import org.eclipse.dltk.internal.corext.util.Resources;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-
-
/**
* This class defines a set of reusable static checks methods.
*/
public class Checks {
-
+
/*
* no instances
*/
- private Checks(){
+ private Checks() {
}
-
+
/* Constants returned by checkExpressionIsRValue */
- public static final int IS_RVALUE= 0;
- public static final int NOT_RVALUE_MISC= 1;
- public static final int NOT_RVALUE_VOID= 2;
-
- public static boolean isAvailable(IModelElement modelElement) throws ModelException {
+ public static final int IS_RVALUE = 0;
+ public static final int NOT_RVALUE_MISC = 1;
+ public static final int NOT_RVALUE_VOID = 2;
+
+ public static boolean isAvailable(IModelElement modelElement)
+ throws ModelException {
if (modelElement == null)
return false;
- if (! modelElement.exists())
+ if (!modelElement.exists())
return false;
if (modelElement.isReadOnly())
return false;
// work around for https://bugs.eclipse.org/bugs/show_bug.cgi?id=48422
- // the Script project is now cheating regarding its children so we shouldn't
+ // the Script project is now cheating regarding its children so we
+ // shouldn't
// call isStructureKnown if the project isn't open.
// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=52474
- if (!(modelElement instanceof IScriptProject) && !modelElement.isStructureKnown())
+ if (!(modelElement instanceof IScriptProject)
+ && !modelElement.isStructureKnown())
return false;
if (DLTKCore.DEBUG) {
System.err.println("Add binary modules support."); //$NON-NLS-1$
@@ -66,42 +66,54 @@
// return false;
return true;
}
+
public static boolean isBuildpathDelete(IProjectFragment pkgRoot) {
- IResource res= pkgRoot.getResource();
+ IResource res = pkgRoot.getResource();
if (res == null)
return true;
- IProject definingProject= res.getProject();
- if (res.getParent() != null && pkgRoot.isArchive() && !res.getParent().equals(definingProject))
+ IProject definingProject = res.getProject();
+ if (res.getParent() != null && pkgRoot.isArchive()
+ && !res.getParent().equals(definingProject))
return true;
-
- IProject occurringProject= pkgRoot.getScriptProject().getProject();
+
+ IProject occurringProject = pkgRoot.getScriptProject().getProject();
return !definingProject.equals(occurringProject);
}
- public static RefactoringStatus checkSourceModuleNewName(ISourceModule cu, String newName) {
- String newCUName= ScriptModelUtil.getRenamedCUName(cu, newName);
- if (resourceExists(RenameResourceChange.renamedResourcePath(ResourceUtil.getResource(cu).getFullPath(), newCUName)))
- return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.Checks_cu_name_used, newName));
- else
- return new RefactoringStatus();
+
+ public static RefactoringStatus checkSourceModuleNewName(ISourceModule cu,
+ String newName) {
+ String newCUName = ScriptModelUtil.getRenamedCUName(cu, newName);
+ if (resourceExists(RenameResourceChange.renamedResourcePath(
+ ResourceUtil.getResource(cu).getFullPath(), newCUName))) {
+ return RefactoringStatus.createFatalErrorStatus(Messages.format(
+ RefactoringCoreMessages.Checks_cu_name_used, newName));
+ }
+ return new RefactoringStatus();
}
- public static boolean resourceExists(IPath resourcePath){
- return ResourcesPlugin.getWorkspace().getRoot().findMember(resourcePath) != null;
+
+ public static boolean resourceExists(IPath resourcePath) {
+ return ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(resourcePath) != null;
}
- public static RefactoringStatus validateModifiesFiles(IFile[] filesToModify, Object context) {
- RefactoringStatus result= new RefactoringStatus();
- IStatus status= Resources.checkInSync(filesToModify);
+
+ public static RefactoringStatus validateModifiesFiles(IFile[] filesToModify,
+ Object context) {
+ RefactoringStatus result = new RefactoringStatus();
+ IStatus status = Resources.checkInSync(filesToModify);
if (!status.isOK())
result.merge(RefactoringStatus.create(status));
- status= Resources.makeCommittable(filesToModify, context);
+ status = Resources.makeCommittable(filesToModify, context);
if (!status.isOK()) {
result.merge(RefactoringStatus.create(status));
if (!result.hasFatalError()) {
- result.addFatalError(RefactoringCoreMessages.Checks_validateEdit);
- }
+ result.addFatalError(
+ RefactoringCoreMessages.Checks_validateEdit);
+ }
}
return result;
}
- public static boolean isAlreadyNamed(IModelElement element, String name){
+
+ public static boolean isAlreadyNamed(IModelElement element, String name) {
return name.equals(element.getElementName());
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/RefactoringAvailabilityTester.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/RefactoringAvailabilityTester.java
index 2988c2e..c91607f 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/RefactoringAvailabilityTester.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/RefactoringAvailabilityTester.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2017 IBM Corporation and others.
+ * Copyright (c) 2005, 2018 IBM Corporation 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
@@ -82,10 +82,10 @@
return isRenameAvailable((IType) element);
case IModelElement.METHOD:
final IMethod method = (IMethod) element;
- if (method.isConstructor())
+ if (method.isConstructor()) {
return isRenameAvailable(method.getDeclaringType());
- else
- return isRenameAvailable(method);
+ }
+ return isRenameAvailable(method);
case IModelElement.FIELD:
final IField field = (IField) element;
return isRenameFieldAvailable(field);
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/base/DLTKChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/base/DLTKChange.java
index 3bbd057..14081d2 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/base/DLTKChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/base/DLTKChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -29,7 +29,6 @@
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-
/**
* DLTK specific change object.
*/
@@ -37,7 +36,7 @@
private long fModificationStamp;
private boolean fReadOnly;
-
+
private static class ValidationState {
private IResource fResource;
private int fKind;
@@ -45,119 +44,141 @@
private boolean fReadOnly;
private long fModificationStamp;
private ITextFileBuffer fTextFileBuffer;
- public static final int RESOURCE= 1;
- public static final int DOCUMENT= 2;
+ public static final int RESOURCE = 1;
+ public static final int DOCUMENT = 2;
+
public ValidationState(IResource resource) {
- fResource= resource;
+ fResource = resource;
if (resource instanceof IFile) {
- initializeFile((IFile)resource);
+ initializeFile((IFile) resource);
} else {
initializeResource(resource);
}
}
- public void checkDirty(RefactoringStatus status, long stampToMatch, IProgressMonitor pm) throws CoreException {
+
+ public void checkDirty(RefactoringStatus status, long stampToMatch,
+ IProgressMonitor pm) throws CoreException {
if (fDirty) {
- if (fKind == DOCUMENT && fTextFileBuffer != null && stampToMatch == fModificationStamp) {
+ if (fKind == DOCUMENT && fTextFileBuffer != null
+ && stampToMatch == fModificationStamp) {
fTextFileBuffer.commit(pm, false);
} else {
status.addFatalError(Messages.format(
- RefactoringCoreMessages.Change_is_unsaved, fResource.getFullPath().toString()));
+ RefactoringCoreMessages.Change_is_unsaved,
+ fResource.getFullPath().toString()));
}
}
}
+
public void checkDirty(RefactoringStatus status) {
if (fDirty) {
status.addFatalError(Messages.format(
- RefactoringCoreMessages.Change_is_unsaved, fResource.getFullPath().toString()));
+ RefactoringCoreMessages.Change_is_unsaved,
+ fResource.getFullPath().toString()));
}
}
+
public void checkReadOnly(RefactoringStatus status) {
if (fReadOnly) {
status.addFatalError(Messages.format(
- RefactoringCoreMessages.Change_is_read_only, fResource.getFullPath().toString()));
+ RefactoringCoreMessages.Change_is_read_only,
+ fResource.getFullPath().toString()));
}
}
- public void checkSameReadOnly(RefactoringStatus status, boolean valueToMatch) {
+
+ public void checkSameReadOnly(RefactoringStatus status,
+ boolean valueToMatch) {
if (fReadOnly != valueToMatch) {
status.addFatalError(Messages.format(
- RefactoringCoreMessages.Change_same_read_only,
- fResource.getFullPath().toString()));
+ RefactoringCoreMessages.Change_same_read_only,
+ fResource.getFullPath().toString()));
}
}
- public void checkModificationStamp(RefactoringStatus status, long stampToMatch) {
+
+ public void checkModificationStamp(RefactoringStatus status,
+ long stampToMatch) {
if (fKind == DOCUMENT) {
- if (stampToMatch != IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP && fModificationStamp != stampToMatch) {
+ if (stampToMatch != IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP
+ && fModificationStamp != stampToMatch) {
status.addFatalError(Messages.format(
- RefactoringCoreMessages.Change_has_modifications, fResource.getFullPath().toString()));
+ RefactoringCoreMessages.Change_has_modifications,
+ fResource.getFullPath().toString()));
}
} else {
- if (stampToMatch != IResource.NULL_STAMP && fModificationStamp != stampToMatch) {
+ if (stampToMatch != IResource.NULL_STAMP
+ && fModificationStamp != stampToMatch) {
status.addFatalError(Messages.format(
- RefactoringCoreMessages.Change_has_modifications, fResource.getFullPath().toString()));
-
+ RefactoringCoreMessages.Change_has_modifications,
+ fResource.getFullPath().toString()));
+
}
}
}
+
private void initializeFile(IFile file) {
- fTextFileBuffer= getBuffer(file);
+ fTextFileBuffer = getBuffer(file);
if (fTextFileBuffer == null) {
initializeResource(file);
} else {
- IDocument document= fTextFileBuffer.getDocument();
- fDirty= fTextFileBuffer.isDirty();
- fReadOnly= Resources.isReadOnly(file);
+ IDocument document = fTextFileBuffer.getDocument();
+ fDirty = fTextFileBuffer.isDirty();
+ fReadOnly = Resources.isReadOnly(file);
if (document instanceof IDocumentExtension4) {
- fKind= DOCUMENT;
- fModificationStamp= ((IDocumentExtension4)document).getModificationStamp();
+ fKind = DOCUMENT;
+ fModificationStamp = ((IDocumentExtension4) document)
+ .getModificationStamp();
} else {
- fKind= RESOURCE;
- fModificationStamp= file.getModificationStamp();
+ fKind = RESOURCE;
+ fModificationStamp = file.getModificationStamp();
}
}
-
+
}
+
private void initializeResource(IResource resource) {
- fKind= RESOURCE;
- fDirty= false;
- fReadOnly= Resources.isReadOnly(resource);
- fModificationStamp= resource.getModificationStamp();
+ fKind = RESOURCE;
+ fDirty = false;
+ fReadOnly = Resources.isReadOnly(resource);
+ fModificationStamp = resource.getModificationStamp();
}
}
- protected static final int NONE= 0;
- protected static final int READ_ONLY= 1 << 0;
- protected static final int DIRTY= 1 << 1;
- private static final int SAVE= 1 << 2;
- protected static final int SAVE_IF_DIRTY= SAVE | DIRTY;
-
+ protected static final int NONE = 0;
+ protected static final int READ_ONLY = 1 << 0;
+ protected static final int DIRTY = 1 << 1;
+ private static final int SAVE = 1 << 2;
+ protected static final int SAVE_IF_DIRTY = SAVE | DIRTY;
+
protected DLTKChange() {
- fModificationStamp= IResource.NULL_STAMP;
- fReadOnly= false;
+ fModificationStamp = IResource.NULL_STAMP;
+ fReadOnly = false;
}
-
+
@Override
public void initializeValidationData(IProgressMonitor pm) {
- IResource resource= getResource(getModifiedElement());
+ IResource resource = getResource(getModifiedElement());
if (resource != null) {
- fModificationStamp= getModificationStamp(resource);
- fReadOnly= Resources.isReadOnly(resource);
+ fModificationStamp = getModificationStamp(resource);
+ fReadOnly = Resources.isReadOnly(resource);
}
}
- // protected final RefactoringStatus isValid(IProgressMonitor pm, boolean checkReadOnly, boolean checkDirty) throws CoreException {
- protected final RefactoringStatus isValid(IProgressMonitor pm, int flags) throws CoreException {
+ // protected final RefactoringStatus isValid(IProgressMonitor pm, boolean
+ // checkReadOnly, boolean checkDirty) throws CoreException {
+ protected final RefactoringStatus isValid(IProgressMonitor pm, int flags)
+ throws CoreException {
pm.beginTask("", 2); //$NON-NLS-1$
try {
- RefactoringStatus result= new RefactoringStatus();
- Object modifiedElement= getModifiedElement();
+ RefactoringStatus result = new RefactoringStatus();
+ Object modifiedElement = getModifiedElement();
checkExistence(result, modifiedElement);
if (result.hasFatalError())
return result;
if (flags == NONE)
return result;
- IResource resource= getResource(modifiedElement);
+ IResource resource = getResource(modifiedElement);
if (resource != null) {
- ValidationState state= new ValidationState(resource);
+ ValidationState state = new ValidationState(resource);
state.checkModificationStamp(result, fModificationStamp);
if (result.hasFatalError())
return result;
@@ -171,7 +192,8 @@
}
if ((flags & DIRTY) != 0) {
if ((flags & SAVE) != 0) {
- state.checkDirty(result, fModificationStamp, new SubProgressMonitor(pm, 1));
+ state.checkDirty(result, fModificationStamp,
+ new SubProgressMonitor(pm, 1));
} else {
state.checkDirty(result);
}
@@ -187,17 +209,19 @@
return isValid(new NullProgressMonitor(), flags);
}
- protected static void checkIfModifiable(RefactoringStatus status, Object element, int flags) {
+ protected static void checkIfModifiable(RefactoringStatus status,
+ Object element, int flags) {
checkIfModifiable(status, getResource(element), flags);
}
- protected static void checkIfModifiable(RefactoringStatus result, IResource resource, int flags) {
+ protected static void checkIfModifiable(RefactoringStatus result,
+ IResource resource, int flags) {
checkExistence(result, resource);
if (result.hasFatalError())
return;
if (flags == NONE)
return;
- ValidationState state= new ValidationState(resource);
+ ValidationState state = new ValidationState(resource);
if ((flags & READ_ONLY) != 0) {
state.checkReadOnly(result);
if (result.hasFatalError())
@@ -208,28 +232,34 @@
}
}
- protected static void checkExistence(RefactoringStatus status, Object element) {
+ protected static void checkExistence(RefactoringStatus status,
+ Object element) {
if (element == null) {
- status.addFatalError(RefactoringCoreMessages.DynamicValidationStateChange_workspace_changed);
-
- } else if (element instanceof IResource && !((IResource)element).exists()) {
+ status.addFatalError(
+ RefactoringCoreMessages.DynamicValidationStateChange_workspace_changed);
+
+ } else if (element instanceof IResource
+ && !((IResource) element).exists()) {
status.addFatalError(Messages.format(
- RefactoringCoreMessages.Change_does_not_exist, ((IResource)element).getFullPath().toString()));
- } else if (element instanceof IModelElement && !((IModelElement)element).exists()) {
+ RefactoringCoreMessages.Change_does_not_exist,
+ ((IResource) element).getFullPath().toString()));
+ } else if (element instanceof IModelElement
+ && !((IModelElement) element).exists()) {
status.addFatalError(Messages.format(
- RefactoringCoreMessages.Change_does_not_exist, ((IModelElement)element).getElementName()));
+ RefactoringCoreMessages.Change_does_not_exist,
+ ((IModelElement) element).getElementName()));
}
}
private static IResource getResource(Object element) {
if (element instanceof IResource) {
- return (IResource)element;
+ return (IResource) element;
}
if (element instanceof ISourceModule) {
- return ((ISourceModule)element).getPrimary().getResource();
+ return ((ISourceModule) element).getPrimary().getResource();
}
if (element instanceof IModelElement) {
- return ((IModelElement)element).getResource();
+ return ((IModelElement) element).getResource();
}
if (element instanceof IAdaptable) {
return ((IAdaptable) element).getAdapter(IResource.class);
@@ -241,26 +271,25 @@
public String toString() {
return getName();
}
-
+
public long getModificationStamp(IResource resource) {
if (!(resource instanceof IFile))
return resource.getModificationStamp();
- IFile file= (IFile)resource;
- ITextFileBuffer buffer= getBuffer(file);
+ IFile file = (IFile) resource;
+ ITextFileBuffer buffer = getBuffer(file);
if (buffer == null) {
return file.getModificationStamp();
- } else {
- IDocument document= buffer.getDocument();
- if (document instanceof IDocumentExtension4) {
- return ((IDocumentExtension4)document).getModificationStamp();
- } else {
- return file.getModificationStamp();
- }
}
+ IDocument document = buffer.getDocument();
+ if (document instanceof IDocumentExtension4) {
+ return ((IDocumentExtension4) document).getModificationStamp();
+ }
+ return file.getModificationStamp();
}
-
+
private static ITextFileBuffer getBuffer(IFile file) {
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
- return manager.getTextFileBuffer(file.getFullPath(), LocationKind.NORMALIZE);
+ ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
+ return manager.getTextFileBuffer(file.getFullPath(),
+ LocationKind.NORMALIZE);
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/AddToBuildpathChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/AddToBuildpathChange.java
index 15cee8e..c7b111b 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/AddToBuildpathChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/AddToBuildpathChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -51,7 +51,7 @@
*
* @param project
* @param newProjectEntry
- * (must be absolute <code>IPath</code>)
+ * (must be absolute <code>IPath</code>)
*/
public AddToBuildpathChange(IScriptProject project, IPath newProjectEntry) {
this(project, DLTKCore.newProjectEntry(newProjectEntry));
@@ -77,9 +77,8 @@
IPath buildpathEntryPath = fEntryToAdd.getPath();
return new DeleteFromBuildpathChange(buildpathEntryPath,
getScriptProject());
- } else {
- return new NullChange();
}
+ return new NullChange();
} finally {
pm.done();
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteFileChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteFileChange.java
index 349ae96..1e2f880 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteFileChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteFileChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -7,6 +7,7 @@
*
*******************************************************************************/
package org.eclipse.dltk.internal.corext.refactoring.changes;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
@@ -19,25 +20,25 @@
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ui.ide.undo.ResourceDescription;
-
public class DeleteFileChange extends AbstractDeleteChange {
private final IPath fPath;
private final boolean fIsExecuteChange;
-
+
public DeleteFileChange(IFile file, boolean executeChange) {
- Assert.isNotNull(file, "file"); //$NON-NLS-1$
- fPath= Utils.getResourcePath(file);
- fIsExecuteChange= executeChange;
+ Assert.isNotNull(file, "file"); //$NON-NLS-1$
+ fPath = Utils.getResourcePath(file);
+ fIsExecuteChange = executeChange;
}
-
- private IFile getFile(){
+
+ private IFile getFile() {
return Utils.getFile(fPath);
}
-
+
@Override
public String getName() {
- return Messages.format(RefactoringCoreMessages.DeleteFileChange_1, fPath.lastSegment());
+ return Messages.format(RefactoringCoreMessages.DeleteFileChange_1,
+ fPath.lastSegment());
}
@Override
@@ -46,9 +47,8 @@
// no need for checking since we already prompt the
// user if the file is dirty or read only
return super.isValid(pm, NONE);
- } else {
- return super.isValid(pm, READ_ONLY | DIRTY);
}
+ return super.isValid(pm, READ_ONLY | DIRTY);
}
@Override
@@ -58,7 +58,7 @@
@Override
protected Change doDelete(IProgressMonitor pm) throws CoreException {
- IFile file= getFile();
+ IFile file = getFile();
Assert.isNotNull(file);
Assert.isTrue(file.exists());
pm.beginTask("", 2); //$NON-NLS-1$
@@ -74,4 +74,3 @@
return new UndoDeleteResourceChange(resourceDescription);
}
}
-
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteFolderChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteFolderChange.java
index 2274ccf..fb88cda 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteFolderChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteFolderChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -25,34 +25,35 @@
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ui.ide.undo.ResourceDescription;
-
public class DeleteFolderChange extends AbstractDeleteChange {
-
+
private final IPath fPath;
private final boolean fIsExecuteChange;
-
+
public DeleteFolderChange(IFolder folder, boolean isExecuteChange) {
this(getFolderPath(folder), isExecuteChange);
}
-
+
public DeleteFolderChange(IPath path, boolean isExecuteChange) {
- fPath= path;
- fIsExecuteChange= isExecuteChange;
+ fPath = path;
+ fIsExecuteChange = isExecuteChange;
}
-
- public static IPath getFolderPath(IFolder folder){
- return folder.getFullPath().removeFirstSegments(ResourcesPlugin.getWorkspace().getRoot().getFullPath().segmentCount());
+
+ public static IPath getFolderPath(IFolder folder) {
+ return folder.getFullPath().removeFirstSegments(ResourcesPlugin
+ .getWorkspace().getRoot().getFullPath().segmentCount());
}
-
- public static IFolder getFolder(IPath path){
+
+ public static IFolder getFolder(IPath path) {
return ResourcesPlugin.getWorkspace().getRoot().getFolder(path);
}
@Override
public String getName() {
- return Messages.format(RefactoringCoreMessages.DeleteFolderChange_0, fPath.lastSegment());
+ return Messages.format(RefactoringCoreMessages.DeleteFolderChange_0,
+ fPath.lastSegment());
}
-
+
@Override
public Object getModifiedElement() {
return getFolder(fPath);
@@ -66,14 +67,13 @@
// or read only files in the folder. The change is
// currently not used as a undo/redo change
return super.isValid(pm, NONE);
- } else {
- return super.isValid(pm, READ_ONLY | DIRTY);
}
+ return super.isValid(pm, READ_ONLY | DIRTY);
}
@Override
protected Change doDelete(IProgressMonitor pm) throws CoreException {
- IFolder folder= getFolder(fPath);
+ IFolder folder = getFolder(fPath);
Assert.isTrue(folder.exists());
pm.beginTask("", 2); //$NON-NLS-1$
folder.accept((IResourceVisitor) resource -> {
@@ -95,4 +95,3 @@
return new UndoDeleteResourceChange(resourceDescription);
}
}
-
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteProjectFragmentChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteProjectFragmentChange.java
index b5dfa80..084526b 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteProjectFragmentChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteProjectFragmentChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -47,26 +47,27 @@
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.ui.ide.undo.ResourceDescription;
-
public class DeleteProjectFragmentChange extends AbstractDeleteChange {
private final String fHandle;
private final boolean fIsExecuteChange;
private final IProjectFragmentManipulationQuery fUpdateClasspathQuery;
- public DeleteProjectFragmentChange(IProjectFragment root, boolean isExecuteChange,
+ public DeleteProjectFragmentChange(IProjectFragment root,
+ boolean isExecuteChange,
IProjectFragmentManipulationQuery updateClasspathQuery) {
Assert.isNotNull(root);
- Assert.isTrue(! root.isExternal());
- fHandle= root.getHandleIdentifier();
- fIsExecuteChange= isExecuteChange;
- fUpdateClasspathQuery= updateClasspathQuery;
+ Assert.isTrue(!root.isExternal());
+ fHandle = root.getHandleIdentifier();
+ fIsExecuteChange = isExecuteChange;
+ fUpdateClasspathQuery = updateClasspathQuery;
}
@Override
public String getName() {
- String[] keys= {getRoot().getElementName()};
- return Messages.format(RefactoringCoreMessages.DeleteProjectFragmentChange_delete, keys);
+ return Messages.format(
+ RefactoringCoreMessages.DeleteProjectFragmentChange_delete,
+ getRoot().getElementName());
}
@Override
@@ -74,8 +75,8 @@
return getRoot();
}
- private IProjectFragment getRoot(){
- return (IProjectFragment)DLTKCore.create(fHandle);
+ private IProjectFragment getRoot() {
+ return (IProjectFragment) DLTKCore.create(fHandle);
}
@Override
@@ -86,17 +87,17 @@
// read only resource. The change is currently not used
// as
return super.isValid(pm, DIRTY);
- } else {
- return super.isValid(pm, READ_ONLY | DIRTY);
}
+ return super.isValid(pm, READ_ONLY | DIRTY);
}
@Override
protected Change doDelete(IProgressMonitor pm) throws CoreException {
- if (! confirmDeleteIfReferenced())
+ if (!confirmDeleteIfReferenced())
return new NullChange();
- int resourceUpdateFlags= IResource.KEEP_HISTORY;
- int jCoreUpdateFlags= IProjectFragment.ORIGINATING_PROJECT_BUILDPATH | IProjectFragment.OTHER_REFERRING_PROJECTS_BUILDPATH;
+ int resourceUpdateFlags = IResource.KEEP_HISTORY;
+ int jCoreUpdateFlags = IProjectFragment.ORIGINATING_PROJECT_BUILDPATH
+ | IProjectFragment.OTHER_REFERRING_PROJECTS_BUILDPATH;
pm.beginTask("", 2); //$NON-NLS-1$
IProjectFragment root = getRoot();
@@ -107,11 +108,11 @@
.fromResource(rootResource);
IScriptProject[] referencingProjects = ModelElementUtil
.getReferencingProjects(root);
- HashMap/* <IFile, String> */classpathFilesContents = new HashMap();
+ HashMap<IFile, String> classpathFilesContents = new HashMap<>();
for (int i = 0; i < referencingProjects.length; i++) {
IScriptProject javaProject = referencingProjects[i];
- IFile classpathFile = javaProject.getProject().getFile(
- ScriptProject.BUILDPATH_FILENAME);
+ IFile classpathFile = javaProject.getProject()
+ .getFile(ScriptProject.BUILDPATH_FILENAME);
if (classpathFile.exists()) {
classpathFilesContents.put(classpathFile,
getFileContents(classpathFile));
@@ -123,20 +124,18 @@
rootDescription.recordStateFromHistory(rootResource,
new SubProgressMonitor(pm, 1));
- for (Iterator iterator = classpathFilesContents.entrySet().iterator(); iterator
- .hasNext();) {
- Entry entry = (Entry) iterator.next();
- IFile file = (IFile) entry.getKey();
- String contents = (String) entry.getValue();
+ for (Iterator<Entry<IFile, String>> iterator = classpathFilesContents
+ .entrySet().iterator(); iterator.hasNext();) {
+ Entry<IFile, String> entry = iterator.next();
+ IFile file = entry.getKey();
+ String contents = entry.getValue();
// Restore time stamps? This should probably be some sort of
// UndoTextFileChange.
- TextFileChange classpathUndo = new TextFileChange(
- Messages
- .format(
- RefactoringCoreMessages.DeleteProjectFragmentChange_restore_file,
- file.getFullPath().toOSString()), file);
- classpathUndo.setEdit(new ReplaceEdit(0, getFileLength(file),
- contents));
+ TextFileChange classpathUndo = new TextFileChange(Messages.format(
+ RefactoringCoreMessages.DeleteProjectFragmentChange_restore_file,
+ file.getFullPath().toOSString()), file);
+ classpathUndo
+ .setEdit(new ReplaceEdit(0, getFileLength(file), contents));
result.add(classpathUndo);
}
result.add(new UndoDeleteResourceChange(rootDescription));
@@ -146,14 +145,17 @@
}
private boolean confirmDeleteIfReferenced() throws ModelException {
- if (! getRoot().isArchive()) //for source folders, you don't ask, just do it
+ if (!getRoot().isArchive()) // for source folders, you don't ask, just
+ // do it
return true;
if (fUpdateClasspathQuery == null)
return true;
- IScriptProject[] referencingProjects= ModelElementUtil.getReferencingProjects(getRoot());
+ IScriptProject[] referencingProjects = ModelElementUtil
+ .getReferencingProjects(getRoot());
if (referencingProjects.length == 0)
return true;
- return fUpdateClasspathQuery.confirmManipulation(getRoot(), referencingProjects);
+ return fUpdateClasspathQuery.confirmManipulation(getRoot(),
+ referencingProjects);
}
private static int getFileLength(IFile file) throws CoreException {
@@ -170,8 +172,8 @@
try {
return (int) reader.skip(Integer.MAX_VALUE);
} catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, DLTKUIPlugin
- .getPluginId(), e.getMessage(), e));
+ throw new CoreException(new Status(IStatus.ERROR,
+ DLTKUIPlugin.getPluginId(), e.getMessage(), e));
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteSourceManipulationChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteSourceManipulationChange.java
index be09192..6386178 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteSourceManipulationChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/DeleteSourceManipulationChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -55,12 +55,10 @@
// don't check anything in this case. We have a warning dialog
// already presented to the user that the file is dirty.
return super.isValid(pm, NONE);
- } else {
- return super.isValid(pm, DIRTY);
}
- } else {
- return super.isValid(pm, READ_ONLY | DIRTY);
+ return super.isValid(pm, DIRTY);
}
+ return super.isValid(pm, READ_ONLY | DIRTY);
}
private String getElementName() {
@@ -100,9 +98,8 @@
resourceDescription.recordStateFromHistory(resource,
new SubProgressMonitor(pm, 1));
return new UndoDeleteResourceChange(resourceDescription);
- } else {
- element.delete(false, pm);
}
+ element.delete(false, pm);
return null;
// begin fix https://bugs.eclipse.org/bugs/show_bug.cgi?id=66835
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveSourceModuleChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveSourceModuleChange.java
index cedc074..1a7c5b0 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveSourceModuleChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveSourceModuleChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -18,65 +18,69 @@
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-
public class MoveSourceModuleChange extends SourceModuleReorgChange {
private boolean fUndoable;
private long fStampToRestore;
-
- public MoveSourceModuleChange(ISourceModule cu, IScriptFolder newPackage){
+
+ public MoveSourceModuleChange(ISourceModule cu, IScriptFolder newPackage) {
super(cu, newPackage);
- fStampToRestore= IResource.NULL_STAMP;
+ fStampToRestore = IResource.NULL_STAMP;
}
-
- private MoveSourceModuleChange(IScriptFolder oldPackage, String cuName, IScriptFolder newPackage, long stampToRestore) {
- super(oldPackage.getHandleIdentifier(), newPackage.getHandleIdentifier(), oldPackage.getSourceModule(cuName).getHandleIdentifier());
- fStampToRestore= stampToRestore;
+
+ private MoveSourceModuleChange(IScriptFolder oldPackage, String cuName,
+ IScriptFolder newPackage, long stampToRestore) {
+ super(oldPackage.getHandleIdentifier(),
+ newPackage.getHandleIdentifier(),
+ oldPackage.getSourceModule(cuName).getHandleIdentifier());
+ fStampToRestore = stampToRestore;
}
-
+
@Override
public String getName() {
- return Messages.format(RefactoringCoreMessages.MoveSourceModuleChange_name,
- new String[]{getCu().getElementName(), getPackageName(getDestinationPackage())});
+ return Messages.format(
+ RefactoringCoreMessages.MoveSourceModuleChange_name,
+ getCu().getElementName(),
+ getPackageName(getDestinationPackage()));
}
@Override
public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
return super.isValid(pm, READ_ONLY | SAVE_IF_DIRTY);
}
-
+
@Override
Change doPerformReorg(IProgressMonitor pm) throws CoreException {
String name;
- String newName= getNewName();
+ String newName = getNewName();
if (newName == null)
- name= getCu().getElementName();
+ name = getCu().getElementName();
else
- name= newName;
-
+ name = newName;
+
// get current modification stamp
- long currentStamp= IResource.NULL_STAMP;
- IResource resource= getCu().getResource();
+ long currentStamp = IResource.NULL_STAMP;
+ IResource resource = getCu().getResource();
if (resource != null) {
- currentStamp= resource.getModificationStamp();
+ currentStamp = resource.getModificationStamp();
}
-
- fUndoable= ! getDestinationPackage().getSourceModule(name).exists();
-
+
+ fUndoable = !getDestinationPackage().getSourceModule(name).exists();
+
// perform the move and restore modification stamp
getCu().move(getDestinationPackage(), null, newName, true, pm);
if (fStampToRestore != IResource.NULL_STAMP) {
- ISourceModule moved= getDestinationPackage().getSourceModule(name);
- IResource movedResource= moved.getResource();
+ ISourceModule moved = getDestinationPackage().getSourceModule(name);
+ IResource movedResource = moved.getResource();
if (movedResource != null) {
movedResource.revertModificationStamp(fStampToRestore);
}
}
-
+
if (fUndoable) {
- return new MoveSourceModuleChange(getDestinationPackage(), getCu().getElementName(), getOldPackage(), currentStamp);
- } else {
- return null;
+ return new MoveSourceModuleChange(getDestinationPackage(),
+ getCu().getElementName(), getOldPackage(), currentStamp);
}
+ return null;
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/ProjectFragmentReorgChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/ProjectFragmentReorgChange.java
index 62fa01d..f453c23 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/ProjectFragmentReorgChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/ProjectFragmentReorgChange.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
*
-
*******************************************************************************/
package org.eclipse.dltk.internal.corext.refactoring.changes;
@@ -130,10 +129,10 @@
boolean updateOtherProjectsToo = fUpdateBuildpathQuery
.confirmManipulation(getRoot(), referencingProjects);
- if (updateOtherProjectsToo)
+ if (updateOtherProjectsToo) {
return replace | originating | destination | otherProjects;
- else
- return replace | originating | destination;
+ }
+ return replace | originating | destination;
}
protected int getResourceUpdateFlags() {
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameResourceChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameResourceChange.java
index f8667fa..4317b8d 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameResourceChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameResourceChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -22,7 +22,6 @@
import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-
public final class RenameResourceChange extends DLTKChange {
public static IPath renamedResourcePath(IPath path, String newName) {
@@ -39,16 +38,20 @@
private final long fStampToRestore;
- private RenameResourceChange(RefactoringDescriptor descriptor, IPath resourcePath, String newName, String comment, long stampToRestore) {
- fDescriptor= descriptor;
- fResourcePath= resourcePath;
- fNewName= newName;
- fComment= comment;
- fStampToRestore= stampToRestore;
+ private RenameResourceChange(RefactoringDescriptor descriptor,
+ IPath resourcePath, String newName, String comment,
+ long stampToRestore) {
+ fDescriptor = descriptor;
+ fResourcePath = resourcePath;
+ fNewName = newName;
+ fComment = comment;
+ fStampToRestore = stampToRestore;
}
- public RenameResourceChange(RefactoringDescriptor descriptor, IResource resource, String newName, String comment) {
- this(descriptor, resource.getFullPath(), newName, comment, IResource.NULL_STAMP);
+ public RenameResourceChange(RefactoringDescriptor descriptor,
+ IResource resource, String newName, String comment) {
+ this(descriptor, resource.getFullPath(), newName, comment,
+ IResource.NULL_STAMP);
}
@Override
@@ -65,7 +68,9 @@
@Override
public String getName() {
- return Messages.format(RefactoringCoreMessages.RenameResourceChange_name, new String[] { fResourcePath.toString(), fNewName});
+ return Messages.format(
+ RefactoringCoreMessages.RenameResourceChange_name,
+ fResourcePath.toString(), fNewName);
}
public String getNewName() {
@@ -73,34 +78,40 @@
}
private IResource getResource() {
- return ResourcesPlugin.getWorkspace().getRoot().findMember(fResourcePath);
+ return ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(fResourcePath);
}
@Override
public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
- IResource resource= getResource();
+ IResource resource = getResource();
if (resource == null || !resource.exists()) {
- return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.RenameResourceChange_does_not_exist, fResourcePath.toString()));
- } else {
- return super.isValid(pm, DIRTY);
+ return RefactoringStatus.createFatalErrorStatus(Messages.format(
+ RefactoringCoreMessages.RenameResourceChange_does_not_exist,
+ fResourcePath.toString()));
}
+ return super.isValid(pm, DIRTY);
}
@Override
public Change perform(IProgressMonitor pm) throws CoreException {
try {
- pm.beginTask(RefactoringCoreMessages.RenameResourceChange_rename_resource, 1);
+ pm.beginTask(
+ RefactoringCoreMessages.RenameResourceChange_rename_resource,
+ 1);
- IResource resource= getResource();
- long currentStamp= resource.getModificationStamp();
- IPath newPath= renamedResourcePath(fResourcePath, fNewName);
+ IResource resource = getResource();
+ long currentStamp = resource.getModificationStamp();
+ IPath newPath = renamedResourcePath(fResourcePath, fNewName);
resource.move(newPath, IResource.SHALLOW, pm);
if (fStampToRestore != IResource.NULL_STAMP) {
- IResource newResource= ResourcesPlugin.getWorkspace().getRoot().findMember(newPath);
+ IResource newResource = ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(newPath);
newResource.revertModificationStamp(fStampToRestore);
}
- String oldName= fResourcePath.lastSegment();
- return new RenameResourceChange(null, newPath, oldName, fComment, currentStamp);
+ String oldName = fResourcePath.lastSegment();
+ return new RenameResourceChange(null, newPath, oldName, fComment,
+ currentStamp);
} finally {
pm.done();
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameSourceFolderChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameSourceFolderChange.java
index aa0d227..a1fd302 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameSourceFolderChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameSourceFolderChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -22,22 +22,27 @@
import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+public final class RenameSourceFolderChange
+ extends AbstractModelElementRenameChange {
-public final class RenameSourceFolderChange extends AbstractModelElementRenameChange {
-
- private static RefactoringStatus checkIfModifiable(IProjectFragment root, IProgressMonitor pm) throws CoreException {
- RefactoringStatus result= new RefactoringStatus();
+ private static RefactoringStatus checkIfModifiable(IProjectFragment root,
+ IProgressMonitor pm) throws CoreException {
+ RefactoringStatus result = new RefactoringStatus();
checkExistence(result, root);
if (result.hasFatalError())
return result;
if (root.isArchive()) {
- result.addFatalError(Messages.format(RefactoringCoreMessages.RenameSourceFolderChange_rename_archive, root.getElementName()));
+ result.addFatalError(Messages.format(
+ RefactoringCoreMessages.RenameSourceFolderChange_rename_archive,
+ root.getElementName()));
return result;
}
if (root.isExternal()) {
- result.addFatalError(Messages.format(RefactoringCoreMessages.RenameSourceFolderChange_rename_external, root.getElementName()));
+ result.addFatalError(Messages.format(
+ RefactoringCoreMessages.RenameSourceFolderChange_rename_external,
+ root.getElementName()));
return result;
}
@@ -46,20 +51,26 @@
return result;
if (root.getCorrespondingResource().isLinked()) {
- result.addFatalError(Messages.format(RefactoringCoreMessages.RenameSourceFolderChange_rename_linked, root.getElementName()));
+ result.addFatalError(Messages.format(
+ RefactoringCoreMessages.RenameSourceFolderChange_rename_linked,
+ root.getElementName()));
return result;
}
return result;
}
- public RenameSourceFolderChange(RefactoringDescriptor descriptor, IProjectFragment sourceFolder, String newName, String comment) {
- this(descriptor, sourceFolder.getPath(), sourceFolder.getElementName(), newName, comment, IResource.NULL_STAMP);
+ public RenameSourceFolderChange(RefactoringDescriptor descriptor,
+ IProjectFragment sourceFolder, String newName, String comment) {
+ this(descriptor, sourceFolder.getPath(), sourceFolder.getElementName(),
+ newName, comment, IResource.NULL_STAMP);
Assert.isTrue(!sourceFolder.isReadOnly(), "should not be read only"); //$NON-NLS-1$
Assert.isTrue(!sourceFolder.isArchive(), "should not be an archive"); //$NON-NLS-1$
}
- private RenameSourceFolderChange(RefactoringDescriptor descriptor, IPath resourcePath, String oldName, String newName, String comment, long stampToRestore) {
+ private RenameSourceFolderChange(RefactoringDescriptor descriptor,
+ IPath resourcePath, String oldName, String newName, String comment,
+ long stampToRestore) {
super(descriptor, resourcePath, oldName, newName, comment);
}
@@ -70,34 +81,42 @@
@Override
protected Change createUndoChange(long stampToRestore) {
- return new RenameSourceFolderChange(null, createNewPath(), getNewName(), getOldName(), getComment(), stampToRestore);
+ return new RenameSourceFolderChange(null, createNewPath(), getNewName(),
+ getOldName(), getComment(), stampToRestore);
}
@Override
protected void doRename(IProgressMonitor pm) throws CoreException {
- IProjectFragment sourceFolder= getSourceFolder();
+ IProjectFragment sourceFolder = getSourceFolder();
if (sourceFolder != null)
- sourceFolder.move(getNewPath(), getCoreMoveFlags(), getScriptModelUpdateFlags(), null, pm);
+ sourceFolder.move(getNewPath(), getCoreMoveFlags(),
+ getScriptModelUpdateFlags(), null, pm);
}
private int getCoreMoveFlags() {
- if (getResource().isLinked())
+ if (getResource().isLinked()) {
return IResource.SHALLOW;
- else
- return IResource.NONE;
+ }
+ return IResource.NONE;
}
private int getScriptModelUpdateFlags() {
- return IProjectFragment.DESTINATION_PROJECT_BUILDPATH | IProjectFragment.ORIGINATING_PROJECT_BUILDPATH | IProjectFragment.OTHER_REFERRING_PROJECTS_BUILDPATH | IProjectFragment.REPLACE;
+ return IProjectFragment.DESTINATION_PROJECT_BUILDPATH
+ | IProjectFragment.ORIGINATING_PROJECT_BUILDPATH
+ | IProjectFragment.OTHER_REFERRING_PROJECTS_BUILDPATH
+ | IProjectFragment.REPLACE;
}
@Override
public String getName() {
- return Messages.format(RefactoringCoreMessages.RenameSourceFolderChange_rename, new String[] { getOldName(), getNewName()});
+ return Messages.format(
+ RefactoringCoreMessages.RenameSourceFolderChange_rename,
+ getOldName(), getNewName());
}
private IPath getNewPath() {
- return getResource().getFullPath().removeLastSegments(1).append(getNewName());
+ return getResource().getFullPath().removeLastSegments(1)
+ .append(getNewName());
}
private IProjectFragment getSourceFolder() {
@@ -106,13 +125,14 @@
@Override
public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
- RefactoringStatus result= new RefactoringStatus();
+ RefactoringStatus result = new RefactoringStatus();
pm.beginTask("", 2); //$NON-NLS-1$
result.merge(isValid(new SubProgressMonitor(pm, 1), DIRTY));
if (result.hasFatalError())
return result;
- IProjectFragment sourceFolder= getSourceFolder();
- result.merge(checkIfModifiable(sourceFolder, new SubProgressMonitor(pm, 1)));
+ IProjectFragment sourceFolder = getSourceFolder();
+ result.merge(
+ checkIfModifiable(sourceFolder, new SubProgressMonitor(pm, 1)));
return result;
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameSourceModuleChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameSourceModuleChange.java
index 8452bb5..8a77d60 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameSourceModuleChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameSourceModuleChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -23,41 +23,52 @@
import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+public final class RenameSourceModuleChange
+ extends AbstractModelElementRenameChange {
-public final class RenameSourceModuleChange extends AbstractModelElementRenameChange {
-
- public RenameSourceModuleChange(RefactoringDescriptor descriptor, ISourceModule unit, String newName, String comment) {
- this(descriptor, ResourceUtil.getResource(unit).getFullPath(), unit.getElementName(), newName, comment, IResource.NULL_STAMP);
- Assert.isTrue(!unit.isReadOnly(), "compilation unit must not be read-only"); //$NON-NLS-1$
+ public RenameSourceModuleChange(RefactoringDescriptor descriptor,
+ ISourceModule unit, String newName, String comment) {
+ this(descriptor, ResourceUtil.getResource(unit).getFullPath(),
+ unit.getElementName(), newName, comment, IResource.NULL_STAMP);
+ Assert.isTrue(!unit.isReadOnly(),
+ "compilation unit must not be read-only"); //$NON-NLS-1$
}
- private RenameSourceModuleChange(RefactoringDescriptor descriptor, IPath resourcePath, String oldName, String newName, String comment, long stampToRestore) {
- super(descriptor, resourcePath, oldName, newName, comment, stampToRestore);
+ private RenameSourceModuleChange(RefactoringDescriptor descriptor,
+ IPath resourcePath, String oldName, String newName, String comment,
+ long stampToRestore) {
+ super(descriptor, resourcePath, oldName, newName, comment,
+ stampToRestore);
}
@Override
protected IPath createNewPath() {
- if (getResourcePath().getFileExtension() != null)
- return getResourcePath().removeFileExtension().removeLastSegments(1).append(getNewName());
- else
- return getResourcePath().removeLastSegments(1).append(getNewName());
+ if (getResourcePath().getFileExtension() != null) {
+ return getResourcePath().removeFileExtension().removeLastSegments(1)
+ .append(getNewName());
+ }
+ return getResourcePath().removeLastSegments(1).append(getNewName());
}
@Override
- protected Change createUndoChange(long stampToRestore) throws ModelException {
- return new RenameSourceModuleChange(null, createNewPath(), getNewName(), getOldName(), getComment(), stampToRestore);
+ protected Change createUndoChange(long stampToRestore)
+ throws ModelException {
+ return new RenameSourceModuleChange(null, createNewPath(), getNewName(),
+ getOldName(), getComment(), stampToRestore);
}
@Override
protected void doRename(IProgressMonitor pm) throws CoreException {
- ISourceModule cu= (ISourceModule) getModifiedElement();
+ ISourceModule cu = (ISourceModule) getModifiedElement();
if (cu != null)
cu.rename(getNewName(), false, pm);
}
@Override
public String getName() {
- return Messages.format(RefactoringCoreMessages.RenameSourceModuleChange_name, new String[] { getOldName(), getNewName()});
+ return Messages.format(
+ RefactoringCoreMessages.RenameSourceModuleChange_name,
+ getOldName(), getNewName());
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/ResourceReorgChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/ResourceReorgChange.java
index be0ce2b..8273b13 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/ResourceReorgChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/ResourceReorgChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -125,17 +125,17 @@
}
protected IResource getResource() {
- if (fIsFile)
+ if (fIsFile) {
return getFile();
- else
- return getFolder();
+ }
+ return getFolder();
}
IContainer getDestination() {
- if (fIsDestinationProject)
+ if (fIsDestinationProject) {
return Utils.getProject(fDestinationPath);
- else
- return Utils.getFolder(fDestinationPath);
+ }
+ return Utils.getFolder(fDestinationPath);
}
protected int getReorgFlags() {
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/SourceModuleReorgChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/SourceModuleReorgChange.java
index 7a2568c..95e55f6 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/SourceModuleReorgChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/SourceModuleReorgChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -89,10 +89,10 @@
}
static String getPackageName(IScriptFolder pack) {
- if (pack.isRootFolder())
+ if (pack.isRootFolder()) {
return RefactoringCoreMessages.MoveSourceModuleChange_default_package;
- else
- return pack.getElementName();
+ }
+ return pack.getElementName();
}
private void markAsExecuted(ISourceModule unit, ResourceMapping mapping) {
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/TextChangeCompatibility.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/TextChangeCompatibility.java
index a0a1d55..fb7f2ae 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/TextChangeCompatibility.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/TextChangeCompatibility.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
*
-
*******************************************************************************/
package org.eclipse.dltk.internal.corext.refactoring.changes;
@@ -18,66 +17,66 @@
import org.eclipse.text.edits.TextEdit;
import org.eclipse.text.edits.TextEditGroup;
-
/**
- * A utility class to provide compatibility with the old
- * text change API of adding text edits directly and auto
- * inserting them into the tree.
+ * A utility class to provide compatibility with the old text change API of
+ * adding text edits directly and auto inserting them into the tree.
*/
public class TextChangeCompatibility {
- public static void addTextEdit(TextChange change, String name, TextEdit edit) {
+ public static void addTextEdit(TextChange change, String name,
+ TextEdit edit) {
Assert.isNotNull(change);
Assert.isNotNull(name);
Assert.isNotNull(edit);
- TextEdit root= change.getEdit();
+ TextEdit root = change.getEdit();
if (root == null) {
- root= new MultiTextEdit();
+ root = new MultiTextEdit();
change.setEdit(root);
}
insert(root, edit);
change.addTextEditGroup(new TextEditGroup(name, edit));
}
-
- public static void addTextEdit(TextChange change, String name, TextEdit edit, GroupCategorySet groupCategories) {
+
+ public static void addTextEdit(TextChange change, String name,
+ TextEdit edit, GroupCategorySet groupCategories) {
Assert.isNotNull(change);
Assert.isNotNull(name);
Assert.isNotNull(edit);
- TextEdit root= change.getEdit();
+ TextEdit root = change.getEdit();
if (root == null) {
- root= new MultiTextEdit();
+ root = new MultiTextEdit();
change.setEdit(root);
}
insert(root, edit);
- change.addTextEditChangeGroup(new TextEditChangeGroup(
- change,
- new CategorizedTextEditGroup(name, edit, groupCategories)));
+ change.addTextEditChangeGroup(new TextEditChangeGroup(change,
+ new CategorizedTextEditGroup(name, edit, groupCategories)));
}
-
- public static void addTextEdit(TextChange change, String name, TextEdit[] edits) {
+
+ public static void addTextEdit(TextChange change, String name,
+ TextEdit[] edits) {
Assert.isNotNull(change);
Assert.isNotNull(name);
Assert.isNotNull(edits);
- TextEdit root= change.getEdit();
+ TextEdit root = change.getEdit();
if (root == null) {
- root= new MultiTextEdit();
+ root = new MultiTextEdit();
change.setEdit(root);
}
- for (int i= 0; i < edits.length; i++) {
+ for (int i = 0; i < edits.length; i++) {
insert(root, edits[i]);
}
change.addTextEditGroup(new TextEditGroup(name, edits));
}
-
+
public static void insert(TextEdit parent, TextEdit edit) {
if (!parent.hasChildren()) {
parent.addChild(edit);
return;
}
- TextEdit[] children= parent.getChildren();
+ TextEdit[] children = parent.getChildren();
// First dive down to find the right parent.
- for (int i= 0; i < children.length; i++) {
- TextEdit child= children[i];
+ for (int i = 0; i < children.length; i++) {
+ TextEdit child = children[i];
if (covers(child, edit)) {
insert(child, edit);
return;
@@ -85,9 +84,9 @@
}
// We have the right parent. Now check if some of the children have to
// be moved under the new edit since it is covering it.
- int removed= 0;
- for (int i= 0; i < children.length; i++) {
- TextEdit child= children[i];
+ int removed = 0;
+ for (int i = 0; i < children.length; i++) {
+ TextEdit child = children[i];
if (covers(edit, child)) {
parent.removeChild(i - removed++);
edit.addChild(child);
@@ -95,21 +94,21 @@
}
parent.addChild(edit);
}
-
+
private static boolean covers(TextEdit thisEdit, TextEdit otherEdit) {
- if (thisEdit.getLength() == 0) // an insertion point can't cover anything
+ if (thisEdit.getLength() == 0) // an insertion point can't cover
+ // anything
return false;
-
- int thisOffset= thisEdit.getOffset();
- int thisEnd= thisEdit.getExclusiveEnd();
+
+ int thisOffset = thisEdit.getOffset();
+ int thisEnd = thisEdit.getExclusiveEnd();
if (otherEdit.getLength() == 0) {
- int otherOffset= otherEdit.getOffset();
+ int otherOffset = otherEdit.getOffset();
return thisOffset < otherOffset && otherOffset < thisEnd;
- } else {
- int otherOffset= otherEdit.getOffset();
- int otherEnd= otherEdit.getExclusiveEnd();
- return thisOffset <= otherOffset && otherEnd <= thisEnd;
}
- }
-
+ int otherOffset = otherEdit.getOffset();
+ int otherEnd = otherEdit.getExclusiveEnd();
+ return thisOffset <= otherOffset && otherEnd <= thisEnd;
+ }
+
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/nls/changes/CreateFileChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/nls/changes/CreateFileChange.java
index a29c900..c56296f 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/nls/changes/CreateFileChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/nls/changes/CreateFileChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -73,11 +73,11 @@
@Override
public String getName() {
- if (fChangeName == null)
+ if (fChangeName == null) {
return Messages.format(NLSChangesMessages.createFile_Create_file,
fPath.toOSString());
- else
- return fChangeName;
+ }
+ return fChangeName;
}
public void setName(String name) {
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameScriptFolderProcessor.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameScriptFolderProcessor.java
index 1de29da..b6ccb9d 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameScriptFolderProcessor.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameScriptFolderProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -89,10 +89,10 @@
/**
* Creates a new rename package processor.
- *
+ *
* @param fragment
- * the package fragment, or <code>null</code> if invoked by
- * scripting
+ * the package fragment, or <code>null</code> if invoked
+ * by scripting
*/
public RenameScriptFolderProcessor(IScriptFolder fragment) {
fPackage = fragment;
@@ -380,11 +380,11 @@
private RefactoringStatus checkPackageInCurrentRoot(String newName)
throws CoreException {
- if (isPackageNameOkInRoot(newName, getProjectFragment()))
+ if (isPackageNameOkInRoot(newName, getProjectFragment())) {
return null;
- else
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.RenamePackageRefactoring_package_exists);
+ }
+ return RefactoringStatus.createFatalErrorStatus(
+ RefactoringCoreMessages.RenamePackageRefactoring_package_exists);
}
private IProjectFragment getProjectFragment() {
@@ -452,7 +452,7 @@
for (int i = 0; i < types.length; i++) {
String name = types[i].getElementName();
if (topLevelTypeNames.contains(name)) {
- String[] keys = { packageName, name };
+ Object[] keys = { packageName, name };
String msg = Messages.format(
RefactoringCoreMessages.RenamePackageRefactoring_contains_type,
keys);
@@ -699,11 +699,11 @@
final IModelElement element = ScriptRefactoringDescriptor
.handleToElement(extended.getProject(), handle, false);
if (element == null || !element.exists() || element
- .getElementType() != IModelElement.SCRIPT_FOLDER)
+ .getElementType() != IModelElement.SCRIPT_FOLDER) {
return ScriptableRefactoring.createInputFatalStatus(element,
getRefactoring().getName(), ID_RENAME_PACKAGE);
- else
- fPackage = (IScriptFolder) element;
+ }
+ fPackage = (IScriptFolder) element;
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(
RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameScriptProjectProcessor.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameScriptProjectProcessor.java
index 46cc326..b15351e 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameScriptProjectProcessor.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameScriptProjectProcessor.java
@@ -44,26 +44,29 @@
import org.eclipse.ltk.core.refactoring.participants.RefactoringArguments;
import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
+public class RenameScriptProjectProcessor extends ScriptRenameProcessor
+ implements IReferenceUpdating {
-public class RenameScriptProjectProcessor extends ScriptRenameProcessor implements IReferenceUpdating {
-
- private static final String ID_RENAME_SCRIPT_PROJECT= "org.eclipse.dltk.ui.rename.script.project"; //$NON-NLS-1$
- private static final String ATTRIBUTE_REFERENCES= "references"; //$NON-NLS-1$
+ private static final String ID_RENAME_SCRIPT_PROJECT = "org.eclipse.dltk.ui.rename.script.project"; //$NON-NLS-1$
+ private static final String ATTRIBUTE_REFERENCES = "references"; //$NON-NLS-1$
private IScriptProject fProject;
private boolean fUpdateReferences;
- public static final String IDENTIFIER= "org.eclipse.dltk.ui.renameScriptProjectProcessor"; //$NON-NLS-1$
+ public static final String IDENTIFIER = "org.eclipse.dltk.ui.renameScriptProjectProcessor"; //$NON-NLS-1$
/**
* Creates a new renamescriptproject processor.
- * @param project thescriptproject, or <code>null</code> if invoked by scripting
+ *
+ * @param project
+ * thescriptproject, or <code>null</code> if invoked by
+ * scripting
*/
public RenameScriptProjectProcessor(IScriptProject project) {
- fProject= project;
+ fProject = project;
if (fProject != null)
setNewElementName(fProject.getElementName());
- fUpdateReferences= true;
+ fUpdateReferences = true;
}
@Override
@@ -88,33 +91,37 @@
@Override
public Object[] getElements() {
- return new Object[] {fProject};
+ return new Object[] { fProject };
}
@Override
public Object getNewElement() throws CoreException {
- IPath newPath= fProject.getPath().removeLastSegments(1).append(getNewElementName());
- return DLTKCore.create(ResourcesPlugin.getWorkspace().getRoot().findMember(newPath));
+ IPath newPath = fProject.getPath().removeLastSegments(1)
+ .append(getNewElementName());
+ return DLTKCore.create(
+ ResourcesPlugin.getWorkspace().getRoot().findMember(newPath));
}
@Override
- protected RenameModifications computeRenameModifications() throws CoreException {
- RenameModifications result= new RenameModifications();
- result.rename(fProject, new RenameArguments(getNewElementName(), getUpdateReferences()));
+ protected RenameModifications computeRenameModifications()
+ throws CoreException {
+ RenameModifications result = new RenameModifications();
+ result.rename(fProject, new RenameArguments(getNewElementName(),
+ getUpdateReferences()));
return result;
}
@Override
protected IFile[] getChangedFiles() throws CoreException {
- IFile projectFile = fProject.getProject().getFile(
- IScriptProjectFilenames.PROJECT_FILENAME);
+ IFile projectFile = fProject.getProject()
+ .getFile(IScriptProjectFilenames.PROJECT_FILENAME);
if (projectFile != null && projectFile.exists()) {
- return new IFile[] {projectFile};
+ return new IFile[] { projectFile };
}
return new IFile[0];
}
- //---- IReferenceUpdating --------------------------------------
+ // ---- IReferenceUpdating --------------------------------------
@Override
public boolean canEnableUpdateReferences() {
@@ -123,7 +130,7 @@
@Override
public void setUpdateReferences(boolean update) {
- fUpdateReferences= update;
+ fUpdateReferences = update;
}
@Override
@@ -131,7 +138,7 @@
return fUpdateReferences;
}
- //---- IRenameProcessor ----------------------------------------------
+ // ---- IRenameProcessor ----------------------------------------------
@Override
public String getCurrentElementName() {
@@ -139,36 +146,43 @@
}
@Override
- public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
+ throws CoreException {
return new RefactoringStatus();
}
@Override
- public RefactoringStatus checkNewElementName(String newName) throws CoreException {
+ public RefactoringStatus checkNewElementName(String newName)
+ throws CoreException {
Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
- RefactoringStatus result= RefactoringStatus.create(ResourcesPlugin.getWorkspace().validateName(newName, IResource.PROJECT));
+ RefactoringStatus result = RefactoringStatus.create(ResourcesPlugin
+ .getWorkspace().validateName(newName, IResource.PROJECT));
if (result.hasFatalError())
return result;
if (projectNameAlreadyExists(newName))
- return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameScriptProjectRefactoring_already_exists);
+ return RefactoringStatus.createFatalErrorStatus(
+ RefactoringCoreMessages.RenameScriptProjectRefactoring_already_exists);
if (projectFolderAlreadyExists(newName))
- return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameScriptProjectProcessor_folder_already_exists);
+ return RefactoringStatus.createFatalErrorStatus(
+ RefactoringCoreMessages.RenameScriptProjectProcessor_folder_already_exists);
return new RefactoringStatus();
}
@Override
- protected RefactoringStatus doCheckFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException {
+ protected RefactoringStatus doCheckFinalConditions(IProgressMonitor pm,
+ CheckConditionsContext context) throws CoreException {
pm.beginTask("", 1); //$NON-NLS-1$
- try{
- if (isReadOnly()){
- String message= Messages.format(RefactoringCoreMessages.RenameScriptProjectRefactoring_read_only,
- fProject.getElementName());
+ try {
+ if (isReadOnly()) {
+ String message = Messages.format(
+ RefactoringCoreMessages.RenameScriptProjectRefactoring_read_only,
+ fProject.getElementName());
return RefactoringStatus.createErrorStatus(message);
}
return new RefactoringStatus();
- } finally{
+ } finally {
pm.done();
}
}
@@ -177,35 +191,54 @@
return Resources.isReadOnly(fProject.getResource());
}
- private boolean projectNameAlreadyExists(String newName){
- return ResourcesPlugin.getWorkspace().getRoot().getProject(newName).exists();
+ private boolean projectNameAlreadyExists(String newName) {
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(newName)
+ .exists();
}
- private boolean projectFolderAlreadyExists(String newName) throws CoreException {
- boolean isNotInWorkpace= fProject.getProject().getDescription().getLocationURI() != null;
+ private boolean projectFolderAlreadyExists(String newName)
+ throws CoreException {
+ boolean isNotInWorkpace = fProject.getProject().getDescription()
+ .getLocationURI() != null;
if (isNotInWorkpace)
return false; // projects outside of the workspace are not renamed
- URI locationURI= fProject.getProject().getLocationURI();
- IFileStore projectStore= EFS.getStore(locationURI);
- IFileStore newProjectStore= projectStore.getParent().getChild(newName);
+ URI locationURI = fProject.getProject().getLocationURI();
+ IFileStore projectStore = EFS.getStore(locationURI);
+ IFileStore newProjectStore = projectStore.getParent().getChild(newName);
return newProjectStore.fetchInfo().exists();
}
- //--- changes
+ // --- changes
@Override
public Change createChange(IProgressMonitor pm) throws CoreException {
pm.beginTask("", 1); //$NON-NLS-1$
try {
- final Map arguments= new HashMap();
- final String description= Messages.format(RefactoringCoreMessages.RenameScriptProjectProcessor_descriptor_description_short, fProject.getElementName());
- final String header= Messages.format(RefactoringCoreMessages.RenameScriptProjectChange_descriptor_description, new String[] { fProject.getElementName(), getNewElementName()});
- final String comment= new ScriptRefactoringDescriptorComment(this, header).asString();
- final ScriptRefactoringDescriptor descriptor= new ScriptRefactoringDescriptor(RenameScriptProjectProcessor.ID_RENAME_SCRIPT_PROJECT, null, description, comment, arguments, RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE | RefactoringDescriptor.BREAKING_CHANGE);
- arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT, descriptor.elementToHandle(fProject));
- arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_NAME, getNewElementName());
- arguments.put(ATTRIBUTE_REFERENCES, Boolean.valueOf(fUpdateReferences).toString());
- return new DynamicValidationStateChange(new RenameScriptProjectChange(descriptor, fProject, getNewElementName(), comment, fUpdateReferences));
+ final Map arguments = new HashMap();
+ final String description = Messages.format(
+ RefactoringCoreMessages.RenameScriptProjectProcessor_descriptor_description_short,
+ fProject.getElementName());
+ final String header = Messages.format(
+ RefactoringCoreMessages.RenameScriptProjectChange_descriptor_description,
+ new String[] { fProject.getElementName(),
+ getNewElementName() });
+ final String comment = new ScriptRefactoringDescriptorComment(this,
+ header).asString();
+ final ScriptRefactoringDescriptor descriptor = new ScriptRefactoringDescriptor(
+ RenameScriptProjectProcessor.ID_RENAME_SCRIPT_PROJECT, null,
+ description, comment, arguments,
+ RefactoringDescriptor.STRUCTURAL_CHANGE
+ | RefactoringDescriptor.MULTI_CHANGE
+ | RefactoringDescriptor.BREAKING_CHANGE);
+ arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT,
+ descriptor.elementToHandle(fProject));
+ arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_NAME,
+ getNewElementName());
+ arguments.put(ATTRIBUTE_REFERENCES,
+ Boolean.valueOf(fUpdateReferences).toString());
+ return new DynamicValidationStateChange(
+ new RenameScriptProjectChange(descriptor, fProject,
+ getNewElementName(), comment, fUpdateReferences));
} finally {
pm.done();
}
@@ -214,28 +247,42 @@
@Override
public RefactoringStatus initialize(RefactoringArguments arguments) {
if (arguments instanceof ScriptRefactoringArguments) {
- final ScriptRefactoringArguments extended= (ScriptRefactoringArguments) arguments;
- final String handle= extended.getAttribute(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT);
+ final ScriptRefactoringArguments extended = (ScriptRefactoringArguments) arguments;
+ final String handle = extended
+ .getAttribute(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT);
if (handle != null) {
- final IModelElement element= ScriptRefactoringDescriptor.handleToElement(extended.getProject(), handle, false);
- if (element == null || !element.exists() || element.getElementType() != IModelElement.SCRIPT_PROJECT)
- return ScriptableRefactoring.createInputFatalStatus(element, getRefactoring().getName(), ID_RENAME_SCRIPT_PROJECT);
- else
- fProject= (IScriptProject) element;
+ final IModelElement element = ScriptRefactoringDescriptor
+ .handleToElement(extended.getProject(), handle, false);
+ if (element == null || !element.exists() || element
+ .getElementType() != IModelElement.SCRIPT_PROJECT) {
+ return ScriptableRefactoring.createInputFatalStatus(element,
+ getRefactoring().getName(),
+ ID_RENAME_SCRIPT_PROJECT);
+ }
+ fProject = (IScriptProject) element;
} else
- return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ScriptRefactoringDescriptor.ATTRIBUTE_INPUT));
- final String name= extended.getAttribute(ScriptRefactoringDescriptor.ATTRIBUTE_NAME);
+ return RefactoringStatus.createFatalErrorStatus(Messages.format(
+ RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
+ ScriptRefactoringDescriptor.ATTRIBUTE_INPUT));
+ final String name = extended
+ .getAttribute(ScriptRefactoringDescriptor.ATTRIBUTE_NAME);
if (name != null && !"".equals(name)) //$NON-NLS-1$
setNewElementName(name);
else
- return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ScriptRefactoringDescriptor.ATTRIBUTE_NAME));
- final String references= extended.getAttribute(ATTRIBUTE_REFERENCES);
+ return RefactoringStatus.createFatalErrorStatus(Messages.format(
+ RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
+ ScriptRefactoringDescriptor.ATTRIBUTE_NAME));
+ final String references = extended
+ .getAttribute(ATTRIBUTE_REFERENCES);
if (references != null) {
- fUpdateReferences= Boolean.valueOf(references).booleanValue();
+ fUpdateReferences = Boolean.valueOf(references).booleanValue();
} else
- return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_REFERENCES));
+ return RefactoringStatus.createFatalErrorStatus(Messages.format(
+ RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
+ ATTRIBUTE_REFERENCES));
} else
- return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments);
+ return RefactoringStatus.createFatalErrorStatus(
+ RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments);
return new RefactoringStatus();
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameSourceFolderProcessor.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameSourceFolderProcessor.java
index 7be1724..f104737 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameSourceFolderProcessor.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameSourceFolderProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -40,23 +40,25 @@
import org.eclipse.ltk.core.refactoring.participants.RefactoringArguments;
import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
-
public class RenameSourceFolderProcessor extends ScriptRenameProcessor {
- private static final String ID_RENAME_SOURCE_FOLDER= "org.eclipse.dltk.ui.rename.source.folder"; //$NON-NLS-1$
- private static final String ATTRIBUTE_PATH= "path"; //$NON-NLS-1$
- private static final String ATTRIBUTE_NAME= "name"; //$NON-NLS-1$
+ private static final String ID_RENAME_SOURCE_FOLDER = "org.eclipse.dltk.ui.rename.source.folder"; //$NON-NLS-1$
+ private static final String ATTRIBUTE_PATH = "path"; //$NON-NLS-1$
+ private static final String ATTRIBUTE_NAME = "name"; //$NON-NLS-1$
private IProjectFragment fSourceFolder;
- public static final String IDENTIFIER= "org.eclipse.dltk.ui.renameSourceFolderProcessor"; //$NON-NLS-1$
+ public static final String IDENTIFIER = "org.eclipse.dltk.ui.renameSourceFolderProcessor"; //$NON-NLS-1$
/**
* Creates a new rename source folder processor.
- * @param root the package fragment root, or <code>null</code> if invoked by scripting
+ *
+ * @param root
+ * the package fragment root, or <code>null</code> if
+ * invoked by scripting
*/
public RenameSourceFolderProcessor(IProjectFragment root) {
- fSourceFolder= root;
+ fSourceFolder = root;
if (root != null)
setNewElementName(root.getElementName());
}
@@ -83,13 +85,14 @@
@Override
public Object[] getElements() {
- return new Object[] {fSourceFolder};
+ return new Object[] { fSourceFolder };
}
@Override
public Object getNewElement() throws CoreException {
- IProjectFragment[] roots= fSourceFolder.getScriptProject().getProjectFragments();
- for (int i= 0; i < roots.length; i++) {
+ IProjectFragment[] roots = fSourceFolder.getScriptProject()
+ .getProjectFragments();
+ for (int i = 0; i < roots.length; i++) {
if (roots[i].getElementName().equals(getNewElementName()))
return roots[i];
}
@@ -97,9 +100,11 @@
}
@Override
- protected RenameModifications computeRenameModifications() throws CoreException {
- RenameModifications result= new RenameModifications();
- result.rename(fSourceFolder, new RenameArguments(getNewElementName(), getUpdateReferences()));
+ protected RenameModifications computeRenameModifications()
+ throws CoreException {
+ RenameModifications result = new RenameModifications();
+ result.rename(fSourceFolder, new RenameArguments(getNewElementName(),
+ getUpdateReferences()));
return result;
}
@@ -108,7 +113,7 @@
return new IFile[0];
}
- //---- IRenameProcessor ----------------------------------------------
+ // ---- IRenameProcessor ----------------------------------------------
@Override
public String getCurrentElementName() {
@@ -116,48 +121,58 @@
}
@Override
- public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
+ throws CoreException {
return new RefactoringStatus();
}
@Override
- public RefactoringStatus checkNewElementName(String newName) throws CoreException {
+ public RefactoringStatus checkNewElementName(String newName)
+ throws CoreException {
Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
- if (! newName.trim().equals(newName))
- return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_blank);
+ if (!newName.trim().equals(newName))
+ return RefactoringStatus.createFatalErrorStatus(
+ RefactoringCoreMessages.RenameSourceFolderRefactoring_blank);
- IContainer c= fSourceFolder.getResource().getParent();
- if (! c.getFullPath().isValidSegment(newName))
- return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_invalid_name);
+ IContainer c = fSourceFolder.getResource().getParent();
+ if (!c.getFullPath().isValidSegment(newName))
+ return RefactoringStatus.createFatalErrorStatus(
+ RefactoringCoreMessages.RenameSourceFolderRefactoring_invalid_name);
- RefactoringStatus result= RefactoringStatus.create(c.getWorkspace().validateName(newName, IResource.FOLDER));
+ RefactoringStatus result = RefactoringStatus.create(
+ c.getWorkspace().validateName(newName, IResource.FOLDER));
if (result.hasFatalError())
return result;
- result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(createNewPath(newName), IResource.FOLDER)));
+ result.merge(RefactoringStatus.create(c.getWorkspace()
+ .validatePath(createNewPath(newName), IResource.FOLDER)));
if (result.hasFatalError())
return result;
- IScriptProject project= fSourceFolder.getScriptProject();
- IPath p= project.getProject().getFullPath().append(newName);
+ IScriptProject project = fSourceFolder.getScriptProject();
+ IPath p = project.getProject().getFullPath().append(newName);
if (project.findProjectFragment(p) != null)
- return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_already_exists);
+ return RefactoringStatus.createFatalErrorStatus(
+ RefactoringCoreMessages.RenameSourceFolderRefactoring_already_exists);
if (project.getProject().findMember(new Path(newName)) != null)
- return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameSourceFolderRefactoring_alread_exists);
+ return RefactoringStatus.createFatalErrorStatus(
+ RefactoringCoreMessages.RenameSourceFolderRefactoring_alread_exists);
return result;
}
private String createNewPath(String newName) {
- return fSourceFolder.getPath().removeLastSegments(1).append(newName).toString();
+ return fSourceFolder.getPath().removeLastSegments(1).append(newName)
+ .toString();
}
@Override
- protected RefactoringStatus doCheckFinalConditions(IProgressMonitor pm, CheckConditionsContext context) throws CoreException {
+ protected RefactoringStatus doCheckFinalConditions(IProgressMonitor pm,
+ CheckConditionsContext context) throws CoreException {
pm.beginTask("", 1); //$NON-NLS-1$
- try{
+ try {
return new RefactoringStatus();
- } finally{
+ } finally {
pm.done();
}
}
@@ -170,17 +185,27 @@
public Change createChange(IProgressMonitor pm) throws CoreException {
pm.beginTask("", 1); //$NON-NLS-1$
try {
- final Map arguments= new HashMap();
- final IResource resource= fSourceFolder.getResource();
- final String project= resource.getProject().getName();
- final String newName= getNewElementName();
- final String description= Messages.format(RefactoringCoreMessages.RenameSourceFolderChange_descriptor_description_short, fSourceFolder.getElementName());
- final String header= Messages.format(RefactoringCoreMessages.RenameSourceFolderChange_descriptor_description, new String[] { resource.getFullPath().toString(), newName});
- final String comment= new ScriptRefactoringDescriptorComment(this, header).asString();
- final ScriptRefactoringDescriptor descriptor= new ScriptRefactoringDescriptor(ID_RENAME_SOURCE_FOLDER, project, description, comment, arguments, RefactoringDescriptor.NONE);
- arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT, descriptor.elementToHandle(DLTKCore.create(resource)));
+ final Map arguments = new HashMap();
+ final IResource resource = fSourceFolder.getResource();
+ final String project = resource.getProject().getName();
+ final String newName = getNewElementName();
+ final String description = Messages.format(
+ RefactoringCoreMessages.RenameSourceFolderChange_descriptor_description_short,
+ fSourceFolder.getElementName());
+ final String header = Messages.format(
+ RefactoringCoreMessages.RenameSourceFolderChange_descriptor_description,
+ resource.getFullPath().toString(), newName);
+ final String comment = new ScriptRefactoringDescriptorComment(this,
+ header).asString();
+ final ScriptRefactoringDescriptor descriptor = new ScriptRefactoringDescriptor(
+ ID_RENAME_SOURCE_FOLDER, project, description, comment,
+ arguments, RefactoringDescriptor.NONE);
+ arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT,
+ descriptor.elementToHandle(DLTKCore.create(resource)));
arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_NAME, newName);
- return new DynamicValidationStateChange(new RenameSourceFolderChange(descriptor, fSourceFolder, newName, comment));
+ return new DynamicValidationStateChange(
+ new RenameSourceFolderChange(descriptor, fSourceFolder,
+ newName, comment));
} finally {
pm.done();
}
@@ -189,23 +214,31 @@
@Override
public RefactoringStatus initialize(RefactoringArguments arguments) {
if (arguments instanceof ScriptRefactoringArguments) {
- final ScriptRefactoringArguments generic= (ScriptRefactoringArguments) arguments;
- final String path= generic.getAttribute(ATTRIBUTE_PATH);
+ final ScriptRefactoringArguments generic = (ScriptRefactoringArguments) arguments;
+ final String path = generic.getAttribute(ATTRIBUTE_PATH);
if (path != null) {
- final IResource resource= ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(path));
- if (resource == null || !resource.exists())
- return ScriptableRefactoring.createInputFatalStatus(resource, getRefactoring().getName(), ID_RENAME_SOURCE_FOLDER);
- else
- fSourceFolder= (IProjectFragment) DLTKCore.create(resource);
+ final IResource resource = ResourcesPlugin.getWorkspace()
+ .getRoot().findMember(new Path(path));
+ if (resource == null || !resource.exists()) {
+ return ScriptableRefactoring.createInputFatalStatus(
+ resource, getRefactoring().getName(),
+ ID_RENAME_SOURCE_FOLDER);
+ }
+ fSourceFolder = (IProjectFragment) DLTKCore.create(resource);
} else
- return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_PATH));
- final String name= generic.getAttribute(ATTRIBUTE_NAME);
+ return RefactoringStatus.createFatalErrorStatus(Messages.format(
+ RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
+ ATTRIBUTE_PATH));
+ final String name = generic.getAttribute(ATTRIBUTE_NAME);
if (name != null && !"".equals(name)) //$NON-NLS-1$
setNewElementName(name);
else
- return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_NAME));
+ return RefactoringStatus.createFatalErrorStatus(Messages.format(
+ RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
+ ATTRIBUTE_NAME));
} else
- return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments);
+ return RefactoringStatus.createFatalErrorStatus(
+ RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments);
return new RefactoringStatus();
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameSourceModuleProcessor.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameSourceModuleProcessor.java
index 04ab7ae..ba68970 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameSourceModuleProcessor.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameSourceModuleProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -69,11 +69,12 @@
* Creates a new rename compilation unit processor.
*
* @param unit
- * the compilation unit, or <code>null</code> if invoked by
- * scripting
+ * the compilation unit, or <code>null</code> if invoked by
+ * scripting
* @throws CoreException
*/
- public RenameSourceModuleProcessor(ISourceModule unit) throws CoreException {
+ public RenameSourceModuleProcessor(ISourceModule unit)
+ throws CoreException {
fCu = unit;
if (fCu != null) {
computeRenameTypeRefactoring();
@@ -133,10 +134,9 @@
if (isFileExtensionRequired()) {
// return initial name without extension
return getSimpleCUName();
- } else {
- // return initial name with extension
- return fCu.getElementName();
}
+ // return initial name with extension
+ return fCu.getElementName();
}
/**
@@ -166,8 +166,8 @@
}
RefactoringStatus result = new RefactoringStatus();// Checks.checkSourceModuleName(newName);
if (Checks.isAlreadyNamed(fCu, newName))
- result
- .addFatalError(RefactoringCoreMessages.RenameSourceModuleRefactoring_same_name);
+ result.addFatalError(
+ RefactoringCoreMessages.RenameSourceModuleRefactoring_same_name);
return result;
}
@@ -184,9 +184,8 @@
IScriptFolder pack = (IScriptFolder) parent;
IDLTKLanguageToolkit tk = null;
tk = DLTKLanguageManager.getLanguageToolkit(pack);
- if (tk != null
- && !DLTKContentTypeManager.isValidFileNameForContentType(tk,
- getNewElementName())) {
+ if (tk != null && !DLTKContentTypeManager
+ .isValidFileNameForContentType(tk, getNewElementName())) {
return fCu; // ??
}
return pack.getSourceModule(getNewElementName());
@@ -341,28 +340,23 @@
final Map arguments = new HashMap();
final IProject project = resource.getProject();
final String name = project.getName();
- final String description = Messages
- .format(
- RefactoringCoreMessages.RenameSourceModuleChange_descriptor_description_short,
- resource.getName());
- final String header = Messages
- .format(
- RefactoringCoreMessages.RenameSourceModuleChange_descriptor_description,
- new String[] { resource.getFullPath().toString(),
- newName });
+ final String description = Messages.format(
+ RefactoringCoreMessages.RenameSourceModuleChange_descriptor_description_short,
+ resource.getName());
+ final String header = Messages.format(
+ RefactoringCoreMessages.RenameSourceModuleChange_descriptor_description,
+ resource.getFullPath().toString(), newName);
final String comment = new ScriptRefactoringDescriptorComment(this,
header).asString();
final ScriptRefactoringDescriptor descriptor = new ScriptRefactoringDescriptor(
- RenameResourceProcessor.ID_RENAME_RESOURCE,
- name,
- description,
- comment,
- arguments,
+ RenameResourceProcessor.ID_RENAME_RESOURCE, name,
+ description, comment, arguments,
(RefactoringDescriptor.STRUCTURAL_CHANGE
- | RefactoringDescriptor.MULTI_CHANGE | RefactoringDescriptor.BREAKING_CHANGE));
+ | RefactoringDescriptor.MULTI_CHANGE
+ | RefactoringDescriptor.BREAKING_CHANGE));
arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT,
- ScriptRefactoringDescriptor
- .resourceToHandle(name, resource));
+ ScriptRefactoringDescriptor.resourceToHandle(name,
+ resource));
arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_NAME, newName);
return new DynamicValidationStateChange(new RenameResourceChange(
descriptor, resource, newName, comment));
@@ -378,14 +372,12 @@
label = fCu.getElementName();
final Map arguments = new HashMap();
final String name = fCu.getScriptProject().getElementName();
- final String description = Messages
- .format(
- RefactoringCoreMessages.RenameSourceModuleChange_descriptor_description_short,
- fCu.getElementName());
- final String header = Messages
- .format(
- RefactoringCoreMessages.RenameSourceModuleChange_descriptor_description,
- new String[] { label, newName });
+ final String description = Messages.format(
+ RefactoringCoreMessages.RenameSourceModuleChange_descriptor_description_short,
+ fCu.getElementName());
+ final String header = Messages.format(
+ RefactoringCoreMessages.RenameSourceModuleChange_descriptor_description,
+ label, newName);
final String comment = new ScriptRefactoringDescriptorComment(this,
header).asString();
final ScriptRefactoringDescriptor descriptor = new ScriptRefactoringDescriptor(
@@ -395,8 +387,8 @@
| ScriptRefactoringDescriptor.ARCHIVE_REFACTORABLE
| RefactoringDescriptor.STRUCTURAL_CHANGE
| RefactoringDescriptor.MULTI_CHANGE);
- arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT, descriptor
- .elementToHandle(fCu));
+ arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT,
+ descriptor.elementToHandle(fCu));
arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_NAME, newName);
return new DynamicValidationStateChange(new RenameSourceModuleChange(
descriptor, fCu, newName, comment));
@@ -419,36 +411,31 @@
if (path != null) {
final IResource resource = ResourcesPlugin.getWorkspace()
.getRoot().findMember(new Path(path));
- if (resource == null || !resource.exists())
+ if (resource == null || !resource.exists()) {
return ScriptableRefactoring.createInputFatalStatus(
resource, getRefactoring().getName(),
ID_RENAME_COMPILATION_UNIT);
- else {
- fCu = (ISourceModule) DLTKCore.create(resource);
- try {
- computeRenameTypeRefactoring();
- } catch (CoreException exception) {
- DLTKUIPlugin.log(exception);
- }
+ }
+ fCu = (ISourceModule) DLTKCore.create(resource);
+ try {
+ computeRenameTypeRefactoring();
+ } catch (CoreException exception) {
+ DLTKUIPlugin.log(exception);
}
} else
- return RefactoringStatus
- .createFatalErrorStatus(Messages
- .format(
- RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
- ATTRIBUTE_PATH));
+ return RefactoringStatus.createFatalErrorStatus(Messages.format(
+ RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
+ ATTRIBUTE_PATH));
final String name = generic.getAttribute(ATTRIBUTE_NAME);
if (name != null && !"".equals(name)) //$NON-NLS-1$
setNewElementName(name);
else
- return RefactoringStatus
- .createFatalErrorStatus(Messages
- .format(
- RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
- ATTRIBUTE_NAME));
+ return RefactoringStatus.createFatalErrorStatus(Messages.format(
+ RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
+ ATTRIBUTE_NAME));
} else
- return RefactoringStatus
- .createFatalErrorStatus(RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments);
+ return RefactoringStatus.createFatalErrorStatus(
+ RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments);
return new RefactoringStatus();
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenamingNameSuggestor.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenamingNameSuggestor.java
index f7931f3..8d526a8 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenamingNameSuggestor.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenamingNameSuggestor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -176,13 +176,13 @@
initializePrefixesAndSuffixes(project);
- if (isStatic)
+ if (isStatic) {
return suggestNewVariableName(fStaticFieldPrefixes,
fStaticFieldSuffixes, oldFieldName, oldTypeName,
newTypeName);
- else
- return suggestNewVariableName(fFieldPrefixes, fFieldSuffixes,
- oldFieldName, oldTypeName, newTypeName);
+ }
+ return suggestNewVariableName(fFieldPrefixes, fFieldSuffixes,
+ oldFieldName, oldTypeName, newTypeName);
}
public String suggestNewLocalName(IScriptProject project,
@@ -191,12 +191,12 @@
initializePrefixesAndSuffixes(project);
- if (isArgument)
+ if (isArgument) {
return suggestNewVariableName(fArgumentPrefixes, fArgumentSuffixes,
oldLocalName, oldTypeName, newTypeName);
- else
- return suggestNewVariableName(fLocalPrefixes, fLocalSuffixes,
- oldLocalName, oldTypeName, newTypeName);
+ }
+ return suggestNewVariableName(fLocalPrefixes, fLocalSuffixes,
+ oldLocalName, oldTypeName, newTypeName);
}
public String suggestNewMethodName(String oldMethodName, String oldTypeName,
@@ -443,10 +443,10 @@
}
String varName = concat(suffixesVar);
- if (varName.equals(strippedVariableName))
+ if (varName.equals(strippedVariableName)) {
return null; // no "silly suggestions"
- else
- return varName;
+ }
+ return varName;
}
// ---------------- Helper methods
@@ -519,25 +519,25 @@
}
private String getLowerCased(String name) {
- if (name.length() > 1)
+ if (name.length() > 1) {
return Character.toLowerCase(name.charAt(0)) + name.substring(1);
- else
- return name.toLowerCase();
+ }
+ return name.toLowerCase();
}
private String getUpperCased(String name) {
- if (name.length() > 1)
+ if (name.length() > 1) {
return Character.toUpperCase(name.charAt(0)) + name.substring(1);
- else
- return name.toLowerCase();
+ }
+ return name.toLowerCase();
}
private String getFirstUpperRestLowerCased(String name) {
- if (name.length() > 1)
+ if (name.length() > 1) {
return Character.toUpperCase(name.charAt(0))
+ name.substring(1).toLowerCase();
- else
- return name.toLowerCase();
+ }
+ return name.toLowerCase();
}
private boolean isInterfaceName(String typeName) {
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/DeleteChangeCreator.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/DeleteChangeCreator.java
index d8a2c54..d9bb91f 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/DeleteChangeCreator.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/DeleteChangeCreator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -44,38 +44,41 @@
import org.eclipse.text.edits.DeleteEdit;
import org.eclipse.text.edits.MultiTextEdit;
-
-
class DeleteChangeCreator {
private DeleteChangeCreator() {
- //private
+ // private
}
- static Change createDeleteChange(TextChangeManager manager, IResource[] resources, IModelElement[] modelElements, String changeName) throws CoreException {
- final DynamicValidationStateChange result= new DynamicValidationStateChange(changeName) {
+ static Change createDeleteChange(TextChangeManager manager,
+ IResource[] resources, IModelElement[] modelElements,
+ String changeName) throws CoreException {
+ final DynamicValidationStateChange result = new DynamicValidationStateChange(
+ changeName) {
@Override
public Change perform(IProgressMonitor pm) throws CoreException {
super.perform(pm);
return null;
}
};
- for (int i= 0; i < modelElements.length; i++) {
- IModelElement element= modelElements[i];
- if (! ReorgUtils.isInsideSourceModule(element))
+ for (int i = 0; i < modelElements.length; i++) {
+ IModelElement element = modelElements[i];
+ if (!ReorgUtils.isInsideSourceModule(element))
result.add(createDeleteChange(element));
}
- for (int i= 0; i < resources.length; i++) {
+ for (int i = 0; i < resources.length; i++) {
result.add(createDeleteChange(resources[i]));
}
- Map grouped= ReorgUtils.groupBySourceModule(getElementsSmallerThanCu(modelElements));
- if (grouped.size() != 0 ){
+ Map grouped = ReorgUtils
+ .groupBySourceModule(getElementsSmallerThanCu(modelElements));
+ if (grouped.size() != 0) {
Assert.isNotNull(manager);
- for (Iterator iter= grouped.keySet().iterator(); iter.hasNext();) {
- ISourceModule cu= (ISourceModule) iter.next();
- Change change = createDeleteChange(cu, (List)grouped.get(cu), manager);
- if( change != null ) {
+ for (Iterator iter = grouped.keySet().iterator(); iter.hasNext();) {
+ ISourceModule cu = (ISourceModule) iter.next();
+ Change change = createDeleteChange(cu, (List) grouped.get(cu),
+ manager);
+ if (change != null) {
result.add(change);
}
}
@@ -85,13 +88,15 @@
}
private static Change createDeleteChange(IResource resource) {
- Assert.isTrue(! (resource instanceof IWorkspaceRoot));//cannot be done
- Assert.isTrue(! (resource instanceof IProject)); //project deletion is handled by the workbench
+ Assert.isTrue(!(resource instanceof IWorkspaceRoot));// cannot be done
+ Assert.isTrue(!(resource instanceof IProject)); // project deletion is
+ // handled by the
+ // workbench
if (resource instanceof IFile)
- return new DeleteFileChange((IFile)resource, true);
+ return new DeleteFileChange((IFile) resource, true);
if (resource instanceof IFolder)
- return new DeleteFolderChange((IFolder)resource, true);
- Assert.isTrue(false);//there're no more kinds
+ return new DeleteFolderChange((IFolder) resource, true);
+ Assert.isTrue(false);// there're no more kinds
return null;
}
@@ -103,41 +108,43 @@
throws CoreException {
// SourceModule cuNode= RefactoringASTParser.parseWithASTProvider(cu, false, null);
// SourceModuleRewrite rewriter= new SourceModuleRewrite(cu, cuNode);
- Assert.isNotNull(cu);
- Assert.isNotNull(modelElements);
- Assert.isNotNull(manager);
- TextFileChange textFileChange = null;
- if (cu != null && cu.getResource() instanceof IFile) {
- textFileChange = new TextFileChange(cu.getElementName(), (IFile)cu.getResource());
- MultiTextEdit fileChangeRootEdit = new MultiTextEdit();
- textFileChange.setEdit(fileChangeRootEdit);
+ Assert.isNotNull(cu);
+ Assert.isNotNull(modelElements);
+ Assert.isNotNull(manager);
+ TextFileChange textFileChange = null;
+ if (cu != null && cu.getResource() instanceof IFile) {
+ textFileChange = new TextFileChange(cu.getElementName(),
+ (IFile) cu.getResource());
+ MultiTextEdit fileChangeRootEdit = new MultiTextEdit();
+ textFileChange.setEdit(fileChangeRootEdit);
- manager.manage(cu, textFileChange);
+ manager.manage(cu, textFileChange);
IModelElement[] elements = modelElements
.toArray(new IModelElement[modelElements.size()]);
- for (int cnt = 0, max = elements.length; cnt < max; cnt++) {
- ISourceRange sourceRange = null;
- if (elements[cnt] instanceof IMember) {
- IMember type = (IMember)elements[cnt];
- sourceRange = type.getSourceRange();
- }
- if (sourceRange != null) {
- DeleteEdit edit = new DeleteEdit(sourceRange.getOffset(), sourceRange.getLength());
+ for (int cnt = 0, max = elements.length; cnt < max; cnt++) {
+ ISourceRange sourceRange = null;
+ if (elements[cnt] instanceof IMember) {
+ IMember type = (IMember) elements[cnt];
+ sourceRange = type.getSourceRange();
+ }
+ if (sourceRange != null) {
+ DeleteEdit edit = new DeleteEdit(sourceRange.getOffset(),
+ sourceRange.getLength());
- fileChangeRootEdit.addChild(edit);
- if (cu.isWorkingCopy()) {
- textFileChange.setSaveMode(TextFileChange.LEAVE_DIRTY);
- }
+ fileChangeRootEdit.addChild(edit);
+ if (cu.isWorkingCopy()) {
+ textFileChange.setSaveMode(TextFileChange.LEAVE_DIRTY);
+ }
- }
- }
- }
+ }
+ }
+ }
- // ASTNodeDeleteUtil.markAsDeleted(elements, rewriter, null);
+ // ASTNodeDeleteUtil.markAsDeleted(elements, rewriter, null);
// return addTextEditFromRewrite(manager, cu, rewriter.getASTRewrite());
- return textFileChange;
+ return textFileChange;
}
// private static TextChange addTextEditFromRewrite(TextChangeManager manager, ISourceModule cu, ASTRewrite rewrite) throws CoreException {
@@ -158,11 +165,12 @@
// }
// }
- //List<IModelElement>
- private static List getElementsSmallerThanCu(IModelElement[] modelElements){
- List result= new ArrayList();
- for (int i= 0; i < modelElements.length; i++) {
- IModelElement element= modelElements[i];
+ // List<IModelElement>
+ private static List getElementsSmallerThanCu(
+ IModelElement[] modelElements) {
+ List result = new ArrayList();
+ for (int i = 0; i < modelElements.length; i++) {
+ IModelElement element = modelElements[i];
if (ReorgUtils.isInsideSourceModule(element))
result.add(element);
}
@@ -170,71 +178,79 @@
}
private static Change createDeleteChange(IModelElement modelElement) {
- Assert.isTrue(! ReorgUtils.isInsideSourceModule(modelElement));
+ Assert.isTrue(!ReorgUtils.isInsideSourceModule(modelElement));
- switch(modelElement.getElementType()){
- case IModelElement.PROJECT_FRAGMENT:
- return createProjectFragmentDeleteChange((IProjectFragment)modelElement);
+ switch (modelElement.getElementType()) {
+ case IModelElement.PROJECT_FRAGMENT:
+ return createProjectFragmentDeleteChange(
+ (IProjectFragment) modelElement);
- case IModelElement.SCRIPT_FOLDER:
- return createSourceManipulationDeleteChange((IScriptFolder)modelElement);
+ case IModelElement.SCRIPT_FOLDER:
+ return createSourceManipulationDeleteChange(
+ (IScriptFolder) modelElement);
- case IModelElement.SOURCE_MODULE:
- return createSourceManipulationDeleteChange((ISourceModule)modelElement);
+ case IModelElement.SOURCE_MODULE:
+ return createSourceManipulationDeleteChange(
+ (ISourceModule) modelElement);
- case IModelElement.SCRIPT_MODEL: //cannot be done
- Assert.isTrue(false);
- return null;
+ case IModelElement.SCRIPT_MODEL: // cannot be done
+ Assert.isTrue(false);
+ return null;
- case IModelElement.SCRIPT_PROJECT: //handled differently
- Assert.isTrue(false);
- return null;
+ case IModelElement.SCRIPT_PROJECT: // handled differently
+ Assert.isTrue(false);
+ return null;
- case IModelElement.TYPE:
- case IModelElement.FIELD:
- case IModelElement.METHOD:
+ case IModelElement.TYPE:
+ case IModelElement.FIELD:
+ case IModelElement.METHOD:
// case IModelElement.INITIALIZER:
// case IModelElement.PACKAGE_DECLARATION:
// case IModelElement.IMPORT_CONTAINER:
// case IModelElement.IMPORT_DECLARATION:
// Assert.isTrue(false);//not done here
- default:
- Assert.isTrue(false);//there's no more kinds
- return new NullChange();
+ default:
+ Assert.isTrue(false);// there's no more kinds
+ return new NullChange();
}
}
- private static Change createSourceManipulationDeleteChange(ISourceManipulation element) {
- //XXX workaround for bug 31384, in case of linked ISourceManipulation delete the resource
- if (element instanceof ISourceModule || element instanceof IScriptFolder){
+ private static Change createSourceManipulationDeleteChange(
+ ISourceManipulation element) {
+ // XXX workaround for bug 31384, in case of linked ISourceManipulation
+ // delete the resource
+ if (element instanceof ISourceModule
+ || element instanceof IScriptFolder) {
IResource resource;
if (element instanceof ISourceModule)
- resource= ReorgUtils.getResource((ISourceModule)element);
+ resource = ReorgUtils.getResource((ISourceModule) element);
else
- resource= ((IScriptFolder)element).getResource();
+ resource = ((IScriptFolder) element).getResource();
if (resource != null && resource.isLinked())
return createDeleteChange(resource);
}
return new DeleteSourceManipulationChange(element, true);
}
- private static Change createProjectFragmentDeleteChange(IProjectFragment root) {
- IResource resource= root.getResource();
- if (resource != null && resource.isLinked()){
- //XXX using this code is a workaround for jcore bug 31998
- //jcore cannot handle linked stuff
- //normally, we should always create DeleteProjectFragmentChange
- CompositeChange composite= new DynamicValidationStateChange(RefactoringCoreMessages.DeleteRefactoring_delete_package_fragment_root);
+ private static Change createProjectFragmentDeleteChange(
+ IProjectFragment root) {
+ IResource resource = root.getResource();
+ if (resource != null && resource.isLinked()) {
+ // XXX using this code is a workaround for jcore bug 31998
+ // jcore cannot handle linked stuff
+ // normally, we should always create DeleteProjectFragmentChange
+ CompositeChange composite = new DynamicValidationStateChange(
+ RefactoringCoreMessages.DeleteRefactoring_delete_package_fragment_root);
composite.add(new DeleteFromBuildpathChange(root));
- Assert.isTrue(! Checks.isBuildpathDelete(root));//checked in preconditions
+ Assert.isTrue(!Checks.isBuildpathDelete(root));// checked in
+ // preconditions
composite.add(createDeleteChange(resource));
return composite;
- } else {
- Assert.isTrue(! root.isExternal());
- // TODO remove the query argument
- return new DeleteProjectFragmentChange(root, true, null);
}
+ Assert.isTrue(!root.isExternal());
+ // TODO remove the query argument
+ return new DeleteProjectFragmentChange(root, true, null);
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/OverwriteHelper.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/OverwriteHelper.java
index ac322bf..63607b7 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/OverwriteHelper.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/OverwriteHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -224,9 +224,8 @@
IScriptFolder destination = (IScriptFolder) fDestination;
return !destination.equals(cu.getParent()) && destination
.getSourceModule(cu.getElementName()).exists();
- } else {
- return canOverwrite(ReorgUtils.getResource(cu));
}
+ return canOverwrite(ReorgUtils.getResource(cu));
}
private static boolean overwrite(IResource resource,
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ParentChecker.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ParentChecker.java
index 9e7ed54..e24a44c 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ParentChecker.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ParentChecker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -41,10 +41,10 @@
Assert.isNotNull(commonResourceParent);
IModelElement convertedToScript = DLTKCore
.create(commonResourceParent);
- if (convertedToScript != null && convertedToScript.exists())
+ if (convertedToScript != null && convertedToScript.exists()) {
return convertedToScript;
- else
- return commonResourceParent;
+ }
+ return commonResourceParent;
}
if (fResources.length == 0)
return getCommonScriptElementParent();
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ReorgPolicyFactory.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ReorgPolicyFactory.java
index 2238ada..5177ad5 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ReorgPolicyFactory.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ReorgPolicyFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -124,12 +124,12 @@
if (resources.length != 0 || ReorgUtils.hasElementsNotOfType(
modelElements, IModelElement.SCRIPT_FOLDER))
return NO;
- if (copy)
+ if (copy) {
return new CopyPackagesPolicy(
ArrayTypeConverter.toPackageArray(modelElements));
- else
- return new MovePackagesPolicy(
- ArrayTypeConverter.toPackageArray(modelElements));
+ }
+ return new MovePackagesPolicy(
+ ArrayTypeConverter.toPackageArray(modelElements));
}
if (ReorgUtils.hasElementsOfType(modelElements,
@@ -137,12 +137,12 @@
if (resources.length != 0 || ReorgUtils.hasElementsNotOfType(
modelElements, IModelElement.PROJECT_FRAGMENT))
return NO;
- if (copy)
+ if (copy) {
return new CopyProjectFragmentsPolicy(ArrayTypeConverter
.toProjectFragmentArray(modelElements));
- else
- return new MoveProjectFragmentsPolicy(ArrayTypeConverter
- .toProjectFragmentArray(modelElements));
+ }
+ return new MoveProjectFragmentsPolicy(
+ ArrayTypeConverter.toProjectFragmentArray(modelElements));
}
if (ReorgUtils.hasElementsOfType(resources,
@@ -155,16 +155,16 @@
if (ReorgUtils.hasElementsNotOfType(resources,
IResource.FILE | IResource.FOLDER))
return NO;
- if (copy)
+ if (copy) {
return new CopyFilesFoldersAndCusPolicy(
ReorgUtils.getFiles(resources),
ReorgUtils.getFolders(resources),
ArrayTypeConverter.toCuArray(modelElements));
- else
- return new MoveFilesFoldersAndCusPolicy(
- ReorgUtils.getFiles(resources),
- ReorgUtils.getFolders(resources),
- ArrayTypeConverter.toCuArray(modelElements));
+ }
+ return new MoveFilesFoldersAndCusPolicy(
+ ReorgUtils.getFiles(resources),
+ ReorgUtils.getFolders(resources),
+ ArrayTypeConverter.toCuArray(modelElements));
}
if (hasElementsSmallerThanCuOrClassFile(modelElements)) {
@@ -173,15 +173,14 @@
Assert.isTrue(!ReorgUtils.hasElementsOfType(modelElements,
IModelElement.SOURCE_MODULE));
Assert.isTrue(!hasElementsLargerThanCuOrClassFile(modelElements));
- if (copy)
+ if (copy) {
return new CopySubCuElementsPolicy(modelElements);
- else {
- if (DLTKCore.DEBUG) {
- System.err.println(
- "TODO: ReorgPolicyFactory: Add MoveSubCuElementsPolicy support"); //$NON-NLS-1$
- }
- // return new MoveSubCuElementsPolicy(modelElements);
}
+ if (DLTKCore.DEBUG) {
+ System.err.println(
+ "TODO: ReorgPolicyFactory: Add MoveSubCuElementsPolicy support"); //$NON-NLS-1$
+ }
+ // return new MoveSubCuElementsPolicy(modelElements);
}
return NO;
}
@@ -308,9 +307,8 @@
if (modifications != null) {
return modifications.loadParticipants(status, processor,
natures, shared);
- } else {
- return new RefactoringParticipant[0];
}
+ return new RefactoringParticipant[0];
}
@Override
@@ -947,10 +945,10 @@
private IScriptProject getDestinationAsScriptProject(
IModelElement modelElementDestination) {
- if (modelElementDestination == null)
+ if (modelElementDestination == null) {
return null;
- else
- return modelElementDestination.getScriptProject();
+ }
+ return modelElementDestination.getScriptProject();
}
protected IProjectFragment[] getProjectFragments() {
@@ -1490,17 +1488,15 @@
newName);
}
return new CopyScriptFolderChange(pack, destination, nameQuery);
- } else {
- if (destination.getResource() instanceof IContainer) {
- IContainer dest = (IContainer) destination.getResource();
- IResource res = pack.getResource();
- INewNameQuery nameQuery = copyQueries
- .createNewResourceNameQuery(res, newName);
- return new CopyResourceChange(res, dest, nameQuery);
- } else {
- return new NullChange();
- }
}
+ if (destination.getResource() instanceof IContainer) {
+ IContainer dest = (IContainer) destination.getResource();
+ IResource res = pack.getResource();
+ INewNameQuery nameQuery = copyQueries
+ .createNewResourceNameQuery(res, newName);
+ return new CopyResourceChange(res, dest, nameQuery);
+ }
+ return new NullChange();
}
}
@@ -2038,9 +2034,8 @@
public Change createChange(IProgressMonitor pm) throws ModelException {
if (!fUpdateReferences) {
return createSimpleMoveChange(pm);
- } else {
- return createReferenceUpdatingMoveChange(pm);
}
+ return createReferenceUpdatingMoveChange(pm);
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ReorgUtils.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ReorgUtils.java
index 69df012..c80b88d 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ReorgUtils.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ReorgUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2017 IBM Corporation and others.
+ * Copyright (c) 2005, 2018 IBM Corporation 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
@@ -128,9 +128,8 @@
case IModelElement.SOURCE_MODULE:
if (element instanceof ExternalSourceModule) {
return RefactoringCoreMessages.ReorgUtils_21;
- } else {
- return RefactoringCoreMessages.ReorgUtils_4;
}
+ return RefactoringCoreMessages.ReorgUtils_4;
case IModelElement.FIELD:
return RefactoringCoreMessages.ReorgUtils_5;
// case IModelElement.IMPORT_CONTAINER:
@@ -140,17 +139,17 @@
case IModelElement.SCRIPT_PROJECT:
return RefactoringCoreMessages.ReorgUtils_9;
case IModelElement.METHOD:
- if (((IMethod) element).isConstructor())
+ if (((IMethod) element).isConstructor()) {
return RefactoringCoreMessages.ReorgUtils_10;
- else
- return RefactoringCoreMessages.ReorgUtils_11;
- // case IModelElement.PACKAGE_DECLARATION:
- // return RefactoringCoreMessages.ReorgUtils_12;
+ }
+ return RefactoringCoreMessages.ReorgUtils_11;
+ // case IModelElement.PACKAGE_DECLARATION:
+ // return RefactoringCoreMessages.ReorgUtils_12;
case IModelElement.SCRIPT_FOLDER:
- if (ModelElementUtil.isDefaultPackage(element))
+ if (ModelElementUtil.isDefaultPackage(element)) {
return RefactoringCoreMessages.ReorgUtils_13;
- else
- return RefactoringCoreMessages.ReorgUtils_14;
+ }
+ return RefactoringCoreMessages.ReorgUtils_14;
case IModelElement.PROJECT_FRAGMENT:
if (isSourceFolder(element))
return RefactoringCoreMessages.ReorgUtils_15;
@@ -173,9 +172,8 @@
if (element instanceof ExternalSourceModule) {
return new String[] { ((ExternalSourceModule) element)
.getFullPath().toString() };
- } else {
- return new String[] { element.getElementName() };
}
+ return new String[] { element.getElementName() };
case IModelElement.FIELD:
return new String[] { element.getElementName() };
// case IModelElement.IMPORT_CONTAINER:
@@ -223,10 +221,10 @@
}
public static IResource getResource(IModelElement element) {
- if (element instanceof ISourceModule)
+ if (element instanceof ISourceModule) {
return ((ISourceModule) element).getPrimary().getResource();
- else
- return element.getResource();
+ }
+ return element.getResource();
}
public static IResource[] getResources(IModelElement[] elements) {
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/util/ModelElementUtil.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/util/ModelElementUtil.java
index 2923086..1475ebe 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/util/ModelElementUtil.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/util/ModelElementUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -116,7 +116,7 @@
/**
* @param pack
- * a package fragment
+ * a package fragment
* @return an array containing the given package and all subpackages
* @throws ModelException
*/
@@ -142,7 +142,7 @@
/**
* @param pack
- * the package fragment; may not be null
+ * the package fragment; may not be null
* @return the parent package fragment, or null if the given package
* fragment is the default package or a top level package
*/
@@ -155,10 +155,10 @@
final IProjectFragment root = (IProjectFragment) pack.getParent();
final String newPackageName = pack.getElementName().substring(0, index);
final IScriptFolder parent = root.getScriptFolder(newPackageName);
- if (parent.exists())
+ if (parent.exists()) {
return parent;
- else
- return null;
+ }
+ return null;
}
public static IMember[] sortByOffset(IMember[] members) {
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/util/OpenMethodHistory.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/util/OpenMethodHistory.java
index 832f699..b772bac 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/util/OpenMethodHistory.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/util/OpenMethodHistory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -61,12 +61,10 @@
IDLTKUILanguageToolkit toolkit) {
if (sToolkitHistory.containsKey(toolkit)) {
return (OpenMethodHistory) sToolkitHistory.get(toolkit);
- } else {
- OpenMethodHistory his = new OpenMethodHistory(toolkit);
- sToolkitHistory.put(toolkit, his);
- return his;
}
-
+ OpenMethodHistory his = new OpenMethodHistory(toolkit);
+ sToolkitHistory.put(toolkit, his);
+ return his;
}
private class MethodHistoryDeltaListener
@@ -82,7 +80,7 @@
* Computes whether the history needs a consistency check or not.
*
* @param delta
- * the Java element delta
+ * the Java element delta
*
* @return <code>true</code> if consistency must be checked
* <code>false</code> otherwise.
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/util/OpenTypeHistory.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/util/OpenTypeHistory.java
index 3a0ceab..417bb25 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/util/OpenTypeHistory.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/util/OpenTypeHistory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -62,11 +62,10 @@
IDLTKUILanguageToolkit toolkit) {
if (sToolkitHistory.containsKey(toolkit)) {
return sToolkitHistory.get(toolkit);
- } else {
- OpenTypeHistory his = new OpenTypeHistory(toolkit);
- sToolkitHistory.put(toolkit, his);
- return his;
}
+ OpenTypeHistory his = new OpenTypeHistory(toolkit);
+ sToolkitHistory.put(toolkit, his);
+ return his;
}
private class TypeHistoryDeltaListener implements IElementChangedListener {
@@ -81,7 +80,7 @@
* Computes whether the history needs a consistency check or not.
*
* @param delta
- * the Java element delta
+ * the Java element delta
*
* @return <code>true</code> if consistency must be checked
* <code>false</code> otherwise.
diff --git a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/corext/documentation/SingleCharReader.java b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/corext/documentation/SingleCharReader.java
index 836e5dc..d6bcb1c 100644
--- a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/corext/documentation/SingleCharReader.java
+++ b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/corext/documentation/SingleCharReader.java
@@ -1,15 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
*
-
*******************************************************************************/
package org.eclipse.dltk.corext.documentation;
-
import java.io.IOException;
import java.io.Reader;
@@ -20,22 +18,21 @@
@Override
public int read(char cbuf[], int off, int len) throws IOException {
- int end= off + len;
- for (int i= off; i < end; i++) {
- int ch= read();
+ int end = off + len;
+ for (int i = off; i < end; i++) {
+ int ch = read();
if (ch == -1) {
if (i == off) {
return -1;
- } else {
- return i - off;
}
+ return i - off;
}
- cbuf[i]= (char)ch;
+ cbuf[i] = (char) ch;
}
return len;
}
- @Override
+ @Override
public boolean ready() throws IOException {
return true;
}
@@ -44,10 +41,10 @@
* Gets the content as a String
*/
public String getString() throws IOException {
- StringBuffer buf= new StringBuffer();
+ StringBuffer buf = new StringBuffer();
int ch;
- while ((ch= read()) != -1) {
- buf.append((char)ch);
+ while ((ch = read()) != -1) {
+ buf.append((char) ch);
}
return buf.toString();
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/buildpath/BuildpathModifier.java b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/buildpath/BuildpathModifier.java
index 750d153..bbee0e4 100644
--- a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/buildpath/BuildpathModifier.java
+++ b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/buildpath/BuildpathModifier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -75,7 +75,7 @@
* <code>IBuildpathEntry</code>, but <code>BPListElement</code>
*
* @param newEntries
- * list of <code>BPListElement</code>
+ * list of <code>BPListElement</code>
*/
public void buildpathEntryChanged(List newEntries);
}
@@ -94,11 +94,11 @@
* Create a linked source folder.
*
* @param query
- * a query to create a linked source folder
+ * a query to create a linked source folder
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return a list containing a <code>IProjectFragment</code> representing
* the linked source folder
* @throws CoreException
@@ -128,15 +128,15 @@
* <code>FolderCreationQuery.getCreatedFolder()</code>.
*
* @param folderQuery
- * query to create the new folder
+ * query to create the new folder
* @param outputQuery
- * query to get information about whether the project should be
- * removed as source folder and update build folder to
- * <code>outputLocation</code>
+ * query to get information about whether the project
+ * should be removed as source folder and update
+ * build folder to <code>outputLocation</code>
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return a list containing the created object (either of type
* <code>IResource</code> of <code>IModelElement</code>, or an empty
* list if no folder was created (e.g. the operation was cancelled).
@@ -158,12 +158,11 @@
if (root.size() == 0)
folder.delete(false, null);
return root;
- } else {
- List entries = getExistingEntries(project);
- exclude(folder.getFullPath(), entries, new ArrayList(),
- project, monitor);
- updateBuildpath(entries, project, null);
}
+ List entries = getExistingEntries(project);
+ exclude(folder.getFullPath(), entries, new ArrayList(), project,
+ monitor);
+ updateBuildpath(entries, project, null);
return folderList;
}
}
@@ -174,17 +173,17 @@
* Add a list of elements to the build path.
*
* @param elements
- * a list of elements to be added to the build path. An element
- * must either be of type <code>IFolder</code>,
- * <code>IModelElement</code> or <code>IFile</code> (only allowed
- * if the file is a .zip file!).
+ * a list of elements to be added to the build path. An
+ * element must either be of type <code>IFolder</code>,
+ * <code>IModelElement</code> or <code>IFile</code>
+ * (only allowed if the file is a .zip file!).
* @param project
- * the script project
+ * the script project
* @param query
- * for information about whether the project should be removed as
- * source folder and update build folder
+ * for information about whether the project should be
+ * removed as source folder and update build folder
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return returns a list of elements of type <code>IProjectFragment</code>
* or <code>IScriptProject</code> that have been added to the build
* path or an empty list if the operation was aborted
@@ -252,12 +251,11 @@
}
return result;
- } else {
- StatusInfo rootStatus = new StatusInfo();
- rootStatus.setError(
- NewWizardMessages.BuildpathModifier_Error_NoNatures);
- throw new CoreException(rootStatus);
}
+ StatusInfo rootStatus = new StatusInfo();
+ rootStatus.setError(
+ NewWizardMessages.BuildpathModifier_Error_NoNatures);
+ throw new CoreException(rootStatus);
} finally {
monitor.done();
}
@@ -268,12 +266,12 @@
* query to find out which entries need to be added.
*
* @param query
- * the query to get the information which entries need to be
- * added
+ * the query to get the information which entries need to
+ * be added
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return a list of <code>IProjectFragment</code>s representing the added
* archives or an empty list if no element was added.
* @throws CoreException
@@ -330,12 +328,12 @@
* which entries need to be added.
*
* @param query
- * the query to get the information which entries need to be
- * added
+ * the query to get the information which entries need to
+ * be added
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return a list of <code>BuildpathContainer</code>s representing the added
* archives or an empty list if no element was added.
* @throws CoreException
@@ -426,16 +424,18 @@
* Remove a list of elements to the build path.
*
* @param query
- * query to remove unused linked folders from the project
+ * query to remove unused linked folders from the
+ * project
* @param elements
- * a list of elements to be removed from the build path. An
- * element must either be of type <code>IScriptProject</code>,
- * <code>IProjectFragment</code> or
- * <code>BuildPathContainer</code>
+ * a list of elements to be removed from the build path.
+ * An element must either be of type
+ * <code>IScriptProject</code>,
+ * <code>IProjectFragment</code> or
+ * <code>BuildPathContainer</code>
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return returns a list of elements of type <code>IFile</code> (in case of
* removed archives) or <code>IFolder</code> that have been removed
* from the build path
@@ -538,12 +538,13 @@
* parent fragment is allowed.
*
* @param elements
- * a list of elements to be included. The elements must be either
- * of type <code>IResource</code> or <code>IModelElement</code>.
+ * a list of elements to be included. The elements must
+ * be either of type <code>IResource</code> or
+ * <code>IModelElement</code>.
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return a list of <code>IModelElement</code>s corresponding to the
* included ones.
* @throws ModelException
@@ -599,11 +600,11 @@
* parent fragment is allowed.
*
* @param scriptElements
- * list of script elements to be excluded
+ * list of script elements to be excluded
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return list of objects representing the excluded elements
* @throws ModelException
*/
@@ -649,11 +650,12 @@
* parent fragment is allowed.
*
* @param scriptElements
- * a list of <code>IModelElements</code> to be unincluded
+ * a list of <code>IModelElements</code> to be
+ * unincluded
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return a list of elements representing unexcluded elements
* @throws ModelException
*
@@ -699,11 +701,11 @@
* parent fragment is allowed.
*
* @param elements
- * list of <code>IResource</code>s to be unexcluded
+ * list of <code>IResource</code>s to be unexcluded
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return an object representing the unexcluded element
* @throws ModelException
*
@@ -745,13 +747,13 @@
* passed <code>IInclusionExclusionQuery</code>.
*
* @param element
- * the script element to edit the filters on. Must be either of
- * type <code>IScriptProject</code> or
- * <code>IProjectFragment</code>.
+ * the script element to edit the filters on. Must be
+ * either of type <code>IScriptProject</code> or
+ * <code>IProjectFragment</code>.
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return returns the edited script element or <code>null</code> if the
* operation was cancelled
* @throws ModelException
@@ -800,9 +802,9 @@
* given attribute is reset to the default output location.</li>
*
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return a list of elements representing the elements on which 'reset' was
* called. They can either be of type <code>BPListElement</code>,
* <code>IScriptProject</code> or <code>IProjectFragment</code>
@@ -852,7 +854,7 @@
* a list of <code>BPListElement</code>s.
*
* @param project
- * the script project to get it's build path entries from
+ * the script project to get it's build path entries from
* @return a list of <code>BPListElement</code>s corresponding to the build
* path entries of the project
* @throws ModelException
@@ -875,10 +877,10 @@
* <code>BPListElement</code> and returned.
*
* @param elements
- * a list of <code>BPListElements</code>
+ * a list of <code>BPListElements</code>
* @param root
- * the root to find the <code>BuildpathEntry</code> for
- * represented by a <code>BPListElement</code>
+ * the root to find the <code>BuildpathEntry</code> for
+ * represented by a <code>BPListElement</code>
* @return the <code>BPListElement</code> found in the list (matching by
* using the path) or the roots own <code>IBuildpathEntry</code>
* converted to a <code>BPListElement</code>.
@@ -905,7 +907,7 @@
* no fragment root could be created.
*
* @param resource
- * the resource to be converted
+ * the resource to be converted
* @return the <code>resource<code> as
* <code>IScriptFolder</code>,or <code>null</code> if failed to convert
*/
@@ -921,11 +923,11 @@
* with the resource's parent.
*
* @param resource
- * the resource to get the fragment root from
+ * the resource to get the fragment root from
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return resolved fragment root
* @throws ModelException
*/
@@ -963,9 +965,9 @@
* build path entries on the project
*
* @param path
- * the path to find a build path entry for
+ * the path to find a build path entry for
* @param project
- * the script project
+ * the script project
* @return the <code>IBuildpathEntry</code> corresponding to the
* <code>path</code> or <code>null</code> if there is no such entry
* @throws ModelException
@@ -987,7 +989,7 @@
* folder or not
*
* @param attrib
- * the attribute to be checked
+ * the attribute to be checked
* @return <code>true</code> if is the default output folder,
* <code>false</code> otherwise.
*/
@@ -1001,11 +1003,11 @@
* inclusion filter of it's parent source folder.
*
* @param selection
- * the current script element
+ * the current script element
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return <code>true</code> if the current selection is included,
* <code>false</code> otherwise.
* @throws ModelException
@@ -1038,9 +1040,9 @@
* Find out whether the <code>IResource</code> excluded or not.
*
* @param resource
- * the resource to be checked
+ * the resource to be checked
* @param project
- * the script project
+ * the script project
* @return <code>true</code> if the resource is excluded, <code>
* false</code> otherwise
* @throws ModelException
@@ -1061,9 +1063,10 @@
* Find out whether one of the <code>IResource</code>'s parents is excluded.
*
* @param resource
- * check the resources parents whether they are excluded or not
+ * check the resources parents whether they are excluded
+ * or not
* @param project
- * the script project
+ * the script project
* @return <code>true</code> if there is an excluded parent,
* <code>false</code> otherwise
* @throws ModelException
@@ -1126,7 +1129,7 @@
* Check whether the <code>IScriptProject</code> is a source folder
*
* @param project
- * the project to test
+ * the project to test
* @return <code>true</code> if <code>project</code> is a source folder
* <code>false</code> otherwise.
*/
@@ -1141,7 +1144,7 @@
* default fragment.
*
* @param fragment
- * the package fragment to be checked
+ * the package fragment to be checked
* @return <code>true</code> if is the default package fragment,
* <code>false</code> otherwise.
*/
@@ -1184,7 +1187,7 @@
* both set (that means they are not empty).
*
* @param root
- * the fragment root to be inspected
+ * the fragment root to be inspected
* @return <code>true</code> inclusion or exclusion filter set,
* <code>false</code> otherwise.
*/
@@ -1206,11 +1209,11 @@
* Add a resource to the build path.
*
* @param resource
- * the resource to be added to the build path
+ * the resource to be added to the build path
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return returns the new element of type <code>IProjectFragment</code>
* that has been added to the build path
* @throws CoreException
@@ -1241,9 +1244,9 @@
* Check whether the provided file is an archive (.zip).
*
* @param file
- * the file to be checked
+ * the file to be checked
* @param project
- * the script project
+ * the script project
* @return <code>true</code> if the file is an archive, <code>false</code>
* otherwise
* @throws ModelException
@@ -1262,11 +1265,11 @@
* Add a script element to the build path.
*
* @param scriptElement
- * element to be added to the build path
+ * element to be added to the build path
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return returns the new element of type <code>IProjectFragment</code>
* that has been added to the build path
* @throws CoreException
@@ -1295,12 +1298,13 @@
* Remove the script project from the build path
*
* @param project
- * the project to be removed
+ * the project to be removed
* @param existingEntries
- * a list of existing <code>BPListElement</code>. This list will
- * be traversed and the entry for the project will be removed.
+ * a list of existing <code>BPListElement</code>.
+ * This list will be traversed and the entry for
+ * the project will be removed.
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return returns the script project
* @throws CoreException
*/
@@ -1318,16 +1322,17 @@
* Remove a given <code>IProjectFragment</code> from the build path.
*
* @param root
- * the <code>IProjectFragment</code> to be removed from the build
- * path
+ * the <code>IProjectFragment</code> to be
+ * removed from the build path
* @param existingEntries
- * a list of <code>BPListElements</code> representing the build
- * path entries of the project. The entry for the root will be
- * looked up and removed from the list.
+ * a list of <code>BPListElements</code>
+ * representing the build path entries of the
+ * project. The entry for the root will be looked
+ * up and removed from the list.
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return returns the <code>IResource</code> that has been removed from the
* build path; is of type <code>IFile</code> if the root was an
* archive, otherwise <code>IFolder</code> or <code>null<code> for
@@ -1358,12 +1363,13 @@
* <code>existingEntries</code>
*
* @param path
- * the path to remove
+ * the path to remove
* @param project
- * the script project
+ * the script project
* @param existingEntries
- * a list of <code>BPListElement</code> representing the build
- * path entries of the project.
+ * a list of <code>BPListElement</code>
+ * representing the build path entries of the
+ * project.
* @return returns a <code>List</code> of <code>BPListElement</code> of
* modified elements, not null.
*/
@@ -1428,14 +1434,14 @@
* parent fragment is allowed.
*
* @param resource
- * the element to be included
+ * the element to be included
* @param entry
- * the <code>BPListElement</code> representing the
- * <code>IBuildpathEntry</code> of the resource's root
+ * the <code>BPListElement</code> representing the
+ * <code>IBuildpathEntry</code> of the resource's root
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
*
* @throws ModelException
*
@@ -1477,15 +1483,15 @@
* path.
*
* @param name
- * the name of the element to be excluded
+ * the name of the element to be excluded
* @param fullPath
- * the absolute path of the element
+ * the absolute path of the element
* @param entry
- * the build path entry to be modified
+ * the build path entry to be modified
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return a <code>IResource</code> corresponding to the excluded element
* @throws ModelException
*/
@@ -1533,15 +1539,15 @@
* parent fragment is allowed.
*
* @param path
- * absolute path of an object to be excluded
+ * absolute path of an object to be excluded
* @param existingEntries
- * a list of existing build path entries
+ * a list of existing build path entries
* @param newEntries
- * a list of new build path entries
+ * a list of new build path entries
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
*/
public static void exclude(IPath path, List existingEntries,
List newEntries, IScriptProject project, IProgressMonitor monitor)
@@ -1585,14 +1591,15 @@
* parent fragment is allowed.
*
* @param scriptElement
- * the script element to be excluded
+ * the script element to be excluded
* @param entry
- * the <code>BPListElement</code> representing the
- * <code>IBuildpathEntry</code> of the script element's root.
+ * the <code>BPListElement</code> representing the
+ * <code>IBuildpathEntry</code> of the script
+ * element's root.
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
*
* @return the resulting <code>IResource<code>
* @throws ModelException
@@ -1621,14 +1628,14 @@
* parent fragment is allowed.
*
* @param scriptElement
- * the script element to be unincluded
+ * the script element to be unincluded
* @param entry
- * the <code>BPListElement</code> representing the
- * <code>IBuildpathEntry</code> of the root.
+ * the <code>BPListElement</code> representing the
+ * <code>IBuildpathEntry</code> of the root.
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @throws ModelException
*
* @see #include(List, IScriptProject, IProgressMonitor)
@@ -1664,14 +1671,14 @@
* parent fragment is allowed.
*
* @param resource
- * the resource to be unexcluded
+ * the resource to be unexcluded
* @param entry
- * the <code>BPListElement</code> representing the
- * <code>IBuildpathEntry</code> of the resource's root.
+ * the <code>BPListElement</code> representing the
+ * <code>IBuildpathEntry</code> of the resource's root.
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @throws ModelException
*
* @see #exclude(List, IScriptProject, IProgressMonitor)
@@ -1702,13 +1709,14 @@
* <code>IModelElement</code>
*
* @param element
- * element to reset it's filters
+ * element to reset it's filters
* @param entry
- * the <code>BPListElement</code> to reset its filters for
+ * the <code>BPListElement</code> to reset its filters
+ * for
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @throws ModelException
*/
private void resetFilters(IModelElement element, BPListElement entry,
@@ -1740,10 +1748,10 @@
* <code>BPListElement</code> is returned.
*
* @param elements
- * a list of <code>BPListElements</code>
+ * a list of <code>BPListElements</code>
* @param cpElement
- * the <code>BPListElement</code> to find the corresponding entry
- * in the list
+ * the <code>BPListElement</code> to find the
+ * corresponding entry in the list
* @return the <code>BPListElement</code> found in the list (matching by
* using the path) or the second <code>BPListElement</code>
* parameter itself if there is no match.
@@ -1764,9 +1772,9 @@
* For a given path, find the corresponding element in the list.
*
* @param path
- * the path to found an entry for
+ * the path to found an entry for
* @param elements
- * a list of <code>BPListElement</code>s
+ * a list of <code>BPListElement</code>s
* @return the mathed <code>BPListElement</code> or <code>null</code> if no
* match could be found
*/
@@ -1788,14 +1796,15 @@
* excluding an object.
*
* @param newEntries
- * a list of <code>BPListElements</code> that should be used as
- * build path entries for the project.
+ * a list of <code>BPListElements</code> that should
+ * be used as build path entries for the project.
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @throws ModelException
- * in case that validation for the new entries fails
+ * in case that validation for the new entries
+ * fails
*/
private void updateBuildpath(List newEntries, IScriptProject project,
IProgressMonitor monitor) throws ModelException {
@@ -1841,12 +1850,13 @@
* in the project and return a list with corresponding elements.
*
* @param entries
- * a list of entries to find an appropriate representation for.
- * The list can contain elements of two types:
- * <li><code>IResource</code></li>
- * <li><code>IModelElement</code></li>
+ * a list of entries to find an appropriate
+ * representation for. The list can contain elements of
+ * two types:
+ * <li><code>IResource</code></li>
+ * <li><code>IModelElement</code></li>
* @param project
- * the script project
+ * the script project
* @return a list of elements corresponding to the passed entries.
*/
public static List getCorrespondingElements(List entries,
@@ -1877,9 +1887,9 @@
* either element of type <code>IFile</code> or <code>IFolder</code>.
*
* @param path
- * an absolute path to a resource
+ * an absolute path to a resource
* @param project
- * the script project
+ * the script project
* @return the resource matching to the path. Can be either an
* <code>IFile</code> or an <code>IFolder</code>.
*/
@@ -1891,11 +1901,11 @@
* Find out whether the provided path equals to one in the array.
*
* @param path
- * path to find an equivalent for
+ * path to find an equivalent for
* @param paths
- * set of paths to compare with
+ * set of paths to compare with
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return <code>true</code> if there is an occurrence, <code>
* false</code> otherwise
*/
@@ -1928,7 +1938,7 @@
* XXX this method does nothing, use {@link #completeName(IPath, String)}
*
* @param name
- * append '/' at the end if necessary
+ * append '/' at the end if necessary
* @return modified string
*/
@Deprecated
@@ -1951,9 +1961,10 @@
* {@link #completeName(IPath, String)}
*
* @param project
- * - the project containing the resource
+ * - the project containing the resource
* @param name
- * - name of the resource append '/' at the end if necessary
+ * - name of the resource append '/' at the end if
+ * necessary
* @return modified string
*/
@Deprecated
@@ -1973,9 +1984,10 @@
* Add a '/' at the end of the name if it maps to a folder.
*
* @param fullPath
- * - the project containing the resource
+ * - the project containing the resource
* @param name
- * - name of the resource append '/' at the end if necessary
+ * - name of the resource append '/' at the end if
+ * necessary
* @return modified string
*/
private static String completeName(IPath fullPath, String name) {
@@ -1998,11 +2010,11 @@
* Only the first occurrence will be removed.
*
* @param path
- * path to be removed
+ * path to be removed
* @param paths
- * array of path to apply the removal on
+ * array of path to apply the removal on
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return array which does not contain <code>path</code>
*/
private static IPath[] remove(IPath path, IPath[] paths,
@@ -2040,11 +2052,11 @@
* returned if they are also on the project's build path.
*
* @param path
- * absolute path
+ * absolute path
* @param project
- * the script project
+ * the script project
* @param monitor
- * progress monitor, can be <code>null</code>
+ * progress monitor, can be <code>null</code>
* @return an array of paths which belong to subfolders of <code>path</code>
* and which are on the build path
* @throws ModelException
@@ -2069,9 +2081,9 @@
* <code>rootPath<code>'s number of segments removed
*
* @param path
- * path to remove segments
+ * path to remove segments
* @param rootPath
- * provides the number of segments to be removed
+ * provides the number of segments to be removed
* @return a string corresponding to the mentioned action
*/
private static String getName(IPath path, IPath rootPath) {
@@ -2084,15 +2096,17 @@
* (therefore, there is no return list for this method).
*
* @param existingEntries
- * a list of existing buildpath entries
+ * a list of existing buildpath entries
* @param newEntries
- * a list of entries to be added to the existing ones
+ * a list of entries to be added to the existing
+ * ones
* @param project
- * the script project
+ * the script project
* @param monitor
- * a progress monitor, can be <code>null</code>
+ * a progress monitor, can be <code>null</code>
* @throws CoreException
- * in case that validation on one of the new entries fails
+ * in case that validation on one of the new
+ * entries fails
*/
public static void setNewEntry(List existingEntries, List newEntries,
IScriptProject project, IProgressMonitor monitor)
@@ -2116,7 +2130,7 @@
* <code>IBuildpathEntry</code>.
*
* @param list
- * the list to be converted
+ * the list to be converted
* @return an array containing build path entries corresponding to the list
*/
private static IBuildpathEntry[] convert(List list) {
@@ -2137,14 +2151,15 @@
* entries.
*
* @param entry
- * the entry to be validated and added to the list of existing
- * entries.
+ * the entry to be validated and added to the
+ * list of existing entries.
* @param existingEntries
- * a list of existing entries representing the build path
+ * a list of existing entries representing the
+ * build path
* @param project
- * the script project
+ * the script project
* @throws CoreException
- * in case that validation fails
+ * in case that validation fails
*/
private static void validateAndAddEntry(BPListElement entry,
List existingEntries, IScriptProject project) throws CoreException {
@@ -2275,9 +2290,10 @@
* <code>IBuildpathEntry.BPE_SOURCE</code>
*
* @param entry
- * the buildpath entry to be compared with the provided type
+ * the buildpath entry to be compared with the provided
+ * type
* @param kind
- * the kind to be checked
+ * the kind to be checked
* @return <code>true</code> if kind equals
* <code>IBuildpathEntry.BPE_SOURCE</code>, <code>false</code>
* otherwise
diff --git a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/CallSearchResultCollector.java b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/CallSearchResultCollector.java
index 7a1f373..520f401 100644
--- a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/CallSearchResultCollector.java
+++ b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/CallSearchResultCollector.java
@@ -1,12 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
*
-
- * (report 36180: Callers/Callees view)
*******************************************************************************/
package org.eclipse.dltk.internal.corext.callhierarchy;
@@ -17,66 +15,69 @@
import org.eclipse.dltk.core.IModelElement;
import org.eclipse.dltk.core.IType;
-
public class CallSearchResultCollector {
- private Map fCalledMembers;
+ private Map fCalledMembers;
- public CallSearchResultCollector() {
- this.fCalledMembers = createCalledMethodsData();
- }
+ public CallSearchResultCollector() {
+ this.fCalledMembers = createCalledMethodsData();
+ }
- public Map getCallers() {
- return fCalledMembers;
- }
+ public Map getCallers() {
+ return fCalledMembers;
+ }
- protected void addMember(IModelElement member, IModelElement calledMember, int start, int end) {
- addMember(member, calledMember, start, end, CallLocation.UNKNOWN_LINE_NUMBER);
- }
+ protected void addMember(IModelElement member, IModelElement calledMember,
+ int start, int end) {
+ addMember(member, calledMember, start, end,
+ CallLocation.UNKNOWN_LINE_NUMBER);
+ }
- protected void addMember(IModelElement member, IModelElement calledMember, int start, int end, int lineNumber) {
- if ((member != null) && (calledMember != null)) {
- if (!isIgnored(calledMember)) {
- MethodCall methodCall = (MethodCall) fCalledMembers.get(calledMember.getHandleIdentifier());
+ protected void addMember(IModelElement member, IModelElement calledMember,
+ int start, int end, int lineNumber) {
+ if ((member != null) && (calledMember != null)) {
+ if (!isIgnored(calledMember)) {
+ MethodCall methodCall = (MethodCall) fCalledMembers
+ .get(calledMember.getHandleIdentifier());
- if (methodCall == null) {
- methodCall = new MethodCall(calledMember);
- fCalledMembers.put(calledMember.getHandleIdentifier(), methodCall);
- }
+ if (methodCall == null) {
+ methodCall = new MethodCall(calledMember);
+ fCalledMembers.put(calledMember.getHandleIdentifier(),
+ methodCall);
+ }
- methodCall.addCallLocation(new CallLocation(member, calledMember, start,
- end, lineNumber));
- }
- }
- }
+ methodCall.addCallLocation(new CallLocation(member,
+ calledMember, start, end, lineNumber));
+ }
+ }
+ }
- protected Map createCalledMethodsData() {
- return new HashMap();
- }
+ protected Map createCalledMethodsData() {
+ return new HashMap();
+ }
- /**
- * Method isIgnored.
- * @param enclosingElement
- * @return boolean
- */
- private boolean isIgnored(IModelElement enclosingElement) {
- IType type = getTypeOfElement(enclosingElement);
- if( type != null ) {
- String fullyQualifiedName = type.getFullyQualifiedName();
+ /**
+ * Method isIgnored.
+ *
+ * @param enclosingElement
+ * @return boolean
+ */
+ private boolean isIgnored(IModelElement enclosingElement) {
+ IType type = getTypeOfElement(enclosingElement);
+ if (type != null) {
+ String fullyQualifiedName = type.getFullyQualifiedName();
- return CallHierarchy.getDefault().isIgnored(fullyQualifiedName);
- }
- else {
- return false;
- }
- }
+ return CallHierarchy.getDefault().isIgnored(fullyQualifiedName);
+ }
+ return false;
+ }
- private IType getTypeOfElement(IModelElement element) {
- if (element.getElementType() == IModelElement.TYPE) {
- return (IType) element;
- }
- if( element instanceof IMember ) {
- return ((IMember)element).getDeclaringType();
- }
- return null;
- }
+ private IType getTypeOfElement(IModelElement element) {
+ if (element.getElementType() == IModelElement.TYPE) {
+ return (IType) element;
+ }
+ if (element instanceof IMember) {
+ return ((IMember) element).getDeclaringType();
+ }
+ return null;
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/MethodCall.java b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/MethodCall.java
index f6b8edd..99b4d54 100644
--- a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/MethodCall.java
+++ b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/MethodCall.java
@@ -1,12 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
*
-
- * (report 36180: Callers/Callees view)
*******************************************************************************/
package org.eclipse.dltk.internal.corext.callhierarchy;
@@ -16,59 +14,57 @@
import org.eclipse.dltk.core.IModelElement;
-
public class MethodCall {
- private IModelElement fMember;
- private List fCallLocations;
+ private IModelElement fMember;
+ private List fCallLocations;
- /**
- * @param enclosingElement
- */
- public MethodCall(IModelElement enclosingElement) {
- this.fMember = enclosingElement;
- }
+ /**
+ * @param enclosingElement
+ */
+ public MethodCall(IModelElement enclosingElement) {
+ this.fMember = enclosingElement;
+ }
- /**
- *
- */
- public Collection getCallLocations() {
- return fCallLocations;
- }
+ /**
+ *
+ */
+ public Collection getCallLocations() {
+ return fCallLocations;
+ }
- public CallLocation getFirstCallLocation() {
- if ((fCallLocations != null) && !fCallLocations.isEmpty()) {
- return (CallLocation) fCallLocations.get(0);
- } else {
- return null;
- }
- }
+ public CallLocation getFirstCallLocation() {
+ if ((fCallLocations != null) && !fCallLocations.isEmpty()) {
+ return (CallLocation) fCallLocations.get(0);
+ }
+ return null;
+ }
- public boolean hasCallLocations() {
- return fCallLocations != null && fCallLocations.size() > 0;
- }
-
- /**
- * @return Object
- */
- public Object getKey() {
- return getMember().getHandleIdentifier();
- }
+ public boolean hasCallLocations() {
+ return fCallLocations != null && fCallLocations.size() > 0;
+ }
- /**
- *
- */
- public IModelElement getMember() {
- return fMember;
- }
+ /**
+ * @return Object
+ */
+ public Object getKey() {
+ return getMember().getHandleIdentifier();
+ }
- /**
- * @param location
- */
- public void addCallLocation(CallLocation location) {
- if (fCallLocations == null) {
- fCallLocations = new ArrayList();
- }
+ /**
+ *
+ */
+ public IModelElement getMember() {
+ return fMember;
+ }
- fCallLocations.add(location);
- }
+ /**
+ * @param location
+ */
+ public void addCallLocation(CallLocation location) {
+ if (fCallLocations == null) {
+ fCallLocations = new ArrayList();
+ }
+
+ fCallLocations.add(location);
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/MethodWrapper.java b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/MethodWrapper.java
index b342740..0e8c435 100644
--- a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/MethodWrapper.java
+++ b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/callhierarchy/MethodWrapper.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
*
- * (report 36180: Callers/Callees view)
*******************************************************************************/
package org.eclipse.dltk.internal.corext.callhierarchy;
@@ -21,300 +20,307 @@
import org.eclipse.dltk.internal.ui.callhierarchy.MethodWrapperWorkbenchAdapter;
import org.eclipse.ui.model.IWorkbenchAdapter;
-
/**
* This class represents the general parts of a method call (either to or from a
* method).
*
*/
public abstract class MethodWrapper extends PlatformObject {
- private Map fElements = null;
+ private Map fElements = null;
- /*
- * A cache of previously found methods. This cache should be searched
- * before adding a "new" method object reference to the list of elements.
- * This way previously found methods won't be searched again.
- */
- private Map fMethodCache;
- private MethodCall fMethodCall;
- private MethodWrapper fParent;
- private int fLevel;
+ /*
+ * A cache of previously found methods. This cache should be searched before
+ * adding a "new" method object reference to the list of elements. This way
+ * previously found methods won't be searched again.
+ */
+ private Map fMethodCache;
+ private MethodCall fMethodCall;
+ private MethodWrapper fParent;
+ private int fLevel;
- /**
- * Constructor CallerElement.
- */
- public MethodWrapper(MethodWrapper parent, MethodCall methodCall) {
- Assert.isNotNull(methodCall);
+ /**
+ * Constructor CallerElement.
+ */
+ public MethodWrapper(MethodWrapper parent, MethodCall methodCall) {
+ Assert.isNotNull(methodCall);
- if (parent == null) {
- setMethodCache(new HashMap());
- fLevel = 1;
- } else {
- setMethodCache(parent.getMethodCache());
- fLevel = parent.getLevel() + 1;
- }
+ if (parent == null) {
+ setMethodCache(new HashMap());
+ fLevel = 1;
+ } else {
+ setMethodCache(parent.getMethodCache());
+ fLevel = parent.getLevel() + 1;
+ }
- this.fMethodCall = methodCall;
- this.fParent = parent;
- }
+ this.fMethodCall = methodCall;
+ this.fParent = parent;
+ }
@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Class<T> adapter) {
if (adapter == IModelElement.class) {
return (T) getMember();
- } else if (adapter == IWorkbenchAdapter.class){
+ } else if (adapter == IWorkbenchAdapter.class) {
return (T) new MethodWrapperWorkbenchAdapter(this);
- } else {
- return null;
- }
+ } else {
+ return null;
+ }
}
- /**
- * @return the child caller elements of this element
- */
- public MethodWrapper[] getCalls(IProgressMonitor progressMonitor) {
- if (fElements == null) {
- doFindChildren(progressMonitor);
- }
+ /**
+ * @return the child caller elements of this element
+ */
+ public MethodWrapper[] getCalls(IProgressMonitor progressMonitor) {
+ if (fElements == null) {
+ doFindChildren(progressMonitor);
+ }
- MethodWrapper[] result = new MethodWrapper[fElements.size()];
- int i = 0;
+ MethodWrapper[] result = new MethodWrapper[fElements.size()];
+ int i = 0;
- for (Iterator iter = fElements.keySet().iterator(); iter.hasNext();) {
- MethodCall methodCall = getMethodCallFromMap(fElements, iter.next());
- result[i++] = createMethodWrapper(methodCall);
- }
+ for (Iterator iter = fElements.keySet().iterator(); iter.hasNext();) {
+ MethodCall methodCall = getMethodCallFromMap(fElements,
+ iter.next());
+ result[i++] = createMethodWrapper(methodCall);
+ }
- return result;
- }
+ return result;
+ }
- public int getLevel() {
- return fLevel;
- }
+ public int getLevel() {
+ return fLevel;
+ }
- public IModelElement getMember() {
- return getMethodCall().getMember();
- }
+ public IModelElement getMember() {
+ return getMethodCall().getMember();
+ }
- public MethodCall getMethodCall() {
- return fMethodCall;
- }
+ public MethodCall getMethodCall() {
+ return fMethodCall;
+ }
- public String getName() {
- if (getMethodCall() != null) {
- return getMethodCall().getMember().getElementName();
- } else {
- return ""; //$NON-NLS-1$
- }
- }
+ public String getName() {
+ if (getMethodCall() != null) {
+ return getMethodCall().getMember().getElementName();
+ }
+ return ""; //$NON-NLS-1$
+ }
- public MethodWrapper getParent() {
- return fParent;
- }
+ public MethodWrapper getParent() {
+ return fParent;
+ }
@Override
public boolean equals(Object oth) {
- if (this == oth) {
- return true;
- }
+ if (this == oth) {
+ return true;
+ }
- if (oth == null) {
- return false;
- }
-
- if (oth instanceof MethodWrapperWorkbenchAdapter) {
- //Note: A MethodWrapper is equal to a referring MethodWrapperWorkbenchAdapter and vice versa (bug 101677).
- oth= ((MethodWrapperWorkbenchAdapter) oth).getMethodWrapper();
- }
-
- if (oth.getClass() != getClass()) {
- return false;
- }
+ if (oth == null) {
+ return false;
+ }
- MethodWrapper other = (MethodWrapper) oth;
+ if (oth instanceof MethodWrapperWorkbenchAdapter) {
+ // Note: A MethodWrapper is equal to a referring
+ // MethodWrapperWorkbenchAdapter and vice versa (bug 101677).
+ oth = ((MethodWrapperWorkbenchAdapter) oth).getMethodWrapper();
+ }
- if (this.fParent == null) {
- if (other.fParent != null) {
- return false;
- }
- } else {
- if (!this.fParent.equals(other.fParent)) {
- return false;
- }
- }
+ if (oth.getClass() != getClass()) {
+ return false;
+ }
- if (this.getMethodCall() == null) {
- if (other.getMethodCall() != null) {
- return false;
- }
- } else {
- if (!this.getMethodCall().equals(other.getMethodCall())) {
- return false;
- }
- }
+ MethodWrapper other = (MethodWrapper) oth;
- return true;
- }
+ if (this.fParent == null) {
+ if (other.fParent != null) {
+ return false;
+ }
+ } else {
+ if (!this.fParent.equals(other.fParent)) {
+ return false;
+ }
+ }
+
+ if (this.getMethodCall() == null) {
+ if (other.getMethodCall() != null) {
+ return false;
+ }
+ } else {
+ if (!this.getMethodCall().equals(other.getMethodCall())) {
+ return false;
+ }
+ }
+
+ return true;
+ }
@Override
public int hashCode() {
- final int PRIME = 1000003;
- int result = 0;
+ final int PRIME = 1000003;
+ int result = 0;
- if (fParent != null) {
- result = (PRIME * result) + fParent.hashCode();
- }
+ if (fParent != null) {
+ result = (PRIME * result) + fParent.hashCode();
+ }
- if (getMethodCall() != null) {
- result = (PRIME * result) + getMethodCall().getMember().hashCode();
- }
+ if (getMethodCall() != null) {
+ result = (PRIME * result) + getMethodCall().getMember().hashCode();
+ }
- return result;
- }
+ return result;
+ }
- private void setMethodCache(Map methodCache) {
- fMethodCache = methodCache;
- }
+ private void setMethodCache(Map methodCache) {
+ fMethodCache = methodCache;
+ }
- protected abstract String getTaskName();
+ protected abstract String getTaskName();
- private void addCallToCache(MethodCall methodCall) {
- Map cachedCalls = lookupMethod(this.getMethodCall());
- cachedCalls.put(methodCall.getKey(), methodCall);
- }
+ private void addCallToCache(MethodCall methodCall) {
+ Map cachedCalls = lookupMethod(this.getMethodCall());
+ cachedCalls.put(methodCall.getKey(), methodCall);
+ }
- protected abstract MethodWrapper createMethodWrapper(MethodCall methodCall);
+ protected abstract MethodWrapper createMethodWrapper(MethodCall methodCall);
- private void doFindChildren(IProgressMonitor progressMonitor) {
- Map existingResults = lookupMethod(getMethodCall());
+ private void doFindChildren(IProgressMonitor progressMonitor) {
+ Map existingResults = lookupMethod(getMethodCall());
- if (existingResults != null) {
- fElements = new HashMap();
- fElements.putAll(existingResults);
- } else {
- initCalls();
+ if (existingResults != null) {
+ fElements = new HashMap();
+ fElements.putAll(existingResults);
+ } else {
+ initCalls();
- if (progressMonitor != null) {
- progressMonitor.beginTask(getTaskName(), 100);
- }
+ if (progressMonitor != null) {
+ progressMonitor.beginTask(getTaskName(), 100);
+ }
- try {
- performSearch(progressMonitor);
- } finally {
- if (progressMonitor != null) {
- progressMonitor.done();
- }
- }
+ try {
+ performSearch(progressMonitor);
+ } finally {
+ if (progressMonitor != null) {
+ progressMonitor.done();
+ }
+ }
- // ModalContext.run(getRunnableWithProgress(), true, getProgressMonitor(),
- // Display.getCurrent());
- }
- }
+ // ModalContext.run(getRunnableWithProgress(), true,
+ // getProgressMonitor(),
+ // Display.getCurrent());
+ }
+ }
- /**
- * Determines if the method represents a recursion call (i.e. whether the
- * method call is already in the cache.)
- *
- * @return True if the call is part of a recursion
- */
- public boolean isRecursive() {
- MethodWrapper current = getParent();
+ /**
+ * Determines if the method represents a recursion call (i.e. whether the
+ * method call is already in the cache.)
+ *
+ * @return True if the call is part of a recursion
+ */
+ public boolean isRecursive() {
+ MethodWrapper current = getParent();
- while (current != null) {
- if (getMember().getHandleIdentifier().equals(current.getMember()
- .getHandleIdentifier())) {
- return true;
- }
+ while (current != null) {
+ if (getMember().getHandleIdentifier()
+ .equals(current.getMember().getHandleIdentifier())) {
+ return true;
+ }
- current = current.getParent();
- }
+ current = current.getParent();
+ }
- return false;
- }
+ return false;
+ }
- /**
- * This method finds the children of the current IMethod (either callers or
- * callees, depending on the concrete subclass.
- * @return The result of the search for children
- */
- protected abstract Map findChildren(IProgressMonitor progressMonitor);
+ /**
+ * This method finds the children of the current IMethod (either callers or
+ * callees, depending on the concrete subclass.
+ *
+ * @return The result of the search for children
+ */
+ protected abstract Map findChildren(IProgressMonitor progressMonitor);
- private Map getMethodCache() {
- return fMethodCache;
- }
+ private Map getMethodCache() {
+ return fMethodCache;
+ }
- private void initCalls() {
- this.fElements = new HashMap();
+ private void initCalls() {
+ this.fElements = new HashMap();
- initCacheForMethod();
- }
+ initCacheForMethod();
+ }
- /**
- * Looks up a previously created search result in the "global" cache.
- * @return the List of previously found search results
- */
- private Map lookupMethod(MethodCall methodCall) {
- return (Map) getMethodCache().get(methodCall.getKey());
- }
+ /**
+ * Looks up a previously created search result in the "global" cache.
+ *
+ * @return the List of previously found search results
+ */
+ private Map lookupMethod(MethodCall methodCall) {
+ return (Map) getMethodCache().get(methodCall.getKey());
+ }
- private void performSearch(IProgressMonitor progressMonitor) {
- fElements = findChildren(progressMonitor);
+ private void performSearch(IProgressMonitor progressMonitor) {
+ fElements = findChildren(progressMonitor);
- for (Iterator iter = fElements.keySet().iterator(); iter.hasNext();) {
- checkCanceled(progressMonitor);
+ for (Iterator iter = fElements.keySet().iterator(); iter.hasNext();) {
+ checkCanceled(progressMonitor);
- MethodCall methodCall = getMethodCallFromMap(fElements, iter.next());
- addCallToCache(methodCall);
- }
- }
+ MethodCall methodCall = getMethodCallFromMap(fElements,
+ iter.next());
+ addCallToCache(methodCall);
+ }
+ }
- private MethodCall getMethodCallFromMap(Map elements, Object key) {
- return (MethodCall) elements.get(key);
- }
+ private MethodCall getMethodCallFromMap(Map elements, Object key) {
+ return (MethodCall) elements.get(key);
+ }
- private void initCacheForMethod() {
- Map cachedCalls = new HashMap();
- getMethodCache().put(this.getMethodCall().getKey(), cachedCalls);
- }
+ private void initCacheForMethod() {
+ Map cachedCalls = new HashMap();
+ getMethodCache().put(this.getMethodCall().getKey(), cachedCalls);
+ }
- /**
- * Checks with the progress monitor to see whether the creation of the type hierarchy
- * should be canceled. Should be regularly called
- * so that the user can cancel.
- *
- * @exception OperationCanceledException if cancelling the operation has been requested
- * @see IProgressMonitor#isCanceled
- */
- protected void checkCanceled(IProgressMonitor progressMonitor) {
- if (progressMonitor != null && progressMonitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- }
-
- /**
- * Allows a visitor to traverse the call hierarchy. The visiting is stopped when
- * a recursive node is reached.
- *
- * @param visitor
- */
- public void accept(CallHierarchyVisitor visitor, IProgressMonitor progressMonitor) {
- if (getParent() != null && getParent().isRecursive()) {
- return;
- }
- checkCanceled(progressMonitor);
-
- visitor.preVisit(this);
- if (visitor.visit(this)) {
- MethodWrapper[] methodWrappers= getCalls(progressMonitor);
- for (int i= 0; i < methodWrappers.length; i++) {
- methodWrappers[i].accept(visitor, progressMonitor);
- }
- }
- visitor.postVisit(this);
+ /**
+ * Checks with the progress monitor to see whether the creation of the type
+ * hierarchy should be canceled. Should be regularly called so that the user
+ * can cancel.
+ *
+ * @exception OperationCanceledException
+ * if cancelling the operation has
+ * been requested
+ * @see IProgressMonitor#isCanceled
+ */
+ protected void checkCanceled(IProgressMonitor progressMonitor) {
+ if (progressMonitor != null && progressMonitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+ }
- if (progressMonitor != null) {
- progressMonitor.worked(1);
- }
- }
+ /**
+ * Allows a visitor to traverse the call hierarchy. The visiting is stopped
+ * when a recursive node is reached.
+ *
+ * @param visitor
+ */
+ public void accept(CallHierarchyVisitor visitor,
+ IProgressMonitor progressMonitor) {
+ if (getParent() != null && getParent().isRecursive()) {
+ return;
+ }
+ checkCanceled(progressMonitor);
+
+ visitor.preVisit(this);
+ if (visitor.visit(this)) {
+ MethodWrapper[] methodWrappers = getCalls(progressMonitor);
+ for (int i = 0; i < methodWrappers.length; i++) {
+ methodWrappers[i].accept(visitor, progressMonitor);
+ }
+ }
+ visitor.postVisit(this);
+
+ if (progressMonitor != null) {
+ progressMonitor.worked(1);
+ }
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/util/Messages.java b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/util/Messages.java
index ab6cd75..9dbeb3d 100644
--- a/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/util/Messages.java
+++ b/core/plugins/org.eclipse.dltk.ui/src corext/org/eclipse/dltk/internal/corext/util/Messages.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 2018 IBM Corporation 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
*
-
*******************************************************************************/
package org.eclipse.dltk.internal.corext.util;
@@ -13,16 +12,12 @@
/**
* Helper class to format message strings.
- *
- *
+ *
+ *
*/
public class Messages {
- public static String format(String message, Object object) {
- return MessageFormat.format(message, new Object[] { object});
- }
-
- public static String format(String message, Object[] objects) {
+ public static String format(String message, Object... objects) {
return MessageFormat.format(message, objects);
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/ResourceLocator.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/ResourceLocator.java
index 7314a81..a3c8028 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/ResourceLocator.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/ResourceLocator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -12,38 +12,40 @@
import org.eclipse.dltk.core.IModelElement;
import org.eclipse.dltk.core.ModelException;
-
/**
- * This class locates different resources
- * which are related to an object
+ * This class locates different resources which are related to an object
*/
public class ResourceLocator implements IResourceLocator {
@Override
- public IResource getUnderlyingResource(Object element) throws ModelException {
- if (element instanceof IModelElement)
- return ((IModelElement) element).getUnderlyingResource();
- else
- return null;
- }
-
- @Override
- public IResource getCorrespondingResource(Object element) throws ModelException {
- if (element instanceof IModelElement)
- return ((IModelElement) element).getCorrespondingResource();
- else
- return null;
- }
-
- @Override
- public IResource getContainingResource(Object element) throws ModelException {
- IResource resource= null;
- if (element instanceof IResource)
- resource= (IResource) element;
+ public IResource getUnderlyingResource(Object element)
+ throws ModelException {
if (element instanceof IModelElement) {
- resource= ((IModelElement) element).getResource();
+ return ((IModelElement) element).getUnderlyingResource();
+ }
+ return null;
+ }
+
+ @Override
+ public IResource getCorrespondingResource(Object element)
+ throws ModelException {
+ if (element instanceof IModelElement) {
+ return ((IModelElement) element).getCorrespondingResource();
+ }
+ return null;
+ }
+
+ @Override
+ public IResource getContainingResource(Object element)
+ throws ModelException {
+ IResource resource = null;
+ if (element instanceof IResource)
+ resource = (IResource) element;
+ if (element instanceof IModelElement) {
+ resource = ((IModelElement) element).getResource();
if (resource == null)
- resource= ((IModelElement) element).getScriptProject().getProject();
+ resource = ((IModelElement) element).getScriptProject()
+ .getProject();
}
return resource;
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/StandardModelElementContentProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/StandardModelElementContentProvider.java
index 173ea9b..bee98dc 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/StandardModelElementContentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/StandardModelElementContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -107,8 +107,8 @@
* Creates a new <code>StandardJavaElementContentProvider</code>.
*
* @param provideMembers
- * if <code>true</code> members below compilation units and class
- * files are provided.
+ * if <code>true</code> members below compilation
+ * units and class files are provided.
*/
public StandardModelElementContentProvider(boolean provideMembers) {
fProvideMembers = provideMembers;
@@ -131,9 +131,9 @@
* asking a compilation unit or class file for its children.
*
* @param b
- * if <code>true</code> then members are provided. If
- * <code>false</code> compilation units and class files are the
- * leaves provided by this content provider.
+ * if <code>true</code> then members are provided. If
+ * <code>false</code> compilation units and class files are the
+ * leaves provided by this content provider.
*/
public void setProvideMembers(boolean b) {
fProvideMembers = b;
@@ -167,9 +167,8 @@
providers[i].provideModelChanges(element, elements, this);
}
return elements.toArray();
- } else {
- return children;
}
+ return children;
}
private String getToolkitID(Object element) {
@@ -302,12 +301,12 @@
* can override this method.
*
* @param root
- * The root to evaluate the children for.
+ * The root to evaluate the children for.
* @return The children of the root
* @exception JavaModelException
- * if the package fragment root does not exist or if an
- * exception occurs while accessing its corresponding
- * resource
+ * if the package fragment root does not
+ * exist or if an exception occurs while
+ * accessing its corresponding resource
*
*/
protected Object[] getProjectFragmentContent(IProjectFragment root)
@@ -345,12 +344,13 @@
* override this method.
*
* @param project
- * The Java project to evaluate the children for.
+ * The Java project to evaluate the children for.
* @return The children of the project. Typically these are package fragment
* roots but can also be other elements.
* @exception JavaModelException
- * if the Java project does not exist or if an exception
- * occurs while accessing its corresponding resource
+ * if the Java project does not exist or
+ * if an exception occurs while accessing
+ * its corresponding resource
*/
protected Object[] getProjectFragments(IScriptProject project)
throws ModelException {
@@ -393,11 +393,12 @@
* override this method.
*
* @param fragment
- * The fragment to evaluate the children for.
+ * The fragment to evaluate the children for.
* @return The children of the given package fragment.
* @exception JavaModelException
- * if the package fragment does not exist or if an exception
- * occurs while accessing its corresponding resource
+ * if the package fragment does not exist
+ * or if an exception occurs while
+ * accessing its corresponding resource
*
* @since 3.3
*/
@@ -416,10 +417,10 @@
* this method.
*
* @param folder
- * The folder to evaluate the children for.
+ * The folder to evaluate the children for.
* @return The children of the given package fragment.
* @exception CoreException
- * if the folder does not exist.
+ * if the folder does not exist.
*
*/
protected Object[] getFolderContent(IFolder folder) throws CoreException {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/ActionUtil.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/ActionUtil.java
index 7eaac02..2745e85 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/ActionUtil.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/ActionUtil.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
*
-
*******************************************************************************/
package org.eclipse.dltk.internal.ui.actions;
@@ -116,18 +115,15 @@
return false;
}
- public static boolean areProcessable(Shell shell, IModelElement[] elements) {
+ public static boolean areProcessable(Shell shell,
+ IModelElement[] elements) {
for (int i = 0; i < elements.length; i++) {
if (!isOnBuildPath(elements[i])) {
- MessageDialog
- .openInformation(
- shell,
- ActionMessages.ActionUtil_notOnBuildPath_title,
- Messages
- .format(
- ActionMessages.ActionUtil_notOnBuildPath_resource_message,
- new Object[] { elements[i]
- .getPath() }));
+ MessageDialog.openInformation(shell,
+ ActionMessages.ActionUtil_notOnBuildPath_title,
+ Messages.format(
+ ActionMessages.ActionUtil_notOnBuildPath_resource_message,
+ new Object[] { elements[i].getPath() }));
return false;
}
}
@@ -139,14 +135,14 @@
* processable and editable. If the editor edits the element, the validation
* is only performed once. If necessary, ask the user whether the file(s)
* should be edited.
- *
+ *
* @param editor
- * an editor, or <code>null</code> iff the action was not
- * executed from an editor
+ * an editor, or <code>null</code> iff the action was not
+ * executed from an editor
* @param shell
- * a shell to serve as parent for a dialog
+ * a shell to serve as parent for a dialog
* @param element
- * the element to check, cannot be <code>null</code>
+ * the element to check, cannot be <code>null</code>
* @return <code>true</code> if the element can be edited,
* <code>false</code> otherwise
*/
@@ -154,12 +150,11 @@
IModelElement element) {
if (editor != null) {
IModelElement input = SelectionConverter.getInput(editor);
- if (input != null
- && input.equals(element
- .getAncestor(IModelElement.SOURCE_MODULE)))
+ if (input != null && input
+ .equals(element.getAncestor(IModelElement.SOURCE_MODULE))) {
return isEditable(editor);
- else
- return isEditable(editor) && isEditable(shell, element);
+ }
+ return isEditable(editor) && isEditable(shell, element);
}
return isEditable(shell, element);
}
@@ -191,16 +186,12 @@
return true;
MessageDialogWithToggle toggleDialog = MessageDialogWithToggle
- .openYesNoQuestion(
- shell,
+ .openYesNoQuestion(shell,
ActionMessages.ActionUtil_warning_derived_title,
- Messages
- .format(
- ActionMessages.ActionUtil_warning_derived_message,
- BasicElementLabels
- .getPathLabel(resource
- .getFullPath(),
- false)),
+ Messages.format(
+ ActionMessages.ActionUtil_warning_derived_message,
+ BasicElementLabels.getPathLabel(
+ resource.getFullPath(), false)),
ActionMessages.ActionUtil_warning_derived_dontShowAgain,
false, null, null);
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/QuickMenuAction.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/QuickMenuAction.java
index bbdafa9..d05cda4 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/QuickMenuAction.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/QuickMenuAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -43,7 +43,8 @@
* Creates a new quick menu action with the given command id.
*
* @param commandId
- * the command id of the short cut used to open the sub menu
+ * the command id of the short cut used to open the sub
+ * menu
*/
public QuickMenuAction(String commandId) {
setActionDefinitionId(commandId);
@@ -79,7 +80,7 @@
* Hook to fill a menu manager with the items of the sub menu.
*
* @param menu
- * the sub menu to fill
+ * the sub menu to fill
*/
protected abstract void fillMenu(IMenuManager menu);
@@ -87,7 +88,7 @@
* Adds the shortcut to the given menu text and returns it.
*
* @param menuText
- * the menu text
+ * the menu text
* @return the menu text with the shortcut
* @since 3.1
*/
@@ -152,7 +153,7 @@
* widget.
*
* @param text
- * the styled text widget that has the focus
+ * the styled text widget that has the focus
*
* @return a widget relative position of the menu to pop up or
* <code>null</code> if now position inside the widget can be
@@ -171,7 +172,7 @@
* Hook to compute the menu location if the focus widget is a tree widget.
*
* @param tree
- * the tree widget that has the focus
+ * the tree widget that has the focus
*
* @return a widget relative position of the menu to pop up or
* <code>null</code> if now position inside the widget can be
@@ -192,9 +193,8 @@
bounds.x + getAvarageCharWith(tree)
* CHAR_INDENT),
bounds.y + bounds.height);
- } else {
- return null;
}
+ return null;
default:
Rectangle[] rectangles = new Rectangle[items.length];
for (int i = 0; i < rectangles.length; i++) {
@@ -214,7 +214,7 @@
* Hook to compute the menu location if the focus widget is a table widget.
*
* @param table
- * the table widget that has the focus
+ * the table widget that has the focus
*
* @return a widget relative position of the menu to pop up or
* <code>null</code> if now position inside the widget can be
@@ -238,9 +238,8 @@
+ getAvarageCharWith(table)
* CHAR_INDENT),
bounds.y + bounds.height);
- } else {
- return null;
}
+ return null;
}
default: {
Rectangle[] rectangles = new Rectangle[items.length];
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/SelectionConverter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/SelectionConverter.java
index db3f0d1..cd1161f 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/SelectionConverter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/SelectionConverter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -120,8 +120,8 @@
/**
* @param primaryOnly
- * if <code>true</code> only primary working copies will be
- * returned
+ * if <code>true</code> only primary working copies
+ * will be returned
*
*/
public static IModelElement[] codeResolve(IEditorPart editor,
@@ -134,8 +134,8 @@
* Perform a code resolve in a separate thread.
*
* @param primaryOnly
- * if <code>true</code> only primary working copies will be
- * returned
+ * if <code>true</code> only primary working copies
+ * will be returned
* @throws InterruptedException
* @throws InvocationTargetException
*
@@ -161,8 +161,8 @@
/**
* @param primaryOnly
- * if <code>true</code> only primary working copies will be
- * returned
+ * if <code>true</code> only primary working copies
+ * will be returned
*
*/
private static IModelElement getElementAtOffset(IEditorPart editor,
@@ -188,9 +188,8 @@
if (editor instanceof ITextEditor) {
return (ITextSelection) ((ITextEditor) editor)
.getSelectionProvider().getSelection();
- } else {
- return TextSelection.emptySelection();
}
+ return TextSelection.emptySelection();
}
public static IModelElement getInput(IEditorPart editor) {
@@ -199,8 +198,8 @@
/**
* @param primaryOnly
- * if <code>true</code> only primary working copies will be
- * returned
+ * if <code>true</code> only primary working copies
+ * will be returned
*
*/
private static IModelElement getInput(IEditorPart editor,
@@ -329,10 +328,10 @@
ISourceModule cunit = (ISourceModule) input;
ScriptModelUtil.reconcile(cunit);
IModelElement ref = cunit.getElementAt(selection.getOffset());
- if (ref == null)
+ if (ref == null) {
return input;
- else
- return ref;
+ }
+ return ref;
}
return null;
}
@@ -367,23 +366,21 @@
}
if (atOffset == null) {
return input;
- } else {
- int selectionEnd = selection.getOffset() + selection.getLength();
- IModelElement result = atOffset;
- if (atOffset instanceof ISourceReference) {
- ISourceRange range = ((ISourceReference) atOffset)
- .getSourceRange();
- while (range.getOffset() + range.getLength() < selectionEnd) {
- result = result.getParent();
- if (!(result instanceof ISourceReference)) {
- result = input;
- break;
- }
- range = ((ISourceReference) result).getSourceRange();
- }
- }
- return result;
}
+ int selectionEnd = selection.getOffset() + selection.getLength();
+ IModelElement result = atOffset;
+ if (atOffset instanceof ISourceReference) {
+ ISourceRange range = ((ISourceReference) atOffset).getSourceRange();
+ while (range.getOffset() + range.getLength() < selectionEnd) {
+ result = result.getParent();
+ if (!(result instanceof ISourceReference)) {
+ result = input;
+ break;
+ }
+ range = ((ISourceReference) result).getSourceRange();
+ }
+ }
+ return result;
}
/**
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/WorkbenchRunnableAdapter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/WorkbenchRunnableAdapter.java
index 4ad034a..7b4676f 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/WorkbenchRunnableAdapter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/WorkbenchRunnableAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -24,15 +24,17 @@
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.operation.IThreadListener;
-
/**
- * An <code>IRunnableWithProgress</code> that adapts and <code>IWorkspaceRunnable</code>
- * so that is can be executed inside <code>IRunnableContext</code>. <code>OperationCanceledException</code>
- * thrown by the adapted runnable are caught and re-thrown as a <code>InterruptedException</code>.
+ * An <code>IRunnableWithProgress</code> that adapts and
+ * <code>IWorkspaceRunnable</code> so that is can be executed inside
+ * <code>IRunnableContext</code>. <code>OperationCanceledException</code> thrown
+ * by the adapted runnable are caught and re-thrown as a
+ * <code>InterruptedException</code>.
*/
-public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadListener {
+public class WorkbenchRunnableAdapter
+ implements IRunnableWithProgress, IThreadListener {
- private boolean fTransfer= false;
+ private boolean fTransfer = false;
private IWorkspaceRunnable fWorkspaceRunnable;
private ISchedulingRule fRule;
@@ -44,22 +46,29 @@
}
/**
- * Runs a workspace runnable with the given lock or <code>null</code> to run with no lock at all.
+ * Runs a workspace runnable with the given lock or <code>null</code> to run
+ * with no lock at all.
*/
- public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable, ISchedulingRule rule) {
- fWorkspaceRunnable= runnable;
- fRule= rule;
+ public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable,
+ ISchedulingRule rule) {
+ fWorkspaceRunnable = runnable;
+ fRule = rule;
}
/**
- * Runs a workspace runnable with the given lock or <code>null</code> to run with no lock at all.
- * @param transfer <code>true</code> if the rule is to be transfered
- * to the model context thread. Otherwise <code>false</code>
+ * Runs a workspace runnable with the given lock or <code>null</code> to run
+ * with no lock at all.
+ *
+ * @param transfer
+ * <code>true</code> if the rule is to be transfered to
+ * the model context thread. Otherwise
+ * <code>false</code>
*/
- public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable, ISchedulingRule rule, boolean transfer) {
- fWorkspaceRunnable= runnable;
- fRule= rule;
- fTransfer= transfer;
+ public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable,
+ ISchedulingRule rule, boolean transfer) {
+ fWorkspaceRunnable = runnable;
+ fRule = rule;
+ fTransfer = transfer;
}
public ISchedulingRule getSchedulingRule() {
@@ -73,7 +82,8 @@
}
@Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
try {
DLTKCore.run(fWorkspaceRunnable, fRule, monitor);
} catch (OperationCanceledException e) {
@@ -84,18 +94,17 @@
}
public void runAsUserJob(String name, final Object jobFamiliy) {
- Job buildJob = new Job(name){
+ Job buildJob = new Job(name) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
WorkbenchRunnableAdapter.this.run(monitor);
} catch (InvocationTargetException e) {
- Throwable cause= e.getCause();
+ Throwable cause = e.getCause();
if (cause instanceof CoreException) {
return ((CoreException) cause).getStatus();
- } else {
- return DLTKUIStatus.createError(IStatus.ERROR, cause);
}
+ return DLTKUIStatus.createError(IStatus.ERROR, cause);
} catch (InterruptedException e) {
return Status.CANCEL_STATUS;
} finally {
@@ -103,6 +112,7 @@
}
return Status.OK_STATUS;
}
+
@Override
public boolean belongsTo(Object family) {
return jobFamiliy == family;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/refactoring/RenameAction.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/refactoring/RenameAction.java
index b203341..1514a22 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/refactoring/RenameAction.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/refactoring/RenameAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -22,7 +22,6 @@
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.ui.IWorkbenchSite;
-
/**
* Renames a Script element or workbench resource.
* <p>
@@ -33,7 +32,7 @@
* This class may be instantiated; it is not intended to be subclassed.
* </p>
*
- *
+ *
*/
public class RenameAction extends SelectionDispatchAction {
@@ -43,34 +42,39 @@
private ScriptEditor fEditor;
/**
- * Creates a new <code>RenameAction</code>. The action requires
- * that the selection provided by the site's selection provider is of type <code>
+ * Creates a new <code>RenameAction</code>. The action requires that the
+ * selection provided by the site's selection provider is of type <code>
* org.eclipse.jface.viewers.IStructuredSelection</code>.
*
- * @param site the site providing context information for this action
+ * @param site
+ * the site providing context information for this action
*/
public RenameAction(IWorkbenchSite site) {
super(site);
setText(RefactoringMessages.RenameAction_text);
- fRenameScriptElement= new RenameModelElementAction(site);
+ fRenameScriptElement = new RenameModelElementAction(site);
fRenameScriptElement.setText(getText());
- fRenameResource= new RenameResourceAction(site);
+ fRenameResource = new RenameResourceAction(site);
fRenameResource.setText(getText());
if (DLTKCore.DEBUG) {
System.err.println("Add help support here..."); //$NON-NLS-1$
}
- // PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IScriptHelpContextIds.RENAME_ACTION);
+ // PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
+ // IScriptHelpContextIds.RENAME_ACTION);
}
/**
- * Note: This constructor is for internal use only. Clients should not call this constructor.
- * @param editor the compilation unit editor
+ * Note: This constructor is for internal use only. Clients should not call
+ * this constructor.
+ *
+ * @param editor
+ * the compilation unit editor
*/
public RenameAction(ScriptEditor editor) {
this(editor.getEditorSite());
- fEditor= editor;
- fRenameScriptElement= new RenameModelElementAction(editor);
+ fEditor = editor;
+ fRenameScriptElement = new RenameModelElementAction(editor);
}
@Override
@@ -91,12 +95,12 @@
setEnabled(computeEnabledState());
}
- private boolean computeEnabledState(){
+ private boolean computeEnabledState() {
if (fRenameResource != null) {
- return fRenameScriptElement.isEnabled() || fRenameResource.isEnabled();
- } else {
- return fRenameScriptElement.isEnabled();
+ return fRenameScriptElement.isEnabled()
+ || fRenameResource.isEnabled();
}
+ return fRenameScriptElement.isEnabled();
}
@Override
@@ -114,6 +118,8 @@
if (fRenameScriptElement.canRun())
fRenameScriptElement.run(selection);
else
- MessageDialog.openInformation(getShell(), RefactoringMessages.RenameAction_rename, RefactoringMessages.RenameAction_unavailable);
+ MessageDialog.openInformation(getShell(),
+ RefactoringMessages.RenameAction_rename,
+ RefactoringMessages.RenameAction_unavailable);
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/browsing/LogicalPackage.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/browsing/LogicalPackage.java
index cec2e82..eb75c88 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/browsing/LogicalPackage.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/browsing/LogicalPackage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -115,11 +115,10 @@
}
private int getHash(IScriptFolder[] fragments, int index) {
- if (index <= 0)
+ if (index <= 0) {
return fragments[0].hashCode() * 17;
- else
- return fragments[index].hashCode() * 17
- + getHash(fragments, index - 1);
+ }
+ return fragments[index].hashCode() * 17 + getHash(fragments, index - 1);
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyContentProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyContentProvider.java
index d7e1c95..9c1efa0 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyContentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -22,124 +22,129 @@
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.progress.DeferredTreeContentManager;
-
public class CallHierarchyContentProvider implements ITreeContentProvider {
- private final static Object[] EMPTY_ARRAY = new Object[0];
+ private final static Object[] EMPTY_ARRAY = new Object[0];
- private DeferredTreeContentManager fManager;
- private CallHierarchyViewPart fPart;
+ private DeferredTreeContentManager fManager;
+ private CallHierarchyViewPart fPart;
- private class MethodWrapperRunnable implements IRunnableWithProgress {
- private MethodWrapper fMethodWrapper;
- private MethodWrapper[] fCalls= null;
+ private class MethodWrapperRunnable implements IRunnableWithProgress {
+ private MethodWrapper fMethodWrapper;
+ private MethodWrapper[] fCalls = null;
- MethodWrapperRunnable(MethodWrapper methodWrapper) {
- fMethodWrapper= methodWrapper;
- }
+ MethodWrapperRunnable(MethodWrapper methodWrapper) {
+ fMethodWrapper = methodWrapper;
+ }
- @Override
+ @Override
public void run(IProgressMonitor pm) {
- fCalls= fMethodWrapper.getCalls(pm);
- }
+ fCalls = fMethodWrapper.getCalls(pm);
+ }
- MethodWrapper[] getCalls() {
- if (fCalls != null) {
- return fCalls;
- }
- return new MethodWrapper[0];
- }
- }
+ MethodWrapper[] getCalls() {
+ if (fCalls != null) {
+ return fCalls;
+ }
+ return new MethodWrapper[0];
+ }
+ }
- public CallHierarchyContentProvider(CallHierarchyViewPart part) {
- super();
- fPart= part;
- }
+ public CallHierarchyContentProvider(CallHierarchyViewPart part) {
+ super();
+ fPart = part;
+ }
- @Override
+ @Override
public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof TreeRoot) {
- TreeRoot dummyRoot = (TreeRoot) parentElement;
+ if (parentElement instanceof TreeRoot) {
+ TreeRoot dummyRoot = (TreeRoot) parentElement;
- return new Object[] { dummyRoot.getRoot() };
- } else if (parentElement instanceof MethodWrapper) {
- MethodWrapper methodWrapper = ((MethodWrapper) parentElement);
+ return new Object[] { dummyRoot.getRoot() };
+ } else if (parentElement instanceof MethodWrapper) {
+ MethodWrapper methodWrapper = ((MethodWrapper) parentElement);
- if (shouldStopTraversion(methodWrapper)) {
- return EMPTY_ARRAY;
- } else {
- if (fManager != null) {
- Object[] children = fManager.getChildren(new DeferredMethodWrapper(this, methodWrapper));
- if (children != null)
- return children;
- }
- return fetchChildren(methodWrapper);
- }
- }
+ if (shouldStopTraversion(methodWrapper)) {
+ return EMPTY_ARRAY;
+ }
+ if (fManager != null) {
+ Object[] children = fManager.getChildren(
+ new DeferredMethodWrapper(this, methodWrapper));
+ if (children != null)
+ return children;
+ }
+ return fetchChildren(methodWrapper);
+ }
- return EMPTY_ARRAY;
- }
+ return EMPTY_ARRAY;
+ }
- protected Object[] fetchChildren(MethodWrapper methodWrapper) {
- IRunnableContext context= DLTKUIPlugin.getActiveWorkbenchWindow();
- MethodWrapperRunnable runnable= new MethodWrapperRunnable(methodWrapper);
- try {
- context.run(true, true, runnable);
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, CallHierarchyMessages.CallHierarchyContentProvider_searchError_title, CallHierarchyMessages.CallHierarchyContentProvider_searchError_message);
- return EMPTY_ARRAY;
- } catch (InterruptedException e) {
- return new Object[] { TreeTermination.SEARCH_CANCELED };
- }
+ protected Object[] fetchChildren(MethodWrapper methodWrapper) {
+ IRunnableContext context = DLTKUIPlugin.getActiveWorkbenchWindow();
+ MethodWrapperRunnable runnable = new MethodWrapperRunnable(
+ methodWrapper);
+ try {
+ context.run(true, true, runnable);
+ } catch (InvocationTargetException e) {
+ ExceptionHandler.handle(e,
+ CallHierarchyMessages.CallHierarchyContentProvider_searchError_title,
+ CallHierarchyMessages.CallHierarchyContentProvider_searchError_message);
+ return EMPTY_ARRAY;
+ } catch (InterruptedException e) {
+ return new Object[] { TreeTermination.SEARCH_CANCELED };
+ }
- return runnable.getCalls();
- }
+ return runnable.getCalls();
+ }
- private boolean shouldStopTraversion(MethodWrapper methodWrapper) {
- return (methodWrapper.getLevel() > CallHierarchyUI.getDefault().getMaxCallDepth()) || methodWrapper.isRecursive();
- }
+ private boolean shouldStopTraversion(MethodWrapper methodWrapper) {
+ return (methodWrapper.getLevel() > CallHierarchyUI.getDefault()
+ .getMaxCallDepth()) || methodWrapper.isRecursive();
+ }
- /**
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- @Override
+ /**
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ @Override
public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
+ return getChildren(inputElement);
+ }
- /**
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- */
- @Override
+ /**
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+ */
+ @Override
public Object getParent(Object element) {
- if (element instanceof MethodWrapper) {
- return ((MethodWrapper) element).getParent();
- }
+ if (element instanceof MethodWrapper) {
+ return ((MethodWrapper) element).getParent();
+ }
- return null;
- }
+ return null;
+ }
- /**
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- @Override
+ /**
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ @Override
public void dispose() {
- // Nothing to dispose
- }
+ // Nothing to dispose
+ }
- /**
+ /**
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
*/
@Override
public boolean hasChildren(Object element) {
- if (element == TreeRoot.EMPTY_ROOT || element == TreeTermination.SEARCH_CANCELED) {
+ if (element == TreeRoot.EMPTY_ROOT
+ || element == TreeTermination.SEARCH_CANCELED) {
return false;
}
// Only methods can have subelements, so there's no need to fool the
// user into believing that there is more
if (element instanceof MethodWrapper) {
- MethodWrapper methodWrapper= (MethodWrapper) element;
- if (methodWrapper.getMember().getElementType() != IModelElement.METHOD) {
+ MethodWrapper methodWrapper = (MethodWrapper) element;
+ if (methodWrapper.getMember()
+ .getElementType() != IModelElement.METHOD) {
return false;
}
if (shouldStopTraversion(methodWrapper)) {
@@ -159,45 +164,45 @@
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (oldInput instanceof TreeRoot) {
- Object root = ((TreeRoot) oldInput).getRoot();
- if (root instanceof MethodWrapper) {
- cancelJobs((MethodWrapper) root);
- }
- }
- if (viewer instanceof AbstractTreeViewer) {
+ if (oldInput instanceof TreeRoot) {
+ Object root = ((TreeRoot) oldInput).getRoot();
+ if (root instanceof MethodWrapper) {
+ cancelJobs((MethodWrapper) root);
+ }
+ }
+ if (viewer instanceof AbstractTreeViewer) {
fManager = new DeferredTreeContentManager(
(AbstractTreeViewer) viewer, fPart.getSite());
- }
- }
+ }
+ }
- /**
- * Cancel all current jobs.
- */
- void cancelJobs(MethodWrapper wrapper) {
- if (fManager != null && wrapper != null) {
+ /**
+ * Cancel all current jobs.
+ */
+ void cancelJobs(MethodWrapper wrapper) {
+ if (fManager != null && wrapper != null) {
fManager.cancel(wrapper);
- if (fPart != null) {
- fPart.setCancelEnabled(false);
- }
- }
- }
+ if (fPart != null) {
+ fPart.setCancelEnabled(false);
+ }
+ }
+ }
- /**
- *
- */
- public void doneFetching() {
- if (fPart != null) {
- fPart.setCancelEnabled(false);
- }
- }
+ /**
+ *
+ */
+ public void doneFetching() {
+ if (fPart != null) {
+ fPart.setCancelEnabled(false);
+ }
+ }
- /**
- *
- */
- public void startFetching() {
- if (fPart != null) {
- fPart.setCancelEnabled(true);
- }
- }
+ /**
+ *
+ */
+ public void startFetching() {
+ if (fPart != null) {
+ fPart.setCancelEnabled(true);
+ }
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyLabelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyLabelProvider.java
index c71ef89..af4c218 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyLabelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -20,7 +20,6 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.model.IWorkbenchAdapter;
-
class CallHierarchyLabelProvider extends AppearanceAwareLabelProvider {
// private final static long FULLY_QUALIFIED = Long.valueOf(ScriptElementLabels.F_FULLY_QUALIFIED | ScriptElementLabels.M_FULLY_QUALIFIED | ScriptElementLabels.I_FULLY_QUALIFIED | ScriptElementLabels.T_FULLY_QUALIFIED ).longValue();
//
@@ -28,66 +27,74 @@
// private static final int IMAGEFLAGS= DEFAULT_IMAGEFLAGS | ScriptElementImageProvider.SMALL_ICONS;
private static final long TEXTFLAGS = DEFAULT_TEXTFLAGS
| ScriptElementLabels.ALL_POST_QUALIFIED
- | ScriptElementLabels.P_COMPRESSED
- | ScriptElementLabels.APPEND_FILE
+ | ScriptElementLabels.P_COMPRESSED | ScriptElementLabels.APPEND_FILE
| ScriptElementLabels.APPEND_ROOT_PATH;
- private static final int IMAGEFLAGS= DEFAULT_IMAGEFLAGS | ScriptElementImageProvider.SMALL_ICONS;
+ private static final int IMAGEFLAGS = DEFAULT_IMAGEFLAGS
+ | ScriptElementImageProvider.SMALL_ICONS;
- private ILabelDecorator fDecorator;
+ private ILabelDecorator fDecorator;
- CallHierarchyLabelProvider() {
- super(TEXTFLAGS, IMAGEFLAGS, DLTKUIPlugin.getDefault().getPreferenceStore());
- fDecorator= new CallHierarchyLabelDecorator();
- }
- @Override
+ CallHierarchyLabelProvider() {
+ super(TEXTFLAGS, IMAGEFLAGS,
+ DLTKUIPlugin.getDefault().getPreferenceStore());
+ fDecorator = new CallHierarchyLabelDecorator();
+ }
+
+ @Override
public Image getImage(Object element) {
- Image result= null;
- if (element instanceof MethodWrapper) {
- MethodWrapper methodWrapper = (MethodWrapper) element;
+ Image result = null;
+ if (element instanceof MethodWrapper) {
+ MethodWrapper methodWrapper = (MethodWrapper) element;
- if (methodWrapper.getMember() != null) {
- result= fDecorator.decorateImage(super.getImage(methodWrapper.getMember()), methodWrapper);
- }
- } else if (isPendingUpdate(element)) {
- return null;
- } else {
- result= super.getImage(element);
- }
+ if (methodWrapper.getMember() != null) {
+ result = fDecorator.decorateImage(
+ super.getImage(methodWrapper.getMember()),
+ methodWrapper);
+ }
+ } else if (isPendingUpdate(element)) {
+ return null;
+ } else {
+ result = super.getImage(element);
+ }
- return result;
- }
+ return result;
+ }
- @Override
+ @Override
public String getText(Object element) {
- if (element instanceof MethodWrapper) {
- MethodWrapper methodWrapper = (MethodWrapper) element;
+ if (element instanceof MethodWrapper) {
+ MethodWrapper methodWrapper = (MethodWrapper) element;
- if (methodWrapper.getMember() != null) {
- return getElementLabel(methodWrapper);
- } else {
- return CallHierarchyMessages.CallHierarchyLabelProvider_root;
- }
- } else if (element == TreeTermination.SEARCH_CANCELED) {
- return CallHierarchyMessages.CallHierarchyLabelProvider_searchCanceled;
- } else if (isPendingUpdate(element)) {
- return CallHierarchyMessages.CallHierarchyLabelProvider_updatePending;
- }
+ if (methodWrapper.getMember() != null) {
+ return getElementLabel(methodWrapper);
+ }
+ return CallHierarchyMessages.CallHierarchyLabelProvider_root;
+ } else if (element == TreeTermination.SEARCH_CANCELED) {
+ return CallHierarchyMessages.CallHierarchyLabelProvider_searchCanceled;
+ } else if (isPendingUpdate(element)) {
+ return CallHierarchyMessages.CallHierarchyLabelProvider_updatePending;
+ }
- return CallHierarchyMessages.CallHierarchyLabelProvider_noMethodSelected;
- }
+ return CallHierarchyMessages.CallHierarchyLabelProvider_noMethodSelected;
+ }
- private boolean isPendingUpdate(Object element) {
- return element instanceof IWorkbenchAdapter;
- }
- private String getElementLabel(MethodWrapper methodWrapper) {
- String label = super.getText(methodWrapper.getMember());
+ private boolean isPendingUpdate(Object element) {
+ return element instanceof IWorkbenchAdapter;
+ }
- Collection callLocations = methodWrapper.getMethodCall().getCallLocations();
+ private String getElementLabel(MethodWrapper methodWrapper) {
+ String label = super.getText(methodWrapper.getMember());
- if ((callLocations != null) && (callLocations.size() > 1)) {
- return Messages.format(CallHierarchyMessages.CallHierarchyLabelProvider_matches, new String[]{label, String.valueOf(callLocations.size())});
- }
+ Collection callLocations = methodWrapper.getMethodCall()
+ .getCallLocations();
- return label;
- }
+ if ((callLocations != null) && (callLocations.size() > 1)) {
+ return Messages.format(
+ CallHierarchyMessages.CallHierarchyLabelProvider_matches,
+ new String[] { label,
+ String.valueOf(callLocations.size()) });
+ }
+
+ return label;
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyViewPart.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyViewPart.java
index 875c12a..f7902c3 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyViewPart.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyViewPart.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -242,16 +242,16 @@
public MethodWrapper getCurrentMethodWrapper() {
if (fCurrentCallMode == CallHierarchyViewPart.CALL_MODE_CALLERS) {
return fCallerRoot;
- } else {
- return fCalleeRoot;
}
+ return fCalleeRoot;
}
/**
* called from ToggleOrientationAction.
*
* @param orientation
- * VIEW_ORIENTATION_HORIZONTAL or VIEW_ORIENTATION_VERTICAL
+ * VIEW_ORIENTATION_HORIZONTAL or
+ * VIEW_ORIENTATION_VERTICAL
*/
void setOrientation(int orientation) {
if (fCurrentOrientation != orientation) {
@@ -294,7 +294,7 @@
* called from ToggleCallModeAction.
*
* @param mode
- * CALL_MODE_CALLERS or CALL_MODE_CALLEES
+ * CALL_MODE_CALLERS or CALL_MODE_CALLEES
*/
void setCallMode(int mode) {
if (fCurrentCallMode != mode) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/LocationLabelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/LocationLabelProvider.java
index 0a13fea..c95cf1b 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/LocationLabelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/LocationLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -14,83 +14,84 @@
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
+class LocationLabelProvider extends LabelProvider
+ implements ITableLabelProvider {
+ private static final int COLUMN_ICON = 0;
+ private static final int COLUMN_LINE = 1;
+ private static final int COLUMN_INFO = 2;
-class LocationLabelProvider extends LabelProvider implements ITableLabelProvider {
- private static final int COLUMN_ICON= 0;
- private static final int COLUMN_LINE= 1;
- private static final int COLUMN_INFO= 2;
+ LocationLabelProvider() {
+ // Do nothing
+ }
- LocationLabelProvider() {
- // Do nothing
- }
-
- @Override
+ @Override
public String getText(Object element) {
- return getColumnText(element, COLUMN_INFO);
- }
+ return getColumnText(element, COLUMN_INFO);
+ }
- @Override
+ @Override
public Image getImage(Object element) {
- return getColumnImage(element, COLUMN_ICON);
- }
+ return getColumnImage(element, COLUMN_ICON);
+ }
- private String removeWhitespaceOutsideStringLiterals(CallLocation callLocation) {
- StringBuffer buf = new StringBuffer();
- boolean withinString = false;
+ private String removeWhitespaceOutsideStringLiterals(
+ CallLocation callLocation) {
+ StringBuffer buf = new StringBuffer();
+ boolean withinString = false;
- String s= callLocation.getCallText();
- for (int i = 0; i < s.length(); i++) {
- char ch = s.charAt(i);
+ String s = callLocation.getCallText();
+ for (int i = 0; i < s.length(); i++) {
+ char ch = s.charAt(i);
- if (ch == '"') {
- withinString = !withinString;
- }
+ if (ch == '"') {
+ withinString = !withinString;
+ }
- if (withinString) {
- buf.append(ch);
- } else if (Character.isWhitespace(ch)) {
- if ((buf.length() == 0) ||
- !Character.isWhitespace(buf.charAt(buf.length() - 1))) {
- if (ch != ' ') {
- ch = ' ';
- }
+ if (withinString) {
+ buf.append(ch);
+ } else if (Character.isWhitespace(ch)) {
+ if ((buf.length() == 0) || !Character
+ .isWhitespace(buf.charAt(buf.length() - 1))) {
+ if (ch != ' ') {
+ ch = ' ';
+ }
- buf.append(ch);
- }
- } else {
- buf.append(ch);
- }
- }
+ buf.append(ch);
+ }
+ } else {
+ buf.append(ch);
+ }
+ }
- return buf.toString();
- }
+ return buf.toString();
+ }
- @Override
+ @Override
public Image getColumnImage(Object element, int columnIndex) {
- if (columnIndex == COLUMN_ICON) {
- return DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_SEARCH_OCCURRENCE);
- }
- return null;
- }
+ if (columnIndex == COLUMN_ICON) {
+ return DLTKPluginImages
+ .get(DLTKPluginImages.IMG_OBJS_SEARCH_OCCURRENCE);
+ }
+ return null;
+ }
- @Override
+ @Override
public String getColumnText(Object element, int columnIndex) {
- if (element instanceof CallLocation) {
- CallLocation callLocation= (CallLocation) element;
+ if (element instanceof CallLocation) {
+ CallLocation callLocation = (CallLocation) element;
- switch (columnIndex) {
- case COLUMN_LINE:
- int lineNumber= callLocation.getLineNumber();
- if (lineNumber == CallLocation.UNKNOWN_LINE_NUMBER) {
- return CallHierarchyMessages.LocationLabelProvider_unknown;
- } else {
- return String.valueOf(lineNumber);
- }
- case COLUMN_INFO:
- return removeWhitespaceOutsideStringLiterals(callLocation);
- }
- }
+ switch (columnIndex) {
+ case COLUMN_LINE:
+ int lineNumber = callLocation.getLineNumber();
+ if (lineNumber == CallLocation.UNKNOWN_LINE_NUMBER) {
+ return CallHierarchyMessages.LocationLabelProvider_unknown;
+ }
+ return String.valueOf(lineNumber);
+ case COLUMN_INFO:
+ return removeWhitespaceOutsideStringLiterals(callLocation);
+ }
+ }
- return ""; //$NON-NLS-1$
- }
+ return ""; //$NON-NLS-1$
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/SearchScopeHierarchyAction.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/SearchScopeHierarchyAction.java
index 4c40178..3554cad 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/SearchScopeHierarchyAction.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/SearchScopeHierarchyAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -16,14 +16,15 @@
import org.eclipse.dltk.internal.ui.search.DLTKSearchScopeFactory;
import org.eclipse.dltk.ui.DLTKUIPlugin;
-
class SearchScopeHierarchyAction extends SearchScopeAction {
private final SearchScopeActionGroup fGroup;
public SearchScopeHierarchyAction(SearchScopeActionGroup group) {
- super(group, CallHierarchyMessages.SearchScopeActionGroup_hierarchy_text);
+ super(group,
+ CallHierarchyMessages.SearchScopeActionGroup_hierarchy_text);
this.fGroup = group;
- setToolTipText(CallHierarchyMessages.SearchScopeActionGroup_hierarchy_tooltip);
+ setToolTipText(
+ CallHierarchyMessages.SearchScopeActionGroup_hierarchy_tooltip);
// PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_SEARCH_SCOPE_ACTION);
if (DLTKCore.DEBUG) {
System.err.println("Add help support here..."); //$NON-NLS-1$
@@ -37,10 +38,10 @@
IMethod method = this.fGroup.getView().getMethod();
if (method != null) {
- return SearchEngine.createHierarchyScope(method.getDeclaringType());
- } else {
- return null;
+ return SearchEngine
+ .createHierarchyScope(method.getDeclaringType());
}
+ return null;
} catch (ModelException e) {
DLTKUIPlugin.log(e);
}
@@ -53,11 +54,11 @@
return SearchScopeActionGroup.SEARCH_SCOPE_TYPE_HIERARCHY;
}
-
@Override
public String getFullDescription() {
IMethod method = this.fGroup.getView().getMethod();
- return DLTKSearchScopeFactory.getInstance().getHierarchyScopeDescription(method.getDeclaringType());
+ return DLTKSearchScopeFactory.getInstance()
+ .getHierarchyScopeDescription(method.getDeclaringType());
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/StatusUtil.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/StatusUtil.java
index 9e9421f..930b832 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/StatusUtil.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/StatusUtil.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
*
-
*******************************************************************************/
package org.eclipse.dltk.internal.ui.dialogs;
@@ -29,9 +28,8 @@
public static IStatus getMoreSevere(IStatus s1, IStatus s2) {
if (s1.getSeverity() > s2.getSeverity()) {
return s1;
- } else {
- return s2;
}
+ return s2;
}
/**
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/TextFieldNavigationHandler.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/TextFieldNavigationHandler.java
index a8654dc..b19886f 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/TextFieldNavigationHandler.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/TextFieldNavigationHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2017 IBM Corporation and others.
+ * Copyright (c) 2005, 2018 IBM Corporation 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
@@ -69,25 +69,27 @@
}
private abstract static class WorkaroundNavigable extends Navigable {
- /* workarounds for:
- * - bug 103630: Add API: Combo#getCaretPosition()
- * - bug 106024: Text#setSelection(int, int) does not handle start > end with SWT.SINGLE
+ /*
+ * workarounds for: - bug 103630: Add API: Combo#getCaretPosition() -
+ * bug 106024: Text#setSelection(int, int) does not handle start > end
+ * with SWT.SINGLE
*/
Point fLastSelection;
int fCaretPosition;
void selectionChanged() {
- Point selection= getSelection();
+ Point selection = getSelection();
if (selection.equals(fLastSelection)) {
// leave caret position
- } else if (selection.x == selection.y) { //empty range
- fCaretPosition= selection.x;
+ } else if (selection.x == selection.y) { // empty range
+ fCaretPosition = selection.x;
} else if (fLastSelection.y == selection.y) {
- fCaretPosition= selection.x; //same end -> assume caret at start
+ fCaretPosition = selection.x; // same end -> assume caret at
+ // start
} else {
- fCaretPosition= selection.y;
+ fCaretPosition = selection.y;
}
- fLastSelection= selection;
+ fLastSelection = selection;
}
}
@@ -106,19 +108,19 @@
}
private static class TextNavigable extends WorkaroundNavigable {
- static final boolean BUG_106024_TEXT_SELECTION=
- "win32".equals(SWT.getPlatform()) //$NON-NLS-1$
+ static final boolean BUG_106024_TEXT_SELECTION = "win32" //$NON-NLS-1$
+ .equals(SWT.getPlatform())
// on carbon, getCaretPosition() always returns getSelection().x
|| "carbon".equals(SWT.getPlatform()); //$NON-NLS-1$
private final Text fText;
public TextNavigable(Text text) {
- fText= text;
+ fText = text;
// workaround for bug 106024:
if (BUG_106024_TEXT_SELECTION) {
- fLastSelection= getSelection();
- fCaretPosition= fLastSelection.y;
+ fLastSelection = getSelection();
+ fCaretPosition = fLastSelection.y;
fText.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
@@ -159,9 +161,8 @@
if (BUG_106024_TEXT_SELECTION) {
selectionChanged();
return fCaretPosition;
- } else {
- return fText.getCaretPosition();
}
+ return fText.getCaretPosition();
}
@Override
@@ -174,7 +175,7 @@
private final StyledText fStyledText;
public StyledTextNavigable(StyledText styledText) {
- fStyledText= styledText;
+ fStyledText = styledText;
}
@Override
@@ -212,10 +213,10 @@
private final Combo fCombo;
public ComboNavigable(Combo combo) {
- fCombo= combo;
+ fCombo = combo;
// workaround for bug 103630:
- fLastSelection= getSelection();
- fCaretPosition= fLastSelection.y;
+ fLastSelection = getSelection();
+ fCaretPosition = fLastSelection.y;
fCombo.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
@@ -265,17 +266,17 @@
private static class FocusHandler implements FocusListener {
- private static final String EMPTY_TEXT= ""; //$NON-NLS-1$
+ private static final String EMPTY_TEXT = ""; //$NON-NLS-1$
private final DLTKWordIterator fIterator;
private final Navigable fNavigable;
private KeyAdapter fKeyListener;
private FocusHandler(Navigable navigable) {
- fIterator= new DLTKWordIterator();
- fNavigable= navigable;
+ fIterator = new DLTKWordIterator();
+ fNavigable = navigable;
- Control control= navigable.getControl();
+ Control control = navigable.getControl();
control.addFocusListener(this);
if (control.isFocusControl())
activate();
@@ -298,59 +299,79 @@
private void deactivate() {
if (fKeyListener != null) {
- Control control= fNavigable.getControl();
- if (! control.isDisposed())
+ Control control = fNavigable.getControl();
+ if (!control.isDisposed())
control.removeKeyListener(fKeyListener);
- fKeyListener= null;
+ fKeyListener = null;
}
}
private KeyAdapter getKeyListener() {
if (fKeyListener == null) {
- fKeyListener= new KeyAdapter() {
- private static final String TEXT_EDITOR_CONTEXT_ID= "org.eclipse.ui.textEditorScope"; //$NON-NLS-1$
- private final boolean IS_WORKAROUND= (fNavigable instanceof ComboNavigable)
- || (fNavigable instanceof TextNavigable && TextNavigable.BUG_106024_TEXT_SELECTION);
- private List/*<Submission>*/ fSubmissions;
+ fKeyListener = new KeyAdapter() {
+ private static final String TEXT_EDITOR_CONTEXT_ID = "org.eclipse.ui.textEditorScope"; //$NON-NLS-1$
+ private final boolean IS_WORKAROUND = (fNavigable instanceof ComboNavigable)
+ || (fNavigable instanceof TextNavigable
+ && TextNavigable.BUG_106024_TEXT_SELECTION);
+ private List/* <Submission> */ fSubmissions;
@Override
public void keyPressed(KeyEvent e) {
if (IS_WORKAROUND) {
- if (e.keyCode == SWT.ARROW_LEFT && e.stateMask == SWT.MOD2) {
- int caretPosition= fNavigable.getCaretPosition();
+ if (e.keyCode == SWT.ARROW_LEFT
+ && e.stateMask == SWT.MOD2) {
+ int caretPosition = fNavigable
+ .getCaretPosition();
if (caretPosition != 0) {
- Point selection= fNavigable.getSelection();
+ Point selection = fNavigable.getSelection();
if (caretPosition == selection.x)
- fNavigable.setSelection(selection.y, caretPosition - 1);
+ fNavigable.setSelection(selection.y,
+ caretPosition - 1);
else
- fNavigable.setSelection(selection.x, caretPosition - 1);
+ fNavigable.setSelection(selection.x,
+ caretPosition - 1);
}
- e.doit= false;
+ e.doit = false;
return;
- } else if (e.keyCode == SWT.ARROW_RIGHT && e.stateMask == SWT.MOD2) {
- String text= fNavigable.getText();
- int caretPosition= fNavigable.getCaretPosition();
+ } else if (e.keyCode == SWT.ARROW_RIGHT
+ && e.stateMask == SWT.MOD2) {
+ String text = fNavigable.getText();
+ int caretPosition = fNavigable
+ .getCaretPosition();
if (caretPosition != text.length()) {
- Point selection= fNavigable.getSelection();
+ Point selection = fNavigable.getSelection();
if (caretPosition == selection.y)
- fNavigable.setSelection(selection.x, caretPosition + 1);
+ fNavigable.setSelection(selection.x,
+ caretPosition + 1);
else
- fNavigable.setSelection(selection.y, caretPosition + 1);
+ fNavigable.setSelection(selection.y,
+ caretPosition + 1);
}
- e.doit= false;
+ e.doit = false;
return;
}
}
- int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(e);
- KeySequence keySequence = KeySequence.getInstance(SWTKeySupport.convertAcceleratorToKeyStroke(accelerator));
+ int accelerator = SWTKeySupport
+ .convertEventToUnmodifiedAccelerator(e);
+ KeySequence keySequence = KeySequence.getInstance(
+ SWTKeySupport.convertAcceleratorToKeyStroke(
+ accelerator));
getSubmissions();
- for (Iterator iter= getSubmissions().iterator(); iter.hasNext();) {
- Submission submission= (Submission) iter.next();
- TriggerSequence[] triggerSequences= submission.getTriggerSequences();
- for (int i= 0; i < triggerSequences.length; i++) {
- if (triggerSequences[i].equals(keySequence)) { // XXX does not work for multi-stroke bindings
- e.doit= false;
+ for (Iterator iter = getSubmissions().iterator(); iter
+ .hasNext();) {
+ Submission submission = (Submission) iter.next();
+ TriggerSequence[] triggerSequences = submission
+ .getTriggerSequences();
+ for (int i = 0; i < triggerSequences.length; i++) {
+ if (triggerSequences[i].equals(keySequence)) { // XXX
+ // does
+ // not
+ // work
+ // for
+ // multi-stroke
+ // bindings
+ e.doit = false;
submission.execute();
return;
}
@@ -358,11 +379,11 @@
}
}
- private List/*<Submission>*/ getSubmissions() {
+ private List/* <Submission> */ getSubmissions() {
if (fSubmissions != null)
return fSubmissions;
- fSubmissions= new ArrayList();
+ fSubmissions = new ArrayList();
IContextService contextService = PlatformUI
.getWorkbench()
@@ -376,116 +397,151 @@
IBindingService bindingService = PlatformUI
.getWorkbench()
.getAdapter(IBindingService.class);
- if (contextService == null || commandService == null || handlerService == null || bindingService == null)
+ if (contextService == null || commandService == null
+ || handlerService == null
+ || bindingService == null)
return fSubmissions;
IContextActivation[] contextActivations;
- contextActivations= new IContextActivation[] {
- contextService.activateContext(IContextService.CONTEXT_ID_WINDOW), // XXX relying on workbench feature https://bugs.eclipse.org/bugs/show_bug.cgi?id=115460#c11
- contextService.activateContext(TEXT_EDITOR_CONTEXT_ID)
- };
+ contextActivations = new IContextActivation[] {
+ contextService.activateContext(
+ IContextService.CONTEXT_ID_WINDOW), // XXX
+ // relying
+ // on
+ // workbench
+ // feature
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=115460#c11
+ contextService.activateContext(
+ TEXT_EDITOR_CONTEXT_ID) };
- fSubmissions.add(new Submission(bindingService.getActiveBindingsFor(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT)) {
+ fSubmissions.add(new Submission(
+ bindingService.getActiveBindingsFor(
+ ITextEditorActionDefinitionIds.SELECT_WORD_NEXT)) {
@Override
public void execute() {
fIterator.setText(fNavigable.getText());
- int caretPosition= fNavigable.getCaretPosition();
- int newCaret= fIterator.following(caretPosition);
+ int caretPosition = fNavigable
+ .getCaretPosition();
+ int newCaret = fIterator
+ .following(caretPosition);
if (newCaret != BreakIterator.DONE) {
- Point selection= fNavigable.getSelection();
+ Point selection = fNavigable.getSelection();
if (caretPosition == selection.y)
- fNavigable.setSelection(selection.x, newCaret);
+ fNavigable.setSelection(selection.x,
+ newCaret);
else
- fNavigable.setSelection(selection.y, newCaret);
+ fNavigable.setSelection(selection.y,
+ newCaret);
}
fIterator.setText(EMPTY_TEXT);
}
});
- fSubmissions.add(new Submission(bindingService.getActiveBindingsFor(ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS)) {
+ fSubmissions.add(new Submission(
+ bindingService.getActiveBindingsFor(
+ ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS)) {
@Override
public void execute() {
fIterator.setText(fNavigable.getText());
- int caretPosition= fNavigable.getCaretPosition();
- int newCaret= fIterator.preceding(caretPosition);
+ int caretPosition = fNavigable
+ .getCaretPosition();
+ int newCaret = fIterator
+ .preceding(caretPosition);
if (newCaret != BreakIterator.DONE) {
- Point selection= fNavigable.getSelection();
+ Point selection = fNavigable.getSelection();
if (caretPosition == selection.x)
- fNavigable.setSelection(selection.y, newCaret);
+ fNavigable.setSelection(selection.y,
+ newCaret);
else
- fNavigable.setSelection(selection.x, newCaret);
+ fNavigable.setSelection(selection.x,
+ newCaret);
}
fIterator.setText(EMPTY_TEXT);
}
});
- fSubmissions.add(new Submission(bindingService.getActiveBindingsFor(ITextEditorActionDefinitionIds.WORD_NEXT)) {
+ fSubmissions.add(new Submission(
+ bindingService.getActiveBindingsFor(
+ ITextEditorActionDefinitionIds.WORD_NEXT)) {
@Override
public void execute() {
fIterator.setText(fNavigable.getText());
- int caretPosition= fNavigable.getCaretPosition();
- int newCaret= fIterator.following(caretPosition);
+ int caretPosition = fNavigable
+ .getCaretPosition();
+ int newCaret = fIterator
+ .following(caretPosition);
if (newCaret != BreakIterator.DONE)
fNavigable.setSelection(newCaret, newCaret);
fIterator.setText(EMPTY_TEXT);
}
});
- fSubmissions.add(new Submission(bindingService.getActiveBindingsFor(ITextEditorActionDefinitionIds.WORD_PREVIOUS)) {
+ fSubmissions.add(new Submission(
+ bindingService.getActiveBindingsFor(
+ ITextEditorActionDefinitionIds.WORD_PREVIOUS)) {
@Override
public void execute() {
fIterator.setText(fNavigable.getText());
- int caretPosition= fNavigable.getCaretPosition();
- int newCaret= fIterator.preceding(caretPosition);
+ int caretPosition = fNavigable
+ .getCaretPosition();
+ int newCaret = fIterator
+ .preceding(caretPosition);
if (newCaret != BreakIterator.DONE)
fNavigable.setSelection(newCaret, newCaret);
fIterator.setText(EMPTY_TEXT);
}
});
- fSubmissions.add(new Submission(bindingService.getActiveBindingsFor(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD)) {
+ fSubmissions.add(new Submission(
+ bindingService.getActiveBindingsFor(
+ ITextEditorActionDefinitionIds.DELETE_NEXT_WORD)) {
@Override
public void execute() {
- Point selection= fNavigable.getSelection();
- String text= fNavigable.getText();
+ Point selection = fNavigable.getSelection();
+ String text = fNavigable.getText();
int start;
int end;
if (selection.x != selection.y) {
- start= selection.x;
- end= selection.y;
+ start = selection.x;
+ end = selection.y;
} else {
fIterator.setText(text);
- start= fNavigable.getCaretPosition();
- end= fIterator.following(start);
+ start = fNavigable.getCaretPosition();
+ end = fIterator.following(start);
fIterator.setText(EMPTY_TEXT);
if (end == BreakIterator.DONE)
return;
}
- fNavigable.setText(text.substring(0, start) + text.substring(end));
+ fNavigable.setText(text.substring(0, start)
+ + text.substring(end));
fNavigable.setSelection(start, start);
}
});
- fSubmissions.add(new Submission(bindingService.getActiveBindingsFor(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD)) {
+ fSubmissions.add(new Submission(
+ bindingService.getActiveBindingsFor(
+ ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD)) {
@Override
public void execute() {
- Point selection= fNavigable.getSelection();
- String text= fNavigable.getText();
+ Point selection = fNavigable.getSelection();
+ String text = fNavigable.getText();
int start;
int end;
if (selection.x != selection.y) {
- start= selection.x;
- end= selection.y;
+ start = selection.x;
+ end = selection.y;
} else {
fIterator.setText(text);
- end= fNavigable.getCaretPosition();
- start= fIterator.preceding(end);
+ end = fNavigable.getCaretPosition();
+ start = fIterator.preceding(end);
fIterator.setText(EMPTY_TEXT);
if (start == BreakIterator.DONE)
return;
}
- fNavigable.setText(text.substring(0, start) + text.substring(end));
+ fNavigable.setText(text.substring(0, start)
+ + text.substring(end));
fNavigable.setSelection(start, start);
}
});
- for (int i= 0; i < contextActivations.length; i++) {
- contextService.deactivateContext(contextActivations[i]);
+ for (int i = 0; i < contextActivations.length; i++) {
+ contextService
+ .deactivateContext(contextActivations[i]);
}
return fSubmissions;
@@ -501,7 +557,7 @@
private TriggerSequence[] fTriggerSequences;
public Submission(TriggerSequence[] triggerSequences) {
- fTriggerSequences= triggerSequences;
+ fTriggerSequences = triggerSequences;
}
public TriggerSequence[] getTriggerSequences() {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dnd/DelegatingDropAdapter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dnd/DelegatingDropAdapter.java
index 472cab9..aa28f78 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dnd/DelegatingDropAdapter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dnd/DelegatingDropAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -32,10 +32,11 @@
/**
* Creates a new delegating drop adapter.
*
- * @param listeners an array of potential listeners
+ * @param listeners
+ * an array of potential listeners
*/
public DelegatingDropAdapter(TransferDropTargetListener[] listeners) {
- fListeners= listeners;
+ fListeners = listeners;
}
/**
@@ -43,12 +44,13 @@
* is updated, and <code>#dragEnter()</code> is forwarded to the current
* listener.
*
- * @param event the drop target event
+ * @param event
+ * the drop target event
* @see DropTargetListener#dragEnter(DropTargetEvent)
*/
@Override
public void dragEnter(DropTargetEvent event) {
- fOriginalDropType= event.detail;
+ fOriginalDropType = event.detail;
updateCurrentListener(event);
}
@@ -56,7 +58,8 @@
* The cursor has left the drop target boundaries. The event is forwarded to
* the current listener.
*
- * @param event the drop target event
+ * @param event
+ * the drop target event
* @see DropTargetListener#dragLeave(DropTargetEvent)
*/
@Override
@@ -69,15 +72,16 @@
* changing a drag modifier key while dragging). Updates the current
* listener and forwards this event to that listener.
*
- * @param event the drop target event
+ * @param event
+ * the drop target event
* @see DropTargetListener#dragOperationChanged(DropTargetEvent)
*/
@Override
public void dragOperationChanged(final DropTargetEvent event) {
- fOriginalDropType= event.detail;
- TransferDropTargetListener oldListener= getCurrentListener();
+ fOriginalDropType = event.detail;
+ TransferDropTargetListener oldListener = getCurrentListener();
updateCurrentListener(event);
- final TransferDropTargetListener newListener= getCurrentListener();
+ final TransferDropTargetListener newListener = getCurrentListener();
// only notify the current listener if it hasn't changed based on the
// operation change. otherwise the new listener would get a dragEnter
// followed by a dragOperationChanged with the exact same event.
@@ -97,14 +101,15 @@
* drag operation the <code>event.detail</code> field is set to
* <code>DND.DROP_NONE</code> to indicate an invalid drop.
*
- * @param event the drop target event
+ * @param event
+ * the drop target event
* @see DropTargetListener#dragOver(DropTargetEvent)
*/
@Override
public void dragOver(final DropTargetEvent event) {
- TransferDropTargetListener oldListener= getCurrentListener();
+ TransferDropTargetListener oldListener = getCurrentListener();
updateCurrentListener(event);
- final TransferDropTargetListener newListener= getCurrentListener();
+ final TransferDropTargetListener newListener = getCurrentListener();
// only notify the current listener if it hasn't changed based on the
// drag over. otherwise the new listener would get a dragEnter
@@ -123,7 +128,8 @@
* Forwards this event to the current listener, if there is one. Sets the
* current listener to <code>null</code> afterwards.
*
- * @param event the drop target event
+ * @param event
+ * the drop target event
* @see DropTargetListener#drop(DropTargetEvent)
*/
@Override
@@ -143,7 +149,8 @@
/**
* Forwards this event to the current listener if there is one.
*
- * @param event the drop target event
+ * @param event
+ * the drop target event
* @see DropTargetListener#dropAccept(DropTargetEvent)
*/
@Override
@@ -173,14 +180,17 @@
* <code>null</code> if the listener does not support any of the specified
* data types.
*
- * @param dataTypes available data types
- * @param listener <code>TransferDropTargetListener</code> to use for
- * testing supported data types.
+ * @param dataTypes
+ * available data types
+ * @param listener
+ * <code>TransferDropTargetListener</code> to use for
+ * testing supported data types.
* @return the transfer data type supported by the given listener or
* <code>null</code>.
*/
- private TransferData getSupportedTransferType(TransferData[] dataTypes, TransferDropTargetListener listener) {
- for (int i= 0; i < dataTypes.length; i++) {
+ private TransferData getSupportedTransferType(TransferData[] dataTypes,
+ TransferDropTargetListener listener) {
+ for (int i = 0; i < dataTypes.length; i++) {
if (listener.getTransfer().isSupportedType(dataTypes[i])) {
return dataTypes[i];
}
@@ -195,9 +205,9 @@
* @return the combined set of <code>Transfer</code> types
*/
public Transfer[] getTransfers() {
- Transfer[] types= new Transfer[fListeners.length];
- for (int i= 0; i < fListeners.length; i++) {
- types[i]= fListeners[i].getTransfer();
+ Transfer[] types = new Transfer[fListeners.length];
+ for (int i = 0; i < fListeners.length; i++) {
+ types[i] = fListeners[i].getTransfer();
}
return types;
}
@@ -209,7 +219,8 @@
* @return <code>true</code> if the new listener is different than the
* previous <code>false</code> otherwise
*/
- private boolean setCurrentListener(TransferDropTargetListener listener, final DropTargetEvent event) {
+ private boolean setCurrentListener(TransferDropTargetListener listener,
+ final DropTargetEvent event) {
if (fCurrentListener == listener)
return false;
if (fCurrentListener != null) {
@@ -220,7 +231,7 @@
}
});
}
- fCurrentListener= listener;
+ fCurrentListener = listener;
if (fCurrentListener != null) {
SafeRunner.run(new SafeRunnable() {
@Override
@@ -235,42 +246,43 @@
/**
* Updates the current listener to one that can handle the drop. There can
* be many listeners and each listener may be able to handle many
- * <code>TransferData</code> types. The first listener found that can
- * handle a drop of one of the given <code>TransferData</code> types will
- * be selected. If no listener can handle the drag operation the
- * <code>event.detail</code> field is set to <code>DND.DROP_NONE</code>
- * to indicate an invalid drop.
+ * <code>TransferData</code> types. The first listener found that can handle
+ * a drop of one of the given <code>TransferData</code> types will be
+ * selected. If no listener can handle the drag operation the
+ * <code>event.detail</code> field is set to <code>DND.DROP_NONE</code> to
+ * indicate an invalid drop.
*
- * @param event the drop target event
+ * @param event
+ * the drop target event
*/
private void updateCurrentListener(DropTargetEvent event) {
- int originalDetail= event.detail;
+ int originalDetail = event.detail;
// Revert the detail to the "original" drop type that the User
// indicated. This is necessary because the previous listener
// may have changed the detail to something other than what the
// user indicated.
- event.detail= fOriginalDropType;
+ event.detail = fOriginalDropType;
- for (int i= 0; i < fListeners.length; i++) {
- TransferDropTargetListener listener= fListeners[i];
- TransferData dataType= getSupportedTransferType(event.dataTypes, listener);
+ for (int i = 0; i < fListeners.length; i++) {
+ TransferDropTargetListener listener = fListeners[i];
+ TransferData dataType = getSupportedTransferType(event.dataTypes,
+ listener);
if (dataType != null) {
- TransferData originalDataType= event.currentDataType;
+ TransferData originalDataType = event.currentDataType;
// set the data type supported by the drop listener
- event.currentDataType= dataType;
+ event.currentDataType = dataType;
if (listener.isEnabled(event)) {
// if the listener stays the same, set its previously
// determined
// event detail
if (!setCurrentListener(listener, event))
- event.detail= originalDetail;
+ event.detail = originalDetail;
return;
- } else {
- event.currentDataType= originalDataType;
}
+ event.currentDataType = originalDataType;
}
}
setCurrentListener(null, event);
- event.detail= DND.DROP_NONE;
+ event.detail = DND.DROP_NONE;
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/BracketInserter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/BracketInserter.java
index 17307e7..79dc130 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/BracketInserter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/BracketInserter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2017 IBM Corporation and others.
+ * Copyright (c) 2005, 2018 IBM Corporation 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
@@ -215,8 +215,8 @@
* @param offset
* @param partitioning
* @param contentTypes
- * acceptable content types, if empty only
- * IDocument.DEFAULT_CONTENT_TYPE is checked.
+ * acceptable content types, if empty only
+ * IDocument.DEFAULT_CONTENT_TYPE is checked.
* @return
* @throws BadLocationException
* @since 2.0
@@ -232,8 +232,7 @@
return true;
}
return false;
- } else {
- return IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType());
}
+ return IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType());
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/ScriptEditor.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/ScriptEditor.java
index ded861f..5ab24f0 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/ScriptEditor.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/ScriptEditor.java
@@ -1694,12 +1694,12 @@
// int style = cutDown ? SWT.NONE : (SWT.V_SCROLL | SWT.H_SCROLL);
// return new DefaultInformationControl(shell, SWT.RESIZE
// | SWT.TOOL, style, new HTMLTextPresenter(cutDown));
- if (BrowserInformationControl.isAvailable(shell))
+ if (BrowserInformationControl.isAvailable(shell)) {
return new BrowserInformationControl(shell,
JFaceResources.DIALOG_FONT, true);
- else
- return new DefaultInformationControl(shell,
- new HTMLTextPresenter(cutDown));
+ }
+ return new DefaultInformationControl(shell,
+ new HTMLTextPresenter(cutDown));
};
fInformationPresenter = new InformationPresenter(
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/SourceModuleDocumentProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/SourceModuleDocumentProvider.java
index bf3537c..1416395 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/SourceModuleDocumentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/SourceModuleDocumentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2017 IBM Corporation and others.
+ * Copyright (c) 2005, 2018 IBM Corporation 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
@@ -198,10 +198,10 @@
Annotation annotation = new Annotation(annotationType, false, null);
AnnotationPreference preference = lookup
.getAnnotationPreference(annotation);
- if (preference != null)
+ if (preference != null) {
return preference.getPresentationLayer() + 1;
- else
- return IAnnotationAccessExtension.DEFAULT_LAYER + 1;
+ }
+ return IAnnotationAccessExtension.DEFAULT_LAYER + 1;
}
private static Image fgQuickFixImage;
@@ -578,12 +578,11 @@
private boolean isScriptMarker(IMarker marker) {
if (problemFactory != null) {
return problemFactory.isValidMarker(marker);
- } else {
- return MarkerUtilities.isMarkerType(marker,
- DefaultProblem.MARKER_TYPE_PROBLEM)
- || MarkerUtilities.isMarkerType(marker,
- DefaultProblem.MARKER_TYPE_TASK);
}
+ return MarkerUtilities.isMarkerType(marker,
+ DefaultProblem.MARKER_TYPE_PROBLEM)
+ || MarkerUtilities.isMarkerType(marker,
+ DefaultProblem.MARKER_TYPE_TASK);
}
@Override
@@ -632,8 +631,9 @@
* Sets up the infrastructure necessary for problem reporting.
*
* @param insideReportingSequence
- * <code>true</code> if this method call is issued from
- * inside a reporting sequence
+ * <code>true</code> if this method
+ * call is issued from inside a
+ * reporting sequence
*/
private void internalBeginReporting(boolean insideReportingSequence) {
@@ -950,7 +950,7 @@
* Updates this model to the given marker deltas.
*
* @param markerDeltas
- * the array of marker deltas
+ * the array of marker deltas
*/
@Override
protected void update(IMarkerDelta[] markerDeltas) {
@@ -1150,7 +1150,7 @@
* Creates a source module from the given file.
*
* @param file
- * the file from which to create the source module
+ * the file from which to create the source module
*/
protected ISourceModule createSourceModule(IFile file) {
@@ -1306,9 +1306,10 @@
* monitor.
*
* @param monitor
- * the parent progress monitor
+ * the parent progress monitor
* @param ticks
- * the number of work ticks allocated from the parent monitor
+ * the number of work ticks allocated from the parent
+ * monitor
* @return the new sub-progress monitor
*/
private IProgressMonitor getSubProgressMonitor(IProgressMonitor monitor,
@@ -1358,10 +1359,6 @@
overwrite);
}
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.
- * DocumentProviderOperation#getSchedulingRule()
- */
@Override
public ISchedulingRule getSchedulingRule() {
@@ -1369,8 +1366,8 @@
IFile file = ((IFileEditorInput) info.fElement)
.getFile();
return computeSchedulingRule(file);
- } else
- return null;
+ }
+ return null;
}
};
}
@@ -1396,8 +1393,7 @@
Assert.isTrue(resource instanceof IFile);
- isSynchronized = resource
- .isSynchronized(IResource.DEPTH_ZERO);
+ isSynchronized = resource.isSynchronized(IResource.DEPTH_ZERO);
/*
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=98327 Make sure
* file gets save in commit() if the underlying file has been
@@ -1410,8 +1406,7 @@
// underlying resource has been deleted, just recreate
// file,
// ignore the rest
- createFileFromDocument(monitor, (IFile) resource,
- document);
+ createFileFromDocument(monitor, (IFile) resource, document);
return;
}
@@ -1604,9 +1599,10 @@
* Creates a fake compilation unit.
*
* @param element
- * the element
+ * the element
* @param setContents
- * tells whether to read and set the contents to the new CU
+ * tells whether to read and set the contents to the
+ * new CU
*
*/
private ISourceModule createFakeSourceModule(Object element,
@@ -1780,7 +1776,7 @@
* path.
*
* @param path
- * the path to match
+ * the path to match
* @return the matching script project or <code>null</code>
*
*/
@@ -1831,15 +1827,15 @@
* </p>
*
* @param info
- * compilation unit info
+ * compilation unit info
* @param changedRegions
- * the array with the changed regions
+ * the array with the changed regions
* @param listeners
- * the listeners to notify
+ * the listeners to notify
* @param monitor
- * the progress monitor
+ * the progress monitor
* @throws CoreException
- * if something goes wrong
+ * if something goes wrong
* @see IPostSaveListener
* @since 3.0
*/
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/selectionaction/GoToNextPreviousMemberAction.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/selectionaction/GoToNextPreviousMemberAction.java
index 703361e..a0dfca0 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/selectionaction/GoToNextPreviousMemberAction.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/selectionaction/GoToNextPreviousMemberAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -105,12 +105,12 @@
Integer oldOffset = Integer.valueOf(oldSourceRange.getOffset());
int index = Arrays.binarySearch(offsetArray, oldOffset);
- if (fIsGotoNext)
+ if (fIsGotoNext) {
return createNewSourceRange(
getNextOffset(index, offsetArray, oldOffset));
- else
- return createNewSourceRange(
- getPreviousOffset(index, offsetArray, oldOffset));
+ }
+ return createNewSourceRange(
+ getPreviousOffset(index, offsetArray, oldOffset));
} catch (ModelException e) {
DLTKUIPlugin.log(e); // dialog would be too heavy here
@@ -137,10 +137,10 @@
return offsetArray[0];
if (index == 0) {
- if (offsetArray.length != 1)
+ if (offsetArray.length != 1) {
return offsetArray[1];
- else
- return offsetArray[0];
+ }
+ return offsetArray[0];
}
if (index > 0) {
if (index == offsetArray.length - 1)
@@ -149,10 +149,10 @@
}
Assert.isTrue(index < -1);
int absIndex = Math.abs(index);
- if (absIndex > offsetArray.length)
+ if (absIndex > offsetArray.length) {
return oldOffset;
- else
- return offsetArray[absIndex - 1];
+ }
+ return offsetArray[absIndex - 1];
}
private static ISourceRange createNewSourceRange(Integer offset) {
@@ -199,7 +199,8 @@
}
private static void addOffset(List result, int offset) {
- if (offset >= 0)
+ if (offset >= 0) {
result.add(Integer.valueOf(offset));
+ }
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/semantic/highlighting/SemanticHighlightingReconciler.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/semantic/highlighting/SemanticHighlightingReconciler.java
index c758cd0..56b328c 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/semantic/highlighting/SemanticHighlightingReconciler.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/semantic/highlighting/SemanticHighlightingReconciler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -108,10 +108,10 @@
return;
// ensure at most one thread can be reconciling at any time
synchronized (fReconcileLock) {
- if (fIsReconciling)
+ if (fIsReconciling) {
return;
- else
- fIsReconciling = true;
+ }
+ fIsReconciling = true;
}
fJobPresenter = fPresenter;
fJobSemanticHighlightings = fSemanticHighlightings;
@@ -165,11 +165,11 @@
* Update the presentation.
*
* @param textPresentation
- * the text presentation
+ * the text presentation
* @param addedPositions
- * the added positions
+ * the added positions
* @param removedPositions
- * the removed positions
+ * the removed positions
*/
private void updatePresentation(TextPresentation textPresentation,
HighlightedPosition[] addedPositions,
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/CustomFiltersDialog.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/CustomFiltersDialog.java
index aad9836..44f4bb9 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/CustomFiltersDialog.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/CustomFiltersDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -288,10 +288,10 @@
@Override
public String getText(Object element) {
- if (element instanceof FilterDescriptor)
+ if (element instanceof FilterDescriptor) {
return ((FilterDescriptor) element).getName();
- else
- return null;
+ }
+ return null;
}
};
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/FilterDescriptor.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/FilterDescriptor.java
index d64d55d..68bf3ed 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/FilterDescriptor.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/FilterDescriptor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -148,12 +148,12 @@
public String getId() {
if (isPatternFilter()) {
String targetId = getTargetId();
- if (targetId == null)
+ if (targetId == null) {
return PATTERN_FILTER_ID_PREFIX + getPattern();
- else
- return targetId + PATTERN_FILTER_ID_PREFIX + getPattern();
- } else
- return fElement.getAttribute(ID_ATTRIBUTE);
+ }
+ return targetId + PATTERN_FILTER_ID_PREFIX + getPattern();
+ }
+ return fElement.getAttribute(ID_ATTRIBUTE);
}
/**
@@ -242,11 +242,11 @@
*/
@Override
public int compareTo(Object o) {
- if (o instanceof FilterDescriptor)
+ if (o instanceof FilterDescriptor) {
return Collator.getInstance().compare(getName(),
((FilterDescriptor) o).getName());
- else
- return Integer.MIN_VALUE;
+ }
+ return Integer.MIN_VALUE;
}
// ---- initialization ---------------------------------------------------
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/NoPackageContainingFoldersFilter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/NoPackageContainingFoldersFilter.java
index b834dc3..13374e6 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/NoPackageContainingFoldersFilter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/filters/NoPackageContainingFoldersFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -23,10 +23,10 @@
public boolean select(Viewer viewer, Object parent, Object element) {
if (element instanceof IFolder) {
try {
- if (containsPackage((IFolder)element))
+ if (containsPackage((IFolder) element)) {
return true;
- else
- return false;
+ }
+ return false;
} catch (CoreException e) {
return true;
}
@@ -36,12 +36,13 @@
}
private boolean containsPackage(IFolder folder) throws CoreException {
- IModelElement element= DLTKCore.create(folder);
+ IModelElement element = DLTKCore.create(folder);
if (element instanceof IScriptFolder)
return true;
- IResource[] resources= folder.members();
- for (int i= 0; i < resources.length; i++) {
- if (resources[i] instanceof IFolder && containsPackage((IFolder)resources[i]))
+ IResource[] resources = folder.members();
+ for (int i = 0; i < resources.length; i++) {
+ if (resources[i] instanceof IFolder
+ && containsPackage((IFolder) resources[i]))
return true;
}
return false;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ProjectFragmentProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ProjectFragmentProvider.java
index 1277e7d..51aba3d 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ProjectFragmentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ProjectFragmentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -252,21 +252,18 @@
IProjectFragment root = (IProjectFragment) parent;
if (root.isArchive()) {
return findNextLevelParentByElementName(fragment);
- } else {
+ }
- IResource resource = fragment.getUnderlyingResource();
- if ((resource != null)
- && (resource instanceof IFolder)) {
- IFolder folder = (IFolder) resource;
- IResource res = folder.getParent();
+ IResource resource = fragment.getUnderlyingResource();
+ if ((resource != null) && (resource instanceof IFolder)) {
+ IFolder folder = (IFolder) resource;
+ IResource res = folder.getParent();
- IModelElement el = DLTKCore.create(res);
- if (el != null) {
- return el;
- } else {
- return res;
- }
+ IModelElement el = DLTKCore.create(res);
+ if (el != null) {
+ return el;
}
+ return res;
}
return parent;
}
@@ -415,10 +412,10 @@
Object parent = findNextLevelParentByElementName(element);
if (parent instanceof IProjectFragment) {
IProjectFragment root = (IProjectFragment) parent;
- if (isRootProject(root))
+ if (isRootProject(root)) {
return root.getScriptProject();
- else
- return root;
+ }
+ return root;
}
Object grandParent = getParent(parent);
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ScriptExplorerContentProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ScriptExplorerContentProvider.java
index 8480dce..37f4deb 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ScriptExplorerContentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/navigator/ScriptExplorerContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -89,7 +89,8 @@
* Creates a new content provider for Java elements.
*
* @param provideMembers
- * if set, members of compilation units and class files are shown
+ * if set, members of compilation units and class
+ * files are shown
*/
public ScriptExplorerContentProvider(final boolean provideMembers) {
super(provideMembers);
@@ -472,12 +473,12 @@
* Returns the hierarchical packages inside a given fragment or root.
*
* @param parent
- * The parent package fragment root
+ * The parent package fragment root
* @param fragment
- * The package to get the children for or 'null' to get the
- * children of the root.
+ * The package to get the children for or 'null' to get
+ * the children of the root.
* @param result
- * Collection where the resulting elements are added
+ * Collection where the resulting elements are added
* @throws JavaModelException
*/
private void getHierarchicalPackageChildren(final IProjectFragment parent,
@@ -535,11 +536,11 @@
* Returns the hierarchical packages inside a given folder.
*
* @param folder
- * The parent folder
+ * The parent folder
* @param result
- * Collection where the resulting elements are added
+ * Collection where the resulting elements are added
* @throws CoreException
- * thrown when elements could not be accessed
+ * thrown when elements could not be accessed
*/
private void getHierarchicalPackagesInFolder(final IFolder folder,
final Collection<Object> result) throws CoreException {
@@ -644,14 +645,15 @@
* the tree is fully refreshed starting at this node.
*
* @param delta
- * the delta to process
+ * the delta to process
* @param runnables
- * the resulting view changes as runnables (type {@link Runnable}
- * )
+ * the resulting view changes as runnables (type
+ * {@link Runnable} )
* @return true is returned if the conclusion is to refresh a parent of an
* element. In that case no siblings need to be processed
* @throws JavaModelException
- * thrown when the access to an element failed
+ * thrown when the access to an element
+ * failed
*/
private boolean processDelta(final IModelElementDelta delta,
final Collection<Runnable> runnables) throws ModelException {
@@ -696,11 +698,10 @@
if (parent instanceof IProjectFragment) {
postRemove(element, runnables);
return false;
- } else {
- postRefresh(internalGetParent(parent), GRANT_PARENT,
- element, runnables);
- return true;
}
+ postRefresh(internalGetParent(parent), GRANT_PARENT,
+ element, runnables);
+ return true;
} else if (kind == IModelElementDelta.ADDED) {
final Object parent = getHierarchicalPackageParent(
(IScriptFolder) element);
@@ -708,15 +709,13 @@
if (fFoldPackages) {
postRefresh(parent, PARENT, element, runnables);
return true;
- } else {
- postAdd(parent, element, runnables);
- return false;
}
- } else {
- postRefresh(internalGetParent(parent), GRANT_PARENT,
- element, runnables);
- return true;
+ postAdd(parent, element, runnables);
+ return false;
}
+ postRefresh(internalGetParent(parent), GRANT_PARENT,
+ element, runnables);
+ return true;
}
handleAffectedChildren(delta, element, runnables);
return false;
@@ -824,9 +823,8 @@
}
}
return true;
- } else {
- postAdd(parent, element, runnables);
}
+ postAdd(parent, element, runnables);
}
if (elementType == IModelElement.SOURCE_MODULE
@@ -962,10 +960,10 @@
* Updates the package icon
*
* @param element
- * the element to update
+ * the element to update
* @param runnables
- * the resulting view changes as runnables (type {@link Runnable}
- * )
+ * the resulting view changes as runnables (type
+ * {@link Runnable} )
*/
private void postUpdateIcon(final IModelElement element,
final Collection<Runnable> runnables) {
@@ -977,12 +975,12 @@
* Process a resource delta.
*
* @param delta
- * the delta to process
+ * the delta to process
* @param parent
- * the parent
+ * the parent
* @param runnables
- * the resulting view changes as runnables (type {@link Runnable}
- * )
+ * the resulting view changes as runnables (type
+ * {@link Runnable} )
* @return true if the parent got refreshed
*/
private boolean processResourceDelta(final IResourceDelta delta,
@@ -1006,10 +1004,9 @@
ScriptExplorerContentProvider.PARENT, parent,
runnables);
return true;
- } else {
- postRemove(resource, runnables);
- return false;
}
+ postRemove(resource, runnables);
+ return false;
}
if ((status & IResourceDelta.ADDED) != 0) {
if (parent instanceof IScriptFolder) {
@@ -1019,10 +1016,9 @@
ScriptExplorerContentProvider.PARENT, parent,
runnables);
return true;
- } else {
- postAdd(parent, resource, runnables);
- return false;
}
+ postAdd(parent, resource, runnables);
+ return false;
}
if ((status & IResourceDelta.CHANGED) != 0) {
if ((flags & IResourceDelta.TYPE) != 0) {
@@ -1085,12 +1081,13 @@
* Can be implemented by subclasses to add additional elements to refresh
*
* @param toRefresh
- * the elements to refresh
+ * the elements to refresh
* @param relation
- * the relation to the affected element ({@link #GRANT_PARENT},
- * {@link #PARENT}, {@link #ORIGINAL}, {@link #PROJECT})
+ * the relation to the affected element
+ * ({@link #GRANT_PARENT}, {@link #PARENT},
+ * {@link #ORIGINAL}, {@link #PROJECT})
* @param affectedElement
- * the affected element
+ * the affected element
*/
protected void augmentElementToRefresh(final List<Object> toRefresh,
final int relation, final Object affectedElement) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/CustomHashtable.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/CustomHashtable.java
index 532a813..d5a4219 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/CustomHashtable.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/CustomHashtable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -15,390 +15,404 @@
/**
* CustomHashtable associates keys with values. Keys and values cannot be null.
- * The size of the Hashtable is the number of key/value pairs it contains.
- * The capacity is the number of key/value pairs the Hashtable can hold.
- * The load factor is a float value which determines how full the Hashtable
- * gets before expanding the capacity. If the load factor of the Hashtable
- * is exceeded, the capacity is doubled.
+ * The size of the Hashtable is the number of key/value pairs it contains. The
+ * capacity is the number of key/value pairs the Hashtable can hold. The load
+ * factor is a float value which determines how full the Hashtable gets before
+ * expanding the capacity. If the load factor of the Hashtable is exceeded, the
+ * capacity is doubled.
* <p>
* CustomHashtable allows a custom comparator and hash code provider.
*/
/* package */final class CustomHashtable {
- /**
- * HashMapEntry is an internal class which is used to hold the entries of a Hashtable.
- */
- private static class HashMapEntry {
- Object key, value;
+ /**
+ * HashMapEntry is an internal class which is used to hold the entries of a
+ * Hashtable.
+ */
+ private static class HashMapEntry {
+ Object key, value;
- HashMapEntry next;
+ HashMapEntry next;
- HashMapEntry(Object theKey, Object theValue) {
- key = theKey;
- value = theValue;
- }
- }
+ HashMapEntry(Object theKey, Object theValue) {
+ key = theKey;
+ value = theValue;
+ }
+ }
- private static final class EmptyEnumerator implements Enumeration {
- @Override
+ private static final class EmptyEnumerator implements Enumeration {
+ @Override
public boolean hasMoreElements() {
- return false;
- }
+ return false;
+ }
- @Override
+ @Override
public Object nextElement() {
- throw new NoSuchElementException();
- }
- }
+ throw new NoSuchElementException();
+ }
+ }
- private class HashEnumerator implements Enumeration {
- boolean key;
+ private class HashEnumerator implements Enumeration {
+ boolean key;
- int start;
+ int start;
- HashMapEntry entry;
+ HashMapEntry entry;
- HashEnumerator(boolean isKey) {
- key = isKey;
- start = firstSlot;
- }
+ HashEnumerator(boolean isKey) {
+ key = isKey;
+ start = firstSlot;
+ }
- @Override
+ @Override
public boolean hasMoreElements() {
- if (entry != null)
- return true;
- while (start <= lastSlot)
- if (elementData[start++] != null) {
- entry = elementData[start - 1];
- return true;
- }
- return false;
- }
+ if (entry != null)
+ return true;
+ while (start <= lastSlot)
+ if (elementData[start++] != null) {
+ entry = elementData[start - 1];
+ return true;
+ }
+ return false;
+ }
- @Override
+ @Override
public Object nextElement() {
- if (hasMoreElements()) {
- Object result = key ? entry.key : entry.value;
- entry = entry.next;
- return result;
- } else
- throw new NoSuchElementException();
- }
- }
+ if (hasMoreElements()) {
+ Object result = key ? entry.key : entry.value;
+ entry = entry.next;
+ return result;
+ }
+ throw new NoSuchElementException();
+ }
+ }
- transient int elementCount;
+ transient int elementCount;
- transient HashMapEntry[] elementData;
+ transient HashMapEntry[] elementData;
- private float loadFactor;
+ private float loadFactor;
- private int threshold;
+ private int threshold;
- transient int firstSlot = 0;
+ transient int firstSlot = 0;
- transient int lastSlot = -1;
+ transient int lastSlot = -1;
- transient private IElementComparer comparer;
+ transient private IElementComparer comparer;
- private static final EmptyEnumerator emptyEnumerator = new EmptyEnumerator();
+ private static final EmptyEnumerator emptyEnumerator = new EmptyEnumerator();
- /**
- * The default capacity used when not specified in the constructor.
- */
- public static final int DEFAULT_CAPACITY = 13;
+ /**
+ * The default capacity used when not specified in the constructor.
+ */
+ public static final int DEFAULT_CAPACITY = 13;
- /**
- * Constructs a new Hashtable using the default capacity
- * and load factor.
- */
- public CustomHashtable() {
- this(13);
- }
+ /**
+ * Constructs a new Hashtable using the default capacity and load factor.
+ */
+ public CustomHashtable() {
+ this(13);
+ }
- /**
- * Constructs a new Hashtable using the specified capacity
- * and the default load factor.
- *
- * @param capacity the initial capacity
- */
- public CustomHashtable(int capacity) {
- this(capacity, null);
- }
+ /**
+ * Constructs a new Hashtable using the specified capacity and the default
+ * load factor.
+ *
+ * @param capacity
+ * the initial capacity
+ */
+ public CustomHashtable(int capacity) {
+ this(capacity, null);
+ }
- /**
- * Constructs a new hash table with the default capacity and the given
- * element comparer.
- *
- * @param comparer the element comparer to use to compare keys and obtain
- * hash codes for keys, or <code>null</code> to use the normal
- * <code>equals</code> and <code>hashCode</code> methods
- */
- public CustomHashtable(IElementComparer comparer) {
- this(DEFAULT_CAPACITY, comparer);
- }
+ /**
+ * Constructs a new hash table with the default capacity and the given
+ * element comparer.
+ *
+ * @param comparer
+ * the element comparer to use to compare keys and
+ * obtain hash codes for keys, or <code>null</code> to
+ * use the normal <code>equals</code> and
+ * <code>hashCode</code> methods
+ */
+ public CustomHashtable(IElementComparer comparer) {
+ this(DEFAULT_CAPACITY, comparer);
+ }
- /**
- * Constructs a new hash table with the given capacity and the given
- * element comparer.
- *
- * @param capacity the maximum number of elements that can be added without
- * rehashing
- * @param comparer the element comparer to use to compare keys and obtain
- * hash codes for keys, or <code>null</code> to use the normal
- * <code>equals</code> and <code>hashCode</code> methods
- */
- public CustomHashtable(int capacity, IElementComparer comparer) {
- if (capacity >= 0) {
- elementCount = 0;
- elementData = new HashMapEntry[capacity == 0 ? 1 : capacity];
- firstSlot = elementData.length;
- loadFactor = 0.75f;
- computeMaxSize();
- } else
- throw new IllegalArgumentException();
- this.comparer = comparer;
- }
+ /**
+ * Constructs a new hash table with the given capacity and the given element
+ * comparer.
+ *
+ * @param capacity
+ * the maximum number of elements that can be added
+ * without rehashing
+ * @param comparer
+ * the element comparer to use to compare keys and
+ * obtain hash codes for keys, or <code>null</code> to
+ * use the normal <code>equals</code> and
+ * <code>hashCode</code> methods
+ */
+ public CustomHashtable(int capacity, IElementComparer comparer) {
+ if (capacity >= 0) {
+ elementCount = 0;
+ elementData = new HashMapEntry[capacity == 0 ? 1 : capacity];
+ firstSlot = elementData.length;
+ loadFactor = 0.75f;
+ computeMaxSize();
+ } else
+ throw new IllegalArgumentException();
+ this.comparer = comparer;
+ }
- /**
- * Constructs a new hash table with enough capacity to hold all keys in the
- * given hash table, then adds all key/value pairs in the given hash table
- * to the new one, using the given element comparer.
- *
- * @param table the hash table to add from
- * @param comparer the element comparer to use to compare keys and obtain
- * hash codes for keys, or <code>null</code> to use the normal
- * <code>equals</code> and <code>hashCode</code> methods
- */
- public CustomHashtable(CustomHashtable table, IElementComparer comparer) {
- this(table.size() * 2, comparer);
- for (int i = table.elementData.length; --i >= 0;) {
- HashMapEntry entry = table.elementData[i];
- while (entry != null) {
- put(entry.key, entry.value);
- entry = entry.next;
- }
- }
- }
+ /**
+ * Constructs a new hash table with enough capacity to hold all keys in the
+ * given hash table, then adds all key/value pairs in the given hash table
+ * to the new one, using the given element comparer.
+ *
+ * @param table
+ * the hash table to add from
+ * @param comparer
+ * the element comparer to use to compare keys and
+ * obtain hash codes for keys, or <code>null</code> to
+ * use the normal <code>equals</code> and
+ * <code>hashCode</code> methods
+ */
+ public CustomHashtable(CustomHashtable table, IElementComparer comparer) {
+ this(table.size() * 2, comparer);
+ for (int i = table.elementData.length; --i >= 0;) {
+ HashMapEntry entry = table.elementData[i];
+ while (entry != null) {
+ put(entry.key, entry.value);
+ entry = entry.next;
+ }
+ }
+ }
- private void computeMaxSize() {
- threshold = (int) (elementData.length * loadFactor);
- }
+ private void computeMaxSize() {
+ threshold = (int) (elementData.length * loadFactor);
+ }
- /**
- * Answers if this Hashtable contains the specified object as a key
- * of one of the key/value pairs.
- *
- * @param key the object to look for as a key in this Hashtable
- * @return true if object is a key in this Hashtable, false otherwise
- */
- public boolean containsKey(Object key) {
- return getEntry(key) != null;
- }
+ /**
+ * Answers if this Hashtable contains the specified object as a key of one
+ * of the key/value pairs.
+ *
+ * @param key
+ * the object to look for as a key in this Hashtable
+ * @return true if object is a key in this Hashtable, false otherwise
+ */
+ public boolean containsKey(Object key) {
+ return getEntry(key) != null;
+ }
- /**
- * Answers an Enumeration on the values of this Hashtable. The
- * results of the Enumeration may be affected if the contents
- * of this Hashtable are modified.
- *
- * @return an Enumeration of the values of this Hashtable
- */
- public Enumeration elements() {
- if (elementCount == 0)
- return emptyEnumerator;
- return new HashEnumerator(false);
- }
+ /**
+ * Answers an Enumeration on the values of this Hashtable. The results of
+ * the Enumeration may be affected if the contents of this Hashtable are
+ * modified.
+ *
+ * @return an Enumeration of the values of this Hashtable
+ */
+ public Enumeration elements() {
+ if (elementCount == 0)
+ return emptyEnumerator;
+ return new HashEnumerator(false);
+ }
- /**
- * Answers the value associated with the specified key in
- * this Hashtable.
- *
- * @param key the key of the value returned
- * @return the value associated with the specified key, null if the specified key
- * does not exist
- */
- public Object get(Object key) {
- int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
- HashMapEntry entry = elementData[index];
- while (entry != null) {
- if (keyEquals(key, entry.key))
- return entry.value;
- entry = entry.next;
- }
- return null;
- }
+ /**
+ * Answers the value associated with the specified key in this Hashtable.
+ *
+ * @param key
+ * the key of the value returned
+ * @return the value associated with the specified key, null if the
+ * specified key does not exist
+ */
+ public Object get(Object key) {
+ int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
+ HashMapEntry entry = elementData[index];
+ while (entry != null) {
+ if (keyEquals(key, entry.key))
+ return entry.value;
+ entry = entry.next;
+ }
+ return null;
+ }
- private HashMapEntry getEntry(Object key) {
- int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
- HashMapEntry entry = elementData[index];
- while (entry != null) {
- if (keyEquals(key, entry.key))
- return entry;
- entry = entry.next;
- }
- return null;
- }
+ private HashMapEntry getEntry(Object key) {
+ int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
+ HashMapEntry entry = elementData[index];
+ while (entry != null) {
+ if (keyEquals(key, entry.key))
+ return entry;
+ entry = entry.next;
+ }
+ return null;
+ }
- /**
- * Answers the hash code for the given key.
- */
- private int hashCode(Object key) {
- if (comparer == null)
- return key.hashCode();
- else
- return comparer.hashCode(key);
- }
+ /**
+ * Answers the hash code for the given key.
+ */
+ private int hashCode(Object key) {
+ if (comparer == null) {
+ return key.hashCode();
+ }
+ return comparer.hashCode(key);
+ }
- /**
- * Compares two keys for equality.
- */
- private boolean keyEquals(Object a, Object b) {
- if (comparer == null)
- return a.equals(b);
- else
- return comparer.equals(a, b);
- }
+ /**
+ * Compares two keys for equality.
+ */
+ private boolean keyEquals(Object a, Object b) {
+ if (comparer == null) {
+ return a.equals(b);
+ }
+ return comparer.equals(a, b);
+ }
- /**
- * Answers an Enumeration on the keys of this Hashtable. The
- * results of the Enumeration may be affected if the contents
- * of this Hashtable are modified.
- *
- * @return an Enumeration of the keys of this Hashtable
- */
- public Enumeration keys() {
- if (elementCount == 0)
- return emptyEnumerator;
- return new HashEnumerator(true);
- }
+ /**
+ * Answers an Enumeration on the keys of this Hashtable. The results of the
+ * Enumeration may be affected if the contents of this Hashtable are
+ * modified.
+ *
+ * @return an Enumeration of the keys of this Hashtable
+ */
+ public Enumeration keys() {
+ if (elementCount == 0)
+ return emptyEnumerator;
+ return new HashEnumerator(true);
+ }
- /**
- * Associate the specified value with the specified key in this Hashtable.
- * If the key already exists, the old value is replaced. The key and value
- * cannot be null.
- *
- * @param key the key to add
- * @param value the value to add
- * @return the old value associated with the specified key, null if the key did
- * not exist
- */
- public Object put(Object key, Object value) {
- if (key != null && value != null) {
- int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
- HashMapEntry entry = elementData[index];
- while (entry != null && !keyEquals(key, entry.key))
- entry = entry.next;
- if (entry == null) {
- if (++elementCount > threshold) {
- rehash();
- index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
- }
- if (index < firstSlot)
- firstSlot = index;
- if (index > lastSlot)
- lastSlot = index;
- entry = new HashMapEntry(key, value);
- entry.next = elementData[index];
- elementData[index] = entry;
- return null;
- }
- Object result = entry.value;
- entry.key = key; // important to avoid hanging onto keys that are equal but "old" -- see bug 30607
- entry.value = value;
- return result;
- } else
- throw new NullPointerException();
- }
+ /**
+ * Associate the specified value with the specified key in this Hashtable.
+ * If the key already exists, the old value is replaced. The key and value
+ * cannot be null.
+ *
+ * @param key
+ * the key to add
+ * @param value
+ * the value to add
+ * @return the old value associated with the specified key, null if the key
+ * did not exist
+ */
+ public Object put(Object key, Object value) {
+ if (key != null && value != null) {
+ int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
+ HashMapEntry entry = elementData[index];
+ while (entry != null && !keyEquals(key, entry.key))
+ entry = entry.next;
+ if (entry == null) {
+ if (++elementCount > threshold) {
+ rehash();
+ index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
+ }
+ if (index < firstSlot)
+ firstSlot = index;
+ if (index > lastSlot)
+ lastSlot = index;
+ entry = new HashMapEntry(key, value);
+ entry.next = elementData[index];
+ elementData[index] = entry;
+ return null;
+ }
+ Object result = entry.value;
+ entry.key = key; // important to avoid hanging onto keys that are
+ // equal but "old" -- see bug 30607
+ entry.value = value;
+ return result;
+ }
+ throw new NullPointerException();
+ }
- /**
- * Increases the capacity of this Hashtable. This method is sent when
- * the size of this Hashtable exceeds the load factor.
- */
- private void rehash() {
- int length = elementData.length << 1;
- if (length == 0)
- length = 1;
- firstSlot = length;
- lastSlot = -1;
- HashMapEntry[] newData = new HashMapEntry[length];
- for (int i = elementData.length; --i >= 0;) {
- HashMapEntry entry = elementData[i];
- while (entry != null) {
- int index = (hashCode(entry.key) & 0x7FFFFFFF) % length;
- if (index < firstSlot)
- firstSlot = index;
- if (index > lastSlot)
- lastSlot = index;
- HashMapEntry next = entry.next;
- entry.next = newData[index];
- newData[index] = entry;
- entry = next;
- }
- }
- elementData = newData;
- computeMaxSize();
- }
+ /**
+ * Increases the capacity of this Hashtable. This method is sent when the
+ * size of this Hashtable exceeds the load factor.
+ */
+ private void rehash() {
+ int length = elementData.length << 1;
+ if (length == 0)
+ length = 1;
+ firstSlot = length;
+ lastSlot = -1;
+ HashMapEntry[] newData = new HashMapEntry[length];
+ for (int i = elementData.length; --i >= 0;) {
+ HashMapEntry entry = elementData[i];
+ while (entry != null) {
+ int index = (hashCode(entry.key) & 0x7FFFFFFF) % length;
+ if (index < firstSlot)
+ firstSlot = index;
+ if (index > lastSlot)
+ lastSlot = index;
+ HashMapEntry next = entry.next;
+ entry.next = newData[index];
+ newData[index] = entry;
+ entry = next;
+ }
+ }
+ elementData = newData;
+ computeMaxSize();
+ }
- /**
- * Remove the key/value pair with the specified key from this Hashtable.
- *
- * @param key the key to remove
- * @return the value associated with the specified key, null if the specified key
- * did not exist
- */
- public Object remove(Object key) {
- HashMapEntry last = null;
- int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
- HashMapEntry entry = elementData[index];
- while (entry != null && !keyEquals(key, entry.key)) {
- last = entry;
- entry = entry.next;
- }
- if (entry != null) {
- if (last == null)
- elementData[index] = entry.next;
- else
- last.next = entry.next;
- elementCount--;
- return entry.value;
- }
- return null;
- }
+ /**
+ * Remove the key/value pair with the specified key from this Hashtable.
+ *
+ * @param key
+ * the key to remove
+ * @return the value associated with the specified key, null if the
+ * specified key did not exist
+ */
+ public Object remove(Object key) {
+ HashMapEntry last = null;
+ int index = (hashCode(key) & 0x7FFFFFFF) % elementData.length;
+ HashMapEntry entry = elementData[index];
+ while (entry != null && !keyEquals(key, entry.key)) {
+ last = entry;
+ entry = entry.next;
+ }
+ if (entry != null) {
+ if (last == null)
+ elementData[index] = entry.next;
+ else
+ last.next = entry.next;
+ elementCount--;
+ return entry.value;
+ }
+ return null;
+ }
- /**
- * Answers the number of key/value pairs in this Hashtable.
- *
- * @return the number of key/value pairs in this Hashtable
- */
- public int size() {
- return elementCount;
- }
+ /**
+ * Answers the number of key/value pairs in this Hashtable.
+ *
+ * @return the number of key/value pairs in this Hashtable
+ */
+ public int size() {
+ return elementCount;
+ }
- /**
- * Answers the string representation of this Hashtable.
- *
- * @return the string representation of this Hashtable
- */
- @Override
+ /**
+ * Answers the string representation of this Hashtable.
+ *
+ * @return the string representation of this Hashtable
+ */
+ @Override
public String toString() {
- if (size() == 0)
- return "{}"; //$NON-NLS-1$
+ if (size() == 0)
+ return "{}"; //$NON-NLS-1$
- StringBuffer buffer = new StringBuffer();
- buffer.append('{');
- for (int i = elementData.length; --i >= 0;) {
- HashMapEntry entry = elementData[i];
- while (entry != null) {
- buffer.append(entry.key);
- buffer.append('=');
- buffer.append(entry.value);
- buffer.append(", "); //$NON-NLS-1$
- entry = entry.next;
- }
- }
- // Remove the last ", "
- if (elementCount > 0)
- buffer.setLength(buffer.length() - 2);
- buffer.append('}');
- return buffer.toString();
- }
+ StringBuffer buffer = new StringBuffer();
+ buffer.append('{');
+ for (int i = elementData.length; --i >= 0;) {
+ HashMapEntry entry = elementData[i];
+ while (entry != null) {
+ buffer.append(entry.key);
+ buffer.append('=');
+ buffer.append(entry.value);
+ buffer.append(", "); //$NON-NLS-1$
+ entry = entry.next;
+ }
+ }
+ // Remove the last ", "
+ if (elementCount > 0)
+ buffer.setLength(buffer.length() - 2);
+ buffer.append('}');
+ return buffer.toString();
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/LayoutActionGroup.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/LayoutActionGroup.java
index b97ec27..9ccd4d4 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/LayoutActionGroup.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/LayoutActionGroup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -21,13 +21,12 @@
/**
* Adds view menus to switch between flat and hierarchical layout.
- *
- *
*/
public class LayoutActionGroup extends MultiActionGroup {
LayoutActionGroup(ScriptExplorerPart packageExplorer) {
- super(createActions(packageExplorer), getSelectedState(packageExplorer));
+ super(createActions(packageExplorer),
+ getSelectedState(packageExplorer));
}
@Override
@@ -49,27 +48,27 @@
viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
viewMenu.add(marker);
viewMenu.appendToGroup(layoutGroupName, layoutSubMenu);
- viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS
- + "-end"));//$NON-NLS-1$
+ viewMenu.add(
+ new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end"));//$NON-NLS-1$
addActions(layoutSubMenu);
}
static int getSelectedState(ScriptExplorerPart packageExplorer) {
- if (packageExplorer.isFlatLayout())
+ if (packageExplorer.isFlatLayout()) {
return 0;
- else
- return 1;
+ }
+ return 1;
}
static IAction[] createActions(ScriptExplorerPart packageExplorer) {
IAction flatLayoutAction = new LayoutAction(packageExplorer, true);
- flatLayoutAction
- .setText(ScriptMessages.LayoutActionGroup_flatLayoutAction_label);
+ flatLayoutAction.setText(
+ ScriptMessages.LayoutActionGroup_flatLayoutAction_label);
DLTKPluginImages.setLocalImageDescriptors(flatLayoutAction,
"flatLayout.png"); //$NON-NLS-1$
IAction hierarchicalLayout = new LayoutAction(packageExplorer, false);
- hierarchicalLayout
- .setText(ScriptMessages.LayoutActionGroup_hierarchicalLayoutAction_label);
+ hierarchicalLayout.setText(
+ ScriptMessages.LayoutActionGroup_hierarchicalLayoutAction_label);
DLTKPluginImages.setLocalImageDescriptors(hierarchicalLayout,
"hierarchicalLayout.png"); //$NON-NLS-1$
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/ScriptExplorerPart.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/ScriptExplorerPart.java
index b16f636..212378d 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/ScriptExplorerPart.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/ScriptExplorerPart.java
@@ -1095,9 +1095,8 @@
je2 = DLTKCore.create(r);
if (je2 != null && je2.exists()) {
return je2;
- } else {
- return r;
}
+ return r;
}
}
return original;
@@ -1190,9 +1189,8 @@
private int getLayoutAsInt() {
if (fIsCurrentLayoutFlat) {
return ScriptExplorerPart.FLAT_LAYOUT;
- } else {
- return ScriptExplorerPart.HIERARCHICAL_LAYOUT;
}
+ return ScriptExplorerPart.HIERARCHICAL_LAYOUT;
}
private void restoreFilterAndSorter() {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/SelectionTransferDropAdapter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/SelectionTransferDropAdapter.java
index 58a96a0..005db32 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/SelectionTransferDropAdapter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/SelectionTransferDropAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -211,11 +211,9 @@
ScriptMessages.SelectionTransferDropAdapter_error_title,
ScriptMessages.SelectionTransferDropAdapter_error_message);
} catch (InvocationTargetException e) {
- ExceptionHandler
- .handle(
- e,
- RefactoringMessages.OpenRefactoringWizardAction_refactoring,
- RefactoringMessages.OpenRefactoringWizardAction_exception);
+ ExceptionHandler.handle(e,
+ RefactoringMessages.OpenRefactoringWizardAction_refactoring,
+ RefactoringMessages.OpenRefactoringWizardAction_exception);
} catch (InterruptedException e) {
// ok
}
@@ -239,9 +237,9 @@
private int handleValidateMove(Object target) throws ModelException {
if (fMoveProcessor == null) {
- IMovePolicy policy = ReorgPolicyFactory.createMovePolicy(ReorgUtils
- .getResources(fElements), ReorgUtils
- .getModelElements(fElements));
+ IMovePolicy policy = ReorgPolicyFactory.createMovePolicy(
+ ReorgUtils.getResources(fElements),
+ ReorgUtils.getModelElements(fElements));
if (policy.canEnable())
fMoveProcessor = new ScriptMoveProcessor(policy);
}
@@ -298,10 +296,11 @@
if (fCopyProcessor == null) {
final ICopyPolicy policy = ReorgPolicyFactory.createCopyPolicy(
- ReorgUtils.getResources(fElements), ReorgUtils
- .getModelElements(fElements));
- fCopyProcessor = policy.canEnable() ? new ScriptCopyProcessor(
- policy) : null;
+ ReorgUtils.getResources(fElements),
+ ReorgUtils.getModelElements(fElements));
+ fCopyProcessor = policy.canEnable()
+ ? new ScriptCopyProcessor(policy)
+ : null;
}
if (!canCopyElements())
@@ -357,15 +356,11 @@
return getViewer().getControl().getShell();
}
- /**
- * {@inheritDoc}
- */
@Override
protected int getCurrentLocation() {
if (getFeedbackEnabled()) {
return super.getCurrentLocation();
- } else {
- return LOCATION_ON;
}
+ return LOCATION_ON;
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/WorkingSetDropAdapter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/WorkingSetDropAdapter.java
index bd483a3..db42d55 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/WorkingSetDropAdapter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/WorkingSetDropAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -127,46 +127,42 @@
return DND.DROP_MOVE;
}
return DND.DROP_NONE;
- } else {
- if (isOthersWorkingSet(fWorkingSet) && operation == DND.DROP_COPY)
- return DND.DROP_NONE;
+ }
+ if (isOthersWorkingSet(fWorkingSet) && operation == DND.DROP_COPY)
+ return DND.DROP_NONE;
- List realScriptElements = new ArrayList();
- List realResource = new ArrayList();
- ReorgUtils.splitIntoModelElementsAndResources(fElementsToAdds,
- realScriptElements, realResource);
- if (fElementsToAdds.length != realScriptElements.size()
- + realResource.size())
+ List realScriptElements = new ArrayList();
+ List realResource = new ArrayList();
+ ReorgUtils.splitIntoModelElementsAndResources(fElementsToAdds,
+ realScriptElements, realResource);
+ if (fElementsToAdds.length != realScriptElements.size()
+ + realResource.size())
+ return DND.DROP_NONE;
+ for (Iterator iter = realScriptElements.iterator(); iter.hasNext();) {
+ IModelElement element = (IModelElement) iter.next();
+ if (ReorgUtils.containsElementOrParent(fCurrentElements, element))
return DND.DROP_NONE;
- for (Iterator iter = realScriptElements.iterator(); iter
- .hasNext();) {
- IModelElement element = (IModelElement) iter.next();
- if (ReorgUtils.containsElementOrParent(fCurrentElements,
- element))
- return DND.DROP_NONE;
- }
- for (Iterator iter = realResource.iterator(); iter.hasNext();) {
- IResource element = (IResource) iter.next();
- if (ReorgUtils.containsElementOrParent(fCurrentElements,
- element))
- return DND.DROP_NONE;
- }
- if (!(fSelection instanceof ITreeSelection)) {
+ }
+ for (Iterator iter = realResource.iterator(); iter.hasNext();) {
+ IResource element = (IResource) iter.next();
+ if (ReorgUtils.containsElementOrParent(fCurrentElements, element))
+ return DND.DROP_NONE;
+ }
+ if (!(fSelection instanceof ITreeSelection)) {
+ return DND.DROP_COPY;
+ }
+ ITreeSelection treeSelection = (ITreeSelection) fSelection;
+ TreePath[] paths = treeSelection.getPaths();
+ for (int i = 0; i < paths.length; i++) {
+ TreePath path = paths[i];
+ if (path.getSegmentCount() != 2)
return DND.DROP_COPY;
- }
- ITreeSelection treeSelection = (ITreeSelection) fSelection;
- TreePath[] paths = treeSelection.getPaths();
- for (int i = 0; i < paths.length; i++) {
- TreePath path = paths[i];
- if (path.getSegmentCount() != 2)
- return DND.DROP_COPY;
- if (!(path.getSegment(0) instanceof IWorkingSet))
- return DND.DROP_COPY;
- if (paths.length == 1) {
- IWorkingSet ws = (IWorkingSet) path.getSegment(0);
- if (WorkingSetIDs.OTHERS.equals(ws.getId()))
- return DND.DROP_MOVE;
- }
+ if (!(path.getSegment(0) instanceof IWorkingSet))
+ return DND.DROP_COPY;
+ if (paths.length == 1) {
+ IWorkingSet ws = (IWorkingSet) path.getSegment(0);
+ if (WorkingSetIDs.OTHERS.equals(ws.getId()))
+ return DND.DROP_MOVE;
}
}
if (operation == DND.DROP_DEFAULT)
@@ -302,9 +298,6 @@
fLocation = location;
}
- /**
- * {@inheritDoc}
- */
@Override
protected int getCurrentLocation() {
if (fLocation == -1)
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchEditorOpener.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchEditorOpener.java
index c850153..df4811c 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchEditorOpener.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchEditorOpener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -91,8 +91,8 @@
private ReusedEditorWatcher fReusedEditorWatcher;
- public IEditorPart openElement(Object element) throws PartInitException,
- ModelException {
+ public IEditorPart openElement(Object element)
+ throws PartInitException, ModelException {
IWorkbenchPage wbPage = DLTKUIPlugin.getActivePage();
final IEditorPart editor;
if (NewSearchUI.reuseEditor())
@@ -104,8 +104,8 @@
return editor;
}
- public IEditorPart openMatch(Match match) throws PartInitException,
- ModelException {
+ public IEditorPart openMatch(Match match)
+ throws PartInitException, ModelException {
Object element = getElementToOpen(match);
return openElement(element);
}
@@ -131,7 +131,8 @@
} else if (module instanceof SourceModule) {
String editorID = getEditorID(module);
IFile file = getFile(element);
- return showInEditor(wbPage, new FileEditorInput(file), editorID);
+ return showInEditor(wbPage, new FileEditorInput(file),
+ editorID);
}
}
@@ -159,12 +160,12 @@
private String getEditorID(IFile file) throws PartInitException {
IEditorDescriptor desc = null;
- if (desc == null)
+ if (desc == null) {
return DLTKUIPlugin.getDefault().getWorkbench().getEditorRegistry()
.findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID)
.getId();
- else
- return desc.getId();
+ }
+ return desc.getId();
}
private String getEditorID(IModelElement module) throws PartInitException {
@@ -182,9 +183,8 @@
return DLTKUIPlugin.getDefault().getWorkbench().getEditorRegistry()
.findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID)
.getId();
- } else {
- return desc.getId();
}
+ return desc.getId();
}
private boolean isPinned(IEditorPart editor) {
@@ -238,8 +238,8 @@
else
setReusedEditor(null);
} catch (PartInitException ex) {
- MessageDialog.openError(DLTKUIPlugin
- .getActiveWorkbenchShell(),
+ MessageDialog.openError(
+ DLTKUIPlugin.getActiveWorkbenchShell(),
SearchMessages.Search_Error_openEditor_title,
SearchMessages.Search_Error_openEditor_message);
return null;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchQuery.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchQuery.java
index 735cdaf..3c375e5 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchQuery.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchQuery.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -41,10 +41,9 @@
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.search.ui.text.Match;
-
public class DLTKSearchQuery implements ISearchQuery {
- private static final String PERF_SEARCH_PARTICIPANT= "org.eclipse.dltk.ui/perf/search/participants"; //$NON-NLS-1$
+ private static final String PERF_SEARCH_PARTICIPANT = "org.eclipse.dltk.ui/perf/search/participants"; //$NON-NLS-1$
private ISearchResult fResult;
private final QuerySpecification fPatternData;
@@ -53,7 +52,7 @@
if (data == null) {
throw new IllegalArgumentException("data must not be null"); //$NON-NLS-1$
}
- fPatternData= data;
+ fPatternData = data;
}
private static class SearchRequestor implements ISearchRequestor {
@@ -62,108 +61,150 @@
@Override
public void reportMatch(Match match) {
- IMatchPresentation participant= fParticipant.getUIParticipant();
- if (participant == null || match.getElement() instanceof IModelElement || match.getElement() instanceof IResource) {
+ IMatchPresentation participant = fParticipant.getUIParticipant();
+ if (participant == null
+ || match.getElement() instanceof IModelElement
+ || match.getElement() instanceof IResource) {
fSearchResult.addMatch(match);
} else {
fSearchResult.addMatch(match, participant);
}
}
- protected SearchRequestor(IQueryParticipant participant, DLTKSearchResult result) {
+ protected SearchRequestor(IQueryParticipant participant,
+ DLTKSearchResult result) {
super();
- fParticipant= participant;
- fSearchResult= result;
+ fParticipant = participant;
+ fSearchResult = result;
}
}
@Override
public IStatus run(IProgressMonitor monitor) {
- final DLTKSearchResult textResult= (DLTKSearchResult) getSearchResult();
+ final DLTKSearchResult textResult = (DLTKSearchResult) getSearchResult();
textResult.removeAll();
// Don't need to pass in working copies in 3.0 here
- SearchEngine engine= new SearchEngine();
+ SearchEngine engine = new SearchEngine();
try {
- int totalTicks= 1000;
- IProject[] projects= DLTKSearchScopeFactory.getInstance().getProjects(fPatternData.getScope());
+ int totalTicks = 1000;
+ IProject[] projects = DLTKSearchScopeFactory.getInstance()
+ .getProjects(fPatternData.getScope());
final SearchParticipantRecord[] participantDescriptors = SearchParticipantsExtensionPoint
- .getInstance().getSearchParticipants(this.fPatternData.getScope().getLanguageToolkit(), projects);
- final int[] ticks= new int[participantDescriptors.length];
- for (int i= 0; i < participantDescriptors.length; i++) {
- final int iPrime= i;
- ISafeRunnable runnable= new ISafeRunnable() {
+ .getInstance().getSearchParticipants(
+ this.fPatternData.getScope().getLanguageToolkit(),
+ projects);
+ final int[] ticks = new int[participantDescriptors.length];
+ for (int i = 0; i < participantDescriptors.length; i++) {
+ final int iPrime = i;
+ ISafeRunnable runnable = new ISafeRunnable() {
@Override
public void handleException(Throwable exception) {
- ticks[iPrime]= 0;
- String message= SearchMessages.DLTKSearchQuery_error_participant_estimate;
- DLTKUIPlugin.log(new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0, message, exception));
+ ticks[iPrime] = 0;
+ String message = SearchMessages.DLTKSearchQuery_error_participant_estimate;
+ DLTKUIPlugin.log(new Status(IStatus.ERROR,
+ DLTKUIPlugin.getPluginId(), 0, message,
+ exception));
}
@Override
public void run() throws Exception {
- ticks[iPrime]= participantDescriptors[iPrime].getParticipant().estimateTicks(fPatternData);
+ ticks[iPrime] = participantDescriptors[iPrime]
+ .getParticipant().estimateTicks(fPatternData);
}
};
SafeRunner.run(runnable);
- totalTicks+= ticks[i];
+ totalTicks += ticks[i];
}
SearchPattern pattern;
String stringPattern;
- IDLTKLanguageToolkit toolkit = this.fPatternData.getScope().getLanguageToolkit();
+ IDLTKLanguageToolkit toolkit = this.fPatternData.getScope()
+ .getLanguageToolkit();
if (fPatternData instanceof ElementQuerySpecification) {
- IModelElement element= ((ElementQuerySpecification) fPatternData).getElement();
- stringPattern= ScriptElementLabels.getDefault().getElementLabel(element, ScriptElementLabels.ALL_DEFAULT);
+ IModelElement element = ((ElementQuerySpecification) fPatternData)
+ .getElement();
+ stringPattern = ScriptElementLabels.getDefault()
+ .getElementLabel(element,
+ ScriptElementLabels.ALL_DEFAULT);
if (!element.exists()) {
- return new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0, Messages.format(SearchMessages.DLTKSearchQuery_error_element_does_not_exist, stringPattern), null);
+ return new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(),
+ 0,
+ Messages.format(
+ SearchMessages.DLTKSearchQuery_error_element_does_not_exist,
+ stringPattern),
+ null);
}
- pattern= SearchPattern.createPattern(element, fPatternData.getLimitTo(), SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE, toolkit);
+ pattern = SearchPattern.createPattern(element,
+ fPatternData.getLimitTo(),
+ SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE, toolkit);
} else {
PatternQuerySpecification patternSpec = (PatternQuerySpecification) fPatternData;
- stringPattern= patternSpec.getPattern();
- int matchMode= getMatchMode(stringPattern) | SearchPattern.R_ERASURE_MATCH;
+ stringPattern = patternSpec.getPattern();
+ int matchMode = getMatchMode(stringPattern)
+ | SearchPattern.R_ERASURE_MATCH;
if (patternSpec.isCaseSensitive())
matchMode |= SearchPattern.R_CASE_SENSITIVE;
- pattern= SearchPattern.createPattern(patternSpec.getPattern(), patternSpec.getSearchFor(), patternSpec.getLimitTo(), matchMode, toolkit);
+ pattern = SearchPattern.createPattern(patternSpec.getPattern(),
+ patternSpec.getSearchFor(), patternSpec.getLimitTo(),
+ matchMode, toolkit);
}
if (pattern == null) {
- return new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0, Messages.format(SearchMessages.DLTKSearchQuery_error_unsupported_pattern, stringPattern), null);
+ return new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0,
+ Messages.format(
+ SearchMessages.DLTKSearchQuery_error_unsupported_pattern,
+ stringPattern),
+ null);
}
- monitor.beginTask(Messages.format(SearchMessages.DLTKSearchQuery_task_label, stringPattern), totalTicks);
- IProgressMonitor mainSearchPM= new SubProgressMonitor(monitor, 1000);
+ monitor.beginTask(
+ Messages.format(SearchMessages.DLTKSearchQuery_task_label,
+ stringPattern),
+ totalTicks);
+ IProgressMonitor mainSearchPM = new SubProgressMonitor(monitor,
+ 1000);
- boolean ignorePotentials= NewSearchUI.arePotentialMatchesIgnored();
- NewSearchResultCollector collector= new NewSearchResultCollector(textResult, ignorePotentials);
+ boolean ignorePotentials = NewSearchUI.arePotentialMatchesIgnored();
+ NewSearchResultCollector collector = new NewSearchResultCollector(
+ textResult, ignorePotentials);
+ engine.search(pattern,
+ new SearchParticipant[] {
+ SearchEngine.getDefaultSearchParticipant() },
+ fPatternData.getScope(), collector, mainSearchPM);
+ for (int i = 0; i < participantDescriptors.length; i++) {
+ final ISearchRequestor requestor = new SearchRequestor(
+ participantDescriptors[i].getParticipant(), textResult);
+ final IProgressMonitor participantPM = new SubProgressMonitor(
+ monitor, ticks[i]);
- engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, fPatternData.getScope(), collector, mainSearchPM);
- for (int i= 0; i < participantDescriptors.length; i++) {
- final ISearchRequestor requestor= new SearchRequestor(participantDescriptors[i].getParticipant(), textResult);
- final IProgressMonitor participantPM= new SubProgressMonitor(monitor, ticks[i]);
-
- final int iPrime= i;
- ISafeRunnable runnable= new ISafeRunnable() {
+ final int iPrime = i;
+ ISafeRunnable runnable = new ISafeRunnable() {
@Override
public void handleException(Throwable exception) {
- participantDescriptors[iPrime].getDescriptor().disable();
- String message= SearchMessages.DLTKSearchQuery_error_participant_search;
- DLTKUIPlugin.log(new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0, message, exception));
+ participantDescriptors[iPrime].getDescriptor()
+ .disable();
+ String message = SearchMessages.DLTKSearchQuery_error_participant_search;
+ DLTKUIPlugin.log(new Status(IStatus.ERROR,
+ DLTKUIPlugin.getPluginId(), 0, message,
+ exception));
}
@Override
public void run() throws Exception {
- final IQueryParticipant participant= participantDescriptors[iPrime].getParticipant();
+ final IQueryParticipant participant = participantDescriptors[iPrime]
+ .getParticipant();
- final PerformanceStats stats= PerformanceStats.getStats(PERF_SEARCH_PARTICIPANT, participant);
+ final PerformanceStats stats = PerformanceStats
+ .getStats(PERF_SEARCH_PARTICIPANT, participant);
stats.startRun();
- participant.search(requestor, fPatternData, participantPM);
+ participant.search(requestor, fPatternData,
+ participantPM);
stats.endRun();
}
@@ -175,8 +216,11 @@
} catch (CoreException e) {
return e.getStatus();
}
- String message= Messages.format(SearchMessages.DLTKSearchQuery_status_ok_message, String.valueOf(textResult.getMatchCount()));
- return new Status(IStatus.OK, DLTKUIPlugin.getPluginId(), 0, message, null);
+ String message = Messages.format(
+ SearchMessages.DLTKSearchQuery_status_ok_message,
+ String.valueOf(textResult.getMatchCount()));
+ return new Status(IStatus.OK, DLTKUIPlugin.getPluginId(), 0, message,
+ null);
}
private int getMatchMode(String pattern) {
@@ -195,58 +239,81 @@
public String getResultLabel(int nMatches) {
if (nMatches == 1) {
- String[] args= { getSearchPatternDescription(), fPatternData.getScopeDescription() };
+ Object[] args = { getSearchPatternDescription(),
+ fPatternData.getScopeDescription() };
switch (fPatternData.getLimitTo()) {
// case IDLTKSearchConstants.IMPLEMENTORS:
// return Messages.format(SearchMessages.DLTKSearchOperation_singularImplementorsPostfix, args);
- case IDLTKSearchConstants.DECLARATIONS:
- return Messages.format(SearchMessages.DLTKSearchOperation_singularDeclarationsPostfix, args);
- case IDLTKSearchConstants.REFERENCES:
- return Messages.format(SearchMessages.DLTKSearchOperation_singularReferencesPostfix, args);
- case IDLTKSearchConstants.ALL_OCCURRENCES:
- return Messages.format(SearchMessages.DLTKSearchOperation_singularOccurrencesPostfix, args);
+ case IDLTKSearchConstants.DECLARATIONS:
+ return Messages.format(
+ SearchMessages.DLTKSearchOperation_singularDeclarationsPostfix,
+ args);
+ case IDLTKSearchConstants.REFERENCES:
+ return Messages.format(
+ SearchMessages.DLTKSearchOperation_singularReferencesPostfix,
+ args);
+ case IDLTKSearchConstants.ALL_OCCURRENCES:
+ return Messages.format(
+ SearchMessages.DLTKSearchOperation_singularOccurrencesPostfix,
+ args);
// case IDLTKSearchConstants.READ_ACCESSES:
// return Messages.format(SearchMessages.DLTKSearchOperation_singularReadReferencesPostfix, args);
// case IDLTKSearchConstants.WRITE_ACCESSES:
// return Messages.format(SearchMessages.DLTKSearchOperation_singularWriteReferencesPostfix, args);
- default:
- return Messages.format(SearchMessages.DLTKSearchOperation_singularOccurrencesPostfix, args);
+ default:
+ return Messages.format(
+ SearchMessages.DLTKSearchOperation_singularOccurrencesPostfix,
+ args);
}
- } else {
- Object[] args= { getSearchPatternDescription(), Integer.valueOf(nMatches), fPatternData.getScopeDescription() };
- switch (fPatternData.getLimitTo()) {
+ }
+ Object[] args = { getSearchPatternDescription(),
+ Integer.valueOf(nMatches), fPatternData.getScopeDescription() };
+ switch (fPatternData.getLimitTo()) {
// case IDLTKSearchConstants.IMPLEMENTORS:
// return Messages.format(SearchMessages.DLTKSearchOperation_pluralImplementorsPostfix, args);
- case IDLTKSearchConstants.DECLARATIONS:
- return Messages.format(SearchMessages.DLTKSearchOperation_pluralDeclarationsPostfix, args);
- case IDLTKSearchConstants.REFERENCES:
- return Messages.format(SearchMessages.DLTKSearchOperation_pluralReferencesPostfix, args);
- case IDLTKSearchConstants.ALL_OCCURRENCES:
- return Messages.format(SearchMessages.DLTKSearchOperation_pluralOccurrencesPostfix, args);
+ case IDLTKSearchConstants.DECLARATIONS:
+ return Messages.format(
+ SearchMessages.DLTKSearchOperation_pluralDeclarationsPostfix,
+ args);
+ case IDLTKSearchConstants.REFERENCES:
+ return Messages.format(
+ SearchMessages.DLTKSearchOperation_pluralReferencesPostfix,
+ args);
+ case IDLTKSearchConstants.ALL_OCCURRENCES:
+ return Messages.format(
+ SearchMessages.DLTKSearchOperation_pluralOccurrencesPostfix,
+ args);
// case IDLTKSearchConstants.READ_ACCESSES:
// return Messages.format(SearchMessages.DLTKSearchOperation_pluralReadReferencesPostfix, args);
// case IDLTKSearchConstants.WRITE_ACCESSES:
// return Messages.format(SearchMessages.DLTKSearchOperation_pluralWriteReferencesPostfix, args);
- default:
- return Messages.format(SearchMessages.DLTKSearchOperation_pluralOccurrencesPostfix, args);
- }
+ default:
+ return Messages.format(
+ SearchMessages.DLTKSearchOperation_pluralOccurrencesPostfix,
+ args);
}
}
private String getSearchPatternDescription() {
if (fPatternData instanceof ElementQuerySpecification) {
- IModelElement element= ((ElementQuerySpecification) fPatternData).getElement();
- return ScriptElementLabels.getDefault().getElementLabel(element, ScriptElementLabels.ALL_DEFAULT
- | ScriptElementLabels.ALL_FULLY_QUALIFIED | ScriptElementLabels.USE_RESOLVED);
+ IModelElement element = ((ElementQuerySpecification) fPatternData)
+ .getElement();
+ return ScriptElementLabels.getDefault().getElementLabel(element,
+ ScriptElementLabels.ALL_DEFAULT
+ | ScriptElementLabels.ALL_FULLY_QUALIFIED
+ | ScriptElementLabels.USE_RESOLVED);
}
return ((PatternQuerySpecification) fPatternData).getPattern();
}
ImageDescriptor getImageDescriptor() {
- if (/*fPatternData.getLimitTo() == IDLTKSearchConstants.IMPLEMENTORS ||*/ fPatternData.getLimitTo() == IDLTKSearchConstants.DECLARATIONS)
+ if (/*
+ * fPatternData.getLimitTo() == IDLTKSearchConstants.IMPLEMENTORS ||
+ */ fPatternData
+ .getLimitTo() == IDLTKSearchConstants.DECLARATIONS) {
return DLTKPluginImages.DESC_OBJS_SEARCH_DECL;
- else
- return DLTKPluginImages.DESC_OBJS_SEARCH_REF;
+ }
+ return DLTKPluginImages.DESC_OBJS_SEARCH_REF;
}
@Override
@@ -262,7 +329,7 @@
@Override
public ISearchResult getSearchResult() {
if (fResult == null) {
- fResult= new DLTKSearchResult(this);
+ fResult = new DLTKSearchResult(this);
new SearchResultUpdater((DLTKSearchResult) fResult);
}
return fResult;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchResultPage.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchResultPage.java
index 0a810a3..c345d86 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchResultPage.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchResultPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -487,15 +487,12 @@
&& input.getActiveMatchFilters().length > 0) {
if (isQueryRunning()) {
String message = SearchMessages.DLTKSearchResultPage_filtered_message;
- return Messages.format(message, new Object[] { label });
+ return Messages.format(message, label);
- } else {
- int filteredOut = input.getMatchCount()
- - getFilteredMatchCount();
- String message = SearchMessages.DLTKSearchResultPage_filteredWithCount_message;
- return Messages.format(message,
- new Object[] { label, String.valueOf(filteredOut) });
}
+ int filteredOut = input.getMatchCount() - getFilteredMatchCount();
+ String message = SearchMessages.DLTKSearchResultPage_filteredWithCount_message;
+ return Messages.format(message, label, String.valueOf(filteredOut));
}
return label;
}
@@ -506,9 +503,8 @@
ITreeContentProvider tp = (ITreeContentProvider) viewer
.getContentProvider();
return getMatchCount(tp, getRootElements((TreeViewer) getViewer()));
- } else {
- return getMatchCount((TableViewer) viewer);
}
+ return getMatchCount((TableViewer) viewer);
}
private Object[] getRootElements(TreeViewer viewer) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchScopeFactory.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchScopeFactory.java
index 62dd15f..0fcdc9c 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchScopeFactory.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/DLTKSearchScopeFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -169,13 +169,13 @@
String label = includeInterp
? SearchMessages.EnclosingProjectsScope2
: SearchMessages.EnclosingProjectsScope2NoInterpreterEnvironment;
- scopeDescription = Messages.format(label,
- new String[] { projectNames[0], projectNames[1] });
+ scopeDescription = Messages.format(label, projectNames[0],
+ projectNames[1]);
} else {
String label = includeInterp ? SearchMessages.EnclosingProjectsScope
: SearchMessages.EnclosingProjectsScopeNoInterpreterEnvironment;
- scopeDescription = Messages.format(label,
- new String[] { projectNames[0], projectNames[1] });
+ scopeDescription = Messages.format(label, projectNames[0],
+ projectNames[1]);
}
return scopeDescription;
}
@@ -185,11 +185,10 @@
if (includeInterp) {
return Messages.format(SearchMessages.ProjectScope,
project.getElementName());
- } else {
- return Messages.format(
- SearchMessages.ProjectScopeNoInterpreterEnvironment,
- project.getElementName());
}
+ return Messages.format(
+ SearchMessages.ProjectScopeNoInterpreterEnvironment,
+ project.getElementName());
}
public String getProjectScopeDescription(IEditorInput editorInput,
@@ -207,7 +206,7 @@
public String getHierarchyScopeDescription(IType type) {
return Messages.format(SearchMessages.HierarchyScope,
- new String[] { type.getElementName() });
+ type.getElementName());
}
public String getSelectionScopeDescription(IModelElement[] modelElements,
@@ -225,14 +224,14 @@
String label = includeInterp ? SearchMessages.DoubleSelectionScope
: SearchMessages.DoubleSelectionScopeNoInterpreterEnvironment;
scopeDescription = Messages.format(label,
- new String[] { modelElements[0].getElementName(),
- modelElements[1].getElementName() });
+ modelElements[0].getElementName(),
+ modelElements[1].getElementName());
} else {
String label = includeInterp ? SearchMessages.SelectionScope
: SearchMessages.SelectionScopeNoInterpreterEnvironment;
scopeDescription = Messages.format(label,
- new String[] { modelElements[0].getElementName(),
- modelElements[1].getElementName() });
+ modelElements[0].getElementName(),
+ modelElements[1].getElementName());
}
return scopeDescription;
}
@@ -251,13 +250,13 @@
if (workingSets.length == 2) {
String label = includeInterp ? SearchMessages.DoubleWorkingSetScope
: SearchMessages.DoubleWorkingSetScopeNoInterpreterEnvironment;
- return Messages.format(label, new String[] {
- workingSets[0].getLabel(), workingSets[1].getLabel() });
+ return Messages.format(label, workingSets[0].getLabel(),
+ workingSets[1].getLabel());
}
String label = includeInterp ? SearchMessages.WorkingSetsScope
: SearchMessages.WorkingSetsScopeNoInterpreterEnvironment;
- return Messages.format(label, new String[] { workingSets[0].getLabel(),
- workingSets[1].getLabel() });
+ return Messages.format(label, workingSets[0].getLabel(),
+ workingSets[1].getLabel());
}
public IProject[] getProjects(IDLTKSearchScope scope) {
@@ -276,9 +275,8 @@
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
return getModelElements(
((IStructuredSelection) selection).toArray());
- } else {
- return new IModelElement[0];
}
+ return new IModelElement[0];
}
private IModelElement[] getModelElements(Object[] elements) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/LevelTreeContentProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/LevelTreeContentProvider.java
index 64ecb16..333bd0d 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/LevelTreeContentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/LevelTreeContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -40,8 +40,8 @@
private static final int MAX_LEVEL = SCRIPT_ELEMENT_TYPES.length - 1;
private int fCurrentLevel;
- static class FastModelElementProvider extends
- StandardModelElementContentProvider {
+ static class FastModelElementProvider
+ extends StandardModelElementContentProvider {
@Override
public Object getParent(Object element) {
Object parent = getExtendedParent(element);
@@ -65,7 +65,8 @@
IModelElement modelElement = (IModelElement) possibleParent;
for (int j = fCurrentLevel; j < MAX_LEVEL + 1; j++) {
for (int i = 0; i < SCRIPT_ELEMENT_TYPES[j].length; i++) {
- if (modelElement.getElementType() == SCRIPT_ELEMENT_TYPES[j][i]) {
+ if (modelElement
+ .getElementType() == SCRIPT_ELEMENT_TYPES[j][i]) {
return null;
}
}
@@ -183,9 +184,8 @@
Set siblings = (Set) fChildrenMap.get(parent);
if (siblings != null) {
return siblings.remove(element);
- } else {
- return false;
}
+ return false;
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/SearchLabelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/SearchLabelProvider.java
index b26a092..ebd72b5 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/SearchLabelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/SearchLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -142,28 +142,26 @@
return Messages.format(
SearchMessages.SearchLabelProvider_exact_noCount,
elementName);
- } else {
- int exactCount = matchCount - potentialCount;
+ }
+ int exactCount = matchCount - potentialCount;
- if (potentialCount > 0 && exactCount > 0) {
- String[] args = new String[] { elementName,
- String.valueOf(matchCount), String.valueOf(exactCount),
- String.valueOf(potentialCount) };
- return Messages.format(
- SearchMessages.SearchLabelProvider_exact_and_potential_plural,
- args);
- } else if (exactCount == 0) {
- String[] args = new String[] { elementName,
- String.valueOf(matchCount) };
- return Messages.format(
- SearchMessages.SearchLabelProvider_potential_plural,
- args);
- }
- String[] args = new String[] { elementName,
+ if (potentialCount > 0 && exactCount > 0) {
+ Object[] args = new String[] { elementName,
+ String.valueOf(matchCount), String.valueOf(exactCount),
+ String.valueOf(potentialCount) };
+ return Messages.format(
+ SearchMessages.SearchLabelProvider_exact_and_potential_plural,
+ args);
+ } else if (exactCount == 0) {
+ Object[] args = new String[] { elementName,
String.valueOf(matchCount) };
return Messages.format(
- SearchMessages.SearchLabelProvider_exact_plural, args);
+ SearchMessages.SearchLabelProvider_potential_plural, args);
}
+ Object[] args = new String[] { elementName,
+ String.valueOf(matchCount) };
+ return Messages.format(SearchMessages.SearchLabelProvider_exact_plural,
+ args);
}
protected boolean hasChildren(Object elem) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/TextSearchLabelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/TextSearchLabelProvider.java
index e6045d6..1eefe88 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/TextSearchLabelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/TextSearchLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -12,26 +12,25 @@
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
-
public abstract class TextSearchLabelProvider extends LabelProvider {
private AbstractTextSearchViewPage fPage;
private String fMatchCountFormat;
public TextSearchLabelProvider(AbstractTextSearchViewPage page) {
- fPage= page;
- fMatchCountFormat= SearchMessages.TextSearchLabelProvider_matchCountFormat;
+ fPage = page;
+ fMatchCountFormat = SearchMessages.TextSearchLabelProvider_matchCountFormat;
}
@Override
public final String getText(Object element) {
- int matchCount= fPage.getInput().getMatchCount(element);
- String text= doGetText(element);
- if (matchCount < 2)
+ int matchCount = fPage.getInput().getMatchCount(element);
+ String text = doGetText(element);
+ if (matchCount < 2) {
return text;
- else {
- return Messages.format(fMatchCountFormat, new Object[] { text, Integer.valueOf(matchCount) });
}
+ return Messages.format(fMatchCountFormat,
+ new Object[] { text, Integer.valueOf(matchCount) });
}
protected abstract String doGetText(Object element);
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/DocumentCharacterIterator.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/DocumentCharacterIterator.java
index be6b128..036d28f 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/DocumentCharacterIterator.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/DocumentCharacterIterator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -14,22 +14,22 @@
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
-
/**
* An <code>IDocument</code> based implementation of
- * <code>CharacterIterator</code> and <code>CharSequence</code>. Note that
- * the supplied document is not copied; if the document is modified during the
- * lifetime of a <code>DocumentCharacterIterator</code>, the methods
- * returning document content may not always return the same values. Also, if
- * accessing the document fails with a {@link BadLocationException}, any of
+ * <code>CharacterIterator</code> and <code>CharSequence</code>. Note that the
+ * supplied document is not copied; if the document is modified during the
+ * lifetime of a <code>DocumentCharacterIterator</code>, the methods returning
+ * document content may not always return the same values. Also, if accessing
+ * the document fails with a {@link BadLocationException}, any of
* <code>CharacterIterator</code> methods as well as <code>charAt</code>may
* return {@link CharacterIterator#DONE}.
*
- *
+ *
*/
-public class DocumentCharacterIterator implements CharacterIterator, CharSequence {
+public class DocumentCharacterIterator
+ implements CharacterIterator, CharSequence {
- private int fIndex= -1;
+ private int fIndex = -1;
private final IDocument fDocument;
private final int fFirst;
private final int fLast;
@@ -42,7 +42,8 @@
/**
* Creates an iterator for the entire document.
*
- * @param document the document backing this iterator
+ * @param document
+ * the document backing this iterator
*/
public DocumentCharacterIterator(IDocument document) {
this(document, 0);
@@ -51,11 +52,15 @@
/**
* Creates an iterator, starting at offset <code>first</code>.
*
- * @param document the document backing this iterator
- * @param first the first character to consider
- * @throws IllegalArgumentException if the indices are out of bounds
+ * @param document
+ * the document backing this iterator
+ * @param first
+ * the first character to consider
+ * @throws IllegalArgumentException
+ * if the indices are out of bounds
*/
- public DocumentCharacterIterator(IDocument document, int first) throws IllegalArgumentException {
+ public DocumentCharacterIterator(IDocument document, int first)
+ throws IllegalArgumentException {
this(document, first, document.getLength());
}
@@ -63,22 +68,27 @@
* Creates an iterator for the document contents from <code>first</code>
* (inclusive) to <code>last</code> (exclusive).
*
- * @param document the document backing this iterator
- * @param first the first character to consider
- * @param last the last character index to consider
- * @throws IllegalArgumentException if the indices are out of bounds
+ * @param document
+ * the document backing this iterator
+ * @param first
+ * the first character to consider
+ * @param last
+ * the last character index to consider
+ * @throws IllegalArgumentException
+ * if the indices are out of bounds
*/
- public DocumentCharacterIterator(IDocument document, int first, int last) throws IllegalArgumentException {
+ public DocumentCharacterIterator(IDocument document, int first, int last)
+ throws IllegalArgumentException {
if (document == null)
throw new NullPointerException();
if (first < 0 || first > last)
throw new IllegalArgumentException();
if (last > document.getLength())
throw new IllegalArgumentException();
- fDocument= document;
- fFirst= first;
- fLast= last;
- fIndex= first;
+ fDocument = document;
+ fFirst = first;
+ fLast = last;
+ fIndex = first;
invariant();
}
@@ -89,10 +99,10 @@
@Override
public char last() {
- if (fFirst == fLast)
+ if (fFirst == fLast) {
return setIndex(getEndIndex());
- else
- return setIndex(getEndIndex() - 1);
+ }
+ return setIndex(getEndIndex() - 1);
}
@Override
@@ -115,15 +125,14 @@
public char previous() {
if (fIndex > getBeginIndex()) {
return setIndex(fIndex - 1);
- } else {
- return DONE;
}
+ return DONE;
}
@Override
public char setIndex(int position) {
if (position >= getBeginIndex() && position <= getEndIndex())
- fIndex= position;
+ fIndex = position;
else
throw new IllegalArgumentException();
@@ -168,20 +177,21 @@
* was thrown when accessing the backing document.
* </p>
*
- * @param index {@inheritDoc}
+ * @param index
+ * {@inheritDoc}
* @return {@inheritDoc}
*/
@Override
public char charAt(int index) {
- if (index >= 0 && index < length())
+ if (index >= 0 && index < length()) {
try {
return fDocument.getChar(getBeginIndex() + index);
} catch (BadLocationException e) {
// ignore and return DONE
return DONE;
}
- else
- throw new IndexOutOfBoundsException();
+ }
+ throw new IndexOutOfBoundsException();
}
@Override
@@ -192,19 +202,19 @@
throw new IndexOutOfBoundsException();
if (end > length())
throw new IndexOutOfBoundsException();
- return new DocumentCharacterIterator(fDocument, getBeginIndex() + start, getBeginIndex() + end);
+ return new DocumentCharacterIterator(fDocument, getBeginIndex() + start,
+ getBeginIndex() + end);
}
@Override
public String toString() {
if (fFirst == 0 && fLast == fDocument.getLength()) {
return fDocument.get();
- } else {
- try {
- return fDocument.get(fFirst, length());
- } catch (BadLocationException e) {
- throw new IndexOutOfBoundsException();
- }
+ }
+ try {
+ return fDocument.get(fFirst, length());
+ } catch (BadLocationException e) {
+ throw new IndexOutOfBoundsException();
}
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/ScriptBreakIterator.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/ScriptBreakIterator.java
index b5566c1..c2c5a4d 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/ScriptBreakIterator.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/ScriptBreakIterator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -14,7 +14,6 @@
import com.ibm.icu.text.BreakIterator;
-
/**
* A script break iterator. It returns all breaks, including before and after
* whitespace, and it returns all camel case breaks.
@@ -22,7 +21,7 @@
* A line break may be any of "\n", "\r", "\r\n", "\n\r".
* </p>
*
- *
+ *
*/
public class ScriptBreakIterator extends BreakIterator {
@@ -39,10 +38,11 @@
/**
* Returns <code>true</code> if this run consumes <code>ch</code>,
- * <code>false</code> otherwise. If <code>true</code> is returned,
- * the length of the receiver is adjusted accordingly.
+ * <code>false</code> otherwise. If <code>true</code> is returned, the
+ * length of the receiver is adjusted accordingly.
*
- * @param ch the character to test
+ * @param ch
+ * the character to test
* @return <code>true</code> if <code>ch</code> was consumed
*/
protected boolean consume(char ch) {
@@ -54,10 +54,11 @@
}
/**
- * Whether this run accepts that character; does not update state. Called
- * from the default implementation of <code>consume</code>.
+ * Whether this run accepts that character; does not update state.
+ * Called from the default implementation of <code>consume</code>.
*
- * @param ch the character to test
+ * @param ch
+ * the character to test
* @return <code>true</code> if <code>ch</code> is accepted
*/
protected abstract boolean isValid(char ch);
@@ -66,7 +67,7 @@
* Resets this run to the initial state.
*/
protected void init() {
- length= 0;
+ length = 0;
}
}
@@ -80,13 +81,13 @@
static final class LineDelimiter extends Run {
/** State: INIT -> delimiter -> EXIT. */
private char fState;
- private static final char INIT= '\0';
- private static final char EXIT= '\1';
+ private static final char INIT = '\0';
+ private static final char EXIT = '\1';
@Override
protected void init() {
super.init();
- fState= INIT;
+ fState = INIT;
}
@Override
@@ -95,11 +96,11 @@
return false;
if (fState == INIT) {
- fState= ch;
+ fState = ch;
length++;
return true;
} else if (fState != ch) {
- fState= EXIT;
+ fState = EXIT;
length++;
return true;
} else {
@@ -122,60 +123,61 @@
static final class CamelCaseIdentifier extends Run {
/* states */
- private static final int S_INIT= 0;
- private static final int S_LOWER= 1;
- private static final int S_ONE_CAP= 2;
- private static final int S_ALL_CAPS= 3;
- private static final int S_EXIT= 4;
- private static final int S_EXIT_MINUS_ONE= 5;
+ private static final int S_INIT = 0;
+ private static final int S_LOWER = 1;
+ private static final int S_ONE_CAP = 2;
+ private static final int S_ALL_CAPS = 3;
+ private static final int S_EXIT = 4;
+ private static final int S_EXIT_MINUS_ONE = 5;
/* character types */
- private static final int K_INVALID= 0;
- private static final int K_LOWER= 1;
- private static final int K_UPPER= 2;
- private static final int K_OTHER= 3;
+ private static final int K_INVALID = 0;
+ private static final int K_LOWER = 1;
+ private static final int K_UPPER = 2;
+ private static final int K_OTHER = 3;
private int fState;
- private final static int[][] MATRIX= new int[][] {
- // K_INVALID, K_LOWER, K_UPPER, K_OTHER
- { S_EXIT, S_LOWER, S_ONE_CAP, S_LOWER }, // S_INIT
- { S_EXIT, S_LOWER, S_EXIT, S_LOWER }, // S_LOWER
- { S_EXIT, S_LOWER, S_ALL_CAPS, S_LOWER }, // S_ONE_CAP
- { S_EXIT, S_EXIT_MINUS_ONE, S_ALL_CAPS, S_LOWER }, // S_ALL_CAPS
+ private final static int[][] MATRIX = new int[][] {
+ // K_INVALID, K_LOWER, K_UPPER, K_OTHER
+ { S_EXIT, S_LOWER, S_ONE_CAP, S_LOWER }, // S_INIT
+ { S_EXIT, S_LOWER, S_EXIT, S_LOWER }, // S_LOWER
+ { S_EXIT, S_LOWER, S_ALL_CAPS, S_LOWER }, // S_ONE_CAP
+ { S_EXIT, S_EXIT_MINUS_ONE, S_ALL_CAPS, S_LOWER }, // S_ALL_CAPS
};
@Override
protected void init() {
super.init();
- fState= S_INIT;
+ fState = S_INIT;
}
@Override
protected boolean consume(char ch) {
- int kind= getKind(ch);
- fState= MATRIX[fState][kind];
+ int kind = getKind(ch);
+ fState = MATRIX[fState][kind];
switch (fState) {
- case S_LOWER:
- case S_ONE_CAP:
- case S_ALL_CAPS:
- length++;
- return true;
- case S_EXIT:
- return false;
- case S_EXIT_MINUS_ONE:
- length--;
- return false;
- default:
- Assert.isTrue(false);
- return false;
+ case S_LOWER:
+ case S_ONE_CAP:
+ case S_ALL_CAPS:
+ length++;
+ return true;
+ case S_EXIT:
+ return false;
+ case S_EXIT_MINUS_ONE:
+ length--;
+ return false;
+ default:
+ Assert.isTrue(false);
+ return false;
}
}
/**
* Determines the kind of a character.
*
- * @param ch the character to test
+ * @param ch
+ * the character to test
*/
private int getKind(char ch) {
if (Character.isUpperCase(ch))
@@ -197,14 +199,16 @@
@Override
protected boolean isValid(char ch) {
- return !Character.isWhitespace(ch) && !Character.isJavaIdentifierPart(ch);
+ return !Character.isWhitespace(ch)
+ && !Character.isJavaIdentifierPart(ch);
}
}
- private static final Run WHITESPACE= new Whitespace();
- private static final Run DELIMITER= new LineDelimiter();
- private static final Run CAMELCASE= new CamelCaseIdentifier(); // new Identifier();
- private static final Run OTHER= new Other();
+ private static final Run WHITESPACE = new Whitespace();
+ private static final Run DELIMITER = new LineDelimiter();
+ private static final Run CAMELCASE = new CamelCaseIdentifier(); // new
+ // Identifier();
+ private static final Run OTHER = new Other();
/** The platform break iterator (word instance) used as a base. */
protected final BreakIterator fIterator;
@@ -213,13 +217,12 @@
/** our current position for the stateful methods. */
private int fIndex;
-
/**
* Creates a new break iterator.
*/
public ScriptBreakIterator() {
- fIterator= BreakIterator.getWordInstance();
- fIndex= fIterator.current();
+ fIterator = BreakIterator.getWordInstance();
+ fIndex = fIterator.current();
}
@Override
@@ -229,7 +232,7 @@
@Override
public int first() {
- fIndex= fIterator.first();
+ fIndex = fIterator.first();
return fIndex;
}
@@ -239,7 +242,7 @@
if (offset == getText().getEndIndex())
return DONE;
- int next= fIterator.following(offset);
+ int next = fIterator.following(offset);
if (next == DONE)
return DONE;
@@ -247,25 +250,27 @@
// Math.min(offset + run.length, next) does not work
// since BreakIterator.getWordInstance considers _ as boundaries
// seems to work fine, however
- Run run= consumeRun(offset);
+ Run run = consumeRun(offset);
return offset + run.length;
}
/**
* Consumes a run of characters at the limits of which we introduce a break.
- * @param offset the offset to start at
+ *
+ * @param offset
+ * the offset to start at
* @return the run that was consumed
*/
private Run consumeRun(int offset) {
// assert offset < length
- char ch= fText.charAt(offset);
- int length= fText.length();
- Run run= getRun(ch);
+ char ch = fText.charAt(offset);
+ int length = fText.length();
+ Run run = getRun(ch);
while (run.consume(ch) && offset < length - 1) {
offset++;
- ch= fText.charAt(offset);
+ ch = fText.charAt(offset);
}
return run;
@@ -274,19 +279,20 @@
/**
* Returns a run based on a character.
*
- * @param ch the character to test
+ * @param ch
+ * the character to test
* @return the correct character given <code>ch</code>
*/
private Run getRun(char ch) {
Run run;
if (WHITESPACE.isValid(ch))
- run= WHITESPACE;
+ run = WHITESPACE;
else if (DELIMITER.isValid(ch))
- run= DELIMITER;
+ run = DELIMITER;
else if (CAMELCASE.isValid(ch))
- run= CAMELCASE;
+ run = CAMELCASE;
else if (OTHER.isValid(ch))
- run= OTHER;
+ run = OTHER;
else {
Assert.isTrue(false);
return null;
@@ -303,21 +309,21 @@
@Override
public boolean isBoundary(int offset) {
- if (offset == getText().getBeginIndex())
- return true;
- else
- return following(offset - 1) == offset;
+ if (offset == getText().getBeginIndex()) {
+ return true;
+ }
+ return following(offset - 1) == offset;
}
@Override
public int last() {
- fIndex= fIterator.last();
+ fIndex = fIterator.last();
return fIndex;
}
@Override
public int next() {
- fIndex= following(fIndex);
+ fIndex = following(fIndex);
return fIndex;
}
@@ -334,15 +340,15 @@
if (isBoundary(offset - 1))
return offset - 1;
- int previous= offset - 1;
+ int previous = offset - 1;
do {
- previous= fIterator.preceding(previous);
+ previous = fIterator.preceding(previous);
} while (!isBoundary(previous));
- int last= DONE;
+ int last = DONE;
while (previous < offset) {
- last= previous;
- previous= following(previous);
+ last = previous;
+ previous = following(previous);
}
return last;
@@ -350,7 +356,7 @@
@Override
public int previous() {
- fIndex= preceding(fIndex);
+ fIndex = preceding(fIndex);
return fIndex;
}
@@ -361,10 +367,12 @@
/**
* Creates a break iterator given a char sequence.
- * @param newText the new text
+ *
+ * @param newText
+ * the new text
*/
public void setText(CharSequence newText) {
- fText= newText;
+ fText = newText;
fIterator.setText(new SequenceCharacterIterator(newText));
first();
}
@@ -372,11 +380,12 @@
@Override
public void setText(CharacterIterator newText) {
if (newText instanceof CharSequence) {
- fText= (CharSequence) newText;
+ fText = (CharSequence) newText;
fIterator.setText(newText);
first();
} else {
- throw new UnsupportedOperationException("CharacterIterator not supported"); //$NON-NLS-1$
+ throw new UnsupportedOperationException(
+ "CharacterIterator not supported"); //$NON-NLS-1$
}
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/ScriptElementProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/ScriptElementProvider.java
index 37431a0..7cd70d7 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/ScriptElementProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/ScriptElementProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -24,30 +24,32 @@
/**
* Provides a Script element to be displayed in by an information presenter.
*/
-public class ScriptElementProvider implements IInformationProvider, IInformationProviderExtension {
+public class ScriptElementProvider
+ implements IInformationProvider, IInformationProviderExtension {
private ScriptEditor fEditor;
private boolean fUseCodeResolve;
public ScriptElementProvider(IEditorPart editor) {
- fUseCodeResolve= false;
+ fUseCodeResolve = false;
if (editor instanceof ScriptEditor)
- fEditor= (ScriptEditor)editor;
+ fEditor = (ScriptEditor) editor;
}
public ScriptElementProvider(IEditorPart editor, boolean useCodeResolve) {
this(editor);
- fUseCodeResolve= useCodeResolve;
+ fUseCodeResolve = useCodeResolve;
}
@Override
public IRegion getSubject(ITextViewer textViewer, int offset) {
if (textViewer != null && fEditor != null) {
- IRegion region= ScriptWordFinder.findWord(textViewer.getDocument(), offset);
- if (region != null)
+ IRegion region = ScriptWordFinder.findWord(textViewer.getDocument(),
+ offset);
+ if (region != null) {
return region;
- else
- return new Region(offset, 0);
+ }
+ return new Region(offset, 0);
}
return null;
}
@@ -64,11 +66,13 @@
try {
if (fUseCodeResolve) {
- IStructuredSelection sel= SelectionConverter.getStructuredSelection(fEditor);
+ IStructuredSelection sel = SelectionConverter
+ .getStructuredSelection(fEditor);
if (!sel.isEmpty())
return sel.getFirstElement();
}
- IModelElement element= SelectionConverter.getElementAtOffset(fEditor);
+ IModelElement element = SelectionConverter
+ .getElementAtOffset(fEditor);
if (element != null)
return element;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/SequenceCharacterIterator.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/SequenceCharacterIterator.java
index 8eafa71..06aef86 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/SequenceCharacterIterator.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/SequenceCharacterIterator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -15,12 +15,10 @@
/**
* A <code>CharSequence</code> based implementation of
* <code>CharacterIterator</code>.
- *
- *
*/
public class SequenceCharacterIterator implements CharacterIterator {
- private int fIndex= -1;
+ private int fIndex = -1;
private final CharSequence fSequence;
private final int fFirst;
private final int fLast;
@@ -33,7 +31,8 @@
/**
* Creates an iterator for the entire sequence.
*
- * @param sequence the sequence backing this iterator
+ * @param sequence
+ * the sequence backing this iterator
*/
public SequenceCharacterIterator(CharSequence sequence) {
this(sequence, 0);
@@ -42,33 +41,42 @@
/**
* Creates an iterator.
*
- * @param sequence the sequence backing this iterator
- * @param first the first character to consider
- * @throws IllegalArgumentException if the indices are out of bounds
+ * @param sequence
+ * the sequence backing this iterator
+ * @param first
+ * the first character to consider
+ * @throws IllegalArgumentException
+ * if the indices are out of bounds
*/
- public SequenceCharacterIterator(CharSequence sequence, int first) throws IllegalArgumentException {
+ public SequenceCharacterIterator(CharSequence sequence, int first)
+ throws IllegalArgumentException {
this(sequence, first, sequence.length());
}
/**
* Creates an iterator.
*
- * @param sequence the sequence backing this iterator
- * @param first the first character to consider
- * @param last the last character index to consider
- * @throws IllegalArgumentException if the indices are out of bounds
+ * @param sequence
+ * the sequence backing this iterator
+ * @param first
+ * the first character to consider
+ * @param last
+ * the last character index to consider
+ * @throws IllegalArgumentException
+ * if the indices are out of bounds
*/
- public SequenceCharacterIterator(CharSequence sequence, int first, int last) throws IllegalArgumentException {
+ public SequenceCharacterIterator(CharSequence sequence, int first, int last)
+ throws IllegalArgumentException {
if (sequence == null)
throw new NullPointerException();
if (first < 0 || first > last)
throw new IllegalArgumentException();
if (last > sequence.length())
throw new IllegalArgumentException();
- fSequence= sequence;
- fFirst= first;
- fLast= last;
- fIndex= first;
+ fSequence = sequence;
+ fFirst = first;
+ fLast = last;
+ fIndex = first;
invariant();
}
@@ -79,18 +87,18 @@
@Override
public char last() {
- if (fFirst == fLast)
+ if (fFirst == fLast) {
return setIndex(getEndIndex());
- else
- return setIndex(getEndIndex() - 1);
+ }
+ return setIndex(getEndIndex() - 1);
}
@Override
public char current() {
- if (fIndex >= fFirst && fIndex < fLast)
+ if (fIndex >= fFirst && fIndex < fLast) {
return fSequence.charAt(fIndex);
- else
- return DONE;
+ }
+ return DONE;
}
@Override
@@ -102,15 +110,14 @@
public char previous() {
if (fIndex > getBeginIndex()) {
return setIndex(fIndex - 1);
- } else {
- return DONE;
}
+ return DONE;
}
@Override
public char setIndex(int position) {
if (position >= getBeginIndex() && position <= getEndIndex())
- fIndex= position;
+ fIndex = position;
else
throw new IllegalArgumentException();
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/SubstitutionTextReader.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/SubstitutionTextReader.java
index c9c6627..a321fe4 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/SubstitutionTextReader.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/SubstitutionTextReader.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -14,13 +14,14 @@
import org.eclipse.dltk.corext.documentation.SingleCharReader;
/**
- * Reads the text contents from a reader and computes for each character
- * a potential substitution. The substitution may eat more characters than
- * only the one passed into the computation routine.
+ * Reads the text contents from a reader and computes for each character a
+ * potential substitution. The substitution may eat more characters than only
+ * the one passed into the computation routine.
*/
public abstract class SubstitutionTextReader extends SingleCharReader {
- protected static final String LINE_DELIM= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ protected static final String LINE_DELIM = System
+ .getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
private Reader fReader;
protected boolean fWasWhiteSpace;
@@ -29,26 +30,25 @@
/**
* Tells whether white space characters are skipped.
*/
- private boolean fSkipWhiteSpace= true;
+ private boolean fSkipWhiteSpace = true;
private boolean fReadFromBuffer;
private StringBuffer fBuffer;
private int fIndex;
-
protected SubstitutionTextReader(Reader reader) {
- fReader= reader;
- fBuffer= new StringBuffer();
- fIndex= 0;
- fReadFromBuffer= false;
- fCharAfterWhiteSpace= -1;
- fWasWhiteSpace= true;
+ fReader = reader;
+ fBuffer = new StringBuffer();
+ fIndex = 0;
+ fReadFromBuffer = false;
+ fCharAfterWhiteSpace = -1;
+ fWasWhiteSpace = true;
}
/**
- * Implement to compute the substitution for the given character and
- * if necessary subsequent characters. Use <code>nextChar</code>
- * to read subsequent characters.
+ * Implement to compute the substitution for the given character and if
+ * necessary subsequent characters. Use <code>nextChar</code> to read
+ * subsequent characters.
*/
protected abstract String computeSubstitution(int c) throws IOException;
@@ -63,32 +63,31 @@
* Returns the next character.
*/
protected int nextChar() throws IOException {
- fReadFromBuffer= (fBuffer.length() > 0);
+ fReadFromBuffer = (fBuffer.length() > 0);
if (fReadFromBuffer) {
- char ch= fBuffer.charAt(fIndex++);
+ char ch = fBuffer.charAt(fIndex++);
if (fIndex >= fBuffer.length()) {
fBuffer.setLength(0);
- fIndex= 0;
- }
- return ch;
- } else {
- int ch= fCharAfterWhiteSpace;
- if (ch == -1) {
- ch= fReader.read();
- }
- if (fSkipWhiteSpace && Character.isWhitespace((char)ch)) {
- do {
- ch= fReader.read();
- } while (Character.isWhitespace((char)ch));
- if (ch != -1) {
- fCharAfterWhiteSpace= ch;
- return ' ';
- }
- } else {
- fCharAfterWhiteSpace= -1;
+ fIndex = 0;
}
return ch;
}
+ int ch = fCharAfterWhiteSpace;
+ if (ch == -1) {
+ ch = fReader.read();
+ }
+ if (fSkipWhiteSpace && Character.isWhitespace((char) ch)) {
+ do {
+ ch = fReader.read();
+ } while (Character.isWhitespace((char) ch));
+ if (ch != -1) {
+ fCharAfterWhiteSpace = ch;
+ return ' ';
+ }
+ } else {
+ fCharAfterWhiteSpace = -1;
+ }
+ return ch;
}
@Override
@@ -96,22 +95,22 @@
int c;
do {
- c= nextChar();
+ c = nextChar();
while (!fReadFromBuffer && c != -1) {
- String s= computeSubstitution(c);
+ String s = computeSubstitution(c);
if (s == null)
break;
if (s.length() > 0)
fBuffer.insert(0, s);
- c= nextChar();
+ c = nextChar();
}
} while (fSkipWhiteSpace && fWasWhiteSpace && (c == ' '));
- fWasWhiteSpace= (c == ' ' || c == '\r' || c == '\n');
+ fWasWhiteSpace = (c == ' ' || c == '\r' || c == '\n');
return c;
}
- @Override
+ @Override
public boolean ready() throws IOException {
return fReader.ready();
}
@@ -124,14 +123,14 @@
@Override
public void reset() throws IOException {
fReader.reset();
- fWasWhiteSpace= true;
- fCharAfterWhiteSpace= -1;
+ fWasWhiteSpace = true;
+ fCharAfterWhiteSpace = -1;
fBuffer.setLength(0);
- fIndex= 0;
+ fIndex = 0;
}
protected final void setSkipWhitespace(boolean state) {
- fSkipWhiteSpace= state;
+ fSkipWhiteSpace = state;
}
protected final boolean isSkippingWhitespace() {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/DocumentationHover.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/DocumentationHover.java
index 8c52433..8816192 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/DocumentationHover.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/DocumentationHover.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -221,7 +221,7 @@
* Creates a new PresenterControlCreator.
*
* @param site
- * the site or <code>null</code> if none
+ * the site or <code>null</code> if none
*/
public PresenterControlCreator(IWorkbenchSite site) {
}
@@ -292,9 +292,8 @@
// TODO (alex) addLinkListener(iControl);
return iControl;
- } else {
- return new DefaultInformationControl(parent, true);
}
+ return new DefaultInformationControl(parent, true);
}
}
@@ -339,7 +338,8 @@
/**
* @param informationPresenterControlCreator
- * control creator for enriched hover
+ * control creator for
+ * enriched hover
*/
public HoverControlCreator(
IInformationControlCreator informationPresenterControlCreator) {
@@ -348,10 +348,15 @@
/**
* @param informationPresenterControlCreator
- * control creator for enriched hover
+ * control creator for
+ * enriched hover
* @param additionalInfoAffordance
- * <code>true</code> to use the additional info affordance,
- * <code>false</code> to use the hover affordance
+ * <code>true</code> to
+ * use the additional info
+ * affordance,
+ * <code>false</code> to
+ * use the hover
+ * affordance
*/
public HoverControlCreator(
IInformationControlCreator informationPresenterControlCreator,
@@ -382,10 +387,9 @@
};
// TODO (alex) addLinkListener(iControl);
return iControl;
- } else {
- return new DefaultInformationControl(parent,
- tooltipAffordanceString);
}
+ return new DefaultInformationControl(parent,
+ tooltipAffordanceString);
}
/**
@@ -595,9 +599,8 @@
String label = ScriptElementLabels.getDefault()
.getElementLabel(member, flags);
return label;
- } else {
- return null;
}
+ return null;
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/EditorTextHoverDescriptor.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/EditorTextHoverDescriptor.java
index 943cec7..71ce8ec 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/EditorTextHoverDescriptor.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/EditorTextHoverDescriptor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -77,8 +77,8 @@
* Computes the state mask for the given modifier string.
*
* @param modifiers
- * the string with the modifiers, separated by '+', '-', ';', ','
- * or '.'
+ * the string with the modifiers, separated by '+',
+ * '-', ';', ',' or '.'
* @return the state mask or -1 if the input is invalid
*/
public static int computeStateMask(String modifiers) {
@@ -154,10 +154,10 @@
// Return simple class name
label = getHoverClassName();
int lastDot = label.lastIndexOf('.');
- if (lastDot >= 0 && lastDot < label.length() - 1)
+ if (lastDot >= 0 && lastDot < label.length() - 1) {
return label.substring(lastDot + 1);
- else
- return label;
+ }
+ return label;
}
/**
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/ScriptExpandHover.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/ScriptExpandHover.java
index da8d0f1..3bceceb 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/ScriptExpandHover.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/ScriptExpandHover.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -186,10 +186,10 @@
@Override
protected int getOrder(Annotation annotation) {
- if (isBreakpointAnnotation(annotation))
+ if (isBreakpointAnnotation(annotation)) {
return 1000;
- else
- return super.getOrder(annotation);
+ }
+ return super.getOrder(annotation);
}
private boolean isBreakpointAnnotation(Annotation a) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/ScriptInformationProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/ScriptInformationProvider.java
index 729bf85..a6db21a 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/ScriptInformationProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/text/hover/ScriptInformationProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -29,8 +29,8 @@
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
-public class ScriptInformationProvider implements IInformationProvider,
- IInformationProviderExtension2 {
+public class ScriptInformationProvider
+ implements IInformationProvider, IInformationProviderExtension2 {
class EditorWatcher implements IPartListener {
@@ -137,12 +137,12 @@
@Override
public IInformationControl doCreateInformationControl(
Shell parent) {
- if (BrowserInformationControl.isAvailable(parent))
+ if (BrowserInformationControl.isAvailable(parent)) {
return new BrowserInformationControl(parent,
JFaceResources.DIALOG_FONT, true);
- else
- return new DefaultInformationControl(parent,
- new HTMLTextPresenter(false));
+ }
+ return new DefaultInformationControl(parent,
+ new HTMLTextPresenter(false));
}
};
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/HierarchyInformationControl.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/HierarchyInformationControl.java
index a1dc749..1b90c0c 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/HierarchyInformationControl.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/HierarchyInformationControl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -203,10 +203,9 @@
if (filterOverrides) {
return fMethodOverrideTester
.findOverriddenMethodInType(typeToFindIn, filterMethod);
- } else {
- return fMethodOverrideTester
- .findOverridingMethodInType(typeToFindIn, filterMethod);
}
+ return fMethodOverrideTester.findOverridingMethodInType(typeToFindIn,
+ filterMethod);
}
@Override
@@ -356,11 +355,10 @@
return Messages.format(
TypeHierarchyMessages.HierarchyInformationControl_toggle_traditionalhierarchy_label,
keyName);
- } else {
- return Messages.format(
- TypeHierarchyMessages.HierarchyInformationControl_toggle_superhierarchy_label,
- keyName);
}
+ return Messages.format(
+ TypeHierarchyMessages.HierarchyInformationControl_toggle_superhierarchy_label,
+ keyName);
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/OpenTypeHierarchyUtil.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/OpenTypeHierarchyUtil.java
index 2c5b885..0bba221 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/OpenTypeHierarchyUtil.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/OpenTypeHierarchyUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -28,25 +28,28 @@
private OpenTypeHierarchyUtil() {
}
- public static TypeHierarchyViewPart open(IModelElement element, IWorkbenchWindow window) {
- IModelElement[] candidates= getCandidates(element);
+ public static TypeHierarchyViewPart open(IModelElement element,
+ IWorkbenchWindow window) {
+ IModelElement[] candidates = getCandidates(element);
if (candidates != null) {
return open(candidates, window);
}
return null;
}
- public static TypeHierarchyViewPart open(IModelElement[] candidates, IWorkbenchWindow window) {
+ public static TypeHierarchyViewPart open(IModelElement[] candidates,
+ IWorkbenchWindow window) {
Assert.isNotNull(candidates);
Assert.isTrue(candidates.length != 0);
- IModelElement input= null;
+ IModelElement input = null;
if (candidates.length > 1) {
- String title= DLTKUIMessages.OpenTypeHierarchyUtil_selectionDialog_title;
- String message= DLTKUIMessages.OpenTypeHierarchyUtil_selectionDialog_message;
- input= OpenActionUtil.selectModelElement(candidates, window.getShell(), title, message);
+ String title = DLTKUIMessages.OpenTypeHierarchyUtil_selectionDialog_title;
+ String message = DLTKUIMessages.OpenTypeHierarchyUtil_selectionDialog_message;
+ input = OpenActionUtil.selectModelElement(candidates,
+ window.getShell(), title, message);
} else {
- input= candidates[0];
+ input = candidates[0];
}
if (input instanceof IMember
&& input.getElementType() != IModelElement.TYPE) {
@@ -61,7 +64,7 @@
// PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.OPEN_TYPE_HIERARCHY))) {
// return openInPerspective(window, input);
// } else {
- return openInViewPart(window, input);
+ return openInViewPart(window, input);
// }
// } catch (WorkbenchException e) {
@@ -76,19 +79,24 @@
// return null;
}
- private static TypeHierarchyViewPart openInViewPart(IWorkbenchWindow window, IModelElement input) {
- IWorkbenchPage page= window.getActivePage();
+ private static TypeHierarchyViewPart openInViewPart(IWorkbenchWindow window,
+ IModelElement input) {
+ IWorkbenchPage page = window.getActivePage();
try {
- TypeHierarchyViewPart result= (TypeHierarchyViewPart) page.findView(DLTKUIPlugin.ID_TYPE_HIERARCHY);
+ TypeHierarchyViewPart result = (TypeHierarchyViewPart) page
+ .findView(DLTKUIPlugin.ID_TYPE_HIERARCHY);
if (result != null) {
- result.clearNeededRefresh(); // avoid refresh of old hierarchy on 'becomes visible'
+ result.clearNeededRefresh(); // avoid refresh of old hierarchy
+ // on 'becomes visible'
}
- result= (TypeHierarchyViewPart) page.showView(DLTKUIPlugin.ID_TYPE_HIERARCHY);
+ result = (TypeHierarchyViewPart) page
+ .showView(DLTKUIPlugin.ID_TYPE_HIERARCHY);
result.setInputElement(input);
return result;
} catch (CoreException e) {
ExceptionHandler.handle(e, window.getShell(),
- DLTKUIMessages.OpenTypeHierarchyUtil_error_open_view, e.getMessage());
+ DLTKUIMessages.OpenTypeHierarchyUtil_error_open_view,
+ e.getMessage());
}
return null;
}
@@ -101,20 +109,19 @@
return null;
}
try {
- IModelElement elem= (IModelElement) input;
+ IModelElement elem = (IModelElement) input;
switch (elem.getElementType()) {
- case IModelElement.METHOD:
- case IModelElement.FIELD:
- case IModelElement.TYPE:
- case IModelElement.SCRIPT_PROJECT:
- return new IModelElement[] { elem };
+ case IModelElement.METHOD:
+ case IModelElement.FIELD:
+ case IModelElement.TYPE:
+ case IModelElement.SCRIPT_PROJECT:
+ return new IModelElement[] { elem };
case IModelElement.LOCAL_VARIABLE: {
final IType type = AdaptUtils.getAdapter(elem, IType.class);
if (type != null) {
return new IModelElement[] { type };
- } else {
- return null;
}
+ return null;
}
// case IModelElement.PROJECT_FRAGMENT:
// if (((IProjectFragment)elem).containsJavaResources())
@@ -135,17 +142,18 @@
//
// case IModelElement.CLASS_FILE:
// return new IModelElement[] { ((IClassFile)input).getType() };
- case IModelElement.SOURCE_MODULE: {
- ISourceModule cu= (ISourceModule) elem.getAncestor(IModelElement.SOURCE_MODULE);
- if (cu != null) {
- IType[] types= cu.getTypes();
- if (types.length > 0) {
- return types;
- }
+ case IModelElement.SOURCE_MODULE: {
+ ISourceModule cu = (ISourceModule) elem
+ .getAncestor(IModelElement.SOURCE_MODULE);
+ if (cu != null) {
+ IType[] types = cu.getTypes();
+ if (types.length > 0) {
+ return types;
}
- break;
}
- default:
+ break;
+ }
+ default:
}
} catch (ModelException e) {
DLTKUIPlugin.log(e);
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/SubTypeHierarchyViewer.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/SubTypeHierarchyViewer.java
index e594763..5f96601 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/SubTypeHierarchyViewer.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/SubTypeHierarchyViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -17,23 +17,25 @@
import org.eclipse.ui.IWorkbenchPart;
/**
- * A viewer including the content provider for the subtype hierarchy.
- * Used by the TypeHierarchyViewPart which has to provide a TypeHierarchyLifeCycle
- * on construction (shared type hierarchy)
+ * A viewer including the content provider for the subtype hierarchy. Used by
+ * the TypeHierarchyViewPart which has to provide a TypeHierarchyLifeCycle on
+ * construction (shared type hierarchy)
*/
public class SubTypeHierarchyViewer extends TypeHierarchyViewer {
- public SubTypeHierarchyViewer(Composite parent, TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part, IPreferenceStore store) {
- super(parent, new SubTypeHierarchyContentProvider(lifeCycle), lifeCycle, part, store);
+ public SubTypeHierarchyViewer(Composite parent,
+ TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part,
+ IPreferenceStore store) {
+ super(parent, new SubTypeHierarchyContentProvider(lifeCycle), lifeCycle,
+ part, store);
}
@Override
public String getTitle() {
if (isMethodFiltering()) {
return TypeHierarchyMessages.SubTypeHierarchyViewer_filtered_title;
- } else {
- return TypeHierarchyMessages.SubTypeHierarchyViewer_title;
}
+ return TypeHierarchyMessages.SubTypeHierarchyViewer_title;
}
@Override
@@ -42,7 +44,7 @@
refresh();
if (expand) {
- int expandLevel= 2;
+ int expandLevel = 2;
if (isMethodFiltering()) {
expandLevel++;
}
@@ -54,25 +56,24 @@
/**
* Content provider for the subtype hierarchy
*/
- public static class SubTypeHierarchyContentProvider extends TypeHierarchyContentProvider {
- public SubTypeHierarchyContentProvider(TypeHierarchyLifeCycle lifeCycle) {
+ public static class SubTypeHierarchyContentProvider
+ extends TypeHierarchyContentProvider {
+ public SubTypeHierarchyContentProvider(
+ TypeHierarchyLifeCycle lifeCycle) {
super(lifeCycle);
}
@Override
protected final void getTypesInHierarchy(IType type, List res) {
- ITypeHierarchy hierarchy= getHierarchy();
+ ITypeHierarchy hierarchy = getHierarchy();
if (hierarchy != null) {
- IType[] types= hierarchy.getSubtypes(type);
- /*if (isObject(type)) {
- for (int i= 0; i < types.length; i++) {
- IType curr= types[i];
- if (!isAnonymousFromInterface(curr)) {
- res.add(curr);
- }
- }
- } else */{
- for (int i= 0; i < types.length; i++) {
+ IType[] types = hierarchy.getSubtypes(type);
+ /*
+ * if (isObject(type)) { for (int i= 0; i < types.length; i++) {
+ * IType curr= types[i]; if (!isAnonymousFromInterface(curr)) {
+ * res.add(curr); } } } else
+ */ {
+ for (int i = 0; i < types.length; i++) {
res.add(types[i]);
}
}
@@ -82,7 +83,7 @@
@Override
protected IType[] getParentType(IType type) {
- ITypeHierarchy hierarchy= getHierarchy();
+ ITypeHierarchy hierarchy = getHierarchy();
if (hierarchy != null) {
return hierarchy.getSuperclass(type);
// dont handle interfaces
@@ -90,8 +91,6 @@
return null;
}
-}
-
-
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/SuperTypeHierarchyViewer.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/SuperTypeHierarchyViewer.java
index 1701e7e..7c70ab0 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/SuperTypeHierarchyViewer.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/SuperTypeHierarchyViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -17,23 +17,25 @@
import org.eclipse.ui.IWorkbenchPart;
/**
- * A viewer including the content provider for the supertype hierarchy.
- * Used by the TypeHierarchyViewPart which has to provide a TypeHierarchyLifeCycle
- * on construction (shared type hierarchy)
+ * A viewer including the content provider for the supertype hierarchy. Used by
+ * the TypeHierarchyViewPart which has to provide a TypeHierarchyLifeCycle on
+ * construction (shared type hierarchy)
*/
public class SuperTypeHierarchyViewer extends TypeHierarchyViewer {
- public SuperTypeHierarchyViewer(Composite parent, TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part, IPreferenceStore store) {
- super(parent, new SuperTypeHierarchyContentProvider(lifeCycle), lifeCycle, part, store);
+ public SuperTypeHierarchyViewer(Composite parent,
+ TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part,
+ IPreferenceStore store) {
+ super(parent, new SuperTypeHierarchyContentProvider(lifeCycle),
+ lifeCycle, part, store);
}
@Override
public String getTitle() {
if (isMethodFiltering()) {
return TypeHierarchyMessages.SuperTypeHierarchyViewer_filtered_title;
- } else {
- return TypeHierarchyMessages.SuperTypeHierarchyViewer_title;
}
+ return TypeHierarchyMessages.SuperTypeHierarchyViewer_title;
}
@Override
@@ -49,18 +51,20 @@
/*
* Content provider for the supertype hierarchy
*/
- public static class SuperTypeHierarchyContentProvider extends TypeHierarchyContentProvider {
- public SuperTypeHierarchyContentProvider(TypeHierarchyLifeCycle lifeCycle) {
+ public static class SuperTypeHierarchyContentProvider
+ extends TypeHierarchyContentProvider {
+ public SuperTypeHierarchyContentProvider(
+ TypeHierarchyLifeCycle lifeCycle) {
super(lifeCycle);
}
@Override
protected final void getTypesInHierarchy(IType type, List res) {
- ITypeHierarchy hierarchy= getHierarchy();
+ ITypeHierarchy hierarchy = getHierarchy();
if (hierarchy != null) {
- IType[] types= hierarchy.getSupertypes(type);
- if( types != null ) {
- for (int i= 0; i < types.length; i++) {
+ IType[] types = hierarchy.getSupertypes(type);
+ if (types != null) {
+ for (int i = 0; i < types.length; i++) {
res.add(types[i]);
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TraditionalHierarchyViewer.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TraditionalHierarchyViewer.java
index 31647f8..3976868 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TraditionalHierarchyViewer.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TraditionalHierarchyViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -36,9 +36,8 @@
public String getTitle() {
if (isMethodFiltering()) {
return TypeHierarchyMessages.TraditionalHierarchyViewer_filtered_title;
- } else {
- return TypeHierarchyMessages.TraditionalHierarchyViewer_title;
}
+ return TypeHierarchyMessages.TraditionalHierarchyViewer_title;
}
@Override
@@ -60,8 +59,8 @@
/**
* Content provider for the 'traditional' type hierarchy.
*/
- public static class TraditionalHierarchyContentProvider extends
- TypeHierarchyContentProvider {
+ public static class TraditionalHierarchyContentProvider
+ extends TypeHierarchyContentProvider {
public TraditionalHierarchyContentProvider(
TypeHierarchyLifeCycle provider) {
@@ -74,9 +73,8 @@
IType input = hierarchy.getType();
if (input != null) {
return getDepth(hierarchy, input) + 2;
- } else {
- return 5;
}
+ return 5;
}
return 2;
}
@@ -84,7 +82,7 @@
private int getDepth(ITypeHierarchy hierarchy, IType input) {
int max = 0;
IType[] superType = hierarchy.getSuperclass(input);
- if( superType == null ) {
+ if (superType == null) {
return 0;
}
for (int q = 0; q < superType.length; ++q) {
@@ -127,10 +125,10 @@
IType[] types = hierarchy.getSubtypes(type);
/*
* if (isObject(type)) { for (int i= 0; i < types.length; i++) {
- * IType curr= types[i]; if (!isAnonymousFromInterface(curr)) { //
- * no anonymous classes on 'Object' -> will be children of
+ * IType curr= types[i]; if (!isAnonymousFromInterface(curr)) {
+ * // no anonymous classes on 'Object' -> will be children of
* interface res.add(curr); } } } else
- */{
+ */ {
boolean isHierarchyOnType = (hierarchy.getType() != null);
boolean isClass = true;// !Flags.isInterface(hierarchy.getCachedFlags(type));
if (isClass || isHierarchyOnType) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyContentProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyContentProvider.java
index fc6ee0f..195b782 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyContentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -124,9 +124,8 @@
boolean filterOverrides) throws ModelException {
if (filterOverrides) {
return fMethodOverrideTester.isSubsignature(filterMethod, method);
- } else {
- return fMethodOverrideTester.isSubsignature(method, filterMethod);
}
+ return fMethodOverrideTester.isSubsignature(method, filterMethod);
}
/**
@@ -352,9 +351,8 @@
if (isInScope(type)) {
if (fMemberFilter != null) {
return hasMemberFilterChildren(type) || hasTypeChildren(type);
- } else {
- return true;
}
+ return true;
}
return hasTypeChildren(type);
}
@@ -409,9 +407,8 @@
final IType[] parents = getParentType((IType) member);
if (parents != null && parents.length == 1) {
return parents[0];
- } else {
- return null;
}
+ return null;
}
return member.getDeclaringType();
} else if (element instanceof CumulativeType.Part) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyLifeCycle.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyLifeCycle.java
index 4138230..3dae868 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyLifeCycle.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyLifeCycle.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -125,37 +125,34 @@
IType type = (IType) element;
if (fIsSuperTypesOnly) {
return type.newSupertypeHierarchy(pm);
- } else {
- return type.newTypeHierarchy(pm);
+ }
+ return type.newTypeHierarchy(pm);
+ }
+ IRegion region = DLTKCore.newRegion();
+ if (element.getElementType() == IModelElement.SCRIPT_PROJECT) {
+ // for projects only add the contained source folders
+ IProjectFragment[] roots = ((IScriptProject) element)
+ .getProjectFragments();
+ for (int i = 0; i < roots.length; i++) {
+ if (!roots[i].isExternal()) {
+ region.add(roots[i]);
+ }
+ }
+ } else if (element.getElementType() == IModelElement.PROJECT_FRAGMENT) {
+ IProjectFragment[] roots = element.getScriptProject()
+ .getProjectFragments();
+ String name = element.getElementName();
+ for (int i = 0; i < roots.length; i++) {
+ IScriptFolder pack = roots[i].getScriptFolder(name);
+ if (pack.exists()) {
+ region.add(pack);
+ }
}
} else {
- IRegion region = DLTKCore.newRegion();
- if (element.getElementType() == IModelElement.SCRIPT_PROJECT) {
- // for projects only add the contained source folders
- IProjectFragment[] roots = ((IScriptProject) element)
- .getProjectFragments();
- for (int i = 0; i < roots.length; i++) {
- if (!roots[i].isExternal()) {
- region.add(roots[i]);
- }
- }
- } else if (element
- .getElementType() == IModelElement.PROJECT_FRAGMENT) {
- IProjectFragment[] roots = element.getScriptProject()
- .getProjectFragments();
- String name = element.getElementName();
- for (int i = 0; i < roots.length; i++) {
- IScriptFolder pack = roots[i].getScriptFolder(name);
- if (pack.exists()) {
- region.add(pack);
- }
- }
- } else {
- region.add(element);
- }
- IScriptProject jproject = element.getScriptProject();
- return jproject.newTypeHierarchy(region, pm);
+ region.add(element);
}
+ IScriptProject jproject = element.getScriptProject();
+ return jproject.newTypeHierarchy(region, pm);
}
public synchronized void doHierarchyRefresh(IModelElement element,
@@ -197,13 +194,11 @@
if (fHierarchyRefreshNeeded) {
return;
- } else {
- ArrayList<IType> changedTypes = new ArrayList<>();
- processDelta(event.getDelta(), changedTypes);
- if (changedTypes.size() > 0) {
- fireChange(
- changedTypes.toArray(new IType[changedTypes.size()]));
- }
+ }
+ ArrayList<IType> changedTypes = new ArrayList<>();
+ processDelta(event.getDelta(), changedTypes);
+ if (changedTypes.size() > 0) {
+ fireChange(changedTypes.toArray(new IType[changedTypes.size()]));
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyViewPart.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyViewPart.java
index 2cdf207..d9914e3 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyViewPart.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyViewPart.java
@@ -1138,9 +1138,8 @@
private IType getSelectableType(IModelElement elem) {
if (elem.getElementType() != IModelElement.TYPE) {
return getCurrentViewer().getTreeRootType();
- } else {
- return (IType) elem;
}
+ return (IType) elem;
}
private void internalSelectType(IMember elem, boolean reveal) {
@@ -1317,7 +1316,7 @@
if (fInputElement != null) {
IWorkingSet workingSet = fWorkingSetActionGroup.getWorkingSet();
if (workingSet == null) {
- String[] args = new String[] { viewerTitle,
+ Object[] args = new String[] { viewerTitle,
ScriptElementLabels.getDefault().getElementLabel(
fInputElement,
ScriptElementLabels.ALL_DEFAULT) };
@@ -1328,7 +1327,7 @@
TypeHierarchyMessages.TypeHierarchyViewPart_tooltip,
args);
} else {
- String[] args = new String[] { viewerTitle,
+ Object[] args = new String[] { viewerTitle,
ScriptElementLabels.getDefault().getElementLabel(
fInputElement, ScriptElementLabels.ALL_DEFAULT),
workingSet.getLabel() };
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/CoreUtility.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/CoreUtility.java
index 797b217..74161a7 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/CoreUtility.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/CoreUtility.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -52,9 +52,9 @@
* cursor will be activated during the duration of the load.
*
* @param element
- * the config element defining the extension
+ * the config element defining the extension
* @param classAttribute
- * the name of the attribute carrying the class
+ * the name of the attribute carrying the class
* @return the extension object
*/
public static Object createExtension(final IConfigurationElement element,
@@ -65,29 +65,27 @@
Bundle bundle = Platform.getBundle(pluginId);
if (bundle != null && bundle.getState() == Bundle.ACTIVE) {
return element.createExecutableExtension(classAttribute);
- } else {
- final Object[] ret = new Object[1];
- final CoreException[] exc = new CoreException[1];
- BusyIndicator.showWhile(null, () -> {
- try {
- ret[0] = element
- .createExecutableExtension(classAttribute);
- } catch (CoreException e) {
- exc[0] = e;
- }
- });
- if (exc[0] != null)
- throw exc[0];
- else
- return ret[0];
}
+ final Object[] ret = new Object[1];
+ final CoreException[] exc = new CoreException[1];
+ BusyIndicator.showWhile(null, () -> {
+ try {
+ ret[0] = element.createExecutableExtension(classAttribute);
+ } catch (CoreException e) {
+ exc[0] = e;
+ }
+ });
+ if (exc[0] != null) {
+ throw exc[0];
+ }
+ return ret[0];
}
/**
* Set the autobuild to the value of the parameter and return the old one.
*
* @param state
- * the value to be set for autobuilding.
+ * the value to be set for autobuilding.
* @return the old value of the autobuild state
*/
public static boolean enableAutoBuild(boolean state) throws CoreException {
@@ -122,8 +120,8 @@
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
- Job[] buildJobs = Job.getJobManager().find(
- ResourcesPlugin.FAMILY_MANUAL_BUILD);
+ Job[] buildJobs = Job.getJobManager()
+ .find(ResourcesPlugin.FAMILY_MANUAL_BUILD);
for (int i = 0; i < buildJobs.length; i++) {
Job curr = buildJobs[i];
if (curr != this && curr instanceof BuildJob) {
@@ -172,14 +170,14 @@
* Returns a build job
*
* @param project
- * The project to build or <code>null</code> to build the
- * workspace.
+ * The project to build or <code>null</code> to build the
+ * workspace.
*/
public static Job getBuildJob(final IProject project) {
Job buildJob = new BuildJob(DLTKUIMessages.CoreUtility_job_title,
project);
- buildJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory()
- .buildRule());
+ buildJob.setRule(
+ ResourcesPlugin.getWorkspace().getRuleFactory().buildRule());
buildJob.setUser(true);
return buildJob;
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/MethodNameMatchLabelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/MethodNameMatchLabelProvider.java
index c2f5973..076f7e1 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/MethodNameMatchLabelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/MethodNameMatchLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -47,10 +47,10 @@
}
private String getPackageName(String packName) {
- if (packName.length() == 0)
+ if (packName.length() == 0) {
return DLTKUIMessages.TypeInfoLabelProvider_default_package;
- else
- return packName;
+ }
+ return packName;
}
@Override
@@ -105,8 +105,8 @@
if (isSet(SHOW_TYPE_CONTAINER_ONLY)) {
MethodNameMatch methodRef = (MethodNameMatch) element;
- if (methodRef.getPackageName().equals(
- methodRef.getMethodContainerName()))
+ if (methodRef.getPackageName()
+ .equals(methodRef.getMethodContainerName()))
return PKG_ICON;
return METHOD_ICON;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/StringMatcher.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/StringMatcher.java
index 53be09b..bb69a50 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/StringMatcher.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/StringMatcher.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
*
-
*******************************************************************************/
package org.eclipse.dltk.internal.ui.util;
@@ -21,259 +20,293 @@
protected boolean fIgnoreCase;
protected boolean fHasLeadingStar;
protected boolean fHasTrailingStar;
- protected String fSegments[]; //the given pattern is split into * separated segments
+ protected String fSegments[]; // the given pattern is split into * separated
+ // segments
/* boundary value beyond which we don't need to search in the text */
- protected int fBound= 0;
-
+ protected int fBound = 0;
- protected static final char fSingleWildCard= '\u0000';
-
+ protected static final char fSingleWildCard = '\u0000';
+
public static class Position {
- int start; //inclusive
- int end; //exclusive
+ int start; // inclusive
+ int end; // exclusive
+
public Position(int start, int end) {
- this.start= start;
- this.end= end;
+ this.start = start;
+ this.end = end;
}
+
public int getStart() {
return start;
}
+
public int getEnd() {
return end;
}
}
+
/**
- * StringMatcher constructor takes in a String object that is a simple
- * pattern. The pattern may contain '*' for 0 and many characters and
- * '?' for exactly one character.
+ * StringMatcher constructor takes in a String object that is a simple
+ * pattern. The pattern may contain '*' for 0 and many characters and '?'
+ * for exactly one character.
*
- * Literal '*' and '?' characters must be escaped in the pattern
- * e.g., "\*" means literal "*", etc.
+ * Literal '*' and '?' characters must be escaped in the pattern e.g., "\*"
+ * means literal "*", etc.
*
- * Escaping any other character (including the escape character itself),
- * just results in that character in the pattern.
- * e.g., "\a" means "a" and "\\" means "\"
+ * Escaping any other character (including the escape character itself),
+ * just results in that character in the pattern. e.g., "\a" means "a" and
+ * "\\" means "\"
*
- * If invoking the StringMatcher with string literals in script lang., don't forget
- * escape characters are represented by "\\".
+ * If invoking the StringMatcher with string literals in script lang., don't
+ * forget escape characters are represented by "\\".
*
- * @param pattern the pattern to match text against
- * @param ignoreCase if true, case is ignored
- * @param ignoreWildCards if true, wild cards and their escape sequences are ignored
- * (everything is taken literally).
+ * @param pattern
+ * the pattern to match text against
+ * @param ignoreCase
+ * if true, case is ignored
+ * @param ignoreWildCards
+ * if true, wild cards and their escape sequences
+ * are ignored (everything is taken literally).
*/
- public StringMatcher(String pattern, boolean ignoreCase, boolean ignoreWildCards) {
+ public StringMatcher(String pattern, boolean ignoreCase,
+ boolean ignoreWildCards) {
if (pattern == null)
throw new IllegalArgumentException();
- fIgnoreCase= ignoreCase;
- fIgnoreWildCards= ignoreWildCards;
- fPattern= pattern;
- fLength= pattern.length();
-
+ fIgnoreCase = ignoreCase;
+ fIgnoreWildCards = ignoreWildCards;
+ fPattern = pattern;
+ fLength = pattern.length();
+
if (fIgnoreWildCards) {
parseNoWildCards();
} else {
parseWildCards();
}
}
+
/**
- * Find the first occurrence of the pattern between <code>start</code)(inclusive)
- * and <code>end</code>(exclusive).
- * @param text the String object to search in
- * @param start the starting index of the search range, inclusive
- * @param end the ending index of the search range, exclusive
- * @return an <code>StringMatcher.Position</code> object that keeps the starting
- * (inclusive) and ending positions (exclusive) of the first occurrence of the
- * pattern in the specified range of the text; return null if not found or subtext
- * is empty (start==end). A pair of zeros is returned if pattern is empty string
- * Note that for pattern like "*abc*" with leading and trailing stars, position of "abc"
- * is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned
+ * Find the first occurrence of the pattern between
+ * <code>start</code)(inclusive)
+ * and <code>end</code>(exclusive).
+ *
+ * @param text
+ * the String object to search in
+ * @param start
+ * the starting index of the search range, inclusive
+ * @param end
+ * the ending index of the search range, exclusive
+ * @return an <code>StringMatcher.Position</code> object that keeps the
+ * starting (inclusive) and ending positions (exclusive) of the
+ * first occurrence of the pattern in the specified range of the
+ * text; return null if not found or subtext is empty (start==end).
+ * A pair of zeros is returned if pattern is empty string Note that
+ * for pattern like "*abc*" with leading and trailing stars,
+ * position of "abc" is returned. For a pattern like"*??*" in text
+ * "abcdf", (1,3) is returned
*/
public StringMatcher.Position find(String text, int start, int end) {
if (text == null)
throw new IllegalArgumentException();
-
- int tlen= text.length();
+
+ int tlen = text.length();
if (start < 0)
- start= 0;
+ start = 0;
if (end > tlen)
- end= tlen;
- if (end < 0 ||start >= end )
+ end = tlen;
+ if (end < 0 || start >= end)
return null;
if (fLength == 0)
return new Position(start, start);
if (fIgnoreWildCards) {
- int x= posIn(text, start, end);
+ int x = posIn(text, start, end);
if (x < 0)
return null;
- return new Position(x, x+fLength);
+ return new Position(x, x + fLength);
}
- int segCount= fSegments.length;
- if (segCount == 0)//pattern contains only '*'(s)
- return new Position (start, end);
-
- int curPos= start;
- int matchStart= -1;
+ int segCount = fSegments.length;
+ if (segCount == 0)// pattern contains only '*'(s)
+ return new Position(start, end);
+
+ int curPos = start;
+ int matchStart = -1;
int i;
- for (i= 0; i < segCount && curPos < end; ++i) {
- String current= fSegments[i];
- int nextMatch= regExpPosIn(text, curPos, end, current);
- if (nextMatch < 0 )
+ for (i = 0; i < segCount && curPos < end; ++i) {
+ String current = fSegments[i];
+ int nextMatch = regExpPosIn(text, curPos, end, current);
+ if (nextMatch < 0)
return null;
- if(i == 0)
- matchStart= nextMatch;
- curPos= nextMatch + current.length();
+ if (i == 0)
+ matchStart = nextMatch;
+ curPos = nextMatch + current.length();
}
if (i < segCount)
return null;
return new Position(matchStart, curPos);
}
+
/**
- * match the given <code>text</code> with the pattern
+ * match the given <code>text</code> with the pattern
+ *
* @return true if matched eitherwise false
- * @param text a String object
+ * @param text
+ * a String object
*/
public boolean match(String text) {
return match(text, 0, text.length());
}
+
/**
- * Given the starting (inclusive) and the ending (exclusive) positions in the
- * <code>text</code>, determine if the given substring matches with aPattern
+ * Given the starting (inclusive) and the ending (exclusive) positions in
+ * the <code>text</code>, determine if the given substring matches with
+ * aPattern
+ *
* @return true if the specified portion of the text matches the pattern
- * @param text a String object that contains the substring to match
- * @param start marks the starting position (inclusive) of the substring
- * @param end marks the ending index (exclusive) of the substring
+ * @param text
+ * a String object that contains the substring to match
+ * @param start
+ * marks the starting position (inclusive) of the substring
+ * @param end
+ * marks the ending index (exclusive) of the substring
*/
public boolean match(String text, int start, int end) {
if (null == text)
throw new IllegalArgumentException();
-
+
if (start > end)
return false;
-
+
if (fIgnoreWildCards)
- return (end - start == fLength) && fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength);
- int segCount= fSegments.length;
- if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar)) // pattern contains only '*'(s)
+ return (end - start == fLength) && fPattern
+ .regionMatches(fIgnoreCase, 0, text, start, fLength);
+ int segCount = fSegments.length;
+ if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar)) // pattern
+ // contains
+ // only
+ // '*'(s)
return true;
if (start == end)
return fLength == 0;
if (fLength == 0)
- return start == end;
-
- int tlen= text.length();
+ return start == end;
+
+ int tlen = text.length();
if (start < 0)
- start= 0;
+ start = 0;
if (end > tlen)
- end= tlen;
-
- int tCurPos= start;
- int bound= end - fBound;
- if ( bound < 0)
+ end = tlen;
+
+ int tCurPos = start;
+ int bound = end - fBound;
+ if (bound < 0)
return false;
- int i=0;
- String current= fSegments[i];
- int segLength= current.length();
+ int i = 0;
+ String current = fSegments[i];
+ int segLength = current.length();
/* process first segment */
- if (!fHasLeadingStar){
- if(!regExpRegionMatches(text, start, current, 0, segLength)) {
+ if (!fHasLeadingStar) {
+ if (!regExpRegionMatches(text, start, current, 0, segLength)) {
return false;
- } else {
- ++i;
- tCurPos= tCurPos + segLength;
}
+ ++i;
+ tCurPos = tCurPos + segLength;
}
- if ((fSegments.length == 1) && (!fHasLeadingStar) && (!fHasTrailingStar)) {
+ if ((fSegments.length == 1) && (!fHasLeadingStar)
+ && (!fHasTrailingStar)) {
// only one segment to match, no wildcards specified
return tCurPos == end;
}
- /* process middle segments */
+ /* process middle segments */
while (i < segCount) {
- current= fSegments[i];
+ current = fSegments[i];
int currentMatch;
- int k= current.indexOf(fSingleWildCard);
+ int k = current.indexOf(fSingleWildCard);
if (k < 0) {
- currentMatch= textPosIn(text, tCurPos, end, current);
+ currentMatch = textPosIn(text, tCurPos, end, current);
if (currentMatch < 0)
return false;
- } else {
- currentMatch= regExpPosIn(text, tCurPos, end, current);
+ } else {
+ currentMatch = regExpPosIn(text, tCurPos, end, current);
if (currentMatch < 0)
return false;
}
- tCurPos= currentMatch + current.length();
+ tCurPos = currentMatch + current.length();
i++;
}
/* process final segment */
if (!fHasTrailingStar && tCurPos != end) {
- int clen= current.length();
+ int clen = current.length();
return regExpRegionMatches(text, end - clen, current, 0, clen);
}
- return i == segCount ;
+ return i == segCount;
}
/**
- * This method parses the given pattern into segments seperated by wildcard '*' characters.
- * Since wildcards are not being used in this case, the pattern consists of a single segment.
+ * This method parses the given pattern into segments seperated by wildcard
+ * '*' characters. Since wildcards are not being used in this case, the
+ * pattern consists of a single segment.
*/
private void parseNoWildCards() {
- fSegments= new String[1];
- fSegments[0]= fPattern;
- fBound= fLength;
+ fSegments = new String[1];
+ fSegments[0] = fPattern;
+ fBound = fLength;
}
+
/**
- * Parses the given pattern into segments seperated by wildcard '*' characters.
+ * Parses the given pattern into segments seperated by wildcard '*'
+ * characters.
*/
private void parseWildCards() {
- if(fPattern.startsWith("*"))//$NON-NLS-1$
- fHasLeadingStar= true;
- if(fPattern.endsWith("*")) {//$NON-NLS-1$
+ if (fPattern.startsWith("*"))//$NON-NLS-1$
+ fHasLeadingStar = true;
+ if (fPattern.endsWith("*")) {//$NON-NLS-1$
/* make sure it's not an escaped wildcard */
if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') {
- fHasTrailingStar= true;
+ fHasTrailingStar = true;
}
}
- Vector temp= new Vector();
+ Vector temp = new Vector();
- int pos= 0;
- StringBuffer buf= new StringBuffer();
+ int pos = 0;
+ StringBuffer buf = new StringBuffer();
while (pos < fLength) {
- char c= fPattern.charAt(pos++);
+ char c = fPattern.charAt(pos++);
switch (c) {
- case '\\':
- if (pos >= fLength) {
- buf.append(c);
- } else {
- char next= fPattern.charAt(pos++);
- /* if it's an escape sequence */
- if (next == '*' || next == '?' || next == '\\') {
- buf.append(next);
- } else {
- /* not an escape sequence, just insert literally */
- buf.append(c);
- buf.append(next);
- }
- }
- break;
- case '*':
- if (buf.length() > 0) {
- /* new segment */
- temp.addElement(buf.toString());
- fBound += buf.length();
- buf.setLength(0);
- }
- break;
- case '?':
- /* append special character representing single match wildcard */
- buf.append(fSingleWildCard);
- break;
- default:
+ case '\\':
+ if (pos >= fLength) {
buf.append(c);
+ } else {
+ char next = fPattern.charAt(pos++);
+ /* if it's an escape sequence */
+ if (next == '*' || next == '?' || next == '\\') {
+ buf.append(next);
+ } else {
+ /* not an escape sequence, just insert literally */
+ buf.append(c);
+ buf.append(next);
+ }
+ }
+ break;
+ case '*':
+ if (buf.length() > 0) {
+ /* new segment */
+ temp.addElement(buf.toString());
+ fBound += buf.length();
+ buf.setLength(0);
+ }
+ break;
+ case '?':
+ /*
+ * append special character representing single match wildcard
+ */
+ buf.append(fSingleWildCard);
+ break;
+ default:
+ buf.append(c);
}
}
@@ -282,56 +315,68 @@
temp.addElement(buf.toString());
fBound += buf.length();
}
-
- fSegments= new String[temp.size()];
+
+ fSegments = new String[temp.size()];
temp.copyInto(fSegments);
}
- /**
- * @param text a string which contains no wildcard
- * @param start the starting index in the text for search, inclusive
- * @param end the stopping point of search, exclusive
- * @return the starting index in the text of the pattern , or -1 if not found
+
+ /**
+ * @param text
+ * a string which contains no wildcard
+ * @param start
+ * the starting index in the text for search, inclusive
+ * @param end
+ * the stopping point of search, exclusive
+ * @return the starting index in the text of the pattern , or -1 if not
+ * found
*/
- protected int posIn(String text, int start, int end) {//no wild card in pattern
- int max= end - fLength;
-
+ protected int posIn(String text, int start, int end) {// no wild card in
+ // pattern
+ int max = end - fLength;
+
if (!fIgnoreCase) {
- int i= text.indexOf(fPattern, start);
+ int i = text.indexOf(fPattern, start);
if (i == -1 || i > max)
return -1;
return i;
}
-
- for (int i= start; i <= max; ++i) {
+
+ for (int i = start; i <= max; ++i) {
if (text.regionMatches(true, i, fPattern, 0, fLength))
return i;
}
-
+
return -1;
}
- /**
- * @param text a simple regular expression that may only contain '?'(s)
- * @param start the starting index in the text for search, inclusive
- * @param end the stopping point of search, exclusive
- * @param p a simple regular expression that may contains '?'
- * @return the starting index in the text of the pattern , or -1 if not found
+
+ /**
+ * @param text
+ * a simple regular expression that may only contain '?'(s)
+ * @param start
+ * the starting index in the text for search, inclusive
+ * @param end
+ * the stopping point of search, exclusive
+ * @param p
+ * a simple regular expression that may contains '?'
+ * @return the starting index in the text of the pattern , or -1 if not
+ * found
*/
protected int regExpPosIn(String text, int start, int end, String p) {
- int plen= p.length();
-
- int max= end - plen;
- for (int i= start; i <= max; ++i) {
+ int plen = p.length();
+
+ int max = end - plen;
+ for (int i = start; i <= max; ++i) {
if (regExpRegionMatches(text, i, p, 0, plen))
return i;
}
return -1;
}
-
- protected boolean regExpRegionMatches(String text, int tStart, String p, int pStart, int plen) {
+ protected boolean regExpRegionMatches(String text, int tStart, String p,
+ int pStart, int plen) {
while (plen-- > 0) {
- char tchar= text.charAt(tStart++);
- char pchar= p.charAt(pStart++);
+ char tchar = text.charAt(tStart++);
+ char pchar = p.charAt(pStart++);
/* process wild cards */
if (!fIgnoreWildCards) {
@@ -343,41 +388,50 @@
if (pchar == tchar)
continue;
if (fIgnoreCase) {
- if (Character.toUpperCase(tchar) == Character.toUpperCase(pchar))
+ if (Character.toUpperCase(tchar) == Character
+ .toUpperCase(pchar))
continue;
- // comparing after converting to upper case doesn't handle all cases;
+ // comparing after converting to upper case doesn't handle all
+ // cases;
// also compare after converting to lower case
- if (Character.toLowerCase(tchar) == Character.toLowerCase(pchar))
+ if (Character.toLowerCase(tchar) == Character
+ .toLowerCase(pchar))
continue;
}
return false;
}
return true;
}
- /**
- * @param text the string to match
- * @param start the starting index in the text for search, inclusive
- * @param end the stopping point of search, exclusive
- * @param p a string that has no wildcard
- * @return the starting index in the text of the pattern , or -1 if not found
+
+ /**
+ * @param text
+ * the string to match
+ * @param start
+ * the starting index in the text for search, inclusive
+ * @param end
+ * the stopping point of search, exclusive
+ * @param p
+ * a string that has no wildcard
+ * @return the starting index in the text of the pattern , or -1 if not
+ * found
*/
- protected int textPosIn(String text, int start, int end, String p) {
-
- int plen= p.length();
- int max= end - plen;
-
+ protected int textPosIn(String text, int start, int end, String p) {
+
+ int plen = p.length();
+ int max = end - plen;
+
if (!fIgnoreCase) {
- int i= text.indexOf(p, start);
+ int i = text.indexOf(p, start);
if (i == -1 || i > max)
return -1;
return i;
}
-
- for (int i= start; i <= max; ++i) {
+
+ for (int i = start; i <= max; ++i) {
if (text.regionMatches(true, i, p, 0, plen))
return i;
}
-
+
return -1;
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/TypeNameMatchLabelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/TypeNameMatchLabelProvider.java
index def1993..dbc0bca 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/TypeNameMatchLabelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/util/TypeNameMatchLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -23,18 +23,21 @@
*/
public class TypeNameMatchLabelProvider extends LabelProvider {
- public static final int SHOW_FULLYQUALIFIED= 0x01;
- public static final int SHOW_PACKAGE_POSTFIX= 0x02;
- public static final int SHOW_PACKAGE_ONLY= 0x04;
- public static final int SHOW_ROOT_POSTFIX= 0x08;
- public static final int SHOW_TYPE_ONLY= 0x10;
- public static final int SHOW_TYPE_CONTAINER_ONLY= 0x20;
- public static final int SHOW_POST_QUALIFIED= 0x40;
+ public static final int SHOW_FULLYQUALIFIED = 0x01;
+ public static final int SHOW_PACKAGE_POSTFIX = 0x02;
+ public static final int SHOW_PACKAGE_ONLY = 0x04;
+ public static final int SHOW_ROOT_POSTFIX = 0x08;
+ public static final int SHOW_TYPE_ONLY = 0x10;
+ public static final int SHOW_TYPE_CONTAINER_ONLY = 0x20;
+ public static final int SHOW_POST_QUALIFIED = 0x40;
- private static final Image CLASS_ICON= DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_CLASS);
- private static final Image ANNOTATION_ICON= DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_ANNOTATION);
+ private static final Image CLASS_ICON = DLTKPluginImages
+ .get(DLTKPluginImages.IMG_OBJS_CLASS);
+ private static final Image ANNOTATION_ICON = DLTKPluginImages
+ .get(DLTKPluginImages.IMG_OBJS_ANNOTATION);
// private static final Image INTERFACE_ICON= DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_INTERFACE);
- private static final Image PKG_ICON= DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_PACKAGE);
+ private static final Image PKG_ICON = DLTKPluginImages
+ .get(DLTKPluginImages.IMG_OBJS_PACKAGE);
private final int fFlags;
private final IDLTKUILanguageToolkit fToolkit;
@@ -43,12 +46,13 @@
* Creates the label provider with the specified parameters.
*
* @param flags
- * bitwise OR of the flags defined in this class
+ * bitwise OR of the flags defined in this class
* @param toolkit
- * language specific UI-toolkit to be used
+ * language specific UI-toolkit to be used
*/
- public TypeNameMatchLabelProvider(int flags, IDLTKUILanguageToolkit toolkit) {
- fFlags= flags;
+ public TypeNameMatchLabelProvider(int flags,
+ IDLTKUILanguageToolkit toolkit) {
+ fFlags = flags;
this.fToolkit = toolkit;
}
@@ -57,33 +61,33 @@
}
private String getPackageName(String packName) {
- if (packName.length() == 0)
+ if (packName.length() == 0) {
return DLTKUIMessages.TypeInfoLabelProvider_default_package;
- else
- return packName;
+ }
+ return packName;
}
@Override
public String getText(Object element) {
- if (! (element instanceof TypeNameMatch))
+ if (!(element instanceof TypeNameMatch))
return super.getText(element);
- TypeNameMatch typeRef= (TypeNameMatch) element;
- StringBuffer buf= new StringBuffer();
+ TypeNameMatch typeRef = (TypeNameMatch) element;
+ StringBuffer buf = new StringBuffer();
if (isSet(SHOW_TYPE_ONLY)) {
buf.append(typeRef.getSimpleTypeName());
} else if (isSet(SHOW_TYPE_CONTAINER_ONLY)) {
- String containerName= typeRef.getTypeContainerName();
+ String containerName = typeRef.getTypeContainerName();
buf.append(getPackageName(containerName));
} else if (isSet(SHOW_PACKAGE_ONLY)) {
- String packName= typeRef.getPackageName();
+ String packName = typeRef.getPackageName();
buf.append(getPackageName(packName));
} else {
if (isSet(SHOW_FULLYQUALIFIED)) {
buf.append(typeRef.getFullyQualifiedName());
} else if (isSet(SHOW_POST_QUALIFIED)) {
buf.append(typeRef.getSimpleTypeName());
- String containerName= typeRef.getTypeContainerName();
+ String containerName = typeRef.getTypeContainerName();
if (containerName != null && containerName.length() > 0) {
buf.append(ScriptElementLabels.CONCAT_STRING);
buf.append(containerName);
@@ -94,26 +98,27 @@
if (isSet(SHOW_PACKAGE_POSTFIX)) {
buf.append(ScriptElementLabels.CONCAT_STRING);
- String packName= typeRef.getPackageName();
+ String packName = typeRef.getPackageName();
buf.append(getPackageName(packName));
}
}
if (isSet(SHOW_ROOT_POSTFIX)) {
buf.append(ScriptElementLabels.CONCAT_STRING);
- IProjectFragment root= typeRef.getProjectFragment();
+ IProjectFragment root = typeRef.getProjectFragment();
ScriptElementLabels labels = this.fToolkit.getScriptElementLabels();
- labels.getProjectFragmentLabel(root, ScriptElementLabels.ROOT_QUALIFIED, buf);
+ labels.getProjectFragmentLabel(root,
+ ScriptElementLabels.ROOT_QUALIFIED, buf);
}
return buf.toString();
}
@Override
public Image getImage(Object element) {
- if (! (element instanceof TypeNameMatch))
+ if (!(element instanceof TypeNameMatch))
return super.getImage(element);
if (isSet(SHOW_TYPE_CONTAINER_ONLY)) {
- TypeNameMatch typeRef= (TypeNameMatch) element;
+ TypeNameMatch typeRef = (TypeNameMatch) element;
if (typeRef.getPackageName().equals(typeRef.getTypeContainerName()))
return PKG_ICON;
@@ -123,8 +128,8 @@
} else if (isSet(SHOW_PACKAGE_ONLY)) {
return PKG_ICON;
} else {
- int modifiers= ((TypeNameMatch)element).getModifiers();
- if ((modifiers & Modifiers.AccAnnotation ) != 0 ) {
+ int modifiers = ((TypeNameMatch) element).getModifiers();
+ if ((modifiers & Modifiers.AccAnnotation) != 0) {
return ANNOTATION_ICON;
}
// else if (Flags.isInterface(modifiers)) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AccessRulesLabelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AccessRulesLabelProvider.java
index fe78340..380fad8 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AccessRulesLabelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AccessRulesLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -15,7 +15,8 @@
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
-public class AccessRulesLabelProvider extends LabelProvider implements ITableLabelProvider {
+public class AccessRulesLabelProvider extends LabelProvider
+ implements ITableLabelProvider {
public AccessRulesLabelProvider() {
}
@@ -23,7 +24,7 @@
@Override
public Image getColumnImage(Object element, int columnIndex) {
if (element instanceof IAccessRule) {
- IAccessRule rule= (IAccessRule) element;
+ IAccessRule rule = (IAccessRule) element;
if (columnIndex == 0) {
return getResolutionImage(rule.getKind());
}
@@ -34,37 +35,38 @@
@Override
public String getColumnText(Object element, int columnIndex) {
if (element instanceof IAccessRule) {
- IAccessRule rule= (IAccessRule) element;
+ IAccessRule rule = (IAccessRule) element;
if (columnIndex == 0) {
return getResolutionLabel(rule.getKind());
- } else {
- return rule.getPattern().toString();
}
+ return rule.getPattern().toString();
}
return element.toString();
}
public static Image getResolutionImage(int kind) {
switch (kind) {
- case IAccessRule.K_ACCESSIBLE:
- return DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_NLS_TRANSLATE);
- case IAccessRule.K_DISCOURAGED:
- return DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_REFACTORING_WARNING);
- case IAccessRule.K_NON_ACCESSIBLE:
- return DLTKPluginImages.get(DLTKPluginImages.IMG_OBJS_REFACTORING_ERROR);
+ case IAccessRule.K_ACCESSIBLE:
+ return DLTKPluginImages
+ .get(DLTKPluginImages.IMG_OBJS_NLS_TRANSLATE);
+ case IAccessRule.K_DISCOURAGED:
+ return DLTKPluginImages
+ .get(DLTKPluginImages.IMG_OBJS_REFACTORING_WARNING);
+ case IAccessRule.K_NON_ACCESSIBLE:
+ return DLTKPluginImages
+ .get(DLTKPluginImages.IMG_OBJS_REFACTORING_ERROR);
}
return null;
}
-
public static String getResolutionLabel(int kind) {
switch (kind) {
- case IAccessRule.K_ACCESSIBLE:
- return NewWizardMessages.AccessRulesLabelProvider_kind_accessible;
- case IAccessRule.K_DISCOURAGED:
- return NewWizardMessages.AccessRulesLabelProvider_kind_discouraged;
- case IAccessRule.K_NON_ACCESSIBLE:
- return NewWizardMessages.AccessRulesLabelProvider_kind_non_accessible;
+ case IAccessRule.K_ACCESSIBLE:
+ return NewWizardMessages.AccessRulesLabelProvider_kind_accessible;
+ case IAccessRule.K_DISCOURAGED:
+ return NewWizardMessages.AccessRulesLabelProvider_kind_discouraged;
+ case IAccessRule.K_NON_ACCESSIBLE:
+ return NewWizardMessages.AccessRulesLabelProvider_kind_non_accessible;
}
return ""; //$NON-NLS-1$
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AddSourceFolderWizard.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AddSourceFolderWizard.java
index 6b079a3..69dae62 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AddSourceFolderWizard.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AddSourceFolderWizard.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -25,52 +25,60 @@
private final boolean fCanCommitConflict;
private final IContainer fParent;
- public AddSourceFolderWizard(BPListElement[] existingEntries, BPListElement newEntry,
- boolean linkedMode, boolean canCommitConflict,
- boolean allowConflict, boolean allowRemoveProjectFolder, boolean allowAddExclusionPatterns) {
- this(existingEntries, newEntry, linkedMode, canCommitConflict, allowConflict, allowRemoveProjectFolder, allowAddExclusionPatterns, newEntry.getScriptProject().getProject());
+ public AddSourceFolderWizard(BPListElement[] existingEntries,
+ BPListElement newEntry, boolean linkedMode,
+ boolean canCommitConflict, boolean allowConflict,
+ boolean allowRemoveProjectFolder,
+ boolean allowAddExclusionPatterns) {
+ this(existingEntries, newEntry, linkedMode, canCommitConflict,
+ allowConflict, allowRemoveProjectFolder,
+ allowAddExclusionPatterns,
+ newEntry.getScriptProject().getProject());
}
- public AddSourceFolderWizard(BPListElement[] existingEntries, BPListElement newEntry,
- boolean linkedMode, boolean canCommitConflict,
- boolean allowConflict, boolean allowRemoveProjectFolder, boolean allowAddExclusionPatterns, IContainer parent) {
- super(existingEntries, newEntry, getTitel(newEntry, linkedMode), DLTKPluginImages.DESC_WIZBAN_NEWSRCFOLDR);
- fLinkedMode= linkedMode;
- fCanCommitConflict= canCommitConflict;
- fAllowConflict= allowConflict;
- fAllowRemoveProjectFolder= allowRemoveProjectFolder;
- fAllowAddExclusionPatterns= allowAddExclusionPatterns;
- fParent= parent;
+ public AddSourceFolderWizard(BPListElement[] existingEntries,
+ BPListElement newEntry, boolean linkedMode,
+ boolean canCommitConflict, boolean allowConflict,
+ boolean allowRemoveProjectFolder, boolean allowAddExclusionPatterns,
+ IContainer parent) {
+ super(existingEntries, newEntry, getTitel(newEntry, linkedMode),
+ DLTKPluginImages.DESC_WIZBAN_NEWSRCFOLDR);
+ fLinkedMode = linkedMode;
+ fCanCommitConflict = canCommitConflict;
+ fAllowConflict = allowConflict;
+ fAllowRemoveProjectFolder = allowRemoveProjectFolder;
+ fAllowAddExclusionPatterns = allowAddExclusionPatterns;
+ fParent = parent;
}
private static String getTitel(BPListElement newEntry, boolean linkedMode) {
if (newEntry.getPath() == null) {
if (linkedMode) {
return NewWizardMessages.NewSourceFolderCreationWizard_link_title;
- } else {
- return NewWizardMessages.NewSourceFolderCreationWizard_title;
}
- } else {
- return NewWizardMessages.NewSourceFolderCreationWizard_edit_title;
+ return NewWizardMessages.NewSourceFolderCreationWizard_title;
}
+ return NewWizardMessages.NewSourceFolderCreationWizard_edit_title;
}
@Override
public void addPages() {
super.addPages();
- fAddFolderPage= new AddSourceFolderWizardPage(getEntryToEdit(), getExistingEntries(),
- fLinkedMode, fCanCommitConflict,
- fAllowConflict, fAllowRemoveProjectFolder, fAllowAddExclusionPatterns, fParent);
+ fAddFolderPage = new AddSourceFolderWizardPage(getEntryToEdit(),
+ getExistingEntries(), fLinkedMode, fCanCommitConflict,
+ fAllowConflict, fAllowRemoveProjectFolder,
+ fAllowAddExclusionPatterns, fParent);
addPage(fAddFolderPage);
- fFilterPage= new SetFilterWizardPage(getEntryToEdit(), getExistingEntries());
+ fFilterPage = new SetFilterWizardPage(getEntryToEdit(),
+ getExistingEntries());
addPage(fFilterPage);
}
@Override
public List getInsertedElements() {
- List result= super.getInsertedElements();
+ List result = super.getInsertedElements();
if (getEntryToEdit().getOrginalPath() == null)
result.add(getEntryToEdit());
@@ -89,10 +97,12 @@
@Override
public boolean performFinish() {
- getEntryToEdit().setAttribute(BPListElement.INCLUSION, fFilterPage.getInclusionPattern());
- getEntryToEdit().setAttribute(BPListElement.EXCLUSION, fFilterPage.getExclusionPattern());
+ getEntryToEdit().setAttribute(BPListElement.INCLUSION,
+ fFilterPage.getInclusionPattern());
+ getEntryToEdit().setAttribute(BPListElement.EXCLUSION,
+ fFilterPage.getExclusionPattern());
- boolean res= super.performFinish();
+ boolean res = super.performFinish();
if (res) {
selectAndReveal(fAddFolderPage.getCorrespondingResource());
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BPListElement.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BPListElement.java
index 3b8a0fd..74f0ba0 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BPListElement.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BPListElement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -215,10 +215,9 @@
return DLTKCore.newBuiltinEntry(fPath, accesRules,
extraAttributes, new IPath[0],
BuildpathEntry.INCLUDE_ALL, isExported(), fExternal);
- } else {
- return DLTKCore.newLibraryEntry(fPath, accesRules,
- extraAttributes, isExported(), fExternal);
}
+ return DLTKCore.newLibraryEntry(fPath, accesRules, extraAttributes,
+ isExported(), fExternal);
}
case IBuildpathEntry.BPE_PROJECT: {
IAccessRule[] accesRules = (IAccessRule[]) getAttribute(
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BPListLabelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BPListLabelProvider.java
index 95e1d89..2c8146d 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BPListLabelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BPListLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -49,8 +49,8 @@
IWorkbench workbench = DLTKUIPlugin.getDefault().getWorkbench();
- fProjectImage = workbench.getSharedImages().getImageDescriptor(
- IDE.SharedImages.IMG_OBJ_PROJECT);
+ fProjectImage = workbench.getSharedImages()
+ .getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT);
}
@Override
@@ -62,23 +62,19 @@
BPListElementAttribute attribute = (BPListElementAttribute) element;
String text = getCPListElementAttributeText(attribute);
if (attribute.isInNonModifiableContainer()) {
- return Messages
- .format(
- NewWizardMessages.CPListLabelProvider_non_modifiable_attribute,
- text);
+ return Messages.format(
+ NewWizardMessages.CPListLabelProvider_non_modifiable_attribute,
+ text);
}
return text;
} else if (element instanceof BPUserLibraryElement) {
return getCPUserLibraryText((BPUserLibraryElement) element);
} else if (element instanceof IAccessRule) {
IAccessRule rule = (IAccessRule) element;
- return Messages
- .format(
- NewWizardMessages.CPListLabelProvider_access_rules_label,
- new String[] {
- AccessRulesLabelProvider
- .getResolutionLabel(rule.getKind()),
- rule.getPattern().toString() });
+ return Messages.format(
+ NewWizardMessages.CPListLabelProvider_access_rules_label,
+ AccessRulesLabelProvider.getResolutionLabel(rule.getKind()),
+ rule.getPattern().toString());
}
return super.getText(element);
}
@@ -107,8 +103,8 @@
String pattern = patterns[i].toString();
if (pattern.length() > 0) {
if (patternsCount > 0) {
- buf
- .append(NewWizardMessages.CPListLabelProvider_exclusion_filter_separator);
+ buf.append(
+ NewWizardMessages.CPListLabelProvider_exclusion_filter_separator);
}
buf.append(pattern);
patternsCount++;
@@ -122,10 +118,9 @@
} else {
arg = notAvailable;
}
- return Messages
- .format(
- NewWizardMessages.CPListLabelProvider_exclusion_filter_label,
- new String[] { arg });
+ return Messages.format(
+ NewWizardMessages.CPListLabelProvider_exclusion_filter_label,
+ arg);
} else if (key.equals(BPListElement.INCLUSION)) {
String arg = null;
IPath[] patterns = (IPath[]) attrib.getValue();
@@ -136,8 +131,8 @@
String pattern = patterns[i].toString();
if (pattern.length() > 0) {
if (patternsCount > 0) {
- buf
- .append(NewWizardMessages.CPListLabelProvider_inclusion_filter_separator);
+ buf.append(
+ NewWizardMessages.CPListLabelProvider_inclusion_filter_separator);
}
buf.append(pattern);
patternsCount++;
@@ -151,51 +146,42 @@
} else {
arg = NewWizardMessages.CPListLabelProvider_all;
}
- return Messages
- .format(
- NewWizardMessages.CPListLabelProvider_inclusion_filter_label,
- new String[] { arg });
+ return Messages.format(
+ NewWizardMessages.CPListLabelProvider_inclusion_filter_label,
+ arg);
} else if (key.equals(BPListElement.ACCESSRULES)) {
IAccessRule[] rules = (IAccessRule[]) attrib.getValue();
int nRules = rules != null ? rules.length : 0;
int parentKind = attrib.getParent().getEntryKind();
if (parentKind == IBuildpathEntry.BPE_PROJECT) {
- Boolean combined = (Boolean) attrib.getParent().getAttribute(
- BPListElement.COMBINE_ACCESSRULES);
+ Boolean combined = (Boolean) attrib.getParent()
+ .getAttribute(BPListElement.COMBINE_ACCESSRULES);
if (nRules > 0) {
if (combined.booleanValue()) {
- return Messages
- .format(
- NewWizardMessages.CPListLabelProvider_project_access_rules_combined,
- String.valueOf(nRules));
- } else {
- return Messages
- .format(
- NewWizardMessages.CPListLabelProvider_project_access_rules_not_combined,
- String.valueOf(nRules));
+ return Messages.format(
+ NewWizardMessages.CPListLabelProvider_project_access_rules_combined,
+ String.valueOf(nRules));
}
- } else {
- return NewWizardMessages.CPListLabelProvider_project_access_rules_no_rules;
+ return Messages.format(
+ NewWizardMessages.CPListLabelProvider_project_access_rules_not_combined,
+ String.valueOf(nRules));
}
+ return NewWizardMessages.CPListLabelProvider_project_access_rules_no_rules;
} else if (parentKind == IBuildpathEntry.BPE_CONTAINER) {
if (nRules > 0) {
- return Messages
- .format(
- NewWizardMessages.CPListLabelProvider_container_access_rules,
- String.valueOf(nRules));
- } else {
- return NewWizardMessages.CPListLabelProvider_container_no_access_rules;
+ return Messages.format(
+ NewWizardMessages.CPListLabelProvider_container_access_rules,
+ String.valueOf(nRules));
}
+ return NewWizardMessages.CPListLabelProvider_container_no_access_rules;
} else {
if (nRules > 0) {
- return Messages
- .format(
- NewWizardMessages.CPListLabelProvider_access_rules_enabled,
- String.valueOf(nRules));
- } else {
- return NewWizardMessages.CPListLabelProvider_access_rules_disabled;
+ return Messages.format(
+ NewWizardMessages.CPListLabelProvider_access_rules_enabled,
+ String.valueOf(nRules));
}
+ return NewWizardMessages.CPListLabelProvider_access_rules_disabled;
}
}
if (DLTKCore.DEBUG) {
@@ -217,8 +203,8 @@
public String getCPListElementText(BPListElement cpentry) {
IPath path = cpentry.getPath();
- if (path.toString().startsWith(
- IBuildpathEntry.BUILTIN_EXTERNAL_ENTRY_STR)) {
+ if (path.toString()
+ .startsWith(IBuildpathEntry.BUILTIN_EXTERNAL_ENTRY_STR)) {
return ScriptElementLabels.BUILTINS_FRAGMENT;
}
if (EnvironmentPathUtils.isFull(path)) {
@@ -228,8 +214,8 @@
case IBuildpathEntry.BPE_LIBRARY: {
IResource resource = cpentry.getResource();
if (resource instanceof IContainer) {
- StringBuffer buf = new StringBuffer(path.makeRelative()
- .toString());
+ StringBuffer buf = new StringBuffer(
+ path.makeRelative().toString());
IPath linkTarget = cpentry.getLinkTarget();
if (linkTarget != null) {
buf.append(ScriptElementLabels.CONCAT_STRING);
@@ -252,9 +238,8 @@
// should not get here
if (!cpentry.isExternalFolder()) {
return path.makeRelative().toString();
- } else {
- return path.toString();
}
+ return path.toString();
}
case IBuildpathEntry.BPE_PROJECT:
return path.lastSegment();
@@ -270,10 +255,9 @@
if (initializer != null) {
String description = initializer.getDescription(path,
cpentry.getScriptProject());
- return Messages
- .format(
- NewWizardMessages.CPListLabelProvider_unbound_library,
- description);
+ return Messages.format(
+ NewWizardMessages.CPListLabelProvider_unbound_library,
+ description);
}
} catch (ModelException e) {
@@ -314,11 +298,9 @@
: appendedPath.makeRelative().toString();
return Messages.format(
NewWizardMessages.CPListLabelProvider_twopart,
- new String[] { path.lastSegment(), appended });
- } else {
- return isExternal ? path.toOSString() : path.makeRelative()
- .toString();
+ path.lastSegment(), appended);
}
+ return isExternal ? path.toOSString() : path.makeRelative().toString();
}
protected ImageDescriptor getCPListElementBaseImage(BPListElement cpentry) {
@@ -327,10 +309,9 @@
case IBuildpathEntry.BPE_SOURCE:
if (cpentry.getPath().segmentCount() == 1) {
return fProjectImage;
- } else {
- return DLTKPluginImages
- .getDescriptor(DLTKPluginImages.IMG_OBJS_PACKFRAG_ROOT);
}
+ return DLTKPluginImages
+ .getDescriptor(DLTKPluginImages.IMG_OBJS_PACKFRAG_ROOT);
case IBuildpathEntry.BPE_LIBRARY:
return DLTKPluginImages
.getDescriptor(DLTKPluginImages.IMG_OBJS_EXTZIP_WSRC);
@@ -349,7 +330,8 @@
if (element instanceof BPListElement) {
BPListElement cpentry = (BPListElement) element;
- ImageDescriptor imageDescriptor = getCPListElementBaseImage(cpentry);
+ ImageDescriptor imageDescriptor = getCPListElementBaseImage(
+ cpentry);
if (imageDescriptor != null) {
if (cpentry.isMissing()) {
imageDescriptor = new ScriptElementImageDescriptor(
@@ -362,11 +344,11 @@
} else if (element instanceof BPListElementAttribute) {
String key = ((BPListElementAttribute) element).getKey();
if (key.equals(BPListElement.EXCLUSION)) {
- return fRegistry
- .get(DLTKPluginImages.DESC_OBJS_EXCLUSION_FILTER_ATTRIB);
+ return fRegistry.get(
+ DLTKPluginImages.DESC_OBJS_EXCLUSION_FILTER_ATTRIB);
} else if (key.equals(BPListElement.INCLUSION)) {
- return fRegistry
- .get(DLTKPluginImages.DESC_OBJS_INCLUSION_FILTER_ATTRIB);
+ return fRegistry.get(
+ DLTKPluginImages.DESC_OBJS_INCLUSION_FILTER_ATTRIB);
} else if (key.equals(BPListElement.ACCESSRULES)) {
return fRegistry
.get(DLTKPluginImages.DESC_OBJS_ACCESSRULES_ATTRIB);
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/CreateMultipleSourceFoldersDialog.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/CreateMultipleSourceFoldersDialog.java
index a859d2d..c5c5e95 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/CreateMultipleSourceFoldersDialog.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/CreateMultipleSourceFoldersDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -42,13 +42,13 @@
import org.eclipse.ui.model.BaseWorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
-
public class CreateMultipleSourceFoldersDialog extends TrayDialog {
- private final class FakeFolderBaseWorkbenchContentProvider extends BaseWorkbenchContentProvider {
+ private final class FakeFolderBaseWorkbenchContentProvider
+ extends BaseWorkbenchContentProvider {
@Override
public Object getParent(Object element) {
- Object object= fNonExistingFolders.get(element);
+ Object object = fNonExistingFolders.get(element);
if (object != null)
return object;
@@ -57,11 +57,11 @@
@Override
public Object[] getChildren(Object element) {
- List result= new ArrayList();
- //all keys with value element
- Set keys= fNonExistingFolders.keySet();
- for (Iterator iter= keys.iterator(); iter.hasNext();) {
- Object key= iter.next();
+ List result = new ArrayList();
+ // all keys with value element
+ Set keys = fNonExistingFolders.keySet();
+ for (Iterator iter = keys.iterator(); iter.hasNext();) {
+ Object key = iter.next();
if (fNonExistingFolders.get(key).equals(element)) {
result.add(key);
}
@@ -69,8 +69,8 @@
if (result.size() == 0)
return super.getChildren(element);
- Object[] children= super.getChildren(element);
- for (int i= 0; i < children.length; i++) {
+ Object[] children = super.getChildren(element);
+ for (int i = 0; i < children.length; i++) {
result.add(children[i]);
}
return result.toArray();
@@ -84,17 +84,18 @@
private final HashSet fInsertedElements;
private final Hashtable fNonExistingFolders;
- public CreateMultipleSourceFoldersDialog(final IScriptProject scriptProject, final BPListElement[] existingElements, Shell shell) {
+ public CreateMultipleSourceFoldersDialog(final IScriptProject scriptProject,
+ final BPListElement[] existingElements, Shell shell) {
super(shell);
- fScriptProject= scriptProject;
- fExistingElements= existingElements;
- fRemovedElements= new HashSet();
- fModifiedElements= new HashSet();
- fInsertedElements= new HashSet();
- fNonExistingFolders= new Hashtable();
+ fScriptProject = scriptProject;
+ fExistingElements = existingElements;
+ fRemovedElements = new HashSet();
+ fModifiedElements = new HashSet();
+ fInsertedElements = new HashSet();
+ fNonExistingFolders = new Hashtable();
- for (int i= 0; i < existingElements.length; i++) {
- BPListElement cur= existingElements[i];
+ for (int i = 0; i < existingElements.length; i++) {
+ BPListElement cur = existingElements[i];
if (cur.getResource() == null || !cur.getResource().exists()) {
addFakeFolder(fScriptProject.getProject(), cur);
}
@@ -103,43 +104,49 @@
@Override
public int open() {
- Class[] acceptedClasses= new Class[] { IProject.class, IFolder.class };
- List existingContainers= getExistingContainers(fExistingElements);
+ Class[] acceptedClasses = new Class[] { IProject.class, IFolder.class };
+ List existingContainers = getExistingContainers(fExistingElements);
- IProject[] allProjects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
- ArrayList rejectedElements= new ArrayList(allProjects.length);
- IProject currProject= fScriptProject.getProject();
- for (int i= 0; i < allProjects.length; i++) {
+ IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot()
+ .getProjects();
+ ArrayList rejectedElements = new ArrayList(allProjects.length);
+ IProject currProject = fScriptProject.getProject();
+ for (int i = 0; i < allProjects.length; i++) {
if (!allProjects[i].equals(currProject)) {
rejectedElements.add(allProjects[i]);
}
}
- ViewerFilter filter= new TypedViewerFilter(acceptedClasses, rejectedElements.toArray());
+ ViewerFilter filter = new TypedViewerFilter(acceptedClasses,
+ rejectedElements.toArray());
- ILabelProvider lp= new WorkbenchLabelProvider();
- ITreeContentProvider cp= new FakeFolderBaseWorkbenchContentProvider();
+ ILabelProvider lp = new WorkbenchLabelProvider();
+ ITreeContentProvider cp = new FakeFolderBaseWorkbenchContentProvider();
- String title= NewWizardMessages.SourceContainerWorkbookPage_ExistingSourceFolderDialog_new_title;
- String message= NewWizardMessages.SourceContainerWorkbookPage_ExistingSourceFolderDialog_edit_description;
+ String title = NewWizardMessages.SourceContainerWorkbookPage_ExistingSourceFolderDialog_new_title;
+ String message = NewWizardMessages.SourceContainerWorkbookPage_ExistingSourceFolderDialog_edit_description;
-
- MultipleFolderSelectionDialog dialog= new MultipleFolderSelectionDialog(getShell(), lp, cp) {
+ MultipleFolderSelectionDialog dialog = new MultipleFolderSelectionDialog(
+ getShell(), lp, cp) {
@Override
protected Control createDialogArea(Composite parent) {
- Control result= super.createDialogArea(parent);
+ Control result = super.createDialogArea(parent);
if (DLTKCore.DEBUG) {
- System.err.println("CreateMultipleSourceFoldersDialog: Add help support"); //$NON-NLS-1$
+ System.err.println(
+ "CreateMultipleSourceFoldersDialog: Add help support"); //$NON-NLS-1$
}
- //PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IDLTKHelpContextIds.BP_CHOOSE_EXISTING_FOLDER_TO_MAKE_SOURCE_FOLDER);
+ // PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
+ // IDLTKHelpContextIds.BP_CHOOSE_EXISTING_FOLDER_TO_MAKE_SOURCE_FOLDER);
return result;
}
@Override
protected Object createFolder(final IContainer container) {
- final Object[] result= new Object[1];
- final BPListElement newElement= new BPListElement(fScriptProject, IBuildpathEntry.BPE_SOURCE, false);
- final AddSourceFolderWizard wizard= newSourceFolderWizard(newElement, fExistingElements, container);
- AbstractOpenWizardAction action= new AbstractOpenWizardAction() {
+ final Object[] result = new Object[1];
+ final BPListElement newElement = new BPListElement(
+ fScriptProject, IBuildpathEntry.BPE_SOURCE, false);
+ final AddSourceFolderWizard wizard = newSourceFolderWizard(
+ newElement, fExistingElements, container);
+ AbstractOpenWizardAction action = new AbstractOpenWizardAction() {
@Override
protected INewWizard createWizard() throws CoreException {
return wizard;
@@ -148,7 +155,8 @@
action.addPropertyChangeListener(event -> {
if (event.getProperty().equals(IAction.RESULT)) {
if (event.getNewValue().equals(Boolean.TRUE)) {
- result[0]= addFakeFolder(fScriptProject.getProject(), newElement);
+ result[0] = addFakeFolder(
+ fScriptProject.getProject(), newElement);
} else {
wizard.cancel();
}
@@ -166,23 +174,24 @@
dialog.setInitialFocus(fScriptProject.getProject());
if (dialog.open() == Window.OK) {
- Object[] elements= dialog.getResult();
- for (int i= 0; i < elements.length; i++) {
- IResource res= (IResource)elements[i];
- fInsertedElements.add(new BPListElement(fScriptProject, IBuildpathEntry.BPE_SOURCE, res.getFullPath(), res, false));
+ Object[] elements = dialog.getResult();
+ for (int i = 0; i < elements.length; i++) {
+ IResource res = (IResource) elements[i];
+ fInsertedElements.add(new BPListElement(fScriptProject,
+ IBuildpathEntry.BPE_SOURCE, res.getFullPath(), res,
+ false));
}
if (fExistingElements.length == 1) {
} else {
- ArrayList added= new ArrayList(fInsertedElements);
- HashSet updatedEclusionPatterns= new HashSet();
+ ArrayList added = new ArrayList(fInsertedElements);
+ HashSet updatedEclusionPatterns = new HashSet();
addExlusionPatterns(added, updatedEclusionPatterns);
fModifiedElements.addAll(updatedEclusionPatterns);
}
return Window.OK;
- } else {
- return Window.CANCEL;
}
+ return Window.CANCEL;
}
public List getInsertedElements() {
@@ -203,50 +212,53 @@
newEntries.toArray(new BPListElement[newEntries.size()]),
fExistingElements, modifiedEntries);
if (!modifiedEntries.isEmpty()) {
- String title= NewWizardMessages.SourceContainerWorkbookPage_exclusion_added_title;
- String message= NewWizardMessages.SourceContainerWorkbookPage_exclusion_added_message;
+ String title = NewWizardMessages.SourceContainerWorkbookPage_exclusion_added_title;
+ String message = NewWizardMessages.SourceContainerWorkbookPage_exclusion_added_message;
MessageDialog.openInformation(getShell(), title, message);
}
}
- private AddSourceFolderWizard newSourceFolderWizard(BPListElement element, BPListElement[] existing, IContainer parent) {
- AddSourceFolderWizard wizard= new AddSourceFolderWizard(existing, element, false, true, false, false, false, parent);
+ private AddSourceFolderWizard newSourceFolderWizard(BPListElement element,
+ BPListElement[] existing, IContainer parent) {
+ AddSourceFolderWizard wizard = new AddSourceFolderWizard(existing,
+ element, false, true, false, false, false, parent);
wizard.setDoFlushChange(false);
return wizard;
}
private List getExistingContainers(BPListElement[] existingElements) {
- List res= new ArrayList();
- for (int i= 0; i < existingElements.length; i++) {
- IResource resource= existingElements[i].getResource();
+ List res = new ArrayList();
+ for (int i = 0; i < existingElements.length; i++) {
+ IResource resource = existingElements[i].getResource();
if (resource instanceof IContainer) {
res.add(resource);
}
}
- Set keys= fNonExistingFolders.keySet();
- for (Iterator iter= keys.iterator(); iter.hasNext();) {
- IFolder folder= (IFolder)iter.next();
+ Set keys = fNonExistingFolders.keySet();
+ for (Iterator iter = keys.iterator(); iter.hasNext();) {
+ IFolder folder = (IFolder) iter.next();
res.add(folder);
}
return res;
}
- private IFolder addFakeFolder(final IContainer container, final BPListElement element) {
+ private IFolder addFakeFolder(final IContainer container,
+ final BPListElement element) {
IFolder result;
- IPath projectPath= fScriptProject.getPath();
- IPath path= element.getPath();
+ IPath projectPath = fScriptProject.getPath();
+ IPath path = element.getPath();
if (projectPath.isPrefixOf(path)) {
- path= path.removeFirstSegments(projectPath.segmentCount());
+ path = path.removeFirstSegments(projectPath.segmentCount());
}
- result= container.getFolder(path);
- IFolder folder= result;
+ result = container.getFolder(path);
+ IFolder folder = result;
do {
- IContainer parent= folder.getParent();
+ IContainer parent = folder.getParent();
fNonExistingFolders.put(folder, parent);
if (parent instanceof IFolder) {
- folder= (IFolder)parent;
+ folder = (IFolder) parent;
} else {
- folder= null;
+ folder = null;
}
} while (folder != null && !folder.exists());
return result;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/newsourcepage/DialogPackageExplorerActionGroup.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/newsourcepage/DialogPackageExplorerActionGroup.java
index e050034..515e1ff 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/newsourcepage/DialogPackageExplorerActionGroup.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/newsourcepage/DialogPackageExplorerActionGroup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -83,9 +83,9 @@
* used.
*
* @param selection
- * the current selection
+ * the current selection
* @param jProject
- * the element's script project
+ * the element's script project
*/
public DialogExplorerActionContext(ISelection selection,
IScriptProject jProject) {
@@ -106,9 +106,9 @@
* used.
*
* @param selectedElements
- * a list of currently selected elements
+ * a list of currently selected elements
* @param jProject
- * the element's script project
+ * the element's script project
*/
public DialogExplorerActionContext(List selectedElements,
IScriptProject jProject) {
@@ -178,11 +178,12 @@
* actions.
*
* @param provider
- * a information provider to pass necessary information to the
- * operations
+ * a information provider to pass necessary information
+ * to the operations
* @param listener
- * a listener for the changes on Buildpath entries, that is the
- * listener will be notified whenever a Buildpath entry changed.
+ * a listener for the changes on Buildpath entries, that
+ * is the listener will be notified whenever a Buildpath
+ * entry changed.
* @see IBuildpathModifierListener
*/
public DialogPackageExplorerActionGroup(
@@ -274,8 +275,8 @@
* Get an action of the specified type
*
* @param type
- * the type of the desired action, must be a constante of
- * <code>IBuildpathInformationProvider</code>
+ * the type of the desired action, must be a constante of
+ * <code>IBuildpathInformationProvider</code>
* @return the requested action
*
* @see IBuildpathInformationProvider
@@ -309,7 +310,7 @@
* Create a toolbar manager for a given <code>ViewerPane</code>
*
* @param pane
- * the pane to create the <code>
+ * the pane to create the <code>
* ToolBarManager</code> for.
* @return the created <code>ToolBarManager</code>
*/
@@ -328,7 +329,7 @@
* Create a toolbar manager for a given <code>ViewerPane</code>
*
* @param pane
- * the pane to create the help toolbar for
+ * the pane to create the help toolbar for
* @return the created <code>ToolBarManager</code>
*/
public ToolBarManager createLeftToolBar(ViewerPane pane) {
@@ -397,7 +398,7 @@
* can be called.
*
* @param context
- * the action context
+ * the action context
*
* @see IPackageExplorerActionListener
* @see PackageExplorerActionEvent
@@ -406,7 +407,8 @@
* @see #refresh(DialogExplorerActionContext)
*
* @throws ModelException
- * if there is a failure while computing the available actions.
+ * if there is a failure while computing the
+ * available actions.
*/
public void setContext(DialogExplorerActionContext context)
throws ModelException {
@@ -455,11 +457,11 @@
* Internal method to set the context of the action group.
*
* @param selectedElements
- * a list of selected elements, can be empty
+ * a list of selected elements, can be empty
* @param project
- * the script project
+ * the script project
* @param type
- * the type of the selected element(s)
+ * the type of the selected element(s)
* @throws ModelException
*/
private void internalSetContext(List selectedElements,
@@ -490,9 +492,9 @@
* therefore provides more information.
*
* @param elements
- * a list of elements to be compared to each other
+ * a list of elements to be compared to each other
* @param project
- * the script project
+ * the script project
* @return <code>true</code> if all elements are of the same type,
* <code>false</code> otherwise.
* @throws ModelException
@@ -516,11 +518,11 @@
* Inform all listeners about new actions.
*
* @param descriptions
- * an array of descriptions for each actions, where the
- * description at position 'i' belongs to the action at position
- * 'i'
+ * an array of descriptions for each actions, where
+ * the description at position 'i' belongs to the
+ * action at position 'i'
* @param actions
- * an array of available actions
+ * an array of available actions
*/
private void informListeners(String[] descriptions,
BuildpathModifierAction[] actions) {
@@ -575,7 +577,7 @@
* to set the content of the hint text group properly.
*
* @param obj
- * the object to get the type from
+ * the object to get the type from
* @return the type of the current selection or UNDEFINED if no appropriate
* type could be found. Possible types are:<br>
* PackageExplorerActionGroup.FOLDER<br>
@@ -648,7 +650,7 @@
* Get the type of the folder
*
* @param folder
- * folder to get the type from
+ * folder to get the type from
* @return the type code for the folder. Possible types are:<br>
* PackageExplorerActionGroup.FOLDER<br>
* PackageExplorerActionGroup.EXCLUDED_FOLDER;<br>
@@ -674,7 +676,7 @@
* Get the type of the file
*
* @param file
- * file to get the type from
+ * file to get the type from
* @return the type code for the file. Possible types are:<br>
* PackageExplorerActionGroup.EXCLUDED_FILE<br>
* PackageExplorerActionGroup.FILE
@@ -717,9 +719,9 @@
* that can be applied on this elements
*
* @param selectedElements
- * the list of elements to get the actions for
+ * the list of elements to get the actions for
* @param project
- * the script project
+ * the script project
* @return a list of <code>BuildpathModifierAction</code>s
* @throws ModelException
*/
@@ -757,12 +759,12 @@
* Changes the enabled state of an action if necessary.
*
* @param action
- * the action to change it's state for
+ * the action to change it's state for
* @param selectedElements
- * a list of selected elements
+ * a list of selected elements
* @param types
- * an array of types corresponding to the types of the selected
- * elements
+ * an array of types corresponding to the types
+ * of the selected elements
* @return <code>true</code> if the action is valid (= enabled),
* <code>false</code> otherwise
* @throws ModelException
@@ -773,18 +775,17 @@
if (!action.isEnabled())
action.setEnabled(true);
return true;
- } else {
- if (action.isEnabled())
- action.setEnabled(false);
- return false;
}
+ if (action.isEnabled())
+ action.setEnabled(false);
+ return false;
}
/**
* Fill the context menu with the available actions
*
* @param menu
- * the menu to be filled up with actions
+ * the menu to be filled up with actions
*/
@Override
public void fillContextMenu(IMenuManager menu) {
@@ -809,7 +810,7 @@
* Add listeners for the <code>PackageExplorerActionEvent</code>.
*
* @param listener
- * the listener to be added
+ * the listener to be added
*
* @see PackageExplorerActionEvent
* @see IPackageExplorerActionListener
@@ -822,7 +823,7 @@
* Remove the listener from the list of registered listeners.
*
* @param listener
- * the listener to be removed
+ * the listener to be removed
*/
public void removeListener(IPackageExplorerActionListener listener) {
fListeners.remove(listener);
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java
index 8042d61..bfc4348 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -39,38 +39,38 @@
/**
* Creates a group without border.
*/
- public SelectionButtonDialogFieldGroup(int buttonsStyle, String[] buttonNames, int nColumns) {
+ public SelectionButtonDialogFieldGroup(int buttonsStyle,
+ String[] buttonNames, int nColumns) {
this(buttonsStyle, buttonNames, nColumns, SWT.NONE);
}
-
/**
- * Creates a group with border (label in border).
- * Accepted button styles are: SWT.RADIO, SWT.CHECK, SWT.TOGGLE
- * For border styles see <code>Group</code>
+ * Creates a group with border (label in border). Accepted button styles
+ * are: SWT.RADIO, SWT.CHECK, SWT.TOGGLE For border styles see
+ * <code>Group</code>
*/
- public SelectionButtonDialogFieldGroup(int buttonsStyle, String[] buttonNames, int nColumns, int borderStyle) {
+ public SelectionButtonDialogFieldGroup(int buttonsStyle,
+ String[] buttonNames, int nColumns, int borderStyle) {
super();
- Assert.isTrue(buttonsStyle == SWT.RADIO || buttonsStyle == SWT.CHECK || buttonsStyle == SWT.TOGGLE);
- fButtonNames= buttonNames;
- fButtonsStyle= buttonsStyle;
+ Assert.isTrue(buttonsStyle == SWT.RADIO || buttonsStyle == SWT.CHECK
+ || buttonsStyle == SWT.TOGGLE);
+ fButtonNames = buttonNames;
+ fButtonsStyle = buttonsStyle;
- int nButtons= buttonNames.length;
- fButtonsSelected= new boolean[nButtons];
- fButtonsEnabled= new boolean[nButtons];
- for (int i= 0; i < nButtons; i++) {
- fButtonsSelected[i]= false;
- fButtonsEnabled[i]= true;
+ int nButtons = buttonNames.length;
+ fButtonsSelected = new boolean[nButtons];
+ fButtonsEnabled = new boolean[nButtons];
+ for (int i = 0; i < nButtons; i++) {
+ fButtonsSelected[i] = false;
+ fButtonsEnabled[i] = true;
}
if (buttonsStyle == SWT.RADIO) {
- fButtonsSelected[0]= true;
+ fButtonsSelected[0] = true;
}
- fGroupBorderStyle= borderStyle;
- fGroupNumberOfColumns= (nColumns <= 0) ? nButtons : nColumns;
-
-
+ fGroupBorderStyle = borderStyle;
+ fGroupNumberOfColumns = (nColumns <= 0) ? nButtons : nColumns;
}
@@ -81,23 +81,22 @@
assertEnoughColumns(nColumns);
if (fGroupBorderStyle == SWT.NONE) {
- Label label= getLabelControl(parent);
+ Label label = getLabelControl(parent);
label.setLayoutData(gridDataForLabel(1));
- Composite buttonsgroup= getSelectionButtonsGroup(parent);
- GridData gd= new GridData();
- gd.horizontalSpan= nColumns - 1;
+ Composite buttonsgroup = getSelectionButtonsGroup(parent);
+ GridData gd = new GridData();
+ gd.horizontalSpan = nColumns - 1;
buttonsgroup.setLayoutData(gd);
return new Control[] { label, buttonsgroup };
- } else {
- Composite buttonsgroup= getSelectionButtonsGroup(parent);
- GridData gd= new GridData();
- gd.horizontalSpan= nColumns;
- buttonsgroup.setLayoutData(gd);
-
- return new Control[] { buttonsgroup };
}
+ Composite buttonsgroup = getSelectionButtonsGroup(parent);
+ GridData gd = new GridData();
+ gd.horizontalSpan = nColumns;
+ buttonsgroup.setLayoutData(gd);
+
+ return new Control[] { buttonsgroup };
}
@Override
@@ -107,8 +106,9 @@
// ------- ui creation
- private Button createSelectionButton(int index, Composite group, SelectionListener listener) {
- Button button= new Button(group, fButtonsStyle | SWT.LEFT);
+ private Button createSelectionButton(int index, Composite group,
+ SelectionListener listener) {
+ Button button = new Button(group, fButtonsStyle | SWT.LEFT);
button.setFont(group.getFont());
button.setText(fButtonNames[index]);
button.setEnabled(isEnabled() && fButtonsEnabled[index]);
@@ -119,52 +119,57 @@
}
/**
- * Returns the group widget. When called the first time, the widget will be created.
- * @param parent The parent composite when called the first time, or <code>null</code>
- * after.
+ * Returns the group widget. When called the first time, the widget will be
+ * created.
+ *
+ * @param parent
+ * The parent composite when called the first time, or
+ * <code>null</code> after.
*/
public Composite getSelectionButtonsGroup(Composite parent) {
if (fButtonComposite == null) {
assertCompositeNotNull(parent);
- GridLayout layout= new GridLayout();
- layout.makeColumnsEqualWidth= true;
- layout.numColumns= fGroupNumberOfColumns;
+ GridLayout layout = new GridLayout();
+ layout.makeColumnsEqualWidth = true;
+ layout.numColumns = fGroupNumberOfColumns;
if (fGroupBorderStyle != SWT.NONE) {
- Group group= new Group(parent, fGroupBorderStyle);
+ Group group = new Group(parent, fGroupBorderStyle);
group.setFont(parent.getFont());
if (fLabelText != null && fLabelText.length() > 0) {
group.setText(fLabelText);
}
- fButtonComposite= group;
+ fButtonComposite = group;
} else {
- fButtonComposite= new Composite(parent, SWT.NONE);
+ fButtonComposite = new Composite(parent, SWT.NONE);
fButtonComposite.setFont(parent.getFont());
- layout.marginHeight= 0;
- layout.marginWidth= 0;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
}
fButtonComposite.setLayout(layout);
- SelectionListener listener= new SelectionListener() {
+ SelectionListener listener = new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
doWidgetSelected(e);
}
+
@Override
public void widgetSelected(SelectionEvent e) {
doWidgetSelected(e);
}
};
- int nButtons= fButtonNames.length;
- fButtons= new Button[nButtons];
- for (int i= 0; i < nButtons; i++) {
- fButtons[i]= createSelectionButton(i, fButtonComposite, listener);
+ int nButtons = fButtonNames.length;
+ fButtons = new Button[nButtons];
+ for (int i = 0; i < nButtons; i++) {
+ fButtons[i] = createSelectionButton(i, fButtonComposite,
+ listener);
}
- int nRows= nButtons / fGroupNumberOfColumns;
- int nFillElements= nRows * fGroupNumberOfColumns - nButtons;
- for (int i= 0; i < nFillElements; i++) {
+ int nRows = nButtons / fGroupNumberOfColumns;
+ int nFillElements = nRows * fGroupNumberOfColumns - nButtons;
+ for (int i = 0; i < nFillElements; i++) {
createEmptySpace(fButtonComposite);
}
}
@@ -182,10 +187,10 @@
}
private void doWidgetSelected(SelectionEvent e) {
- Button button= (Button)e.widget;
- for (int i= 0; i < fButtons.length; i++) {
+ Button button = (Button) e.widget;
+ for (int i = 0; i < fButtons.length; i++) {
if (fButtons[i] == button) {
- fButtonsSelected[i]= button.getSelection();
+ fButtonsSelected[i] = button.getSelection();
dialogFieldChanged();
return;
}
@@ -196,7 +201,9 @@
/**
* Returns the selection state of a button contained in the group.
- * @param index The index of the button
+ *
+ * @param index
+ * The index of the button
*/
public boolean isSelected(int index) {
if (index >= 0 && index < fButtonsSelected.length) {
@@ -211,9 +218,9 @@
public void setSelection(int index, boolean selected) {
if (index >= 0 && index < fButtonsSelected.length) {
if (fButtonsSelected[index] != selected) {
- fButtonsSelected[index]= selected;
+ fButtonsSelected[index] = selected;
if (fButtons != null) {
- Button button= fButtons[index];
+ Button button = fButtons[index];
if (isOkToUse(button)) {
button.setSelection(selected);
}
@@ -228,9 +235,9 @@
protected void updateEnableState() {
super.updateEnableState();
if (fButtons != null) {
- boolean enabled= isEnabled();
- for (int i= 0; i < fButtons.length; i++) {
- Button button= fButtons[i];
+ boolean enabled = isEnabled();
+ for (int i = 0; i < fButtons.length; i++) {
+ Button button = fButtons[i];
if (isOkToUse(button)) {
button.setEnabled(enabled && fButtonsEnabled[i]);
}
@@ -243,9 +250,9 @@
*/
public void enableSelectionButton(int index, boolean enable) {
if (index >= 0 && index < fButtonsEnabled.length) {
- fButtonsEnabled[index]= enable;
+ fButtonsEnabled[index] = enable;
if (fButtons != null) {
- Button button= fButtons[index];
+ Button button = fButtons[index];
if (isOkToUse(button)) {
button.setEnabled(isEnabled() && enable);
}
@@ -256,8 +263,8 @@
@Override
public void refresh() {
super.refresh();
- for (int i= 0; i < fButtons.length; i++) {
- Button button= fButtons[i];
+ for (int i = 0; i < fButtons.length; i++) {
+ Button button = fButtons[i];
if (isOkToUse(button)) {
button.setSelection(fButtonsSelected[i]);
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/AbstractWorkingSetWizardPage.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/AbstractWorkingSetWizardPage.java
index 998ed2a..afe1343 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/AbstractWorkingSetWizardPage.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/AbstractWorkingSetWizardPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -22,7 +22,8 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.IWorkingSetPage;
-public abstract class AbstractWorkingSetWizardPage extends WizardPage implements IWorkingSetPage {
+public abstract class AbstractWorkingSetWizardPage extends WizardPage
+ implements IWorkingSetPage {
private boolean fIsFirstValidation;
private Text fWorkingSetName;
@@ -31,7 +32,8 @@
/**
* Default constructor.
*/
- public AbstractWorkingSetWizardPage(String pageid, String title, ImageDescriptor image) {
+ public AbstractWorkingSetWizardPage(String pageid, String title,
+ ImageDescriptor image) {
super(pageid, title, image);
}
@@ -39,21 +41,23 @@
public void createControl(Composite parent) {
initializeDialogUnits(parent);
- Composite composite= new Composite(parent, SWT.NONE);
+ Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
setControl(composite);
- Label label= new Label(composite, SWT.WRAP);
- label.setText(WorkingSetMessages.AbstractWorkingSetPage_workingSet_name);
- GridData gd= new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
+ Label label = new Label(composite, SWT.WRAP);
+ label.setText(
+ WorkingSetMessages.AbstractWorkingSetPage_workingSet_name);
+ GridData gd = new GridData(
+ GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_CENTER);
label.setLayoutData(gd);
- fWorkingSetName= new Text(composite, SWT.SINGLE | SWT.BORDER);
- fWorkingSetName.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
- fWorkingSetName.addModifyListener(
- e -> validateInput()
- );
+ fWorkingSetName = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ fWorkingSetName.setLayoutData(new GridData(
+ GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
+ fWorkingSetName.addModifyListener(e -> validateInput());
fWorkingSetName.setFocus();
Dialog.applyDialogFont(composite);
@@ -67,8 +71,9 @@
@Override
public void setSelection(IWorkingSet workingSet) {
Assert.isNotNull(workingSet, "Working set must not be null"); //$NON-NLS-1$
- fWorkingSet= workingSet;
- if (getContainer() != null && getShell() != null && fWorkingSetName != null) {
+ fWorkingSet = workingSet;
+ if (getContainer() != null && getShell() != null
+ && fWorkingSetName != null) {
fWorkingSetName.setText(fWorkingSet.getName());
validateInput();
}
@@ -76,9 +81,9 @@
@Override
public void finish() {
- String workingSetName= fWorkingSetName.getText();
+ String workingSetName = fWorkingSetName.getText();
if (fWorkingSet == null) {
- fWorkingSet= createWorkingSet(workingSetName);
+ fWorkingSet = createWorkingSet(workingSetName);
}
fWorkingSet.setName(workingSetName);
}
@@ -86,28 +91,29 @@
protected abstract IWorkingSet createWorkingSet(String workingSetName);
private void validateInput() {
- String errorMessage= null;
- String newText= fWorkingSetName.getText();
+ String errorMessage = null;
+ String newText = fWorkingSetName.getText();
if (newText.equals(newText.trim()) == false)
errorMessage = WorkingSetMessages.AbstractWorkingSetPage_warning_nameWhitespace;
if (newText.equals("")) { //$NON-NLS-1$
if (fIsFirstValidation) {
setPageComplete(false);
- fIsFirstValidation= false;
+ fIsFirstValidation = false;
return;
- } else {
- errorMessage= WorkingSetMessages.AbstractWorkingSetPage_warning_nameMustNotBeEmpty;
}
+ errorMessage = WorkingSetMessages.AbstractWorkingSetPage_warning_nameMustNotBeEmpty;
}
- fIsFirstValidation= false;
+ fIsFirstValidation = false;
- if (errorMessage == null && (fWorkingSet == null || newText.equals(fWorkingSet.getName()) == false)) {
- IWorkingSet[] workingSets= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSets();
- for (int i= 0; i < workingSets.length; i++) {
+ if (errorMessage == null && (fWorkingSet == null
+ || newText.equals(fWorkingSet.getName()) == false)) {
+ IWorkingSet[] workingSets = PlatformUI.getWorkbench()
+ .getWorkingSetManager().getWorkingSets();
+ for (int i = 0; i < workingSets.length; i++) {
if (newText.equals(workingSets[i].getName())) {
- errorMessage= WorkingSetMessages.AbstractWorkingSetPage_warning_workingSetExists;
+ errorMessage = WorkingSetMessages.AbstractWorkingSetPage_warning_workingSetExists;
}
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/OpenCloseWorkingSetAction.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/OpenCloseWorkingSetAction.java
index 74e2bcb..8452bc4 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/OpenCloseWorkingSetAction.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/workingsets/OpenCloseWorkingSetAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -36,16 +36,19 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDEActionFactory;
+public abstract class OpenCloseWorkingSetAction extends SelectionDispatchAction
+ implements IResourceChangeListener {
-public abstract class OpenCloseWorkingSetAction extends SelectionDispatchAction implements IResourceChangeListener {
-
- private static final class CloseWorkingSetAction extends OpenCloseWorkingSetAction {
+ private static final class CloseWorkingSetAction
+ extends OpenCloseWorkingSetAction {
private IAction fProjectAction;
+
private CloseWorkingSetAction(IWorkbenchSite site, String label) {
super(site, label);
- IActionBars actionBars= getActionBars();
+ IActionBars actionBars = getActionBars();
if (actionBars != null) {
- fProjectAction= actionBars.getGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId());
+ fProjectAction = actionBars.getGlobalActionHandler(
+ IDEActionFactory.CLOSE_PROJECT.getId());
}
}
@@ -55,19 +58,22 @@
}
@Override
- protected void performOperation(IProject project, IProgressMonitor monitor) throws CoreException {
+ protected void performOperation(IProject project,
+ IProgressMonitor monitor) throws CoreException {
project.close(monitor);
}
@Override
protected void connectToActionBar(IActionBars actionBars) {
- actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(), this);
+ actionBars.setGlobalActionHandler(
+ IDEActionFactory.CLOSE_PROJECT.getId(), this);
actionBars.updateActionBars();
}
@Override
protected void disconnectFromActionBar(IActionBars actionBars) {
- actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(), fProjectAction);
+ actionBars.setGlobalActionHandler(
+ IDEActionFactory.CLOSE_PROJECT.getId(), fProjectAction);
actionBars.updateActionBars();
}
@@ -82,13 +88,16 @@
}
}
- private static final class OpenWorkingSetAction extends OpenCloseWorkingSetAction {
+ private static final class OpenWorkingSetAction
+ extends OpenCloseWorkingSetAction {
private IAction fProjectAction;
+
private OpenWorkingSetAction(IWorkbenchSite site, String label) {
super(site, label);
- IActionBars actionBars= getActionBars();
+ IActionBars actionBars = getActionBars();
if (actionBars != null) {
- fProjectAction= actionBars.getGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId());
+ fProjectAction = actionBars.getGlobalActionHandler(
+ IDEActionFactory.OPEN_PROJECT.getId());
}
}
@@ -98,19 +107,22 @@
}
@Override
- protected void performOperation(IProject project, IProgressMonitor monitor) throws CoreException {
+ protected void performOperation(IProject project,
+ IProgressMonitor monitor) throws CoreException {
project.open(monitor);
}
@Override
protected void connectToActionBar(IActionBars actionBars) {
- actionBars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(), this);
+ actionBars.setGlobalActionHandler(
+ IDEActionFactory.OPEN_PROJECT.getId(), this);
actionBars.updateActionBars();
}
@Override
protected void disconnectFromActionBar(IActionBars actionBars) {
- actionBars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(), fProjectAction);
+ actionBars.setGlobalActionHandler(
+ IDEActionFactory.OPEN_PROJECT.getId(), fProjectAction);
actionBars.updateActionBars();
}
@@ -128,15 +140,20 @@
private OpenCloseWorkingSetAction(IWorkbenchSite site, String label) {
super(site);
setText(label);
- ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(this,
+ IResourceChangeEvent.POST_CHANGE);
}
- public static OpenCloseWorkingSetAction createCloseAction(IWorkbenchSite site) {
- return new CloseWorkingSetAction(site, WorkingSetMessages.OpenCloseWorkingSetAction_close_label);
+ public static OpenCloseWorkingSetAction createCloseAction(
+ IWorkbenchSite site) {
+ return new CloseWorkingSetAction(site,
+ WorkingSetMessages.OpenCloseWorkingSetAction_close_label);
}
- public static OpenCloseWorkingSetAction createOpenAction(IWorkbenchSite site) {
- return new OpenWorkingSetAction(site, WorkingSetMessages.OpenCloseWorkingSetAction_open_label);
+ public static OpenCloseWorkingSetAction createOpenAction(
+ IWorkbenchSite site) {
+ return new OpenWorkingSetAction(site,
+ WorkingSetMessages.OpenCloseWorkingSetAction_open_label);
}
public void dispose() {
@@ -145,8 +162,8 @@
@Override
public void selectionChanged(IStructuredSelection selection) {
- List projects= getProjects(selection);
- IActionBars actionBars= getActionBars();
+ List projects = getProjects(selection);
+ IActionBars actionBars = getActionBars();
if (projects != null && projects.size() > 0) {
setEnabled(true);
if (actionBars != null) {
@@ -162,7 +179,7 @@
@Override
public void run(IStructuredSelection selection) {
- final List projects= getProjects(selection);
+ final List projects = getProjects(selection);
if (projects != null && projects.size() > 0) {
try {
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(
@@ -173,11 +190,12 @@
IProject project = (IProject) iter.next();
performOperation(project,
new SubProgressMonitor(monitor, 1));
- }
+ }
monitor.done();
- }));
+ }));
} catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, getShell(), getErrorTitle(), getErrorMessage());
+ ExceptionHandler.handle(e, getShell(), getErrorTitle(),
+ getErrorMessage());
} catch (InterruptedException e) {
// do nothing. Got cancelled.
}
@@ -186,7 +204,8 @@
protected abstract boolean validate(IProject project);