1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-19 23:15:24 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2014-12-30 10:05:19 -08:00
parent 8758a144a7
commit 6de0d0163b
7 changed files with 122 additions and 160 deletions

View file

@ -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) { public boolean isSharedLib(IFile file) {
ICElement celement = create(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) { public boolean isObject(IFile file) {
ICElement celement = create(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) { public boolean isExecutable(IFile file) {
ICElement celement = create(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) { public boolean isBinary(IFile file) {
ICElement celement = create(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) { public boolean isArchive(IFile file) {
ICElement celement = create(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) { public static boolean isTranslationUnit(IFile file) {
if (file != null) { 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 * @return String[] ids
*/ */
public static String[] getRegistedContentTypeIds() { 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) { public static boolean isValidTranslationUnitName(IProject project, String name) {
IContentType contentType = CCorePlugin.getContentType(project, 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) { public static boolean isValidHeaderUnitName(IProject project, String name) {
IContentType contentType = CCorePlugin.getContentType(project, 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) { public static boolean isValidSourceUnitName(IProject project, String name) {
IContentType contentType = CCorePlugin.getContentType(project, 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) { public static boolean isValidCSourceUnitName(IProject project, String name) {
IContentType contentType = CCorePlugin.getContentType(project, 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) { public static boolean isValidCXXSourceUnitName(IProject project, String name) {
IContentType contentType = CCorePlugin.getContentType(project, 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) { public static boolean isValidASMSourceUnitName(IProject project, String name) {
IContentType contentType = CCorePlugin.getContentType(project, 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) { public static boolean isValidCXXHeaderUnitName(IProject project, String name) {
IContentType contentType = CCorePlugin.getContentType(project, 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) { public static boolean isValidCHeaderUnitName(IProject project, String name) {
IContentType contentType = CCorePlugin.getContentType(project, 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) { public static boolean hasCNature(IProject project) {
try { 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) { public static boolean hasCCNature(IProject project) {
try { try {
@ -1036,7 +1036,7 @@ public class CoreModel {
} }
/** /**
* Return the IPathEntryStore of the project. * Returns the IPathEntryStore of the project.
* @throws CoreException * @throws CoreException
*/ */
public static IPathEntryStore getPathEntryStore(IProject 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() { public static CoreModel getDefault() {
if (cmodel == null) { if (cmodel == null) {

View file

@ -19,11 +19,10 @@ import org.eclipse.core.runtime.IProgressMonitor;
* <em>the</em> C model element. * <em>the</em> C model element.
* The C model element needs to be opened before it can be navigated or manipulated. * 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 * The C model element has no parent (it is the root of the C element
* hierarchy). Its children are <code>ICProject</code>s. * hierarchy). Its children are {@code ICProject}s.
* <p> * <p>
* This interface provides methods for performing copy, move, rename, and * This interface provides methods for performing copy, move, rename, and
* delete operations on multiple C elements. * delete operations on multiple C elements.
* </p>
* *
* @see CoreModel#create(org.eclipse.core.resources.IWorkspaceRoot) * @see CoreModel#create(org.eclipse.core.resources.IWorkspaceRoot)
* *
@ -39,56 +38,55 @@ public interface ICModel extends ICElement, IParent, IOpenable {
* its associated container. * its associated container.
* <p> * <p>
* Optionally, each copy can positioned before a sibling * Optionally, each copy can positioned before a sibling
* element. If <code>null</code> 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. * is inserted as the last child of its associated container.
* </p>
* <p> * <p>
* Optionally, each copy can be renamed. If * Optionally, each copy can be renamed. If
* <code>null</code> is specified for the new name, the copy * {@code null} is specified for the new name, the copy
* is not renamed. * is not renamed.
* </p>
* <p> * <p>
* Optionally, any existing child in the destination container with * Optionally, any existing child in the destination container with
* the same name can be replaced by specifying <code>true</code> for * the same name can be replaced by specifying {@code true} for
* force. Otherwise an exception is thrown in the event that a name * force. Otherwise an exception is thrown in the event that a name
* collision occurs. * collision occurs.
* </p>
* *
* @param elements the elements to copy * @param elements the elements to copy
* @param containers the container, or list of containers * @param containers the container, or list of containers
* @param siblings the list of siblings element any of which may be * @param siblings the list of sibling elements, any of which may be
* <code>null</code>; or <code>null</code> * {@code null}, or {@code null}
* @param renamings the list of new names any of which may be * @param renamings the list of new names, any of which may be
* <code>null</code>; or <code>null</code> * {@code null}, or {@code null}
* @param replace <code>true</code> if any existing child in a target container * @param replace {@code true} if any existing child in a target container
* with the target name should be replaced, and <code>false</code> to throw an * with the target name should be replaced, and {@code false} to throw an
* exception in the event of a name collision * exception in the event of a name collision
* @param monitor a progress monitor * @param monitor a progress monitor
* @exception CModelException if an element could not be copied. Reasons include: * @exception CModelException if an element could not be copied. Reasons include:
* <ul> * <ul>
* <li> A specified element, container, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)</li> * <li> A specified element, container, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> A <code>CoreException</code> occurred while updating an underlying resource * <li> A {@code CoreException} occurred while updating an underlying resource
* <li> A container is of an incompatible type (<code>INVALID_DESTINATION</code>) * <li> A container is of an incompatible type ({@code INVALID_DESTINATION})
* <li> A sibling is not a child of it associated container (<code>INVALID_SIBLING</code>) * <li> A sibling is not a child of it associated container ({@code INVALID_SIBLING})
* <li> A new name is invalid (<code>INVALID_NAME</code>) * <li> A new name is invalid ({@code INVALID_NAME})
* <li> A child in its associated container already exists with the same * <li> A child in its associated container already exists with the same
* name and <code>replace</code> has been specified as <code>false</code> (<code>NAME_COLLISION</code>) * name and {@code replace} has been specified as {@code false}
* <li> A container or element is read-only (<code>READ_ONLY</code>) * ({@code NAME_COLLISION})
* <li> A container or element is read-only ({@code READ_ONLY})
* </ul> * </ul>
*/ */
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. * Deletes the given elements, forcing the operation if necessary and specified.
* *
* @param elements the elements to delete * @param elements the elements to delete
* @param force a flag controlling whether underlying resources that are not * @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 * @param monitor a progress monitor
* @exception CModelException if an element could not be deleted. Reasons include: * @exception CModelException if an element could not be deleted. Reasons include:
* <ul> * <ul>
* <li> A specified element does not exist (ELEMENT_DOES_NOT_EXIST)</li> * <li> A specified element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> A <code>CoreException</code> occurred while updating an underlying resource * <li> A {@code CoreException} occurred while updating an underlying resource
* <li> An element is read-only (<code>READ_ONLY</code>) * <li> An element is read-only ({@code READ_ONLY})
* </ul> * </ul>
*/ */
void delete(ICElement[] elements, boolean force, IProgressMonitor monitor) throws CModelException; void delete(ICElement[] elements, boolean force, IProgressMonitor monitor) throws CModelException;
@ -101,46 +99,45 @@ public interface ICModel extends ICElement, IParent, IOpenable {
* its associated container. * its associated container.
* <p> * <p>
* Optionally, each element can positioned before a sibling * Optionally, each element can positioned before a sibling
* element. If <code>null</code> 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. * is inserted as the last child of its associated container.
* </p>
* <p> * <p>
* Optionally, each element can be renamed. If * Optionally, each element can be renamed. If
* <code>null</code> is specified for the new name, the element * {@code null} is specified for the new name, the element
* is not renamed. * is not renamed.
* </p>
* <p> * <p>
* Optionally, any existing child in the destination container with * Optionally, any existing child in the destination container with
* the same name can be replaced by specifying <code>true</code> for * the same name can be replaced by specifying {@code true} for
* force. Otherwise an exception is thrown in the event that a name * force. Otherwise an exception is thrown in the event that a name
* collision occurs. * collision occurs.
* </p>
* *
* @param elements the elements to move * @param elements the elements to move
* @param containers the container, or list of containers * @param containers the container, or list of containers
* @param siblings the list of siblings element any of which may be * @param siblings the list of siblings element any of which may be
* <code>null</code>; or <code>null</code> * {@code null}; or {@code null}
* @param renamings the list of new names any of which may be * @param renamings the list of new names any of which may be
* <code>null</code>; or <code>null</code> * {@code null}; or {@code null}
* @param replace <code>true</code> if any existing child in a target container * @param replace {@code true} if any existing child in a target container
* with the target name should be replaced, and <code>false</code> to throw an * with the target name should be replaced, and {@code false} to throw an
* exception in the event of a name collision * exception in the event of a name collision
* @param monitor a progress monitor * @param monitor a progress monitor
* @exception CModelException if an element could not be moved. Reasons include: * @exception CModelException if an element could not be moved. Reasons include:
* <ul> * <ul>
* <li> A specified element, container, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)</li> * <li> A specified element, container, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> A <code>CoreException</code> occurred while updating an underlying resource * <li> A {@code CoreException} occurred while updating an underlying resource
* <li> A container is of an incompatible type (<code>INVALID_DESTINATION</code>) * <li> A container is of an incompatible type ({@code INVALID_DESTINATION})
* <li> A sibling is not a child of it associated container (<code>INVALID_SIBLING</code>) * <li> A sibling is not a child of it associated container ({@code INVALID_SIBLING})
* <li> A new name is invalid (<code>INVALID_NAME</code>) * <li> A new name is invalid ({@code INVALID_NAME})
* <li> A child in its associated container already exists with the same * <li> A child in its associated container already exists with the same
* name and <code>replace</code> has been specified as <code>false</code> (<code>NAME_COLLISION</code>) * name and {@code replace} has been specified as {@code false}
* <li> A container or element is read-only (<code>READ_ONLY</code>) * ({@code NAME_COLLISION})
* <li> A container or element is read-only ({@code READ_ONLY})
* </ul> * </ul>
* *
* @exception IllegalArgumentException any element or container is <code>null</code> * @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. * Renames the given elements as specified.
@ -152,46 +149,44 @@ public interface ICModel extends ICElement, IParent, IOpenable {
* @param elements the elements to rename * @param elements the elements to rename
* @param destinations the container, or list of containers * @param destinations the container, or list of containers
* @param names the list of new names * @param names the list of new names
* @param replace <code>true</code> if an existing child in a target container * @param replace {@code true} if an existing child in a target container
* with the target name should be replaced, and <code>false</code> to throw an * with the target name should be replaced, and {@code false} to throw an
* exception in the event of a name collision * exception in the event of a name collision
* @param monitor a progress monitor * @param monitor a progress monitor
* @exception CModelException if an element could not be renamed. Reasons include: * @exception CModelException if an element could not be renamed. Reasons include:
* <ul> * <ul>
* <li> A specified element does not exist (ELEMENT_DOES_NOT_EXIST)</li> * <li> A specified element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> A <code>CoreException</code> occurred while updating an underlying resource * <li> A {@code CoreException} occurred while updating an underlying resource
* <li> A new name is invalid (<code>INVALID_NAME</code>) * <li> A new name is invalid ({@code INVALID_NAME})
* <li> A child already exists with the same name and <code>replace</code> has been specified as <code>false</code> (<code>NAME_COLLISION</code>) * <li> A child already exists with the same name and {@code replace} has been specified as
* <li> An element is read-only (<code>READ_ONLY</code>) * {@code false} ({@code NAME_COLLISION})
* <li> An element is read-only ({@code READ_ONLY})
* </ul> * </ul>
*/ */
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. * Returns the C project with the given name. This is a handle-only method.
* The project may or may not exist. * The project may or may not exist.
* *
* @param name of the Project * @param name of the project
*/ */
ICProject getCProject(String name); ICProject getCProject(String name);
/** /**
* Returns the C projects. * Returns the C projects.
*
*/ */
ICProject[] getCProjects() throws CModelException; ICProject[] getCProjects() throws CModelException;
/** /**
* Returns an array of non-C resources (i.e. non-C projects) in * Returns an array of non-C resources (i.e. non-C projects) in the workspace.
* the workspace.
* <p> * <p>
* Non-C projects include all projects that are closed (even if they have the * Non-C projects include all projects that are closed (even if they have the C nature).
* C nature). *
* </p>
*
* @return an array of non-C projects contained in the workspace. * @return an array of non-C projects contained in the workspace.
* @throws CModelException if this element does not exist or if an * @throws CModelException if this element does not exist or if an exception occurs
* exception occurs while accessing its corresponding resource * while accessing its corresponding resource
* @since 2.1 * @since 2.1
*/ */
Object[] getNonCResources() throws CModelException; Object[] getNonCResources() throws CModelException;
@ -200,5 +195,4 @@ public interface ICModel extends ICElement, IParent, IOpenable {
* Returns the workspace associated with this C model. * Returns the workspace associated with this C model.
*/ */
IWorkspace getWorkspace(); IWorkspace getWorkspace();
} }

View file

@ -16,36 +16,22 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
public abstract class ACPathEntry extends ACSettingEntry implements ICPathEntry { 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 rc - a resource in the workspace.
* @param flags - bitwise combination of {@link ICSettingEntry} flags. * @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) { ACPathEntry(IResource rc, int flags) {
super(rc.getFullPath().toString(), flags | RESOLVED | VALUE_WORKSPACE_PATH); 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 * @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. * @param flags - bitwise combination of {@link ICSettingEntry} flags.
*/ */
ACPathEntry(String name, int flags) { ACPathEntry(String name, int flags) {
@ -61,11 +47,6 @@ public abstract class ACPathEntry extends ACSettingEntry implements ICPathEntry
*/ */
ACPathEntry(IPath path, int flags) { ACPathEntry(IPath path, int flags) {
super(path.toString(), flags /*| RESOLVED*/); super(path.toString(), flags /*| RESOLVED*/);
// fPath = path;
// if (isValueWorkspacePath())
// fFullPath = path;
// else
// fLocation = path;
} }
@Override @Override
@ -81,8 +62,8 @@ public abstract class ACPathEntry extends ACSettingEntry implements ICPathEntry
protected IPath fullPathForLocation(IPath location){ protected IPath fullPathForLocation(IPath location){
IResource rcs[] = isFile() ? IResource rcs[] = isFile() ?
(IResource[])ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(location) (IResource[]) ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(location) :
: (IResource[])ResourcesPlugin.getWorkspace().getRoot().findContainersForLocation(location); (IResource[]) ResourcesPlugin.getWorkspace().getRoot().findContainersForLocation(location);
if (rcs.length > 0) if (rcs.length > 0)
return rcs[0].getFullPath(); return rcs[0].getFullPath();

View file

@ -10,14 +10,13 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import com.ibm.icu.text.MessageFormat;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; 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 { public class CoreModelMessages {
private static final String RESOURCE_BUNDLE= "org.eclipse.cdt.internal.core.model.CoreModelMessages"; //$NON-NLS-1$ 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) { public static String getFormattedString(String key) {
return getString(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) { public static String getFormattedString(String key, Object arg) {
return MessageFormat.format(getString(key), new 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) { public static String getFormattedString(String key, Object[] args) {
return MessageFormat.format(getString(key), args); return MessageFormat.format(getString(key), args);
} }
} }

View file

@ -6,9 +6,9 @@
# http://www.eclipse.org/legal/epl-v10.html # http://www.eclipse.org/legal/epl-v10.html
# #
# Contributors: # Contributors:
# QNX Software Systems - Initial API and implementation # QNX Software Systems - Initial API and implementation
# Anton Leherbauer (Wind River Systems) # Anton Leherbauer (Wind River Systems)
# Markus Schorn (Wind River Systems) # Markus Schorn (Wind River Systems)
############################################################################### ###############################################################################
### CoreModel messages. ### CoreModel messages.

View file

@ -24,9 +24,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
/** /**
* Element info for ISourceReference elements. * Element info for ISourceReference elements.
*/ */
/* package */
class SourceManipulationInfo extends CElementInfo { class SourceManipulationInfo extends CElementInfo {
protected int fStartPos; protected int fStartPos;
protected int fLength; protected int fLength;
protected int fIdStartPos; protected int fIdStartPos;
@ -79,16 +77,11 @@ class SourceManipulationInfo extends CElementInfo {
} }
protected ISourceRange getSourceRange() { protected ISourceRange getSourceRange() {
return new SourceRange(fStartPos, return new SourceRange(fStartPos, fLength, fIdStartPos, fIdLength, fStartLine, fEndLine);
fLength,
fIdStartPos,
fIdLength,
fStartLine,
fEndLine);
} }
/** /**
* @see ISourceReference * @see ISourceReference#getSource()
*/ */
public String getSource() throws CModelException { public String getSource() throws CModelException {
ITranslationUnit unit = getTranslationUnit(); ITranslationUnit unit = getTranslationUnit();
@ -103,7 +96,7 @@ class SourceManipulationInfo extends CElementInfo {
} }
try { try {
return buffer.getText(offset, length); return buffer.getText(offset, length);
} catch(RuntimeException e) { } catch (RuntimeException e) {
return null; return null;
} }
@ -127,93 +120,90 @@ class SourceManipulationInfo extends CElementInfo {
} }
/** /**
* @see IMember * @see IMember#getTranslationUnit()
*/ */
public ITranslationUnit getTranslationUnit() { public ITranslationUnit getTranslationUnit() {
ICElement celem = getElement(); for (ICElement celem = getElement(); celem != null; celem = celem.getParent()) {
for (; celem != null; celem = celem.getParent()) {
if (celem instanceof ITranslationUnit) if (celem instanceof ITranslationUnit)
return (ITranslationUnit)celem; return (ITranslationUnit) celem;
} }
return null; return null;
} }
/** /**
* @see ISourceManipulation * @see ISourceManipulation#copy(ICElement, ICElement, String, boolean, IProgressMonitor)
*/ */
public void copy(ICElement container, ICElement sibling, String rename, boolean force, public void copy(ICElement container, ICElement sibling, String rename, boolean force,
IProgressMonitor monitor) throws CModelException { IProgressMonitor monitor) throws CModelException {
if (container == null) { if (container == null) {
throw new IllegalArgumentException(CoreModelMessages.getString("operation.nullContainer")); //$NON-NLS-1$ throw new IllegalArgumentException(CoreModelMessages.getString("operation.nullContainer")); //$NON-NLS-1$
} }
ICElement[] elements= new ICElement[] {getElement()}; ICElement[] elements= new ICElement[] { getElement() };
ICElement[] containers= new ICElement[] {container}; ICElement[] containers= new ICElement[] { container };
ICElement[] siblings= null; ICElement[] siblings= null;
if (sibling != null) { if (sibling != null) {
siblings= new ICElement[] {sibling}; siblings= new ICElement[] { sibling };
} }
String[] renamings= null; String[] renamings= null;
if (rename != null) { if (rename != null) {
renamings= new String[] {rename}; renamings= new String[] { rename };
} }
getElement().getCModel().copy(elements, containers, siblings, renamings, force, monitor); 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 { 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); 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, public void move(ICElement container, ICElement sibling, String rename, boolean force,
IProgressMonitor monitor) throws CModelException { IProgressMonitor monitor) throws CModelException {
if (container == null) { if (container == null) {
throw new IllegalArgumentException(CoreModelMessages.getString("operation.nullContainer")); //$NON-NLS-1$ throw new IllegalArgumentException(CoreModelMessages.getString("operation.nullContainer")); //$NON-NLS-1$
} }
ICElement[] elements= new ICElement[] {getElement()}; ICElement[] elements= new ICElement[] { getElement() };
ICElement[] containers= new ICElement[] {container}; ICElement[] containers= new ICElement[] { container };
ICElement[] siblings= null; ICElement[] siblings= null;
if (sibling != null) { if (sibling != null) {
siblings= new ICElement[] {sibling}; siblings= new ICElement[] { sibling };
} }
String[] renamings= null; String[] renamings= null;
if (rename != null) { if (rename != null) {
renamings= new String[] {rename}; renamings= new String[] { rename };
} }
getElement().getCModel().move(elements, containers, siblings, renamings, force, monitor); 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 { public void rename(String name, boolean force, IProgressMonitor monitor) throws CModelException {
if (name == null) { if (name == null) {
throw new IllegalArgumentException("element.nullName"); //$NON-NLS-1$ throw new IllegalArgumentException("element.nullName"); //$NON-NLS-1$
} }
ICElement[] elements= new ICElement[] {getElement()}; ICElement[] elements= new ICElement[] { getElement() };
ICElement[] dests= new ICElement[] {getElement().getParent()}; ICElement[] dests= new ICElement[] { getElement().getParent() };
String[] renamings= new String[] {name}; String[] renamings= new String[] { name };
getElement().getCModel().rename(elements, dests, renamings, force, monitor); getElement().getCModel().rename(elements, dests, renamings, force, monitor);
} }
/** /**
* return the element modifiers * Returns the element modifiers.
* @return int
*/ */
public int getModifiers(){ public int getModifiers() {
return 0; return 0;
} }
/** /**
* subclasses should override * Subclasses should override
*/ */
public boolean hasSameContentsAs( SourceManipulationInfo otherInfo){ public boolean hasSameContentsAs(SourceManipulationInfo otherInfo) {
return (this.element.fType == otherInfo.element.fType); return element.fType == otherInfo.element.fType;
} }
} }

View file

@ -106,12 +106,12 @@ public class CRenameClassProcessor extends CRenameTypeProcessor {
} }
} }
renameCompilationUnits(ctype); renameTranslationUnits(ctype);
} }
return bindings.toArray(new IBinding[bindings.size()]); return bindings.toArray(new IBinding[bindings.size()]);
} }
private void renameCompilationUnits(ICPPBinding binding) { private void renameTranslationUnits(ICPPBinding binding) {
IIndex index = getIndex(); IIndex index = getIndex();
if (index == null) { if (index == null) {
return; return;