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

auto-clean: @Override annotations + organize imports + unnecessary

casts/$NON-NLS + trailing white spaces
This commit is contained in:
Andrew Gvozdev 2011-11-17 18:14:36 -05:00
parent 2a1cddd716
commit 5c1a981cd7
311 changed files with 6186 additions and 4412 deletions

View file

@ -13,7 +13,7 @@ package org.eclipse.cdt.core.model;
/** /**
* Represents the declaration method of a class * Represents the declaration method of a class
* *
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
@ -46,7 +46,7 @@ public interface IMethodDeclaration extends IMember, IFunctionDeclaration {
/** /**
* Returns whether this method is declared pure virtual. * Returns whether this method is declared pure virtual.
* *
* <p>For example, a source method declared as <code>virtual void m() = 0;</code>. * <p>For example, a source method declared as <code>virtual void m() = 0;</code>.
* *
* @exception CModelException if this element does not exist or if an * @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource. * exception occurs while accessing its corresponding resource.
@ -57,14 +57,15 @@ public interface IMethodDeclaration extends IMember, IFunctionDeclaration {
* Returns if this method is static or not * Returns if this method is static or not
* @return boolean * @return boolean
*/ */
@Override
public boolean isStatic() throws CModelException; public boolean isStatic() throws CModelException;
/** /**
* Returns if this method is inline or not * Returns if this method is inline or not
* @return boolean * @return boolean
*/ */
public boolean isInline() throws CModelException; public boolean isInline() throws CModelException;
/** /**
* Returns whether this method is declared virtual. * Returns whether this method is declared virtual.
* *

View file

@ -12,7 +12,7 @@ package org.eclipse.cdt.core.model;
/** /**
* Represents a "using" declaration in C translation unit. * Represents a "using" declaration in C translation unit.
* *
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
@ -21,6 +21,7 @@ public interface IUsing extends ICElement, ISourceManipulation, ISourceReference
* Returns the name of the package the statement refers to. * Returns the name of the package the statement refers to.
* This is a handle-only method. * This is a handle-only method.
*/ */
@Override
String getElementName(); String getElementName();
boolean isDirective(); boolean isDirective();

View file

@ -59,7 +59,7 @@ public class LanguageManager {
private static final String ELEMENT_PDOM_LINKAGE_FACTORY = "pdomLinkageFactory"; //$NON-NLS-1$ private static final String ELEMENT_PDOM_LINKAGE_FACTORY = "pdomLinkageFactory"; //$NON-NLS-1$
private static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$ private static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$
private static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$ private static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
private static LanguageManager instance; private static LanguageManager instance;
private Map<String, ILanguage> fLanguageCache = new HashMap<String, ILanguage>(); private Map<String, ILanguage> fLanguageCache = new HashMap<String, ILanguage>();
private Map<String, IPDOMLinkageFactory> fPDOMLinkageFactoryCache= new HashMap<String, IPDOMLinkageFactory>(); private Map<String, IPDOMLinkageFactory> fPDOMLinkageFactoryCache= new HashMap<String, IPDOMLinkageFactory>();
@ -81,19 +81,19 @@ public class LanguageManager {
Map<String, ILanguageDescriptor> map = getDescriptorCache(); Map<String, ILanguageDescriptor> map = getDescriptorCache();
return map.get(id); return map.get(id);
} }
private HashMap<String, ILanguageDescriptor> getDescriptorCache() { private HashMap<String, ILanguageDescriptor> getDescriptorCache() {
if (fIdToLanguageDescriptorCache == null) { if (fIdToLanguageDescriptorCache == null) {
fIdToLanguageDescriptorCache = createDescriptorCache(); fIdToLanguageDescriptorCache = createDescriptorCache();
} }
return fIdToLanguageDescriptorCache; return fIdToLanguageDescriptorCache;
} }
public ILanguageDescriptor[] getLanguageDescriptors() { public ILanguageDescriptor[] getLanguageDescriptors() {
HashMap<String, ILanguageDescriptor> map = getDescriptorCache(); HashMap<String, ILanguageDescriptor> map = getDescriptorCache();
return map.values().toArray(new ILanguageDescriptor[map.size()]); return map.values().toArray(new ILanguageDescriptor[map.size()]);
} }
private HashMap<String, ILanguageDescriptor> createDescriptorCache() { private HashMap<String, ILanguageDescriptor> createDescriptorCache() {
HashMap<String, ILanguageDescriptor> map = new HashMap<String, ILanguageDescriptor>(); HashMap<String, ILanguageDescriptor> map = new HashMap<String, ILanguageDescriptor>();
IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID); IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
@ -106,18 +106,18 @@ public class LanguageManager {
} }
return map; return map;
} }
private HashMap<String, List<ILanguageDescriptor>> getContentTypeToDescriptorCache() { private HashMap<String, List<ILanguageDescriptor>> getContentTypeToDescriptorCache() {
if (fContentTypeToDescriptorListCache == null) { if (fContentTypeToDescriptorListCache == null) {
fContentTypeToDescriptorListCache = createContentTypeToDescriptorCache(); fContentTypeToDescriptorListCache = createContentTypeToDescriptorCache();
} }
return fContentTypeToDescriptorListCache; return fContentTypeToDescriptorListCache;
} }
public Map<String, ILanguageDescriptor[]> getContentTypeIdToLanguageDescriptionsMap() { public Map<String, ILanguageDescriptor[]> getContentTypeIdToLanguageDescriptionsMap() {
HashMap<String, ILanguageDescriptor[]> map = new HashMap<String, ILanguageDescriptor[]>(); HashMap<String, ILanguageDescriptor[]> map = new HashMap<String, ILanguageDescriptor[]>();
Map<String, List<ILanguageDescriptor>> cache = getContentTypeToDescriptorCache(); Map<String, List<ILanguageDescriptor>> cache = getContentTypeToDescriptorCache();
for (Entry<String, List<ILanguageDescriptor>> entry : cache.entrySet()) { for (Entry<String, List<ILanguageDescriptor>> entry : cache.entrySet()) {
List<ILanguageDescriptor> list = entry.getValue(); List<ILanguageDescriptor> list = entry.getValue();
if (list.size() > 0) { if (list.size() > 0) {
@ -125,11 +125,11 @@ public class LanguageManager {
map.put(entry.getKey(), dess); map.put(entry.getKey(), dess);
} }
} }
return map; return map;
} }
private HashMap<String, List<ILanguageDescriptor>> createContentTypeToDescriptorCache() { private HashMap<String, List<ILanguageDescriptor>> createContentTypeToDescriptorCache() {
HashMap<String, List<ILanguageDescriptor>> map = new HashMap<String, List<ILanguageDescriptor>>(); HashMap<String, List<ILanguageDescriptor>> map = new HashMap<String, List<ILanguageDescriptor>>();
Map<String, ILanguageDescriptor> dc = getDescriptorCache(); Map<String, ILanguageDescriptor> dc = getDescriptorCache();
@ -150,7 +150,7 @@ public class LanguageManager {
} }
return map; return map;
} }
public ILanguage getLanguage(String id) { public ILanguage getLanguage(String id) {
ILanguage language = fLanguageCache.get(id); ILanguage language = fLanguageCache.get(id);
if (language != null) if (language != null)
@ -160,14 +160,16 @@ public class LanguageManager {
for (int j = 0; j < configs.length; ++j) { for (int j = 0; j < configs.length; ++j) {
final IConfigurationElement languageElem = configs[j]; final IConfigurationElement languageElem = configs[j];
if (ELEMENT_LANGUAGE.equals(languageElem.getName())) { if (ELEMENT_LANGUAGE.equals(languageElem.getName())) {
String langId = getLanguageID(languageElem); String langId = getLanguageID(languageElem);
if (langId.equals(id)) { if (langId.equals(id)) {
final ILanguage[] result= new ILanguage[]{null}; final ILanguage[] result= new ILanguage[]{null};
SafeRunner.run(new ISafeRunnable() { SafeRunner.run(new ISafeRunnable() {
@Override
public void handleException(Throwable exception) { public void handleException(Throwable exception) {
CCorePlugin.log(exception); CCorePlugin.log(exception);
} }
@Override
public void run() throws Exception { public void run() throws Exception {
result[0]= (ILanguage)languageElem.createExecutableExtension(ATTRIBUTE_CLASS); result[0]= (ILanguage)languageElem.createExecutableExtension(ATTRIBUTE_CLASS);
} }
@ -185,15 +187,15 @@ public class LanguageManager {
private String getLanguageID(final IConfigurationElement languageElem) { private String getLanguageID(final IConfigurationElement languageElem) {
return languageElem.getNamespaceIdentifier() + NAMESPACE_SEPARATOR + languageElem.getAttribute(ATTRIBUTE_ID); return languageElem.getNamespaceIdentifier() + NAMESPACE_SEPARATOR + languageElem.getAttribute(ATTRIBUTE_ID);
} }
public ILanguage getLanguage(IContentType contentType) { public ILanguage getLanguage(IContentType contentType) {
String contentTypeID= contentType.getId(); String contentTypeID= contentType.getId();
return getLanguageForContentTypeID(contentTypeID); return getLanguageForContentTypeID(contentTypeID);
} }
public ILanguage getLanguageForContentTypeID(String contentTypeID) { public ILanguage getLanguageForContentTypeID(String contentTypeID) {
cacheAllLanguages(); cacheAllLanguages();
ILanguage language = fContentTypeToLanguageCache.get(contentTypeID); ILanguage language = fContentTypeToLanguageCache.get(contentTypeID);
if (language != null || fContentTypeToLanguageCache.containsKey(contentTypeID)) if (language != null || fContentTypeToLanguageCache.containsKey(contentTypeID))
return language; return language;
@ -202,7 +204,7 @@ public class LanguageManager {
for (int j = 0; j < configs.length; ++j) { for (int j = 0; j < configs.length; ++j) {
final IConfigurationElement languageElem = configs[j]; final IConfigurationElement languageElem = configs[j];
if (ELEMENT_LANGUAGE.equals(languageElem.getName())) { if (ELEMENT_LANGUAGE.equals(languageElem.getName())) {
IConfigurationElement[] assocContentTypes = languageElem.getChildren(ELEMENT_CONTENT_TYPE); IConfigurationElement[] assocContentTypes = languageElem.getChildren(ELEMENT_CONTENT_TYPE);
for (int k = 0; k < assocContentTypes.length; ++k) { for (int k = 0; k < assocContentTypes.length; ++k) {
if (contentTypeID.equals(assocContentTypes[k].getAttribute(ATTRIBUTE_ID))) { if (contentTypeID.equals(assocContentTypes[k].getAttribute(ATTRIBUTE_ID))) {
String id= getLanguageID(languageElem); String id= getLanguageID(languageElem);
@ -216,8 +218,8 @@ public class LanguageManager {
fContentTypeToLanguageCache.put(contentTypeID, null); fContentTypeToLanguageCache.put(contentTypeID, null);
return null; return null;
} }
/** /**
* @deprecated use getRegisteredContentTypes() instead. * @deprecated use getRegisteredContentTypes() instead.
*/ */
@Deprecated @Deprecated
@ -229,19 +231,19 @@ public class LanguageManager {
allTypes.add(CCorePlugin.CONTENT_TYPE_CXXHEADER); allTypes.add(CCorePlugin.CONTENT_TYPE_CXXHEADER);
allTypes.add(CCorePlugin.CONTENT_TYPE_CXXSOURCE); allTypes.add(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
IContentTypeManager manager = Platform.getContentTypeManager(); IContentTypeManager manager = Platform.getContentTypeManager();
IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID); IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
for (int j = 0; j < configs.length; ++j) { for (int j = 0; j < configs.length; ++j) {
final IConfigurationElement languageElem = configs[j]; final IConfigurationElement languageElem = configs[j];
if (ELEMENT_LANGUAGE.equals(languageElem.getName())) { if (ELEMENT_LANGUAGE.equals(languageElem.getName())) {
IConfigurationElement[] contentTypes = languageElem.getChildren(ELEMENT_CONTENT_TYPE); IConfigurationElement[] contentTypes = languageElem.getChildren(ELEMENT_CONTENT_TYPE);
for (int k = 0; k < contentTypes.length; ++k) { for (int k = 0; k < contentTypes.length; ++k) {
IContentType langContType = manager.getContentType(contentTypes[k].getAttribute(ATTRIBUTE_ID)); IContentType langContType = manager.getContentType(contentTypes[k].getAttribute(ATTRIBUTE_ID));
allTypes.add(langContType.getId()); allTypes.add(langContType.getId());
} }
} }
} }
return allTypes; return allTypes;
} }
@ -253,7 +255,7 @@ public class LanguageManager {
Set<String> contentTypes= collectContentTypeIds(); Set<String> contentTypes= collectContentTypeIds();
return contentTypes.toArray(new String[contentTypes.size()]); return contentTypes.toArray(new String[contentTypes.size()]);
} }
private Set<String> collectContentTypeIds() { private Set<String> collectContentTypeIds() {
HashSet<String> allTypes = new HashSet<String>(); HashSet<String> allTypes = new HashSet<String>();
allTypes.add(CCorePlugin.CONTENT_TYPE_ASMSOURCE); allTypes.add(CCorePlugin.CONTENT_TYPE_ASMSOURCE);
@ -262,26 +264,26 @@ public class LanguageManager {
allTypes.add(CCorePlugin.CONTENT_TYPE_CXXHEADER); allTypes.add(CCorePlugin.CONTENT_TYPE_CXXHEADER);
allTypes.add(CCorePlugin.CONTENT_TYPE_CXXSOURCE); allTypes.add(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
IContentTypeManager manager = Platform.getContentTypeManager(); IContentTypeManager manager = Platform.getContentTypeManager();
IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID); IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
for (int j = 0; j < configs.length; ++j) { for (int j = 0; j < configs.length; ++j) {
final IConfigurationElement languageElem = configs[j]; final IConfigurationElement languageElem = configs[j];
if (ELEMENT_LANGUAGE.equals(languageElem.getName())) { if (ELEMENT_LANGUAGE.equals(languageElem.getName())) {
IConfigurationElement[] contentTypes = languageElem.getChildren(ELEMENT_CONTENT_TYPE); IConfigurationElement[] contentTypes = languageElem.getChildren(ELEMENT_CONTENT_TYPE);
for (int k = 0; k < contentTypes.length; ++k) { for (int k = 0; k < contentTypes.length; ++k) {
IContentType langContType = manager.getContentType(contentTypes[k].getAttribute(ATTRIBUTE_ID)); IContentType langContType = manager.getContentType(contentTypes[k].getAttribute(ATTRIBUTE_ID));
allTypes.add(langContType.getId()); allTypes.add(langContType.getId());
} }
} }
} }
return allTypes; return allTypes;
} }
public boolean isContributedContentType(String contentTypeId) { public boolean isContributedContentType(String contentTypeId) {
return contentTypeId != null && getLanguageForContentTypeID(contentTypeId) != null; return contentTypeId != null && getLanguageForContentTypeID(contentTypeId) != null;
} }
/** /**
* @deprecated use {@link #getContributedModelBuilderFor(ITranslationUnit)}, instead. * @deprecated use {@link #getContributedModelBuilderFor(ITranslationUnit)}, instead.
* @noreference This method is not intended to be referenced by clients. * @noreference This method is not intended to be referenced by clients.
@ -309,36 +311,38 @@ public class LanguageManager {
} }
/** /**
* Returns mappings between IDs and IPDOMLinkageFactory. The IDs are defined in {@link ILinkage}. * Returns mappings between IDs and IPDOMLinkageFactory. The IDs are defined in {@link ILinkage}.
* @return a map. * @return a map.
* @since 4.0 * @since 4.0
*/ */
public Map<String, IPDOMLinkageFactory> getPDOMLinkageFactoryMappings() { public Map<String, IPDOMLinkageFactory> getPDOMLinkageFactoryMappings() {
if (!fPDOMLinkageFactoryCache.isEmpty()) if (!fPDOMLinkageFactoryCache.isEmpty())
return Collections.unmodifiableMap(fPDOMLinkageFactoryCache); return Collections.unmodifiableMap(fPDOMLinkageFactoryCache);
fPDOMLinkageFactoryCache.clear(); fPDOMLinkageFactoryCache.clear();
final IPDOMLinkageFactory[] result = new IPDOMLinkageFactory[] {null}; final IPDOMLinkageFactory[] result = new IPDOMLinkageFactory[] {null};
// read configuration // read configuration
IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID); IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
for (final IConfigurationElement element : configs) { for (final IConfigurationElement element : configs) {
if (ELEMENT_PDOM_LINKAGE_FACTORY.equals(element.getName())) { if (ELEMENT_PDOM_LINKAGE_FACTORY.equals(element.getName())) {
SafeRunner.run(new ISafeRunnable() { SafeRunner.run(new ISafeRunnable() {
@Override
public void handleException(Throwable exception) { public void handleException(Throwable exception) {
CCorePlugin.log(exception); CCorePlugin.log(exception);
} }
@Override
public void run() throws Exception { public void run() throws Exception {
result[0] = (IPDOMLinkageFactory) element.createExecutableExtension(ATTRIBUTE_CLASS); result[0] = (IPDOMLinkageFactory) element.createExecutableExtension(ATTRIBUTE_CLASS);
}} }}
); );
fPDOMLinkageFactoryCache.put(element.getAttribute(ATTRIBUTE_ID), result[0]); fPDOMLinkageFactoryCache.put(element.getAttribute(ATTRIBUTE_ID), result[0]);
} }
} }
return Collections.unmodifiableMap(fPDOMLinkageFactoryCache); return Collections.unmodifiableMap(fPDOMLinkageFactoryCache);
} }
/** /**
* Returns all of the languages registered with the <code>Platform</code>. * Returns all of the languages registered with the <code>Platform</code>.
* @return all of the languages registered with the <code>Platform</code>. * @return all of the languages registered with the <code>Platform</code>.
@ -361,13 +365,15 @@ public class LanguageManager {
for (int j = 0; j < configs.length; ++j) { for (int j = 0; j < configs.length; ++j) {
final IConfigurationElement languageElem = configs[j]; final IConfigurationElement languageElem = configs[j];
if (ELEMENT_LANGUAGE.equals(languageElem.getName())) { if (ELEMENT_LANGUAGE.equals(languageElem.getName())) {
String langId = getLanguageID(languageElem); String langId = getLanguageID(languageElem);
final ILanguage[] result= new ILanguage[] { null }; final ILanguage[] result= new ILanguage[] { null };
SafeRunner.run(new ISafeRunnable() { SafeRunner.run(new ISafeRunnable() {
@Override
public void handleException(Throwable exception) { public void handleException(Throwable exception) {
CCorePlugin.log(exception); CCorePlugin.log(exception);
} }
@Override
public void run() throws Exception { public void run() throws Exception {
result[0]= (ILanguage) languageElem.createExecutableExtension(ATTRIBUTE_CLASS); result[0]= (ILanguage) languageElem.createExecutableExtension(ATTRIBUTE_CLASS);
} }
@ -379,7 +385,7 @@ public class LanguageManager {
} }
fIsFullyCached = true; fIsFullyCached = true;
} }
/** /**
* Returns the language configuration for the workspace. * Returns the language configuration for the workspace.
* @return the language configuration for the workspace * @return the language configuration for the workspace
@ -391,16 +397,16 @@ public class LanguageManager {
if (fWorkspaceMappings != null) { if (fWorkspaceMappings != null) {
return fWorkspaceMappings; return fWorkspaceMappings;
} }
LanguageMappingStore store = new LanguageMappingStore(); LanguageMappingStore store = new LanguageMappingStore();
fWorkspaceMappings = store.decodeWorkspaceMappings(); fWorkspaceMappings = store.decodeWorkspaceMappings();
return fWorkspaceMappings; return fWorkspaceMappings;
} }
} }
/** /**
* Saves the workspace language configuration to persistent storage and notifies * Saves the workspace language configuration to persistent storage and notifies
* all <code>ILanguageMappingChangeListeners</code> of changes. * all <code>ILanguageMappingChangeListeners</code> of changes.
* @param affectedContentTypes * @param affectedContentTypes
* @throws CoreException * @throws CoreException
* @since 4.0 * @since 4.0
@ -410,18 +416,18 @@ public class LanguageManager {
if (fWorkspaceMappings == null) { if (fWorkspaceMappings == null) {
return; return;
} }
LanguageMappingStore store = new LanguageMappingStore(); LanguageMappingStore store = new LanguageMappingStore();
store.storeMappings(fWorkspaceMappings); store.storeMappings(fWorkspaceMappings);
} }
// Notify listeners that the language mappings have changed. // Notify listeners that the language mappings have changed.
LanguageMappingChangeEvent event = new LanguageMappingChangeEvent(); LanguageMappingChangeEvent event = new LanguageMappingChangeEvent();
event.setType(ILanguageMappingChangeEvent.TYPE_WORKSPACE); event.setType(ILanguageMappingChangeEvent.TYPE_WORKSPACE);
event.setAffectedContentTypes(affectedContentTypes); event.setAffectedContentTypes(affectedContentTypes);
notifyLanguageChangeListeners(event); notifyLanguageChangeListeners(event);
} }
/** /**
* Returns the language configuration for the given project. * Returns the language configuration for the given project.
* @param project * @param project
@ -435,18 +441,18 @@ public class LanguageManager {
if (mappings != null) { if (mappings != null) {
return mappings; return mappings;
} }
LanguageMappingStore store = new LanguageMappingStore(); LanguageMappingStore store = new LanguageMappingStore();
mappings = store.decodeMappings(project); mappings = store.decodeMappings(project);
fLanguageConfigurationCache.put(project, mappings); fLanguageConfigurationCache.put(project, mappings);
return mappings; return mappings;
} }
} }
/** /**
* Saves the language configuration for the given project to persistent * Saves the language configuration for the given project to persistent
* storage and notifies all <code>ILanguageMappingChangeListeners</code> * storage and notifies all <code>ILanguageMappingChangeListeners</code>
* of changes. * of changes.
* @param project * @param project
* @param affectedContentTypes * @param affectedContentTypes
* @throws CoreException * @throws CoreException
@ -458,7 +464,7 @@ public class LanguageManager {
LanguageMappingStore store = new LanguageMappingStore(); LanguageMappingStore store = new LanguageMappingStore();
store.storeMappings(project, mappings); store.storeMappings(project, mappings);
} }
// Notify listeners that the language mappings have changed. // Notify listeners that the language mappings have changed.
LanguageMappingChangeEvent event = new LanguageMappingChangeEvent(); LanguageMappingChangeEvent event = new LanguageMappingChangeEvent();
event.setType(ILanguageMappingChangeEvent.TYPE_PROJECT); event.setType(ILanguageMappingChangeEvent.TYPE_PROJECT);
@ -466,7 +472,7 @@ public class LanguageManager {
event.setAffectedContentTypes(affectedContentTypes); event.setAffectedContentTypes(affectedContentTypes);
notifyLanguageChangeListeners(event); notifyLanguageChangeListeners(event);
} }
/** /**
* Returns an ILanguage representing the language to be used for the given file. * Returns an ILanguage representing the language to be used for the given file.
* @since 4.0 * @since 4.0
@ -475,20 +481,20 @@ public class LanguageManager {
* @param project the IProject that this file is in the context of. This field cannot be null. * @param project the IProject that this file is in the context of. This field cannot be null.
* @param configuration the active build configuration, or <code>null</code> if build configurations * @param configuration the active build configuration, or <code>null</code> if build configurations
* are not relevant to determining the language. * are not relevant to determining the language.
* @throws CoreException * @throws CoreException
*/ */
public ILanguage getLanguageForFile(String fullPathToFile, IProject project, ICConfigurationDescription configuration) throws CoreException { public ILanguage getLanguageForFile(String fullPathToFile, IProject project, ICConfigurationDescription configuration) throws CoreException {
if (project == null) if (project == null)
throw new IllegalArgumentException("project must not be null in call to LanguageManager.getLanguageForFile(String, IProject)"); //$NON-NLS-1$ throw new IllegalArgumentException("project must not be null in call to LanguageManager.getLanguageForFile(String, IProject)"); //$NON-NLS-1$
IContentType contentType = CContentTypes.getContentType(project, fullPathToFile); IContentType contentType = CContentTypes.getContentType(project, fullPathToFile);
if (contentType == null) { if (contentType == null) {
return null; return null;
} }
String contentTypeID = contentType.getId(); String contentTypeID = contentType.getId();
return LanguageMappingResolver.computeLanguage(project, fullPathToFile, configuration, contentTypeID, false)[0].language; return LanguageMappingResolver.computeLanguage(project, fullPathToFile, configuration, contentTypeID, false)[0].language;
} }
@ -507,7 +513,7 @@ public class LanguageManager {
public ILanguage getLanguageForFile(IPath pathToFile, IProject project, ICConfigurationDescription configuration) throws CoreException { public ILanguage getLanguageForFile(IPath pathToFile, IProject project, ICConfigurationDescription configuration) throws CoreException {
return getLanguageForFile(pathToFile, project, configuration, null); return getLanguageForFile(pathToFile, project, configuration, null);
} }
/** /**
* Returns an ILanguage representing the language to be used for the given file. * Returns an ILanguage representing the language to be used for the given file.
* @return an ILanguage representing the language to be used for the given file * @return an ILanguage representing the language to be used for the given file
@ -536,7 +542,7 @@ public class LanguageManager {
} }
contentTypeID= ct.getId(); contentTypeID= ct.getId();
} }
return LanguageMappingResolver.computeLanguage(project, pathToFile.toPortableString(), configuration, contentTypeID, false)[0].language; return LanguageMappingResolver.computeLanguage(project, pathToFile.toPortableString(), configuration, contentTypeID, false)[0].language;
} }
@ -566,7 +572,7 @@ public class LanguageManager {
public ILanguage getLanguageForFile(IFile file, ICConfigurationDescription configuration, public ILanguage getLanguageForFile(IFile file, ICConfigurationDescription configuration,
String contentTypeId) throws CoreException { String contentTypeId) throws CoreException {
IProject project = file.getProject(); IProject project = file.getProject();
if (contentTypeId == null) { if (contentTypeId == null) {
IPath location = file.getLocation(); IPath location = file.getLocation();
String filename; String filename;
@ -581,36 +587,36 @@ public class LanguageManager {
} }
contentTypeId= contentType.getId(); contentTypeId= contentType.getId();
} }
return LanguageMappingResolver.computeLanguage(project, file.getProjectRelativePath().toPortableString(), configuration, contentTypeId, false)[0].language; return LanguageMappingResolver.computeLanguage(project, file.getProjectRelativePath().toPortableString(), configuration, contentTypeId, false)[0].language;
} }
/** /**
* Adds a listener that will be notified of changes in language mappings. * Adds a listener that will be notified of changes in language mappings.
* *
* @param listener the ILanguageMappingChangeListener to add * @param listener the ILanguageMappingChangeListener to add
*/ */
public void registerLanguageChangeListener(ILanguageMappingChangeListener listener) { public void registerLanguageChangeListener(ILanguageMappingChangeListener listener) {
fLanguageChangeListeners.add(listener); fLanguageChangeListeners.add(listener);
} }
/** /**
* Removes a language mapping change listener. * Removes a language mapping change listener.
* *
* @param listener the ILanguageMappingChangeListener to remove. * @param listener the ILanguageMappingChangeListener to remove.
*/ */
public void unregisterLanguageChangeListener(ILanguageMappingChangeListener listener) { public void unregisterLanguageChangeListener(ILanguageMappingChangeListener listener) {
fLanguageChangeListeners.remove(listener); fLanguageChangeListeners.remove(listener);
} }
/** /**
* Notifies all language mappings change listeners of a change in the mappings. * Notifies all language mappings change listeners of a change in the mappings.
* *
* @param event the ILanguageMappingsChange event to be broadcast. * @param event the ILanguageMappingsChange event to be broadcast.
*/ */
public void notifyLanguageChangeListeners(ILanguageMappingChangeEvent event) { public void notifyLanguageChangeListeners(ILanguageMappingChangeEvent event) {
Object[] listeners = fLanguageChangeListeners.getListeners(); Object[] listeners = fLanguageChangeListeners.getListeners();
for (Object obj : listeners) { for (Object obj : listeners) {
ILanguageMappingChangeListener listener = (ILanguageMappingChangeListener) obj; ILanguageMappingChangeListener listener = (ILanguageMappingChangeListener) obj;
listener.handleLanguageMappingChangeEvent(event); listener.handleLanguageMappingChangeEvent(event);
@ -620,7 +626,7 @@ public class LanguageManager {
/** /**
* Saves the language configuration for the given file to persistent * Saves the language configuration for the given file to persistent
* storage and notifies all <code>ILanguageMappingChangeListeners</code> * storage and notifies all <code>ILanguageMappingChangeListeners</code>
* of changes. * of changes.
* @param file * @param file
* @throws CoreException * @throws CoreException
* @since 4.0 * @since 4.0
@ -632,7 +638,7 @@ public class LanguageManager {
LanguageMappingStore store = new LanguageMappingStore(); LanguageMappingStore store = new LanguageMappingStore();
store.storeMappings(project, mappings); store.storeMappings(project, mappings);
} }
// Notify listeners that the language mappings have changed. // Notify listeners that the language mappings have changed.
LanguageMappingChangeEvent event = new LanguageMappingChangeEvent(); LanguageMappingChangeEvent event = new LanguageMappingChangeEvent();
event.setType(ILanguageMappingChangeEvent.TYPE_FILE); event.setType(ILanguageMappingChangeEvent.TYPE_FILE);
@ -645,10 +651,10 @@ public class LanguageManager {
* Returns language binding to a particular content type for given project. * Returns language binding to a particular content type for given project.
* This method will check project settings, workspace settings and default * This method will check project settings, workspace settings and default
* bindings (in that order) * bindings (in that order)
* *
* @param contentType content type of the file * @param contentType content type of the file
* @param project C/C++ workspace project * @param project C/C++ workspace project
* @return CDT language object * @return CDT language object
* @since 5.4 * @since 5.4
*/ */
public ILanguage getLanguage(IContentType contentType, IProject project) { public ILanguage getLanguage(IContentType contentType, IProject project) {
@ -659,11 +665,11 @@ public class LanguageManager {
* Returns language binding to a particular content type for given project. * Returns language binding to a particular content type for given project.
* This method will check project settings, workspace settings and default * This method will check project settings, workspace settings and default
* bindings (in that order) * bindings (in that order)
* *
* @param contentType content type of the file * @param contentType content type of the file
* @param project C/C++ workspace project * @param project C/C++ workspace project
* @param configurationDescription build configuration or <code>null</code> * @param configurationDescription build configuration or <code>null</code>
* @return CDT language object * @return CDT language object
* @since 5.4 * @since 5.4
*/ */
public ILanguage getLanguage(IContentType contentType, public ILanguage getLanguage(IContentType contentType,

View file

@ -19,9 +19,9 @@ import org.eclipse.core.runtime.content.IContentType;
/** /**
* A minimal implementation of ILanguageMappingsChangeEvent. * A minimal implementation of ILanguageMappingsChangeEvent.
* *
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noinstantiate This class is not intended to be instantiated by clients. * @noinstantiate This class is not intended to be instantiated by clients.
*/ */
public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent { public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent {
@ -35,6 +35,7 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getAffectedContentTypes() * @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getAffectedContentTypes()
*/ */
@Override
public IContentType[] getAffectedContentTypes() { public IContentType[] getAffectedContentTypes() {
return fContentTypes; return fContentTypes;
} }
@ -42,6 +43,7 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getFile() * @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getFile()
*/ */
@Override
public IFile getFile() { public IFile getFile() {
return fFile; return fFile;
} }
@ -49,11 +51,12 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getFilename() * @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getFilename()
*/ */
@Override
public String getFilename() { public String getFilename() {
// if the filename has been set, use it. otherwise get the path from // if the filename has been set, use it. otherwise get the path from
// either the IFile or the IPath if we have one // either the IFile or the IPath if we have one
if(fFileName != null) if(fFileName != null)
return fFileName; return fFileName;
else { else {
@ -65,30 +68,31 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent {
else { else {
// use the URI if there is one // use the URI if there is one
URI uri = fFile.getLocationURI(); URI uri = fFile.getLocationURI();
if(uri != null) if(uri != null)
return uri.toString(); return uri.toString();
} }
} }
else { // no file, use path else { // no file, use path
if(fPath != null) if(fPath != null)
return fPath.toString(); return fPath.toString();
} }
} }
return null; return null;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getPath() * @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getPath()
*/ */
@Override
public IPath getPath() { public IPath getPath() {
if(fPath != null) if(fPath != null)
return fPath; return fPath;
else { // try to get the path from the file if we have one else { // try to get the path from the file if we have one
if(fFile != null) if(fFile != null)
{ {
@ -96,31 +100,33 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent {
return location; return location;
} }
} }
return null; return null;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getProject() * @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getProject()
*/ */
@Override
public IProject getProject() { public IProject getProject() {
if(fProject != null) if(fProject != null)
return fProject; return fProject;
else { // try to get the project from the file if we have one else { // try to get the project from the file if we have one
if(fFile != null) if(fFile != null)
return fFile.getProject(); return fFile.getProject();
} }
return null; return null;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getType() * @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getType()
*/ */
@Override
public int getType() { public int getType() {
return fType; return fType;
} }
@ -128,7 +134,7 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent {
/** /**
* Sets the associated IContentTypes for this event. The provided array will be returned * Sets the associated IContentTypes for this event. The provided array will be returned
* subsequently by getAffectedContentTypes. * subsequently by getAffectedContentTypes.
* *
* @param affectedContentTypes * @param affectedContentTypes
*/ */
public void setAffectedContentTypes(IContentType[] affectedContentTypes) { public void setAffectedContentTypes(IContentType[] affectedContentTypes) {
@ -138,7 +144,7 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent {
/** /**
* Sets the associated IFile for this event. This file will be returned subsequently * Sets the associated IFile for this event. This file will be returned subsequently
* by getFile(). * by getFile().
* *
* @param file the IFile to set * @param file the IFile to set
*/ */
public void setFile(IFile file) { public void setFile(IFile file) {
@ -148,7 +154,7 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent {
/** /**
* Sets the associated String filename for this event. This filename will be returned subsequently * Sets the associated String filename for this event. This filename will be returned subsequently
* by getFileName(). * by getFileName().
* *
* @param fileName the fFileName to set * @param fileName the fFileName to set
*/ */
public void setFileName(String fileName) { public void setFileName(String fileName) {
@ -158,7 +164,7 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent {
/** /**
* Sets the associated IPath for this event. This path will be returned subsequently * Sets the associated IPath for this event. This path will be returned subsequently
* by getPath(). * by getPath().
* *
* @param path the IPath to set * @param path the IPath to set
*/ */
public void setPath(IPath path) { public void setPath(IPath path) {
@ -168,16 +174,16 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent {
/** /**
* Sets the associated project for this event. This project will be returned subsequently * Sets the associated project for this event. This project will be returned subsequently
* by getProject(). * by getProject().
* *
* @param project the IProject to set * @param project the IProject to set
*/ */
public void setProject(IProject project) { public void setProject(IProject project) {
fProject = project; fProject = project;
} }
/** /**
* Sets the type of this event. This type will be returned by getType(). * Sets the type of this event. This type will be returned by getType().
* *
* @param type the type to set * @param type the type to set
* @see ILanguageMappingChangeEvent#TYPE_WORKSPACE * @see ILanguageMappingChangeEvent#TYPE_WORKSPACE
* @see ILanguageMappingChangeEvent#TYPE_PROJECT * @see ILanguageMappingChangeEvent#TYPE_PROJECT

View file

@ -25,19 +25,20 @@ public class CDTListComparator implements Comparator<Object> {
comparator = new CDTListComparator(); comparator = new CDTListComparator();
return comparator; return comparator;
} }
@Override
public int compare(Object a, Object b) { public int compare(Object a, Object b) {
if (a == null || b == null) if (a == null || b == null)
return 0; return 0;
if (a instanceof ICLanguageSetting) { if (a instanceof ICLanguageSetting) {
ICLanguageSetting c1 = (ICLanguageSetting)a; ICLanguageSetting c1 = (ICLanguageSetting)a;
ICLanguageSetting c2 = (ICLanguageSetting)b; ICLanguageSetting c2 = (ICLanguageSetting)b;
return c1.getName().compareToIgnoreCase(c2.getName()); return c1.getName().compareToIgnoreCase(c2.getName());
} }
if (a instanceof ICLanguageSettingEntry) { if (a instanceof ICLanguageSettingEntry) {
ICLanguageSettingEntry c1 = (ICLanguageSettingEntry)a; ICLanguageSettingEntry c1 = (ICLanguageSettingEntry)a;
ICLanguageSettingEntry c2 = (ICLanguageSettingEntry)b; ICLanguageSettingEntry c2 = (ICLanguageSettingEntry)b;
return c1.getName().compareToIgnoreCase(c2.getName()); return c1.getName().compareToIgnoreCase(c2.getName());
} }
if (a instanceof ICConfigurationDescription) { if (a instanceof ICConfigurationDescription) {
ICConfigurationDescription c1 = (ICConfigurationDescription)a; ICConfigurationDescription c1 = (ICConfigurationDescription)a;
ICConfigurationDescription c2 = (ICConfigurationDescription)b; ICConfigurationDescription c2 = (ICConfigurationDescription)b;
@ -46,7 +47,7 @@ public class CDTListComparator implements Comparator<Object> {
if (a instanceof ICdtVariable) { if (a instanceof ICdtVariable) {
ICdtVariable c1 = (ICdtVariable) a; ICdtVariable c1 = (ICdtVariable) a;
ICdtVariable c2 = (ICdtVariable) b; ICdtVariable c2 = (ICdtVariable) b;
return c1.getName().compareToIgnoreCase(c2.getName()); return c1.getName().compareToIgnoreCase(c2.getName());
} }
return a.toString().compareTo(b.toString()); return a.toString().compareTo(b.toString());
} }

View file

@ -40,11 +40,12 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx
protected final boolean isFile() { protected final boolean isFile() {
return false; return false;
} }
/** /**
* Returns the exclusion patterns * Returns the exclusion patterns
* @return IPath[] * @return IPath[]
*/ */
@Override
public IPath[] getExclusionPatterns() { public IPath[] getExclusionPatterns() {
return exclusionPatterns.length != 0 ? (IPath[])exclusionPatterns.clone() : exclusionPatterns; return exclusionPatterns.length != 0 ? (IPath[])exclusionPatterns.clone() : exclusionPatterns;
} }
@ -52,6 +53,7 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx
/** /**
* Returns a char based representation of the exclusions patterns full path. * Returns a char based representation of the exclusions patterns full path.
*/ */
@Override
public char[][] fullExclusionPatternChars() { public char[][] fullExclusionPatternChars() {
if (this.fullCharExclusionPatterns == UNINIT_PATTERNS) { if (this.fullCharExclusionPatterns == UNINIT_PATTERNS) {
int length = this.exclusionPatterns.length; int length = this.exclusionPatterns.length;
@ -61,18 +63,18 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx
path = getLocation(); path = getLocation();
IPath prefixPath = path.removeTrailingSeparator(); IPath prefixPath = path.removeTrailingSeparator();
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
this.fullCharExclusionPatterns[i] = this.fullCharExclusionPatterns[i] =
prefixPath.append(this.exclusionPatterns[i]).toString().toCharArray(); prefixPath.append(this.exclusionPatterns[i]).toString().toCharArray();
} }
} }
return this.fullCharExclusionPatterns; return this.fullCharExclusionPatterns;
} }
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if(!super.equals(other)) if(!super.equals(other))
return false; return false;
ACExclusionFilterEntry otherEntry = (ACExclusionFilterEntry)other; ACExclusionFilterEntry otherEntry = (ACExclusionFilterEntry)other;
return Arrays.equals(exclusionPatterns, otherEntry.exclusionPatterns); return Arrays.equals(exclusionPatterns, otherEntry.exclusionPatterns);
} }
@ -86,7 +88,7 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx
public boolean equalsByContents(ICSettingEntry entry) { public boolean equalsByContents(ICSettingEntry entry) {
if(!super.equalsByContents(entry)) if(!super.equalsByContents(entry))
return false; return false;
ACExclusionFilterEntry otherEntry = (ACExclusionFilterEntry)entry; ACExclusionFilterEntry otherEntry = (ACExclusionFilterEntry)entry;
return Arrays.equals(exclusionPatterns, otherEntry.exclusionPatterns); return Arrays.equals(exclusionPatterns, otherEntry.exclusionPatterns);
} }

View file

@ -20,7 +20,7 @@ public abstract class ACPathEntry extends ACSettingEntry
// IPath fFullPath; // IPath fFullPath;
// IPath fLocation; // IPath fLocation;
// private IPath fPath; // private IPath fPath;
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(); // fFullPath = rc.getFullPath();
@ -37,7 +37,7 @@ public abstract class ACPathEntry extends ACSettingEntry
ACPathEntry(String value, int flags) { ACPathEntry(String value, int flags) {
super(value, flags); super(value, flags);
} }
ACPathEntry(IPath path, int flags) { ACPathEntry(IPath path, int flags) {
super(path.toString(), flags /*| RESOLVED*/); super(path.toString(), flags /*| RESOLVED*/);
// fPath = path; // fPath = path;
@ -47,6 +47,7 @@ public abstract class ACPathEntry extends ACSettingEntry
// fLocation = path; // fLocation = path;
} }
@Override
public IPath getFullPath() { public IPath getFullPath() {
if(isValueWorkspacePath()) if(isValueWorkspacePath())
return new Path(getValue()); return new Path(getValue());
@ -56,19 +57,20 @@ public abstract class ACPathEntry extends ACSettingEntry
} }
return null; return null;
} }
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();
return null; return null;
} }
protected abstract boolean isFile(); protected abstract boolean isFile();
@Override
public IPath getLocation() { public IPath getLocation() {
if(!isValueWorkspacePath()) if(!isValueWorkspacePath())
return new Path(getValue()); return new Path(getValue());
@ -80,7 +82,8 @@ public abstract class ACPathEntry extends ACSettingEntry
} }
return null; return null;
} }
@Override
public boolean isValueWorkspacePath() { public boolean isValueWorkspacePath() {
return checkFlags(VALUE_WORKSPACE_PATH); return checkFlags(VALUE_WORKSPACE_PATH);
} }

View file

@ -18,107 +18,115 @@ import org.eclipse.cdt.internal.core.SafeStringInterner;
public abstract class ACSettingEntry implements ICSettingEntry { public abstract class ACSettingEntry implements ICSettingEntry {
int fFlags; int fFlags;
String fName; String fName;
ACSettingEntry(String name, int flags){ ACSettingEntry(String name, int flags){
fName = SafeStringInterner.safeIntern(name); fName = SafeStringInterner.safeIntern(name);
fFlags = flags; fFlags = flags;
} }
@Override
public boolean isBuiltIn() { public boolean isBuiltIn() {
return checkFlags(BUILTIN); return checkFlags(BUILTIN);
} }
@Override
public boolean isReadOnly() { public boolean isReadOnly() {
return checkFlags(READONLY); return checkFlags(READONLY);
} }
protected boolean checkFlags(int flags){ protected boolean checkFlags(int flags){
return (fFlags & flags) == flags; return (fFlags & flags) == flags;
} }
@Override
public String getName() { public String getName() {
return fName; return fName;
} }
@Override
public String getValue() { public String getValue() {
//name and value differ only for macro entry and have the same contents //name and value differ only for macro entry and have the same contents
//for all other entries //for all other entries
return fName; return fName;
} }
@Override
public boolean isResolved() { public boolean isResolved() {
return checkFlags(RESOLVED); return checkFlags(RESOLVED);
} }
@Override @Override
public boolean equals(Object other){ public boolean equals(Object other){
if(other == this) if(other == this)
return true; return true;
if(!(other instanceof ACSettingEntry)) if(!(other instanceof ACSettingEntry))
return false; return false;
ACSettingEntry e = (ACSettingEntry)other; ACSettingEntry e = (ACSettingEntry)other;
if(getKind() != e.getKind()) if(getKind() != e.getKind())
return false; return false;
if(fFlags != e.fFlags) if(fFlags != e.fFlags)
return false; return false;
if(!fName.equals(e.fName)) if(!fName.equals(e.fName))
return false; return false;
return true; return true;
} }
@Override @Override
public int hashCode(){ public int hashCode(){
return getKind() + fFlags + fName.hashCode(); return getKind() + fFlags + fName.hashCode();
} }
@Override
public int getFlags() { public int getFlags() {
return fFlags; return fFlags;
} }
@Override
public boolean equalsByContents(ICSettingEntry entry) { public boolean equalsByContents(ICSettingEntry entry) {
return equalsByName(entry); return equalsByName(entry);
} }
protected int getByNameMatchFlags(){ protected int getByNameMatchFlags(){
return (fFlags & (~ (BUILTIN | READONLY | RESOLVED))); return (fFlags & (~ (BUILTIN | READONLY | RESOLVED)));
} }
@Override
public final boolean equalsByName(ICSettingEntry entry) { public final boolean equalsByName(ICSettingEntry entry) {
if(entry == this) if(entry == this)
return true; return true;
if(!(entry instanceof ACSettingEntry)) if(!(entry instanceof ACSettingEntry))
return false; return false;
ACSettingEntry e = (ACSettingEntry)entry; ACSettingEntry e = (ACSettingEntry)entry;
if(getKind() != e.getKind()) if(getKind() != e.getKind())
return false; return false;
if(getByNameMatchFlags() if(getByNameMatchFlags()
!= e.getByNameMatchFlags()) != e.getByNameMatchFlags())
return false; return false;
if(!fName.equals(e.fName)) if(!fName.equals(e.fName))
return false; return false;
return true; return true;
} }
public final int codeForNameKey(){ public final int codeForNameKey(){
return getKind() + getByNameMatchFlags() + fName.hashCode(); return getKind() + getByNameMatchFlags() + fName.hashCode();
} }
public int codeForContentsKey(){ public int codeForContentsKey(){
return codeForNameKey(); return codeForNameKey();
} }
@Override @Override
public final String toString(){ public final String toString(){
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
@ -127,7 +135,7 @@ public abstract class ACSettingEntry implements ICSettingEntry {
buf.append(" ; flags: ").append(LanguageSettingEntriesSerializer.composeFlagsString(getFlags())); //$NON-NLS-1$ buf.append(" ; flags: ").append(LanguageSettingEntriesSerializer.composeFlagsString(getFlags())); //$NON-NLS-1$
return buf.toString(); return buf.toString();
} }
protected abstract String contentsToString(); protected abstract String contentsToString();
} }

View file

@ -29,14 +29,14 @@ public final class CExternalSetting implements ICExternalSetting {
fLanguageIds = base.getCompatibleLanguageIds(); fLanguageIds = base.getCompatibleLanguageIds();
fContentTypeIds = base.getCompatibleContentTypeIds(); fContentTypeIds = base.getCompatibleContentTypeIds();
fExtensions = base.getCompatibleExtensions(); fExtensions = base.getCompatibleExtensions();
// fEntryStore = new EntryStore(); // fEntryStore = new EntryStore();
initEntryStore(base.getEntries()); initEntryStore(base.getEntries());
} }
public CExternalSetting(ICExternalSetting base, ICSettingEntry entries[]) { public CExternalSetting(ICExternalSetting base, ICSettingEntry entries[]) {
this(base); this(base);
initEntryStore(entries); initEntryStore(entries);
} }
@ -48,25 +48,25 @@ public final class CExternalSetting implements ICExternalSetting {
fContentTypeIds = contentTypeIds.clone(); fContentTypeIds = contentTypeIds.clone();
if (extensions != null) if (extensions != null)
fExtensions = extensions.clone(); fExtensions = extensions.clone();
initEntryStore(entries); initEntryStore(entries);
} }
private void initEntryStore(ICSettingEntry entries[]) { private void initEntryStore(ICSettingEntry entries[]) {
ICSettingEntry entry; ICSettingEntry entry;
for (int i = 0; i < entries.length; i++) { for (int i = 0; i < entries.length; i++) {
entry = entries[i]; entry = entries[i];
addEntry(entry); addEntry(entry);
} }
// trimToSize(); // trimToSize();
} }
private void addEntry(ICSettingEntry entry) { private void addEntry(ICSettingEntry entry) {
getEntriesSet(entry.getKind(), true).addEntry(entry); getEntriesSet(entry.getKind(), true).addEntry(entry);
} }
// private void trimToSize() { // private void trimToSize() {
// int kinds[] = KindBasedStore.getSupportedKinds(); // int kinds[] = KindBasedStore.getSupportedKinds();
// for (int i = 0; i < kinds.length; i++) { // for (int i = 0; i < kinds.length; i++) {
@ -75,7 +75,7 @@ public final class CExternalSetting implements ICExternalSetting {
// set.trimToSize(); // set.trimToSize();
// } // }
// } // }
private CEntriesSet getEntriesSet(int kind, boolean create) { private CEntriesSet getEntriesSet(int kind, boolean create) {
CEntriesSet set = fStore.get(kind); CEntriesSet set = fStore.get(kind);
if (set == null && create) { if (set == null && create) {
@ -85,24 +85,28 @@ public final class CExternalSetting implements ICExternalSetting {
return set; return set;
} }
@Override
public String[] getCompatibleContentTypeIds() { public String[] getCompatibleContentTypeIds() {
if (fContentTypeIds != null) if (fContentTypeIds != null)
return fContentTypeIds.clone(); return fContentTypeIds.clone();
return null; return null;
} }
@Override
public String[] getCompatibleExtensions() { public String[] getCompatibleExtensions() {
if (fExtensions != null) if (fExtensions != null)
return fExtensions.clone(); return fExtensions.clone();
return null; return null;
} }
@Override
public String[] getCompatibleLanguageIds() { public String[] getCompatibleLanguageIds() {
if (fLanguageIds != null) if (fLanguageIds != null)
return fLanguageIds.clone(); return fLanguageIds.clone();
return null; return null;
} }
@Override
public ICSettingEntry[] getEntries(int kind) { public ICSettingEntry[] getEntries(int kind) {
CEntriesSet set = getEntriesSet(kind, false); CEntriesSet set = getEntriesSet(kind, false);
if (set != null) if (set != null)
@ -114,6 +118,7 @@ public final class CExternalSetting implements ICExternalSetting {
// return fId; // return fId;
// } // }
@Override
public ICSettingEntry[] getEntries() { public ICSettingEntry[] getEntries() {
List<ICSettingEntry> result = new ArrayList<ICSettingEntry>(); List<ICSettingEntry> result = new ArrayList<ICSettingEntry>();
int kinds[] = KindBasedStore.getAllEntryKinds(); int kinds[] = KindBasedStore.getAllEntryKinds();
@ -122,7 +127,7 @@ public final class CExternalSetting implements ICExternalSetting {
if (list != null) if (list != null)
result.addAll(Arrays.asList(list.toArray())); result.addAll(Arrays.asList(list.toArray()));
} }
return result.toArray(new ICSettingEntry[result.size()]); return result.toArray(new ICSettingEntry[result.size()]);
} }
} }

View file

@ -28,6 +28,7 @@ public final class CIncludeFileEntry extends ACPathEntry implements
super(rc, flags); super(rc, flags);
} }
@Override
public final int getKind() { public final int getKind() {
return INCLUDE_FILE; return INCLUDE_FILE;
} }

View file

@ -27,10 +27,12 @@ public final class CIncludePathEntry extends ACPathEntry implements ICIncludePat
super(rc, flags); super(rc, flags);
} }
@Override
public boolean isLocal() { public boolean isLocal() {
return checkFlags(LOCAL); return checkFlags(LOCAL);
} }
@Override
public final int getKind() { public final int getKind() {
return INCLUDE_PATH; return INCLUDE_PATH;
} }

View file

@ -20,7 +20,7 @@ public final class CLibraryFileEntry extends ACPathEntry implements
private IPath fSourceAttachmentPath; private IPath fSourceAttachmentPath;
private IPath fSourceAttachmentRootPath; private IPath fSourceAttachmentRootPath;
private IPath fSourceAttachmentPrefixMapping; private IPath fSourceAttachmentPrefixMapping;
public CLibraryFileEntry(String value, int flags) { public CLibraryFileEntry(String value, int flags) {
this(value, flags, null, null, null); this(value, flags, null, null, null);
} }
@ -33,8 +33,8 @@ public final class CLibraryFileEntry extends ACPathEntry implements
this(rc, flags, null, null, null); this(rc, flags, null, null, null);
} }
public CLibraryFileEntry(String value, public CLibraryFileEntry(String value,
int flags, int flags,
IPath sourceAttachmentPath, IPath sourceAttachmentPath,
IPath sourceAttachmentRootPath, IPath sourceAttachmentRootPath,
IPath sourceAttachmentPrefixMapping) { IPath sourceAttachmentPrefixMapping) {
@ -43,7 +43,7 @@ public final class CLibraryFileEntry extends ACPathEntry implements
} }
public CLibraryFileEntry(IPath location, public CLibraryFileEntry(IPath location,
int flags, int flags,
IPath sourceAttachmentPath, IPath sourceAttachmentPath,
IPath sourceAttachmentRootPath, IPath sourceAttachmentRootPath,
IPath sourceAttachmentPrefixMapping) { IPath sourceAttachmentPrefixMapping) {
@ -51,26 +51,27 @@ public final class CLibraryFileEntry extends ACPathEntry implements
setSourceAttachmentSettings(sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping); setSourceAttachmentSettings(sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping);
} }
public CLibraryFileEntry(IFile rc, public CLibraryFileEntry(IFile rc,
int flags, int flags,
IPath sourceAttachmentPath, IPath sourceAttachmentPath,
IPath sourceAttachmentRootPath, IPath sourceAttachmentRootPath,
IPath sourceAttachmentPrefixMapping) { IPath sourceAttachmentPrefixMapping) {
super(rc, flags); super(rc, flags);
setSourceAttachmentSettings(sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping); setSourceAttachmentSettings(sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping);
} }
private void setSourceAttachmentSettings(IPath sourceAttachmentPath, private void setSourceAttachmentSettings(IPath sourceAttachmentPath,
IPath sourceAttachmentRootPath, IPath sourceAttachmentRootPath,
IPath sourceAttachmentPrefixMapping){ IPath sourceAttachmentPrefixMapping){
if(sourceAttachmentPath == null) if(sourceAttachmentPath == null)
return; return;
fSourceAttachmentPath = sourceAttachmentPath; fSourceAttachmentPath = sourceAttachmentPath;
fSourceAttachmentRootPath = sourceAttachmentRootPath != null ? sourceAttachmentRootPath : Path.EMPTY; fSourceAttachmentRootPath = sourceAttachmentRootPath != null ? sourceAttachmentRootPath : Path.EMPTY;
fSourceAttachmentPrefixMapping = sourceAttachmentPrefixMapping != null ? sourceAttachmentPrefixMapping : Path.EMPTY; fSourceAttachmentPrefixMapping = sourceAttachmentPrefixMapping != null ? sourceAttachmentPrefixMapping : Path.EMPTY;
} }
@Override
public final int getKind() { public final int getKind() {
return LIBRARY_FILE; return LIBRARY_FILE;
} }
@ -80,14 +81,17 @@ public final class CLibraryFileEntry extends ACPathEntry implements
return true; return true;
} }
@Override
public IPath getSourceAttachmentPath() { public IPath getSourceAttachmentPath() {
return fSourceAttachmentPath; return fSourceAttachmentPath;
} }
@Override
public IPath getSourceAttachmentPrefixMapping() { public IPath getSourceAttachmentPrefixMapping() {
return fSourceAttachmentPrefixMapping; return fSourceAttachmentPrefixMapping;
} }
@Override
public IPath getSourceAttachmentRootPath() { public IPath getSourceAttachmentRootPath() {
return fSourceAttachmentRootPath; return fSourceAttachmentRootPath;
} }
@ -108,10 +112,10 @@ public final class CLibraryFileEntry extends ACPathEntry implements
public boolean equals(Object other) { public boolean equals(Object other) {
if(other == this) if(other == this)
return true; return true;
if(!super.equals(other)) if(!super.equals(other))
return false; return false;
return sourceAttachmentSettingsEqual((CLibraryFileEntry)other); return sourceAttachmentSettingsEqual((CLibraryFileEntry)other);
} }
@ -119,13 +123,13 @@ public final class CLibraryFileEntry extends ACPathEntry implements
public boolean equalsByContents(ICSettingEntry entry) { public boolean equalsByContents(ICSettingEntry entry) {
if(entry == this) if(entry == this)
return true; return true;
if(!super.equalsByContents(entry)) if(!super.equalsByContents(entry))
return false; return false;
return sourceAttachmentSettingsEqual((CLibraryFileEntry)entry); return sourceAttachmentSettingsEqual((CLibraryFileEntry)entry);
} }
private boolean sourceAttachmentSettingsEqual(CLibraryFileEntry otherEntry){ private boolean sourceAttachmentSettingsEqual(CLibraryFileEntry otherEntry){
if(!CDataUtil.objectsEqual(fSourceAttachmentPath, otherEntry.fSourceAttachmentPath)) if(!CDataUtil.objectsEqual(fSourceAttachmentPath, otherEntry.fSourceAttachmentPath))
return false; return false;
@ -135,11 +139,11 @@ public final class CLibraryFileEntry extends ACPathEntry implements
return false; return false;
return true; return true;
} }
@Override @Override
protected String contentsToString() { protected String contentsToString() {
String result = super.contentsToString(); String result = super.contentsToString();
if(fSourceAttachmentPath != null){ if(fSourceAttachmentPath != null){
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
buf.append(result); buf.append(result);

View file

@ -28,6 +28,7 @@ public final class CLibraryPathEntry extends ACPathEntry implements
super(rc, flags); super(rc, flags);
} }
@Override
public final int getKind() { public final int getKind() {
return LIBRARY_PATH; return LIBRARY_PATH;
} }

View file

@ -29,6 +29,7 @@ public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry{
return fValue; return fValue;
} }
@Override
public final int getKind() { public final int getKind() {
return MACRO; return MACRO;
} }
@ -49,7 +50,7 @@ public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry{
public boolean equalsByContents(ICSettingEntry entry) { public boolean equalsByContents(ICSettingEntry entry) {
if(!super.equalsByContents(entry)) if(!super.equalsByContents(entry))
return false; return false;
return fValue.equals(((CMacroEntry)entry).fValue); return fValue.equals(((CMacroEntry)entry).fValue);
} }
@ -57,5 +58,5 @@ public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry{
protected String contentsToString() { protected String contentsToString() {
return new StringBuffer().append(fName).append('=').append(fValue).toString(); return new StringBuffer().append(fName).append('=').append(fValue).toString();
} }
} }

View file

@ -28,10 +28,11 @@ public final class CMacroFileEntry extends ACPathEntry implements
super(rc, flags); super(rc, flags);
} }
@Override
public final int getKind() { public final int getKind() {
return MACRO_FILE; return MACRO_FILE;
} }
@Override @Override
public final boolean isFile() { public final boolean isFile() {
return true; return true;

View file

@ -27,6 +27,7 @@ public final class COutputEntry extends ACExclusionFilterEntry implements ICOutp
super(value, exclusionPatterns, flags | VALUE_WORKSPACE_PATH); super(value, exclusionPatterns, flags | VALUE_WORKSPACE_PATH);
} }
@Override
public final int getKind() { public final int getKind() {
return OUTPUT_PATH; return OUTPUT_PATH;
} }

View file

@ -27,6 +27,7 @@ public final class CSourceEntry extends ACExclusionFilterEntry implements ICSour
super(value, exclusionPatterns, flags | VALUE_WORKSPACE_PATH); super(value, exclusionPatterns, flags | VALUE_WORKSPACE_PATH);
} }
@Override
public final int getKind() { public final int getKind() {
return SOURCE_PATH; return SOURCE_PATH;
} }

View file

@ -175,6 +175,7 @@ public interface ICConfigurationDescription extends ICSettingContainer, ICSettin
/** /**
* Returns whether or not the configuration description was modified * Returns whether or not the configuration description was modified
*/ */
@Override
boolean isModified(); boolean isModified();
/** /**

View file

@ -19,5 +19,6 @@ public interface ICMacroEntry extends ICLanguageSettingEntry {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICSettingEntry#getValue() * @see org.eclipse.cdt.core.settings.model.ICSettingEntry#getValue()
*/ */
@Override
String getValue(); String getValue();
} }

View file

@ -20,11 +20,11 @@ import org.eclipse.core.runtime.QualifiedName;
* The ICProjectDescription is the root element for obtaining the CDT project settings * The ICProjectDescription is the root element for obtaining the CDT project settings
* it can be obtained by the {@link CoreModel#getProjectDescription(IProject, boolean)} call * it can be obtained by the {@link CoreModel#getProjectDescription(IProject, boolean)} call
* @see CoreModel#getProjectDescription(IProject) * @see CoreModel#getProjectDescription(IProject)
* @see CoreModel#getProjectDescription(IProject, boolean) * @see CoreModel#getProjectDescription(IProject, boolean)
* *
*/ */
public interface ICProjectDescription extends ICSettingContainer, public interface ICProjectDescription extends ICSettingContainer,
ICSettingObject, ICSettingObject,
ICSettingsStorage, ICSettingsStorage,
ICProjectDescriptionPreferences { ICProjectDescriptionPreferences {
@ -32,7 +32,7 @@ public interface ICProjectDescription extends ICSettingContainer,
* @return {@link ICConfigurationDescription}[] containing all configurations in the project * @return {@link ICConfigurationDescription}[] containing all configurations in the project
*/ */
ICConfigurationDescription[] getConfigurations(); ICConfigurationDescription[] getConfigurations();
/** /**
* Returns the Project's active configuration. This is the configuration which is built by default * Returns the Project's active configuration. This is the configuration which is built by default
* @see ICProjectDescriptionPreferences#setConfigurationRelations(int) * @see ICProjectDescriptionPreferences#setConfigurationRelations(int)
@ -42,9 +42,9 @@ public interface ICProjectDescription extends ICSettingContainer,
/** /**
* sets active configuration for this project description * sets active configuration for this project description
* *
* @param cfg * @param cfg
* *
* @throws WriteAccessException when the project description is read-only * @throws WriteAccessException when the project description is read-only
* the description is read only if it was queried/returned by the <code>CoreModel.getProjectDescription(org.eclipse.core.resources.IProject, false)</code> call * the description is read only if it was queried/returned by the <code>CoreModel.getProjectDescription(org.eclipse.core.resources.IProject, false)</code> call
*/ */
@ -52,7 +52,7 @@ public interface ICProjectDescription extends ICSettingContainer,
/** /**
* creates/adds a new configuration for this project description * creates/adds a new configuration for this project description
* *
* @param id configuration id * @param id configuration id
* @param name configuration name * @param name configuration name
* @param base the configuration description from which the settings are to be copied * @param base the configuration description from which the settings are to be copied
@ -60,15 +60,15 @@ public interface ICProjectDescription extends ICSettingContainer,
* @throws CoreException * @throws CoreException
* @throws WriteAccessException when the project description is read-only * @throws WriteAccessException when the project description is read-only
* the description is read only if it was queried/returned by the <code>CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)</code> call * the description is read only if it was queried/returned by the <code>CoreModel#getProjectDescription(org.eclipse.core.resources.IProject, false)</code> call
* *
*/ */
ICConfigurationDescription createConfiguration(String id, String name, ICConfigurationDescription base) throws CoreException, WriteAccessException; ICConfigurationDescription createConfiguration(String id, String name, ICConfigurationDescription base) throws CoreException, WriteAccessException;
/** /**
* creates/adds a new configuration for this project description * creates/adds a new configuration for this project description
* This method is typically used by the Build System-specific code for creating new configurations * This method is typically used by the Build System-specific code for creating new configurations
* *
* @param buildSystemId build system id, i.e. the extension id contributing to the * @param buildSystemId build system id, i.e. the extension id contributing to the
* org.eclipse.cdt.core.CConfigurationDataProvider extension point * org.eclipse.cdt.core.CConfigurationDataProvider extension point
* @param data CConfigurationData to be associated with this configuration * @param data CConfigurationData to be associated with this configuration
* @return {@link ICConfigurationDescription} created * @return {@link ICConfigurationDescription} created
@ -89,7 +89,7 @@ public interface ICProjectDescription extends ICSettingContainer,
* @return {@link ICConfigurationDescription} of the given id or null if not found * @return {@link ICConfigurationDescription} of the given id or null if not found
*/ */
ICConfigurationDescription getConfigurationById(String id); ICConfigurationDescription getConfigurationById(String id);
/** /**
* Remove Configuration of the given name from the project description * Remove Configuration of the given name from the project description
* @param name String name of the configuration to remove * @param name String name of the configuration to remove
@ -105,23 +105,24 @@ public interface ICProjectDescription extends ICSettingContainer,
* the description is read only if it was queried/returned by the <code>CoreModel.getProjectDescription(IProject, false)</code> call * the description is read only if it was queried/returned by the <code>CoreModel.getProjectDescription(IProject, false)</code> call
*/ */
void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException; void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException;
/** /**
* @return IProject this project description is associated with * @return IProject this project description is associated with
*/ */
IProject getProject(); IProject getProject();
/** /**
* @return true if the project description was modified, false otherwise * @return true if the project description was modified, false otherwise
*/ */
@Override
boolean isModified(); boolean isModified();
/** /**
* the get/setSettionsProperty methods allow to associate the session properties with the given project description * the get/setSettionsProperty methods allow to associate the session properties with the given project description
* session properties are not persisted and are not restored on the next eclipse session * session properties are not persisted and are not restored on the next eclipse session
* the scope of project description session properties is the current project description, * the scope of project description session properties is the current project description,
* i.e. modifications to the properties are not applied until the setProjectDescription call * i.e. modifications to the properties are not applied until the setProjectDescription call
* *
* @param name * @param name
*/ */
Object getSessionProperty(QualifiedName name); Object getSessionProperty(QualifiedName name);
@ -131,16 +132,16 @@ public interface ICProjectDescription extends ICSettingContainer,
* session properties are not persisted and are not restored on the next eclipse session * session properties are not persisted and are not restored on the next eclipse session
* the scope of project description session properties is the current project description, * the scope of project description session properties is the current project description,
* i.e. modifications to the properties are not applied until the setProjectDescription call * i.e. modifications to the properties are not applied until the setProjectDescription call
* *
* @param name * @param name
* @param value * @param value
*/ */
void setSessionProperty(QualifiedName name, Object value); void setSessionProperty(QualifiedName name, Object value);
/** /**
* Returns the default setting ICConfigurationDescription. This is the configuration * Returns the default setting ICConfigurationDescription. This is the configuration
* used by the CDT editor and views. * used by the CDT editor and views.
* *
* @see ICProjectDescriptionPreferences#setConfigurationRelations(int) * @see ICProjectDescriptionPreferences#setConfigurationRelations(int)
* @return the default {@link ICConfigurationDescription} * @return the default {@link ICConfigurationDescription}
*/ */
@ -153,28 +154,28 @@ public interface ICProjectDescription extends ICSettingContainer,
* @param cfg * @param cfg
*/ */
void setDefaultSettingConfiguration(ICConfigurationDescription cfg); void setDefaultSettingConfiguration(ICConfigurationDescription cfg);
/** /**
* when true specifies that the project creation is in progress. * when true specifies that the project creation is in progress.
* Sometimes project creation might be performed via multiple steps, e.g. * Sometimes project creation might be performed via multiple steps, e.g.
* the New Project Wizard may create a temporary project with temporary settings * the New Project Wizard may create a temporary project with temporary settings
* and delete it on cancel, etc. * and delete it on cancel, etc.
* *
* Thus the project may exist as well as the project may contain the associated ICProjectDescription, * Thus the project may exist as well as the project may contain the associated ICProjectDescription,
* but its initialization may not be completed. * but its initialization may not be completed.
* *
* once the flag is set to false it can never be reset back to true. * once the flag is set to false it can never be reset back to true.
* if {@link ICProjectDescriptionManager#setProjectDescription(IProject, ICProjectDescription)} is called * if {@link ICProjectDescriptionManager#setProjectDescription(IProject, ICProjectDescription)} is called
* for the description containing the true "isCdtProjectCreating" state, * for the description containing the true "isCdtProjectCreating" state,
* but the project already contains the project description with the false "isCdtProjectCreating" state * but the project already contains the project description with the false "isCdtProjectCreating" state
* the true state will be ignored, i.e. the resulting setting will contain false "isCdtProjectCreating" state * the true state will be ignored, i.e. the resulting setting will contain false "isCdtProjectCreating" state
* *
* so only the newly created descriptions (created via a {@link ICProjectDescriptionManager#createProjectDescription(IProject, boolean, boolean)}) may contain * so only the newly created descriptions (created via a {@link ICProjectDescriptionManager#createProjectDescription(IProject, boolean, boolean)}) may contain
* true "isCdtProjectCreating" state * true "isCdtProjectCreating" state
* *
* *
* @return boolean * @return boolean
* *
* @see ICProjectDescriptionManager#createProjectDescription(IProject, boolean, boolean) * @see ICProjectDescriptionManager#createProjectDescription(IProject, boolean, boolean)
* @see #setCdtProjectCreated() * @see #setCdtProjectCreated()
*/ */
@ -182,7 +183,7 @@ public interface ICProjectDescription extends ICSettingContainer,
/** /**
* sets the project creation state to false * sets the project creation state to false
* *
* @see #isCdtProjectCreating() * @see #isCdtProjectCreating()
* @see ICProjectDescriptionManager#createProjectDescription(IProject, boolean, boolean) * @see ICProjectDescriptionManager#createProjectDescription(IProject, boolean, boolean)
*/ */

View file

@ -25,21 +25,22 @@ public abstract class MultiItemsHolder implements ICMultiItemsHolder {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICMultiItemsHolder#getItems() * @see org.eclipse.cdt.core.settings.model.ICMultiItemsHolder#getItems()
*/ */
@Override
public abstract Object[] getItems(); public abstract Object[] getItems();
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICMultiItemsHolder#setStringListMode(int) * @see org.eclipse.cdt.core.settings.model.ICMultiItemsHolder#setStringListMode(int)
*/ */
/** /**
* This method is put here to prevent UI from * This method is put here to prevent UI from
* accessing constructors in "internal" dirs. * accessing constructors in "internal" dirs.
* *
* Creates multiple configuration description. * Creates multiple configuration description.
* If there's 1 cfg.desc in array, * If there's 1 cfg.desc in array,
* it's returned itself. * it's returned itself.
* *
* @param rds - array of cfg.descs * @param rds - array of cfg.descs
* *
* @return multiple cfg.description or single cfg.desc. * @return multiple cfg.description or single cfg.desc.
*/ */
public static ICConfigurationDescription createCDescription(ICConfigurationDescription[] rds) { public static ICConfigurationDescription createCDescription(ICConfigurationDescription[] rds) {
@ -51,16 +52,16 @@ public abstract class MultiItemsHolder implements ICMultiItemsHolder {
return new MultiConfigDescription(rds); return new MultiConfigDescription(rds);
} }
/** /**
* This method is put here to prevent UI from * This method is put here to prevent UI from
* accessing constructors in "internal" dirs. * accessing constructors in "internal" dirs.
* *
* Creates multiple resource description, it * Creates multiple resource description, it
* can be either MultiFile or MultiFolder. * can be either MultiFile or MultiFolder.
* If there's 1 description in array, * If there's 1 description in array,
* it's returned itself. * it's returned itself.
* *
* @param rds - array of resource descs * @param rds - array of resource descs
* *
* @return multiple res.description or single res.desc. * @return multiple res.description or single res.desc.
*/ */
public static ICResourceDescription createRDescription(ICResourceDescription[] rds) { public static ICResourceDescription createRDescription(ICResourceDescription[] rds) {

View file

@ -15,21 +15,22 @@ import java.util.List;
/** /**
* This class is intended to hold "similar" Language Setting objects. * This class is intended to hold "similar" Language Setting objects.
* Normally, they should have the same name. * Normally, they should have the same name.
*/ */
public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguageSetting { public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguageSetting {
ICLanguageSetting[] items = null; ICLanguageSetting[] items = null;
ICConfigurationDescription cfgd = null; ICConfigurationDescription cfgd = null;
public MultiLanguageSetting(List<ICLanguageSetting> data, ICConfigurationDescription cf) { public MultiLanguageSetting(List<ICLanguageSetting> data, ICConfigurationDescription cf) {
items = data.toArray(new ICLanguageSetting[data.size()]); items = data.toArray(new ICLanguageSetting[data.size()]);
cfgd = cf; cfgd = cf;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#getLanguageId() * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#getLanguageId()
*/ */
@Override
public String getLanguageId() { public String getLanguageId() {
return items[0].getLanguageId(); // Assuming language is the same. return items[0].getLanguageId(); // Assuming language is the same.
} }
@ -48,6 +49,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#getSettingEntriesList(int) * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#getSettingEntriesList(int)
*/ */
@Override
public List<ICLanguageSettingEntry> getSettingEntriesList(int kind) { public List<ICLanguageSettingEntry> getSettingEntriesList(int kind) {
return Arrays.asList(getSettingEntries(kind)); return Arrays.asList(getSettingEntries(kind));
} }
@ -75,6 +77,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#getSupportedEntryKinds() * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#getSupportedEntryKinds()
*/ */
@Override
public int getSupportedEntryKinds() { public int getSupportedEntryKinds() {
int res = 0; int res = 0;
for (ICLanguageSetting item : items) for (ICLanguageSetting item : items)
@ -85,11 +88,13 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setLanguageId(java.lang.String) * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setLanguageId(java.lang.String)
*/ */
@Override
public void setLanguageId(String id) {} // Do nothing public void setLanguageId(String id) {} // Do nothing
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setSettingEntries(int, org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry[]) * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setSettingEntries(int, org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry[])
*/ */
@Override
public void setSettingEntries(int kind, ICLanguageSettingEntry[] entries) { public void setSettingEntries(int kind, ICLanguageSettingEntry[] entries) {
for (ICLanguageSetting item : items) for (ICLanguageSetting item : items)
item.setSettingEntries(kind, entries); item.setSettingEntries(kind, entries);
@ -98,6 +103,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setSettingEntries(int, java.util.List) * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setSettingEntries(int, java.util.List)
*/ */
@Override
public void setSettingEntries(int kind, List<ICLanguageSettingEntry> entriesList) { public void setSettingEntries(int kind, List<ICLanguageSettingEntry> entriesList) {
for (ICLanguageSetting item : items) for (ICLanguageSetting item : items)
item.setSettingEntries(kind, entriesList); item.setSettingEntries(kind, entriesList);
@ -106,6 +112,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setSourceContentTypeIds(java.lang.String[]) * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setSourceContentTypeIds(java.lang.String[])
*/ */
@Override
public void setSourceContentTypeIds(String[] ids) { public void setSourceContentTypeIds(String[] ids) {
for (ICLanguageSetting item : items) for (ICLanguageSetting item : items)
item.setSourceContentTypeIds(ids); item.setSourceContentTypeIds(ids);
@ -114,6 +121,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setSourceExtensions(java.lang.String[]) * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setSourceExtensions(java.lang.String[])
*/ */
@Override
public void setSourceExtensions(String[] exts) { public void setSourceExtensions(String[] exts) {
for (ICLanguageSetting item : items) for (ICLanguageSetting item : items)
item.setSourceExtensions(exts); item.setSourceExtensions(exts);
@ -122,6 +130,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#supportsEntryKind(int) * @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#supportsEntryKind(int)
*/ */
@Override
public boolean supportsEntryKind(int kind) { public boolean supportsEntryKind(int kind) {
for (ICLanguageSetting item : items) for (ICLanguageSetting item : items)
if (item.supportsEntryKind(kind)) if (item.supportsEntryKind(kind))
@ -132,6 +141,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICSettingObject#getConfiguration() * @see org.eclipse.cdt.core.settings.model.ICSettingObject#getConfiguration()
*/ */
@Override
public ICConfigurationDescription getConfiguration() { public ICConfigurationDescription getConfiguration() {
if (DEBUG) if (DEBUG)
System.out.println("Bad multi access: MultiLanguageSetting.getConfiguration()"); //$NON-NLS-1$ System.out.println("Bad multi access: MultiLanguageSetting.getConfiguration()"); //$NON-NLS-1$
@ -141,6 +151,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICSettingObject#getId() * @see org.eclipse.cdt.core.settings.model.ICSettingObject#getId()
*/ */
@Override
public String getId() { // IDs are different public String getId() { // IDs are different
if (DEBUG) if (DEBUG)
System.out.println("Bad multi access: MultiLanguageSetting.getId()"); //$NON-NLS-1$ System.out.println("Bad multi access: MultiLanguageSetting.getId()"); //$NON-NLS-1$
@ -150,6 +161,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICSettingObject#getName() * @see org.eclipse.cdt.core.settings.model.ICSettingObject#getName()
*/ */
@Override
public String getName() { // names are proposed to be equal public String getName() { // names are proposed to be equal
return items[0].getName(); return items[0].getName();
} }
@ -157,6 +169,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICSettingObject#getParent() * @see org.eclipse.cdt.core.settings.model.ICSettingObject#getParent()
*/ */
@Override
public ICSettingContainer getParent() { public ICSettingContainer getParent() {
if (DEBUG) if (DEBUG)
System.out.println("Bad multi access: MultiLanguageSetting.getParent()"); //$NON-NLS-1$ System.out.println("Bad multi access: MultiLanguageSetting.getParent()"); //$NON-NLS-1$
@ -166,6 +179,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICSettingObject#getType() * @see org.eclipse.cdt.core.settings.model.ICSettingObject#getType()
*/ */
@Override
public int getType() { public int getType() {
int x = items[0].getType(); int x = items[0].getType();
for (ICLanguageSetting item : items) for (ICLanguageSetting item : items)
@ -177,6 +191,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICSettingObject#isReadOnly() * @see org.eclipse.cdt.core.settings.model.ICSettingObject#isReadOnly()
*/ */
@Override
public boolean isReadOnly() { public boolean isReadOnly() {
for (int i=0; i<items.length; i++) for (int i=0; i<items.length; i++)
if (! items[i].isReadOnly()) if (! items[i].isReadOnly())
@ -187,6 +202,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.settings.model.ICSettingObject#isValid() * @see org.eclipse.cdt.core.settings.model.ICSettingObject#isValid()
*/ */
@Override
public boolean isValid() { public boolean isValid() {
for (int i=0; i<items.length; i++) for (int i=0; i<items.length; i++)
if (! items[i].isValid()) if (! items[i].isValid())
@ -199,19 +215,23 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
return items; return items;
} }
@Override
public ICLanguageSettingEntry[] getResolvedSettingEntries(int kind) { public ICLanguageSettingEntry[] getResolvedSettingEntries(int kind) {
return null; return null;
} }
@Override
public ICLanguageSettingEntry[] getSettingEntries(int kind) { public ICLanguageSettingEntry[] getSettingEntries(int kind) {
ICLanguageSettingEntry[][] ses = getSettingEntriesM(kind); ICLanguageSettingEntry[][] ses = getSettingEntriesM(kind);
return ses[0]; return ses[0];
} }
@Override
public String[] getSourceContentTypeIds() { public String[] getSourceContentTypeIds() {
return null; return null;
} }
@Override
public String[] getSourceExtensions() { public String[] getSourceExtensions() {
return null; return null;
} }

View file

@ -25,24 +25,24 @@ import org.eclipse.core.runtime.IPath;
public class CResourceDataContainer { public class CResourceDataContainer {
private PathSettingsContainer fRcDataContainer; private PathSettingsContainer fRcDataContainer;
private boolean fIncludeCurrent; private boolean fIncludeCurrent;
public CResourceDataContainer(PathSettingsContainer pathSettings, boolean includeCurrent){ public CResourceDataContainer(PathSettingsContainer pathSettings, boolean includeCurrent){
fRcDataContainer = pathSettings; fRcDataContainer = pathSettings;
fIncludeCurrent = includeCurrent; fIncludeCurrent = includeCurrent;
} }
public void changeCurrentPath(IPath path, boolean moveChildren){ public void changeCurrentPath(IPath path, boolean moveChildren){
fRcDataContainer.setPath(path, moveChildren); fRcDataContainer.setPath(path, moveChildren);
} }
public IPath getCurrentPath(){ public IPath getCurrentPath(){
return fRcDataContainer.getPath(); return fRcDataContainer.getPath();
} }
public CResourceData getCurrentResourceData(){ public CResourceData getCurrentResourceData(){
return (CResourceData)fRcDataContainer.getValue(); return (CResourceData)fRcDataContainer.getValue();
} }
public CResourceData getResourceData(IPath path, boolean exactPath) { public CResourceData getResourceData(IPath path, boolean exactPath) {
PathSettingsContainer cr = fRcDataContainer.getChildContainer(path, false, exactPath); PathSettingsContainer cr = fRcDataContainer.getChildContainer(path, false, exactPath);
if(cr != null) if(cr != null)
@ -57,19 +57,20 @@ public class CResourceDataContainer {
public CResourceData[] getResourceDatas(final int kind) { public CResourceData[] getResourceDatas(final int kind) {
return getResourceDatas(kind, CResourceData.class); return getResourceDatas(kind, CResourceData.class);
} }
public CResourceData[] getResourceDatas(int kind, Class<CResourceData> clazz){ public CResourceData[] getResourceDatas(int kind, Class<CResourceData> clazz){
List<CResourceData> list = getRcDataList(kind); List<CResourceData> list = getRcDataList(kind);
CResourceData datas[] = (CResourceData[])Array.newInstance(clazz, list.size()); CResourceData datas[] = (CResourceData[])Array.newInstance(clazz, list.size());
return list.toArray(datas); return list.toArray(datas);
} }
public List<CResourceData> getRcDataList(final int kind){ public List<CResourceData> getRcDataList(final int kind){
final List<CResourceData> list = new ArrayList<CResourceData>(); final List<CResourceData> list = new ArrayList<CResourceData>();
fRcDataContainer.accept(new IPathSettingsContainerVisitor(){ fRcDataContainer.accept(new IPathSettingsContainerVisitor(){
@Override
public boolean visit(PathSettingsContainer container) { public boolean visit(PathSettingsContainer container) {
if(fIncludeCurrent || container != fRcDataContainer){ if(fIncludeCurrent || container != fRcDataContainer){
CResourceData data = (CResourceData)container.getValue(); CResourceData data = (CResourceData)container.getValue();
@ -79,7 +80,7 @@ public class CResourceDataContainer {
return true; return true;
} }
}); });
return list; return list;
} }
@ -93,16 +94,16 @@ public class CResourceDataContainer {
public void removeResourceData(IPath path) { public void removeResourceData(IPath path) {
fRcDataContainer.removeChildContainer(path); fRcDataContainer.removeChildContainer(path);
} }
public void addResourceData(CResourceData data){ public void addResourceData(CResourceData data){
PathSettingsContainer cr = fRcDataContainer.getChildContainer(data.getPath(), true, true); PathSettingsContainer cr = fRcDataContainer.getChildContainer(data.getPath(), true, true);
cr.setValue(data); cr.setValue(data);
} }
public CFileData getFileData(IPath path){ public CFileData getFileData(IPath path){
return (CFileData)getResourceData(path, true, ICSettingBase.SETTING_FILE); return (CFileData)getResourceData(path, true, ICSettingBase.SETTING_FILE);
} }
public CFolderData getFolderData(IPath path){ public CFolderData getFolderData(IPath path){
return (CFolderData)getResourceData(path, true, ICSettingBase.SETTING_FOLDER); return (CFolderData)getResourceData(path, true, ICSettingBase.SETTING_FOLDER);
} }

View file

@ -16,9 +16,9 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry;
/** /**
* A storage where stored data is organized by "kind". * A storage where stored data is organized by "kind".
* In most cases kind is one of {@link ICLanguageSettingEntry}, i.e. include path, macro etc. * In most cases kind is one of {@link ICLanguageSettingEntry}, i.e. include path, macro etc.
* *
* @param <T> - stored type * @param <T> - stored type
* *
* @see ICSettingEntry#INCLUDE_PATH * @see ICSettingEntry#INCLUDE_PATH
* @see ICSettingEntry#INCLUDE_FILE * @see ICSettingEntry#INCLUDE_FILE
* @see ICSettingEntry#MACRO * @see ICSettingEntry#MACRO
@ -41,8 +41,8 @@ public class KindBasedStore<T> implements Cloneable {
private static final int INDEX_SOURCE_PATH = 6; private static final int INDEX_SOURCE_PATH = 6;
private static final int INDEX_OUPUT_PATH = 7; private static final int INDEX_OUPUT_PATH = 7;
private static final int ALL_STORAGE_SIZE = 8; private static final int ALL_STORAGE_SIZE = 8;
public static final int ORED_LANG_ENTRY_KINDS = public static final int ORED_LANG_ENTRY_KINDS =
ICLanguageSettingEntry.INCLUDE_PATH ICLanguageSettingEntry.INCLUDE_PATH
| ICLanguageSettingEntry.INCLUDE_FILE | ICLanguageSettingEntry.INCLUDE_FILE
| ICLanguageSettingEntry.MACRO | ICLanguageSettingEntry.MACRO
@ -50,7 +50,7 @@ public class KindBasedStore<T> implements Cloneable {
| ICLanguageSettingEntry.LIBRARY_PATH | ICLanguageSettingEntry.LIBRARY_PATH
| ICLanguageSettingEntry.LIBRARY_FILE; | ICLanguageSettingEntry.LIBRARY_FILE;
public static final int ORED_ALL_ENTRY_KINDS = public static final int ORED_ALL_ENTRY_KINDS =
ICLanguageSettingEntry.INCLUDE_PATH ICLanguageSettingEntry.INCLUDE_PATH
| ICLanguageSettingEntry.INCLUDE_FILE | ICLanguageSettingEntry.INCLUDE_FILE
| ICLanguageSettingEntry.MACRO | ICLanguageSettingEntry.MACRO
@ -59,7 +59,7 @@ public class KindBasedStore<T> implements Cloneable {
| ICLanguageSettingEntry.LIBRARY_FILE | ICLanguageSettingEntry.LIBRARY_FILE
| ICLanguageSettingEntry.SOURCE_PATH | ICLanguageSettingEntry.SOURCE_PATH
| ICLanguageSettingEntry.OUTPUT_PATH; | ICLanguageSettingEntry.OUTPUT_PATH;
private static final int LANG_ENTRY_KINDS[] = new int[]{ private static final int LANG_ENTRY_KINDS[] = new int[]{
ICLanguageSettingEntry.INCLUDE_PATH, ICLanguageSettingEntry.INCLUDE_PATH,
ICLanguageSettingEntry.INCLUDE_FILE, ICLanguageSettingEntry.INCLUDE_FILE,
@ -81,7 +81,7 @@ public class KindBasedStore<T> implements Cloneable {
}; };
// private static final int INEXISTENT_INDEX = -1; // private static final int INEXISTENT_INDEX = -1;
private Object[] fEntryStorage; private Object[] fEntryStorage;
public KindBasedStore(){ public KindBasedStore(){
@ -162,11 +162,11 @@ public class KindBasedStore<T> implements Cloneable {
fEntryStorage[index] = object; fEntryStorage[index] = object;
return old; return old;
} }
private class KindBasedInfo implements IKindBasedInfo<T> { private class KindBasedInfo implements IKindBasedInfo<T> {
int fIdex; int fIdex;
int fKind; int fKind;
KindBasedInfo(int num, boolean isKind){ KindBasedInfo(int num, boolean isKind){
if(isKind){ if(isKind){
fIdex = kindToIndex(num); fIdex = kindToIndex(num);
@ -176,26 +176,29 @@ public class KindBasedStore<T> implements Cloneable {
fKind = indexToKind(num); fKind = indexToKind(num);
} }
} }
@Override
public T getInfo() { public T getInfo() {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
T info = (T)fEntryStorage[fIdex]; T info = (T)fEntryStorage[fIdex];
return info; return info;
} }
@Override
public int getKind() { public int getKind() {
return fKind; return fKind;
} }
@Override
public T setInfo(T newInfo) { public T setInfo(T newInfo) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
T old = (T)fEntryStorage[fIdex]; T old = (T)fEntryStorage[fIdex];
fEntryStorage[fIdex] = newInfo; fEntryStorage[fIdex] = newInfo;
return old; return old;
} }
} }
public IKindBasedInfo<T>[] getContents(){ public IKindBasedInfo<T>[] getContents(){
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
IKindBasedInfo<T> infos[] = new IKindBasedInfo[fEntryStorage.length]; IKindBasedInfo<T> infos[] = new IKindBasedInfo[fEntryStorage.length];
@ -204,11 +207,11 @@ public class KindBasedStore<T> implements Cloneable {
} }
return infos; return infos;
} }
public IKindBasedInfo<T> getInfo(int kind){ public IKindBasedInfo<T> getInfo(int kind){
return new KindBasedInfo(kind, true); return new KindBasedInfo(kind, true);
} }
public void clear(){ public void clear(){
for(int i = 0; i < fEntryStorage.length; i++){ for(int i = 0; i < fEntryStorage.length; i++){
fEntryStorage[i] = null; fEntryStorage[i] = null;
@ -226,6 +229,6 @@ public class KindBasedStore<T> implements Cloneable {
} }
return null; return null;
} }
} }

View file

@ -990,6 +990,7 @@ public class PathEntryTranslator {
final Set<PathEntryComposer> set = new HashSet<PathEntryComposer>(); final Set<PathEntryComposer> set = new HashSet<PathEntryComposer>();
fStorage.accept(new IPathSettingsContainerVisitor() { fStorage.accept(new IPathSettingsContainerVisitor() {
@Override
public boolean visit(PathSettingsContainer container) { public boolean visit(PathSettingsContainer container) {
PathEntryCollector clr = (PathEntryCollector)container.getValue(); PathEntryCollector clr = (PathEntryCollector)container.getValue();
clr.getLocalCollectedEntries(kind, list, set); clr.getLocalCollectedEntries(kind, list, set);
@ -2033,6 +2034,7 @@ public class PathEntryTranslator {
final int kinds[] = KindBasedStore.getLanguageEntryKinds(); final int kinds[] = KindBasedStore.getLanguageEntryKinds();
rcDatas.accept(new IPathSettingsContainerVisitor() { rcDatas.accept(new IPathSettingsContainerVisitor() {
@Override
public boolean visit(PathSettingsContainer container) { public boolean visit(PathSettingsContainer container) {
CResourceData data = (CResourceData)container.getValue(); CResourceData data = (CResourceData)container.getValue();
if (data != null) { if (data != null) {

View file

@ -181,6 +181,7 @@ public final class PathSettingsContainer {
final List<PathSettingsContainer> list = new ArrayList<PathSettingsContainer>(); final List<PathSettingsContainer> list = new ArrayList<PathSettingsContainer>();
accept(new IPathSettingsContainerVisitor(){ accept(new IPathSettingsContainerVisitor(){
@Override
public boolean visit(PathSettingsContainer container) { public boolean visit(PathSettingsContainer container) {
if(container != PathSettingsContainer.this || includeThis) if(container != PathSettingsContainer.this || includeThis)
list.add(container); list.add(container);
@ -258,6 +259,7 @@ public final class PathSettingsContainer {
final List<Object> list = new ArrayList<Object>(); final List<Object> list = new ArrayList<Object>();
accept(new IPathSettingsContainerVisitor(){ accept(new IPathSettingsContainerVisitor(){
@Override
public boolean visit(PathSettingsContainer container) { public boolean visit(PathSettingsContainer container) {
if(container != PathSettingsContainer.this || includeThis) if(container != PathSettingsContainer.this || includeThis)
list.add(container.getValue()); list.add(container.getValue());

View file

@ -17,13 +17,13 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.NoSuchElementException;
import org.eclipse.cdt.core.model.CoreModelUtil; import org.eclipse.cdt.core.model.CoreModelUtil;
public class PatternNameMap { public class PatternNameMap {
private static final char[] SPEC_CHARS = new char[]{'*', '?'}; private static final char[] SPEC_CHARS = new char[]{'*', '?'};
static final String DOUBLE_STAR_PATTERN = "**"; //$NON-NLS-1$ static final String DOUBLE_STAR_PATTERN = "**"; //$NON-NLS-1$
private Map<String, PathSettingsContainer> fChildrenMap; private Map<String, PathSettingsContainer> fChildrenMap;
@ -38,7 +38,7 @@ public class PatternNameMap {
StringCharArray(String string){ StringCharArray(String string){
fString = string; fString = string;
} }
char[] getCharArray(){ char[] getCharArray(){
if(fCharArray == null){ if(fCharArray == null){
fCharArray = fString.toCharArray(); fCharArray = fString.toCharArray();
@ -50,10 +50,10 @@ public class PatternNameMap {
public boolean equals(Object obj) { public boolean equals(Object obj) {
if(obj == this) if(obj == this)
return true; return true;
if(!(obj instanceof StringCharArray)) if(!(obj instanceof StringCharArray))
return false; return false;
return fString.equals(((StringCharArray)obj).fString); return fString.equals(((StringCharArray)obj).fString);
} }
@ -67,25 +67,28 @@ public class PatternNameMap {
return fString; return fString;
} }
} }
private class EmptyIterator implements Iterator<PathSettingsContainer>{ private class EmptyIterator implements Iterator<PathSettingsContainer>{
@Override
public boolean hasNext() { public boolean hasNext() {
return false; return false;
} }
@Override
public PathSettingsContainer next() { public PathSettingsContainer next() {
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
@Override
public void remove() { public void remove() {
throw new IllegalStateException(); throw new IllegalStateException();
} }
} }
private class ValuesCollection extends AbstractCollection<PathSettingsContainer> { private class ValuesCollection extends AbstractCollection<PathSettingsContainer> {
private class Iter implements Iterator<PathSettingsContainer> { private class Iter implements Iterator<PathSettingsContainer> {
private Iterator<Entry<String, PathSettingsContainer>> fEntrySetIter; private Iterator<Entry<String, PathSettingsContainer>> fEntrySetIter;
private Entry<String, PathSettingsContainer> fCur; private Entry<String, PathSettingsContainer> fCur;
@ -93,15 +96,18 @@ public class PatternNameMap {
Iter (Iterator<Entry<String, PathSettingsContainer>> entryIter){ Iter (Iterator<Entry<String, PathSettingsContainer>> entryIter){
this.fEntrySetIter = entryIter; this.fEntrySetIter = entryIter;
} }
@Override
public boolean hasNext() { public boolean hasNext() {
return fEntrySetIter.hasNext(); return fEntrySetIter.hasNext();
} }
@Override
public PathSettingsContainer next() { public PathSettingsContainer next() {
fCur = fEntrySetIter.next(); fCur = fEntrySetIter.next();
return fCur.getValue(); return fCur.getValue();
} }
@Override
public void remove() { public void remove() {
fEntrySetIter.remove(); fEntrySetIter.remove();
String name = fCur.getKey(); String name = fCur.getKey();
@ -122,12 +128,12 @@ public class PatternNameMap {
public int size() { public int size() {
return PatternNameMap.this.size(); return PatternNameMap.this.size();
} }
@Override @Override
public void clear(){ public void clear(){
PatternNameMap.this.clear(); PatternNameMap.this.clear();
} }
@Override @Override
public boolean contains(Object o){ public boolean contains(Object o){
return fChildrenMap != null ? fChildrenMap.containsValue(o) : false; return fChildrenMap != null ? fChildrenMap.containsValue(o) : false;
@ -137,15 +143,15 @@ public class PatternNameMap {
public /* PathSettingsContainer */ Object get(String name){ public /* PathSettingsContainer */ Object get(String name){
return fChildrenMap != null ? fChildrenMap.get(name) : null; return fChildrenMap != null ? fChildrenMap.get(name) : null;
} }
public int size(){ public int size(){
return fChildrenMap != null ? fChildrenMap.size() : 0; return fChildrenMap != null ? fChildrenMap.size() : 0;
} }
public boolean isEmpty(){ public boolean isEmpty(){
return fChildrenMap == null || fChildrenMap.isEmpty(); return fChildrenMap == null || fChildrenMap.isEmpty();
} }
public boolean hasPatterns(){ public boolean hasPatterns(){
return fContainsDoubleStar || hasPatternsMap(); return fContainsDoubleStar || hasPatternsMap();
} }
@ -157,7 +163,7 @@ public class PatternNameMap {
public List<PathSettingsContainer> getValues(String name){ public List<PathSettingsContainer> getValues(String name){
if(fChildrenMap == null) if(fChildrenMap == null)
return null; return null;
PathSettingsContainer val = fChildrenMap.get(name); PathSettingsContainer val = fChildrenMap.get(name);
if(hasPatternsMap()){ if(hasPatternsMap()){
List<PathSettingsContainer> list; List<PathSettingsContainer> list;
@ -167,10 +173,10 @@ public class PatternNameMap {
} else { } else {
list = null; list = null;
} }
Map.Entry<PatternNameMap.StringCharArray,PathSettingsContainer> entry; Map.Entry<PatternNameMap.StringCharArray,PathSettingsContainer> entry;
StringCharArray strCA; StringCharArray strCA;
char[] nameCharArray = name.toCharArray(); char[] nameCharArray = name.toCharArray();
for(Iterator<Map.Entry<PatternNameMap.StringCharArray,PathSettingsContainer>> iter = fPatternMap.entrySet().iterator(); iter.hasNext();){ for(Iterator<Map.Entry<PatternNameMap.StringCharArray,PathSettingsContainer>> iter = fPatternMap.entrySet().iterator(); iter.hasNext();){
entry = iter.next(); entry = iter.next();
strCA = entry.getKey(); strCA = entry.getKey();
@ -188,19 +194,19 @@ public class PatternNameMap {
} }
return null; return null;
} }
public boolean containsDoubleStar(){ public boolean containsDoubleStar(){
return fContainsDoubleStar; return fContainsDoubleStar;
} }
public /* PathSettingsContainer */ Object put(String name, /* PathSettingsContainer */Object value){ public /* PathSettingsContainer */ Object put(String name, /* PathSettingsContainer */Object value){
return put(name, (PathSettingsContainer)value); return put(name, (PathSettingsContainer)value);
} }
private PathSettingsContainer put(String name, PathSettingsContainer value){ private PathSettingsContainer put(String name, PathSettingsContainer value){
if(value == null) if(value == null)
return (PathSettingsContainer)remove(name); return (PathSettingsContainer)remove(name);
PathSettingsContainer oldValue; PathSettingsContainer oldValue;
if(fChildrenMap == null){ if(fChildrenMap == null){
fChildrenMap = new HashMap<String, PathSettingsContainer>(); fChildrenMap = new HashMap<String, PathSettingsContainer>();
@ -208,22 +214,22 @@ public class PatternNameMap {
} else { } else {
oldValue = fChildrenMap.get(name); oldValue = fChildrenMap.get(name);
} }
fChildrenMap.put(name, value); fChildrenMap.put(name, value);
if(DOUBLE_STAR_PATTERN.equals(name)){ if(DOUBLE_STAR_PATTERN.equals(name)){
fContainsDoubleStar = true; fContainsDoubleStar = true;
} else if(isPatternName(name)){ } else if(isPatternName(name)){
StringCharArray strCA = new StringCharArray(name); StringCharArray strCA = new StringCharArray(name);
if(fPatternMap == null) if(fPatternMap == null)
fPatternMap = new HashMap<StringCharArray, PathSettingsContainer>(); fPatternMap = new HashMap<StringCharArray, PathSettingsContainer>();
fPatternMap.put(strCA, value); fPatternMap.put(strCA, value);
} }
return oldValue; return oldValue;
} }
public /* PathSettingsContainer */ Object remove(String name){ public /* PathSettingsContainer */ Object remove(String name){
if(fChildrenMap != null){ if(fChildrenMap != null){
PathSettingsContainer oldVal = fChildrenMap.remove(name); PathSettingsContainer oldVal = fChildrenMap.remove(name);
@ -240,7 +246,7 @@ public class PatternNameMap {
} }
return null; return null;
} }
private void removePattern(String name){ private void removePattern(String name){
if (fPatternMap != null){ if (fPatternMap != null){
fPatternMap.remove(new StringCharArray(name)); fPatternMap.remove(new StringCharArray(name));
@ -248,7 +254,7 @@ public class PatternNameMap {
fPatternMap = null; fPatternMap = null;
} }
} }
private static boolean hasSpecChars(String str){ private static boolean hasSpecChars(String str){
for(int i = 0; i < SPEC_CHARS.length; i++){ for(int i = 0; i < SPEC_CHARS.length; i++){
if(str.indexOf(SPEC_CHARS[i]) != -1) if(str.indexOf(SPEC_CHARS[i]) != -1)
@ -261,13 +267,13 @@ public class PatternNameMap {
//TODO: check escape chars //TODO: check escape chars
return hasSpecChars(str); return hasSpecChars(str);
} }
public void clear(){ public void clear(){
fChildrenMap = null; fChildrenMap = null;
fPatternMap = null; fPatternMap = null;
fContainsDoubleStar = false; fContainsDoubleStar = false;
} }
public Collection<PathSettingsContainer> values(){ public Collection<PathSettingsContainer> values(){
if(fValues == null) if(fValues == null)
fValues = new ValuesCollection(); fValues = new ValuesCollection();

View file

@ -50,7 +50,7 @@ public abstract class ResourceChangeHandlerBase implements IResourceChangeListen
void handleProjectClose(IProject project); void handleProjectClose(IProject project);
/** /**
* Call-back ticked at end of a resource change event * Call-back ticked at end of a resource change event
*/ */
void done(); void done();
} }
@ -66,7 +66,7 @@ public abstract class ResourceChangeHandlerBase implements IResourceChangeListen
fHandler = handler; fHandler = handler;
// fRootDelta = rootDelta; // fRootDelta = rootDelta;
} }
private IResource getResource(IPath path, IResource baseResource){ private IResource getResource(IPath path, IResource baseResource){
switch(baseResource.getType()){ switch(baseResource.getType()){
case IResource.FILE: case IResource.FILE:
@ -80,24 +80,25 @@ public abstract class ResourceChangeHandlerBase implements IResourceChangeListen
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
} }
private boolean checkInitHandleResourceMove(IResource fromRc, IResource toRc){ private boolean checkInitHandleResourceMove(IResource fromRc, IResource toRc){
if(fMoveMap.put(fromRc, toRc) == null){ if(fMoveMap.put(fromRc, toRc) == null){
return fHandler.handleResourceMove(fromRc, toRc); return fHandler.handleResourceMove(fromRc, toRc);
} }
return true; return true;
} }
@Override
public boolean visit(IResourceDelta delta) throws CoreException { public boolean visit(IResourceDelta delta) throws CoreException {
IResource dResource = delta.getResource(); IResource dResource = delta.getResource();
if(dResource.getType() == IResource.PROJECT && !shouldVisit((IProject)dResource)) if(dResource.getType() == IResource.PROJECT && !shouldVisit((IProject)dResource))
return false; return false;
boolean resume = true; boolean resume = true;
boolean removed = false; boolean removed = false;
switch (delta.getKind()) { switch (delta.getKind()) {
case IResourceDelta.REMOVED: case IResourceDelta.REMOVED:
removed = true; removed = true;
@ -126,29 +127,30 @@ public abstract class ResourceChangeHandlerBase implements IResourceChangeListen
break; break;
} }
return resume; // visit the children return resume; // visit the children
} }
} }
/* /*
* I R e s o u r c e C h a n g e L i s t e n e r * I R e s o u r c e C h a n g e L i s t e n e r
*/ */
/* (non-Javadoc) /* (non-Javadoc)
* *
* Handle the renaming and deletion of project resources * Handle the renaming and deletion of project resources
* This is necessary in order to update ResourceConfigurations and AdditionalInputs * This is necessary in order to update ResourceConfigurations and AdditionalInputs
* *
* @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
*/ */
@Override
public void resourceChanged(IResourceChangeEvent event) { public void resourceChanged(IResourceChangeEvent event) {
if (event.getSource() instanceof IWorkspace) { if (event.getSource() instanceof IWorkspace) {
IResourceMoveHandler handler = createResourceMoveHandler(event); IResourceMoveHandler handler = createResourceMoveHandler(event);
doHandleResourceMove(event, handler); doHandleResourceMove(event, handler);
} }
} }
protected boolean shouldVisit(IProject project){ protected boolean shouldVisit(IProject project){
try { try {
return project.isOpen() ? project.hasNature(CProjectNature.C_NATURE_ID) : true; return project.isOpen() ? project.hasNature(CProjectNature.C_NATURE_ID) : true;
@ -165,7 +167,7 @@ public abstract class ResourceChangeHandlerBase implements IResourceChangeListen
protected void doHahdleResourceMove(IResourceChangeEvent event, IResourceMoveHandler handler) { protected void doHahdleResourceMove(IResourceChangeEvent event, IResourceMoveHandler handler) {
doHandleResourceMove(event, handler); doHandleResourceMove(event, handler);
} }
/** /**
* @since 5.1 * @since 5.1
*/ */
@ -194,9 +196,9 @@ public abstract class ResourceChangeHandlerBase implements IResourceChangeListen
default : default :
break; break;
} }
handler.done(); handler.done();
} }
protected abstract IResourceMoveHandler createResourceMoveHandler(IResourceChangeEvent event); protected abstract IResourceMoveHandler createResourceMoveHandler(IResourceChangeEvent event);
} }

View file

@ -58,14 +58,14 @@ public class XmlStorageElement implements ICStorageElement {
fElement = element; fElement = element;
fParent = parent; fParent = parent;
fParentRefAlowed = alowReferencingParent; fParentRefAlowed = alowReferencingParent;
if(attributeFilters != null && attributeFilters.length != 0) if(attributeFilters != null && attributeFilters.length != 0)
fAttributeFilters = attributeFilters.clone(); fAttributeFilters = attributeFilters.clone();
if(childFilters != null && childFilters.length != 0) if(childFilters != null && childFilters.length != 0)
fChildFilters = childFilters.clone(); fChildFilters = childFilters.clone();
} }
// public String[] getAttributeFilters(){ // public String[] getAttributeFilters(){
// if(fAttributeFilters != null) // if(fAttributeFilters != null)
// return (String[])fAttributeFilters.clone(); // return (String[])fAttributeFilters.clone();
@ -77,7 +77,7 @@ public class XmlStorageElement implements ICStorageElement {
// return (String[])fChildFilters.clone(); // return (String[])fChildFilters.clone();
// return null; // return null;
// } // }
// //
// public boolean isParentRefAlowed(){ // public boolean isParentRefAlowed(){
// return fParentRefAlowed; // return fParentRefAlowed;
// } // }
@ -85,7 +85,7 @@ public class XmlStorageElement implements ICStorageElement {
private void createChildren(){ private void createChildren(){
if(fChildrenCreated) if(fChildrenCreated)
return; return;
fChildrenCreated = true; fChildrenCreated = true;
NodeList list = fElement.getChildNodes(); NodeList list = fElement.getChildNodes();
int size = list.getLength(); int size = list.getLength();
@ -97,16 +97,16 @@ public class XmlStorageElement implements ICStorageElement {
} }
} }
} }
private XmlStorageElement createAddChild(Element element, private XmlStorageElement createAddChild(Element element,
boolean alowReferencingParent, boolean alowReferencingParent,
String[] attributeFilters, String[] attributeFilters,
String[] childFilters){ String[] childFilters){
XmlStorageElement child = createChild(element, alowReferencingParent, attributeFilters, childFilters); XmlStorageElement child = createChild(element, alowReferencingParent, attributeFilters, childFilters);
fChildList.add(child); fChildList.add(child);
return child; return child;
} }
protected XmlStorageElement createChild(Element element, protected XmlStorageElement createChild(Element element,
boolean alowReferencingParent, boolean alowReferencingParent,
String[] attributeFilters, String[] attributeFilters,
@ -114,6 +114,7 @@ public class XmlStorageElement implements ICStorageElement {
return new XmlStorageElement(element, this, alowReferencingParent, attributeFilters, childFilters); return new XmlStorageElement(element, this, alowReferencingParent, attributeFilters, childFilters);
} }
@Override
public ICStorageElement[] getChildren() { public ICStorageElement[] getChildren() {
return getChildren(XmlStorageElement.class); return getChildren(XmlStorageElement.class);
} }
@ -136,16 +137,18 @@ public class XmlStorageElement implements ICStorageElement {
return fChildList.toArray(children); return fChildList.toArray(children);
} }
@Override
public ICStorageElement getParent() { public ICStorageElement getParent() {
return fParentRefAlowed ? fParent : null; return fParentRefAlowed ? fParent : null;
} }
@Override
public String getAttribute(String name) { public String getAttribute(String name) {
if(isPropertyAlowed(name) && fElement.hasAttribute(name)) if(isPropertyAlowed(name) && fElement.hasAttribute(name))
return fElement.getAttribute(name); return fElement.getAttribute(name);
return null; return null;
} }
private boolean isPropertyAlowed(String name){ private boolean isPropertyAlowed(String name){
if(fAttributeFilters != null){ if(fAttributeFilters != null){
return checkString(name, fAttributeFilters); return checkString(name, fAttributeFilters);
@ -173,15 +176,16 @@ public class XmlStorageElement implements ICStorageElement {
// protected void childRemoved(ICStorageElement child) { // protected void childRemoved(ICStorageElement child) {
// fChildList.remove(child); // fChildList.remove(child);
// } // }
protected void removed(){ protected void removed(){
// fElement.getParentNode().removeChild(fElement); // fElement.getParentNode().removeChild(fElement);
fElement = null; fElement = null;
// if(fParent != null) // if(fParent != null)
// ((XmlStorageElement)fParent).childRemoved(this); // ((XmlStorageElement)fParent).childRemoved(this);
} }
@Override
public void removeChild(ICStorageElement el) { public void removeChild(ICStorageElement el) {
if(el instanceof XmlStorageElement){ if(el instanceof XmlStorageElement){
ICStorageElement[] children = getChildren(); ICStorageElement[] children = getChildren();
@ -202,19 +206,22 @@ public class XmlStorageElement implements ICStorageElement {
} }
} }
} }
} }
@Override
public void removeAttribute(String name) { public void removeAttribute(String name) {
if(isPropertyAlowed(name)) if(isPropertyAlowed(name))
fElement.removeAttribute(name); fElement.removeAttribute(name);
} }
@Override
public void setAttribute(String name, String value) { public void setAttribute(String name, String value) {
if(isPropertyAlowed(name)) if(isPropertyAlowed(name))
fElement.setAttribute(name, value); fElement.setAttribute(name, value);
} }
@Override
public void clear(){ public void clear(){
createChildren(); createChildren();
@ -222,14 +229,14 @@ public class XmlStorageElement implements ICStorageElement {
for(int i = 0; i < children.length; i++){ for(int i = 0; i < children.length; i++){
removeChild(children[i]); removeChild(children[i]);
} }
NamedNodeMap map = fElement.getAttributes(); NamedNodeMap map = fElement.getAttributes();
for(int i = 0; i < map.getLength(); i++){ for(int i = 0; i < map.getLength(); i++){
Node attr = map.item(i); Node attr = map.item(i);
if(isPropertyAlowed(attr.getNodeName())) if(isPropertyAlowed(attr.getNodeName()))
map.removeNamedItem(attr.getNodeName()); map.removeNamedItem(attr.getNodeName());
} }
NodeList list = fElement.getChildNodes(); NodeList list = fElement.getChildNodes();
for(int i = 0; i < list.getLength(); i++){ for(int i = 0; i < list.getLength(); i++){
Node node = list.item(i); Node node = list.item(i);
@ -237,8 +244,8 @@ public class XmlStorageElement implements ICStorageElement {
fElement.removeChild(node); fElement.removeChild(node);
} }
} }
public ICStorageElement createChild(String name, public ICStorageElement createChild(String name,
boolean alowReferencingParent, boolean alowReferencingParent,
String[] attributeFilters, String[] attributeFilters,
String[] childFilters) { String[] childFilters) {
@ -249,14 +256,17 @@ public class XmlStorageElement implements ICStorageElement {
return createAddChild(childElement, alowReferencingParent, attributeFilters, childFilters); return createAddChild(childElement, alowReferencingParent, attributeFilters, childFilters);
} }
@Override
public String getName() { public String getName() {
return fElement.getNodeName(); return fElement.getNodeName();
} }
@Override
public ICStorageElement createChild(String name) { public ICStorageElement createChild(String name) {
return createChild(name, true, null, null); return createChild(name, true, null, null);
} }
@Override
public String getValue() { public String getValue() {
Text text = getTextChild(); Text text = getTextChild();
if(text != null) if(text != null)
@ -264,6 +274,7 @@ public class XmlStorageElement implements ICStorageElement {
return null; return null;
} }
@Override
public void setValue(String value) { public void setValue(String value) {
Text text = getTextChild(); Text text = getTextChild();
if(value != null){ if(value != null){
@ -279,7 +290,7 @@ public class XmlStorageElement implements ICStorageElement {
} }
} }
} }
private Text getTextChild(){ private Text getTextChild(){
NodeList nodes = fElement.getChildNodes(); NodeList nodes = fElement.getChildNodes();
Text text = null; Text text = null;
@ -293,16 +304,17 @@ public class XmlStorageElement implements ICStorageElement {
return text; return text;
} }
@Override
public ICStorageElement importChild(ICStorageElement el) throws UnsupportedOperationException { public ICStorageElement importChild(ICStorageElement el) throws UnsupportedOperationException {
return addChild(el, true, null, null); return addChild(el, true, null, null);
} }
public ICStorageElement addChild(ICStorageElement el, public ICStorageElement addChild(ICStorageElement el,
boolean alowReferencingParent, boolean alowReferencingParent,
String[] attributeFilters, String[] attributeFilters,
String[] childFilters) throws UnsupportedOperationException { String[] childFilters) throws UnsupportedOperationException {
if(!isChildAlowed(el.getName())) if(!isChildAlowed(el.getName()))
return null; return null;
@ -316,14 +328,14 @@ public class XmlStorageElement implements ICStorageElement {
} else { } else {
xmlEl = (Element)xmlEl.cloneNode(true); xmlEl = (Element)xmlEl.cloneNode(true);
} }
xmlEl = (Element)fElement.appendChild(xmlEl); xmlEl = (Element)fElement.appendChild(xmlEl);
return createAddChild(xmlEl, alowReferencingParent, attributeFilters, childFilters); return createAddChild(xmlEl, alowReferencingParent, attributeFilters, childFilters);
} else { } else {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
} }
public String[] getAttributeFilters(){ public String[] getAttributeFilters(){
if(fAttributeFilters != null) if(fAttributeFilters != null)
return fAttributeFilters.clone(); return fAttributeFilters.clone();
@ -339,20 +351,20 @@ public class XmlStorageElement implements ICStorageElement {
public boolean isParentRefAlowed(){ public boolean isParentRefAlowed(){
return fParentRefAlowed; return fParentRefAlowed;
} }
public boolean matches(ICStorageElement el){ public boolean matches(ICStorageElement el){
if(!getName().equals(el.getName())) if(!getName().equals(el.getName()))
return false; return false;
if (!valuesMatch(getValue(), el.getValue())) if (!valuesMatch(getValue(), el.getValue()))
return false; return false;
String[] attrs = getAttributeNames(); String[] attrs = getAttributeNames();
String[] otherAttrs = el.getAttributeNames(); String[] otherAttrs = el.getAttributeNames();
if(attrs.length != otherAttrs.length) if(attrs.length != otherAttrs.length)
return false; return false;
if(attrs.length != 0){ if(attrs.length != 0){
Set<String> set = new HashSet<String>(Arrays.asList(attrs)); Set<String> set = new HashSet<String>(Arrays.asList(attrs));
set.removeAll(Arrays.asList(otherAttrs)); set.removeAll(Arrays.asList(otherAttrs));
@ -365,21 +377,21 @@ public class XmlStorageElement implements ICStorageElement {
} }
} }
XmlStorageElement[] children = (XmlStorageElement[])getChildren(); XmlStorageElement[] children = (XmlStorageElement[])getChildren();
ICStorageElement[] otherChildren = el.getChildren(); ICStorageElement[] otherChildren = el.getChildren();
if(children.length != otherChildren.length) if(children.length != otherChildren.length)
return false; return false;
if(children.length != 0){ if(children.length != 0){
for(int i = 0; i < children.length; i++){ for(int i = 0; i < children.length; i++){
if(!children[i].matches(otherChildren[i])) if(!children[i].matches(otherChildren[i]))
return false; return false;
} }
} }
return true; return true;
} }
@ -393,6 +405,7 @@ public class XmlStorageElement implements ICStorageElement {
} }
} }
@Override
public String[] getAttributeNames() { public String[] getAttributeNames() {
NamedNodeMap nodeMap = fElement.getAttributes(); NamedNodeMap nodeMap = fElement.getAttributes();
int length = nodeMap.getLength(); int length = nodeMap.getLength();
@ -409,6 +422,7 @@ public class XmlStorageElement implements ICStorageElement {
/** /**
* @since 5.1 * @since 5.1
*/ */
@Override
public ICStorageElement createCopy() throws UnsupportedOperationException, CoreException { public ICStorageElement createCopy() throws UnsupportedOperationException, CoreException {
// todo Auto-generated method stub // todo Auto-generated method stub
return null; return null;
@ -417,6 +431,7 @@ public class XmlStorageElement implements ICStorageElement {
/** /**
* @since 5.1 * @since 5.1
*/ */
@Override
public boolean equals(ICStorageElement other) { public boolean equals(ICStorageElement other) {
// todo Auto-generated method stub // todo Auto-generated method stub
return false; return false;
@ -425,6 +440,7 @@ public class XmlStorageElement implements ICStorageElement {
/** /**
* @since 5.1 * @since 5.1
*/ */
@Override
public ICStorageElement[] getChildrenByName(String name) { public ICStorageElement[] getChildrenByName(String name) {
// todo Auto-generated method stub // todo Auto-generated method stub
return null; return null;
@ -433,6 +449,7 @@ public class XmlStorageElement implements ICStorageElement {
/** /**
* @since 5.1 * @since 5.1
*/ */
@Override
public boolean hasAttribute(String name) { public boolean hasAttribute(String name) {
// todo Auto-generated method stub // todo Auto-generated method stub
return false; return false;
@ -441,6 +458,7 @@ public class XmlStorageElement implements ICStorageElement {
/** /**
* @since 5.1 * @since 5.1
*/ */
@Override
public boolean hasChildren() { public boolean hasChildren() {
// todo Auto-generated method stub // todo Auto-generated method stub
return false; return false;

View file

@ -3,8 +3,8 @@
* This program and the accompanying materials are made available under the * This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution, * terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html * and is available at http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Anton Leherbauer (Wind River Systems) - initial API and implementation * Anton Leherbauer (Wind River Systems) - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
@ -29,7 +29,7 @@ import org.eclipse.core.runtime.Status;
/** /**
* Provides a shared AST of a single translation unit at a time. * Provides a shared AST of a single translation unit at a time.
* *
* @since 4.0 * @since 4.0
*/ */
public class ASTCache { public class ASTCache {
@ -43,7 +43,7 @@ public class ASTCache {
public static int PARSE_MODE_FULL = ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT public static int PARSE_MODE_FULL = ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT
| ITranslationUnit.AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS | ITranslationUnit.AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS
| ITranslationUnit.AST_PARSE_INACTIVE_CODE; | ITranslationUnit.AST_PARSE_INACTIVE_CODE;
/** Fast parse mode (use PDOM) */ /** Fast parse mode (use PDOM) */
public static int PARSE_MODE_FAST = ITranslationUnit.AST_SKIP_ALL_HEADERS public static int PARSE_MODE_FAST = ITranslationUnit.AST_SKIP_ALL_HEADERS
| ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT
@ -52,28 +52,28 @@ public class ASTCache {
/** /**
* Do something with an AST. * Do something with an AST.
* *
* @see #runOnAST(ILanguage, IASTTranslationUnit) * @see #runOnAST(ILanguage, IASTTranslationUnit)
*/ */
public static interface ASTRunnable { public static interface ASTRunnable {
/** /**
* Do something with the given AST. * Do something with the given AST.
* *
* @param lang the language with which the AST has been created. * @param lang the language with which the AST has been created.
* @param ast the translation unit AST, may be <code>null</code> * @param ast the translation unit AST, may be <code>null</code>
* @return a status object * @return a status object
*/ */
IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException; IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException;
} }
private final int fParseMode; private final int fParseMode;
private final Object fCacheMutex= new Object(); private final Object fCacheMutex= new Object();
/** The active translation unit for which to cache the AST */ /** The active translation unit for which to cache the AST */
private ITranslationUnit fActiveTU; private ITranslationUnit fActiveTU;
/** The cached AST if any */ /** The cached AST if any */
private IASTTranslationUnit fAST; private IASTTranslationUnit fAST;
/** /**
* The timestamp of the last index write access at the time * The timestamp of the last index write access at the time
* the AST got cached. A cached AST becomes invalid on any index * the AST got cached. A cached AST becomes invalid on any index
* write access afterwards. * write access afterwards.
@ -107,11 +107,11 @@ public class ASTCache {
IProgressMonitor progressMonitor) { IProgressMonitor progressMonitor) {
if (tUnit == null) if (tUnit == null)
return null; return null;
while (true) { while (true) {
if (progressMonitor != null && progressMonitor.isCanceled()) if (progressMonitor != null && progressMonitor.isCanceled())
return null; return null;
final boolean isActiveElement; final boolean isActiveElement;
synchronized (fCacheMutex) { synchronized (fCacheMutex) {
isActiveElement= tUnit.equals(fActiveTU); isActiveElement= tUnit.equals(fActiveTU);
@ -132,7 +132,7 @@ public class ASTCache {
if (!wait) { if (!wait) {
// no AST, no wait - we are done // no AST, no wait - we are done
if (DEBUG) if (DEBUG)
System.out.println(DEBUG_PREFIX + getThreadName() + "returning null (WAIT_NO) for: " + tUnit.getElementName()); //$NON-NLS-1$ System.out.println(DEBUG_PREFIX + getThreadName() + "returning null (WAIT_NO) for: " + tUnit.getElementName()); //$NON-NLS-1$
return null; return null;
} }
} }
@ -141,12 +141,12 @@ public class ASTCache {
try { try {
// Wait for AST // Wait for AST
if (DEBUG) if (DEBUG)
System.out.println(DEBUG_PREFIX + getThreadName() + "waiting for AST for: " + tUnit.getElementName()); //$NON-NLS-1$ System.out.println(DEBUG_PREFIX + getThreadName() + "waiting for AST for: " + tUnit.getElementName()); //$NON-NLS-1$
fCacheMutex.wait(); fCacheMutex.wait();
// Check whether active element is still valid // Check whether active element is still valid
if (fAST != null) { if (fAST != null) {
if (DEBUG) if (DEBUG)
System.out.println(DEBUG_PREFIX + getThreadName() + "...got AST for: " + tUnit.getElementName()); //$NON-NLS-1$ System.out.println(DEBUG_PREFIX + getThreadName() + "...got AST for: " + tUnit.getElementName()); //$NON-NLS-1$
return fAST; return fAST;
} }
// try again // try again
@ -158,20 +158,20 @@ public class ASTCache {
return null; return null;
} }
} }
if (isActiveElement) if (isActiveElement)
aboutToBeReconciled(tUnit); aboutToBeReconciled(tUnit);
if (DEBUG) if (DEBUG)
System.err.println(DEBUG_PREFIX + getThreadName() + "creating AST for " + tUnit.getElementName()); //$NON-NLS-1$ System.err.println(DEBUG_PREFIX + getThreadName() + "creating AST for " + tUnit.getElementName()); //$NON-NLS-1$
IASTTranslationUnit ast= null; IASTTranslationUnit ast= null;
try { try {
ast= createAST(tUnit, index, progressMonitor); ast= createAST(tUnit, index, progressMonitor);
if (progressMonitor != null && progressMonitor.isCanceled()) if (progressMonitor != null && progressMonitor.isCanceled())
ast= null; ast= null;
else if (DEBUG && ast != null) else if (DEBUG && ast != null)
System.err.println(DEBUG_PREFIX + getThreadName() + "created AST for: " + tUnit.getElementName()); //$NON-NLS-1$ System.err.println(DEBUG_PREFIX + getThreadName() + "created AST for: " + tUnit.getElementName()); //$NON-NLS-1$
} finally { } finally {
if (isActiveElement) { if (isActiveElement) {
if (fAST != null) { if (fAST != null) {
@ -191,7 +191,7 @@ public class ASTCache {
* Executes {@link ASTRunnable#runOnAST(ILanguage, IASTTranslationUnit)} with the AST * Executes {@link ASTRunnable#runOnAST(ILanguage, IASTTranslationUnit)} with the AST
* provided by this cache for the given translation unit. Handles acquiring * provided by this cache for the given translation unit. Handles acquiring
* and releasing the index read-lock for the client. * and releasing the index read-lock for the client.
* *
* @param tUnit * @param tUnit
* the translation unit * the translation unit
* @param wait * @param wait
@ -212,7 +212,7 @@ public class ASTCache {
} catch (InterruptedException e) { } catch (InterruptedException e) {
return Status.CANCEL_STATUS; return Status.CANCEL_STATUS;
} }
try { try {
IASTTranslationUnit ast= acquireSharedAST(tUnit, index, wait, monitor); IASTTranslationUnit ast= acquireSharedAST(tUnit, index, wait, monitor);
ILanguage lang= (tUnit instanceof TranslationUnit) ? ((TranslationUnit) tUnit).getLanguageOfContext() : tUnit.getLanguage(); ILanguage lang= (tUnit instanceof TranslationUnit) ? ((TranslationUnit) tUnit).getLanguageOfContext() : tUnit.getLanguage();
@ -286,12 +286,12 @@ public class ASTCache {
assert Thread.holdsLock(fCacheMutex); assert Thread.holdsLock(fCacheMutex);
if (fActiveTU != null && !fActiveTU.equals(tUnit)) { if (fActiveTU != null && !fActiveTU.equals(tUnit)) {
if (DEBUG && tUnit != null) // don't report call from disposeAST() if (DEBUG && tUnit != null) // don't report call from disposeAST()
System.out.println(DEBUG_PREFIX + getThreadName() + "don't cache AST for inactive: " + toString(tUnit)); //$NON-NLS-1$ System.out.println(DEBUG_PREFIX + getThreadName() + "don't cache AST for inactive: " + toString(tUnit)); //$NON-NLS-1$
return; return;
} }
if (DEBUG && (tUnit != null || ast != null)) // don't report call from disposeAST() if (DEBUG && (tUnit != null || ast != null)) // don't report call from disposeAST()
System.out.println(DEBUG_PREFIX + getThreadName() + "caching AST: " + toString(ast) + " for: " + toString(tUnit)); //$NON-NLS-1$ //$NON-NLS-2$ System.out.println(DEBUG_PREFIX + getThreadName() + "caching AST: " + toString(ast) + " for: " + toString(tUnit)); //$NON-NLS-1$ //$NON-NLS-2$
if (fAST != null) if (fAST != null)
disposeAST(); disposeAST();
@ -310,10 +310,10 @@ public class ASTCache {
synchronized (fCacheMutex) { synchronized (fCacheMutex) {
if (fAST == null) if (fAST == null)
return; return;
if (DEBUG) if (DEBUG)
System.out.println(DEBUG_PREFIX + getThreadName() + "disposing AST: " + toString(fAST) + " for: " + toString(fActiveTU)); //$NON-NLS-1$ //$NON-NLS-2$ System.out.println(DEBUG_PREFIX + getThreadName() + "disposing AST: " + toString(fAST) + " for: " + toString(fActiveTU)); //$NON-NLS-1$ //$NON-NLS-2$
fAST= null; fAST= null;
cache(null, null); cache(null, null);
} }
@ -321,7 +321,7 @@ public class ASTCache {
/** /**
* Creates a new translation unit AST. * Creates a new translation unit AST.
* *
* @param tUnit the translation unit for which to create the AST * @param tUnit the translation unit for which to create the AST
* @param index the index for AST generation, needs to be read-locked. * @param index the index for AST generation, needs to be read-locked.
* @param progressMonitor a progress monitor, may be <code>null</code> * @param progressMonitor a progress monitor, may be <code>null</code>
@ -331,9 +331,10 @@ public class ASTCache {
if (progressMonitor != null && progressMonitor.isCanceled()) if (progressMonitor != null && progressMonitor.isCanceled())
return null; return null;
final IASTTranslationUnit root[]= new IASTTranslationUnit[1]; final IASTTranslationUnit root[]= new IASTTranslationUnit[1];
SafeRunner.run(new ISafeRunnable() { SafeRunner.run(new ISafeRunnable() {
@Override
public void run() throws CoreException { public void run() throws CoreException {
try { try {
if (progressMonitor != null && progressMonitor.isCanceled()) { if (progressMonitor != null && progressMonitor.isCanceled()) {
@ -345,18 +346,19 @@ public class ASTCache {
root[0]= null; root[0]= null;
} }
} }
@Override
public void handleException(Throwable ex) { public void handleException(Throwable ex) {
IStatus status= new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.OK, "Error in CDT Core during AST creation", ex); //$NON-NLS-1$ IStatus status= new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.OK, "Error in CDT Core during AST creation", ex); //$NON-NLS-1$
CCorePlugin.getDefault().getLog().log(status); CCorePlugin.getDefault().getLog().log(status);
} }
}); });
return root[0]; return root[0];
} }
/** /**
* Set the given translation unit as active element to cache an AST for. * Set the given translation unit as active element to cache an AST for.
* *
* @param tUnit the translation unit * @param tUnit the translation unit
*/ */
public void setActiveElement(ITranslationUnit tUnit) { public void setActiveElement(ITranslationUnit tUnit) {
@ -369,12 +371,12 @@ public class ASTCache {
cache(null, tUnit); cache(null, tUnit);
} }
if (DEBUG) if (DEBUG)
System.out.println(DEBUG_PREFIX + getThreadName() + "active element is: " + toString(tUnit)); //$NON-NLS-1$ System.out.println(DEBUG_PREFIX + getThreadName() + "active element is: " + toString(tUnit)); //$NON-NLS-1$
} }
/** /**
* Check whether the given translation unit is the active element of this cache. * Check whether the given translation unit is the active element of this cache.
* *
* @param tUnit the translation unit * @param tUnit the translation unit
* @return <code>true</code>, if this cache manages the given translation unit * @return <code>true</code>, if this cache manages the given translation unit
*/ */
@ -385,7 +387,7 @@ public class ASTCache {
} }
/** /**
* Informs that reconciling (computation of the AST) for the given element * Informs that reconciling (computation of the AST) for the given element
* is about to be started. * is about to be started.
* *
* @param tUnit the translation unit * @param tUnit the translation unit
@ -393,15 +395,15 @@ public class ASTCache {
public void aboutToBeReconciled(ITranslationUnit tUnit) { public void aboutToBeReconciled(ITranslationUnit tUnit) {
if (tUnit == null) if (tUnit == null)
return; return;
synchronized (fCacheMutex) { synchronized (fCacheMutex) {
if (fActiveTU == null || !fActiveTU.equals(tUnit)) { if (fActiveTU == null || !fActiveTU.equals(tUnit)) {
return; return;
} }
if (DEBUG) if (DEBUG)
System.out.println(DEBUG_PREFIX + getThreadName() + "about to reconcile: " + toString(tUnit)); //$NON-NLS-1$ System.out.println(DEBUG_PREFIX + getThreadName() + "about to reconcile: " + toString(tUnit)); //$NON-NLS-1$
fIsReconciling= true; fIsReconciling= true;
cache(null, tUnit); cache(null, tUnit);
} }
@ -409,7 +411,7 @@ public class ASTCache {
/** /**
* Informs that reconciling of the AST of the given translation unit has finished. * Informs that reconciling of the AST of the given translation unit has finished.
* *
* @param ast the translation unit AST * @param ast the translation unit AST
* @param tUnit the translation unit * @param tUnit the translation unit
*/ */

View file

@ -11,7 +11,7 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive; import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
@ -42,6 +42,7 @@ public class Archive extends Openable implements IArchive {
binaryArchive = ar; binaryArchive = ar;
} }
@Override
public IBinary[] getBinaries() throws CModelException { public IBinary[] getBinaries() throws CModelException {
ICElement[] e = getChildren(); ICElement[] e = getChildren();
IBinary[] b = new IBinary[e.length]; IBinary[] b = new IBinary[e.length];

View file

@ -11,7 +11,7 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
@ -30,6 +30,7 @@ public class ArchiveContainer extends Openable implements IArchiveContainer {
super (cProject, null, CCorePlugin.getResourceString("CoreModel.ArchiveContainer.Archives"), ICElement.C_VCONTAINER); //$NON-NLS-1$ super (cProject, null, CCorePlugin.getResourceString("CoreModel.ArchiveContainer.Archives"), ICElement.C_VCONTAINER); //$NON-NLS-1$
} }
@Override
public IArchive[] getArchives() throws CModelException { public IArchive[] getArchives() throws CModelException {
((ArchiveContainerInfo)getElementInfo()).sync(); ((ArchiveContainerInfo)getElementInfo()).sync();
ICElement[] e = getChildren(); ICElement[] e = getChildren();

View file

@ -26,7 +26,7 @@ public class AsmLabel extends SourceManipulation implements IAsmLabel, IParent {
/** /**
* Create a new assembly label. * Create a new assembly label.
* *
* @param parent the parent element (must be ITranslationUnit) * @param parent the parent element (must be ITranslationUnit)
* @param name the name of the label * @param name the name of the label
* @param global if <code>true</code>, the label is declared global (visible to the linker) * @param global if <code>true</code>, the label is declared global (visible to the linker)
@ -41,6 +41,7 @@ public class AsmLabel extends SourceManipulation implements IAsmLabel, IParent {
/* /*
* @see org.eclipse.cdt.core.model.IAsmLabel#isGlobal() * @see org.eclipse.cdt.core.model.IAsmLabel#isGlobal()
*/ */
@Override
public final boolean isGlobal() { public final boolean isGlobal() {
return fIsGlobal; return fIsGlobal;
} }
@ -55,7 +56,7 @@ public class AsmLabel extends SourceManipulation implements IAsmLabel, IParent {
} }
return false; return false;
} }
public static boolean equals(AsmLabel lhs, AsmLabel rhs) { public static boolean equals(AsmLabel lhs, AsmLabel rhs) {
if (CElement.equals(lhs, rhs)) { if (CElement.equals(lhs, rhs)) {
return lhs.fIndex == rhs.fIndex && lhs.fIsGlobal == rhs.fIsGlobal; return lhs.fIndex == rhs.fIndex && lhs.fIsGlobal == rhs.fIsGlobal;

View file

@ -22,14 +22,14 @@ import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.OffsetLimitReachedException; import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
import org.eclipse.cdt.internal.core.parser.scanner.ILexerLog; import org.eclipse.cdt.internal.core.parser.scanner.ILexerLog;
import org.eclipse.cdt.internal.core.parser.scanner.Lexer; import org.eclipse.cdt.internal.core.parser.scanner.Lexer;
import org.eclipse.cdt.internal.core.parser.scanner.Token;
import org.eclipse.cdt.internal.core.parser.scanner.Lexer.LexerOptions; import org.eclipse.cdt.internal.core.parser.scanner.Lexer.LexerOptions;
import org.eclipse.cdt.internal.core.parser.scanner.Token;
/** /**
* A simple model builder for assembly translation units. * A simple model builder for assembly translation units.
* Recognizes preprocessor directives (#include and #define) * Recognizes preprocessor directives (#include and #define)
* and labels. * and labels.
* *
* @see AssemblyLanguage * @see AssemblyLanguage
* @since 5.0 * @since 5.0
*/ */
@ -41,8 +41,10 @@ public class AsmModelBuilder implements IContributedModelBuilder {
} }
private static final class LexerLog implements ILexerLog { private static final class LexerLog implements ILexerLog {
@Override
public void handleComment(boolean isBlockComment, int offset, int endOffset) { public void handleComment(boolean isBlockComment, int offset, int endOffset) {
} }
@Override
public void handleProblem(int problemID, char[] info, int offset, int endOffset) { public void handleProblem(int problemID, char[] info, int offset, int endOffset) {
} }
} }
@ -52,7 +54,7 @@ public class AsmModelBuilder implements IContributedModelBuilder {
} }
private static final Map<String, AsmDirective> fgDirectives; private static final Map<String, AsmDirective> fgDirectives;
static { static {
fgDirectives= new HashMap<String, AsmDirective>(); fgDirectives= new HashMap<String, AsmDirective>();
fgDirectives.put("globl", AsmDirective.GLOBAL); //$NON-NLS-1$ fgDirectives.put("globl", AsmDirective.GLOBAL); //$NON-NLS-1$
@ -63,12 +65,12 @@ public class AsmModelBuilder implements IContributedModelBuilder {
fgDirectives.put("long", AsmDirective.DATA); //$NON-NLS-1$ fgDirectives.put("long", AsmDirective.DATA); //$NON-NLS-1$
fgDirectives.put("word", AsmDirective.DATA); //$NON-NLS-1$ fgDirectives.put("word", AsmDirective.DATA); //$NON-NLS-1$
} }
private TranslationUnit fTranslationUnit; private TranslationUnit fTranslationUnit;
private char fLineSeparatorChar; private char fLineSeparatorChar;
private Map<String, Counter> fGlobals; private Map<String, Counter> fGlobals;
private Map<String, Counter> fLabels; private Map<String, Counter> fLabels;
private int fLastLabelEndOffset; private int fLastLabelEndOffset;
private AsmLabel fLastGlobalLabel; private AsmLabel fLastGlobalLabel;
private SourceManipulation fLastLabel; private SourceManipulation fLastLabel;
@ -76,7 +78,7 @@ public class AsmModelBuilder implements IContributedModelBuilder {
/** /**
* Creates a model builder for the given assembly translation unit. * Creates a model builder for the given assembly translation unit.
* *
* @param tu the translation unit * @param tu the translation unit
*/ */
public AsmModelBuilder(ITranslationUnit tu) { public AsmModelBuilder(ITranslationUnit tu) {
@ -85,7 +87,7 @@ public class AsmModelBuilder implements IContributedModelBuilder {
/** /**
* Configure the line separator character (in addition to normal newlines). * Configure the line separator character (in addition to normal newlines).
* *
* @param lineSeparatorChar * @param lineSeparatorChar
*/ */
public void setLineSeparatorCharacter(char lineSeparatorChar) { public void setLineSeparatorCharacter(char lineSeparatorChar) {
@ -95,6 +97,7 @@ public class AsmModelBuilder implements IContributedModelBuilder {
/* /*
* @see org.eclipse.cdt.core.model.IContributedModelBuilder#parse(boolean) * @see org.eclipse.cdt.core.model.IContributedModelBuilder#parse(boolean)
*/ */
@Override
public void parse(boolean quickParseMode) throws Exception { public void parse(boolean quickParseMode) throws Exception {
char[] source = fTranslationUnit.getContents(); char[] source = fTranslationUnit.getContents();
if (source == null) { if (source == null) {
@ -111,7 +114,7 @@ public class AsmModelBuilder implements IContributedModelBuilder {
/** /**
* Build the model. * Build the model.
* *
* @param source * @param source
* @throws CModelException * @throws CModelException
*/ */
@ -124,7 +127,7 @@ public class AsmModelBuilder implements IContributedModelBuilder {
final LexerOptions lexerOptions= new LexerOptions(); final LexerOptions lexerOptions= new LexerOptions();
fLexer= new Lexer(source, lexerOptions, new LexerLog(), null); fLexer= new Lexer(source, lexerOptions, new LexerLog(), null);
// if true the next token is the first on a (logical) line // if true the next token is the first on a (logical) line
boolean firstTokenOnLine= true; boolean firstTokenOnLine= true;
// next token can be an instruction or a label // next token can be an instruction or a label
@ -207,7 +210,7 @@ public class AsmModelBuilder implements IContributedModelBuilder {
fixupLastGlobalLabel(); fixupLastGlobalLabel();
} }
} }
/** /**
* @return the next token from the scanner or <code>null</code> on end-of-input. * @return the next token from the scanner or <code>null</code> on end-of-input.
*/ */
@ -313,8 +316,8 @@ public class AsmModelBuilder implements IContributedModelBuilder {
/** /**
* Set the body position of the last global label. * Set the body position of the last global label.
* *
* @throws CModelException * @throws CModelException
*/ */
private void fixupLastGlobalLabel() throws CModelException { private void fixupLastGlobalLabel() throws CModelException {
if (fLastLabel != null && fLastLabel != fLastGlobalLabel) { if (fLastLabel != null && fLastLabel != fLastGlobalLabel) {
@ -327,8 +330,8 @@ public class AsmModelBuilder implements IContributedModelBuilder {
/** /**
* Set the body position of the last label. * Set the body position of the last label.
* *
* @throws CModelException * @throws CModelException
*/ */
private void fixupLastLabel() throws CModelException { private void fixupLastLabel() throws CModelException {
if (fLastLabelEndOffset > 0) { if (fLastLabelEndOffset > 0) {

View file

@ -12,7 +12,7 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -22,13 +22,13 @@ import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CCorePreferenceConstants; import org.eclipse.cdt.core.CCorePreferenceConstants;
import org.eclipse.cdt.core.ISourceFinder;
import org.eclipse.cdt.core.ISymbolReader;
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable; import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile; import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
import org.eclipse.cdt.core.IBinaryParser.IBinaryShared; import org.eclipse.cdt.core.IBinaryParser.IBinaryShared;
import org.eclipse.cdt.core.IBinaryParser.ISymbol; import org.eclipse.cdt.core.IBinaryParser.ISymbol;
import org.eclipse.cdt.core.ISourceFinder;
import org.eclipse.cdt.core.ISymbolReader;
import org.eclipse.cdt.core.model.BinaryFilePresentation; import org.eclipse.cdt.core.model.BinaryFilePresentation;
import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
@ -58,7 +58,7 @@ public class Binary extends Openable implements IBinary {
private long longBSS; private long longBSS;
private String endian; private String endian;
private String soname; private String soname;
private long fLastModification; private long fLastModification;
private IBinaryObject binaryObject; private IBinaryObject binaryObject;
@ -84,22 +84,27 @@ public class Binary extends Openable implements IBinary {
showInBinaryContainer= determineShowInBinaryContainer(bin); showInBinaryContainer= determineShowInBinaryContainer(bin);
} }
@Override
public boolean isSharedLib() { public boolean isSharedLib() {
return getType() == IBinaryFile.SHARED; return getType() == IBinaryFile.SHARED;
} }
@Override
public boolean isExecutable() { public boolean isExecutable() {
return getType() == IBinaryFile.EXECUTABLE; return getType() == IBinaryFile.EXECUTABLE;
} }
@Override
public boolean isObject() { public boolean isObject() {
return getType() == IBinaryFile.OBJECT; return getType() == IBinaryFile.OBJECT;
} }
@Override
public boolean isCore() { public boolean isCore() {
return getType() == IBinaryFile.CORE; return getType() == IBinaryFile.CORE;
} }
@Override
public boolean hasDebug() { public boolean hasDebug() {
if (isObject() || isExecutable() || isSharedLib()) { if (isObject() || isExecutable() || isSharedLib()) {
if (hasDebug == null || hasChanged()) { if (hasDebug == null || hasChanged()) {
@ -112,6 +117,7 @@ public class Binary extends Openable implements IBinary {
return Boolean.valueOf(hasDebug).booleanValue(); return Boolean.valueOf(hasDebug).booleanValue();
} }
@Override
public String getCPU() { public String getCPU() {
if (isObject() || isExecutable() || isSharedLib() || isCore()) { if (isObject() || isExecutable() || isSharedLib() || isCore()) {
if (cpu == null || hasChanged()) { if (cpu == null || hasChanged()) {
@ -122,6 +128,7 @@ public class Binary extends Openable implements IBinary {
return (cpu == null ? "" : cpu); //$NON-NLS-1$ return (cpu == null ? "" : cpu); //$NON-NLS-1$
} }
@Override
public String[] getNeededSharedLibs() { public String[] getNeededSharedLibs() {
if (isExecutable() || isSharedLib()) { if (isExecutable() || isSharedLib()) {
if (needed == null || hasChanged()) { if (needed == null || hasChanged()) {
@ -134,6 +141,7 @@ public class Binary extends Openable implements IBinary {
return (needed == null ? new String[0] : needed); return (needed == null ? new String[0] : needed);
} }
@Override
public long getText() { public long getText() {
if (isObject() || isExecutable() || isSharedLib()) { if (isObject() || isExecutable() || isSharedLib()) {
if (longText == -1 || hasChanged()) { if (longText == -1 || hasChanged()) {
@ -146,6 +154,7 @@ public class Binary extends Openable implements IBinary {
return longText; return longText;
} }
@Override
public long getData() { public long getData() {
if (isObject() || isExecutable() || isSharedLib()) { if (isObject() || isExecutable() || isSharedLib()) {
if (longData == -1 || hasChanged()) { if (longData == -1 || hasChanged()) {
@ -158,6 +167,7 @@ public class Binary extends Openable implements IBinary {
return longData; return longData;
} }
@Override
public long getBSS() { public long getBSS() {
if (isObject() || isExecutable() || isSharedLib()) { if (isObject() || isExecutable() || isSharedLib()) {
if (longBSS == -1 || hasChanged()) { if (longBSS == -1 || hasChanged()) {
@ -170,6 +180,7 @@ public class Binary extends Openable implements IBinary {
return longBSS; return longBSS;
} }
@Override
public String getSoname() { public String getSoname() {
if (isSharedLib()) { if (isSharedLib()) {
if (soname == null || hasChanged()) { if (soname == null || hasChanged()) {
@ -182,6 +193,7 @@ public class Binary extends Openable implements IBinary {
return (soname == null ? "" : soname); //$NON-NLS-1$ return (soname == null ? "" : soname); //$NON-NLS-1$
} }
@Override
public boolean isLittleEndian() { public boolean isLittleEndian() {
if (isObject() || isExecutable() || isSharedLib() || isCore()) { if (isObject() || isExecutable() || isSharedLib() || isCore()) {
if (endian == null || hasChanged()) { if (endian == null || hasChanged()) {
@ -290,7 +302,7 @@ public class Binary extends Openable implements IBinary {
break; break;
} }
} }
} }
ok = true; ok = true;
} }
} }
@ -311,34 +323,34 @@ public class Binary extends Openable implements IBinary {
ISourceFinder srcFinder = (ISourceFinder) getAdapter(ISourceFinder.class); ISourceFinder srcFinder = (ISourceFinder) getAdapter(ISourceFinder.class);
try { try {
for (String filename : sourceFiles) { for (String filename : sourceFiles) {
// Find the file locally // Find the file locally
if (srcFinder != null) { if (srcFinder != null) {
String localPath = srcFinder.toLocalPath(filename); String localPath = srcFinder.toLocalPath(filename);
if (localPath != null) { if (localPath != null) {
filename = localPath; filename = localPath;
} }
} }
// Be careful how you use this File object. If filename is a relative path, the resulting File // Be careful how you use this File object. If filename is a relative path, the resulting File
// object will apply the relative path to the working directory, which is not what we want. // object will apply the relative path to the working directory, which is not what we want.
// Stay away from methods that return or use the absolute path of the object. Note that // Stay away from methods that return or use the absolute path of the object. Note that
// File.isAbsolute() returns false when the object was constructed with a relative path. // File.isAbsolute() returns false when the object was constructed with a relative path.
File file = new File(filename); File file = new File(filename);
// Create a translation unit for this file and add it as a child of the binary // Create a translation unit for this file and add it as a child of the binary
String id = CoreModel.getRegistedContentTypeId(getCProject().getProject(), file.getName()); String id = CoreModel.getRegistedContentTypeId(getCProject().getProject(), file.getName());
if (id == null) { if (id == null) {
// Don't add files we can't get an ID for. // Don't add files we can't get an ID for.
continue; continue;
} }
// See if this source file is already in the project. // See if this source file is already in the project.
// We check this to determine if we should create a TranslationUnit or ExternalTranslationUnit // We check this to determine if we should create a TranslationUnit or ExternalTranslationUnit
IFile wkspFile = null; IFile wkspFile = null;
if (file.isAbsolute()) { if (file.isAbsolute()) {
IFile[] filesInWP = ResourceLookup.findFilesForLocation(new Path(filename)); IFile[] filesInWP = ResourceLookup.findFilesForLocation(new Path(filename));
for (IFile element : filesInWP) { for (IFile element : filesInWP) {
if (element.isAccessible()) { if (element.isAccessible()) {
wkspFile = element; wkspFile = element;
@ -346,7 +358,7 @@ public class Binary extends Openable implements IBinary {
} }
} }
} }
TranslationUnit tu; TranslationUnit tu;
if (wkspFile != null) if (wkspFile != null)
tu = new TranslationUnit(this, wkspFile, id); tu = new TranslationUnit(this, wkspFile, id);
@ -362,12 +374,12 @@ public class Binary extends Openable implements IBinary {
tu = new ExternalTranslationUnit(this, Path.fromOSString(filename), id); tu = new ExternalTranslationUnit(this, Path.fromOSString(filename), id);
} }
else { else {
tu = new ExternalTranslationUnit(this, URIUtil.toURI(filename, true), id); tu = new ExternalTranslationUnit(this, URIUtil.toURI(filename, true), id);
} }
} }
if (! info.includesChild(tu)) if (! info.includesChild(tu))
info.addChild(tu); info.addChild(tu);
} }
return true; return true;
} }
@ -376,11 +388,11 @@ public class Binary extends Openable implements IBinary {
srcFinder.dispose(); srcFinder.dispose();
} }
} }
} }
return false; return false;
} }
private void addFunction(OpenableInfo info, ISymbol symbol, Map<IPath, BinaryModule> hash) throws CModelException { private void addFunction(OpenableInfo info, ISymbol symbol, Map<IPath, BinaryModule> hash) throws CModelException {
IPath filename= symbol.getFilename(); IPath filename= symbol.getFilename();
BinaryFunction function = null; BinaryFunction function = null;
@ -431,7 +443,7 @@ public class Binary extends Openable implements IBinary {
variable.setLines(symbol.getStartLine(), symbol.getEndLine()); variable.setLines(symbol.getStartLine(), symbol.getEndLine());
info.addChild(variable); info.addChild(variable);
} }
//if (variable != null) { //if (variable != null) {
// if (!external) { // if (!external) {
// variable.getVariableInfo().setAccessControl(IConstants.AccStatic); // variable.getVariableInfo().setAccessControl(IConstants.AccStatic);
@ -441,7 +453,7 @@ public class Binary extends Openable implements IBinary {
/** /**
* @see org.eclipse.cdt.core.model.IOpenable#getBuffer() * @see org.eclipse.cdt.core.model.IOpenable#getBuffer()
* *
* overridden from default as we do not need to create our children to provider a buffer since the buffer just contains * overridden from default as we do not need to create our children to provider a buffer since the buffer just contains
* IBinaryOject contents which is not model specific. * IBinaryOject contents which is not model specific.
*/ */
@ -465,11 +477,11 @@ public class Binary extends Openable implements IBinary {
protected IBuffer openBuffer(IProgressMonitor pm) throws CModelException { protected IBuffer openBuffer(IProgressMonitor pm) throws CModelException {
// create buffer - translation units only use default buffer factory // create buffer - translation units only use default buffer factory
BufferManager bufManager = getBufferManager(); BufferManager bufManager = getBufferManager();
IBuffer buffer = getBufferFactory().createBuffer(this); IBuffer buffer = getBufferFactory().createBuffer(this);
if (buffer == null) if (buffer == null)
return null; return null;
// set the buffer source // set the buffer source
if (buffer.getCharacters() == null){ if (buffer.getCharacters() == null){
IBinaryObject bin = getBinaryObject(); IBinaryObject bin = getBinaryObject();
@ -496,13 +508,13 @@ public class Binary extends Openable implements IBinary {
// add buffer to buffer cache // add buffer to buffer cache
bufManager.addBuffer(buffer); bufManager.addBuffer(buffer);
// listen to buffer changes // listen to buffer changes
buffer.addBufferChangedListener(this); buffer.addBufferChangedListener(this);
return buffer; return buffer;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.model.Openable#hasBuffer() * @see org.eclipse.cdt.internal.core.model.Openable#hasBuffer()
*/ */
@ -534,6 +546,7 @@ public class Binary extends Openable implements IBinary {
super.closing(info); super.closing(info);
} }
@Override
public boolean showInBinaryContainer() { public boolean showInBinaryContainer() {
return showInBinaryContainer; return showInBinaryContainer;
} }

View file

@ -11,7 +11,7 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map; import java.util.Map;
@ -38,6 +38,7 @@ public class BinaryContainer extends Openable implements IBinaryContainer {
} }
} }
@Override
public IBinary[] getBinaries() throws CModelException { public IBinary[] getBinaries() throws CModelException {
sync(); sync();
ICElement[] e = getChildren(); ICElement[] e = getChildren();

View file

@ -50,6 +50,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ISourceManipulation#copy(org.eclipse.cdt.core.model.ICElement, org.eclipse.cdt.core.model.ICElement, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) * @see org.eclipse.cdt.core.model.ISourceManipulation#copy(org.eclipse.cdt.core.model.ICElement, org.eclipse.cdt.core.model.ICElement, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
*/ */
@Override
public void copy(ICElement container, ICElement sibling, String rename, boolean replace, IProgressMonitor monitor) public void copy(ICElement container, ICElement sibling, String rename, boolean replace, IProgressMonitor monitor)
throws CModelException { throws CModelException {
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this)); throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this));
@ -58,6 +59,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ISourceManipulation#delete(boolean, org.eclipse.core.runtime.IProgressMonitor) * @see org.eclipse.cdt.core.model.ISourceManipulation#delete(boolean, org.eclipse.core.runtime.IProgressMonitor)
*/ */
@Override
public void delete(boolean force, IProgressMonitor monitor) throws CModelException { public void delete(boolean force, IProgressMonitor monitor) throws CModelException {
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this)); throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this));
} }
@ -65,6 +67,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ISourceManipulation#move(org.eclipse.cdt.core.model.ICElement, org.eclipse.cdt.core.model.ICElement, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) * @see org.eclipse.cdt.core.model.ISourceManipulation#move(org.eclipse.cdt.core.model.ICElement, org.eclipse.cdt.core.model.ICElement, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
*/ */
@Override
public void move(ICElement container, ICElement sibling, String rename, boolean replace, IProgressMonitor monitor) public void move(ICElement container, ICElement sibling, String rename, boolean replace, IProgressMonitor monitor)
throws CModelException { throws CModelException {
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this)); throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this));
@ -73,6 +76,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ISourceManipulation#rename(java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor) * @see org.eclipse.cdt.core.model.ISourceManipulation#rename(java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
*/ */
@Override
public void rename(String name, boolean replace, IProgressMonitor monitor) throws CModelException { public void rename(String name, boolean replace, IProgressMonitor monitor) throws CModelException {
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this)); throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this));
} }
@ -80,6 +84,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ISourceReference#getSource() * @see org.eclipse.cdt.core.model.ISourceReference#getSource()
*/ */
@Override
public String getSource() throws CModelException { public String getSource() throws CModelException {
ITranslationUnit tu = getTranslationUnit(); ITranslationUnit tu = getTranslationUnit();
if (tu != null) { if (tu != null) {
@ -100,11 +105,12 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ISourceReference#getSourceRange() * @see org.eclipse.cdt.core.model.ISourceReference#getSourceRange()
*/ */
@Override
public ISourceRange getSourceRange() throws CModelException { public ISourceRange getSourceRange() throws CModelException {
return new SourceRange(getStartPos(), return new SourceRange(getStartPos(),
getLength(), getLength(),
getIdStartPos(), getIdStartPos(),
getIdLength(), getIdLength(),
getStartLine(), getStartLine(),
getEndLine()); getEndLine());
} }
@ -112,6 +118,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ISourceReference#getTranslationUnit() * @see org.eclipse.cdt.core.model.ISourceReference#getTranslationUnit()
*/ */
@Override
public ITranslationUnit getTranslationUnit() { public ITranslationUnit getTranslationUnit() {
if (fSourceTU == null) { if (fSourceTU == null) {
ITranslationUnit tu = null; ITranslationUnit tu = null;
@ -171,6 +178,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IBinaryElement#getAddress() * @see org.eclipse.cdt.core.model.IBinaryElement#getAddress()
*/ */
@Override
public IAddress getAddress() throws CModelException { public IAddress getAddress() throws CModelException {
return addr; return addr;
} }
@ -212,6 +220,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IBinaryElement#getBinary() * @see org.eclipse.cdt.core.model.IBinaryElement#getBinary()
*/ */
@Override
public IBinary getBinary() { public IBinary getBinary() {
ICElement current = this; ICElement current = this;
do { do {
@ -245,10 +254,12 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
return 0; return 0;
} }
@Override
public boolean isActive() { public boolean isActive() {
return true; return true;
} }
@Override
public int getIndex() { public int getIndex() {
return 0; return 0;
} }

View file

@ -26,6 +26,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IFunctionDeclaration#getExceptions() * @see org.eclipse.cdt.core.model.IFunctionDeclaration#getExceptions()
*/ */
@Override
public String[] getExceptions() { public String[] getExceptions() {
return new String[0]; return new String[0];
} }
@ -33,6 +34,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IFunctionDeclaration#getNumberOfParameters() * @see org.eclipse.cdt.core.model.IFunctionDeclaration#getNumberOfParameters()
*/ */
@Override
public int getNumberOfParameters() { public int getNumberOfParameters() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return 0; return 0;
@ -41,6 +43,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IFunctionDeclaration#getParameterInitializer(int) * @see org.eclipse.cdt.core.model.IFunctionDeclaration#getParameterInitializer(int)
*/ */
@Override
public String getParameterInitializer(int pos) { public String getParameterInitializer(int pos) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return new String(); return new String();
@ -49,6 +52,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IFunctionDeclaration#getParameterTypes() * @see org.eclipse.cdt.core.model.IFunctionDeclaration#getParameterTypes()
*/ */
@Override
public String[] getParameterTypes() { public String[] getParameterTypes() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return new String[0]; return new String[0];
@ -57,6 +61,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IFunctionDeclaration#getReturnType() * @see org.eclipse.cdt.core.model.IFunctionDeclaration#getReturnType()
*/ */
@Override
public String getReturnType() { public String getReturnType() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return new String(); return new String();
@ -65,6 +70,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IFunctionDeclaration#getSignature() * @see org.eclipse.cdt.core.model.IFunctionDeclaration#getSignature()
*/ */
@Override
public String getSignature() { public String getSignature() {
return getElementName(); return getElementName();
} }
@ -72,6 +78,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IDeclaration#isStatic() * @see org.eclipse.cdt.core.model.IDeclaration#isStatic()
*/ */
@Override
public boolean isStatic() { public boolean isStatic() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;
@ -80,6 +87,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IDeclaration#isConst() * @see org.eclipse.cdt.core.model.IDeclaration#isConst()
*/ */
@Override
public boolean isConst() { public boolean isConst() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;
@ -88,6 +96,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IDeclaration#isVolatile() * @see org.eclipse.cdt.core.model.IDeclaration#isVolatile()
*/ */
@Override
public boolean isVolatile() { public boolean isVolatile() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;

View file

@ -41,6 +41,7 @@ public class BinaryModule extends Parent implements IBinaryModule {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IBinaryModule#getBinaryElements() * @see org.eclipse.cdt.core.model.IBinaryModule#getBinaryElements()
*/ */
@Override
public IBinaryElement[] getBinaryElements() throws CModelException { public IBinaryElement[] getBinaryElements() throws CModelException {
ICElement[] e = getChildren(); ICElement[] e = getChildren();
IBinaryElement[] b = new IBinaryElement[e.length]; IBinaryElement[] b = new IBinaryElement[e.length];
@ -51,13 +52,15 @@ public class BinaryModule extends Parent implements IBinaryModule {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IBinaryElement#getAddress() * @see org.eclipse.cdt.core.model.IBinaryElement#getAddress()
*/ */
@Override
public IAddress getAddress() throws CModelException { public IAddress getAddress() throws CModelException {
return null; return null;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IBinaryElement#getBinary() * @see org.eclipse.cdt.core.model.IBinaryElement#getBinary()
*/ */
@Override
public IBinary getBinary() { public IBinary getBinary() {
return (IBinary)getParent(); return (IBinary)getParent();
} }

View file

@ -80,9 +80,9 @@ public class BinaryRunner {
} }
addDelta(cdelta); addDelta(cdelta);
} }
} }
private final ICProject cproject; private final ICProject cproject;
private final Job runnerJob; // final fields don't need synchronization private final Job runnerJob; // final fields don't need synchronization
private IOutputEntry[] entries = new IOutputEntry[0]; private IOutputEntry[] entries = new IOutputEntry[0];
@ -182,6 +182,7 @@ public class BinaryRunner {
textContentType = mgr.getContentType("org.eclipse.core.runtime.text"); //$NON-NLS-1$ textContentType = mgr.getContentType("org.eclipse.core.runtime.text"); //$NON-NLS-1$
} }
@Override
public boolean visit(IResourceProxy proxy) throws CoreException { public boolean visit(IResourceProxy proxy) throws CoreException {
if (vMonitor.isCanceled()) { if (vMonitor.isCanceled()) {
return false; return false;
@ -189,13 +190,13 @@ public class BinaryRunner {
vMonitor.worked(1); vMonitor.worked(1);
// Attempt to speed things up by rejecting up front // Attempt to speed things up by rejecting up front
// Things we know should not be Binary files. // Things we know should not be Binary files.
// check if it's a file resource // check if it's a file resource
// and bail out early // and bail out early
if (proxy.getType() != IResource.FILE) { if (proxy.getType() != IResource.FILE) {
return true; return true;
} }
// check against known content types // check against known content types
String name = proxy.getName(); String name = proxy.getName();
IContentType contentType = CCorePlugin.getContentType(project, name); IContentType contentType = CCorePlugin.getContentType(project, name);
@ -228,7 +229,7 @@ public class BinaryRunner {
} }
return true; return true;
} }
private boolean isOnOutputEntry(IOutputEntry entry, IPath path) { private boolean isOnOutputEntry(IOutputEntry entry, IPath path) {
if (entry.getPath().isPrefixOf(path) && !CoreModelUtil.isExcluded(path, entry.fullExclusionPatternChars())) { if (entry.getPath().isPrefixOf(path) && !CoreModelUtil.isExcluded(path, entry.fullExclusionPatternChars())) {
return true; return true;

View file

@ -26,6 +26,7 @@ public class BinaryVariable extends BinaryElement implements IVariable {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IVariable#getInitializer() * @see org.eclipse.cdt.core.model.IVariable#getInitializer()
*/ */
@Override
public String getInitializer() { public String getInitializer() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
@ -34,6 +35,7 @@ public class BinaryVariable extends BinaryElement implements IVariable {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IVariableDeclaration#getTypeName() * @see org.eclipse.cdt.core.model.IVariableDeclaration#getTypeName()
*/ */
@Override
public String getTypeName() { public String getTypeName() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
@ -42,6 +44,7 @@ public class BinaryVariable extends BinaryElement implements IVariable {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IVariableDeclaration#setTypeName(java.lang.String) * @see org.eclipse.cdt.core.model.IVariableDeclaration#setTypeName(java.lang.String)
*/ */
@Override
public void setTypeName(String type) { public void setTypeName(String type) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@ -49,6 +52,7 @@ public class BinaryVariable extends BinaryElement implements IVariable {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IDeclaration#isStatic() * @see org.eclipse.cdt.core.model.IDeclaration#isStatic()
*/ */
@Override
public boolean isStatic() { public boolean isStatic() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;
@ -57,6 +61,7 @@ public class BinaryVariable extends BinaryElement implements IVariable {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IDeclaration#isConst() * @see org.eclipse.cdt.core.model.IDeclaration#isConst()
*/ */
@Override
public boolean isConst() { public boolean isConst() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;
@ -65,9 +70,10 @@ public class BinaryVariable extends BinaryElement implements IVariable {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IDeclaration#isVolatile() * @see org.eclipse.cdt.core.model.IDeclaration#isVolatile()
*/ */
@Override
public boolean isVolatile() { public boolean isVolatile() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;
} }
} }

View file

@ -61,6 +61,7 @@ public class Buffer implements IBuffer {
/** /**
* @see IBuffer * @see IBuffer
*/ */
@Override
public void addBufferChangedListener(IBufferChangedListener listener) { public void addBufferChangedListener(IBufferChangedListener listener) {
if (this.changeListeners == null) { if (this.changeListeners == null) {
this.changeListeners = new ArrayList<IBufferChangedListener>(5); this.changeListeners = new ArrayList<IBufferChangedListener>(5);
@ -72,6 +73,7 @@ public class Buffer implements IBuffer {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#append(char[]) * @see org.eclipse.cdt.core.model.IBuffer#append(char[])
*/ */
@Override
public void append(char[] text) { public void append(char[] text) {
if (!isReadOnly()) { if (!isReadOnly()) {
if (text == null || text.length == 0) { if (text == null || text.length == 0) {
@ -89,6 +91,7 @@ public class Buffer implements IBuffer {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#append(java.lang.String) * @see org.eclipse.cdt.core.model.IBuffer#append(java.lang.String)
*/ */
@Override
public void append(String text) { public void append(String text) {
if (text == null) { if (text == null) {
return; return;
@ -99,6 +102,7 @@ public class Buffer implements IBuffer {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#close() * @see org.eclipse.cdt.core.model.IBuffer#close()
*/ */
@Override
public void close() { public void close() {
BufferChangedEvent event = null; BufferChangedEvent event = null;
synchronized (this.lock) { synchronized (this.lock) {
@ -115,6 +119,7 @@ public class Buffer implements IBuffer {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#getChar(int) * @see org.eclipse.cdt.core.model.IBuffer#getChar(int)
*/ */
@Override
public char getChar(int position) { public char getChar(int position) {
synchronized (this.lock) { synchronized (this.lock) {
if (position < this.gapStart) { if (position < this.gapStart) {
@ -128,6 +133,7 @@ public class Buffer implements IBuffer {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#getCharacters() * @see org.eclipse.cdt.core.model.IBuffer#getCharacters()
*/ */
@Override
public char[] getCharacters() { public char[] getCharacters() {
if (this.contents == null) return null; if (this.contents == null) return null;
synchronized (this.lock) { synchronized (this.lock) {
@ -145,6 +151,7 @@ public class Buffer implements IBuffer {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#getContents() * @see org.eclipse.cdt.core.model.IBuffer#getContents()
*/ */
@Override
public String getContents() { public String getContents() {
if (this.contents == null) return null; if (this.contents == null) return null;
return new String(this.getCharacters()); return new String(this.getCharacters());
@ -153,6 +160,7 @@ public class Buffer implements IBuffer {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#getLength() * @see org.eclipse.cdt.core.model.IBuffer#getLength()
*/ */
@Override
public int getLength() { public int getLength() {
synchronized (this.lock) { synchronized (this.lock) {
int length = this.gapEnd - this.gapStart; int length = this.gapEnd - this.gapStart;
@ -163,6 +171,7 @@ public class Buffer implements IBuffer {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#getOwner() * @see org.eclipse.cdt.core.model.IBuffer#getOwner()
*/ */
@Override
public IOpenable getOwner() { public IOpenable getOwner() {
return this.owner; return this.owner;
} }
@ -170,6 +179,7 @@ public class Buffer implements IBuffer {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#getText(int, int) * @see org.eclipse.cdt.core.model.IBuffer#getText(int, int)
*/ */
@Override
public String getText(int offset, int length) { public String getText(int offset, int length) {
if (this.contents == null) if (this.contents == null)
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
@ -190,6 +200,7 @@ public class Buffer implements IBuffer {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#getUnderlyingResource() * @see org.eclipse.cdt.core.model.IBuffer#getUnderlyingResource()
*/ */
@Override
public IResource getUnderlyingResource() { public IResource getUnderlyingResource() {
return this.file; return this.file;
} }
@ -197,6 +208,7 @@ public class Buffer implements IBuffer {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#hasUnsavedChanges() * @see org.eclipse.cdt.core.model.IBuffer#hasUnsavedChanges()
*/ */
@Override
public boolean hasUnsavedChanges() { public boolean hasUnsavedChanges() {
return (this.flags & F_HAS_UNSAVED_CHANGES) != 0; return (this.flags & F_HAS_UNSAVED_CHANGES) != 0;
} }
@ -204,6 +216,7 @@ public class Buffer implements IBuffer {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#isClosed() * @see org.eclipse.cdt.core.model.IBuffer#isClosed()
*/ */
@Override
public boolean isClosed() { public boolean isClosed() {
return (this.flags & F_IS_CLOSED) != 0; return (this.flags & F_IS_CLOSED) != 0;
} }
@ -211,6 +224,7 @@ public class Buffer implements IBuffer {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#isReadOnly() * @see org.eclipse.cdt.core.model.IBuffer#isReadOnly()
*/ */
@Override
public boolean isReadOnly() { public boolean isReadOnly() {
if (this.file == null) { if (this.file == null) {
return (this.flags & F_IS_READ_ONLY) != 0; return (this.flags & F_IS_READ_ONLY) != 0;
@ -227,9 +241,11 @@ public class Buffer implements IBuffer {
for (int i = 0, size = this.changeListeners.size(); i < size; ++i) { for (int i = 0, size = this.changeListeners.size(); i < size; ++i) {
final IBufferChangedListener listener = this.changeListeners.get(i); final IBufferChangedListener listener = this.changeListeners.get(i);
SafeRunner.run(new ISafeRunnable() { SafeRunner.run(new ISafeRunnable() {
@Override
public void handleException(Throwable exception) { public void handleException(Throwable exception) {
Util.log(exception, "Exception occurred in listener of buffer change notification", ICLogConstants.CDT); //$NON-NLS-1$ Util.log(exception, "Exception occurred in listener of buffer change notification", ICLogConstants.CDT); //$NON-NLS-1$
} }
@Override
public void run() throws Exception { public void run() throws Exception {
listener.bufferChanged(event); listener.bufferChanged(event);
} }
@ -240,6 +256,7 @@ public class Buffer implements IBuffer {
/** /**
* @see IBuffer * @see IBuffer
*/ */
@Override
public void removeBufferChangedListener(IBufferChangedListener listener) { public void removeBufferChangedListener(IBufferChangedListener listener) {
if (this.changeListeners != null) { if (this.changeListeners != null) {
this.changeListeners.remove(listener); this.changeListeners.remove(listener);
@ -251,6 +268,7 @@ public class Buffer implements IBuffer {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, char[]) * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, char[])
*/ */
@Override
public void replace(int position, int length, char[] text) { public void replace(int position, int length, char[] text) {
if (!isReadOnly()) { if (!isReadOnly()) {
int textLength = text == null ? 0 : text.length; int textLength = text == null ? 0 : text.length;
@ -277,13 +295,14 @@ public class Buffer implements IBuffer {
if (textLength > 0) { if (textLength > 0) {
string = new String(text); string = new String(text);
} }
notifyChanged(new BufferChangedEvent(this, position, length, string)); notifyChanged(new BufferChangedEvent(this, position, length, string));
} }
} }
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, java.lang.String) * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, java.lang.String)
*/ */
@Override
public void replace(int position, int length, String text) { public void replace(int position, int length, String text) {
this.replace(position, length, text == null ? null : text.toCharArray()); this.replace(position, length, text == null ? null : text.toCharArray());
} }
@ -291,16 +310,17 @@ public class Buffer implements IBuffer {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#save(org.eclipse.core.runtime.IProgressMonitor, boolean) * @see org.eclipse.cdt.core.model.IBuffer#save(org.eclipse.core.runtime.IProgressMonitor, boolean)
*/ */
@Override
public void save(IProgressMonitor progress, boolean force) public void save(IProgressMonitor progress, boolean force)
throws CModelException { throws CModelException {
// determine if saving is required // determine if saving is required
if (isReadOnly() || this.file == null) { if (isReadOnly() || this.file == null) {
return; return;
} }
synchronized (this.lock) { synchronized (this.lock) {
if (!hasUnsavedChanges()) if (!hasUnsavedChanges())
return; return;
// use a platform operation to update the resource contents // use a platform operation to update the resource contents
try { try {
String encoding = null; String encoding = null;
@ -312,19 +332,19 @@ public class Buffer implements IBuffer {
} }
String contents = this.getContents(); String contents = this.getContents();
if (contents == null) return; if (contents == null) return;
byte[] bytes = encoding == null byte[] bytes = encoding == null
? contents.getBytes() ? contents.getBytes()
: contents.getBytes(encoding); : contents.getBytes(encoding);
ByteArrayInputStream stream = new ByteArrayInputStream(bytes); ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
if (this.file.exists()) { if (this.file.exists()) {
this.file.setContents( this.file.setContents(
stream, stream,
force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY, force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
null); null);
} else { } else {
this.file.create(stream, force, null); this.file.create(stream, force, null);
} }
} catch (IOException e) { } catch (IOException e) {
throw new CModelException(e, ICModelStatusConstants.IO_EXCEPTION); throw new CModelException(e, ICModelStatusConstants.IO_EXCEPTION);
} }
@ -340,15 +360,16 @@ public class Buffer implements IBuffer {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#setContents(char[]) * @see org.eclipse.cdt.core.model.IBuffer#setContents(char[])
*/ */
@Override
public void setContents(char[] newContents) { public void setContents(char[] newContents) {
// allow special case for first initialization // allow special case for first initialization
// after creation by buffer factory // after creation by buffer factory
if (this.contents == null) { if (this.contents == null) {
this.contents = newContents; this.contents = newContents;
this.flags &= ~ (F_HAS_UNSAVED_CHANGES); this.flags &= ~ (F_HAS_UNSAVED_CHANGES);
return; return;
} }
if (!isReadOnly()) { if (!isReadOnly()) {
String string = null; String string = null;
if (newContents != null) { if (newContents != null) {
@ -368,13 +389,14 @@ public class Buffer implements IBuffer {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#setContents(java.lang.String) * @see org.eclipse.cdt.core.model.IBuffer#setContents(java.lang.String)
*/ */
@Override
public void setContents(String newContents) { public void setContents(String newContents) {
this.setContents(newContents.toCharArray()); this.setContents(newContents.toCharArray());
} }
/** /**
* Moves the gap to location and adjust its size to the * Moves the gap to location and adjust its size to the
* anticipated change size. The size represents the expected * anticipated change size. The size represents the expected
* range of the gap that will be filled after the gap has been moved. * range of the gap that will be filled after the gap has been moved.
* Thus the gap is resized to actual size + the specified size and * Thus the gap is resized to actual size + the specified size and
* moved to the given position. * moved to the given position.
@ -414,7 +436,7 @@ public class Buffer implements IBuffer {
this.gapStart = newGapStart; this.gapStart = newGapStart;
this.gapEnd = newGapEnd; this.gapEnd = newGapEnd;
} }
/** /**
* Sets this <code>Buffer</code> to be read only. * Sets this <code>Buffer</code> to be read only.
*/ */
@ -425,7 +447,7 @@ public class Buffer implements IBuffer {
this.flags &= ~(F_IS_READ_ONLY); this.flags &= ~(F_IS_READ_ONLY);
} }
} }
@Override @Override
public String toString() { public String toString() {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
@ -442,7 +464,7 @@ public class Buffer implements IBuffer {
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
char car = contents[i]; char car = contents[i];
switch (car) { switch (car) {
case '\n': case '\n':
buffer.append("\\n\n"); //$NON-NLS-1$ buffer.append("\\n\n"); //$NON-NLS-1$
break; break;
case '\r': case '\r':

View file

@ -22,7 +22,7 @@ import org.eclipse.core.resources.IResource;
/** /**
* The buffer manager manages the set of open buffers. * The buffer manager manages the set of open buffers.
* It implements an LRU cache of buffers. * It implements an LRU cache of buffers.
* *
* This class is similar to the JDT BufferManager class * This class is similar to the JDT BufferManager class
*/ */
@ -92,17 +92,18 @@ public class BufferManager implements IBufferFactory {
/** /**
* @see org.eclipse.cdt.internal.core.model.IBufferFactory#createBuffer(org.eclipse.cdt.core.model.IOpenable) * @see org.eclipse.cdt.internal.core.model.IBufferFactory#createBuffer(org.eclipse.cdt.core.model.IOpenable)
*/ */
@Override
public IBuffer createBuffer(IOpenable owner) { public IBuffer createBuffer(IOpenable owner) {
ICElement element = (ICElement)owner; ICElement element = (ICElement)owner;
IResource resource = element.getResource(); IResource resource = element.getResource();
return return
new Buffer( new Buffer(
resource instanceof IFile ? (IFile)resource : null, resource instanceof IFile ? (IFile)resource : null,
owner, owner,
element.isReadOnly()); element.isReadOnly());
} }
/** /**
* Returns the open buffer associated with the given owner, * Returns the open buffer associated with the given owner,
* or <code>null</code> if the owner does not have an open * or <code>null</code> if the owner does not have an open
@ -128,7 +129,7 @@ public class BufferManager implements IBufferFactory {
} }
/** /**
* Returns an enumeration of all open buffers. * Returns an enumeration of all open buffers.
* <p> * <p>
* The <code>Enumeration</code> answered is thread safe. * The <code>Enumeration</code> answered is thread safe.
* *
* @see OverflowingLRUCache * @see OverflowingLRUCache
@ -140,8 +141,8 @@ public class BufferManager implements IBufferFactory {
return openBuffers.elements(); return openBuffers.elements();
} }
} }
/** /**
* Removes a buffer from the table of open buffers. * Removes a buffer from the table of open buffers.
*/ */

View file

@ -50,9 +50,10 @@ public class CContainer extends Openable implements ICContainer {
/** /**
* Returns a the collection of binary files in this ccontainer * Returns a the collection of binary files in this ccontainer
* *
* @see ICContainer#getBinaries() * @see ICContainer#getBinaries()
*/ */
@Override
public IBinary[] getBinaries() throws CModelException { public IBinary[] getBinaries() throws CModelException {
List<?> list = getChildrenOfType(C_BINARY); List<?> list = getChildrenOfType(C_BINARY);
IBinary[] array = new IBinary[list.size()]; IBinary[] array = new IBinary[list.size()];
@ -63,6 +64,7 @@ public class CContainer extends Openable implements ICContainer {
/** /**
* @see ICContainer#getBinary(String) * @see ICContainer#getBinary(String)
*/ */
@Override
public IBinary getBinary(String name) { public IBinary getBinary(String name) {
IFile file = getContainer().getFile(new Path(name)); IFile file = getContainer().getFile(new Path(name));
return getBinary(file); return getBinary(file);
@ -78,9 +80,10 @@ public class CContainer extends Openable implements ICContainer {
/** /**
* Returns a the collection of archive files in this ccontainer * Returns a the collection of archive files in this ccontainer
* *
* @see ICContainer#getArchives() * @see ICContainer#getArchives()
*/ */
@Override
public IArchive[] getArchives() throws CModelException { public IArchive[] getArchives() throws CModelException {
List<?> list = getChildrenOfType(C_ARCHIVE); List<?> list = getChildrenOfType(C_ARCHIVE);
IArchive[] array = new IArchive[list.size()]; IArchive[] array = new IArchive[list.size()];
@ -91,6 +94,7 @@ public class CContainer extends Openable implements ICContainer {
/** /**
* @see ICContainer#getArchive(String) * @see ICContainer#getArchive(String)
*/ */
@Override
public IArchive getArchive(String name) { public IArchive getArchive(String name) {
IFile file = getContainer().getFile(new Path(name)); IFile file = getContainer().getFile(new Path(name));
return getArchive(file); return getArchive(file);
@ -107,6 +111,7 @@ public class CContainer extends Openable implements ICContainer {
/** /**
* @see ICContainer#getTranslationUnits() * @see ICContainer#getTranslationUnits()
*/ */
@Override
public ITranslationUnit[] getTranslationUnits() throws CModelException { public ITranslationUnit[] getTranslationUnits() throws CModelException {
List<?> list = getChildrenOfType(C_UNIT); List<?> list = getChildrenOfType(C_UNIT);
ITranslationUnit[] array = new ITranslationUnit[list.size()]; ITranslationUnit[] array = new ITranslationUnit[list.size()];
@ -116,9 +121,10 @@ public class CContainer extends Openable implements ICContainer {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.cdt.core.model.ICContainer#getTranslationUnit(java.lang.String) * @see org.eclipse.cdt.core.model.ICContainer#getTranslationUnit(java.lang.String)
*/ */
@Override
public ITranslationUnit getTranslationUnit(String name) { public ITranslationUnit getTranslationUnit(String name) {
IFile file = getContainer().getFile(new Path(name)); IFile file = getContainer().getFile(new Path(name));
return getTranslationUnit(file); return getTranslationUnit(file);
@ -131,9 +137,10 @@ public class CContainer extends Openable implements ICContainer {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.cdt.core.model.ICContainer#getCContainers() * @see org.eclipse.cdt.core.model.ICContainer#getCContainers()
*/ */
@Override
public ICContainer[] getCContainers() throws CModelException { public ICContainer[] getCContainers() throws CModelException {
List<?> list = getChildrenOfType(C_CCONTAINER); List<?> list = getChildrenOfType(C_CCONTAINER);
ICContainer[] array = new ICContainer[list.size()]; ICContainer[] array = new ICContainer[list.size()];
@ -143,9 +150,10 @@ public class CContainer extends Openable implements ICContainer {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.cdt.core.model.ICContainer#getCContainer(java.lang.String) * @see org.eclipse.cdt.core.model.ICContainer#getCContainer(java.lang.String)
*/ */
@Override
public ICContainer getCContainer(String name) { public ICContainer getCContainer(String name) {
IFolder folder = getContainer().getFolder(new Path(name)); IFolder folder = getContainer().getFolder(new Path(name));
return getCContainer(folder); return getCContainer(folder);
@ -195,9 +203,10 @@ public class CContainer extends Openable implements ICContainer {
/* /*
* (non-Javadoc) Returns an array of non-c resources contained in the * (non-Javadoc) Returns an array of non-c resources contained in the
* receiver. * receiver.
* *
* @see org.eclipse.cdt.core.model.ICContainer#getNonCResources() * @see org.eclipse.cdt.core.model.ICContainer#getNonCResources()
*/ */
@Override
public Object[] getNonCResources() throws CModelException { public Object[] getNonCResources() throws CModelException {
return ((CContainerInfo) getElementInfo()).getNonCResources(getResource()); return ((CContainerInfo) getElementInfo()).getNonCResources(getResource());
} }
@ -273,7 +282,7 @@ public class CContainer extends Openable implements ICContainer {
} }
return celement; return celement;
} }
@Override @Override
public ICElement getHandleFromMemento(String token, MementoTokenizer memento) { public ICElement getHandleFromMemento(String token, MementoTokenizer memento) {
switch (token.charAt(0)) { switch (token.charAt(0)) {

View file

@ -41,7 +41,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.PlatformObject;
public abstract class CElement extends PlatformObject implements ICElement { public abstract class CElement extends PlatformObject implements ICElement {
public static final char CEM_ESCAPE = '\\'; public static final char CEM_ESCAPE = '\\';
public static final char CEM_CPROJECT = '='; public static final char CEM_CPROJECT = '=';
public static final char CEM_SOURCEROOT = '/'; public static final char CEM_SOURCEROOT = '/';
@ -53,7 +53,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
protected static final CElement[] NO_ELEMENTS = new CElement[0]; protected static final CElement[] NO_ELEMENTS = new CElement[0];
protected int fType; protected int fType;
protected ICElement fParent; protected ICElement fParent;
protected String fName; protected String fName;
@ -63,7 +63,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
fName= name; fName= name;
fType= type; fType= type;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class) * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
*/ */
@ -79,8 +79,8 @@ public abstract class CElement extends PlatformObject implements ICElement {
} }
return super.getAdapter(adapter); return super.getAdapter(adapter);
} }
// setters // setters
public void setElementType (int type) { public void setElementType (int type) {
@ -90,44 +90,50 @@ public abstract class CElement extends PlatformObject implements ICElement {
public void setElementName(String name) { public void setElementName(String name) {
fName = name; fName = name;
} }
public void setParent (ICElement parent) { public void setParent (ICElement parent) {
fParent = parent; fParent = parent;
} }
// getters // getters
@Override
public int getElementType() { public int getElementType() {
return fType; return fType;
} }
@Override
public String getElementName() { public String getElementName() {
return fName; return fName;
} }
@Override
public ICElement getParent() { public ICElement getParent() {
return fParent; return fParent;
} }
@Override
public IPath getPath() { public IPath getPath() {
IResource res = getUnderlyingResource(); IResource res = getUnderlyingResource();
if (res != null) if (res != null)
return res.getFullPath(); return res.getFullPath();
return new Path(getElementName()); return new Path(getElementName());
} }
@Override
public URI getLocationURI() { public URI getLocationURI() {
IResource res = getUnderlyingResource(); IResource res = getUnderlyingResource();
if(res != null) { if(res != null) {
return res.getLocationURI(); return res.getLocationURI();
} }
else { else {
return null; return null;
} }
} }
@Override
public boolean exists() { public boolean exists() {
try { try {
return getElementInfo() != null; return getElementInfo() != null;
@ -201,7 +207,8 @@ public abstract class CElement extends PlatformObject implements ICElement {
} }
return new ICElement[]{this}; return new ICElement[]{this};
} }
@Override
public boolean isReadOnly () { public boolean isReadOnly () {
IResource r = getUnderlyingResource(); IResource r = getUnderlyingResource();
if (r != null) { if (r != null) {
@ -209,14 +216,16 @@ public abstract class CElement extends PlatformObject implements ICElement {
if (attributes != null) { if (attributes != null) {
return attributes.isReadOnly(); return attributes.isReadOnly();
} }
} }
return false; return false;
} }
@Override
public boolean isStructureKnown() throws CModelException { public boolean isStructureKnown() throws CModelException {
return getElementInfo().isStructureKnown(); return getElementInfo().isStructureKnown();
} }
@Override
public ICModel getCModel () { public ICModel getCModel () {
ICElement current = this; ICElement current = this;
do { do {
@ -225,6 +234,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
return null; return null;
} }
@Override
public ICProject getCProject() { public ICProject getCProject() {
ICElement current = this; ICElement current = this;
do { do {
@ -236,6 +246,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
protected void addChild(ICElement e) throws CModelException { protected void addChild(ICElement e) throws CModelException {
} }
@Override
public IResource getUnderlyingResource() { public IResource getUnderlyingResource() {
IResource res = getResource(); IResource res = getResource();
if (res == null) { if (res == null) {
@ -247,6 +258,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
return res; return res;
} }
@Override
public abstract IResource getResource() ; public abstract IResource getResource() ;
protected abstract CElementInfo createElementInfo(); protected abstract CElementInfo createElementInfo();
@ -263,7 +275,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
} }
return false; return false;
} }
public static boolean equals(ICElement lhs, ICElement rhs) { public static boolean equals(ICElement lhs, ICElement rhs) {
if (lhs == rhs) { if (lhs == rhs) {
return true; return true;
@ -277,19 +289,19 @@ public abstract class CElement extends PlatformObject implements ICElement {
!lhsName.equals(rhsName)) { !lhsName.equals(rhsName)) {
return false; return false;
} }
if (lhs instanceof ISourceReference && rhs instanceof ISourceReference) { if (lhs instanceof ISourceReference && rhs instanceof ISourceReference) {
if (((ISourceReference) lhs).getIndex() != ((ISourceReference) rhs).getIndex()) { if (((ISourceReference) lhs).getIndex() != ((ISourceReference) rhs).getIndex()) {
return false; return false;
} }
} }
ICElement lhsParent= lhs.getParent(); ICElement lhsParent= lhs.getParent();
ICElement rhsParent= rhs.getParent(); ICElement rhsParent= rhs.getParent();
if (lhsParent == rhsParent) { if (lhsParent == rhsParent) {
return true; return true;
} }
return lhsParent != null && lhsParent.equals(rhsParent); return lhsParent != null && lhsParent.equals(rhsParent);
} }
@ -370,7 +382,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
return "UNKNOWN"; //$NON-NLS-1$ return "UNKNOWN"; //$NON-NLS-1$
} }
} }
/** /**
* Close the C Element * Close the C Element
* @throws CModelException * @throws CModelException
@ -398,7 +410,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
* <p>Subclasses that are not IOpenable's must override this method. * <p>Subclasses that are not IOpenable's must override this method.
*/ */
public IOpenable getOpenableParent() { public IOpenable getOpenableParent() {
if (fParent instanceof IOpenable) { if (fParent instanceof IOpenable) {
return (IOpenable)fParent; return (IOpenable)fParent;
} }
return null; return null;
@ -455,6 +467,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
/** /**
* @see ICElement * @see ICElement
*/ */
@Override
public ICElement getAncestor(int ancestorType) { public ICElement getAncestor(int ancestorType) {
ICElement element = this; ICElement element = this;
while (element != null) { while (element != null) {
@ -477,14 +490,14 @@ public abstract class CElement extends PlatformObject implements ICElement {
} }
return parent != null; return parent != null;
} }
/** /**
* Creates and returns and not present exception for this element. * Creates and returns and not present exception for this element.
*/ */
protected CModelException newNotPresentException() { protected CModelException newNotPresentException() {
return new CModelException(new CModelStatus(ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this)); return new CModelException(new CModelStatus(ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this));
} }
/** /**
* Returns the hash code for this Java element. By default, * Returns the hash code for this Java element. By default,
* the hash code for an element is a combination of its name * the hash code for an element is a combination of its name
@ -497,7 +510,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
public int hashCode() { public int hashCode() {
return hashCode(this); return hashCode(this);
} }
public static int hashCode(ICElement elem) { public static int hashCode(ICElement elem) {
ICElement parent= elem.getParent(); ICElement parent= elem.getParent();
if (parent == null) { if (parent == null) {
@ -505,7 +518,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
} }
return Util.combineHashCodes(elem.getElementName().hashCode(), parent.hashCode()); return Util.combineHashCodes(elem.getElementName().hashCode(), parent.hashCode());
} }
/* /*
* Test to see if two objects are identical * Test to see if two objects are identical
* Subclasses should override accordingly * Subclasses should override accordingly
@ -513,10 +526,11 @@ public abstract class CElement extends PlatformObject implements ICElement {
public boolean isIdentical(CElement otherElement){ public boolean isIdentical(CElement otherElement){
return this.equals(otherElement); return this.equals(otherElement);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICElement#accept(org.eclipse.cdt.core.model.ICElementVisitor) * @see org.eclipse.cdt.core.model.ICElement#accept(org.eclipse.cdt.core.model.ICElementVisitor)
*/ */
@Override
public void accept(ICElementVisitor visitor) throws CoreException { public void accept(ICElementVisitor visitor) throws CoreException {
// Visit me, return right away if the visitor doesn't want to visit my children // Visit me, return right away if the visitor doesn't want to visit my children
if (!visitor.visit(this)) if (!visitor.visit(this))
@ -533,13 +547,14 @@ public abstract class CElement extends PlatformObject implements ICElement {
/* /*
* @see org.eclipse.cdt.core.model.ICElement#getHandleIdentifier() * @see org.eclipse.cdt.core.model.ICElement#getHandleIdentifier()
*/ */
@Override
public String getHandleIdentifier() { public String getHandleIdentifier() {
return getHandleMemento(); return getHandleMemento();
} }
/** /**
* Builds a string representation of this element. * Builds a string representation of this element.
* *
* @return the string representation * @return the string representation
*/ */
public String getHandleMemento(){ public String getHandleMemento(){
@ -550,7 +565,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
/** /**
* Append this elements memento string to the given buffer. * Append this elements memento string to the given buffer.
* *
* @param buff the buffer building the memento string * @param buff the buffer building the memento string
*/ */
public void getHandleMemento(StringBuilder buff) { public void getHandleMemento(StringBuilder buff) {
@ -567,7 +582,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
/** /**
* Creates a C element handle from the given memento. * Creates a C element handle from the given memento.
* *
* @param memento the memento tokenizer * @param memento the memento tokenizer
*/ */
public ICElement getHandleFromMemento(MementoTokenizer memento) { public ICElement getHandleFromMemento(MementoTokenizer memento) {
@ -579,7 +594,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
/** /**
* Creates a C element handle from the given memento. * Creates a C element handle from the given memento.
* The given token is the current delimiter indicating the type of the next token(s). * The given token is the current delimiter indicating the type of the next token(s).
* *
* @param token the curren memento token * @param token the curren memento token
* @param memento the memento tokenizer * @param memento the memento tokenizer
*/ */
@ -587,7 +602,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
/** /**
* Escape special characters in the given name and append the result to buffer. * Escape special characters in the given name and append the result to buffer.
* *
* @param buffer the buffer to build the memento string * @param buffer the buffer to build the memento string
* @param mementoName the name to escape * @param mementoName the name to escape
*/ */

View file

@ -103,12 +103,12 @@ public class CElementDelta implements ICElementDelta {
fChangeFlags |= F_CHILDREN; fChangeFlags |= F_CHILDREN;
} }
// if a child delta is added to a translation unit delta or below, // if a child delta is added to a translation unit delta or below,
// it's a fine grained delta // it's a fine grained delta
if (!(fChangedElement.getElementType() >= ICElement.C_UNIT)) { if (!(fChangedElement.getElementType() >= ICElement.C_UNIT)) {
fineGrained(); fineGrained();
} }
if (fAffectedChildren.length == 0) { if (fAffectedChildren.length == 0) {
fAffectedChildren = new ICElementDelta[] {child}; fAffectedChildren = new ICElementDelta[] {child};
return; return;
@ -189,7 +189,7 @@ public class CElementDelta implements ICElementDelta {
return; return;
} }
break; break;
default: default:
// unknown -> existing child becomes the child with the existing child's flags // unknown -> existing child becomes the child with the existing child's flags
int flags = existingChild.getFlags(); int flags = existingChild.getFlags();
fAffectedChildren[existingChildIndex] = child; fAffectedChildren[existingChildIndex] = child;
@ -201,7 +201,7 @@ public class CElementDelta implements ICElementDelta {
/** /**
* Creates the nested deltas resulting from an add operation. * Creates the nested deltas resulting from an add operation.
* Convenience method for creating add deltas. * Convenience method for creating add deltas.
* The constructor should be used to create the root delta * The constructor should be used to create the root delta
* and then an add operation should call this method. * and then an add operation should call this method.
*/ */
public void added(ICElement element) { public void added(ICElement element) {
@ -242,7 +242,7 @@ public class CElementDelta implements ICElementDelta {
/** /**
* Creates the nested deltas resulting from a change operation. * Creates the nested deltas resulting from a change operation.
* Convenience method for creating change deltas. * Convenience method for creating change deltas.
* The constructor should be used to create the root delta * The constructor should be used to create the root delta
* and then a change operation should call this method. * and then a change operation should call this method.
*/ */
public void changed(ICElement element, int changeFlag) { public void changed(ICElement element, int changeFlag) {
@ -329,6 +329,7 @@ public class CElementDelta implements ICElementDelta {
/** /**
* @see ICElementDelta * @see ICElementDelta
*/ */
@Override
public ICElementDelta[] getAddedChildren() { public ICElementDelta[] getAddedChildren() {
return getChildrenOfType(ADDED); return getChildrenOfType(ADDED);
} }
@ -336,6 +337,7 @@ public class CElementDelta implements ICElementDelta {
/** /**
* @see ICElementDelta * @see ICElementDelta
*/ */
@Override
public ICElementDelta[] getAffectedChildren() { public ICElementDelta[] getAffectedChildren() {
return fAffectedChildren; return fAffectedChildren;
} }
@ -366,6 +368,7 @@ public class CElementDelta implements ICElementDelta {
/** /**
* @see ICElementDelta * @see ICElementDelta
*/ */
@Override
public ICElementDelta[] getChangedChildren() { public ICElementDelta[] getChangedChildren() {
return getChildrenOfType(CHANGED); return getChildrenOfType(CHANGED);
} }
@ -415,6 +418,7 @@ public class CElementDelta implements ICElementDelta {
/** /**
* @see ICElementDelta * @see ICElementDelta
*/ */
@Override
public ICElement getElement() { public ICElement getElement() {
return fChangedElement; return fChangedElement;
} }
@ -422,6 +426,7 @@ public class CElementDelta implements ICElementDelta {
/** /**
* @see ICElementDelta * @see ICElementDelta
*/ */
@Override
public int getFlags() { public int getFlags() {
return fChangeFlags; return fChangeFlags;
} }
@ -429,6 +434,7 @@ public class CElementDelta implements ICElementDelta {
/** /**
* @see ICElementDelta * @see ICElementDelta
*/ */
@Override
public int getKind() { public int getKind() {
return fKind; return fKind;
} }
@ -436,6 +442,7 @@ public class CElementDelta implements ICElementDelta {
/** /**
* @see ICElementDelta * @see ICElementDelta
*/ */
@Override
public ICElement getMovedFromElement() { public ICElement getMovedFromElement() {
return fMovedFromHandle; return fMovedFromHandle;
} }
@ -443,6 +450,7 @@ public class CElementDelta implements ICElementDelta {
/** /**
* @see ICElementDelta * @see ICElementDelta
*/ */
@Override
public ICElement getMovedToElement() { public ICElement getMovedToElement() {
return fMovedToHandle; return fMovedToHandle;
} }
@ -450,6 +458,7 @@ public class CElementDelta implements ICElementDelta {
/** /**
* @see ICElementDelta * @see ICElementDelta
*/ */
@Override
public ICElementDelta[] getRemovedChildren() { public ICElementDelta[] getRemovedChildren() {
return getChildrenOfType(REMOVED); return getChildrenOfType(REMOVED);
} }
@ -457,6 +466,7 @@ public class CElementDelta implements ICElementDelta {
/** /**
* Return the collection of resource deltas. Return null if none. * Return the collection of resource deltas. Return null if none.
*/ */
@Override
public IResourceDelta[] getResourceDeltas() { public IResourceDelta[] getResourceDeltas() {
if (resourceDeltas == null) if (resourceDeltas == null)
return null; return null;
@ -493,7 +503,7 @@ public class CElementDelta implements ICElementDelta {
/** /**
* Creates the nested deltas resulting from an move operation. * Creates the nested deltas resulting from an move operation.
* Convenience method for creating the "move from" delta. * Convenience method for creating the "move from" delta.
* The constructor should be used to create the root delta * The constructor should be used to create the root delta
* and then the move operation should call this method. * and then the move operation should call this method.
*/ */
public void movedFrom(ICElement movedFromElement, ICElement movedToElement) { public void movedFrom(ICElement movedFromElement, ICElement movedToElement) {
@ -507,7 +517,7 @@ public class CElementDelta implements ICElementDelta {
/** /**
* Creates the nested deltas resulting from an move operation. * Creates the nested deltas resulting from an move operation.
* Convenience method for creating the "move to" delta. * Convenience method for creating the "move to" delta.
* The constructor should be used to create the root delta * The constructor should be used to create the root delta
* and then the move operation should call this method. * and then the move operation should call this method.
*/ */
public void movedTo(ICElement movedToElement, ICElement movedFromElement) { public void movedTo(ICElement movedToElement, ICElement movedFromElement) {
@ -563,7 +573,7 @@ public class CElementDelta implements ICElementDelta {
/** /**
* Creates the nested deltas resulting from an delete operation. * Creates the nested deltas resulting from an delete operation.
* Convenience method for creating removed deltas. * Convenience method for creating removed deltas.
* The constructor should be used to create the root delta * The constructor should be used to create the root delta
* and then the delete operation should call this method. * and then the delete operation should call this method.
*/ */
public void removed(ICElement element) { public void removed(ICElement element) {
@ -580,7 +590,7 @@ public class CElementDelta implements ICElementDelta {
/** /**
* Creates the nested deltas resulting from a change operation. * Creates the nested deltas resulting from a change operation.
* Convenience method for creating change deltas. * Convenience method for creating change deltas.
* The constructor should be used to create the root delta * The constructor should be used to create the root delta
* and then a change operation should call this method. * and then a change operation should call this method.
*/ */
public void binaryParserChanged(ICElement element) { public void binaryParserChanged(ICElement element) {
@ -593,7 +603,7 @@ public class CElementDelta implements ICElementDelta {
/** /**
* Creates the nested deltas resulting from a change operation. * Creates the nested deltas resulting from a change operation.
* Convenience method for creating change deltas. * Convenience method for creating change deltas.
* The constructor should be used to create the root delta * The constructor should be used to create the root delta
* and then a change operation should call this method. * and then a change operation should call this method.
*/ */
public void sourceAttached(ICElement element) { public void sourceAttached(ICElement element) {
@ -606,7 +616,7 @@ public class CElementDelta implements ICElementDelta {
/** /**
* Creates the nested deltas resulting from a change operation. * Creates the nested deltas resulting from a change operation.
* Convenience method for creating change deltas. * Convenience method for creating change deltas.
* The constructor should be used to create the root delta * The constructor should be used to create the root delta
* and then a change operation should call this method. * and then a change operation should call this method.
*/ */
public void sourceDetached(ICElement element) { public void sourceDetached(ICElement element) {
@ -616,7 +626,7 @@ public class CElementDelta implements ICElementDelta {
insertDeltaTree(element, detachedDelta); insertDeltaTree(element, detachedDelta);
} }
/** /**
* Returns a string representation of this delta's * Returns a string representation of this delta's
* structure suitable for debug purposes. * structure suitable for debug purposes.
* *
@ -761,7 +771,7 @@ public class CElementDelta implements ICElementDelta {
return buffer.toString(); return buffer.toString();
} }
/** /**
* Returns a string representation of this delta's * Returns a string representation of this delta's
* structure suitable for debug purposes. * structure suitable for debug purposes.
*/ */

View file

@ -10,7 +10,7 @@
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -48,6 +48,7 @@ public class CModel extends Openable implements ICModel {
return super.equals(o); return super.equals(o);
} }
@Override
public ICProject[] getCProjects() throws CModelException { public ICProject[] getCProjects() throws CModelException {
List<?> list = getChildrenOfType(C_PROJECT); List<?> list = getChildrenOfType(C_PROJECT);
ICProject[] array= new ICProject[list.size()]; ICProject[] array= new ICProject[list.size()];
@ -58,9 +59,10 @@ public class CModel extends Openable implements ICModel {
/** /**
* ICModel#getCProject(String) * ICModel#getCProject(String)
*/ */
@Override
public ICProject getCProject(String name) { public ICProject getCProject(String name) {
IProject project = ((IWorkspaceRoot) getResource()).getProject(name); IProject project = ((IWorkspaceRoot) getResource()).getProject(name);
return CModelManager.getDefault().create(project); return CModelManager.getDefault().create(project);
} }
/** /**
@ -101,11 +103,13 @@ public class CModel extends Openable implements ICModel {
} }
return null; return null;
} }
@Override
public IWorkspace getWorkspace() { public IWorkspace getWorkspace() {
return getUnderlyingResource().getWorkspace(); return getUnderlyingResource().getWorkspace();
} }
@Override
public void copy(ICElement[] elements, ICElement[] containers, ICElement[] siblings, public void copy(ICElement[] elements, ICElement[] containers, ICElement[] siblings,
String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException { String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException {
if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT ) { if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT ) {
@ -117,6 +121,7 @@ public class CModel extends Openable implements ICModel {
} }
} }
@Override
public void delete(ICElement[] elements, boolean force, IProgressMonitor monitor) public void delete(ICElement[] elements, boolean force, IProgressMonitor monitor)
throws CModelException { throws CModelException {
CModelOperation op; CModelOperation op;
@ -128,6 +133,7 @@ public class CModel extends Openable implements ICModel {
op.runOperation(monitor); op.runOperation(monitor);
} }
@Override
public void move(ICElement[] elements, ICElement[] containers, ICElement[] siblings, public void move(ICElement[] elements, ICElement[] containers, ICElement[] siblings,
String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException { String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException {
if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT) { if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT) {
@ -139,6 +145,7 @@ public class CModel extends Openable implements ICModel {
} }
} }
@Override
public void rename(ICElement[] elements, ICElement[] destinations, String[] renamings, public void rename(ICElement[] elements, ICElement[] destinations, String[] renamings,
boolean force, IProgressMonitor monitor) throws CModelException { boolean force, IProgressMonitor monitor) throws CModelException {
CModelOperation op; CModelOperation op;
@ -210,6 +217,7 @@ public class CModel extends Openable implements ICModel {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICModel#getNonCResources() * @see org.eclipse.cdt.core.model.ICModel#getNonCResources()
*/ */
@Override
public Object[] getNonCResources() throws CModelException { public Object[] getNonCResources() throws CModelException {
return ((CModelInfo) getElementInfo()).getNonCResources(); return ((CModelInfo) getElementInfo()).getNonCResources();
} }
@ -241,12 +249,12 @@ public class CModel extends Openable implements ICModel {
} }
return null; return null;
} }
@Override @Override
public void getHandleMemento(StringBuilder buff) { public void getHandleMemento(StringBuilder buff) {
buff.append(getElementName()); buff.append(getElementName());
} }
@Override @Override
protected char getHandleMementoDelimiter() { protected char getHandleMementoDelimiter() {
Assert.isTrue(false, "Should not be called"); //$NON-NLS-1$ Assert.isTrue(false, "Should not be called"); //$NON-NLS-1$

View file

@ -104,7 +104,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
/** /**
* Create a model builder for the given translation unit. * Create a model builder for the given translation unit.
* *
* @param tu the translation unit (must be a {@link TranslationUnit} * @param tu the translation unit (must be a {@link TranslationUnit}
* @param newElements element cache * @param newElements element cache
* @param monitor the progress monitor * @param monitor the progress monitor
@ -118,10 +118,11 @@ public class CModelBuilder2 implements IContributedModelBuilder {
/* /*
* @see org.eclipse.cdt.core.model.IContributedModelBuilder#parse(boolean) * @see org.eclipse.cdt.core.model.IContributedModelBuilder#parse(boolean)
*/ */
@Override
public void parse(boolean quickParseMode) throws Exception { public void parse(boolean quickParseMode) throws Exception {
final IIndexManager indexManager= CCorePlugin.getIndexManager(); final IIndexManager indexManager= CCorePlugin.getIndexManager();
IIndex index= indexManager.getIndex(fTranslationUnit.getCProject(), IIndexManager.ADD_DEPENDENCIES); IIndex index= indexManager.getIndex(fTranslationUnit.getCProject(), IIndexManager.ADD_DEPENDENCIES);
try { try {
if (index != null) { if (index != null) {
try { try {
@ -229,6 +230,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
// sort by offset // sort by offset
final List<ICElement> children= getElementInfo(fTranslationUnit).internalGetChildren(); final List<ICElement> children= getElementInfo(fTranslationUnit).internalGetChildren();
Collections.sort(children, new Comparator<ICElement>() { Collections.sort(children, new Comparator<ICElement>() {
@Override
public int compare(ICElement o1, ICElement o2) { public int compare(ICElement o1, ICElement o2) {
final SourceManipulationInfo info1= getSourceManipulationInfo((SourceManipulation) o1); final SourceManipulationInfo info1= getSourceManipulationInfo((SourceManipulation) o1);
final SourceManipulationInfo info2= getSourceManipulationInfo((SourceManipulation) o2); final SourceManipulationInfo info2= getSourceManipulationInfo((SourceManipulation) o2);
@ -589,7 +591,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
final Enumeration element= new Enumeration (parent, enumName); final Enumeration element= new Enumeration (parent, enumName);
setIndex(element); setIndex(element);
element.setActive(enumSpecifier.isActive()); element.setActive(enumSpecifier.isActive());
// add to parent // add to parent
parent.addChild(element); parent.addChild(element);
EnumerationInfo info= (EnumerationInfo) getElementInfo(element); EnumerationInfo info= (EnumerationInfo) getElementInfo(element);
@ -600,7 +602,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
final IASTFileLocation enumLocation= enumSpecifier.getFileLocation(); final IASTFileLocation enumLocation= enumSpecifier.getFileLocation();
info.setIdPos(enumLocation.getNodeOffset(), type.length()); info.setIdPos(enumLocation.getNodeOffset(), type.length());
} }
// add enumerators // add enumerators
final IASTEnumerator[] enumerators= enumSpecifier.getEnumerators(); final IASTEnumerator[] enumerators= enumSpecifier.getEnumerators();
for (final IASTEnumerator enumerator : enumerators) { for (final IASTEnumerator enumerator : enumerators) {
createEnumerator(element, enumerator); createEnumerator(element, enumerator);
@ -967,7 +969,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
element.setParameterTypes(parameterTypes); element.setParameterTypes(parameterTypes);
element.setReturnType(returnType); element.setReturnType(returnType);
setIndex(element); setIndex(element);
info= (FunctionInfo) getElementInfo(element); info= (FunctionInfo) getElementInfo(element);
info.setConst(cppFunctionDeclarator.isConst()); info.setConst(cppFunctionDeclarator.isConst());
} }
@ -978,7 +980,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
element.setParameterTypes(parameterTypes); element.setParameterTypes(parameterTypes);
element.setReturnType(returnType); element.setReturnType(returnType);
setIndex(element); setIndex(element);
info= (FunctionInfo) getElementInfo(element); info= (FunctionInfo) getElementInfo(element);
} }
element.setActive(functionDeclaration.isActive()); element.setActive(functionDeclaration.isActive());
@ -1053,7 +1055,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
element.setParameterTypes(parameterTypes); element.setParameterTypes(parameterTypes);
element.setReturnType(returnType); element.setReturnType(returnType);
setIndex(element); setIndex(element);
info= (FunctionInfo)getElementInfo(element); info= (FunctionInfo)getElementInfo(element);
info.setConst(cppFunctionDeclarator.isConst()); info.setConst(cppFunctionDeclarator.isConst());
} }
@ -1073,7 +1075,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
return null; return null;
} }
element.setActive(declarator.isActive()); element.setActive(declarator.isActive());
// TODO [cmodel] correctly resolve isStatic // TODO [cmodel] correctly resolve isStatic
info.setStatic(declSpecifier.getStorageClass() == IASTDeclSpecifier.sc_static); info.setStatic(declSpecifier.getStorageClass() == IASTDeclSpecifier.sc_static);
@ -1281,7 +1283,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
/** /**
* Determine the scope for given name. * Determine the scope for given name.
* *
* @param astName * @param astName
* @return the scope or <code>null</code> * @return the scope or <code>null</code>
*/ */

View file

@ -230,7 +230,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
} }
if (res != null && !res.exists()) { if (res != null && !res.exists()) {
res = null; res = null;
} }
} }
// In case this is an external resource see if we can find // In case this is an external resource see if we can find
@ -343,7 +343,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
break; break;
} }
} }
// check for binary on output entry // check for binary on output entry
if (celement == null && cproject.isOnOutputEntry(file)) { if (celement == null && cproject.isOnOutputEntry(file)) {
IBinaryFile bin = createBinaryFile(file); IBinaryFile bin = createBinaryFile(file);
@ -371,12 +371,12 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
if (cproject.isOnOutputEntry(file)) { if (cproject.isOnOutputEntry(file)) {
IPath resourcePath = file.getParent().getFullPath(); IPath resourcePath = file.getParent().getFullPath();
ICElement cfolder = cproject.findElement(resourcePath); ICElement cfolder = cproject.findElement(resourcePath);
// Check if folder is a source root and use that instead // Check if folder is a source root and use that instead
ISourceRoot sourceRoot = cproject.findSourceRoot(resourcePath); ISourceRoot sourceRoot = cproject.findSourceRoot(resourcePath);
if (sourceRoot != null) if (sourceRoot != null)
cfolder = sourceRoot; cfolder = sourceRoot;
if (bin.getType() == IBinaryFile.ARCHIVE) { if (bin.getType() == IBinaryFile.ARCHIVE) {
ArchiveContainer vlib = (ArchiveContainer)cproject.getArchiveContainer(); ArchiveContainer vlib = (ArchiveContainer)cproject.getArchiveContainer();
celement = new Archive(cfolder, file, (IBinaryArchive)bin); celement = new Archive(cfolder, file, (IBinaryArchive)bin);
@ -405,7 +405,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
if (!Util.isNonZeroLengthFile(path)) { if (!Util.isNonZeroLengthFile(path)) {
return null; return null;
} }
try { try {
IIncludeReference[] includeReferences = cproject.getIncludeReferences(); IIncludeReference[] includeReferences = cproject.getIncludeReferences();
for (IIncludeReference includeReference : includeReferences) { for (IIncludeReference includeReference : includeReferences) {
@ -414,7 +414,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
if (headerContentTypeId == null) { if (headerContentTypeId == null) {
headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER; headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
} }
// TODO: use URI // TODO: use URI
return new ExternalTranslationUnit(includeReference, URIUtil.toURI(path), headerContentTypeId); return new ExternalTranslationUnit(includeReference, URIUtil.toURI(path), headerContentTypeId);
} }
@ -439,7 +439,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
if (headerContentTypeId == null) { if (headerContentTypeId == null) {
headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER; headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
} }
// TODO: use URI // TODO: use URI
return new ExternalTranslationUnit(includeReference, URIUtil.toURI(includePath), headerContentTypeId); return new ExternalTranslationUnit(includeReference, URIUtil.toURI(includePath), headerContentTypeId);
} }
@ -449,10 +449,10 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
} }
return null; return null;
} }
/** /**
* Creates a translation unit in the given project for the given location. * Creates a translation unit in the given project for the given location.
* *
* @param cproject * @param cproject
* @param locationURI * @param locationURI
* @return ITranslationUnit * @return ITranslationUnit
@ -465,9 +465,9 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
if(!locationURI.isAbsolute()) { if(!locationURI.isAbsolute()) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
final IProject project= cproject.getProject(); final IProject project= cproject.getProject();
IFileStore fileStore = null; IFileStore fileStore = null;
try { try {
fileStore = EFS.getStore(locationURI); fileStore = EFS.getStore(locationURI);
@ -475,12 +475,12 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
CCorePlugin.log(e1); CCorePlugin.log(e1);
return null; return null;
} }
final String contentTypeId = CoreModel.getRegistedContentTypeId(project, fileStore.getName()); final String contentTypeId = CoreModel.getRegistedContentTypeId(project, fileStore.getName());
if (!Util.isNonZeroLengthFile(locationURI)) { if (!Util.isNonZeroLengthFile(locationURI)) {
return null; return null;
} }
try { try {
IIncludeReference[] includeReferences = cproject.getIncludeReferences(); IIncludeReference[] includeReferences = cproject.getIncludeReferences();
for (IIncludeReference includeReference : includeReferences) { for (IIncludeReference includeReference : includeReferences) {
@ -492,7 +492,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
if (headerContentTypeId == null) { if (headerContentTypeId == null) {
headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER; headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
} }
return new ExternalTranslationUnit(includeReference, locationURI, headerContentTypeId); return new ExternalTranslationUnit(includeReference, locationURI, headerContentTypeId);
} }
} }
@ -502,11 +502,11 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
// if the file exists and it has a known C/C++ file extension then just create // if the file exists and it has a known C/C++ file extension then just create
// an external translation unit for it. // an external translation unit for it.
IFileInfo info = fileStore.fetchInfo(); IFileInfo info = fileStore.fetchInfo();
if (contentTypeId != null && info != null && info.exists()) { if (contentTypeId != null && info != null && info.exists()) {
return new ExternalTranslationUnit(cproject, locationURI, contentTypeId); return new ExternalTranslationUnit(cproject, locationURI, contentTypeId);
} }
return null; return null;
} }
@ -632,7 +632,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
if (parsers.length == 0) { if (parsers.length == 0) {
return null; return null;
} }
// Only if file has no extension, has an extension that is an integer // Only if file has no extension, has an extension that is an integer
// or is a binary file content type // or is a binary file content type
String ext = file.getFileExtension(); String ext = file.getFileExtension();
@ -650,7 +650,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
baseFileName = baseFileName.removeFileExtension(); baseFileName = baseFileName.removeFileExtension();
ext = baseFileName.getFileExtension(); ext = baseFileName.getFileExtension();
} while (ext != null && ext.length() > 0); } while (ext != null && ext.length() > 0);
boolean isBinary= false; boolean isBinary= false;
final IContentTypeManager ctm = Platform.getContentTypeManager(); final IContentTypeManager ctm = Platform.getContentTypeManager();
final IContentType ctbin = ctm.getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE); final IContentType ctbin = ctm.getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE);
@ -662,7 +662,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
return null; return null;
} }
} }
URI fileUri = file.getLocationURI(); URI fileUri = file.getLocationURI();
//Avoid name special devices, empty files and the like //Avoid name special devices, empty files and the like
if (!Util.isNonZeroLengthFile(fileUri)) { if (!Util.isNonZeroLengthFile(fileUri)) {
@ -677,9 +677,9 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
} }
//return null; //return null;
} }
int hints = 0; int hints = 0;
for (BinaryParserConfig parser2 : parsers) { for (BinaryParserConfig parser2 : parsers) {
IBinaryParser parser = null; IBinaryParser parser = null;
try { try {
@ -850,10 +850,11 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
* on the platform, and that the C Model should update any required * on the platform, and that the C Model should update any required
* internal structures such that its elements remain consistent. * internal structures such that its elements remain consistent.
* Translates <code>IResourceDeltas</code> into <code>ICElementDeltas</code>. * Translates <code>IResourceDeltas</code> into <code>ICElementDeltas</code>.
* *
* @see IResourceDelta * @see IResourceDelta
* @see IResource * @see IResource
*/ */
@Override
public void resourceChanged(IResourceChangeEvent event) { public void resourceChanged(IResourceChangeEvent event) {
if (event.getSource() instanceof IWorkspace) { if (event.getSource() instanceof IWorkspace) {
IResourceDelta delta = event.getDelta(); IResourceDelta delta = event.getDelta();
@ -861,7 +862,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
switch (event.getType()) { switch (event.getType()) {
case IResourceChangeEvent.PRE_DELETE: case IResourceChangeEvent.PRE_DELETE:
try { try {
if (resource.getType() == IResource.PROJECT && if (resource.getType() == IResource.PROJECT &&
( ((IProject)resource).hasNature(CProjectNature.C_NATURE_ID) || ( ((IProject)resource).hasNature(CProjectNature.C_NATURE_ID) ||
((IProject)resource).hasNature(CCProjectNature.CC_NATURE_ID) )){ ((IProject)resource).hasNature(CCProjectNature.CC_NATURE_ID) )){
this.preDeleteProject((IProject) resource);} this.preDeleteProject((IProject) resource);}
@ -871,7 +872,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
case IResourceChangeEvent.PRE_CLOSE: case IResourceChangeEvent.PRE_CLOSE:
try { try {
if (resource.getType() == IResource.PROJECT && if (resource.getType() == IResource.PROJECT &&
( ((IProject)resource).hasNature(CProjectNature.C_NATURE_ID) || ( ((IProject)resource).hasNature(CProjectNature.C_NATURE_ID) ||
((IProject)resource).hasNature(CCProjectNature.CC_NATURE_ID) )){ ((IProject)resource).hasNature(CCProjectNature.CC_NATURE_ID) )){
this.preCloseProject((IProject) resource);} this.preCloseProject((IProject) resource);}
@ -899,6 +900,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
} }
} }
@Override
public void handleEvent(CProjectDescriptionEvent event) { public void handleEvent(CProjectDescriptionEvent event) {
switch(event.getEventType()) { switch(event.getEventType()) {
case CProjectDescriptionEvent.APPLIED: case CProjectDescriptionEvent.APPLIED:
@ -961,6 +963,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.core.runtime.content.IContentTypeManager.IContentTypeListener#contentTypeChanged() * @see org.eclipse.core.runtime.content.IContentTypeManager.IContentTypeListener#contentTypeChanged()
*/ */
@Override
public void contentTypeChanged(ContentTypeChangeEvent event) { public void contentTypeChanged(ContentTypeChangeEvent event) {
ContentTypeProcessor.processContentTypeChanges(new ContentTypeChangeEvent[]{ event }); ContentTypeProcessor.processContentTypeChanges(new ContentTypeChangeEvent[]{ event });
} }
@ -975,12 +978,12 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
public void fireShift(ICElement element, int offset, int size, int lines) { public void fireShift(ICElement element, int offset, int size, int lines) {
ICElementDelta delta = new CShiftData(element, offset, size, lines); ICElementDelta delta = new CShiftData(element, offset, size, lines);
fire(delta, ElementChangedEvent.POST_SHIFT); fire(delta, ElementChangedEvent.POST_SHIFT);
} }
/** /**
* Fire C Model deltas, flushing them after the fact. * Fire C Model deltas, flushing them after the fact.
* If the firing mode has been turned off, this has no effect. * If the firing mode has been turned off, this has no effect.
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
void fire(ICElementDelta customDeltas, int eventType) { void fire(ICElementDelta customDeltas, int eventType) {
@ -1077,7 +1080,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
notifyListeners(deltaToNotify, ElementChangedEvent.POST_SHIFT, listeners, listenerMask, listenerCount); notifyListeners(deltaToNotify, ElementChangedEvent.POST_SHIFT, listeners, listenerMask, listenerCount);
} }
} }
public void notifyListeners(ICElementDelta deltaToNotify, int eventType, public void notifyListeners(ICElementDelta deltaToNotify, int eventType,
IElementChangedListener[] listeners, int[] listenerMask, int listenerCount) { IElementChangedListener[] listeners, int[] listenerMask, int listenerCount) {
@ -1093,10 +1096,12 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
// wrap callbacks with Safe runnable for subsequent listeners to be called when some are causing grief // wrap callbacks with Safe runnable for subsequent listeners to be called when some are causing grief
SafeRunner.run(new ISafeRunnable() { SafeRunner.run(new ISafeRunnable() {
@Override
public void handleException(Throwable exception) { public void handleException(Throwable exception) {
//CCorePlugin.log(exception, "Exception occurred in listener of C element change notification"); //$NON-NLS-1$ //CCorePlugin.log(exception, "Exception occurred in listener of C element change notification"); //$NON-NLS-1$
CCorePlugin.log(exception); CCorePlugin.log(exception);
} }
@Override
public void run() throws Exception { public void run() throws Exception {
listener.elementChanged(extraEvent); listener.elementChanged(extraEvent);
} }
@ -1192,7 +1197,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
/* /*
* Puts the infos in the given map (keys are ICElements and values are CElementInfos) * Puts the infos in the given map (keys are ICElements and values are CElementInfos)
* in the C model cache in an atomic way. * in the C model cache in an atomic way.
* First checks that the info for the opened element (or one of its ancestors) has not been * First checks that the info for the opened element (or one of its ancestors) has not been
* added to the cache. If it is the case, another thread has opened the element (or one of * added to the cache. If it is the case, another thread has opened the element (or one of
* its ancestors). So returns without updating the cache. * its ancestors). So returns without updating the cache.
*/ */
@ -1306,10 +1311,10 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
movedTo= delta.getMovedToPath(); movedTo= delta.getMovedToPath();
} }
LocalProjectScope.deletePreferences(res.getFullPath(), movedTo); LocalProjectScope.deletePreferences(res.getFullPath(), movedTo);
} }
} }
} }
private void preDeleteProject(IProject project) { private void preDeleteProject(IProject project) {
// remove binary parsers // remove binary parsers
binaryParsersMap.remove(project); binaryParsersMap.remove(project);

View file

@ -198,6 +198,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
/** /**
* @see IProgressMonitor * @see IProgressMonitor
*/ */
@Override
public void beginTask(String name, int totalWork) { public void beginTask(String name, int totalWork) {
if (fMonitor != null) { if (fMonitor != null) {
fMonitor.beginTask(name, totalWork); fMonitor.beginTask(name, totalWork);
@ -320,6 +321,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
/** /**
* @see IProgressMonitor * @see IProgressMonitor
*/ */
@Override
public void done() { public void done() {
if (fMonitor != null) { if (fMonitor != null) {
fMonitor.done(); fMonitor.done();
@ -436,7 +438,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
} }
/** /**
* Returns the scheduling rule for this operation (i.e. the resource that needs to be locked * Returns the scheduling rule for this operation (i.e. the resource that needs to be locked
* while this operation is running. * while this operation is running.
* Subclasses can override. * Subclasses can override.
*/ */
@ -477,6 +479,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
return !this.isReadOnly() && this.hasModifiedResource; return !this.isReadOnly() && this.hasModifiedResource;
} }
@Override
public void internalWorked(double work) { public void internalWorked(double work) {
if (fMonitor != null) { if (fMonitor != null) {
fMonitor.internalWorked(work); fMonitor.internalWorked(work);
@ -486,6 +489,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
/** /**
* @see IProgressMonitor * @see IProgressMonitor
*/ */
@Override
public boolean isCanceled() { public boolean isCanceled() {
if (fMonitor != null) { if (fMonitor != null) {
return fMonitor.isCanceled(); return fMonitor.isCanceled();
@ -543,7 +547,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
/* /*
* Returns the stack of operations running in the current thread. * Returns the stack of operations running in the current thread.
* Returns an empty stack if no operations are currently running in this thread. * Returns an empty stack if no operations are currently running in this thread.
*/ */
protected ArrayList<CModelOperation> getCurrentOperationStack() { protected ArrayList<CModelOperation> getCurrentOperationStack() {
ArrayList<CModelOperation> stack = operationStacks.get(); ArrayList<CModelOperation> stack = operationStacks.get();
@ -562,7 +566,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
ArrayList<CModelOperation> stack = getCurrentOperationStack(); ArrayList<CModelOperation> stack = getCurrentOperationStack();
int size = stack.size(); int size = stack.size();
if (size > 0) { if (size > 0) {
if (size == 1) { // top level operation if (size == 1) { // top level operation
operationStacks.set(null); // release reference (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=33927) operationStacks.set(null); // release reference (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=33927)
} }
return stack.remove(size-1); return stack.remove(size-1);
@ -593,6 +597,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
* @see IWorkspaceRunnable * @see IWorkspaceRunnable
* @exception CoreException if the operation fails * @exception CoreException if the operation fails
*/ */
@Override
public void run(IProgressMonitor monitor) throws CoreException { public void run(IProgressMonitor monitor) throws CoreException {
CModelManager manager= CModelManager.getDefault(); CModelManager manager= CModelManager.getDefault();
int previousDeltaCount = manager.fCModelDeltas.size(); int previousDeltaCount = manager.fCModelDeltas.size();
@ -649,6 +654,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
/** /**
* @see IProgressMonitor * @see IProgressMonitor
*/ */
@Override
public void setCanceled(boolean b) { public void setCanceled(boolean b) {
if (fMonitor != null) { if (fMonitor != null) {
fMonitor.setCanceled(b); fMonitor.setCanceled(b);
@ -666,6 +672,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
/** /**
* @see IProgressMonitor * @see IProgressMonitor
*/ */
@Override
public void setTaskName(String name) { public void setTaskName(String name) {
if (fMonitor != null) { if (fMonitor != null) {
fMonitor.setTaskName(name); fMonitor.setTaskName(name);
@ -675,6 +682,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
/** /**
* @see IProgressMonitor * @see IProgressMonitor
*/ */
@Override
public void subTask(String name) { public void subTask(String name) {
if (fMonitor != null) { if (fMonitor != null) {
fMonitor.subTask(name); fMonitor.subTask(name);
@ -698,6 +706,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
/** /**
* @see IProgressMonitor * @see IProgressMonitor
*/ */
@Override
public void worked(int work) { public void worked(int work) {
if (fMonitor != null) { if (fMonitor != null) {
fMonitor.worked(work); fMonitor.worked(work);

View file

@ -157,6 +157,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
/** /**
* @see ICModelStatus * @see ICModelStatus
*/ */
@Override
public ICElement[] getElements() { public ICElement[] getElements() {
return fElements; return fElements;
} }
@ -289,6 +290,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
return exception.toString(); return exception.toString();
} }
@Override
public IPath getPath() { public IPath getPath() {
if (fPath == null) { if (fPath == null) {
return Path.EMPTY; return Path.EMPTY;
@ -316,6 +318,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
/** /**
* @see ICModelStatus * @see ICModelStatus
*/ */
@Override
public String getString() { public String getString() {
if (fString == null) { if (fString == null) {
return EMPTY_STRING; return EMPTY_STRING;
@ -333,6 +336,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
/** /**
* @see ICModelStatus * @see ICModelStatus
*/ */
@Override
public boolean doesNotExist() { public boolean doesNotExist() {
return getCode() == ELEMENT_DOES_NOT_EXIST; return getCode() == ELEMENT_DOES_NOT_EXIST;
} }
@ -381,7 +385,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
/** /**
* Creates and returns a new <code>ICModelStatus</code> that is a a * Creates and returns a new <code>ICModelStatus</code> that is a a
* multi-status status. * multi-status status.
* *
* @see IStatus#isMultiStatus() * @see IStatus#isMultiStatus()
*/ */
public static ICModelStatus newMultiStatus(ICModelStatus[] children) { public static ICModelStatus newMultiStatus(ICModelStatus[] children) {

View file

@ -72,18 +72,22 @@ public class CProject extends Openable implements ICProject {
super(parent, project, ICElement.C_PROJECT); super(parent, project, ICElement.C_PROJECT);
} }
@Override
public IBinaryContainer getBinaryContainer() throws CModelException { public IBinaryContainer getBinaryContainer() throws CModelException {
return ((CProjectInfo) getElementInfo()).getBinaryContainer(); return ((CProjectInfo) getElementInfo()).getBinaryContainer();
} }
@Override
public IArchiveContainer getArchiveContainer() throws CModelException { public IArchiveContainer getArchiveContainer() throws CModelException {
return ((CProjectInfo) getElementInfo()).getArchiveContainer(); return ((CProjectInfo) getElementInfo()).getArchiveContainer();
} }
@Override
public IProject getProject() { public IProject getProject() {
return getUnderlyingResource().getProject(); return getUnderlyingResource().getProject();
} }
@Override
public ICElement findElement(IPath path) throws CModelException { public ICElement findElement(IPath path) throws CModelException {
ICElement celem = null; ICElement celem = null;
if (path.isAbsolute()) { if (path.isAbsolute()) {
@ -134,13 +138,13 @@ public class CProject extends Openable implements ICProject {
*/ */
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) if (this == o)
return true; return true;
if (!(o instanceof CProject)) if (!(o instanceof CProject))
return false; return false;
CProject other = (CProject) o; CProject other = (CProject) o;
return getProject().equals(other.getProject()); return getProject().equals(other.getProject());
} }
@ -156,6 +160,7 @@ public class CProject extends Openable implements ICProject {
return getProject().hashCode(); return getProject().hashCode();
} }
@Override
public IIncludeReference[] getIncludeReferences() throws CModelException { public IIncludeReference[] getIncludeReferences() throws CModelException {
CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this); CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this);
IIncludeReference[] incRefs = null; IIncludeReference[] incRefs = null;
@ -179,6 +184,7 @@ public class CProject extends Openable implements ICProject {
return incRefs; return incRefs;
} }
@Override
public ILibraryReference[] getLibraryReferences() throws CModelException { public ILibraryReference[] getLibraryReferences() throws CModelException {
CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this); CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this);
ILibraryReference[] libRefs = null; ILibraryReference[] libRefs = null;
@ -240,6 +246,7 @@ public class CProject extends Openable implements ICProject {
/** /**
* @see ICProject#getRequiredProjectNames() * @see ICProject#getRequiredProjectNames()
*/ */
@Override
public String[] getRequiredProjectNames() throws CModelException { public String[] getRequiredProjectNames() throws CModelException {
return projectPrerequisites(getResolvedPathEntries()); return projectPrerequisites(getResolvedPathEntries());
} }
@ -252,6 +259,7 @@ public class CProject extends Openable implements ICProject {
/** /**
* @see org.eclipse.cdt.core.model.ICProject#getOption(String, boolean) * @see org.eclipse.cdt.core.model.ICProject#getOption(String, boolean)
*/ */
@Override
public String getOption(String optionName, boolean inheritCCoreOptions) { public String getOption(String optionName, boolean inheritCCoreOptions) {
if (CModelManager.OptionNames.contains(optionName)) { if (CModelManager.OptionNames.contains(optionName)) {
IEclipsePreferences preferences = getPreferences(); IEclipsePreferences preferences = getPreferences();
@ -269,6 +277,7 @@ public class CProject extends Openable implements ICProject {
/** /**
* @see org.eclipse.cdt.core.model.ICProject#getOptions(boolean) * @see org.eclipse.cdt.core.model.ICProject#getOptions(boolean)
*/ */
@Override
public Map<String, String> getOptions(boolean inheritCCoreOptions) { public Map<String, String> getOptions(boolean inheritCCoreOptions) {
// initialize to the defaults from CCorePlugin options pool // initialize to the defaults from CCorePlugin options pool
Map<String, String> options= inheritCCoreOptions ? CCorePlugin.getOptions() : new HashMap<String, String>(5); Map<String, String> options= inheritCCoreOptions ? CCorePlugin.getOptions() : new HashMap<String, String>(5);
@ -296,6 +305,7 @@ public class CProject extends Openable implements ICProject {
/** /**
* @see org.eclipse.cdt.core.model.ICProject#setOption(java.lang.String, java.lang.String) * @see org.eclipse.cdt.core.model.ICProject#setOption(java.lang.String, java.lang.String)
*/ */
@Override
public void setOption(String optionName, String optionValue) { public void setOption(String optionName, String optionValue) {
if (!CModelManager.OptionNames.contains(optionName)) if (!CModelManager.OptionNames.contains(optionName))
return; // unrecognized option return; // unrecognized option
@ -307,7 +317,7 @@ public class CProject extends Openable implements ICProject {
} else { } else {
projectPreferences.put(optionName, optionValue); projectPreferences.put(optionName, optionValue);
} }
// Dump changes // Dump changes
try { try {
projectPreferences.flush(); projectPreferences.flush();
@ -319,6 +329,7 @@ public class CProject extends Openable implements ICProject {
/** /**
* @see org.eclipse.cdt.core.model.ICProject#setOptions(Map) * @see org.eclipse.cdt.core.model.ICProject#setOptions(Map)
*/ */
@Override
public void setOptions(Map<String, String> newOptions) { public void setOptions(Map<String, String> newOptions) {
Preferences preferences = new Preferences(); Preferences preferences = new Preferences();
setPreferences(preferences); // always reset (26255) setPreferences(preferences); // always reset (26255)
@ -397,6 +408,7 @@ public class CProject extends Openable implements ICProject {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICProject#getResolvedCPathEntries() * @see org.eclipse.cdt.core.model.ICProject#getResolvedCPathEntries()
*/ */
@Override
public IPathEntry[] getResolvedPathEntries() throws CModelException { public IPathEntry[] getResolvedPathEntries() throws CModelException {
return CoreModel.getResolvedPathEntries(this); return CoreModel.getResolvedPathEntries(this);
} }
@ -404,6 +416,7 @@ public class CProject extends Openable implements ICProject {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICProject#getRawCPathEntries() * @see org.eclipse.cdt.core.model.ICProject#getRawCPathEntries()
*/ */
@Override
public IPathEntry[] getRawPathEntries() throws CModelException { public IPathEntry[] getRawPathEntries() throws CModelException {
return CoreModel.getRawPathEntries(this); return CoreModel.getRawPathEntries(this);
} }
@ -411,6 +424,7 @@ public class CProject extends Openable implements ICProject {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICProject#setRawCPathEntries(org.eclipse.cdt.core.model.IPathEntry[], org.eclipse.core.runtime.IProgressMonitor) * @see org.eclipse.cdt.core.model.ICProject#setRawCPathEntries(org.eclipse.cdt.core.model.IPathEntry[], org.eclipse.core.runtime.IProgressMonitor)
*/ */
@Override
public void setRawPathEntries(IPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException { public void setRawPathEntries(IPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException {
CoreModel.setRawPathEntries(this, newEntries, monitor); CoreModel.setRawPathEntries(this, newEntries, monitor);
} }
@ -418,6 +432,7 @@ public class CProject extends Openable implements ICProject {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICProject#getSourceRoot(org.eclipse.cdt.core.model.ISourceEntry) * @see org.eclipse.cdt.core.model.ICProject#getSourceRoot(org.eclipse.cdt.core.model.ISourceEntry)
*/ */
@Override
public ISourceRoot getSourceRoot(ISourceEntry entry) throws CModelException { public ISourceRoot getSourceRoot(ISourceEntry entry) throws CModelException {
return getSourceRoot(new CSourceEntry(entry.getPath(), entry.getExclusionPatterns(), 0)); return getSourceRoot(new CSourceEntry(entry.getPath(), entry.getExclusionPatterns(), 0));
} }
@ -444,6 +459,7 @@ public class CProject extends Openable implements ICProject {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICProject#findSourceRoot() * @see org.eclipse.cdt.core.model.ICProject#findSourceRoot()
*/ */
@Override
public ISourceRoot findSourceRoot(IResource res) { public ISourceRoot findSourceRoot(IResource res) {
try { try {
ISourceRoot[] roots = getAllSourceRoots(); ISourceRoot[] roots = getAllSourceRoots();
@ -460,6 +476,7 @@ public class CProject extends Openable implements ICProject {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICProject#findSourceRoot() * @see org.eclipse.cdt.core.model.ICProject#findSourceRoot()
*/ */
@Override
public ISourceRoot findSourceRoot(IPath path) { public ISourceRoot findSourceRoot(IPath path) {
try { try {
ISourceRoot[] roots = getAllSourceRoots(); ISourceRoot[] roots = getAllSourceRoots();
@ -472,10 +489,11 @@ public class CProject extends Openable implements ICProject {
} }
return null; return null;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICProject#getSourceRoots() * @see org.eclipse.cdt.core.model.ICProject#getSourceRoots()
*/ */
@Override
public ISourceRoot[] getSourceRoots() throws CModelException { public ISourceRoot[] getSourceRoots() throws CModelException {
Object[] children = getChildren(); Object[] children = getChildren();
ArrayList<ISourceRoot> result = new ArrayList<ISourceRoot>(children.length); ArrayList<ISourceRoot> result = new ArrayList<ISourceRoot>(children.length);
@ -489,10 +507,11 @@ public class CProject extends Openable implements ICProject {
/** /**
* Get all source roots. * Get all source roots.
* *
* @return all source roots * @return all source roots
* @throws CModelException * @throws CModelException
*/ */
@Override
public ISourceRoot[] getAllSourceRoots() throws CModelException { public ISourceRoot[] getAllSourceRoots() throws CModelException {
CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this); CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this);
ISourceRoot[] roots = null; ISourceRoot[] roots = null;
@ -510,6 +529,7 @@ public class CProject extends Openable implements ICProject {
return roots; return roots;
} }
@Override
public IOutputEntry[] getOutputEntries() throws CModelException { public IOutputEntry[] getOutputEntries() throws CModelException {
CProjectInfo pinfo = (CProjectInfo) CModelManager.getDefault().peekAtInfo(this); CProjectInfo pinfo = (CProjectInfo) CModelManager.getDefault().peekAtInfo(this);
IOutputEntry[] outs = null; IOutputEntry[] outs = null;
@ -528,7 +548,7 @@ public class CProject extends Openable implements ICProject {
} }
/** /**
* *
*/ */
public IOutputEntry[] getOutputEntries(IPathEntry[] entries) throws CModelException { public IOutputEntry[] getOutputEntries(IPathEntry[] entries) throws CModelException {
ArrayList<IPathEntry> list = new ArrayList<IPathEntry>(entries.length); ArrayList<IPathEntry> list = new ArrayList<IPathEntry>(entries.length);
@ -543,11 +563,12 @@ public class CProject extends Openable implements ICProject {
} }
/** /**
* *
*/ */
@Override
public boolean isOnOutputEntry(IResource resource) { public boolean isOnOutputEntry(IResource resource) {
IPath path = resource.getFullPath(); IPath path = resource.getFullPath();
// ensure that folders are only excluded if all of their children are excluded // ensure that folders are only excluded if all of their children are excluded
if (resource.getType() == IResource.FOLDER || resource.getType() == IResource.PROJECT) { if (resource.getType() == IResource.FOLDER || resource.getType() == IResource.PROJECT) {
path = path.append("*"); //$NON-NLS-1$ path = path.append("*"); //$NON-NLS-1$
@ -606,7 +627,7 @@ public class CProject extends Openable implements ICProject {
if(cfg != null) if(cfg != null)
entries = cfg.getResolvedSourceEntries(); entries = cfg.getResolvedSourceEntries();
} }
if(entries != null){ if(entries != null){
ArrayList<ISourceRoot> list = new ArrayList<ISourceRoot>(entries.length); ArrayList<ISourceRoot> list = new ArrayList<ISourceRoot>(entries.length);
for (ICSourceEntry sourceEntry : entries) { for (ICSourceEntry sourceEntry : entries) {
@ -624,14 +645,14 @@ public class CProject extends Openable implements ICProject {
List<ISourceRoot> sourceRoots = computeSourceRoots(); List<ISourceRoot> sourceRoots = computeSourceRoots();
List<ICContainer> children = new ArrayList<ICContainer>(sourceRoots.size()); List<ICContainer> children = new ArrayList<ICContainer>(sourceRoots.size());
children.addAll(sourceRoots); children.addAll(sourceRoots);
boolean projectIsSourceRoot = false; boolean projectIsSourceRoot = false;
for (ISourceRoot sourceRoot : sourceRoots) for (ISourceRoot sourceRoot : sourceRoots)
if (sourceRoot.getResource().equals(getProject())) { if (sourceRoot.getResource().equals(getProject())) {
projectIsSourceRoot = true; projectIsSourceRoot = true;
break; break;
} }
// Now look for output folders // Now look for output folders
try { try {
IResource[] resources = getProject().members(); IResource[] resources = getProject().members();
@ -644,7 +665,7 @@ public class CProject extends Openable implements ICProject {
break; break;
} }
} }
// Not in source folder, check if it's a container on output entry // Not in source folder, check if it's a container on output entry
// Also make sure I'm not a source root since my SourceRoot object would // Also make sure I'm not a source root since my SourceRoot object would
// have already added this. // have already added this.
@ -655,7 +676,7 @@ public class CProject extends Openable implements ICProject {
} catch (CoreException e) { } catch (CoreException e) {
// ignore // ignore
} }
info.setChildren(children); info.setChildren(children);
if (info instanceof CProjectInfo) { if (info instanceof CProjectInfo) {
CProjectInfo pinfo = (CProjectInfo)info; CProjectInfo pinfo = (CProjectInfo)info;
@ -664,10 +685,11 @@ public class CProject extends Openable implements ICProject {
} }
return true; return true;
} }
/* /*
* @see ICProject * @see ICProject
*/ */
@Override
public boolean isOnSourceRoot(ICElement element) { public boolean isOnSourceRoot(ICElement element) {
try { try {
ISourceRoot[] roots = getSourceRoots(); ISourceRoot[] roots = getSourceRoots();
@ -685,6 +707,7 @@ public class CProject extends Openable implements ICProject {
/* /*
* @see ICProject * @see ICProject
*/ */
@Override
public boolean isOnSourceRoot(IResource resource) { public boolean isOnSourceRoot(IResource resource) {
try { try {
ISourceRoot[] roots = getSourceRoots(); ISourceRoot[] roots = getSourceRoots();
@ -713,6 +736,7 @@ public class CProject extends Openable implements ICProject {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICProject#getNonCResources() * @see org.eclipse.cdt.core.model.ICProject#getNonCResources()
*/ */
@Override
public Object[] getNonCResources() throws CModelException { public Object[] getNonCResources() throws CModelException {
return ((CProjectInfo) getElementInfo()).getNonCResources(getResource()); return ((CProjectInfo) getElementInfo()).getNonCResources(getResource());
} }

View file

@ -17,7 +17,7 @@ import org.eclipse.core.resources.IResourceDelta;
/** /**
* In this case, no delta for specific element passed * In this case, no delta for specific element passed
* Instead we'll notify Outline about offsets change. * Instead we'll notify Outline about offsets change.
* *
* @author Oleg Krasilnikov * @author Oleg Krasilnikov
*/ */
public class CShiftData implements ICElementDelta { public class CShiftData implements ICElementDelta {
@ -26,7 +26,7 @@ public class CShiftData implements ICElementDelta {
private final int offset; private final int offset;
private final int size; private final int size;
private final int lines; private final int lines;
public CShiftData(ICElement element, int offset, int size, int lines) { public CShiftData(ICElement element, int offset, int size, int lines) {
this.element = element; this.element = element;
this.offset = offset; this.offset = offset;
@ -37,18 +37,19 @@ public class CShiftData implements ICElementDelta {
public int getOffset() { public int getOffset() {
return offset; return offset;
} }
public int getSize() { public int getSize() {
return size; return size;
} }
public int getLines() { public int getLines() {
return lines; return lines;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICElementDelta#getAddedChildren() * @see org.eclipse.cdt.core.model.ICElementDelta#getAddedChildren()
*/ */
@Override
public ICElementDelta[] getAddedChildren() { public ICElementDelta[] getAddedChildren() {
return new ICElementDelta[0]; return new ICElementDelta[0];
} }
@ -56,6 +57,7 @@ public class CShiftData implements ICElementDelta {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICElementDelta#getAffectedChildren() * @see org.eclipse.cdt.core.model.ICElementDelta#getAffectedChildren()
*/ */
@Override
public ICElementDelta[] getAffectedChildren() { public ICElementDelta[] getAffectedChildren() {
return new ICElementDelta[0]; return new ICElementDelta[0];
} }
@ -63,6 +65,7 @@ public class CShiftData implements ICElementDelta {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICElementDelta#getChangedChildren() * @see org.eclipse.cdt.core.model.ICElementDelta#getChangedChildren()
*/ */
@Override
public ICElementDelta[] getChangedChildren() { public ICElementDelta[] getChangedChildren() {
return new ICElementDelta[0]; return new ICElementDelta[0];
} }
@ -70,6 +73,7 @@ public class CShiftData implements ICElementDelta {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICElementDelta#getElement() * @see org.eclipse.cdt.core.model.ICElementDelta#getElement()
*/ */
@Override
public ICElement getElement() { public ICElement getElement() {
return element; return element;
} }
@ -77,6 +81,7 @@ public class CShiftData implements ICElementDelta {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICElementDelta#getFlags() * @see org.eclipse.cdt.core.model.ICElementDelta#getFlags()
*/ */
@Override
public int getFlags() { public int getFlags() {
return 0; return 0;
} }
@ -84,6 +89,7 @@ public class CShiftData implements ICElementDelta {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICElementDelta#getKind() * @see org.eclipse.cdt.core.model.ICElementDelta#getKind()
*/ */
@Override
public int getKind() { public int getKind() {
return 0; return 0;
} }
@ -91,6 +97,7 @@ public class CShiftData implements ICElementDelta {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICElementDelta#getMovedFromElement() * @see org.eclipse.cdt.core.model.ICElementDelta#getMovedFromElement()
*/ */
@Override
public ICElement getMovedFromElement() { public ICElement getMovedFromElement() {
return null; return null;
} }
@ -98,6 +105,7 @@ public class CShiftData implements ICElementDelta {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICElementDelta#getMovedToElement() * @see org.eclipse.cdt.core.model.ICElementDelta#getMovedToElement()
*/ */
@Override
public ICElement getMovedToElement() { public ICElement getMovedToElement() {
return null; return null;
} }
@ -105,6 +113,7 @@ public class CShiftData implements ICElementDelta {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICElementDelta#getRemovedChildren() * @see org.eclipse.cdt.core.model.ICElementDelta#getRemovedChildren()
*/ */
@Override
public ICElementDelta[] getRemovedChildren() { public ICElementDelta[] getRemovedChildren() {
return new ICElementDelta[0]; return new ICElementDelta[0];
} }
@ -112,6 +121,7 @@ public class CShiftData implements ICElementDelta {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICElementDelta#getResourceDeltas() * @see org.eclipse.cdt.core.model.ICElementDelta#getResourceDeltas()
*/ */
@Override
public IResourceDelta[] getResourceDeltas() { public IResourceDelta[] getResourceDeltas() {
return null; return null;
} }

View file

@ -72,9 +72,9 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
List<IPathEntryStoreListener> listeners; List<IPathEntryStoreListener> listeners;
IProject fProject; IProject fProject;
/** /**
* *
*/ */
public DefaultPathEntryStore(IProject project) { public DefaultPathEntryStore(IProject project) {
fProject = project; fProject = project;
@ -84,6 +84,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
CCorePlugin.getDefault().getCDescriptorManager().addDescriptorListener(this); CCorePlugin.getDefault().getCDescriptorManager().addDescriptorListener(this);
} }
@Override
public IPathEntry[] getRawPathEntries() throws CoreException { public IPathEntry[] getRawPathEntries() throws CoreException {
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(fProject, false); ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(fProject, false);
if (cdesc != null) { if (cdesc != null) {
@ -91,17 +92,18 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
ICStorageElement entry = cdesc.getProjectStorageElement(PATH_ENTRY_ID); ICStorageElement entry = cdesc.getProjectStorageElement(PATH_ENTRY_ID);
for (ICStorageElement childNode : entry.getChildrenByName(PATH_ENTRY)) for (ICStorageElement childNode : entry.getChildrenByName(PATH_ENTRY))
pathEntries.add(decodePathEntry(fProject, childNode)); pathEntries.add(decodePathEntry(fProject, childNode));
IPathEntry[] entries = new IPathEntry[pathEntries.size()]; IPathEntry[] entries = new IPathEntry[pathEntries.size()];
pathEntries.toArray(entries); pathEntries.toArray(entries);
return entries; return entries;
} }
return NO_PATHENTRIES; return NO_PATHENTRIES;
} }
@Override
public void setRawPathEntries(IPathEntry[] newRawEntries) throws CoreException { public void setRawPathEntries(IPathEntry[] newRawEntries) throws CoreException {
if (Arrays.equals(newRawEntries, getRawPathEntries())) { if (Arrays.equals(newRawEntries, getRawPathEntries())) {
return; return;
} }
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(fProject, true); ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
ICStorageElement rootElement = descriptor.getProjectStorageElement(PATH_ENTRY_ID); ICStorageElement rootElement = descriptor.getProjectStorageElement(PATH_ENTRY_ID);
// Clear out all current children // Clear out all current children
@ -116,11 +118,11 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
static IPathEntry decodePathEntry(IProject project, ICStorageElement element) throws CModelException { static IPathEntry decodePathEntry(IProject project, ICStorageElement element) throws CModelException {
IPath projectPath = project.getFullPath(); IPath projectPath = project.getFullPath();
// kind // kind
String kindAttr = element.getAttribute(ATTRIBUTE_KIND); String kindAttr = element.getAttribute(ATTRIBUTE_KIND);
int kind = PathEntry.kindFromString(kindAttr); int kind = PathEntry.kindFromString(kindAttr);
// exported flag // exported flag
boolean isExported = false; boolean isExported = false;
if (element.hasAttribute(ATTRIBUTE_EXPORTED)) { if (element.hasAttribute(ATTRIBUTE_EXPORTED)) {
@ -157,13 +159,13 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
} }
} }
} }
// recreate the entry // recreate the entry
switch (kind) { switch (kind) {
case IPathEntry.CDT_PROJECT : case IPathEntry.CDT_PROJECT :
return CoreModel.newProjectEntry(path, isExported); return CoreModel.newProjectEntry(path, isExported);
case IPathEntry.CDT_LIBRARY : { case IPathEntry.CDT_LIBRARY : {
IPath libraryPath = new Path(element.getAttribute(ATTRIBUTE_LIBRARY)); IPath libraryPath = new Path(element.getAttribute(ATTRIBUTE_LIBRARY));
// source attachment info (optional) // source attachment info (optional)
IPath sourceAttachmentPath = element.hasAttribute(ATTRIBUTE_SOURCEPATH) ? new Path( IPath sourceAttachmentPath = element.hasAttribute(ATTRIBUTE_SOURCEPATH) ? new Path(
element.getAttribute(ATTRIBUTE_SOURCEPATH)) : null; element.getAttribute(ATTRIBUTE_SOURCEPATH)) : null;
@ -171,7 +173,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
element.getAttribute(ATTRIBUTE_ROOTPATH)) : null; element.getAttribute(ATTRIBUTE_ROOTPATH)) : null;
IPath sourceAttachmentPrefixMapping = element.hasAttribute(ATTRIBUTE_PREFIXMAPPING) ? new Path( IPath sourceAttachmentPrefixMapping = element.hasAttribute(ATTRIBUTE_PREFIXMAPPING) ? new Path(
element.getAttribute(ATTRIBUTE_PREFIXMAPPING)) : null; element.getAttribute(ATTRIBUTE_PREFIXMAPPING)) : null;
if (!baseRef.isEmpty()) { if (!baseRef.isEmpty()) {
return CoreModel.newLibraryRefEntry(path, baseRef, libraryPath); return CoreModel.newLibraryRefEntry(path, baseRef, libraryPath);
} }
@ -207,7 +209,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
case IPathEntry.CDT_INCLUDE_FILE: { case IPathEntry.CDT_INCLUDE_FILE: {
// include path info // include path info
IPath includeFilePath = new Path(element.getAttribute(ATTRIBUTE_INCLUDE_FILE)); IPath includeFilePath = new Path(element.getAttribute(ATTRIBUTE_INCLUDE_FILE));
return CoreModel.newIncludeFileEntry(path, basePath, baseRef, includeFilePath, exclusionPatterns, isExported); return CoreModel.newIncludeFileEntry(path, basePath, baseRef, includeFilePath, exclusionPatterns, isExported);
} }
case IPathEntry.CDT_MACRO : { case IPathEntry.CDT_MACRO : {
String macroName = element.getAttribute(ATTRIBUTE_NAME); String macroName = element.getAttribute(ATTRIBUTE_NAME);
@ -276,7 +278,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
element.setAttribute(ATTRIBUTE_LIBRARY, libraryPath.toString()); element.setAttribute(ATTRIBUTE_LIBRARY, libraryPath.toString());
IPath sourcePath = lib.getSourceAttachmentPath(); IPath sourcePath = lib.getSourceAttachmentPath();
if (sourcePath != null) { if (sourcePath != null) {
// translate to project relative from absolute // translate to project relative from absolute
if (projectPath != null && projectPath.isPrefixOf(sourcePath)) { if (projectPath != null && projectPath.isPrefixOf(sourcePath)) {
if (sourcePath.segment(0).equals(projectPath.segment(0))) { if (sourcePath.segment(0).equals(projectPath.segment(0))) {
sourcePath = sourcePath.removeFirstSegments(1); sourcePath = sourcePath.removeFirstSegments(1);
@ -356,9 +358,10 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.cdt.core.ICDescriptorListener#descriptorChanged(org.eclipse.cdt.core.CDescriptorEvent) * @see org.eclipse.cdt.core.ICDescriptorListener#descriptorChanged(org.eclipse.cdt.core.CDescriptorEvent)
*/ */
@Override
public void descriptorChanged(CDescriptorEvent event) { public void descriptorChanged(CDescriptorEvent event) {
if (event.getType() == CDescriptorEvent.CDTPROJECT_CHANGED if (event.getType() == CDescriptorEvent.CDTPROJECT_CHANGED
/*|| event.getType() == CDescriptorEvent.CDTPROJECT_ADDED*/) { /*|| event.getType() == CDescriptorEvent.CDTPROJECT_ADDED*/) {
@ -373,13 +376,15 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.resources.IPathEntryStore#addPathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener) * @see org.eclipse.cdt.core.resources.IPathEntryStore#addPathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener)
*/ */
public void addPathEntryStoreListener(IPathEntryStoreListener listener) { @Override
public void addPathEntryStoreListener(IPathEntryStoreListener listener) {
listeners.add(listener); listeners.add(listener);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.resources.IPathEntryStore#removePathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener) * @see org.eclipse.cdt.core.resources.IPathEntryStore#removePathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener)
*/ */
@Override
public void removePathEntryStoreListener(IPathEntryStoreListener listener) { public void removePathEntryStoreListener(IPathEntryStoreListener listener) {
listeners.remove(listener); listeners.remove(listener);
} }
@ -396,6 +401,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.resources.IPathEntryStore#fireClosedChangedEvent(IProject) * @see org.eclipse.cdt.core.resources.IPathEntryStore#fireClosedChangedEvent(IProject)
*/ */
@Override
public void close() { public void close() {
PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, fProject, PathEntryStoreChangedEvent.STORE_CLOSED); PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, fProject, PathEntryStoreChangedEvent.STORE_CLOSED);
IPathEntryStoreListener[] observers = new IPathEntryStoreListener[listeners.size()]; IPathEntryStoreListener[] observers = new IPathEntryStoreListener[listeners.size()];
@ -406,14 +412,17 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
CCorePlugin.getDefault().getCDescriptorManager().removeDescriptorListener(this); CCorePlugin.getDefault().getCDescriptorManager().removeDescriptorListener(this);
} }
@Override
public IProject getProject() { public IProject getProject() {
return fProject; return fProject;
} }
@Override
public ICExtensionReference getExtensionReference() { public ICExtensionReference getExtensionReference() {
return null; return null;
} }
@Override
public ICConfigExtensionReference getConfigExtensionReference() { public ICConfigExtensionReference getConfigExtensionReference() {
return null; return null;
} }

View file

@ -19,7 +19,7 @@ import org.eclipse.cdt.core.model.IEnumeration;
public class Enumeration extends SourceManipulation implements IEnumeration{ public class Enumeration extends SourceManipulation implements IEnumeration{
public Enumeration(ICElement parent, String name) { public Enumeration(ICElement parent, String name) {
super(parent, name, ICElement.C_ENUMERATION); super(parent, name, ICElement.C_ENUMERATION);
} }
@Override @Override
@ -34,6 +34,7 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
/** /**
* @see org.eclipse.cdt.core.model.IVariableDeclaration#getTypeName() * @see org.eclipse.cdt.core.model.IVariableDeclaration#getTypeName()
*/ */
@Override
public String getTypeName() throws CModelException { public String getTypeName() throws CModelException {
return getEnumerationInfo().getTypeName(); return getEnumerationInfo().getTypeName();
} }
@ -48,6 +49,7 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
/** /**
* @see org.eclipse.cdt.core.model.IDeclaration#isConst() * @see org.eclipse.cdt.core.model.IDeclaration#isConst()
*/ */
@Override
public boolean isConst() throws CModelException { public boolean isConst() throws CModelException {
return getEnumerationInfo().isConst(); return getEnumerationInfo().isConst();
} }
@ -55,6 +57,7 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
/** /**
* @see org.eclipse.cdt.core.model.IDeclaration#isStatic() * @see org.eclipse.cdt.core.model.IDeclaration#isStatic()
*/ */
@Override
public boolean isStatic() throws CModelException { public boolean isStatic() throws CModelException {
return getEnumerationInfo().isStatic(); return getEnumerationInfo().isStatic();
} }
@ -62,6 +65,7 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
/** /**
* @see org.eclipse.cdt.core.model.IDeclaration#isVolatile() * @see org.eclipse.cdt.core.model.IDeclaration#isVolatile()
*/ */
@Override
public boolean isVolatile() throws CModelException { public boolean isVolatile() throws CModelException {
return getEnumerationInfo().isVolatile(); return getEnumerationInfo().isVolatile();
} }
@ -88,6 +92,6 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
*/ */
public void setVolatile(boolean isVolatile) throws CModelException { public void setVolatile(boolean isVolatile) throws CModelException {
getEnumerationInfo().setVolatile(isVolatile); getEnumerationInfo().setVolatile(isVolatile);
} }
} }

View file

@ -16,19 +16,20 @@ import org.eclipse.cdt.core.model.IEnumerator;
public class Enumerator extends SourceManipulation implements IEnumerator{ public class Enumerator extends SourceManipulation implements IEnumerator{
String constantExpression = ""; //$NON-NLS-1$ String constantExpression = ""; //$NON-NLS-1$
public Enumerator(ICElement parent, String name) { public Enumerator(ICElement parent, String name) {
super(parent, name, ICElement.C_ENUMERATOR); super(parent, name, ICElement.C_ENUMERATOR);
} }
@Override @Override
protected CElementInfo createElementInfo () { protected CElementInfo createElementInfo () {
return new SourceManipulationInfo(this); return new SourceManipulationInfo(this);
} }
/** /**
* @see org.eclipse.cdt.core.model.IEnumerator#getConstantExpression() * @see org.eclipse.cdt.core.model.IEnumerator#getConstantExpression()
*/ */
@Override
public String getConstantExpression() { public String getConstantExpression() {
return constantExpression; return constantExpression;
} }

View file

@ -17,11 +17,12 @@ import org.eclipse.cdt.core.model.IField;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
public class Field extends VariableDeclaration implements IField { public class Field extends VariableDeclaration implements IField {
public Field(ICElement parent, String name) { public Field(ICElement parent, String name) {
super(parent, name, ICElement.C_FIELD); super(parent, name, ICElement.C_FIELD);
} }
@Override
public boolean isMutable() throws CModelException{ public boolean isMutable() throws CModelException{
return getFieldInfo().isMutable(); return getFieldInfo().isMutable();
} }
@ -70,6 +71,7 @@ public class Field extends VariableDeclaration implements IField {
getFieldInfo().setStatic(isStatic); getFieldInfo().setStatic(isStatic);
} }
@Override
public ASTAccessVisibility getVisibility() throws CModelException { public ASTAccessVisibility getVisibility() throws CModelException {
return getFieldInfo().getVisibility(); return getFieldInfo().getVisibility();
} }

View file

@ -20,7 +20,7 @@ import org.eclipse.cdt.core.model.IFunctionDeclaration;
public class FunctionDeclaration extends SourceManipulation implements IFunctionDeclaration { public class FunctionDeclaration extends SourceManipulation implements IFunctionDeclaration {
protected String[] fParameterTypes; protected String[] fParameterTypes;
protected String returnType; protected String returnType;
public FunctionDeclaration(ICElement parent, String name) { public FunctionDeclaration(ICElement parent, String name) {
super(parent, name, ICElement.C_FUNCTION_DECLARATION); super(parent, name, ICElement.C_FUNCTION_DECLARATION);
fParameterTypes= fgEmptyStrings; fParameterTypes= fgEmptyStrings;
@ -31,6 +31,7 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
fParameterTypes= fgEmptyStrings; fParameterTypes= fgEmptyStrings;
} }
@Override
public String getReturnType(){ public String getReturnType(){
if (returnType != null) { if (returnType != null) {
return returnType; return returnType;
@ -42,22 +43,25 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
returnType = type; returnType = type;
} }
@Override
public int getNumberOfParameters() { public int getNumberOfParameters() {
return fParameterTypes == null ? 0 : fParameterTypes.length; return fParameterTypes == null ? 0 : fParameterTypes.length;
} }
@Override
public String[] getParameterTypes() { public String[] getParameterTypes() {
return fParameterTypes; return fParameterTypes;
} }
public void setParameterTypes(String[] parameterTypes) { public void setParameterTypes(String[] parameterTypes) {
fParameterTypes = parameterTypes; fParameterTypes = parameterTypes;
} }
@Override
public String getSignature() throws CModelException{ public String getSignature() throws CModelException{
return getSignature(this); return getSignature(this);
} }
public static String getSignature(IFunctionDeclaration func) { public static String getSignature(IFunctionDeclaration func) {
StringBuffer sig = new StringBuffer(func.getElementName()); StringBuffer sig = new StringBuffer(func.getElementName());
sig.append(getParameterClause(func.getParameterTypes())); sig.append(getParameterClause(func.getParameterTypes()));
@ -68,17 +72,17 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
sig.append(" volatile"); //$NON-NLS-1$ sig.append(" volatile"); //$NON-NLS-1$
} }
} catch (CModelException e) { } catch (CModelException e) {
} }
return sig.toString(); return sig.toString();
} }
public String getParameterClause() { public String getParameterClause() {
return getParameterClause(getParameterTypes()); return getParameterClause(getParameterTypes());
} }
public static String getParameterClause(String[] paramTypes){ public static String getParameterClause(String[] paramTypes){
StringBuffer sig = new StringBuffer(); StringBuffer sig = new StringBuffer();
if(paramTypes.length > 0){ if(paramTypes.length > 0){
sig.append("("); //$NON-NLS-1$ sig.append("("); //$NON-NLS-1$
int i = 0; int i = 0;
@ -92,13 +96,15 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
else{ else{
sig.append("()"); //$NON-NLS-1$ sig.append("()"); //$NON-NLS-1$
} }
return sig.toString(); return sig.toString();
} }
@Override
public String getParameterInitializer(int pos) { public String getParameterInitializer(int pos) {
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
} }
@Override
public String[] getExceptions(){ public String[] getExceptions(){
return new String[] {}; return new String[] {};
} }
@ -107,11 +113,11 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
protected CElementInfo createElementInfo () { protected CElementInfo createElementInfo () {
return new FunctionInfo(this); return new FunctionInfo(this);
} }
protected FunctionInfo getFunctionInfo() throws CModelException{ protected FunctionInfo getFunctionInfo() throws CModelException{
return (FunctionInfo) getElementInfo(); return (FunctionInfo) getElementInfo();
} }
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other instanceof IFunctionDeclaration) { if (other instanceof IFunctionDeclaration) {
@ -119,17 +125,18 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
} }
return false; return false;
} }
public static boolean equals(IFunctionDeclaration lhs, IFunctionDeclaration rhs) { public static boolean equals(IFunctionDeclaration lhs, IFunctionDeclaration rhs) {
return CElement.equals(lhs, rhs) && return CElement.equals(lhs, rhs) &&
Util.equalArraysOrNull(lhs.getParameterTypes(), rhs.getParameterTypes()) && Util.equalArraysOrNull(lhs.getParameterTypes(), rhs.getParameterTypes()) &&
lhs.getReturnType().equals(rhs.getReturnType()); lhs.getReturnType().equals(rhs.getReturnType());
} }
/** /**
* FunctionDeclarations and Functions can not be constant * FunctionDeclarations and Functions can not be constant
* @see org.eclipse.cdt.core.model.IDeclaration#isConst() * @see org.eclipse.cdt.core.model.IDeclaration#isConst()
*/ */
@Override
public boolean isConst() throws CModelException{ public boolean isConst() throws CModelException{
return getFunctionInfo().isConst(); return getFunctionInfo().isConst();
} }
@ -142,6 +149,7 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
* Returns the isStatic. * Returns the isStatic.
* @return boolean * @return boolean
*/ */
@Override
public boolean isStatic() throws CModelException { public boolean isStatic() throws CModelException {
return getFunctionInfo().isStatic(); return getFunctionInfo().isStatic();
} }
@ -150,6 +158,7 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
* Returns the isVolatile. * Returns the isVolatile.
* @return boolean * @return boolean
*/ */
@Override
public boolean isVolatile() throws CModelException { public boolean isVolatile() throws CModelException {
return getFunctionInfo().isVolatile(); return getFunctionInfo().isVolatile();
} }

View file

@ -16,23 +16,25 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IFunctionTemplate; import org.eclipse.cdt.core.model.IFunctionTemplate;
public class FunctionTemplate extends Function implements IFunctionTemplate { public class FunctionTemplate extends Function implements IFunctionTemplate {
protected Template fTemplate; protected Template fTemplate;
public FunctionTemplate(ICElement parent, String name) { public FunctionTemplate(ICElement parent, String name) {
super(parent, name, ICElement.C_TEMPLATE_FUNCTION); super(parent, name, ICElement.C_TEMPLATE_FUNCTION);
fTemplate = new Template(name); fTemplate = new Template(name);
} }
/** /**
* Returns the parameterTypes. * Returns the parameterTypes.
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes() * @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes()
* @return String[] * @return String[]
*/ */
@Override
public String[] getTemplateParameterTypes() { public String[] getTemplateParameterTypes() {
return fTemplate.getTemplateParameterTypes(); return fTemplate.getTemplateParameterTypes();
} }
@Override
public String[] getTemplateArguments() { public String[] getTemplateArguments() {
return fTemplate.getTemplateArguments(); return fTemplate.getTemplateArguments();
} }
@ -47,6 +49,7 @@ public class FunctionTemplate extends Function implements IFunctionTemplate {
/** /**
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters() * @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
*/ */
@Override
public int getNumberOfTemplateParameters() { public int getNumberOfTemplateParameters() {
return fTemplate.getNumberOfTemplateParameters(); return fTemplate.getNumberOfTemplateParameters();
} }
@ -55,13 +58,14 @@ public class FunctionTemplate extends Function implements IFunctionTemplate {
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature() * @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
*/ */
/* /*
* The signature in the outline view will be: * The signature in the outline view will be:
* The class X followed by its template parameters, * The class X followed by its template parameters,
* then the scope resolution, then the function name, * then the scope resolution, then the function name,
* followed by its template parameters, folowed by its * followed by its template parameters, folowed by its
* normal parameter list, then a colon then the function's * normal parameter list, then a colon then the function's
* return type. * return type.
*/ */
@Override
public String getTemplateSignature() throws CModelException { public String getTemplateSignature() throws CModelException {
StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature()); StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature());
sig.append(this.getParameterClause()); sig.append(this.getParameterClause());
@ -71,7 +75,7 @@ public class FunctionTemplate extends Function implements IFunctionTemplate {
if (isVolatile()) { if (isVolatile()) {
sig.append(" volatile"); //$NON-NLS-1$ sig.append(" volatile"); //$NON-NLS-1$
} }
if ((this.getReturnType() != null) && (this.getReturnType().length() > 0)) { if ((this.getReturnType() != null) && (this.getReturnType().length() > 0)) {
sig.append(" : "); //$NON-NLS-1$ sig.append(" : "); //$NON-NLS-1$
sig.append(this.getReturnType()); sig.append(this.getReturnType());
} }

View file

@ -24,14 +24,17 @@ public class FunctionTemplateDeclaration extends FunctionDeclaration implements
fTemplate = new Template(name); fTemplate = new Template(name);
} }
@Override
public String[] getTemplateParameterTypes() { public String[] getTemplateParameterTypes() {
return fTemplate.getTemplateParameterTypes(); return fTemplate.getTemplateParameterTypes();
} }
@Override
public String[] getTemplateArguments() { public String[] getTemplateArguments() {
return fTemplate.getTemplateArguments(); return fTemplate.getTemplateArguments();
} }
@Override
public String getTemplateSignature() throws CModelException { public String getTemplateSignature() throws CModelException {
StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature()); StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature());
sig.append(this.getParameterClause()); sig.append(this.getParameterClause());
@ -40,14 +43,15 @@ public class FunctionTemplateDeclaration extends FunctionDeclaration implements
if(isVolatile()) if(isVolatile())
sig.append(" volatile"); //$NON-NLS-1$ sig.append(" volatile"); //$NON-NLS-1$
if((this.getReturnType() != null) && (this.getReturnType().length() > 0)){ if((this.getReturnType() != null) && (this.getReturnType().length() > 0)){
sig.append(" : "); //$NON-NLS-1$ sig.append(" : "); //$NON-NLS-1$
sig.append(this.getReturnType()); sig.append(this.getReturnType());
} }
return sig.toString(); return sig.toString();
} }
@Override
public int getNumberOfTemplateParameters() { public int getNumberOfTemplateParameters() {
return fTemplate.getNumberOfTemplateParameters(); return fTemplate.getNumberOfTemplateParameters();
} }

View file

@ -16,7 +16,7 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IInclude; import org.eclipse.cdt.core.model.IInclude;
public class Include extends SourceManipulation implements IInclude { public class Include extends SourceManipulation implements IInclude {
private String fullPath; private String fullPath;
private final boolean standard; private final boolean standard;
private boolean fIsResolved= true; private boolean fIsResolved= true;
@ -26,10 +26,12 @@ public class Include extends SourceManipulation implements IInclude {
standard = isStandard; standard = isStandard;
} }
@Override
public String getIncludeName() { public String getIncludeName() {
return getElementName(); return getElementName();
} }
@Override
public boolean isStandard() { public boolean isStandard() {
return standard; return standard;
} }
@ -37,6 +39,7 @@ public class Include extends SourceManipulation implements IInclude {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IInclude#getFullFileName() * @see org.eclipse.cdt.core.model.IInclude#getFullFileName()
*/ */
@Override
public String getFullFileName() { public String getFullFileName() {
return fullPath; return fullPath;
} }
@ -44,6 +47,7 @@ public class Include extends SourceManipulation implements IInclude {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IInclude#isLocal() * @see org.eclipse.cdt.core.model.IInclude#isLocal()
*/ */
@Override
public boolean isLocal() { public boolean isLocal() {
return !isStandard(); return !isStandard();
} }
@ -63,6 +67,7 @@ public class Include extends SourceManipulation implements IInclude {
/* /*
* @see org.eclipse.cdt.core.model.IInclude#isResolved() * @see org.eclipse.cdt.core.model.IInclude#isResolved()
*/ */
@Override
public boolean isResolved() { public boolean isResolved() {
return fIsResolved; return fIsResolved;
} }
@ -77,13 +82,13 @@ public class Include extends SourceManipulation implements IInclude {
} }
return false; return false;
} }
public static boolean equals(IInclude lhs, IInclude rhs) { public static boolean equals(IInclude lhs, IInclude rhs) {
return CElement.equals(lhs, rhs) return CElement.equals(lhs, rhs)
&& lhs.isActive() == rhs.isActive() && lhs.isActive() == rhs.isActive()
&& lhs.isResolved() == rhs.isResolved() && lhs.isResolved() == rhs.isResolved()
&& lhs.isLocal() == rhs.isLocal() && lhs.isLocal() == rhs.isLocal()
&& (lhs.getFullFileName() == rhs.getFullFileName() && (lhs.getFullFileName() == rhs.getFullFileName()
|| lhs.getFullFileName() != null && lhs.getFullFileName().equals(rhs.getFullFileName())); || lhs.getFullFileName() != null && lhs.getFullFileName().equals(rhs.getFullFileName()));
} }
} }

View file

@ -33,18 +33,20 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry {
/** /**
* Returns the include path * Returns the include path
* *
* @return IPath * @return IPath
*/ */
@Override
public IPath getIncludePath() { public IPath getIncludePath() {
return includePath; return includePath;
} }
/** /**
* Whether or not it a system include path * Whether or not it a system include path
* *
* @return boolean * @return boolean
*/ */
@Override
public boolean isSystemInclude() { public boolean isSystemInclude() {
return isSystemInclude; return isSystemInclude;
} }
@ -95,6 +97,7 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IIncludeEntry#getFullIncludePath() * @see org.eclipse.cdt.core.model.IIncludeEntry#getFullIncludePath()
*/ */
@Override
public IPath getFullIncludePath() { public IPath getFullIncludePath() {
final IPath inc = getIncludePath(); final IPath inc = getIncludePath();
if (!basePath.isEmpty()) { if (!basePath.isEmpty()) {
@ -110,7 +113,7 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry {
} }
return loc.append(inc); return loc.append(inc);
} }
if (!inc.isAbsolute()) { if (!inc.isAbsolute()) {
IPath resPath = getPath(); IPath resPath = getPath();
IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(resPath.append(inc)); IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(resPath.append(inc));

View file

@ -33,9 +33,10 @@ public class IncludeFileEntry extends APathEntry implements IIncludeFileEntry {
/** /**
* Returns the include path * Returns the include path
* *
* @return IPath * @return IPath
*/ */
@Override
public IPath getIncludeFilePath() { public IPath getIncludeFilePath() {
return includeFilePath; return includeFilePath;
} }
@ -83,6 +84,7 @@ public class IncludeFileEntry extends APathEntry implements IIncludeFileEntry {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IIncludeEntry#getFullIncludePath() * @see org.eclipse.cdt.core.model.IIncludeEntry#getFullIncludePath()
*/ */
@Override
public IPath getFullIncludeFilePath() { public IPath getFullIncludeFilePath() {
final IPath inc = getIncludeFilePath(); final IPath inc = getIncludeFilePath();
if (!basePath.isEmpty()) { if (!basePath.isEmpty()) {
@ -98,7 +100,7 @@ public class IncludeFileEntry extends APathEntry implements IIncludeFileEntry {
} }
return loc.append(inc); return loc.append(inc);
} }
if (!inc.isAbsolute()) { if (!inc.isAbsolute()) {
IPath resPath = getPath(); IPath resPath = getPath();
IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(resPath.append(inc)); IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(resPath.append(inc));

View file

@ -41,7 +41,7 @@ import org.eclipse.core.runtime.Path;
* IncludeReference * IncludeReference
*/ */
public class IncludeReference extends Openable implements IIncludeReference { public class IncludeReference extends Openable implements IIncludeReference {
final IIncludeEntry fIncludeEntry; final IIncludeEntry fIncludeEntry;
final IPath fPath; final IPath fPath;
@ -76,7 +76,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
} }
return file != null && file.isDirectory(); return file != null && file.isDirectory();
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.model.CElement#createElementInfo() * @see org.eclipse.cdt.internal.core.model.CElement#createElementInfo()
*/ */
@ -88,6 +88,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IIncludeReference#getIncludeEntry() * @see org.eclipse.cdt.core.model.IIncludeReference#getIncludeEntry()
*/ */
@Override
public IIncludeEntry getIncludeEntry() { public IIncludeEntry getIncludeEntry() {
return fIncludeEntry; return fIncludeEntry;
} }
@ -103,6 +104,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IIncludeReference#getAffectedPath() * @see org.eclipse.cdt.core.model.IIncludeReference#getAffectedPath()
*/ */
@Override
public IPath getAffectedPath() { public IPath getAffectedPath() {
return fIncludeEntry.getPath(); return fIncludeEntry.getPath();
} }
@ -124,7 +126,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
String[] names = null; String[] names = null;
if (file != null && file.isDirectory()) { if (file != null && file.isDirectory()) {
names = file.list(); names = file.list();
if (names != null) { if (names != null) {
IPath path = new Path(file.getAbsolutePath()); IPath path = new Path(file.getAbsolutePath());
for (String name : names) { for (String name : names) {
@ -175,8 +177,9 @@ public class IncludeReference extends Openable implements IIncludeReference {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IIncludeReference#isOnIncludeEntry(org.eclipse.core.runtime.IPath) * @see org.eclipse.cdt.core.model.IIncludeReference#isOnIncludeEntry(org.eclipse.core.runtime.IPath)
*/ */
@Override
public boolean isOnIncludeEntry(IPath path) { public boolean isOnIncludeEntry(IPath path) {
if (fIncludeEntry.getFullIncludePath().isPrefixOf(path) if (fIncludeEntry.getFullIncludePath().isPrefixOf(path)
&& !CoreModelUtil.isExcluded(path, fIncludeEntry.fullExclusionPatternChars())) { && !CoreModelUtil.isExcluded(path, fIncludeEntry.fullExclusionPatternChars())) {
return true; return true;
} }
@ -190,7 +193,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
public IPath getPath() { public IPath getPath() {
return fPath; return fPath;
} }
@Override @Override
public ICElement getHandleFromMemento(String token, MementoTokenizer memento) { public ICElement getHandleFromMemento(String token, MementoTokenizer memento) {
return null; return null;

View file

@ -31,19 +31,22 @@ public class LanguageDescriptor extends CExtensionDescriptor implements
private String fContentTypeIds[]; private String fContentTypeIds[];
private String fId; private String fId;
private IContentType[] fContentTypes; private IContentType[] fContentTypes;
public LanguageDescriptor(IConfigurationElement el) { public LanguageDescriptor(IConfigurationElement el) {
super(el); super(el);
} }
@Override
public ILanguage getLanguage() { public ILanguage getLanguage() {
if(fLanguage == null){ if(fLanguage == null){
SafeRunner.run(new ISafeRunnable(){ SafeRunner.run(new ISafeRunnable(){
@Override
public void handleException(Throwable exception) { public void handleException(Throwable exception) {
CCorePlugin.log(exception); CCorePlugin.log(exception);
} }
@Override
public void run() throws Exception { public void run() throws Exception {
fLanguage = (ILanguage)getConfigurationElement().createExecutableExtension(ATTRIBUTE_CLASS); fLanguage = (ILanguage)getConfigurationElement().createExecutableExtension(ATTRIBUTE_CLASS);
} }
@ -52,13 +55,14 @@ public class LanguageDescriptor extends CExtensionDescriptor implements
return fLanguage; return fLanguage;
} }
@Override
public String[] getContentTypeIds() { public String[] getContentTypeIds() {
if(fContentTypeIds == null){ if(fContentTypeIds == null){
fContentTypeIds = calculateCintentTypeIds(); fContentTypeIds = calculateCintentTypeIds();
} }
return fContentTypeIds; return fContentTypeIds;
} }
private String[] calculateCintentTypeIds(){ private String[] calculateCintentTypeIds(){
IConfigurationElement el = getConfigurationElement(); IConfigurationElement el = getConfigurationElement();
IConfigurationElement children[] = el.getChildren(); IConfigurationElement children[] = el.getChildren();
@ -80,10 +84,10 @@ public class LanguageDescriptor extends CExtensionDescriptor implements
ids = t; ids = t;
} }
} }
return ids; return ids;
} }
@Override @Override
public String getId(){ public String getId(){
if(fId == null) if(fId == null)
@ -91,26 +95,27 @@ public class LanguageDescriptor extends CExtensionDescriptor implements
return fId; return fId;
} }
@Override
public IContentType[] getContentTypes() { public IContentType[] getContentTypes() {
if(fContentTypes == null){ if(fContentTypes == null){
fContentTypes = calculateContentTypes(getContentTypeIds()); fContentTypes = calculateContentTypes(getContentTypeIds());
} }
return fContentTypes; return fContentTypes;
} }
private IContentType[] calculateContentTypes(String ids[]){ private IContentType[] calculateContentTypes(String ids[]){
IContentType cTypes[] = new IContentType[ids.length]; IContentType cTypes[] = new IContentType[ids.length];
if(ids.length > 0){ if(ids.length > 0){
int num = 0; int num = 0;
IContentTypeManager manager = Platform.getContentTypeManager(); IContentTypeManager manager = Platform.getContentTypeManager();
for (int k = 0; k < ids.length; ++k) { for (int k = 0; k < ids.length; ++k) {
IContentType langContType = manager.getContentType(ids[k]); IContentType langContType = manager.getContentType(ids[k]);
if(langContType != null) if(langContType != null)
cTypes[num++] = langContType; cTypes[num++] = langContType;
} }
if(num < ids.length){ if(num < ids.length){
IContentType tmp[] = new IContentType[num]; IContentType tmp[] = new IContentType[num];
System.arraycopy(cTypes, 0, tmp, 0, num); System.arraycopy(cTypes, 0, tmp, 0, num);

View file

@ -25,7 +25,7 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry {
IPath sourceAttachmentPrefixMapping; IPath sourceAttachmentPrefixMapping;
/** /**
* *
* @param basePath * @param basePath
* @param baseRef * @param baseRef
* @param libraryPath * @param libraryPath
@ -58,6 +58,7 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry {
* *
* @return the path to the source archive or folder, or <code>null</code> if none * @return the path to the source archive or folder, or <code>null</code> if none
*/ */
@Override
public IPath getSourceAttachmentPath() { public IPath getSourceAttachmentPath() {
return sourceAttachmentPath; return sourceAttachmentPath;
} }
@ -72,10 +73,11 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry {
* @return the path within the source archive or folder, or <code>null</code> if * @return the path within the source archive or folder, or <code>null</code> if
* not applicable * not applicable
*/ */
@Override
public IPath getSourceAttachmentRootPath() { public IPath getSourceAttachmentRootPath() {
return sourceAttachmentRootPath; return sourceAttachmentRootPath;
} }
/** /**
* Returns the path to map the source paths with to the source achive or folder * Returns the path to map the source paths with to the source achive or folder
* An empty path indicates that the is a one-to-one mapping of source paths to the * An empty path indicates that the is a one-to-one mapping of source paths to the
@ -86,6 +88,7 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry {
* @return the path mapping within the source archive or folder, or <code>null</code> if * @return the path mapping within the source archive or folder, or <code>null</code> if
* not applicable * not applicable
*/ */
@Override
public IPath getSourceAttachmentPrefixMapping() { public IPath getSourceAttachmentPrefixMapping() {
return sourceAttachmentPrefixMapping; return sourceAttachmentPrefixMapping;
} }
@ -143,6 +146,7 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry {
return super.equals(obj); return super.equals(obj);
} }
@Override
public IPath getFullLibraryPath() { public IPath getFullLibraryPath() {
IPath p; IPath p;
IPath lib = getLibraryPath(); IPath lib = getLibraryPath();
@ -178,6 +182,7 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ILibraryEntry#getLibraryPath() * @see org.eclipse.cdt.core.model.ILibraryEntry#getLibraryPath()
*/ */
@Override
public IPath getLibraryPath() { public IPath getLibraryPath() {
return libraryPath; return libraryPath;
} }

View file

@ -62,6 +62,7 @@ public class LibraryReference extends Parent implements ILibraryReference {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ILibraryReference#getLibraryEntry() * @see org.eclipse.cdt.core.model.ILibraryReference#getLibraryEntry()
*/ */
@Override
public ILibraryEntry getLibraryEntry() { public ILibraryEntry getLibraryEntry() {
return entry; return entry;
} }

View file

@ -39,7 +39,7 @@ public class LibraryReferenceArchive extends Archive implements ILibraryReferenc
return null; return null;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICElement#getPath() * @see org.eclipse.cdt.core.model.ICElement#getPath()
@ -64,6 +64,7 @@ public class LibraryReferenceArchive extends Archive implements ILibraryReferenc
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ILibraryReference#getLibraryEntry() * @see org.eclipse.cdt.core.model.ILibraryReference#getLibraryEntry()
*/ */
@Override
public ILibraryEntry getLibraryEntry() { public ILibraryEntry getLibraryEntry() {
return entry; return entry;
} }

View file

@ -9,7 +9,7 @@
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Created on Apr 2, 2003 * Created on Apr 2, 2003
* *
* To change this generated comment go to * To change this generated comment go to
* Window>Preferences>Java>Code Generation>Code Template * Window>Preferences>Java>Code Generation>Code Template
* / * /
*******************************************************************************/ *******************************************************************************/
@ -79,6 +79,7 @@ public class LibraryReferenceShared extends Binary implements ILibraryReference
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ILibraryReference#getLibraryEntry() * @see org.eclipse.cdt.core.model.ILibraryReference#getLibraryEntry()
*/ */
@Override
public ILibraryEntry getLibraryEntry() { public ILibraryEntry getLibraryEntry() {
return entry; return entry;
} }

View file

@ -15,9 +15,9 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IMacro; import org.eclipse.cdt.core.model.IMacro;
public class Macro extends SourceManipulation implements IMacro { public class Macro extends SourceManipulation implements IMacro {
private boolean fFunctionStyle = false; private boolean fFunctionStyle = false;
public void setFunctionStyle(boolean isFunctionStyle) { public void setFunctionStyle(boolean isFunctionStyle) {
this.fFunctionStyle = isFunctionStyle; this.fFunctionStyle = isFunctionStyle;
} }
@ -26,10 +26,12 @@ public class Macro extends SourceManipulation implements IMacro {
super(parent, name, ICElement.C_MACRO); super(parent, name, ICElement.C_MACRO);
} }
@Override
public String getIdentifierList() { public String getIdentifierList() {
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
} }
@Override
public String getTokenSequence() { public String getTokenSequence() {
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
} }
@ -39,6 +41,7 @@ public class Macro extends SourceManipulation implements IMacro {
return new SourceManipulationInfo(this); return new SourceManipulationInfo(this);
} }
@Override
public boolean isFunctionStyle() { public boolean isFunctionStyle() {
return fFunctionStyle; return fFunctionStyle;
} }

View file

@ -32,6 +32,7 @@ public class MacroEntry extends APathEntry implements IMacroEntry {
* Returns the macro name. * Returns the macro name.
* @return String * @return String
*/ */
@Override
public String getMacroName() { public String getMacroName() {
return macroName; return macroName;
} }
@ -40,6 +41,7 @@ public class MacroEntry extends APathEntry implements IMacroEntry {
* Returns the macro value. * Returns the macro value.
* @return String * @return String
*/ */
@Override
public String getMacroValue() { public String getMacroValue() {
return macroValue; return macroValue;
} }
@ -84,7 +86,7 @@ public class MacroEntry extends APathEntry implements IMacroEntry {
} }
return super.equals(obj); return super.equals(obj);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */

View file

@ -32,9 +32,10 @@ public class MacroFileEntry extends APathEntry implements IMacroFileEntry {
/** /**
* Returns the macro file path * Returns the macro file path
* *
* @return IPath * @return IPath
*/ */
@Override
public IPath getMacroFilePath() { public IPath getMacroFilePath() {
return macroFilePath; return macroFilePath;
} }
@ -81,6 +82,7 @@ public class MacroFileEntry extends APathEntry implements IMacroFileEntry {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IIncludeEntry#getFullIncludePath() * @see org.eclipse.cdt.core.model.IIncludeEntry#getFullIncludePath()
*/ */
@Override
public IPath getFullMacroFilePath() { public IPath getFullMacroFilePath() {
IPath p; IPath p;
IPath inc = getMacroFilePath(); IPath inc = getMacroFilePath();
@ -95,7 +97,7 @@ public class MacroFileEntry extends APathEntry implements IMacroFileEntry {
p = loc.append(inc); p = loc.append(inc);
return p; return p;
} }
p = inc; p = inc;
if (!p.isAbsolute()) { if (!p.isAbsolute()) {

View file

@ -19,7 +19,7 @@ import org.eclipse.cdt.core.model.IMethodDeclaration;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
public class MethodDeclaration extends FunctionDeclaration implements IMethodDeclaration{ public class MethodDeclaration extends FunctionDeclaration implements IMethodDeclaration{
boolean isConst = false; boolean isConst = false;
boolean isConstructor = false; boolean isConstructor = false;
boolean isDestructor = false; boolean isDestructor = false;
@ -31,11 +31,13 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
public MethodDeclaration(ICElement parent, String name, int type){ public MethodDeclaration(ICElement parent, String name, int type){
super(parent, name, type); super(parent, name, type);
} }
@Override
public boolean isConstructor(){ public boolean isConstructor(){
return isConstructor; return isConstructor;
} }
@Override
public boolean isDestructor() { public boolean isDestructor() {
return isDestructor; return isDestructor;
} }
@ -48,10 +50,12 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
this.isDestructor = isDestructor; this.isDestructor = isDestructor;
} }
@Override
public boolean isOperator(){ public boolean isOperator(){
return getElementName().startsWith("operator"); //$NON-NLS-1$ return getElementName().startsWith("operator"); //$NON-NLS-1$
} }
@Override
public boolean isPureVirtual() throws CModelException{ public boolean isPureVirtual() throws CModelException{
return getMethodInfo().isPureVirtual(); return getMethodInfo().isPureVirtual();
} }
@ -60,6 +64,7 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
getMethodInfo().setPureVirtual(isPureVirtual); getMethodInfo().setPureVirtual(isPureVirtual);
} }
@Override
public boolean isInline() throws CModelException{ public boolean isInline() throws CModelException{
return getMethodInfo().isInline(); return getMethodInfo().isInline();
} }
@ -68,6 +73,7 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
getMethodInfo().setInline(isInline); getMethodInfo().setInline(isInline);
} }
@Override
public boolean isVirtual() throws CModelException{ public boolean isVirtual() throws CModelException{
return getMethodInfo().isVirtual(); return getMethodInfo().isVirtual();
} }
@ -76,6 +82,7 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
getMethodInfo().setVirtual(isVirtual); getMethodInfo().setVirtual(isVirtual);
} }
@Override
public boolean isFriend() throws CModelException{ public boolean isFriend() throws CModelException{
return getMethodInfo().isFriend(); return getMethodInfo().isFriend();
} }
@ -94,23 +101,24 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
this.isConst = isConst; this.isConst = isConst;
} }
@Override
public ASTAccessVisibility getVisibility() throws CModelException{ public ASTAccessVisibility getVisibility() throws CModelException{
return getMethodInfo().getVisibility(); return getMethodInfo().getVisibility();
} }
public void setVisibility(ASTAccessVisibility visibility) throws CModelException{ public void setVisibility(ASTAccessVisibility visibility) throws CModelException{
getMethodInfo().setVisibility(visibility); getMethodInfo().setVisibility(visibility);
} }
@Override @Override
protected CElementInfo createElementInfo () { protected CElementInfo createElementInfo () {
return new MethodInfo(this); return new MethodInfo(this);
} }
protected MethodInfo getMethodInfo() throws CModelException{ protected MethodInfo getMethodInfo() throws CModelException{
return (MethodInfo) getElementInfo(); return (MethodInfo) getElementInfo();
} }
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other instanceof IMethodDeclaration) { if (other instanceof IMethodDeclaration) {
@ -127,6 +135,6 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
return false; return false;
} }
} }
} }

View file

@ -18,21 +18,23 @@ import org.eclipse.cdt.core.model.IMethodTemplate;
public class MethodTemplate extends Method implements IMethodTemplate { public class MethodTemplate extends Method implements IMethodTemplate {
protected Template fTemplate; protected Template fTemplate;
public MethodTemplate(ICElement parent, String name) { public MethodTemplate(ICElement parent, String name) {
super(parent, name, ICElement.C_TEMPLATE_METHOD); super(parent, name, ICElement.C_TEMPLATE_METHOD);
fTemplate = new Template(name); fTemplate = new Template(name);
} }
/** /**
* Returns the parameterTypes. * Returns the parameterTypes.
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes() * @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes()
* @return String[] * @return String[]
*/ */
@Override
public String[] getTemplateParameterTypes() { public String[] getTemplateParameterTypes() {
return fTemplate.getTemplateParameterTypes(); return fTemplate.getTemplateParameterTypes();
} }
@Override
public String[] getTemplateArguments() { public String[] getTemplateArguments() {
return fTemplate.getTemplateArguments(); return fTemplate.getTemplateArguments();
} }
@ -48,22 +50,24 @@ public class MethodTemplate extends Method implements IMethodTemplate {
/** /**
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters() * @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
*/ */
@Override
public int getNumberOfTemplateParameters() { public int getNumberOfTemplateParameters() {
return fTemplate.getNumberOfTemplateParameters(); return fTemplate.getNumberOfTemplateParameters();
} }
/** /**
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature() * @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
*/ */
/* /*
* The signature in the outline view will be: * The signature in the outline view will be:
* The class X followed by its template parameters, * The class X followed by its template parameters,
* then the scope resolution, then the function name, * then the scope resolution, then the function name,
* followed by its template parameters, folowed by its * followed by its template parameters, folowed by its
* normal parameter list, then a colon then the function's * normal parameter list, then a colon then the function's
* return type. * return type.
*/ */
@Override
public String getTemplateSignature() throws CModelException { public String getTemplateSignature() throws CModelException {
StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature()); StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature());
sig.append(this.getParameterClause()); sig.append(this.getParameterClause());
@ -72,11 +76,11 @@ public class MethodTemplate extends Method implements IMethodTemplate {
if(isVolatile()) if(isVolatile())
sig.append(" volatile"); //$NON-NLS-1$ sig.append(" volatile"); //$NON-NLS-1$
if((this.getReturnType() != null) && (this.getReturnType().length() > 0)){ if((this.getReturnType() != null) && (this.getReturnType().length() > 0)){
sig.append(" : "); //$NON-NLS-1$ sig.append(" : "); //$NON-NLS-1$
sig.append(this.getReturnType()); sig.append(this.getReturnType());
} }
return sig.toString(); return sig.toString();
} }

View file

@ -24,14 +24,17 @@ public class MethodTemplateDeclaration extends MethodDeclaration implements IMet
fTemplate = new Template(name); fTemplate = new Template(name);
} }
@Override
public String[] getTemplateParameterTypes() { public String[] getTemplateParameterTypes() {
return fTemplate.getTemplateParameterTypes(); return fTemplate.getTemplateParameterTypes();
} }
@Override
public String[] getTemplateArguments() { public String[] getTemplateArguments() {
return fTemplate.getTemplateArguments(); return fTemplate.getTemplateArguments();
} }
@Override
public String getTemplateSignature() throws CModelException { public String getTemplateSignature() throws CModelException {
StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature()); StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature());
sig.append(this.getParameterClause()); sig.append(this.getParameterClause());
@ -40,15 +43,16 @@ public class MethodTemplateDeclaration extends MethodDeclaration implements IMet
if(isVolatile()) if(isVolatile())
sig.append(" volatile"); //$NON-NLS-1$ sig.append(" volatile"); //$NON-NLS-1$
if((this.getReturnType() != null) && (this.getReturnType().length() > 0)){ if((this.getReturnType() != null) && (this.getReturnType().length() > 0)){
sig.append(" : "); //$NON-NLS-1$ sig.append(" : "); //$NON-NLS-1$
sig.append(this.getReturnType()); sig.append(this.getReturnType());
} }
return sig.toString(); return sig.toString();
} }
@Override
public int getNumberOfTemplateParameters() { public int getNumberOfTemplateParameters() {
return fTemplate.getNumberOfTemplateParameters(); return fTemplate.getNumberOfTemplateParameters();
} }

View file

@ -27,6 +27,7 @@ public class Namespace extends SourceManipulation implements INamespace{
* Returns the typeName. * Returns the typeName.
* @return String * @return String
*/ */
@Override
public String getTypeName() { public String getTypeName() {
return typeName; return typeName;
} }

View file

@ -25,6 +25,7 @@ public class NullBinaryParser extends PlatformObject implements IBinaryParser {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.IBinaryParser#getBinary(org.eclipse.core.runtime.IPath) * @see org.eclipse.cdt.core.IBinaryParser#getBinary(org.eclipse.core.runtime.IPath)
*/ */
@Override
public IBinaryFile getBinary(byte[] data, IPath path) throws IOException { public IBinaryFile getBinary(byte[] data, IPath path) throws IOException {
throw new IOException(CCorePlugin.getResourceString("CoreModel.NullBinaryParser.Not_binary_file")); //$NON-NLS-1$ throw new IOException(CCorePlugin.getResourceString("CoreModel.NullBinaryParser.Not_binary_file")); //$NON-NLS-1$
} }
@ -32,6 +33,7 @@ public class NullBinaryParser extends PlatformObject implements IBinaryParser {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.IBinaryParser#getBinary(org.eclipse.core.runtime.IPath) * @see org.eclipse.cdt.core.IBinaryParser#getBinary(org.eclipse.core.runtime.IPath)
*/ */
@Override
public IBinaryFile getBinary(IPath path) throws IOException { public IBinaryFile getBinary(IPath path) throws IOException {
throw new IOException(CCorePlugin.getResourceString("CoreModel.NullBinaryParser.Not_binary_file")); //$NON-NLS-1$ throw new IOException(CCorePlugin.getResourceString("CoreModel.NullBinaryParser.Not_binary_file")); //$NON-NLS-1$
} }
@ -39,6 +41,7 @@ public class NullBinaryParser extends PlatformObject implements IBinaryParser {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.IBinaryParser#getFormat() * @see org.eclipse.cdt.core.IBinaryParser#getFormat()
*/ */
@Override
public String getFormat() { public String getFormat() {
return CCorePlugin.getResourceString("CoreModel.NullBinaryParser.Null_Format"); //$NON-NLS-1$ return CCorePlugin.getResourceString("CoreModel.NullBinaryParser.Null_Format"); //$NON-NLS-1$
} }
@ -46,6 +49,7 @@ public class NullBinaryParser extends PlatformObject implements IBinaryParser {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.IBinaryParser#isBinary(byte[], org.eclipse.core.runtime.IPath) * @see org.eclipse.cdt.core.IBinaryParser#isBinary(byte[], org.eclipse.core.runtime.IPath)
*/ */
@Override
public boolean isBinary(byte[] array, IPath path) { public boolean isBinary(byte[] array, IPath path) {
return false; return false;
} }
@ -53,6 +57,7 @@ public class NullBinaryParser extends PlatformObject implements IBinaryParser {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.IBinaryParser#getBufferSize() * @see org.eclipse.cdt.core.IBinaryParser#getBufferSize()
*/ */
@Override
public int getHintBufferSize() { public int getHintBufferSize() {
return 0; return 0;
} }

View file

@ -9,7 +9,7 @@
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Map; import java.util.Map;
@ -27,7 +27,7 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
public abstract class Openable extends Parent implements IOpenable { public abstract class Openable extends Parent implements IOpenable {
protected IResource resource; protected IResource resource;
public Openable(ICElement parent, IPath path, int type) { public Openable(ICElement parent, IPath path, int type) {
// Check if the file is under the workspace. // Check if the file is under the workspace.
@ -38,7 +38,7 @@ public abstract class Openable extends Parent implements IOpenable {
public Openable(ICElement parent, IResource resource, int type) { public Openable(ICElement parent, IResource resource, int type) {
this(parent, resource, resource.getName(), type); this(parent, resource, resource.getName(), type);
} }
public Openable(ICElement parent, IResource res, String name, int type) { public Openable(ICElement parent, IResource res, String name, int type) {
super(parent, name, type); super(parent, name, type);
resource = res; resource = res;
@ -57,6 +57,7 @@ public abstract class Openable extends Parent implements IOpenable {
* *
* @see IBufferChangedListener * @see IBufferChangedListener
*/ */
@Override
public void bufferChanged(BufferChangedEvent event) { public void bufferChanged(BufferChangedEvent event) {
if (event.getBuffer().isClosed()) { if (event.getBuffer().isClosed()) {
CModelManager.getDefault().getElementsOutOfSynchWithBuffers().remove(this); CModelManager.getDefault().getElementsOutOfSynchWithBuffers().remove(this);
@ -64,7 +65,7 @@ public abstract class Openable extends Parent implements IOpenable {
} else { } else {
CModelManager.getDefault().getElementsOutOfSynchWithBuffers().put(this, this); CModelManager.getDefault().getElementsOutOfSynchWithBuffers().put(this, this);
} }
} }
/** /**
* Builds this element's structure and properties in the given * Builds this element's structure and properties in the given
@ -103,6 +104,7 @@ public abstract class Openable extends Parent implements IOpenable {
/** /**
* @see org.eclipse.cdt.core.model.IOpenable#getBuffer() * @see org.eclipse.cdt.core.model.IOpenable#getBuffer()
*/ */
@Override
public IBuffer getBuffer() throws CModelException { public IBuffer getBuffer() throws CModelException {
if (hasBuffer()) { if (hasBuffer()) {
// ensure element is open // ensure element is open
@ -132,7 +134,7 @@ public abstract class Openable extends Parent implements IOpenable {
protected BufferManager getBufferManager() { protected BufferManager getBufferManager() {
return BufferManager.getDefaultBufferManager(); return BufferManager.getDefaultBufferManager();
} }
/** /**
* Returns true if this element may have an associated source buffer, * Returns true if this element may have an associated source buffer,
* otherwise false. Subclasses must override as required. * otherwise false. Subclasses must override as required.
@ -143,6 +145,7 @@ public abstract class Openable extends Parent implements IOpenable {
/** /**
* @see org.eclipse.cdt.core.model.IOpenable#hasUnsavedChanges() * @see org.eclipse.cdt.core.model.IOpenable#hasUnsavedChanges()
*/ */
@Override
public boolean hasUnsavedChanges() throws CModelException{ public boolean hasUnsavedChanges() throws CModelException{
if (isReadOnly() || !isOpen()) { if (isReadOnly() || !isOpen()) {
return false; return false;
@ -165,22 +168,24 @@ public abstract class Openable extends Parent implements IOpenable {
} }
} }
} }
return false; return false;
} }
/** /**
* Subclasses must override as required. * Subclasses must override as required.
* *
* @see org.eclipse.cdt.core.model.IOpenable#isConsistent() * @see org.eclipse.cdt.core.model.IOpenable#isConsistent()
*/ */
@Override
public boolean isConsistent() throws CModelException { public boolean isConsistent() throws CModelException {
return true; return true;
} }
/** /**
* @see org.eclipse.cdt.core.model.IOpenable#isOpen() * @see org.eclipse.cdt.core.model.IOpenable#isOpen()
*/ */
@Override
public boolean isOpen() { public boolean isOpen() {
return CModelManager.getDefault().getInfo(this) != null; return CModelManager.getDefault().getInfo(this) != null;
} }
@ -203,10 +208,12 @@ public abstract class Openable extends Parent implements IOpenable {
/** /**
* @see org.eclipse.cdt.core.model.IOpenable#makeConsistent(IProgressMonitor) * @see org.eclipse.cdt.core.model.IOpenable#makeConsistent(IProgressMonitor)
*/ */
@Override
public void makeConsistent(IProgressMonitor pm) throws CModelException { public void makeConsistent(IProgressMonitor pm) throws CModelException {
makeConsistent(pm, false); makeConsistent(pm, false);
} }
@Override
public void makeConsistent(IProgressMonitor monitor, boolean forced) throws CModelException { public void makeConsistent(IProgressMonitor monitor, boolean forced) throws CModelException {
// only translation units can be inconsistent // only translation units can be inconsistent
// other openables cannot be inconsistent so default is to do nothing // other openables cannot be inconsistent so default is to do nothing
@ -215,6 +222,7 @@ public abstract class Openable extends Parent implements IOpenable {
/** /**
* @see org.eclipse.cdt.core.model.IOpenable#open(IProgressMonitor) * @see org.eclipse.cdt.core.model.IOpenable#open(IProgressMonitor)
*/ */
@Override
public void open(IProgressMonitor pm) throws CModelException { public void open(IProgressMonitor pm) throws CModelException {
getElementInfo(pm); getElementInfo(pm);
} }
@ -249,7 +257,7 @@ public abstract class Openable extends Parent implements IOpenable {
if (CModelManager.VERBOSE){ if (CModelManager.VERBOSE){
System.out.println("OPENING Element ("+ Thread.currentThread()+"): " + this); //$NON-NLS-1$//$NON-NLS-2$ System.out.println("OPENING Element ("+ Thread.currentThread()+"): " + this); //$NON-NLS-1$//$NON-NLS-2$
} }
// open the parent if necessary // open the parent if necessary
openParent(info, newElements, monitor); openParent(info, newElements, monitor);
if (monitor != null && monitor.isCanceled()) if (monitor != null && monitor.isCanceled())
@ -268,7 +276,7 @@ public abstract class Openable extends Parent implements IOpenable {
newElements.remove(this); newElements.remove(this);
throw e; throw e;
} }
// remove out of sync buffer for this element // remove out of sync buffer for this element
CModelManager.getDefault().getElementsOutOfSynchWithBuffers().remove(this); CModelManager.getDefault().getElementsOutOfSynchWithBuffers().remove(this);
} }
@ -276,6 +284,7 @@ public abstract class Openable extends Parent implements IOpenable {
/** /**
* @see org.eclipse.cdt.core.model.IOpenable#save(IProgressMonitor, boolean) * @see org.eclipse.cdt.core.model.IOpenable#save(IProgressMonitor, boolean)
*/ */
@Override
public void save(IProgressMonitor pm, boolean force) throws CModelException { public void save(IProgressMonitor pm, boolean force) throws CModelException {
IResource res = getResource(); IResource res = getResource();
if (res != null) { if (res != null) {
@ -289,7 +298,7 @@ public abstract class Openable extends Parent implements IOpenable {
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this)); throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this));
} }
IBuffer buf = getBuffer(); IBuffer buf = getBuffer();
if (buf != null) { if (buf != null) {
buf.save(pm, force); buf.save(pm, force);
this.makeConsistent(pm); // update the element info of this element this.makeConsistent(pm); // update the element info of this element
} }

View file

@ -28,27 +28,30 @@ public class PathEntry implements IPathEntry {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.cdt.core.IPathEntry#getEntryKind() * @see org.eclipse.cdt.core.IPathEntry#getEntryKind()
*/ */
@Override
public IPath getPath() { public IPath getPath() {
return path; return path;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.cdt.core.IPathEntry#getEntryKind() * @see org.eclipse.cdt.core.IPathEntry#getEntryKind()
*/ */
@Override
public int getEntryKind() { public int getEntryKind() {
return entryKind; return entryKind;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.cdt.core.IPathEntry#isExported() * @see org.eclipse.cdt.core.IPathEntry#isExported()
*/ */
@Override
public boolean isExported() { public boolean isExported() {
return isExported; return isExported;
} }
@ -80,7 +83,7 @@ public class PathEntry implements IPathEntry {
} }
return super.equals(obj); return super.equals(obj);
} }
/** /**
* Returns the kind from its <code>String</code> form. * Returns the kind from its <code>String</code> form.
*/ */

View file

@ -114,7 +114,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
// Synchronized the access of the cache entries. // Synchronized the access of the cache entries.
protected Map<ICProject, ArrayList<IPathEntry>> resolvedMap = new Hashtable<ICProject, ArrayList<IPathEntry>>(); protected Map<ICProject, ArrayList<IPathEntry>> resolvedMap = new Hashtable<ICProject, ArrayList<IPathEntry>>();
private Map<ICProject, PathEntryResolveInfo> resolvedInfoMap = new Hashtable<ICProject, PathEntryResolveInfo>(); private Map<ICProject, PathEntryResolveInfo> resolvedInfoMap = new Hashtable<ICProject, PathEntryResolveInfo>();
private ThreadLocalMap resolveInfoValidState = new ThreadLocalMap(); private ThreadLocalMap resolveInfoValidState = new ThreadLocalMap();
// Accessing the map is synch with the class // Accessing the map is synch with the class
private Map<IProject, IPathEntryStore> storeMap = new HashMap<IProject, IPathEntryStore>(); private Map<IProject, IPathEntryStore> storeMap = new HashMap<IProject, IPathEntryStore>();
@ -122,7 +122,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
private static PathEntryManager pathEntryManager; private static PathEntryManager pathEntryManager;
protected ConcurrentLinkedQueue<PathEntryProblem> markerProblems = new ConcurrentLinkedQueue<PathEntryProblem>(); protected ConcurrentLinkedQueue<PathEntryProblem> markerProblems = new ConcurrentLinkedQueue<PathEntryProblem>();
//Setting up a generate markers job, it does not get scheduled //Setting up a generate markers job, it does not get scheduled
Job markerTask = new GenerateMarkersJob("PathEntry Marker Job"); //$NON-NLS-1$ Job markerTask = new GenerateMarkersJob("PathEntry Marker Job"); //$NON-NLS-1$
@ -132,11 +132,11 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
private class PathEntryProblem { private class PathEntryProblem {
IProject project; IProject project;
ICModelStatus[] problems; ICModelStatus[] problems;
public PathEntryProblem(IProject project, ICModelStatus[] problems) { public PathEntryProblem(IProject project, ICModelStatus[] problems) {
this.project = project; this.project = project;
this.problems = problems; this.problems = problems;
} }
} }
private class PathEntryContainerLock implements IPathEntryContainer { private class PathEntryContainerLock implements IPathEntryContainer {
@ -153,27 +153,30 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getPathEntries() * @see org.eclipse.cdt.core.model.IPathEntryContainer#getPathEntries()
*/ */
@Override
public IPathEntry[] getPathEntries() { public IPathEntry[] getPathEntries() {
return NO_PATHENTRIES; return NO_PATHENTRIES;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getDescription() * @see org.eclipse.cdt.core.model.IPathEntryContainer#getDescription()
*/ */
@Override
public String getDescription() { public String getDescription() {
return new String("Lock container"); //$NON-NLS-1$ return new String("Lock container"); //$NON-NLS-1$
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getPath() * @see org.eclipse.cdt.core.model.IPathEntryContainer#getPath()
*/ */
@Override
public IPath getPath() { public IPath getPath() {
return Path.EMPTY; return Path.EMPTY;
} }
@ -294,8 +297,8 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
IMacroEntry[] macros = macroList.toArray(new IMacroEntry[macroList.size()]); IMacroEntry[] macros = macroList.toArray(new IMacroEntry[macroList.size()]);
macroList.clear(); macroList.clear();
// For the macros the closest symbol will override // For the macros the closest symbol will override
// /projec/src/file.c --> NDEBUG=1 // /projec/src/file.c --> NDEBUG=1
// /project/src --> NDEBUG=0 // /project/src --> NDEBUG=0
// //
@ -387,7 +390,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
// includes with the closest match to the resource will come first // includes with the closest match to the resource will come first
// /project/src/file.c --> /usr/local/include // /project/src/file.c --> /usr/local/include
// /project --> /usr/include // /project --> /usr/include
// //
// /usr/local/include must come first. // /usr/local/include must come first.
// //
int count = resPath.segmentCount(); int count = resPath.segmentCount();
@ -422,7 +425,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} }
} }
} }
return entryList; return entryList;
} }
/** /**
@ -440,7 +443,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} }
return null; return null;
} }
public PathEntryResolveInfo getResolveInfo(ICProject cproject, boolean useCache) throws CModelException{ public PathEntryResolveInfo getResolveInfo(ICProject cproject, boolean useCache) throws CModelException{
PathEntryResolveInfo info = resolvedInfoMap.get(cproject); PathEntryResolveInfo info = resolvedInfoMap.get(cproject);
if (info == null && useCache){ if (info == null && useCache){
@ -450,20 +453,20 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
if (info == null || !useCache || !getResolveInfoValidState(cproject)){ if (info == null || !useCache || !getResolveInfoValidState(cproject)){
Object[] resolved = getResolvedPathEntries(cproject, false, false); Object[] resolved = getResolvedPathEntries(cproject, false, false);
if (resolved != null) if (resolved != null)
info = (PathEntryResolveInfo)resolved[1]; info = (PathEntryResolveInfo)resolved[1];
} }
return info; return info;
} }
private void setResolveInfoValidState(ICProject cproject, boolean valid){ private void setResolveInfoValidState(ICProject cproject, boolean valid){
Object v = valid ? null : Boolean.FALSE; Object v = valid ? null : Boolean.FALSE;
resolveInfoValidState.set(cproject, v); resolveInfoValidState.set(cproject, v);
} }
private boolean getResolveInfoValidState(ICProject cproject){ private boolean getResolveInfoValidState(ICProject cproject){
return resolveInfoValidState.get(cproject) == null; return resolveInfoValidState.get(cproject) == null;
} }
protected IPathEntry[] removeCachedResolvedPathEntries(ICProject cproject) { protected IPathEntry[] removeCachedResolvedPathEntries(ICProject cproject) {
ArrayList<IPathEntry> resolvedListEntries = resolvedMap.remove(cproject); ArrayList<IPathEntry> resolvedListEntries = resolvedMap.remove(cproject);
resolvedInfoMap.remove(cproject); resolvedInfoMap.remove(cproject);
@ -523,7 +526,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
/** /**
* This method will not expand container extending IPathEntryContainerExtension * This method will not expand container extending IPathEntryContainerExtension
* *
* @param cproject * @param cproject
* @param generateMarkers * @param generateMarkers
* @return * @return
@ -745,12 +748,14 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
// causing some grief // causing some grief
SafeRunner.run(new ISafeRunnable() { SafeRunner.run(new ISafeRunnable() {
@Override
public void handleException(Throwable exception) { public void handleException(Throwable exception) {
IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID,
"Exception occurred in container initializer: " + initializer, exception); //$NON-NLS-1$ "Exception occurred in container initializer: " + initializer, exception); //$NON-NLS-1$
CCorePlugin.log(status); CCorePlugin.log(status);
} }
@Override
public void run() throws Exception { public void run() throws Exception {
initializer.initialize(containerPath, project); initializer.initialize(containerPath, project);
ok[0] = true; ok[0] = true;
@ -777,7 +782,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
* A containerID is the first segment of any container path, used to * A containerID is the first segment of any container path, used to
* identify the registered container initializer. * identify the registered container initializer.
* <p> * <p>
* *
* @param containerID - * @param containerID -
* a containerID identifying a registered initializer * a containerID identifying a registered initializer
* @return PathEntryContainerInitializer - the registered container * @return PathEntryContainerInitializer - the registered container
@ -1011,7 +1016,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
throw new CModelException(e); throw new CModelException(e);
} }
} }
/** /**
* Collects path entry errors for each project and generate error markers for these errors * Collects path entry errors for each project and generate error markers for these errors
* @param project - Project with path entry errors * @param project - Project with path entry errors
@ -1031,7 +1036,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} }
@Override @Override
public IStatus runInWorkspace(IProgressMonitor monitor) { public IStatus runInWorkspace(IProgressMonitor monitor) {
while (markerProblems.peek() != null && !monitor.isCanceled()) { while (markerProblems.peek() != null && !monitor.isCanceled()) {
PathEntryProblem problem = markerProblems.poll(); PathEntryProblem problem = markerProblems.poll();
IProject project = problem.project; IProject project = problem.project;
@ -1044,7 +1049,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
return Status.OK_STATUS; return Status.OK_STATUS;
} }
} }
private boolean needDelta(ICProject cproject){ private boolean needDelta(ICProject cproject){
try { try {
PathEntryStoreProxy store = (PathEntryStoreProxy)getPathEntryStore(cproject.getProject(), false); PathEntryStoreProxy store = (PathEntryStoreProxy)getPathEntryStore(cproject.getProject(), false);
@ -1172,7 +1177,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
flag = ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE; flag = ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE;
break; break;
} }
case IPathEntry.CDT_MACRO: { case IPathEntry.CDT_MACRO: {
IMacroEntry macro = (IMacroEntry)entry; IMacroEntry macro = (IMacroEntry)entry;
IPath path = macro.getPath(); IPath path = macro.getPath();
celement = CoreModel.getDefault().create(path); celement = CoreModel.getDefault().create(path);
@ -1286,7 +1291,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
// } // }
// return store; // return store;
} }
// private IPathEntryStore createDefaultStore(IProject project){ // private IPathEntryStore createDefaultStore(IProject project){
// if (CProjectDescriptionManager.getInstance().isNewStyleIndexCfg(project)){ // if (CProjectDescriptionManager.getInstance().isNewStyleIndexCfg(project)){
// return new ConfigBasedPathEntryStore(project); // return new ConfigBasedPathEntryStore(project);
@ -1296,9 +1301,10 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.cdt.core.resources.IPathEntryStoreListener#pathEntryStoreChanged(org.eclipse.cdt.core.resources.PathEntryChangedEvent) * @see org.eclipse.cdt.core.resources.IPathEntryStoreListener#pathEntryStoreChanged(org.eclipse.cdt.core.resources.PathEntryChangedEvent)
*/ */
@Override
public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) { public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
IProject project = event.getProject(); IProject project = event.getProject();
@ -1329,9 +1335,10 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.eclipse.cdt.core.model.IElementChangedListener#elementChanged(org.eclipse.cdt.core.model.ElementChangedEvent) * @see org.eclipse.cdt.core.model.IElementChangedListener#elementChanged(org.eclipse.cdt.core.model.ElementChangedEvent)
*/ */
@Override
public void elementChanged(ElementChangedEvent event) { public void elementChanged(ElementChangedEvent event) {
try { try {
if (processDelta(event.getDelta()) == true) { if (processDelta(event.getDelta()) == true) {
@ -1369,7 +1376,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
protected boolean processDelta(ICElementDelta delta) throws CModelException { protected boolean processDelta(ICElementDelta delta) throws CModelException {
int kind = delta.getKind(); int kind = delta.getKind();
ICElement element = delta.getElement(); ICElement element = delta.getElement();
int type = element.getElementType(); int type = element.getElementType();
// handle open, closing and removing of projects // handle open, closing and removing of projects
if ( type == ICElement.C_PROJECT) { if ( type == ICElement.C_PROJECT) {
@ -1392,11 +1399,11 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
containerRemove(cproject); containerRemove(cproject);
} }
} }
} }
return true; return true;
} }
// project change, traverse children. // project change, traverse children.
} }
if (element instanceof IWorkingCopy) { if (element instanceof IWorkingCopy) {
return false; return false;
} }
@ -1464,7 +1471,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
updatePathEntry.schedule(); updatePathEntry.schedule();
} }
} }
public ICModelStatus validatePathEntry(ICProject cProject, IPathEntry[] entries) { public ICModelStatus validatePathEntry(ICProject cProject, IPathEntry[] entries) {
return PathEntryUtil.validatePathEntry(cProject, entries); return PathEntryUtil.validatePathEntry(cProject, entries);
} }

View file

@ -30,12 +30,12 @@ import org.eclipse.core.runtime.CoreException;
public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPathEntryStore, IPathEntryStoreListener { public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPathEntryStore, IPathEntryStoreListener {
private List<IPathEntryStoreListener> fListeners; private List<IPathEntryStoreListener> fListeners;
private IPathEntryStore fStore; private IPathEntryStore fStore;
public PathEntryStoreProxy(IProject project){ public PathEntryStoreProxy(IProject project){
super(project, PathEntryManager.PATHENTRY_STORE_UNIQ_ID); super(project, PathEntryManager.PATHENTRY_STORE_UNIQ_ID);
fListeners = Collections.synchronizedList(new ArrayList<IPathEntryStoreListener>()); fListeners = Collections.synchronizedList(new ArrayList<IPathEntryStoreListener>());
} }
public IPathEntryStore getStore(){ public IPathEntryStore getStore(){
providerRequested(); providerRequested();
return fStore; return fStore;
@ -43,13 +43,15 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.resources.IPathEntryStore#addPathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener) * @see org.eclipse.cdt.core.resources.IPathEntryStore#addPathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener)
*/ */
public void addPathEntryStoreListener(IPathEntryStoreListener listener) { @Override
public void addPathEntryStoreListener(IPathEntryStoreListener listener) {
fListeners.add(listener); fListeners.add(listener);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.resources.IPathEntryStore#removePathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener) * @see org.eclipse.cdt.core.resources.IPathEntryStore#removePathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener)
*/ */
@Override
public void removePathEntryStoreListener(IPathEntryStoreListener listener) { public void removePathEntryStoreListener(IPathEntryStoreListener listener) {
fListeners.remove(listener); fListeners.remove(listener);
} }
@ -58,7 +60,7 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, project, PathEntryStoreChangedEvent.CONTENT_CHANGED); PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, project, PathEntryStoreChangedEvent.CONTENT_CHANGED);
notifyListeners(evt); notifyListeners(evt);
} }
private void notifyListeners(PathEntryStoreChangedEvent evt){ private void notifyListeners(PathEntryStoreChangedEvent evt){
IPathEntryStoreListener[] observers = new IPathEntryStoreListener[fListeners.size()]; IPathEntryStoreListener[] observers = new IPathEntryStoreListener[fListeners.size()];
fListeners.toArray(observers); fListeners.toArray(observers);
@ -86,30 +88,35 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
return super.getProject(); return super.getProject();
} }
@Override
public ICExtensionReference getExtensionReference() { public ICExtensionReference getExtensionReference() {
//TODO: calculate //TODO: calculate
return null; return null;
} }
@Override
public ICConfigExtensionReference getConfigExtensionReference() { public ICConfigExtensionReference getConfigExtensionReference() {
return null; return null;
} }
@Override
public IPathEntry[] getRawPathEntries() throws CoreException { public IPathEntry[] getRawPathEntries() throws CoreException {
providerRequested(); providerRequested();
return fStore.getRawPathEntries(); return fStore.getRawPathEntries();
} }
@Override
public void setRawPathEntries(IPathEntry[] entries) throws CoreException { public void setRawPathEntries(IPathEntry[] entries) throws CoreException {
providerRequested(); providerRequested();
fStore.setRawPathEntries(entries); fStore.setRawPathEntries(entries);
} }
@Override
public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) { public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
notifyListeners(event); notifyListeners(event);
} }
@Override @Override
protected Object createDefaultProvider(ICConfigurationDescription cfgDes, protected Object createDefaultProvider(ICConfigurationDescription cfgDes,
boolean newStile) { boolean newStile) {
@ -148,10 +155,10 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
@Override @Override
protected boolean doHandleEvent(CProjectDescriptionEvent event) { protected boolean doHandleEvent(CProjectDescriptionEvent event) {
IPathEntryStore oldStore = fStore; IPathEntryStore oldStore = fStore;
boolean result = super.doHandleEvent(event); boolean result = super.doHandleEvent(event);
if(!result) if(!result)
postProcessProviderChange(fStore, oldStore); postProcessProviderChange(fStore, oldStore);
return result; return result;
} }

View file

@ -16,24 +16,25 @@ import org.eclipse.core.runtime.NullProgressMonitor;
/** /**
* A progress monitor accepting a <code>ICancelable</code> object to receive the cancel request. * A progress monitor accepting a <code>ICancelable</code> object to receive the cancel request.
* *
* @since 5.0 * @since 5.0
*/ */
public class ProgressMonitorAndCanceler extends NullProgressMonitor implements ICanceler { public class ProgressMonitorAndCanceler extends NullProgressMonitor implements ICanceler {
private ICancelable fCancelable; private ICancelable fCancelable;
@Override
public void setCancelable(ICancelable cancelable) { public void setCancelable(ICancelable cancelable) {
fCancelable= cancelable; fCancelable= cancelable;
checkCanceled(); checkCanceled();
} }
@Override @Override
public void setCanceled(boolean canceled) { public void setCanceled(boolean canceled) {
super.setCanceled(canceled); super.setCanceled(canceled);
checkCanceled(); checkCanceled();
} }
private void checkCanceled() { private void checkCanceled() {
if (fCancelable != null && isCanceled()) { if (fCancelable != null && isCanceled()) {
fCancelable.cancel(); fCancelable.cancel();

View file

@ -32,7 +32,7 @@ public class Region implements IRegion {
/** /**
* Creates an empty region. * Creates an empty region.
* *
* @see IRegion * @see IRegion
*/ */
public Region() { public Region() {
@ -42,6 +42,7 @@ public class Region implements IRegion {
/** /**
* @see IRegion#add(ICElement) * @see IRegion#add(ICElement)
*/ */
@Override
public void add(ICElement element) { public void add(ICElement element) {
if (!contains(element)) { if (!contains(element)) {
// "new" element added to region // "new" element added to region
@ -54,6 +55,7 @@ public class Region implements IRegion {
/** /**
* @see IRegion * @see IRegion
*/ */
@Override
public boolean contains(ICElement element) { public boolean contains(ICElement element) {
int size = fRootElements.size(); int size = fRootElements.size();
@ -77,7 +79,7 @@ public class Region implements IRegion {
/** /**
* Returns a collection of all the parents of this element in bottom-up * Returns a collection of all the parents of this element in bottom-up
* order. * order.
* *
*/ */
private ArrayList<ICElement> getAncestors(ICElement element) { private ArrayList<ICElement> getAncestors(ICElement element) {
ArrayList<ICElement> parents = new ArrayList<ICElement>(); ArrayList<ICElement> parents = new ArrayList<ICElement>();
@ -93,6 +95,7 @@ public class Region implements IRegion {
/** /**
* @see IRegion * @see IRegion
*/ */
@Override
public ICElement[] getElements() { public ICElement[] getElements() {
int size = fRootElements.size(); int size = fRootElements.size();
ICElement[] roots = new ICElement[size]; ICElement[] roots = new ICElement[size];
@ -106,6 +109,7 @@ public class Region implements IRegion {
/** /**
* @see IRegion#remove(ICElement) * @see IRegion#remove(ICElement)
*/ */
@Override
public boolean remove(ICElement element) { public boolean remove(ICElement element) {
removeAllChildren(element); removeAllChildren(element);
@ -115,7 +119,7 @@ public class Region implements IRegion {
/** /**
* Removes any children of this element that are contained within this * Removes any children of this element that are contained within this
* region as this parent is about to be added to the region. * region as this parent is about to be added to the region.
* *
* <p> * <p>
* Children are all children, not just direct children. * Children are all children, not just direct children.
*/ */

View file

@ -52,6 +52,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
/** /**
* @see ISourceManipulation * @see ISourceManipulation
*/ */
@Override
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) {
@ -73,6 +74,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
/** /**
* @see ISourceManipulation * @see ISourceManipulation
*/ */
@Override
public void delete(boolean force, IProgressMonitor monitor) throws CModelException { public void delete(boolean force, IProgressMonitor monitor) throws CModelException {
ICElement[] elements = new ICElement[] {this}; ICElement[] elements = new ICElement[] {this};
getCModel().delete(elements, force, monitor); getCModel().delete(elements, force, monitor);
@ -81,6 +83,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
/** /**
* @see ISourceManipulation * @see ISourceManipulation
*/ */
@Override
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) {
@ -102,6 +105,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
/** /**
* @see ISourceManipulation * @see ISourceManipulation
*/ */
@Override
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$
@ -115,6 +119,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
/** /**
* @see IMember * @see IMember
*/ */
@Override
public ITranslationUnit getTranslationUnit() { public ITranslationUnit getTranslationUnit() {
try { try {
return getSourceManipulationInfo().getTranslationUnit(); return getSourceManipulationInfo().getTranslationUnit();
@ -152,6 +157,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
/** /**
* @see ISourceReference * @see ISourceReference
*/ */
@Override
public String getSource() throws CModelException { public String getSource() throws CModelException {
return getSourceManipulationInfo().getSource(); return getSourceManipulationInfo().getSource();
} }
@ -159,6 +165,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
/** /**
* @see ISourceReference * @see ISourceReference
*/ */
@Override
public ISourceRange getSourceRange() throws CModelException { public ISourceRange getSourceRange() throws CModelException {
return getSourceManipulationInfo().getSourceRange(); return getSourceManipulationInfo().getSourceRange();
} }
@ -175,7 +182,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
public IResource getResource() { public IResource getResource() {
return null; return null;
} }
@Override @Override
protected CElementInfo createElementInfo () { protected CElementInfo createElementInfo () {
return new SourceManipulationInfo(this); return new SourceManipulationInfo(this);
@ -184,9 +191,9 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
protected SourceManipulationInfo getSourceManipulationInfo() throws CModelException { protected SourceManipulationInfo getSourceManipulationInfo() throws CModelException {
return (SourceManipulationInfo)getElementInfo(); return (SourceManipulationInfo)getElementInfo();
} }
public boolean isIdentical(SourceManipulation other) throws CModelException{ public boolean isIdentical(SourceManipulation other) throws CModelException{
return (this.equals(other) return (this.equals(other)
&& (this.getSourceManipulationInfo().hasSameContentsAs(other.getSourceManipulationInfo()))); && (this.getSourceManipulationInfo().hasSameContentsAs(other.getSourceManipulationInfo())));
} }
@ -199,7 +206,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
if (openableParent == null) { if (openableParent == null) {
return; return;
} }
newElements.put(this, info); newElements.put(this, info);
CElementInfo openableParentInfo = (CElementInfo) CModelManager.getDefault().getInfo(openableParent); CElementInfo openableParentInfo = (CElementInfo) CModelManager.getDefault().getInfo(openableParent);
@ -215,7 +222,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
// //
} }
} }
public void setIdPos(int startPos, int length) { public void setIdPos(int startPos, int length) {
try { try {
getSourceManipulationInfo().setIdPos(startPos, length); getSourceManipulationInfo().setIdPos(startPos, length);
@ -301,7 +308,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
case ICElement.C_TEMPLATE_METHOD: case ICElement.C_TEMPLATE_METHOD:
case ICElement.C_TEMPLATE_METHOD_DECLARATION: case ICElement.C_TEMPLATE_METHOD_DECLARATION:
for (ICElement element2 : children) { for (ICElement element2 : children) {
if (elementType == element2.getElementType() if (elementType == element2.getElementType()
&& elementName.equals(element2.getElementName())) { && elementName.equals(element2.getElementName())) {
assert element2 instanceof IFunctionDeclaration; assert element2 instanceof IFunctionDeclaration;
String[] functionParams= ((IFunctionDeclaration)element2).getParameterTypes(); String[] functionParams= ((IFunctionDeclaration)element2).getParameterTypes();
@ -316,7 +323,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
case ICElement.C_TEMPLATE_STRUCT: case ICElement.C_TEMPLATE_STRUCT:
case ICElement.C_TEMPLATE_UNION: case ICElement.C_TEMPLATE_UNION:
for (ICElement element2 : children) { for (ICElement element2 : children) {
if (elementType == element2.getElementType() if (elementType == element2.getElementType()
&& elementName.equals(element2.getElementName())) { && elementName.equals(element2.getElementName())) {
assert element2 instanceof ITemplate; assert element2 instanceof ITemplate;
String[] templateParams= ((ITemplate)element2).getTemplateParameterTypes(); String[] templateParams= ((ITemplate)element2).getTemplateParameterTypes();
@ -329,7 +336,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
break; break;
default: default:
for (ICElement element2 : children) { for (ICElement element2 : children) {
if (elementType == element2.getElementType() if (elementType == element2.getElementType()
&& elementName.equals(element2.getElementName())) { && elementName.equals(element2.getElementName())) {
element= (CElement) element2; element= (CElement) element2;
break; break;
@ -362,14 +369,16 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
return CElement.CEM_SOURCEELEMENT; return CElement.CEM_SOURCEELEMENT;
} }
@Override
public boolean isActive() { public boolean isActive() {
return fIsActive; return fIsActive;
} }
@Override
public int getIndex() { public int getIndex() {
return fIndex; return fIndex;
} }
public void setActive(boolean active) { public void setActive(boolean active) {
fIsActive= active; fIsActive= active;
} }
@ -377,12 +386,12 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
public void setIndex(int i) { public void setIndex(int i) {
fIndex= (short) i; fIndex= (short) i;
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Util.combineHashCodes(fIndex, super.hashCode()); return Util.combineHashCodes(fIndex, super.hashCode());
} }
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other instanceof ISourceReference) { if (other instanceof ISourceReference) {

View file

@ -50,6 +50,7 @@ class SourceRange implements ISourceRange {
/** /**
* @see ISourceRange * @see ISourceRange
*/ */
@Override
public int getLength() { public int getLength() {
return length; return length;
} }
@ -57,24 +58,29 @@ class SourceRange implements ISourceRange {
/** /**
* @see ISourceRange * @see ISourceRange
*/ */
@Override
public int getStartPos() { public int getStartPos() {
return startPos; return startPos;
} }
/** /**
*/ */
@Override
public int getIdStartPos() { public int getIdStartPos() {
return idStartPos; return idStartPos;
} }
@Override
public int getIdLength() { public int getIdLength() {
return idLength; return idLength;
} }
@Override
public int getStartLine() { public int getStartLine() {
return startLine; return startLine;
} }
@Override
public int getEndLine() { public int getEndLine() {
return endLine; return endLine;
} }

View file

@ -50,6 +50,7 @@ public class SourceRoot extends CContainer implements ISourceRoot {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ISourceRoot#isOnclasspath(org.eclipse.cdt.core.model.ICElement) * @see org.eclipse.cdt.core.model.ISourceRoot#isOnclasspath(org.eclipse.cdt.core.model.ICElement)
*/ */
@Override
public boolean isOnSourceEntry(ICElement element) { public boolean isOnSourceEntry(ICElement element) {
IPath path = element.getPath(); IPath path = element.getPath();
return this.isOnSourceEntry(path); return this.isOnSourceEntry(path);
@ -58,13 +59,15 @@ public class SourceRoot extends CContainer implements ISourceRoot {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ISourceRoot#isOnSourceEntry(org.eclipse.core.resources.IResource) * @see org.eclipse.cdt.core.model.ISourceRoot#isOnSourceEntry(org.eclipse.core.resources.IResource)
*/ */
@Override
public boolean isOnSourceEntry(IResource res) { public boolean isOnSourceEntry(IResource res) {
IPath path = res.getFullPath(); IPath path = res.getFullPath();
return isOnSourceEntry(path); return isOnSourceEntry(path);
} }
@Override
public boolean isOnSourceEntry(IPath path) { public boolean isOnSourceEntry(IPath path) {
if (sourceEntry.getFullPath().isPrefixOf(path) if (sourceEntry.getFullPath().isPrefixOf(path)
&& !CoreModelUtil.isExcluded(path, sourceEntry.fullExclusionPatternChars())) { && !CoreModelUtil.isExcluded(path, sourceEntry.fullExclusionPatternChars())) {
return true; return true;
} }
@ -86,7 +89,7 @@ public class SourceRoot extends CContainer implements ISourceRoot {
} }
((CElement)getParent()).getHandleMemento(buff); ((CElement)getParent()).getHandleMemento(buff);
buff.append(getHandleMementoDelimiter()); buff.append(getHandleMementoDelimiter());
escapeMementoName(buff, path.toString()); escapeMementoName(buff, path.toString());
} }
/** /**

View file

@ -24,19 +24,21 @@ import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
public class Structure extends StructureDeclaration implements IStructure { public class Structure extends StructureDeclaration implements IStructure {
Map<String, ASTAccessVisibility> superClassesNames = new TreeMap<String, ASTAccessVisibility>(); Map<String, ASTAccessVisibility> superClassesNames = new TreeMap<String, ASTAccessVisibility>();
public Structure(ICElement parent, int kind, String name) { public Structure(ICElement parent, int kind, String name) {
super(parent, name, kind); super(parent, name, kind);
} }
@Override
public IField[] getFields() throws CModelException { public IField[] getFields() throws CModelException {
List<ICElement> fields = new ArrayList<ICElement>(); List<ICElement> fields = new ArrayList<ICElement>();
fields.addAll(getChildrenOfType(ICElement.C_FIELD)); fields.addAll(getChildrenOfType(ICElement.C_FIELD));
return fields.toArray(new IField[fields.size()]); return fields.toArray(new IField[fields.size()]);
} }
@Override
public IField getField(String name) { public IField getField(String name) {
try { try {
IField[] fields = getFields(); IField[] fields = getFields();
@ -50,6 +52,7 @@ public class Structure extends StructureDeclaration implements IStructure {
return null; return null;
} }
@Override
public IMethodDeclaration[] getMethods() throws CModelException { public IMethodDeclaration[] getMethods() throws CModelException {
List<ICElement> methods = new ArrayList<ICElement>(); List<ICElement> methods = new ArrayList<ICElement>();
methods.addAll(getChildrenOfType(ICElement.C_METHOD_DECLARATION)); methods.addAll(getChildrenOfType(ICElement.C_METHOD_DECLARATION));
@ -57,6 +60,7 @@ public class Structure extends StructureDeclaration implements IStructure {
return methods.toArray(new IMethodDeclaration[methods.size()]); return methods.toArray(new IMethodDeclaration[methods.size()]);
} }
@Override
public IMethodDeclaration getMethod(String name) { public IMethodDeclaration getMethod(String name) {
try { try {
IMethodDeclaration[] methods = getMethods(); IMethodDeclaration[] methods = getMethods();
@ -70,6 +74,7 @@ public class Structure extends StructureDeclaration implements IStructure {
return null; return null;
} }
@Override
public boolean isAbstract() throws CModelException { public boolean isAbstract() throws CModelException {
IMethodDeclaration[] methods = getMethods(); IMethodDeclaration[] methods = getMethods();
for (IMethodDeclaration method : methods) { for (IMethodDeclaration method : methods) {
@ -79,14 +84,16 @@ public class Structure extends StructureDeclaration implements IStructure {
return false; return false;
} }
@Override
public String[] getSuperClassesNames(){ public String[] getSuperClassesNames(){
return superClassesNames.keySet().toArray(new String[superClassesNames.keySet().size()]); return superClassesNames.keySet().toArray(new String[superClassesNames.keySet().size()]);
} }
@Override
public ASTAccessVisibility getSuperClassAccess(String name){ public ASTAccessVisibility getSuperClassAccess(String name){
return superClassesNames.get(name); return superClassesNames.get(name);
} }
public void addSuperClass(String name) { public void addSuperClass(String name) {
superClassesNames.put(name, ASTAccessVisibility.PUBLIC); superClassesNames.put(name, ASTAccessVisibility.PUBLIC);
} }

View file

@ -24,6 +24,7 @@ public class StructureDeclaration extends SourceManipulation implements IStructu
super(parent, name, kind); super(parent, name, kind);
} }
@Override
public String getTypeName() throws CModelException { public String getTypeName() throws CModelException {
return getStructureInfo().getTypeName(); return getStructureInfo().getTypeName();
} }
@ -32,14 +33,17 @@ public class StructureDeclaration extends SourceManipulation implements IStructu
getStructureInfo().setTypeName(type); getStructureInfo().setTypeName(type);
} }
@Override
public boolean isUnion() throws CModelException { public boolean isUnion() throws CModelException {
return getStructureInfo().isUnion(); return getStructureInfo().isUnion();
} }
@Override
public boolean isClass() throws CModelException { public boolean isClass() throws CModelException {
return getStructureInfo().isClass(); return getStructureInfo().isClass();
} }
@Override
public boolean isStruct() throws CModelException { public boolean isStruct() throws CModelException {
return getStructureInfo().isStruct(); return getStructureInfo().isStruct();
} }
@ -56,6 +60,7 @@ public class StructureDeclaration extends SourceManipulation implements IStructu
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IDeclaration#isStatic() * @see org.eclipse.cdt.core.model.IDeclaration#isStatic()
*/ */
@Override
public boolean isStatic() throws CModelException { public boolean isStatic() throws CModelException {
return getStructureInfo().isStatic(); return getStructureInfo().isStatic();
} }
@ -63,6 +68,7 @@ public class StructureDeclaration extends SourceManipulation implements IStructu
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IDeclaration#isConst() * @see org.eclipse.cdt.core.model.IDeclaration#isConst()
*/ */
@Override
public boolean isConst() throws CModelException { public boolean isConst() throws CModelException {
return getStructureInfo().isConst(); return getStructureInfo().isConst();
} }
@ -70,6 +76,7 @@ public class StructureDeclaration extends SourceManipulation implements IStructu
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IDeclaration#isVolatile() * @see org.eclipse.cdt.core.model.IDeclaration#isVolatile()
*/ */
@Override
public boolean isVolatile() throws CModelException { public boolean isVolatile() throws CModelException {
return getStructureInfo().isVolatile(); return getStructureInfo().isVolatile();
} }

View file

@ -17,7 +17,7 @@ import org.eclipse.cdt.core.model.IStructureTemplate;
public class StructureTemplate extends Structure implements IStructureTemplate { public class StructureTemplate extends Structure implements IStructureTemplate {
protected Template fTemplate; protected Template fTemplate;
public StructureTemplate(ICElement parent, int kind, String name) { public StructureTemplate(ICElement parent, int kind, String name) {
super(parent, kind, name); super(parent, kind, name);
fTemplate = new Template(name); fTemplate = new Template(name);
@ -27,10 +27,12 @@ public class StructureTemplate extends Structure implements IStructureTemplate {
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes() * @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes()
* @return String[] * @return String[]
*/ */
@Override
public String[] getTemplateParameterTypes() { public String[] getTemplateParameterTypes() {
return fTemplate.getTemplateParameterTypes(); return fTemplate.getTemplateParameterTypes();
} }
@Override
public String[] getTemplateArguments() { public String[] getTemplateArguments() {
return fTemplate.getTemplateArguments(); return fTemplate.getTemplateArguments();
} }
@ -46,13 +48,15 @@ public class StructureTemplate extends Structure implements IStructureTemplate {
/** /**
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters() * @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
*/ */
@Override
public int getNumberOfTemplateParameters() { public int getNumberOfTemplateParameters() {
return fTemplate.getNumberOfTemplateParameters(); return fTemplate.getNumberOfTemplateParameters();
} }
/** /**
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature() * @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
*/ */
@Override
public String getTemplateSignature() { public String getTemplateSignature() {
return fTemplate.getTemplateSignature(); return fTemplate.getTemplateSignature();
} }

View file

@ -25,10 +25,12 @@ public class StructureTemplateDeclaration extends StructureDeclaration implement
fTemplate = new Template(name); fTemplate = new Template(name);
} }
@Override
public String[] getTemplateParameterTypes() { public String[] getTemplateParameterTypes() {
return fTemplate.getTemplateParameterTypes(); return fTemplate.getTemplateParameterTypes();
} }
@Override
public String[] getTemplateArguments() { public String[] getTemplateArguments() {
return fTemplate.getTemplateArguments(); return fTemplate.getTemplateArguments();
} }
@ -37,10 +39,12 @@ public class StructureTemplateDeclaration extends StructureDeclaration implement
fTemplate.setTemplateInfo(templateParameterTypes, null); fTemplate.setTemplateInfo(templateParameterTypes, null);
} }
@Override
public String getTemplateSignature() throws CModelException { public String getTemplateSignature() throws CModelException {
return fTemplate.getTemplateSignature(); return fTemplate.getTemplateSignature();
} }
@Override
public int getNumberOfTemplateParameters() { public int getNumberOfTemplateParameters() {
return fTemplate.getNumberOfTemplateParameters(); return fTemplate.getNumberOfTemplateParameters();
} }

View file

@ -18,7 +18,7 @@ public class Template implements ITemplate {
protected String[] fTemplateParameterTypes; protected String[] fTemplateParameterTypes;
protected String[] fTemplateArgs; protected String[] fTemplateArgs;
protected String fName; protected String fName;
public Template(String name) { public Template(String name) {
fName = name; fName = name;
fTemplateParameterTypes= fgEmptyList; fTemplateParameterTypes= fgEmptyList;
@ -29,10 +29,12 @@ public class Template implements ITemplate {
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes() * @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes()
* @return String[] * @return String[]
*/ */
@Override
public String[] getTemplateParameterTypes() { public String[] getTemplateParameterTypes() {
return fTemplateParameterTypes; return fTemplateParameterTypes;
} }
@Override
public String[] getTemplateArguments() { public String[] getTemplateArguments() {
return fTemplateArgs; return fTemplateArgs;
} }
@ -48,13 +50,15 @@ public class Template implements ITemplate {
} }
} }
@Override
public int getNumberOfTemplateParameters() { public int getNumberOfTemplateParameters() {
return fTemplateParameterTypes == null ? 0 : fTemplateParameterTypes.length; return fTemplateParameterTypes == null ? 0 : fTemplateParameterTypes.length;
} }
/** /**
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature() * @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
*/ */
@Override
public String getTemplateSignature() { public String getTemplateSignature() {
StringBuffer sig = new StringBuffer(fName); StringBuffer sig = new StringBuffer(fName);
if(getNumberOfTemplateParameters() > 0){ if(getNumberOfTemplateParameters() > 0){

View file

@ -117,10 +117,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
setContentTypeID(idType); setContentTypeID(idType);
} }
@Override
public ITranslationUnit getTranslationUnit() { public ITranslationUnit getTranslationUnit() {
return this; return this;
} }
@Override
public IInclude createInclude(String includeName, boolean isStd, ICElement sibling, public IInclude createInclude(String includeName, boolean isStd, ICElement sibling,
IProgressMonitor monitor) throws CModelException { IProgressMonitor monitor) throws CModelException {
CreateIncludeOperation op = new CreateIncludeOperation(includeName, isStd, this); CreateIncludeOperation op = new CreateIncludeOperation(includeName, isStd, this);
@ -131,6 +133,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return getInclude(includeName); return getInclude(includeName);
} }
@Override
public IUsing createUsing(String usingName, boolean isDirective, ICElement sibling, public IUsing createUsing(String usingName, boolean isDirective, ICElement sibling,
IProgressMonitor monitor) throws CModelException { IProgressMonitor monitor) throws CModelException {
CreateIncludeOperation op = new CreateIncludeOperation(usingName, isDirective, this); CreateIncludeOperation op = new CreateIncludeOperation(usingName, isDirective, this);
@ -141,6 +144,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return getUsing(usingName); return getUsing(usingName);
} }
@Override
public INamespace createNamespace(String namespace, ICElement sibling, public INamespace createNamespace(String namespace, ICElement sibling,
IProgressMonitor monitor) throws CModelException { IProgressMonitor monitor) throws CModelException {
CreateNamespaceOperation op = new CreateNamespaceOperation(namespace, this); CreateNamespaceOperation op = new CreateNamespaceOperation(namespace, this);
@ -151,6 +155,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return getNamespace(namespace); return getNamespace(namespace);
} }
@Override
public ICElement getElementAtLine(int line) throws CModelException { public ICElement getElementAtLine(int line) throws CModelException {
ICElement[] celements = getChildren(); ICElement[] celements = getChildren();
for (ICElement celement : celements) { for (ICElement celement : celements) {
@ -164,6 +169,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return null; return null;
} }
@Override
public ICElement getElementAtOffset(int pos) throws CModelException { public ICElement getElementAtOffset(int pos) throws CModelException {
ICElement e = getSourceElementAtOffset(pos); ICElement e = getSourceElementAtOffset(pos);
if (e == this) { if (e == this) {
@ -172,6 +178,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return e; return e;
} }
@Override
public ICElement[] getElementsAtOffset(int pos) throws CModelException { public ICElement[] getElementsAtOffset(int pos) throws CModelException {
ICElement[] e = getSourceElementsAtOffset(pos); ICElement[] e = getSourceElementsAtOffset(pos);
if (e.length == 1 && e[0] == this) { if (e.length == 1 && e[0] == this) {
@ -180,6 +187,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return e; return e;
} }
@Override
public ICElement getElement(String name) { public ICElement getElement(String name) {
if (name == null || name.length() == 0) { if (name == null || name.length() == 0) {
return null; return null;
@ -218,6 +226,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return current; return current;
} }
@Override
public IInclude getInclude(String name) { public IInclude getInclude(String name) {
try { try {
ICElement[] celements = getChildren(); ICElement[] celements = getChildren();
@ -233,6 +242,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return null; return null;
} }
@Override
public IInclude[] getIncludes() throws CModelException { public IInclude[] getIncludes() throws CModelException {
ICElement[] celements = getChildren(); ICElement[] celements = getChildren();
ArrayList<ICElement> aList = new ArrayList<ICElement>(); ArrayList<ICElement> aList = new ArrayList<ICElement>();
@ -244,6 +254,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return aList.toArray(new IInclude[0]); return aList.toArray(new IInclude[0]);
} }
@Override
public IUsing getUsing(String name) { public IUsing getUsing(String name) {
try { try {
ICElement[] celements = getChildren(); ICElement[] celements = getChildren();
@ -259,6 +270,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return null; return null;
} }
@Override
public IUsing[] getUsings() throws CModelException { public IUsing[] getUsings() throws CModelException {
ICElement[] celements = getChildren(); ICElement[] celements = getChildren();
ArrayList<ICElement> aList = new ArrayList<ICElement>(); ArrayList<ICElement> aList = new ArrayList<ICElement>();
@ -270,6 +282,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return aList.toArray(new IUsing[0]); return aList.toArray(new IUsing[0]);
} }
@Override
public INamespace getNamespace(String name) { public INamespace getNamespace(String name) {
try { try {
String[] names = name.split("::"); //$NON-NLS-1$ String[] names = name.split("::"); //$NON-NLS-1$
@ -298,6 +311,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return null; return null;
} }
@Override
public INamespace[] getNamespaces() throws CModelException { public INamespace[] getNamespaces() throws CModelException {
ICElement[] celements = getChildren(); ICElement[] celements = getChildren();
ArrayList<ICElement> elementList = new ArrayList<ICElement>(); ArrayList<ICElement> elementList = new ArrayList<ICElement>();
@ -313,6 +327,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
location = loc; location = loc;
} }
@Override
public IPath getLocation() { public IPath getLocation() {
if (location == null) { if (location == null) {
IFile file = getFile(); IFile file = getFile();
@ -324,7 +339,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
} }
return UNCPathConverter.toPath(location); return UNCPathConverter.toPath(location);
} }
@Override @Override
public URI getLocationURI() { public URI getLocationURI() {
if (location == null) { if (location == null) {
@ -346,28 +361,34 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return null; return null;
} }
@Override
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 {
getSourceManipulationInfo().copy(container, sibling, rename, force, monitor); getSourceManipulationInfo().copy(container, sibling, rename, force, monitor);
} }
@Override
public void delete(boolean force, IProgressMonitor monitor) throws CModelException { public void delete(boolean force, IProgressMonitor monitor) throws CModelException {
getSourceManipulationInfo().delete(force, monitor); getSourceManipulationInfo().delete(force, monitor);
} }
@Override
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 {
getSourceManipulationInfo().move(container, sibling, rename, force, monitor); getSourceManipulationInfo().move(container, sibling, rename, force, monitor);
} }
@Override
public void rename(String name, boolean force, IProgressMonitor monitor) throws CModelException { public void rename(String name, boolean force, IProgressMonitor monitor) throws CModelException {
getSourceManipulationInfo().rename(name, force, monitor); getSourceManipulationInfo().rename(name, force, monitor);
} }
@Override
public String getSource() throws CModelException { public String getSource() throws CModelException {
return getSourceManipulationInfo().getSource(); return getSourceManipulationInfo().getSource();
} }
@Override
public ISourceRange getSourceRange() throws CModelException { public ISourceRange getSourceRange() throws CModelException {
return getSourceManipulationInfo().getSourceRange(); return getSourceManipulationInfo().getSourceRange();
} }
@ -391,9 +412,9 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
/** /**
* Returns true if this handle represents the same Java element * Returns true if this handle represents the same Java element
* as the given handle. * as the given handle.
* *
* <p>Compilation units must also check working copy state; * <p>Compilation units must also check working copy state;
* *
* @see Object#equals(java.lang.Object) * @see Object#equals(java.lang.Object)
*/ */
@Override @Override
@ -402,6 +423,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return super.equals(o) && !((ITranslationUnit) o).isWorkingCopy(); return super.equals(o) && !((ITranslationUnit) o).isWorkingCopy();
} }
@Override
public IWorkingCopy findSharedWorkingCopy() { public IWorkingCopy findSharedWorkingCopy() {
return CModelManager.getDefault().findSharedWorkingCopy(null, this); return CModelManager.getDefault().findSharedWorkingCopy(null, this);
} }
@ -442,6 +464,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return unitInfo.isStructureKnown(); return unitInfo.isStructureKnown();
} }
@Override
public char[] getContents() { public char[] getContents() {
try { try {
IBuffer buffer = this.getBuffer(); IBuffer buffer = this.getBuffer();
@ -451,19 +474,23 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
} }
} }
@Override
public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IProblemRequestor requestor) public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IProblemRequestor requestor)
throws CModelException { throws CModelException {
return CModelManager.getDefault().getSharedWorkingCopy(null, this, requestor, monitor); return CModelManager.getDefault().getSharedWorkingCopy(null, this, requestor, monitor);
} }
@Override
public IWorkingCopy getWorkingCopy() throws CModelException { public IWorkingCopy getWorkingCopy() throws CModelException {
return this.getWorkingCopy(null, null); return this.getWorkingCopy(null, null);
} }
@Override
public IWorkingCopy getWorkingCopy(IProgressMonitor monitor) throws CModelException { public IWorkingCopy getWorkingCopy(IProgressMonitor monitor) throws CModelException {
return getWorkingCopy(monitor, null); return getWorkingCopy(monitor, null);
} }
@Override
public IWorkingCopy getWorkingCopy(IProgressMonitor monitor, IBufferFactory factory) throws CModelException { public IWorkingCopy getWorkingCopy(IProgressMonitor monitor, IBufferFactory factory) throws CModelException {
WorkingCopy workingCopy; WorkingCopy workingCopy;
IFile file= getFile(); IFile file= getFile();
@ -513,7 +540,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
if (!computeAST && isConsistent()) { if (!computeAST && isConsistent()) {
return null; return null;
} }
// create a new info and make it the current info // create a new info and make it the current info
// (this will remove the info and its children just before storing the new infos) // (this will remove the info and its children just before storing the new infos)
CModelManager manager = CModelManager.getDefault(); CModelManager manager = CModelManager.getDefault();
@ -559,6 +586,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return true; return true;
} }
@Override
public boolean isWorkingCopy() { public boolean isWorkingCopy() {
return false; return false;
} }
@ -601,6 +629,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return buffer; return buffer;
} }
@Override
public Map<?, ?> parse() { public Map<?, ?> parse() {
throw new UnsupportedOperationException("Deprecated method"); //$NON-NLS-1$ throw new UnsupportedOperationException("Deprecated method"); //$NON-NLS-1$
} }
@ -655,10 +684,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return problemRequestor; return problemRequestor;
} }
@Override
public boolean isHeaderUnit() { public boolean isHeaderUnit() {
return isHeaderContentType(contentTypeId); return isHeaderContentType(contentTypeId);
} }
@Override
public boolean isSourceUnit() { public boolean isSourceUnit() {
return isSourceContentType(contentTypeId); return isSourceContentType(contentTypeId);
} }
@ -678,16 +709,19 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|| LanguageManager.getInstance().isContributedContentType(contentType); || LanguageManager.getInstance().isContributedContentType(contentType);
} }
@Override
public boolean isCLanguage() { public boolean isCLanguage() {
return CCorePlugin.CONTENT_TYPE_CSOURCE.equals(contentTypeId) return CCorePlugin.CONTENT_TYPE_CSOURCE.equals(contentTypeId)
|| CCorePlugin.CONTENT_TYPE_CHEADER.equals(contentTypeId); || CCorePlugin.CONTENT_TYPE_CHEADER.equals(contentTypeId);
} }
@Override
public boolean isCXXLanguage() { public boolean isCXXLanguage() {
return CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(contentTypeId) return CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(contentTypeId)
|| CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(contentTypeId); || CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(contentTypeId);
} }
@Override
public boolean isASMLanguage() { public boolean isASMLanguage() {
return CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(contentTypeId); return CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(contentTypeId);
} }
@ -705,20 +739,21 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
} }
} }
return false; return false;
} }
@Override
public ILanguage getLanguage() throws CoreException { public ILanguage getLanguage() throws CoreException {
ILanguage language = null; ILanguage language = null;
ICProject cProject = getCProject(); ICProject cProject = getCProject();
IProject project= cProject.getProject(); IProject project= cProject.getProject();
ICProjectDescription description = CoreModel.getDefault().getProjectDescription(project, false); ICProjectDescription description = CoreModel.getDefault().getProjectDescription(project, false);
ICConfigurationDescription configuration; ICConfigurationDescription configuration;
if (description == null) { if (description == null) {
// TODO: Sometimes, CoreModel returns a null ICProjectDescription // TODO: Sometimes, CoreModel returns a null ICProjectDescription
// so for now, fall back to configuration-less language determination. // so for now, fall back to configuration-less language determination.
@ -726,7 +761,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
} else { } else {
configuration = description.getActiveConfiguration(); configuration = description.getActiveConfiguration();
} }
IFile file= getFile(); IFile file= getFile();
if (file != null) { if (file != null) {
language = LanguageManager.getInstance().getLanguageForFile(file, configuration, contentTypeId); language = LanguageManager.getInstance().getLanguageForFile(file, configuration, contentTypeId);
@ -738,6 +773,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return language; return language;
} }
@Override
public String getContentTypeId() { public String getContentTypeId() {
return contentTypeId; return contentTypeId;
} }
@ -759,9 +795,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
* Contributed languages' model builders need to be able to indicate whether or * Contributed languages' model builders need to be able to indicate whether or
* not the parse of a translation unit was successful without having access to * not the parse of a translation unit was successful without having access to
* the <code>CElementInfo</code> object associated with the translation unit * the <code>CElementInfo</code> object associated with the translation unit
* *
* @param wasSuccessful * @param wasSuccessful
*/ */
@Override
public void setIsStructureKnown(boolean wasSuccessful) { public void setIsStructureKnown(boolean wasSuccessful) {
try { try {
this.getElementInfo().setIsStructureKnown(wasSuccessful); this.getElementInfo().setIsStructureKnown(wasSuccessful);
@ -769,10 +806,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
} }
} }
@Override
public IASTTranslationUnit getAST() throws CoreException { public IASTTranslationUnit getAST() throws CoreException {
return getAST(null, 0, null); return getAST(null, 0, null);
} }
@Override
public IASTTranslationUnit getAST(IIndex index, int style) throws CoreException { public IASTTranslationUnit getAST(IIndex index, int style) throws CoreException {
return getAST(index, style, null); return getAST(index, style, null);
} }
@ -782,12 +821,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
ITranslationUnit configureWith = getConfigureWith(contextToHeader); ITranslationUnit configureWith = getConfigureWith(contextToHeader);
if (configureWith == this) if (configureWith == this)
contextToHeader= null; contextToHeader= null;
IScannerInfo scanInfo= configureWith.getScannerInfo((style & AST_SKIP_IF_NO_BUILD_INFO) == 0); IScannerInfo scanInfo= configureWith.getScannerInfo((style & AST_SKIP_IF_NO_BUILD_INFO) == 0);
if (scanInfo == null) { if (scanInfo == null) {
return null; return null;
} }
FileContent fileContent= FileContent.create(this); FileContent fileContent= FileContent.create(this);
if (fileContent == null) { if (fileContent == null) {
return null; return null;
@ -833,19 +872,19 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
} else { } else {
fileContentsProvider= IncludeFileContentProvider.getSavedFilesProvider(); fileContentsProvider= IncludeFileContentProvider.getSavedFilesProvider();
} }
if (index != null && (style & AST_SKIP_INDEXED_HEADERS) != 0) { if (index != null && (style & AST_SKIP_INDEXED_HEADERS) != 0) {
IndexBasedFileContentProvider ibcf= new IndexBasedFileContentProvider(index, pathResolver, linkageID, IndexBasedFileContentProvider ibcf= new IndexBasedFileContentProvider(index, pathResolver, linkageID,
fileContentsProvider); fileContentsProvider);
ibcf.setContextToHeaderGap(contextToHeader); ibcf.setContextToHeaderGap(contextToHeader);
fileContentsProvider= ibcf; fileContentsProvider= ibcf;
} }
if (fileContentsProvider instanceof InternalFileContentProvider) { if (fileContentsProvider instanceof InternalFileContentProvider) {
final ProjectIndexerIncludeResolutionHeuristics heuristics = new ProjectIndexerIncludeResolutionHeuristics(cprj.getProject(), pathResolver); final ProjectIndexerIncludeResolutionHeuristics heuristics = new ProjectIndexerIncludeResolutionHeuristics(cprj.getProject(), pathResolver);
((InternalFileContentProvider) fileContentsProvider).setIncludeResolutionHeuristics(heuristics); ((InternalFileContentProvider) fileContentsProvider).setIncludeResolutionHeuristics(heuristics);
} }
return fileContentsProvider; return fileContentsProvider;
} }
@ -874,7 +913,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
} }
} }
} }
if (best != null && contextOfBest != best) { if (best != null && contextOfBest != best) {
return new IIndexFile[] { contextOfBest, best }; return new IIndexFile[] { contextOfBest, best };
} }
@ -897,10 +936,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
} }
return indexFile; return indexFile;
} }
/** /**
* Returns <code>true</code> if the given file was parsed in a context of a source file. * Returns <code>true</code> if the given file was parsed in a context of a source file.
* @throws CoreException * @throws CoreException
*/ */
private boolean isSourceFile(IIndexFile indexFile) throws CoreException { private boolean isSourceFile(IIndexFile indexFile) throws CoreException {
String path = indexFile.getLocation().getURI().getPath(); String path = indexFile.getLocation().getURI().getPath();
@ -912,28 +951,29 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
} }
private ITranslationUnit getConfigureWith(IIndexFile[] contextToHeader) throws CoreException { private ITranslationUnit getConfigureWith(IIndexFile[] contextToHeader) throws CoreException {
if (contextToHeader != null) { if (contextToHeader != null) {
ITranslationUnit configureWith = CoreModelUtil.findTranslationUnitForLocation( ITranslationUnit configureWith = CoreModelUtil.findTranslationUnitForLocation(
contextToHeader[0].getLocation(), getCProject()); contextToHeader[0].getLocation(), getCProject());
if (configureWith != null) if (configureWith != null)
return configureWith; return configureWith;
} }
return this; return this;
} }
@Override
public IASTCompletionNode getCompletionNode(IIndex index, int style, int offset) throws CoreException { public IASTCompletionNode getCompletionNode(IIndex index, int style, int offset) throws CoreException {
IIndexFile[] contextToHeader = getContextToHeader(index, style); IIndexFile[] contextToHeader = getContextToHeader(index, style);
ITranslationUnit configureWith = getConfigureWith(contextToHeader); ITranslationUnit configureWith = getConfigureWith(contextToHeader);
if (configureWith == this) if (configureWith == this)
contextToHeader= null; contextToHeader= null;
IScannerInfo scanInfo = configureWith.getScannerInfo((style & ITranslationUnit.AST_SKIP_IF_NO_BUILD_INFO) == 0); IScannerInfo scanInfo = configureWith.getScannerInfo((style & ITranslationUnit.AST_SKIP_IF_NO_BUILD_INFO) == 0);
if (scanInfo == null) { if (scanInfo == null) {
return null; return null;
} }
FileContent fileContent= FileContent.create(this); FileContent fileContent= FileContent.create(this);
ILanguage language= configureWith.getLanguage(); ILanguage language= configureWith.getLanguage();
fLanguageOfContext= language; fLanguageOfContext= language;
if (language != null) { if (language != null) {
@ -952,6 +992,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return null; return null;
} }
@Override
@Deprecated @Deprecated
public org.eclipse.cdt.core.parser.CodeReader getCodeReader() { public org.eclipse.cdt.core.parser.CodeReader getCodeReader() {
IPath location= getLocation(); IPath location= getLocation();
@ -960,12 +1001,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
if (isWorkingCopy()) { if (isWorkingCopy()) {
return new org.eclipse.cdt.core.parser.CodeReader(location.toOSString(), getContents()); return new org.eclipse.cdt.core.parser.CodeReader(location.toOSString(), getContents());
} }
IResource res= getResource(); IResource res= getResource();
try { try {
if (res instanceof IFile) if (res instanceof IFile)
return InternalParserUtil.createWorkspaceFileReader(location.toOSString(), (IFile) res, null); return InternalParserUtil.createWorkspaceFileReader(location.toOSString(), (IFile) res, null);
else else
return InternalParserUtil.createExternalFileReader(location.toOSString(), null); return InternalParserUtil.createExternalFileReader(location.toOSString(), null);
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
@ -975,6 +1016,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return null; return null;
} }
@Override
public IScannerInfo getScannerInfo(boolean force) { public IScannerInfo getScannerInfo(boolean force) {
IResource resource = getResource(); IResource resource = getResource();
ICProject project = getCProject(); ICProject project = getCProject();
@ -984,7 +1026,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
if (!force && CoreModel.isScannerInformationEmpty(infoResource)) { if (!force && CoreModel.isScannerInformationEmpty(infoResource)) {
return null; return null;
} }
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(rproject); IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(rproject);
if (provider != null) { if (provider != null) {
IScannerInfo scanInfo = provider.getScannerInformation(infoResource); IScannerInfo scanInfo = provider.getScannerInformation(infoResource);
@ -996,7 +1038,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
} }
return null; return null;
} }
/** /**
* Return the language of the context this file was parsed in. Works only after using * Return the language of the context this file was parsed in. Works only after using
* {@link #getAST(IIndex, int, IProgressMonitor)} with the flag {@link ITranslationUnit#AST_CONFIGURE_USING_SOURCE_CONTEXT}. * {@link #getAST(IIndex, int, IProgressMonitor)} with the flag {@link ITranslationUnit#AST_CONFIGURE_USING_SOURCE_CONTEXT}.
@ -1159,30 +1201,35 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
} }
} }
} }
@Override @Override
protected char getHandleMementoDelimiter() { protected char getHandleMementoDelimiter() {
return CElement.CEM_TRANSLATIONUNIT; return CElement.CEM_TRANSLATIONUNIT;
} }
@Override
public boolean isActive() { public boolean isActive() {
return true; return true;
} }
@Override
public int getIndex() { public int getIndex() {
return 0; return 0;
} }
@Override
@Deprecated @Deprecated
public IWorkingCopy findSharedWorkingCopy(IBufferFactory bufferFactory) { public IWorkingCopy findSharedWorkingCopy(IBufferFactory bufferFactory) {
return CModelManager.getDefault().findSharedWorkingCopy(bufferFactory, this); return CModelManager.getDefault().findSharedWorkingCopy(bufferFactory, this);
} }
@Override
@Deprecated @Deprecated
public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IBufferFactory factory, IProblemRequestor requestor) throws CModelException { public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IBufferFactory factory, IProblemRequestor requestor) throws CModelException {
return CModelManager.getDefault().getSharedWorkingCopy(factory, this, requestor, monitor); return CModelManager.getDefault().getSharedWorkingCopy(factory, this, requestor, monitor);
} }
@Override
@Deprecated @Deprecated
public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IBufferFactory factory) throws CModelException { public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IBufferFactory factory) throws CModelException {
return CModelManager.getDefault().getSharedWorkingCopy(factory, this, null, monitor); return CModelManager.getDefault().getSharedWorkingCopy(factory, this, null, monitor);

View file

@ -24,6 +24,7 @@ public class TypeDef extends SourceManipulation implements ITypeDef {
* Returns the typeName. * Returns the typeName.
* @return String * @return String
*/ */
@Override
public String getTypeName() { public String getTypeName() {
return typeName; return typeName;
} }

View file

@ -31,6 +31,7 @@ public class Using extends SourceManipulation implements IUsing {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.IUsing#isDirective() * @see org.eclipse.cdt.core.model.IUsing#isDirective()
*/ */
@Override
public boolean isDirective() { public boolean isDirective() {
return directive; return directive;
} }

View file

@ -15,7 +15,7 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IVariable; import org.eclipse.cdt.core.model.IVariable;
public class Variable extends VariableDeclaration implements IVariable { public class Variable extends VariableDeclaration implements IVariable {
public Variable(ICElement parent, String name) { public Variable(ICElement parent, String name) {
super(parent, name, ICElement.C_VARIABLE); super(parent, name, ICElement.C_VARIABLE);
} }
@ -24,6 +24,7 @@ public class Variable extends VariableDeclaration implements IVariable {
super(parent, name, kind); super(parent, name, kind);
} }
@Override
public String getInitializer() { public String getInitializer() {
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
} }

View file

@ -16,7 +16,7 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IVariableDeclaration; import org.eclipse.cdt.core.model.IVariableDeclaration;
public class VariableDeclaration extends SourceManipulation implements IVariableDeclaration { public class VariableDeclaration extends SourceManipulation implements IVariableDeclaration {
public VariableDeclaration(ICElement parent, String name) { public VariableDeclaration(ICElement parent, String name) {
super(parent, name, ICElement.C_VARIABLE_DECLARATION); super(parent, name, ICElement.C_VARIABLE_DECLARATION);
} }
@ -25,14 +25,17 @@ public class VariableDeclaration extends SourceManipulation implements IVariable
super(parent, name, type); super(parent, name, type);
} }
@Override
public String getTypeName() throws CModelException { public String getTypeName() throws CModelException {
return getVariableInfo().getTypeName(); return getVariableInfo().getTypeName();
} }
@Override
public void setTypeName(String type) throws CModelException { public void setTypeName(String type) throws CModelException {
getVariableInfo().setTypeString(type); getVariableInfo().setTypeString(type);
} }
@Override
public boolean isConst() throws CModelException { public boolean isConst() throws CModelException {
return getVariableInfo().isConst(); return getVariableInfo().isConst();
} }
@ -41,6 +44,7 @@ public class VariableDeclaration extends SourceManipulation implements IVariable
getVariableInfo().setConst(isConst); getVariableInfo().setConst(isConst);
} }
@Override
public boolean isVolatile() throws CModelException { public boolean isVolatile() throws CModelException {
return getVariableInfo().isVolatile(); return getVariableInfo().isVolatile();
} }
@ -49,6 +53,7 @@ public class VariableDeclaration extends SourceManipulation implements IVariable
getVariableInfo().setVolatile(isVolatile); getVariableInfo().setVolatile(isVolatile);
} }
@Override
public boolean isStatic() throws CModelException { public boolean isStatic() throws CModelException {
return getVariableInfo().isStatic(); return getVariableInfo().isStatic();
} }
@ -60,7 +65,7 @@ public class VariableDeclaration extends SourceManipulation implements IVariable
public VariableInfo getVariableInfo() throws CModelException{ public VariableInfo getVariableInfo() throws CModelException{
return (VariableInfo) getElementInfo(); return (VariableInfo) getElementInfo();
} }
@Override @Override
protected CElementInfo createElementInfo () { protected CElementInfo createElementInfo () {
return new VariableInfo(this); return new VariableInfo(this);

View file

@ -17,15 +17,16 @@ public class VariableTemplate extends Variable implements ITemplate {
protected static final String[] fgEmptyList= new String[] {}; protected static final String[] fgEmptyList= new String[] {};
protected String[] templateParameterTypes; protected String[] templateParameterTypes;
public VariableTemplate(ICElement parent, String name) { public VariableTemplate(ICElement parent, String name) {
super(parent, name, ICElement.C_TEMPLATE_VARIABLE); super(parent, name, ICElement.C_TEMPLATE_VARIABLE);
templateParameterTypes= fgEmptyList; templateParameterTypes= fgEmptyList;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters() * @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
*/ */
@Override
public int getNumberOfTemplateParameters() { public int getNumberOfTemplateParameters() {
return templateParameterTypes == null ? 0 : templateParameterTypes.length; return templateParameterTypes == null ? 0 : templateParameterTypes.length;
} }
@ -33,10 +34,12 @@ public class VariableTemplate extends Variable implements ITemplate {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes() * @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes()
*/ */
@Override
public String[] getTemplateParameterTypes() { public String[] getTemplateParameterTypes() {
return templateParameterTypes; return templateParameterTypes;
} }
@Override
public String[] getTemplateArguments() { public String[] getTemplateArguments() {
return fgEmptyList; return fgEmptyList;
} }
@ -51,6 +54,7 @@ public class VariableTemplate extends Variable implements ITemplate {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature() * @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
*/ */
@Override
public String getTemplateSignature() throws CModelException { public String getTemplateSignature() throws CModelException {
StringBuffer sig = new StringBuffer(getElementName()); StringBuffer sig = new StringBuffer(getElementName());
if(getNumberOfTemplateParameters() > 0){ if(getNumberOfTemplateParameters() > 0){
@ -67,10 +71,10 @@ public class VariableTemplate extends Variable implements ITemplate {
else{ else{
sig.append("<>"); //$NON-NLS-1$ sig.append("<>"); //$NON-NLS-1$
} }
sig.append(" : "); //$NON-NLS-1$ sig.append(" : "); //$NON-NLS-1$
sig.append(this.getTypeName()); sig.append(this.getTypeName());
return sig.toString(); return sig.toString();
} }
} }

View file

@ -38,13 +38,13 @@ import org.eclipse.core.runtime.IProgressMonitor;
* the timestamp of the resource it was created from. * the timestamp of the resource it was created from.
*/ */
public class WorkingCopy extends TranslationUnit implements IWorkingCopy { public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
/** /**
* If set, this is the factory that will be used to create the buffer. * If set, this is the factory that will be used to create the buffer.
*/ */
protected IBufferFactory bufferFactory; protected IBufferFactory bufferFactory;
/** /**
* A counter of the number of time clients have asked for this * A counter of the number of time clients have asked for this
* working copy. It is set to 1, if the working * working copy. It is set to 1, if the working
* copy is not managed. When destroyed, this counter is * copy is not managed. When destroyed, this counter is
* set to 0. Once destroyed, this working copy cannot be opened * set to 0. Once destroyed, this working copy cannot be opened
@ -74,6 +74,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
/** /**
* @see org.eclipse.cdt.core.model.IWorkingCopy#commit(boolean, org.eclipse.core.runtime.IProgressMonitor) * @see org.eclipse.cdt.core.model.IWorkingCopy#commit(boolean, org.eclipse.core.runtime.IProgressMonitor)
*/ */
@Override
public void commit(boolean force, IProgressMonitor monitor) throws CModelException { public void commit(boolean force, IProgressMonitor monitor) throws CModelException {
ITranslationUnit original = this.getOriginalElement(); ITranslationUnit original = this.getOriginalElement();
if (original.exists()) { if (original.exists()) {
@ -94,8 +95,8 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
ByteArrayInputStream stream = new ByteArrayInputStream(bytes); ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
if (originalRes.exists()) { if (originalRes.exists()) {
originalRes.setContents( originalRes.setContents(
stream, stream,
force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY, force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
null); null);
} else { } else {
originalRes.create( originalRes.create(
@ -108,12 +109,13 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
} catch (CoreException e) { } catch (CoreException e) {
throw new CModelException(e); throw new CModelException(e);
} }
} }
} }
/** /**
* @see org.eclipse.cdt.core.model.IWorkingCopy#destroy() * @see org.eclipse.cdt.core.model.IWorkingCopy#destroy()
*/ */
@Override
public void destroy() { public void destroy() {
if (--this.useCount > 0) { if (--this.useCount > 0) {
return; return;
@ -151,17 +153,18 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
*/ */
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
return this == o; return this == o;
} }
/** /**
* Returns the original element the specified working copy element was created from, * Returns the original element the specified working copy element was created from,
* or <code>null</code> if this is not a working copy element. * or <code>null</code> if this is not a working copy element.
* *
* @param workingCopyElement the specified working copy element * @param workingCopyElement the specified working copy element
* @return the original element the specified working copy element was created from, * @return the original element the specified working copy element was created from,
* or <code>null</code> if this is not a working copy element * or <code>null</code> if this is not a working copy element
*/ */
@Override
public ICElement getOriginal(ICElement workingCopyElement) { public ICElement getOriginal(ICElement workingCopyElement) {
// It has to come from the same workingCopy, meaning ours. // It has to come from the same workingCopy, meaning ours.
if (workingCopyElement instanceof ISourceReference) { if (workingCopyElement instanceof ISourceReference) {
@ -207,10 +210,11 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
} }
return current; return current;
} }
/** /**
* @see org.eclipse.cdt.core.model.IWorkingCopy#getOriginalElement() * @see org.eclipse.cdt.core.model.IWorkingCopy#getOriginalElement()
*/ */
@Override
public ITranslationUnit getOriginalElement() { public ITranslationUnit getOriginalElement() {
IFile file= getFile(); IFile file= getFile();
if (file != null) { if (file != null) {
@ -224,12 +228,12 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
*/ */
@Override @Override
public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IProblemRequestor requestor) { public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IProblemRequestor requestor) {
return this; return this;
} }
/** /**
* @see org.eclipse.cdt.core.model.ITranslationUnit#getWorkingCopy() * @see org.eclipse.cdt.core.model.ITranslationUnit#getWorkingCopy()
*/ */
@Override @Override
public IWorkingCopy getWorkingCopy() { public IWorkingCopy getWorkingCopy() {
return this; return this;
@ -246,6 +250,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
/** /**
* @see IWorkingCopy * @see IWorkingCopy
*/ */
@Override
public boolean isBasedOn(IResource resource) { public boolean isBasedOn(IResource resource) {
if (resource.getType() != IResource.FILE) { if (resource.getType() != IResource.FILE) {
return false; return false;
@ -282,12 +287,12 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
public void open(IProgressMonitor monitor) throws CModelException { public void open(IProgressMonitor monitor) throws CModelException {
if (this.useCount == 0) { // was destroyed if (this.useCount == 0) { // was destroyed
throw newNotPresentException(); throw newNotPresentException();
} }
super.open(monitor); super.open(monitor);
//if (monitor != null && monitor.isCanceled()) return; //if (monitor != null && monitor.isCanceled()) return;
//if (this.problemRequestor != null && this.problemRequestor.isActive()){ //if (this.problemRequestor != null && this.problemRequestor.isActive()){
// this.problemRequestor.beginReporting(); // this.problemRequestor.beginReporting();
// TranslationUnitProblemFinder.process(this, this.problemRequestor, monitor); // TranslationUnitProblemFinder.process(this, this.problemRequestor, monitor);
// this.problemRequestor.endReporting(); // this.problemRequestor.endReporting();
//} //}
} }
@ -298,10 +303,10 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
@Override @Override
protected IBuffer openBuffer(IProgressMonitor pm) throws CModelException { protected IBuffer openBuffer(IProgressMonitor pm) throws CModelException {
if (this.useCount == 0) throw newNotPresentException(); if (this.useCount == 0) throw newNotPresentException();
// create buffer - working copies may use custom buffer factory // create buffer - working copies may use custom buffer factory
IBuffer buffer = getBufferFactory().createBuffer(this); IBuffer buffer = getBufferFactory().createBuffer(this);
if (buffer == null) if (buffer == null)
return null; return null;
// set the buffer source if needed // set the buffer source if needed
@ -333,20 +338,22 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
// listen to buffer changes // listen to buffer changes
buffer.addBufferChangedListener(this); buffer.addBufferChangedListener(this);
return buffer; return buffer;
} }
/** /**
* @see org.eclipse.cdt.core.model.IWorkingCopy#reconcile() * @see org.eclipse.cdt.core.model.IWorkingCopy#reconcile()
*/ */
@Override
public IMarker[] reconcile() throws CModelException { public IMarker[] reconcile() throws CModelException {
reconcile(false, null); reconcile(false, null);
return null; return null;
} }
/** /**
* @see org.eclipse.cdt.core.model.IWorkingCopy#reconcile(boolean, org.eclipse.core.runtime.IProgressMonitor) * @see org.eclipse.cdt.core.model.IWorkingCopy#reconcile(boolean, org.eclipse.core.runtime.IProgressMonitor)
*/ */
@Override
public void reconcile(boolean forceProblemDetection, IProgressMonitor monitor) throws CModelException { public void reconcile(boolean forceProblemDetection, IProgressMonitor monitor) throws CModelException {
reconcile(false, forceProblemDetection, monitor); reconcile(false, forceProblemDetection, monitor);
} }
@ -354,6 +361,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
/** /**
* @see org.eclipse.cdt.core.model.IWorkingCopy#restore() * @see org.eclipse.cdt.core.model.IWorkingCopy#restore()
*/ */
@Override
public void restore() throws CModelException{ public void restore() throws CModelException{
if (this.useCount == 0) throw newNotPresentException(); //was destroyed if (this.useCount == 0) throw newNotPresentException(); //was destroyed
@ -362,7 +370,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
if (buffer == null) return; if (buffer == null) return;
buffer.setContents(original.getContents()); buffer.setContents(original.getContents());
updateTimeStamp(original); updateTimeStamp(original);
makeConsistent(null); makeConsistent(null);
} }
/** /**
@ -375,7 +383,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
} }
// computes fine-grain deltas in case the working copy is being reconciled already // computes fine-grain deltas in case the working copy is being reconciled already
// (if not it would miss one iteration of deltas). // (if not it would miss one iteration of deltas).
this.reconcile(); this.reconcile();
} }
/** /**
@ -394,6 +402,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
/* /*
* @see org.eclipse.cdt.core.model.IWorkingCopy#reconcile(boolean, boolean, org.eclipse.core.runtime.IProgressMonitor) * @see org.eclipse.cdt.core.model.IWorkingCopy#reconcile(boolean, boolean, org.eclipse.core.runtime.IProgressMonitor)
*/ */
@Override
public IASTTranslationUnit reconcile(boolean computeAST, boolean forceProblemDetection, IProgressMonitor monitor) public IASTTranslationUnit reconcile(boolean computeAST, boolean forceProblemDetection, IProgressMonitor monitor)
throws CModelException { throws CModelException {
if (this.useCount == 0) if (this.useCount == 0)

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model.ext; package org.eclipse.cdt.internal.core.model.ext;
import java.net.URI; import java.net.URI;
@ -42,7 +42,7 @@ import org.eclipse.jface.text.Region;
abstract class CElementHandle implements ICElementHandle, ISourceReference { abstract class CElementHandle implements ICElementHandle, ISourceReference {
protected static final String[] EMPTY_STRING_ARRAY = new String[0]; protected static final String[] EMPTY_STRING_ARRAY = new String[0];
private static final ICElement[] NO_CHILDREN = new ICElement[0]; private static final ICElement[] NO_CHILDREN = new ICElement[0];
private ICElement fParent; private ICElement fParent;
private String fName; private String fName;
private int fType; private int fType;
@ -54,7 +54,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
public CElementHandle(ICElement parent, int type, String name) { public CElementHandle(ICElement parent, int type, String name) {
fParent= parent; fParent= parent;
fType= type; fType= type;
// anonymous types are assigned a name in the index, we // anonymous types are assigned a name in the index, we
// undo this here // undo this here
if (name.length() > 0 && name.charAt(0)=='{') { if (name.length() > 0 && name.charAt(0)=='{') {
fName= ""; //$NON-NLS-1$ fName= ""; //$NON-NLS-1$
@ -64,7 +64,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
} }
fRegion= new Region(0,0); fRegion= new Region(0,0);
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof ICElement) { if (obj instanceof ICElement) {
@ -79,6 +79,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
} }
@Override
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public Object getAdapter(Class adapter) { public Object getAdapter(Class adapter) {
return null; return null;
@ -89,6 +90,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
fTimestamp= timestamp; fTimestamp= timestamp;
} }
@Override
public ISourceRange getSourceRange() throws CModelException { public ISourceRange getSourceRange() throws CModelException {
IRegion region= fRegion; IRegion region= fRegion;
ITranslationUnit tu= getTranslationUnit(); ITranslationUnit tu= getTranslationUnit();
@ -103,10 +105,12 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
return new SourceRange(startpos, length); return new SourceRange(startpos, length);
} }
@Override
public String getSource() throws CModelException { public String getSource() throws CModelException {
return null; return null;
} }
@Override
public ITranslationUnit getTranslationUnit() { public ITranslationUnit getTranslationUnit() {
ICElement parent= fParent; ICElement parent= fParent;
do { do {
@ -118,58 +122,72 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
while (parent != null); while (parent != null);
return null; return null;
} }
@Override
public void accept(ICElementVisitor visitor) throws CoreException { public void accept(ICElementVisitor visitor) throws CoreException {
} }
@Override
public boolean exists() { public boolean exists() {
return true; return true;
} }
@Override
public ICElement getAncestor(int ancestorType) { public ICElement getAncestor(int ancestorType) {
return null; return null;
} }
@Override
public ICModel getCModel() { public ICModel getCModel() {
return fParent.getCModel(); return fParent.getCModel();
} }
@Override
public ICProject getCProject() { public ICProject getCProject() {
return fParent.getCProject(); return fParent.getCProject();
} }
@Override
public String getElementName() { public String getElementName() {
return fName; return fName;
} }
@Override
public int getElementType() { public int getElementType() {
return fType; return fType;
} }
@Override
public ICElement getParent() { public ICElement getParent() {
return fParent; return fParent;
} }
@Override
public IPath getPath() { public IPath getPath() {
return getTranslationUnit().getPath(); return getTranslationUnit().getPath();
} }
@Override
public URI getLocationURI() { public URI getLocationURI() {
return getTranslationUnit().getLocationURI(); return getTranslationUnit().getLocationURI();
} }
@Override
public IResource getResource() { public IResource getResource() {
return getTranslationUnit().getResource(); return getTranslationUnit().getResource();
} }
@Override
public IResource getUnderlyingResource() { public IResource getUnderlyingResource() {
return getResource(); return getResource();
} }
@Override
public boolean isReadOnly() { public boolean isReadOnly() {
return true; return true;
} }
@Override
public boolean isStructureKnown() throws CModelException { public boolean isStructureKnown() throws CModelException {
return false; return false;
} }
@ -185,7 +203,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
public void rename(String name, boolean replace, IProgressMonitor monitor) throws CModelException { public void rename(String name, boolean replace, IProgressMonitor monitor) throws CModelException {
} }
public void setTypeName(String type) throws CModelException { public void setTypeName(String type) throws CModelException {
} }
@ -224,7 +242,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
public boolean isFriend() throws CModelException { public boolean isFriend() throws CModelException {
return false; return false;
} }
public boolean isInline() throws CModelException { public boolean isInline() throws CModelException {
return false; return false;
} }
@ -248,7 +266,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
public String getInitializer() { public String getInitializer() {
return null; return null;
} }
public boolean isAbstract() throws CModelException { public boolean isAbstract() throws CModelException {
return false; return false;
} }
@ -260,7 +278,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
public String[] getSuperClassesNames() { public String[] getSuperClassesNames() {
return EMPTY_STRING_ARRAY; return EMPTY_STRING_ARRAY;
} }
protected String[] extractParameterTypes(IFunction func) { protected String[] extractParameterTypes(IFunction func) {
IParameter[] params= func.getParameters(); IParameter[] params= func.getParameters();
String[] parameterTypes= new String[params.length]; String[] parameterTypes= new String[params.length];
@ -273,7 +291,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
} }
return parameterTypes; return parameterTypes;
} }
protected ASTAccessVisibility getVisibility(IBinding binding) { protected ASTAccessVisibility getVisibility(IBinding binding) {
if (binding instanceof ICPPMember) { if (binding instanceof ICPPMember) {
ICPPMember member= (ICPPMember) binding; ICPPMember member= (ICPPMember) binding;
@ -292,6 +310,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
/** /**
* @see ICElement * @see ICElement
*/ */
@Override
public String getHandleIdentifier() { public String getHandleIdentifier() {
ICElement cModelElement= mapToModelElement(); ICElement cModelElement= mapToModelElement();
if (cModelElement != null) { if (cModelElement != null) {
@ -309,10 +328,12 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
} }
} }
@Override
public boolean isActive() { public boolean isActive() {
return true; return true;
} }
@Override
public int getIndex() { public int getIndex() {
return fIndex; return fIndex;
} }

View file

@ -7,7 +7,7 @@
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model.ext; package org.eclipse.cdt.internal.core.model.ext;
@ -21,6 +21,7 @@ public class EnumerationHandle extends CElementHandle implements org.eclipse.cdt
super(parent, ICElement.C_ENUMERATION, enumeration.getName()); super(parent, ICElement.C_ENUMERATION, enumeration.getName());
} }
@Override
public boolean isStatic() throws CModelException { public boolean isStatic() throws CModelException {
return false; return false;
} }

Some files were not shown because too many files have changed in this diff Show more