From 6de0d0163b7be783cbbb328ab09fd8523637d38c Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Tue, 30 Dec 2014 10:05:19 -0800 Subject: [PATCH] Cosmetics. --- .../org/eclipse/cdt/core/model/CoreModel.java | 38 +++--- .../org/eclipse/cdt/core/model/ICModel.java | 120 +++++++++--------- .../cdt/core/settings/model/ACPathEntry.java | 31 +---- .../core/model/CoreModelMessages.java | 17 +-- .../core/model/CoreModelMessages.properties | 6 +- .../core/model/SourceManipulationInfo.java | 66 ++++------ .../rename/CRenameClassProcessor.java | 4 +- 7 files changed, 122 insertions(+), 160 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java index 70bd98c4179..83810224289 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java @@ -167,7 +167,7 @@ public class CoreModel { } /** - * Return true if IFile is a shared library, i.e. libxx.so + * Returns true if IFile is a shared library, i.e. libxx.so */ public boolean isSharedLib(IFile file) { ICElement celement = create(file); @@ -178,7 +178,7 @@ public class CoreModel { } /** - * Return true if IFile is a an object(ELF), i.e. *.o + * Returns true if IFile is a an object(ELF), i.e. *.o */ public boolean isObject(IFile file) { ICElement celement = create(file); @@ -189,7 +189,7 @@ public class CoreModel { } /** - * Return true if IFile is an ELF executable + * Returns true if IFile is an ELF executable */ public boolean isExecutable(IFile file) { ICElement celement = create(file); @@ -200,7 +200,7 @@ public class CoreModel { } /** - * Return true if IFile is an ELF. + * Returns true if IFile is an ELF. */ public boolean isBinary(IFile file) { ICElement celement = create(file); @@ -208,7 +208,7 @@ public class CoreModel { } /** - * Return true if IFile is an Achive, *.a + * Returns true if IFile is an Achive, *.a */ public boolean isArchive(IFile file) { ICElement celement = create(file); @@ -216,7 +216,7 @@ public class CoreModel { } /** - * Return true if IFile is a possible TranslationUnit. + * Returns true if IFile is a possible TranslationUnit. */ public static boolean isTranslationUnit(IFile file) { if (file != null) { @@ -229,7 +229,7 @@ public class CoreModel { } /** - * Return an array of the register contentTypes. + * Returns an array of the register contentTypes. * @return String[] ids */ public static String[] getRegistedContentTypeIds() { @@ -237,7 +237,7 @@ public class CoreModel { } /** - * Return true if name is a valid name for a translation unit. + * Returns true if name is a valid name for a translation unit. */ public static boolean isValidTranslationUnitName(IProject project, String name) { IContentType contentType = CCorePlugin.getContentType(project, name); @@ -254,7 +254,7 @@ public class CoreModel { } /** - * Return true if name is a valid name for a translation unit. + * Returns true if name is a valid name for a translation unit. */ public static boolean isValidHeaderUnitName(IProject project, String name) { IContentType contentType = CCorePlugin.getContentType(project, name); @@ -269,7 +269,7 @@ public class CoreModel { } /** - * Return true if name is a valid name for a translation unit. + * Returns true if name is a valid name for a translation unit. */ public static boolean isValidSourceUnitName(IProject project, String name) { IContentType contentType = CCorePlugin.getContentType(project, name); @@ -289,7 +289,7 @@ public class CoreModel { } /** - * Return true if name is a valid name for a translation unit. + * Returns true if name is a valid name for a translation unit. */ public static boolean isValidCSourceUnitName(IProject project, String name) { IContentType contentType = CCorePlugin.getContentType(project, name); @@ -303,7 +303,7 @@ public class CoreModel { } /** - * Return true if name is a valid name for a translation unit. + * Returns true if name is a valid name for a translation unit. */ public static boolean isValidCXXSourceUnitName(IProject project, String name) { IContentType contentType = CCorePlugin.getContentType(project, name); @@ -317,7 +317,7 @@ public class CoreModel { } /** - * Return true if name is a valid name for a translation unit. + * Returns true if name is a valid name for a translation unit. */ public static boolean isValidASMSourceUnitName(IProject project, String name) { IContentType contentType = CCorePlugin.getContentType(project, name); @@ -331,7 +331,7 @@ public class CoreModel { } /** - * Return true if name is a valid name for a translation unit. + * Returns true if name is a valid name for a translation unit. */ public static boolean isValidCXXHeaderUnitName(IProject project, String name) { IContentType contentType = CCorePlugin.getContentType(project, name); @@ -345,7 +345,7 @@ public class CoreModel { } /** - * Return true if name is a valid name for a translation unit. + * Returns true if name is a valid name for a translation unit. */ public static boolean isValidCHeaderUnitName(IProject project, String name) { IContentType contentType = CCorePlugin.getContentType(project, name); @@ -379,7 +379,7 @@ public class CoreModel { } /** - * Return true if project has C nature. + * Returns true if project has C nature. */ public static boolean hasCNature(IProject project) { try { @@ -390,7 +390,7 @@ public class CoreModel { } /** - * Return true if project has C++ nature. + * Returns true if project has C++ nature. */ public static boolean hasCCNature(IProject project) { try { @@ -1036,7 +1036,7 @@ public class CoreModel { } /** - * Return the IPathEntryStore of the project. + * Returns the IPathEntryStore of the project. * @throws CoreException */ public static IPathEntryStore getPathEntryStore(IProject project) throws CoreException { @@ -1113,7 +1113,7 @@ public class CoreModel { } /** - * Return the singleton. + * Returns the singleton. */ public static CoreModel getDefault() { if (cmodel == null) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICModel.java index f2aa60b02b0..d146136a669 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICModel.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICModel.java @@ -19,11 +19,10 @@ import org.eclipse.core.runtime.IProgressMonitor; * the C model element. * The C model element needs to be opened before it can be navigated or manipulated. * The C model element has no parent (it is the root of the C element - * hierarchy). Its children are ICProjects. + * hierarchy). Its children are {@code ICProject}s. *

* This interface provides methods for performing copy, move, rename, and * delete operations on multiple C elements. - *

* * @see CoreModel#create(org.eclipse.core.resources.IWorkspaceRoot) * @@ -39,56 +38,55 @@ public interface ICModel extends ICElement, IParent, IOpenable { * its associated container. *

* Optionally, each copy can positioned before a sibling - * element. If null is specified for a given sibling, the copy + * element. If {@code null} is specified for a given sibling, the copy * is inserted as the last child of its associated container. - *

*

* Optionally, each copy can be renamed. If - * null is specified for the new name, the copy + * {@code null} is specified for the new name, the copy * is not renamed. - *

*

* Optionally, any existing child in the destination container with - * the same name can be replaced by specifying true for + * the same name can be replaced by specifying {@code true} for * force. Otherwise an exception is thrown in the event that a name * collision occurs. - *

* * @param elements the elements to copy * @param containers the container, or list of containers - * @param siblings the list of siblings element any of which may be - * null; or null - * @param renamings the list of new names any of which may be - * null; or null - * @param replace true if any existing child in a target container - * with the target name should be replaced, and false to throw an - * exception in the event of a name collision + * @param siblings the list of sibling elements, any of which may be + * {@code null}, or {@code null} + * @param renamings the list of new names, any of which may be + * {@code null}, or {@code null} + * @param replace {@code true} if any existing child in a target container + * with the target name should be replaced, and {@code false} to throw an + * exception in the event of a name collision * @param monitor a progress monitor * @exception CModelException if an element could not be copied. Reasons include: * */ - void copy(ICElement[] elements, ICElement[] containers, ICElement[] siblings, String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException; + void copy(ICElement[] elements, ICElement[] containers, ICElement[] siblings, String[] renamings, + boolean replace, IProgressMonitor monitor) throws CModelException; /** * Deletes the given elements, forcing the operation if necessary and specified. * * @param elements the elements to delete * @param force a flag controlling whether underlying resources that are not - * in sync with the local file system will be tolerated + * in sync with the local file system will be tolerated * @param monitor a progress monitor * @exception CModelException if an element could not be deleted. Reasons include: * */ void delete(ICElement[] elements, boolean force, IProgressMonitor monitor) throws CModelException; @@ -101,46 +99,45 @@ public interface ICModel extends ICElement, IParent, IOpenable { * its associated container. *

* Optionally, each element can positioned before a sibling - * element. If null is specified for sibling, the element + * element. If {@code null} is specified for sibling, the element * is inserted as the last child of its associated container. - *

*

* Optionally, each element can be renamed. If - * null is specified for the new name, the element + * {@code null} is specified for the new name, the element * is not renamed. - *

*

* Optionally, any existing child in the destination container with - * the same name can be replaced by specifying true for + * the same name can be replaced by specifying {@code true} for * force. Otherwise an exception is thrown in the event that a name * collision occurs. - *

* * @param elements the elements to move * @param containers the container, or list of containers * @param siblings the list of siblings element any of which may be - * null; or null + * {@code null}; or {@code null} * @param renamings the list of new names any of which may be - * null; or null - * @param replace true if any existing child in a target container - * with the target name should be replaced, and false to throw an - * exception in the event of a name collision + * {@code null}; or {@code null} + * @param replace {@code true} if any existing child in a target container + * with the target name should be replaced, and {@code false} to throw an + * exception in the event of a name collision * @param monitor a progress monitor * @exception CModelException if an element could not be moved. Reasons include: * * - * @exception IllegalArgumentException any element or container is null + * @exception IllegalArgumentException any element or container is {@code null} */ - void move(ICElement[] elements, ICElement[] containers, ICElement[] siblings, String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException; + void move(ICElement[] elements, ICElement[] containers, ICElement[] siblings, String[] renamings, + boolean replace, IProgressMonitor monitor) throws CModelException; /** * Renames the given elements as specified. @@ -152,46 +149,44 @@ public interface ICModel extends ICElement, IParent, IOpenable { * @param elements the elements to rename * @param destinations the container, or list of containers * @param names the list of new names - * @param replace true if an existing child in a target container - * with the target name should be replaced, and false to throw an - * exception in the event of a name collision + * @param replace {@code true} if an existing child in a target container + * with the target name should be replaced, and {@code false} to throw an + * exception in the event of a name collision * @param monitor a progress monitor * @exception CModelException if an element could not be renamed. Reasons include: * */ - void rename(ICElement[] elements, ICElement[] destinations, String[] names, boolean replace, IProgressMonitor monitor) throws CModelException; + void rename(ICElement[] elements, ICElement[] destinations, String[] names, boolean replace, + IProgressMonitor monitor) throws CModelException; /** * Returns the C project with the given name. This is a handle-only method. * The project may or may not exist. * - * @param name of the Project + * @param name of the project */ ICProject getCProject(String name); /** * Returns the C projects. - * */ ICProject[] getCProjects() throws CModelException; /** - * Returns an array of non-C resources (i.e. non-C projects) in - * the workspace. + * Returns an array of non-C resources (i.e. non-C projects) in the workspace. *

- * Non-C projects include all projects that are closed (even if they have the - * C nature). - *

- * + * Non-C projects include all projects that are closed (even if they have the C nature). + * * @return an array of non-C projects contained in the workspace. - * @throws CModelException if this element does not exist or if an - * exception occurs while accessing its corresponding resource + * @throws CModelException if this element does not exist or if an exception occurs + * while accessing its corresponding resource * @since 2.1 */ Object[] getNonCResources() throws CModelException; @@ -200,5 +195,4 @@ public interface ICModel extends ICElement, IParent, IOpenable { * Returns the workspace associated with this C model. */ IWorkspace getWorkspace(); - } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java index fdee6dd9b43..2e8b5045926 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ACPathEntry.java @@ -16,36 +16,22 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; public abstract class ACPathEntry extends ACSettingEntry implements ICPathEntry { -// IPath fFullPath; -// IPath fLocation; -// private IPath fPath; - /** - * Constructor. + * Creates an ACPathEntry. * * @param rc - a resource in the workspace. * @param flags - bitwise combination of {@link ICSettingEntry} flags. - * If {@link #VALUE_WORKSPACE_PATH} is missing it will be supplied. + * If {@link #VALUE_WORKSPACE_PATH} is missing it will be supplied. */ ACPathEntry(IResource rc, int flags) { super(rc.getFullPath().toString(), flags | RESOLVED | VALUE_WORKSPACE_PATH); -// fFullPath = rc.getFullPath(); -// fPath = rc.getFullPath(); -// fLocation = rc.getLocation(); } -/* public ACLanguageSettingPathEntry(IPath fullPath, IPath location, int flags) { - super(flags); - fLocation = location; - fFullPath = fullPath; - } -*/ - /** - * Constructor. + * Creates an ACPathEntry. * * @param name - resource path. The path can be an absolute location on the local file-system - * or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path. + * or with flag {@link #VALUE_WORKSPACE_PATH} it is treated as workspace full path. * @param flags - bitwise combination of {@link ICSettingEntry} flags. */ ACPathEntry(String name, int flags) { @@ -61,11 +47,6 @@ public abstract class ACPathEntry extends ACSettingEntry implements ICPathEntry */ ACPathEntry(IPath path, int flags) { super(path.toString(), flags /*| RESOLVED*/); -// fPath = path; -// if (isValueWorkspacePath()) -// fFullPath = path; -// else -// fLocation = path; } @Override @@ -81,8 +62,8 @@ public abstract class ACPathEntry extends ACSettingEntry implements ICPathEntry protected IPath fullPathForLocation(IPath location){ IResource rcs[] = isFile() ? - (IResource[])ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(location) - : (IResource[])ResourcesPlugin.getWorkspace().getRoot().findContainersForLocation(location); + (IResource[]) ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(location) : + (IResource[]) ResourcesPlugin.getWorkspace().getRoot().findContainersForLocation(location); if (rcs.length > 0) return rcs[0].getFullPath(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CoreModelMessages.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CoreModelMessages.java index 91db0a71bb0..a1297778e11 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CoreModelMessages.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CoreModelMessages.java @@ -10,14 +10,13 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.model; -import com.ibm.icu.text.MessageFormat; import java.util.MissingResourceException; import java.util.ResourceBundle; +import com.ibm.icu.text.MessageFormat; /** - * CoreModelMessages - * + * @noreference This class is not intended to be referenced by clients. */ public class CoreModelMessages { private static final String RESOURCE_BUNDLE= "org.eclipse.cdt.internal.core.model.CoreModelMessages"; //$NON-NLS-1$ @@ -44,29 +43,27 @@ public class CoreModelMessages { } /** - * Gets a string from the resource bundle and formats it with the argument + * Returns a string from the resource bundle and formats it with the argument * - * @param key the string used to get the bundle value, must not be null + * @param key the string used to get the bundle value, must not be {@code null} */ public static String getFormattedString(String key) { return getString(key); } - /** - * Gets a string from the resource bundle and formats it with the argument + * Returns a string from the resource bundle and formats it with the argument * - * @param key the string used to get the bundle value, must not be null + * @param key the string used to get the bundle value, must not be {@code null} */ public static String getFormattedString(String key, Object arg) { return MessageFormat.format(getString(key), new Object[] { arg }); } /** - * Gets a string from the resource bundle and formats it with arguments + * Returns a string from the resource bundle and formats it with arguments */ public static String getFormattedString(String key, Object[] args) { return MessageFormat.format(getString(key), args); } - } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CoreModelMessages.properties b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CoreModelMessages.properties index c086dc11021..8ef96cae326 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CoreModelMessages.properties +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CoreModelMessages.properties @@ -6,9 +6,9 @@ # http://www.eclipse.org/legal/epl-v10.html # # Contributors: -# QNX Software Systems - Initial API and implementation -# Anton Leherbauer (Wind River Systems) -# Markus Schorn (Wind River Systems) +# QNX Software Systems - Initial API and implementation +# Anton Leherbauer (Wind River Systems) +# Markus Schorn (Wind River Systems) ############################################################################### ### CoreModel messages. diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceManipulationInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceManipulationInfo.java index 3378c3ee372..7eb1281c35c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceManipulationInfo.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceManipulationInfo.java @@ -24,9 +24,7 @@ import org.eclipse.core.runtime.IProgressMonitor; /** * Element info for ISourceReference elements. */ -/* package */ class SourceManipulationInfo extends CElementInfo { - protected int fStartPos; protected int fLength; protected int fIdStartPos; @@ -79,16 +77,11 @@ class SourceManipulationInfo extends CElementInfo { } protected ISourceRange getSourceRange() { - return new SourceRange(fStartPos, - fLength, - fIdStartPos, - fIdLength, - fStartLine, - fEndLine); + return new SourceRange(fStartPos, fLength, fIdStartPos, fIdLength, fStartLine, fEndLine); } /** - * @see ISourceReference + * @see ISourceReference#getSource() */ public String getSource() throws CModelException { ITranslationUnit unit = getTranslationUnit(); @@ -103,7 +96,7 @@ class SourceManipulationInfo extends CElementInfo { } try { return buffer.getText(offset, length); - } catch(RuntimeException e) { + } catch (RuntimeException e) { return null; } @@ -127,93 +120,90 @@ class SourceManipulationInfo extends CElementInfo { } /** - * @see IMember + * @see IMember#getTranslationUnit() */ public ITranslationUnit getTranslationUnit() { - ICElement celem = getElement(); - for (; celem != null; celem = celem.getParent()) { + for (ICElement celem = getElement(); celem != null; celem = celem.getParent()) { if (celem instanceof ITranslationUnit) - return (ITranslationUnit)celem; + return (ITranslationUnit) celem; } return null; } /** - * @see ISourceManipulation + * @see ISourceManipulation#copy(ICElement, ICElement, String, boolean, IProgressMonitor) */ public void copy(ICElement container, ICElement sibling, String rename, boolean force, IProgressMonitor monitor) throws CModelException { if (container == null) { throw new IllegalArgumentException(CoreModelMessages.getString("operation.nullContainer")); //$NON-NLS-1$ } - ICElement[] elements= new ICElement[] {getElement()}; - ICElement[] containers= new ICElement[] {container}; + ICElement[] elements= new ICElement[] { getElement() }; + ICElement[] containers= new ICElement[] { container }; ICElement[] siblings= null; if (sibling != null) { - siblings= new ICElement[] {sibling}; + siblings= new ICElement[] { sibling }; } String[] renamings= null; if (rename != null) { - renamings= new String[] {rename}; + renamings= new String[] { rename }; } getElement().getCModel().copy(elements, containers, siblings, renamings, force, monitor); } /** - * @see ISourceManipulation + * @see ISourceManipulation#delete(boolean, IProgressMonitor) */ public void delete(boolean force, IProgressMonitor monitor) throws CModelException { - ICElement[] elements = new ICElement[] {getElement()}; + ICElement[] elements = new ICElement[] { getElement() }; getElement().getCModel().delete(elements, force, monitor); } /** - * @see ISourceManipulation + * @see ISourceManipulation#move(ICElement, ICElement, String, boolean, IProgressMonitor) */ public void move(ICElement container, ICElement sibling, String rename, boolean force, - IProgressMonitor monitor) throws CModelException { + IProgressMonitor monitor) throws CModelException { if (container == null) { throw new IllegalArgumentException(CoreModelMessages.getString("operation.nullContainer")); //$NON-NLS-1$ } - ICElement[] elements= new ICElement[] {getElement()}; - ICElement[] containers= new ICElement[] {container}; + ICElement[] elements= new ICElement[] { getElement() }; + ICElement[] containers= new ICElement[] { container }; ICElement[] siblings= null; if (sibling != null) { - siblings= new ICElement[] {sibling}; + siblings= new ICElement[] { sibling }; } String[] renamings= null; if (rename != null) { - renamings= new String[] {rename}; + renamings= new String[] { rename }; } getElement().getCModel().move(elements, containers, siblings, renamings, force, monitor); } /** - * @see ISourceManipulation + * @see ISourceManipulation#rename(String, boolean, IProgressMonitor) */ public void rename(String name, boolean force, IProgressMonitor monitor) throws CModelException { if (name == null) { throw new IllegalArgumentException("element.nullName"); //$NON-NLS-1$ } - ICElement[] elements= new ICElement[] {getElement()}; - ICElement[] dests= new ICElement[] {getElement().getParent()}; - String[] renamings= new String[] {name}; + ICElement[] elements= new ICElement[] { getElement() }; + ICElement[] dests= new ICElement[] { getElement().getParent() }; + String[] renamings= new String[] { name }; getElement().getCModel().rename(elements, dests, renamings, force, monitor); } /** - * return the element modifiers - * @return int + * Returns the element modifiers. */ - public int getModifiers(){ + public int getModifiers() { return 0; } /** - * subclasses should override + * Subclasses should override */ - public boolean hasSameContentsAs( SourceManipulationInfo otherInfo){ - return (this.element.fType == otherInfo.element.fType); + public boolean hasSameContentsAs(SourceManipulationInfo otherInfo) { + return element.fType == otherInfo.element.fType; } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java index 894a237d788..229aeecbce7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java @@ -106,12 +106,12 @@ public class CRenameClassProcessor extends CRenameTypeProcessor { } } - renameCompilationUnits(ctype); + renameTranslationUnits(ctype); } return bindings.toArray(new IBinding[bindings.size()]); } - private void renameCompilationUnits(ICPPBinding binding) { + private void renameTranslationUnits(ICPPBinding binding) { IIndex index = getIndex(); if (index == null) { return;