mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
auto-clean: @Override annotations + organize imports + unnecessary
casts/$NON-NLS + trailing white spaces
This commit is contained in:
parent
2a1cddd716
commit
5c1a981cd7
311 changed files with 6186 additions and 4412 deletions
|
@ -13,7 +13,7 @@ package org.eclipse.cdt.core.model;
|
|||
|
||||
/**
|
||||
* Represents the declaration method of a class
|
||||
*
|
||||
*
|
||||
* @noextend This interface is not intended to be extended 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.
|
||||
*
|
||||
* <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 occurs while accessing its corresponding resource.
|
||||
|
@ -57,14 +57,15 @@ public interface IMethodDeclaration extends IMember, IFunctionDeclaration {
|
|||
* Returns if this method is static or not
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean isStatic() throws CModelException;
|
||||
|
||||
|
||||
/**
|
||||
* Returns if this method is inline or not
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isInline() throws CModelException;
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether this method is declared virtual.
|
||||
*
|
||||
|
|
|
@ -12,7 +12,7 @@ package org.eclipse.cdt.core.model;
|
|||
|
||||
/**
|
||||
* Represents a "using" declaration in C translation unit.
|
||||
*
|
||||
*
|
||||
* @noextend This interface is not intended to be extended 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.
|
||||
* This is a handle-only method.
|
||||
*/
|
||||
@Override
|
||||
String getElementName();
|
||||
|
||||
boolean isDirective();
|
||||
|
|
|
@ -59,7 +59,7 @@ public class LanguageManager {
|
|||
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_ID = "id"; //$NON-NLS-1$
|
||||
|
||||
|
||||
private static LanguageManager instance;
|
||||
private Map<String, ILanguage> fLanguageCache = new HashMap<String, ILanguage>();
|
||||
private Map<String, IPDOMLinkageFactory> fPDOMLinkageFactoryCache= new HashMap<String, IPDOMLinkageFactory>();
|
||||
|
@ -81,19 +81,19 @@ public class LanguageManager {
|
|||
Map<String, ILanguageDescriptor> map = getDescriptorCache();
|
||||
return map.get(id);
|
||||
}
|
||||
|
||||
|
||||
private HashMap<String, ILanguageDescriptor> getDescriptorCache() {
|
||||
if (fIdToLanguageDescriptorCache == null) {
|
||||
fIdToLanguageDescriptorCache = createDescriptorCache();
|
||||
}
|
||||
return fIdToLanguageDescriptorCache;
|
||||
}
|
||||
|
||||
|
||||
public ILanguageDescriptor[] getLanguageDescriptors() {
|
||||
HashMap<String, ILanguageDescriptor> map = getDescriptorCache();
|
||||
return map.values().toArray(new ILanguageDescriptor[map.size()]);
|
||||
}
|
||||
|
||||
|
||||
private HashMap<String, ILanguageDescriptor> createDescriptorCache() {
|
||||
HashMap<String, ILanguageDescriptor> map = new HashMap<String, ILanguageDescriptor>();
|
||||
IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
|
||||
|
@ -106,18 +106,18 @@ public class LanguageManager {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
private HashMap<String, List<ILanguageDescriptor>> getContentTypeToDescriptorCache() {
|
||||
if (fContentTypeToDescriptorListCache == null) {
|
||||
fContentTypeToDescriptorListCache = createContentTypeToDescriptorCache();
|
||||
}
|
||||
return fContentTypeToDescriptorListCache;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, ILanguageDescriptor[]> getContentTypeIdToLanguageDescriptionsMap() {
|
||||
HashMap<String, ILanguageDescriptor[]> map = new HashMap<String, ILanguageDescriptor[]>();
|
||||
Map<String, List<ILanguageDescriptor>> cache = getContentTypeToDescriptorCache();
|
||||
|
||||
|
||||
for (Entry<String, List<ILanguageDescriptor>> entry : cache.entrySet()) {
|
||||
List<ILanguageDescriptor> list = entry.getValue();
|
||||
if (list.size() > 0) {
|
||||
|
@ -125,11 +125,11 @@ public class LanguageManager {
|
|||
map.put(entry.getKey(), dess);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private HashMap<String, List<ILanguageDescriptor>> createContentTypeToDescriptorCache() {
|
||||
HashMap<String, List<ILanguageDescriptor>> map = new HashMap<String, List<ILanguageDescriptor>>();
|
||||
Map<String, ILanguageDescriptor> dc = getDescriptorCache();
|
||||
|
@ -150,7 +150,7 @@ public class LanguageManager {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
public ILanguage getLanguage(String id) {
|
||||
ILanguage language = fLanguageCache.get(id);
|
||||
if (language != null)
|
||||
|
@ -160,14 +160,16 @@ public class LanguageManager {
|
|||
for (int j = 0; j < configs.length; ++j) {
|
||||
final IConfigurationElement languageElem = configs[j];
|
||||
if (ELEMENT_LANGUAGE.equals(languageElem.getName())) {
|
||||
String langId = getLanguageID(languageElem);
|
||||
String langId = getLanguageID(languageElem);
|
||||
if (langId.equals(id)) {
|
||||
final ILanguage[] result= new ILanguage[]{null};
|
||||
SafeRunner.run(new ISafeRunnable() {
|
||||
@Override
|
||||
public void handleException(Throwable exception) {
|
||||
CCorePlugin.log(exception);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
result[0]= (ILanguage)languageElem.createExecutableExtension(ATTRIBUTE_CLASS);
|
||||
}
|
||||
|
@ -185,15 +187,15 @@ public class LanguageManager {
|
|||
private String getLanguageID(final IConfigurationElement languageElem) {
|
||||
return languageElem.getNamespaceIdentifier() + NAMESPACE_SEPARATOR + languageElem.getAttribute(ATTRIBUTE_ID);
|
||||
}
|
||||
|
||||
|
||||
public ILanguage getLanguage(IContentType contentType) {
|
||||
String contentTypeID= contentType.getId();
|
||||
return getLanguageForContentTypeID(contentTypeID);
|
||||
}
|
||||
|
||||
|
||||
public ILanguage getLanguageForContentTypeID(String contentTypeID) {
|
||||
cacheAllLanguages();
|
||||
|
||||
|
||||
ILanguage language = fContentTypeToLanguageCache.get(contentTypeID);
|
||||
if (language != null || fContentTypeToLanguageCache.containsKey(contentTypeID))
|
||||
return language;
|
||||
|
@ -202,7 +204,7 @@ public class LanguageManager {
|
|||
for (int j = 0; j < configs.length; ++j) {
|
||||
final IConfigurationElement languageElem = configs[j];
|
||||
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) {
|
||||
if (contentTypeID.equals(assocContentTypes[k].getAttribute(ATTRIBUTE_ID))) {
|
||||
String id= getLanguageID(languageElem);
|
||||
|
@ -216,8 +218,8 @@ public class LanguageManager {
|
|||
fContentTypeToLanguageCache.put(contentTypeID, null);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* @deprecated use getRegisteredContentTypes() instead.
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -229,19 +231,19 @@ public class LanguageManager {
|
|||
allTypes.add(CCorePlugin.CONTENT_TYPE_CXXHEADER);
|
||||
allTypes.add(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
|
||||
|
||||
IContentTypeManager manager = Platform.getContentTypeManager();
|
||||
IContentTypeManager manager = Platform.getContentTypeManager();
|
||||
IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
|
||||
for (int j = 0; j < configs.length; ++j) {
|
||||
final IConfigurationElement languageElem = configs[j];
|
||||
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) {
|
||||
IContentType langContType = manager.getContentType(contentTypes[k].getAttribute(ATTRIBUTE_ID));
|
||||
IContentType langContType = manager.getContentType(contentTypes[k].getAttribute(ATTRIBUTE_ID));
|
||||
allTypes.add(langContType.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return allTypes;
|
||||
}
|
||||
|
||||
|
@ -253,7 +255,7 @@ public class LanguageManager {
|
|||
Set<String> contentTypes= collectContentTypeIds();
|
||||
return contentTypes.toArray(new String[contentTypes.size()]);
|
||||
}
|
||||
|
||||
|
||||
private Set<String> collectContentTypeIds() {
|
||||
HashSet<String> allTypes = new HashSet<String>();
|
||||
allTypes.add(CCorePlugin.CONTENT_TYPE_ASMSOURCE);
|
||||
|
@ -262,26 +264,26 @@ public class LanguageManager {
|
|||
allTypes.add(CCorePlugin.CONTENT_TYPE_CXXHEADER);
|
||||
allTypes.add(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
|
||||
|
||||
IContentTypeManager manager = Platform.getContentTypeManager();
|
||||
IContentTypeManager manager = Platform.getContentTypeManager();
|
||||
IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
|
||||
for (int j = 0; j < configs.length; ++j) {
|
||||
final IConfigurationElement languageElem = configs[j];
|
||||
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) {
|
||||
IContentType langContType = manager.getContentType(contentTypes[k].getAttribute(ATTRIBUTE_ID));
|
||||
IContentType langContType = manager.getContentType(contentTypes[k].getAttribute(ATTRIBUTE_ID));
|
||||
allTypes.add(langContType.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return allTypes;
|
||||
}
|
||||
|
||||
public boolean isContributedContentType(String contentTypeId) {
|
||||
return contentTypeId != null && getLanguageForContentTypeID(contentTypeId) != null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getContributedModelBuilderFor(ITranslationUnit)}, instead.
|
||||
* @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.
|
||||
* @since 4.0
|
||||
*/
|
||||
public Map<String, IPDOMLinkageFactory> getPDOMLinkageFactoryMappings() {
|
||||
if (!fPDOMLinkageFactoryCache.isEmpty())
|
||||
return Collections.unmodifiableMap(fPDOMLinkageFactoryCache);
|
||||
|
||||
|
||||
fPDOMLinkageFactoryCache.clear();
|
||||
final IPDOMLinkageFactory[] result = new IPDOMLinkageFactory[] {null};
|
||||
|
||||
|
||||
// read configuration
|
||||
IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
|
||||
for (final IConfigurationElement element : configs) {
|
||||
if (ELEMENT_PDOM_LINKAGE_FACTORY.equals(element.getName())) {
|
||||
SafeRunner.run(new ISafeRunnable() {
|
||||
@Override
|
||||
public void handleException(Throwable exception) {
|
||||
CCorePlugin.log(exception);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
result[0] = (IPDOMLinkageFactory) element.createExecutableExtension(ATTRIBUTE_CLASS);
|
||||
}}
|
||||
);
|
||||
);
|
||||
fPDOMLinkageFactoryCache.put(element.getAttribute(ATTRIBUTE_ID), result[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableMap(fPDOMLinkageFactoryCache);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 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) {
|
||||
final IConfigurationElement languageElem = configs[j];
|
||||
if (ELEMENT_LANGUAGE.equals(languageElem.getName())) {
|
||||
String langId = getLanguageID(languageElem);
|
||||
String langId = getLanguageID(languageElem);
|
||||
final ILanguage[] result= new ILanguage[] { null };
|
||||
SafeRunner.run(new ISafeRunnable() {
|
||||
@Override
|
||||
public void handleException(Throwable exception) {
|
||||
CCorePlugin.log(exception);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
result[0]= (ILanguage) languageElem.createExecutableExtension(ATTRIBUTE_CLASS);
|
||||
}
|
||||
|
@ -379,7 +385,7 @@ public class LanguageManager {
|
|||
}
|
||||
fIsFullyCached = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the language configuration for the workspace.
|
||||
* @return the language configuration for the workspace
|
||||
|
@ -391,16 +397,16 @@ public class LanguageManager {
|
|||
if (fWorkspaceMappings != null) {
|
||||
return fWorkspaceMappings;
|
||||
}
|
||||
|
||||
|
||||
LanguageMappingStore store = new LanguageMappingStore();
|
||||
fWorkspaceMappings = store.decodeWorkspaceMappings();
|
||||
return fWorkspaceMappings;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Saves the workspace language configuration to persistent storage and notifies
|
||||
* all <code>ILanguageMappingChangeListeners</code> of changes.
|
||||
* all <code>ILanguageMappingChangeListeners</code> of changes.
|
||||
* @param affectedContentTypes
|
||||
* @throws CoreException
|
||||
* @since 4.0
|
||||
|
@ -410,18 +416,18 @@ public class LanguageManager {
|
|||
if (fWorkspaceMappings == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
LanguageMappingStore store = new LanguageMappingStore();
|
||||
store.storeMappings(fWorkspaceMappings);
|
||||
}
|
||||
|
||||
|
||||
// Notify listeners that the language mappings have changed.
|
||||
LanguageMappingChangeEvent event = new LanguageMappingChangeEvent();
|
||||
event.setType(ILanguageMappingChangeEvent.TYPE_WORKSPACE);
|
||||
event.setAffectedContentTypes(affectedContentTypes);
|
||||
notifyLanguageChangeListeners(event);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the language configuration for the given project.
|
||||
* @param project
|
||||
|
@ -435,18 +441,18 @@ public class LanguageManager {
|
|||
if (mappings != null) {
|
||||
return mappings;
|
||||
}
|
||||
|
||||
|
||||
LanguageMappingStore store = new LanguageMappingStore();
|
||||
mappings = store.decodeMappings(project);
|
||||
fLanguageConfigurationCache.put(project, mappings);
|
||||
return mappings;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Saves the language configuration for the given project to persistent
|
||||
* storage and notifies all <code>ILanguageMappingChangeListeners</code>
|
||||
* of changes.
|
||||
* of changes.
|
||||
* @param project
|
||||
* @param affectedContentTypes
|
||||
* @throws CoreException
|
||||
|
@ -458,7 +464,7 @@ public class LanguageManager {
|
|||
LanguageMappingStore store = new LanguageMappingStore();
|
||||
store.storeMappings(project, mappings);
|
||||
}
|
||||
|
||||
|
||||
// Notify listeners that the language mappings have changed.
|
||||
LanguageMappingChangeEvent event = new LanguageMappingChangeEvent();
|
||||
event.setType(ILanguageMappingChangeEvent.TYPE_PROJECT);
|
||||
|
@ -466,7 +472,7 @@ public class LanguageManager {
|
|||
event.setAffectedContentTypes(affectedContentTypes);
|
||||
notifyLanguageChangeListeners(event);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an ILanguage representing the language to be used for the given file.
|
||||
* @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 configuration the active build configuration, or <code>null</code> if build configurations
|
||||
* are not relevant to determining the language.
|
||||
* @throws CoreException
|
||||
* @throws CoreException
|
||||
*/
|
||||
public ILanguage getLanguageForFile(String fullPathToFile, IProject project, ICConfigurationDescription configuration) throws CoreException {
|
||||
if (project == null)
|
||||
throw new IllegalArgumentException("project must not be null in call to LanguageManager.getLanguageForFile(String, IProject)"); //$NON-NLS-1$
|
||||
|
||||
|
||||
IContentType contentType = CContentTypes.getContentType(project, fullPathToFile);
|
||||
|
||||
|
||||
if (contentType == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
String contentTypeID = contentType.getId();
|
||||
|
||||
|
||||
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 {
|
||||
return getLanguageForFile(pathToFile, project, configuration, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -536,7 +542,7 @@ public class LanguageManager {
|
|||
}
|
||||
contentTypeID= ct.getId();
|
||||
}
|
||||
|
||||
|
||||
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,
|
||||
String contentTypeId) throws CoreException {
|
||||
IProject project = file.getProject();
|
||||
|
||||
|
||||
if (contentTypeId == null) {
|
||||
IPath location = file.getLocation();
|
||||
String filename;
|
||||
|
@ -581,36 +587,36 @@ public class LanguageManager {
|
|||
}
|
||||
contentTypeId= contentType.getId();
|
||||
}
|
||||
|
||||
|
||||
return LanguageMappingResolver.computeLanguage(project, file.getProjectRelativePath().toPortableString(), configuration, contentTypeId, false)[0].language;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a listener that will be notified of changes in language mappings.
|
||||
*
|
||||
*
|
||||
* @param listener the ILanguageMappingChangeListener to add
|
||||
*/
|
||||
public void registerLanguageChangeListener(ILanguageMappingChangeListener listener) {
|
||||
fLanguageChangeListeners.add(listener);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes a language mapping change listener.
|
||||
*
|
||||
*
|
||||
* @param listener the ILanguageMappingChangeListener to remove.
|
||||
*/
|
||||
public void unregisterLanguageChangeListener(ILanguageMappingChangeListener listener) {
|
||||
fLanguageChangeListeners.remove(listener);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notifies all language mappings change listeners of a change in the mappings.
|
||||
*
|
||||
*
|
||||
* @param event the ILanguageMappingsChange event to be broadcast.
|
||||
*/
|
||||
public void notifyLanguageChangeListeners(ILanguageMappingChangeEvent event) {
|
||||
Object[] listeners = fLanguageChangeListeners.getListeners();
|
||||
|
||||
|
||||
for (Object obj : listeners) {
|
||||
ILanguageMappingChangeListener listener = (ILanguageMappingChangeListener) obj;
|
||||
listener.handleLanguageMappingChangeEvent(event);
|
||||
|
@ -620,7 +626,7 @@ public class LanguageManager {
|
|||
/**
|
||||
* Saves the language configuration for the given file to persistent
|
||||
* storage and notifies all <code>ILanguageMappingChangeListeners</code>
|
||||
* of changes.
|
||||
* of changes.
|
||||
* @param file
|
||||
* @throws CoreException
|
||||
* @since 4.0
|
||||
|
@ -632,7 +638,7 @@ public class LanguageManager {
|
|||
LanguageMappingStore store = new LanguageMappingStore();
|
||||
store.storeMappings(project, mappings);
|
||||
}
|
||||
|
||||
|
||||
// Notify listeners that the language mappings have changed.
|
||||
LanguageMappingChangeEvent event = new LanguageMappingChangeEvent();
|
||||
event.setType(ILanguageMappingChangeEvent.TYPE_FILE);
|
||||
|
@ -645,10 +651,10 @@ public class LanguageManager {
|
|||
* Returns language binding to a particular content type for given project.
|
||||
* This method will check project settings, workspace settings and default
|
||||
* bindings (in that order)
|
||||
*
|
||||
*
|
||||
* @param contentType content type of the file
|
||||
* @param project C/C++ workspace project
|
||||
* @return CDT language object
|
||||
* @return CDT language object
|
||||
* @since 5.4
|
||||
*/
|
||||
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.
|
||||
* This method will check project settings, workspace settings and default
|
||||
* bindings (in that order)
|
||||
*
|
||||
*
|
||||
* @param contentType content type of the file
|
||||
* @param project C/C++ workspace project
|
||||
* @param configurationDescription build configuration or <code>null</code>
|
||||
* @return CDT language object
|
||||
* @return CDT language object
|
||||
* @since 5.4
|
||||
*/
|
||||
public ILanguage getLanguage(IContentType contentType,
|
||||
|
|
|
@ -19,9 +19,9 @@ import org.eclipse.core.runtime.content.IContentType;
|
|||
|
||||
/**
|
||||
* A minimal implementation of ILanguageMappingsChangeEvent.
|
||||
*
|
||||
*
|
||||
* @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 {
|
||||
|
||||
|
@ -35,6 +35,7 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getAffectedContentTypes()
|
||||
*/
|
||||
@Override
|
||||
public IContentType[] getAffectedContentTypes() {
|
||||
return fContentTypes;
|
||||
}
|
||||
|
@ -42,6 +43,7 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getFile()
|
||||
*/
|
||||
@Override
|
||||
public IFile getFile() {
|
||||
return fFile;
|
||||
}
|
||||
|
@ -49,11 +51,12 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getFilename()
|
||||
*/
|
||||
@Override
|
||||
public String getFilename() {
|
||||
|
||||
|
||||
// if the filename has been set, use it. otherwise get the path from
|
||||
// either the IFile or the IPath if we have one
|
||||
|
||||
|
||||
if(fFileName != null)
|
||||
return fFileName;
|
||||
else {
|
||||
|
@ -65,30 +68,31 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent {
|
|||
else {
|
||||
// use the URI if there is one
|
||||
URI uri = fFile.getLocationURI();
|
||||
|
||||
|
||||
if(uri != null)
|
||||
return uri.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else { // no file, use path
|
||||
if(fPath != null)
|
||||
return fPath.toString();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getPath()
|
||||
*/
|
||||
@Override
|
||||
public IPath getPath() {
|
||||
|
||||
|
||||
if(fPath != null)
|
||||
return fPath;
|
||||
|
||||
|
||||
else { // try to get the path from the file if we have one
|
||||
if(fFile != null)
|
||||
{
|
||||
|
@ -96,31 +100,33 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent {
|
|||
return location;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getProject()
|
||||
*/
|
||||
@Override
|
||||
public IProject getProject() {
|
||||
|
||||
|
||||
if(fProject != null)
|
||||
return fProject;
|
||||
|
||||
|
||||
else { // try to get the project from the file if we have one
|
||||
|
||||
|
||||
if(fFile != null)
|
||||
return fFile.getProject();
|
||||
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ILanguageMappingsChangeEvent#getType()
|
||||
*/
|
||||
@Override
|
||||
public int getType() {
|
||||
return fType;
|
||||
}
|
||||
|
@ -128,7 +134,7 @@ public class LanguageMappingChangeEvent implements ILanguageMappingChangeEvent {
|
|||
/**
|
||||
* Sets the associated IContentTypes for this event. The provided array will be returned
|
||||
* subsequently by getAffectedContentTypes.
|
||||
*
|
||||
*
|
||||
* @param 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
|
||||
* by getFile().
|
||||
*
|
||||
*
|
||||
* @param file the IFile to set
|
||||
*/
|
||||
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
|
||||
* by getFileName().
|
||||
*
|
||||
*
|
||||
* @param fileName the fFileName to set
|
||||
*/
|
||||
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
|
||||
* by getPath().
|
||||
*
|
||||
*
|
||||
* @param path the IPath to set
|
||||
*/
|
||||
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
|
||||
* by getProject().
|
||||
*
|
||||
*
|
||||
* @param project the IProject to set
|
||||
*/
|
||||
public void setProject(IProject project) {
|
||||
fProject = project;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the type of this event. This type will be returned by getType().
|
||||
*
|
||||
*
|
||||
* @param type the type to set
|
||||
* @see ILanguageMappingChangeEvent#TYPE_WORKSPACE
|
||||
* @see ILanguageMappingChangeEvent#TYPE_PROJECT
|
||||
|
|
|
@ -25,19 +25,20 @@ public class CDTListComparator implements Comparator<Object> {
|
|||
comparator = new CDTListComparator();
|
||||
return comparator;
|
||||
}
|
||||
@Override
|
||||
public int compare(Object a, Object b) {
|
||||
if (a == null || b == null)
|
||||
if (a == null || b == null)
|
||||
return 0;
|
||||
if (a instanceof ICLanguageSetting) {
|
||||
ICLanguageSetting c1 = (ICLanguageSetting)a;
|
||||
ICLanguageSetting c2 = (ICLanguageSetting)b;
|
||||
return c1.getName().compareToIgnoreCase(c2.getName());
|
||||
}
|
||||
}
|
||||
if (a instanceof ICLanguageSettingEntry) {
|
||||
ICLanguageSettingEntry c1 = (ICLanguageSettingEntry)a;
|
||||
ICLanguageSettingEntry c2 = (ICLanguageSettingEntry)b;
|
||||
return c1.getName().compareToIgnoreCase(c2.getName());
|
||||
}
|
||||
}
|
||||
if (a instanceof ICConfigurationDescription) {
|
||||
ICConfigurationDescription c1 = (ICConfigurationDescription)a;
|
||||
ICConfigurationDescription c2 = (ICConfigurationDescription)b;
|
||||
|
@ -46,7 +47,7 @@ public class CDTListComparator implements Comparator<Object> {
|
|||
if (a instanceof ICdtVariable) {
|
||||
ICdtVariable c1 = (ICdtVariable) a;
|
||||
ICdtVariable c2 = (ICdtVariable) b;
|
||||
return c1.getName().compareToIgnoreCase(c2.getName());
|
||||
return c1.getName().compareToIgnoreCase(c2.getName());
|
||||
}
|
||||
return a.toString().compareTo(b.toString());
|
||||
}
|
||||
|
|
|
@ -40,11 +40,12 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx
|
|||
protected final boolean isFile() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the exclusion patterns
|
||||
* @return IPath[]
|
||||
*/
|
||||
@Override
|
||||
public IPath[] getExclusionPatterns() {
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public char[][] fullExclusionPatternChars() {
|
||||
if (this.fullCharExclusionPatterns == UNINIT_PATTERNS) {
|
||||
int length = this.exclusionPatterns.length;
|
||||
|
@ -61,18 +63,18 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx
|
|||
path = getLocation();
|
||||
IPath prefixPath = path.removeTrailingSeparator();
|
||||
for (int i = 0; i < length; i++) {
|
||||
this.fullCharExclusionPatterns[i] =
|
||||
this.fullCharExclusionPatterns[i] =
|
||||
prefixPath.append(this.exclusionPatterns[i]).toString().toCharArray();
|
||||
}
|
||||
}
|
||||
return this.fullCharExclusionPatterns;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if(!super.equals(other))
|
||||
return false;
|
||||
|
||||
|
||||
ACExclusionFilterEntry otherEntry = (ACExclusionFilterEntry)other;
|
||||
return Arrays.equals(exclusionPatterns, otherEntry.exclusionPatterns);
|
||||
}
|
||||
|
@ -86,7 +88,7 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx
|
|||
public boolean equalsByContents(ICSettingEntry entry) {
|
||||
if(!super.equalsByContents(entry))
|
||||
return false;
|
||||
|
||||
|
||||
ACExclusionFilterEntry otherEntry = (ACExclusionFilterEntry)entry;
|
||||
return Arrays.equals(exclusionPatterns, otherEntry.exclusionPatterns);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public abstract class ACPathEntry extends ACSettingEntry
|
|||
// IPath fFullPath;
|
||||
// IPath fLocation;
|
||||
// private IPath fPath;
|
||||
|
||||
|
||||
ACPathEntry(IResource rc, int flags) {
|
||||
super(rc.getFullPath().toString(), flags | RESOLVED | VALUE_WORKSPACE_PATH);
|
||||
// fFullPath = rc.getFullPath();
|
||||
|
@ -37,7 +37,7 @@ public abstract class ACPathEntry extends ACSettingEntry
|
|||
ACPathEntry(String value, int flags) {
|
||||
super(value, flags);
|
||||
}
|
||||
|
||||
|
||||
ACPathEntry(IPath path, int flags) {
|
||||
super(path.toString(), flags /*| RESOLVED*/);
|
||||
// fPath = path;
|
||||
|
@ -47,6 +47,7 @@ public abstract class ACPathEntry extends ACSettingEntry
|
|||
// fLocation = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPath getFullPath() {
|
||||
if(isValueWorkspacePath())
|
||||
return new Path(getValue());
|
||||
|
@ -56,19 +57,20 @@ public abstract class ACPathEntry extends ACSettingEntry
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
protected IPath fullPathForLocation(IPath location){
|
||||
IResource rcs[] = isFile() ?
|
||||
(IResource[])ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(location)
|
||||
: (IResource[])ResourcesPlugin.getWorkspace().getRoot().findContainersForLocation(location);
|
||||
|
||||
|
||||
if(rcs.length > 0)
|
||||
return rcs[0].getFullPath();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
protected abstract boolean isFile();
|
||||
|
||||
@Override
|
||||
public IPath getLocation() {
|
||||
if(!isValueWorkspacePath())
|
||||
return new Path(getValue());
|
||||
|
@ -80,7 +82,8 @@ public abstract class ACPathEntry extends ACSettingEntry
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isValueWorkspacePath() {
|
||||
return checkFlags(VALUE_WORKSPACE_PATH);
|
||||
}
|
||||
|
|
|
@ -18,107 +18,115 @@ import org.eclipse.cdt.internal.core.SafeStringInterner;
|
|||
public abstract class ACSettingEntry implements ICSettingEntry {
|
||||
int fFlags;
|
||||
String fName;
|
||||
|
||||
|
||||
ACSettingEntry(String name, int flags){
|
||||
fName = SafeStringInterner.safeIntern(name);
|
||||
fFlags = flags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltIn() {
|
||||
return checkFlags(BUILTIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
return checkFlags(READONLY);
|
||||
}
|
||||
|
||||
|
||||
protected boolean checkFlags(int flags){
|
||||
return (fFlags & flags) == flags;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return fName;
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
return fName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResolved() {
|
||||
return checkFlags(RESOLVED);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other){
|
||||
if(other == this)
|
||||
return true;
|
||||
|
||||
|
||||
if(!(other instanceof ACSettingEntry))
|
||||
return false;
|
||||
|
||||
|
||||
ACSettingEntry e = (ACSettingEntry)other;
|
||||
|
||||
|
||||
if(getKind() != e.getKind())
|
||||
return false;
|
||||
|
||||
|
||||
if(fFlags != e.fFlags)
|
||||
return false;
|
||||
|
||||
|
||||
if(!fName.equals(e.fName))
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode(){
|
||||
return getKind() + fFlags + fName.hashCode();
|
||||
return getKind() + fFlags + fName.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return fFlags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsByContents(ICSettingEntry entry) {
|
||||
return equalsByName(entry);
|
||||
}
|
||||
|
||||
|
||||
protected int getByNameMatchFlags(){
|
||||
return (fFlags & (~ (BUILTIN | READONLY | RESOLVED)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equalsByName(ICSettingEntry entry) {
|
||||
if(entry == this)
|
||||
return true;
|
||||
|
||||
|
||||
if(!(entry instanceof ACSettingEntry))
|
||||
return false;
|
||||
|
||||
|
||||
ACSettingEntry e = (ACSettingEntry)entry;
|
||||
|
||||
|
||||
if(getKind() != e.getKind())
|
||||
return false;
|
||||
|
||||
|
||||
if(getByNameMatchFlags()
|
||||
!= e.getByNameMatchFlags())
|
||||
return false;
|
||||
|
||||
|
||||
if(!fName.equals(e.fName))
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public final int codeForNameKey(){
|
||||
return getKind() + getByNameMatchFlags() + fName.hashCode();
|
||||
return getKind() + getByNameMatchFlags() + fName.hashCode();
|
||||
}
|
||||
|
||||
|
||||
public int codeForContentsKey(){
|
||||
return codeForNameKey();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final String toString(){
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
@ -127,7 +135,7 @@ public abstract class ACSettingEntry implements ICSettingEntry {
|
|||
buf.append(" ; flags: ").append(LanguageSettingEntriesSerializer.composeFlagsString(getFlags())); //$NON-NLS-1$
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
protected abstract String contentsToString();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -29,14 +29,14 @@ public final class CExternalSetting implements ICExternalSetting {
|
|||
fLanguageIds = base.getCompatibleLanguageIds();
|
||||
fContentTypeIds = base.getCompatibleContentTypeIds();
|
||||
fExtensions = base.getCompatibleExtensions();
|
||||
|
||||
|
||||
// fEntryStore = new EntryStore();
|
||||
initEntryStore(base.getEntries());
|
||||
}
|
||||
|
||||
public CExternalSetting(ICExternalSetting base, ICSettingEntry entries[]) {
|
||||
this(base);
|
||||
|
||||
|
||||
initEntryStore(entries);
|
||||
}
|
||||
|
||||
|
@ -48,25 +48,25 @@ public final class CExternalSetting implements ICExternalSetting {
|
|||
fContentTypeIds = contentTypeIds.clone();
|
||||
if (extensions != null)
|
||||
fExtensions = extensions.clone();
|
||||
|
||||
|
||||
initEntryStore(entries);
|
||||
}
|
||||
|
||||
|
||||
private void initEntryStore(ICSettingEntry entries[]) {
|
||||
ICSettingEntry entry;
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
entry = entries[i];
|
||||
|
||||
|
||||
addEntry(entry);
|
||||
}
|
||||
|
||||
|
||||
// trimToSize();
|
||||
}
|
||||
|
||||
|
||||
private void addEntry(ICSettingEntry entry) {
|
||||
getEntriesSet(entry.getKind(), true).addEntry(entry);
|
||||
}
|
||||
|
||||
|
||||
// private void trimToSize() {
|
||||
// int kinds[] = KindBasedStore.getSupportedKinds();
|
||||
// for (int i = 0; i < kinds.length; i++) {
|
||||
|
@ -75,7 +75,7 @@ public final class CExternalSetting implements ICExternalSetting {
|
|||
// set.trimToSize();
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
private CEntriesSet getEntriesSet(int kind, boolean create) {
|
||||
CEntriesSet set = fStore.get(kind);
|
||||
if (set == null && create) {
|
||||
|
@ -85,24 +85,28 @@ public final class CExternalSetting implements ICExternalSetting {
|
|||
return set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getCompatibleContentTypeIds() {
|
||||
if (fContentTypeIds != null)
|
||||
return fContentTypeIds.clone();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getCompatibleExtensions() {
|
||||
if (fExtensions != null)
|
||||
return fExtensions.clone();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getCompatibleLanguageIds() {
|
||||
if (fLanguageIds != null)
|
||||
return fLanguageIds.clone();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICSettingEntry[] getEntries(int kind) {
|
||||
CEntriesSet set = getEntriesSet(kind, false);
|
||||
if (set != null)
|
||||
|
@ -114,6 +118,7 @@ public final class CExternalSetting implements ICExternalSetting {
|
|||
// return fId;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public ICSettingEntry[] getEntries() {
|
||||
List<ICSettingEntry> result = new ArrayList<ICSettingEntry>();
|
||||
int kinds[] = KindBasedStore.getAllEntryKinds();
|
||||
|
@ -122,7 +127,7 @@ public final class CExternalSetting implements ICExternalSetting {
|
|||
if (list != null)
|
||||
result.addAll(Arrays.asList(list.toArray()));
|
||||
}
|
||||
|
||||
|
||||
return result.toArray(new ICSettingEntry[result.size()]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ public final class CIncludeFileEntry extends ACPathEntry implements
|
|||
super(rc, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getKind() {
|
||||
return INCLUDE_FILE;
|
||||
}
|
||||
|
|
|
@ -27,10 +27,12 @@ public final class CIncludePathEntry extends ACPathEntry implements ICIncludePat
|
|||
super(rc, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocal() {
|
||||
return checkFlags(LOCAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getKind() {
|
||||
return INCLUDE_PATH;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public final class CLibraryFileEntry extends ACPathEntry implements
|
|||
private IPath fSourceAttachmentPath;
|
||||
private IPath fSourceAttachmentRootPath;
|
||||
private IPath fSourceAttachmentPrefixMapping;
|
||||
|
||||
|
||||
public CLibraryFileEntry(String value, int flags) {
|
||||
this(value, flags, null, null, null);
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ public final class CLibraryFileEntry extends ACPathEntry implements
|
|||
this(rc, flags, null, null, null);
|
||||
}
|
||||
|
||||
public CLibraryFileEntry(String value,
|
||||
int flags,
|
||||
public CLibraryFileEntry(String value,
|
||||
int flags,
|
||||
IPath sourceAttachmentPath,
|
||||
IPath sourceAttachmentRootPath,
|
||||
IPath sourceAttachmentPrefixMapping) {
|
||||
|
@ -43,7 +43,7 @@ public final class CLibraryFileEntry extends ACPathEntry implements
|
|||
}
|
||||
|
||||
public CLibraryFileEntry(IPath location,
|
||||
int flags,
|
||||
int flags,
|
||||
IPath sourceAttachmentPath,
|
||||
IPath sourceAttachmentRootPath,
|
||||
IPath sourceAttachmentPrefixMapping) {
|
||||
|
@ -51,26 +51,27 @@ public final class CLibraryFileEntry extends ACPathEntry implements
|
|||
setSourceAttachmentSettings(sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping);
|
||||
}
|
||||
|
||||
public CLibraryFileEntry(IFile rc,
|
||||
int flags,
|
||||
public CLibraryFileEntry(IFile rc,
|
||||
int flags,
|
||||
IPath sourceAttachmentPath,
|
||||
IPath sourceAttachmentRootPath,
|
||||
IPath sourceAttachmentPrefixMapping) {
|
||||
super(rc, flags);
|
||||
setSourceAttachmentSettings(sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping);
|
||||
}
|
||||
|
||||
|
||||
private void setSourceAttachmentSettings(IPath sourceAttachmentPath,
|
||||
IPath sourceAttachmentRootPath,
|
||||
IPath sourceAttachmentPrefixMapping){
|
||||
if(sourceAttachmentPath == null)
|
||||
return;
|
||||
|
||||
|
||||
fSourceAttachmentPath = sourceAttachmentPath;
|
||||
fSourceAttachmentRootPath = sourceAttachmentRootPath != null ? sourceAttachmentRootPath : Path.EMPTY;
|
||||
fSourceAttachmentPrefixMapping = sourceAttachmentPrefixMapping != null ? sourceAttachmentPrefixMapping : Path.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getKind() {
|
||||
return LIBRARY_FILE;
|
||||
}
|
||||
|
@ -80,14 +81,17 @@ public final class CLibraryFileEntry extends ACPathEntry implements
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPath getSourceAttachmentPath() {
|
||||
return fSourceAttachmentPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPath getSourceAttachmentPrefixMapping() {
|
||||
return fSourceAttachmentPrefixMapping;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPath getSourceAttachmentRootPath() {
|
||||
return fSourceAttachmentRootPath;
|
||||
}
|
||||
|
@ -108,10 +112,10 @@ public final class CLibraryFileEntry extends ACPathEntry implements
|
|||
public boolean equals(Object other) {
|
||||
if(other == this)
|
||||
return true;
|
||||
|
||||
|
||||
if(!super.equals(other))
|
||||
return false;
|
||||
|
||||
|
||||
return sourceAttachmentSettingsEqual((CLibraryFileEntry)other);
|
||||
}
|
||||
|
||||
|
@ -119,13 +123,13 @@ public final class CLibraryFileEntry extends ACPathEntry implements
|
|||
public boolean equalsByContents(ICSettingEntry entry) {
|
||||
if(entry == this)
|
||||
return true;
|
||||
|
||||
|
||||
if(!super.equalsByContents(entry))
|
||||
return false;
|
||||
|
||||
|
||||
return sourceAttachmentSettingsEqual((CLibraryFileEntry)entry);
|
||||
}
|
||||
|
||||
|
||||
private boolean sourceAttachmentSettingsEqual(CLibraryFileEntry otherEntry){
|
||||
if(!CDataUtil.objectsEqual(fSourceAttachmentPath, otherEntry.fSourceAttachmentPath))
|
||||
return false;
|
||||
|
@ -135,11 +139,11 @@ public final class CLibraryFileEntry extends ACPathEntry implements
|
|||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String contentsToString() {
|
||||
String result = super.contentsToString();
|
||||
|
||||
|
||||
if(fSourceAttachmentPath != null){
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(result);
|
||||
|
|
|
@ -28,6 +28,7 @@ public final class CLibraryPathEntry extends ACPathEntry implements
|
|||
super(rc, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getKind() {
|
||||
return LIBRARY_PATH;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry{
|
|||
return fValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getKind() {
|
||||
return MACRO;
|
||||
}
|
||||
|
@ -49,7 +50,7 @@ public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry{
|
|||
public boolean equalsByContents(ICSettingEntry entry) {
|
||||
if(!super.equalsByContents(entry))
|
||||
return false;
|
||||
|
||||
|
||||
return fValue.equals(((CMacroEntry)entry).fValue);
|
||||
}
|
||||
|
||||
|
@ -57,5 +58,5 @@ public final class CMacroEntry extends ACSettingEntry implements ICMacroEntry{
|
|||
protected String contentsToString() {
|
||||
return new StringBuffer().append(fName).append('=').append(fValue).toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -28,10 +28,11 @@ public final class CMacroFileEntry extends ACPathEntry implements
|
|||
super(rc, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getKind() {
|
||||
return MACRO_FILE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final boolean isFile() {
|
||||
return true;
|
||||
|
|
|
@ -27,6 +27,7 @@ public final class COutputEntry extends ACExclusionFilterEntry implements ICOutp
|
|||
super(value, exclusionPatterns, flags | VALUE_WORKSPACE_PATH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getKind() {
|
||||
return OUTPUT_PATH;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ public final class CSourceEntry extends ACExclusionFilterEntry implements ICSour
|
|||
super(value, exclusionPatterns, flags | VALUE_WORKSPACE_PATH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getKind() {
|
||||
return SOURCE_PATH;
|
||||
}
|
||||
|
|
|
@ -175,6 +175,7 @@ public interface ICConfigurationDescription extends ICSettingContainer, ICSettin
|
|||
/**
|
||||
* Returns whether or not the configuration description was modified
|
||||
*/
|
||||
@Override
|
||||
boolean isModified();
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,5 +19,6 @@ public interface ICMacroEntry extends ICLanguageSettingEntry {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.settings.model.ICSettingEntry#getValue()
|
||||
*/
|
||||
@Override
|
||||
String getValue();
|
||||
}
|
||||
|
|
|
@ -20,11 +20,11 @@ import org.eclipse.core.runtime.QualifiedName;
|
|||
* The ICProjectDescription is the root element for obtaining the CDT project settings
|
||||
* it can be obtained by the {@link CoreModel#getProjectDescription(IProject, boolean)} call
|
||||
* @see CoreModel#getProjectDescription(IProject)
|
||||
* @see CoreModel#getProjectDescription(IProject, boolean)
|
||||
* @see CoreModel#getProjectDescription(IProject, boolean)
|
||||
*
|
||||
*/
|
||||
public interface ICProjectDescription extends ICSettingContainer,
|
||||
ICSettingObject,
|
||||
public interface ICProjectDescription extends ICSettingContainer,
|
||||
ICSettingObject,
|
||||
ICSettingsStorage,
|
||||
ICProjectDescriptionPreferences {
|
||||
|
||||
|
@ -32,7 +32,7 @@ public interface ICProjectDescription extends ICSettingContainer,
|
|||
* @return {@link ICConfigurationDescription}[] containing all configurations in the project
|
||||
*/
|
||||
ICConfigurationDescription[] getConfigurations();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the Project's active configuration. This is the configuration which is built by default
|
||||
* @see ICProjectDescriptionPreferences#setConfigurationRelations(int)
|
||||
|
@ -42,9 +42,9 @@ public interface ICProjectDescription extends ICSettingContainer,
|
|||
|
||||
/**
|
||||
* sets active configuration for this project description
|
||||
*
|
||||
*
|
||||
* @param cfg
|
||||
*
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
@ -52,7 +52,7 @@ public interface ICProjectDescription extends ICSettingContainer,
|
|||
|
||||
/**
|
||||
* creates/adds a new configuration for this project description
|
||||
*
|
||||
*
|
||||
* @param id configuration id
|
||||
* @param name configuration name
|
||||
* @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 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
|
||||
*
|
||||
*
|
||||
*/
|
||||
ICConfigurationDescription createConfiguration(String id, String name, ICConfigurationDescription base) throws CoreException, WriteAccessException;
|
||||
|
||||
/**
|
||||
* creates/adds a new configuration for this project description
|
||||
* 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
|
||||
* @param data CConfigurationData to be associated with this configuration
|
||||
* @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
|
||||
*/
|
||||
ICConfigurationDescription getConfigurationById(String id);
|
||||
|
||||
|
||||
/**
|
||||
* Remove Configuration of the given name from the project description
|
||||
* @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
|
||||
*/
|
||||
void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException;
|
||||
|
||||
|
||||
/**
|
||||
* @return IProject this project description is associated with
|
||||
*/
|
||||
IProject getProject();
|
||||
|
||||
|
||||
/**
|
||||
* @return true if the project description was modified, false otherwise
|
||||
*/
|
||||
@Override
|
||||
boolean isModified();
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* @param 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
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* @param value
|
||||
*/
|
||||
void setSessionProperty(QualifiedName name, Object value);
|
||||
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* @return the default {@link ICConfigurationDescription}
|
||||
*/
|
||||
|
@ -153,28 +154,28 @@ public interface ICProjectDescription extends ICSettingContainer,
|
|||
* @param cfg
|
||||
*/
|
||||
void setDefaultSettingConfiguration(ICConfigurationDescription cfg);
|
||||
|
||||
|
||||
/**
|
||||
* when true specifies that the project creation is in progress.
|
||||
* Sometimes project creation might be performed via multiple steps, e.g.
|
||||
* the New Project Wizard may create a temporary project with temporary settings
|
||||
* and delete it on cancel, etc.
|
||||
*
|
||||
*
|
||||
* Thus the project may exist as well as the project may contain the associated ICProjectDescription,
|
||||
* but its initialization may not be completed.
|
||||
*
|
||||
*
|
||||
* 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,
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* so only the newly created descriptions (created via a {@link ICProjectDescriptionManager#createProjectDescription(IProject, boolean, boolean)}) may contain
|
||||
* true "isCdtProjectCreating" state
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
*
|
||||
* @see ICProjectDescriptionManager#createProjectDescription(IProject, boolean, boolean)
|
||||
* @see #setCdtProjectCreated()
|
||||
*/
|
||||
|
@ -182,7 +183,7 @@ public interface ICProjectDescription extends ICSettingContainer,
|
|||
|
||||
/**
|
||||
* sets the project creation state to false
|
||||
*
|
||||
*
|
||||
* @see #isCdtProjectCreating()
|
||||
* @see ICProjectDescriptionManager#createProjectDescription(IProject, boolean, boolean)
|
||||
*/
|
||||
|
|
|
@ -25,21 +25,22 @@ public abstract class MultiItemsHolder implements ICMultiItemsHolder {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.settings.model.ICMultiItemsHolder#getItems()
|
||||
*/
|
||||
@Override
|
||||
public abstract Object[] getItems();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.settings.model.ICMultiItemsHolder#setStringListMode(int)
|
||||
*/
|
||||
/**
|
||||
* This method is put here to prevent UI from
|
||||
* accessing constructors in "internal" dirs.
|
||||
*
|
||||
* This method is put here to prevent UI from
|
||||
* accessing constructors in "internal" dirs.
|
||||
*
|
||||
* Creates multiple configuration description.
|
||||
* If there's 1 cfg.desc in array,
|
||||
* it's returned itself.
|
||||
*
|
||||
* If there's 1 cfg.desc in array,
|
||||
* it's returned itself.
|
||||
*
|
||||
* @param rds - array of cfg.descs
|
||||
*
|
||||
*
|
||||
* @return multiple cfg.description or single cfg.desc.
|
||||
*/
|
||||
public static ICConfigurationDescription createCDescription(ICConfigurationDescription[] rds) {
|
||||
|
@ -51,16 +52,16 @@ public abstract class MultiItemsHolder implements ICMultiItemsHolder {
|
|||
return new MultiConfigDescription(rds);
|
||||
}
|
||||
/**
|
||||
* This method is put here to prevent UI from
|
||||
* accessing constructors in "internal" dirs.
|
||||
*
|
||||
* This method is put here to prevent UI from
|
||||
* accessing constructors in "internal" dirs.
|
||||
*
|
||||
* Creates multiple resource description, it
|
||||
* can be either MultiFile or MultiFolder.
|
||||
* If there's 1 description in array,
|
||||
* it's returned itself.
|
||||
*
|
||||
* If there's 1 description in array,
|
||||
* it's returned itself.
|
||||
*
|
||||
* @param rds - array of resource descs
|
||||
*
|
||||
*
|
||||
* @return multiple res.description or single res.desc.
|
||||
*/
|
||||
public static ICResourceDescription createRDescription(ICResourceDescription[] rds) {
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguageSetting {
|
||||
ICLanguageSetting[] items = null;
|
||||
ICConfigurationDescription cfgd = null;
|
||||
|
||||
|
||||
public MultiLanguageSetting(List<ICLanguageSetting> data, ICConfigurationDescription cf) {
|
||||
items = data.toArray(new ICLanguageSetting[data.size()]);
|
||||
cfgd = cf;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#getLanguageId()
|
||||
*/
|
||||
@Override
|
||||
public String getLanguageId() {
|
||||
return items[0].getLanguageId(); // Assuming language is the same.
|
||||
}
|
||||
|
@ -48,6 +49,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#getSettingEntriesList(int)
|
||||
*/
|
||||
@Override
|
||||
public List<ICLanguageSettingEntry> getSettingEntriesList(int kind) {
|
||||
return Arrays.asList(getSettingEntries(kind));
|
||||
}
|
||||
|
@ -75,6 +77,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#getSupportedEntryKinds()
|
||||
*/
|
||||
@Override
|
||||
public int getSupportedEntryKinds() {
|
||||
int res = 0;
|
||||
for (ICLanguageSetting item : items)
|
||||
|
@ -85,11 +88,13 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setLanguageId(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setLanguageId(String id) {} // Do nothing
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @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) {
|
||||
for (ICLanguageSetting item : items)
|
||||
item.setSettingEntries(kind, entries);
|
||||
|
@ -98,6 +103,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setSettingEntries(int, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public void setSettingEntries(int kind, List<ICLanguageSettingEntry> entriesList) {
|
||||
for (ICLanguageSetting item : items)
|
||||
item.setSettingEntries(kind, entriesList);
|
||||
|
@ -106,6 +112,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setSourceContentTypeIds(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public void setSourceContentTypeIds(String[] ids) {
|
||||
for (ICLanguageSetting item : items)
|
||||
item.setSourceContentTypeIds(ids);
|
||||
|
@ -114,6 +121,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#setSourceExtensions(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public void setSourceExtensions(String[] exts) {
|
||||
for (ICLanguageSetting item : items)
|
||||
item.setSourceExtensions(exts);
|
||||
|
@ -122,6 +130,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.settings.model.ICLanguageSetting#supportsEntryKind(int)
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsEntryKind(int kind) {
|
||||
for (ICLanguageSetting item : items)
|
||||
if (item.supportsEntryKind(kind))
|
||||
|
@ -132,6 +141,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.settings.model.ICSettingObject#getConfiguration()
|
||||
*/
|
||||
@Override
|
||||
public ICConfigurationDescription getConfiguration() {
|
||||
if (DEBUG)
|
||||
System.out.println("Bad multi access: MultiLanguageSetting.getConfiguration()"); //$NON-NLS-1$
|
||||
|
@ -141,6 +151,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.settings.model.ICSettingObject#getId()
|
||||
*/
|
||||
@Override
|
||||
public String getId() { // IDs are different
|
||||
if (DEBUG)
|
||||
System.out.println("Bad multi access: MultiLanguageSetting.getId()"); //$NON-NLS-1$
|
||||
|
@ -150,6 +161,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.settings.model.ICSettingObject#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() { // names are proposed to be equal
|
||||
return items[0].getName();
|
||||
}
|
||||
|
@ -157,6 +169,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.settings.model.ICSettingObject#getParent()
|
||||
*/
|
||||
@Override
|
||||
public ICSettingContainer getParent() {
|
||||
if (DEBUG)
|
||||
System.out.println("Bad multi access: MultiLanguageSetting.getParent()"); //$NON-NLS-1$
|
||||
|
@ -166,6 +179,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.settings.model.ICSettingObject#getType()
|
||||
*/
|
||||
@Override
|
||||
public int getType() {
|
||||
int x = items[0].getType();
|
||||
for (ICLanguageSetting item : items)
|
||||
|
@ -177,6 +191,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.settings.model.ICSettingObject#isReadOnly()
|
||||
*/
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
for (int i=0; i<items.length; i++)
|
||||
if (! items[i].isReadOnly())
|
||||
|
@ -187,6 +202,7 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.settings.model.ICSettingObject#isValid()
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
for (int i=0; i<items.length; i++)
|
||||
if (! items[i].isValid())
|
||||
|
@ -199,19 +215,23 @@ public class MultiLanguageSetting extends MultiItemsHolder implements ICLanguage
|
|||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICLanguageSettingEntry[] getResolvedSettingEntries(int kind) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICLanguageSettingEntry[] getSettingEntries(int kind) {
|
||||
ICLanguageSettingEntry[][] ses = getSettingEntriesM(kind);
|
||||
return ses[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSourceContentTypeIds() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSourceExtensions() {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -25,24 +25,24 @@ import org.eclipse.core.runtime.IPath;
|
|||
public class CResourceDataContainer {
|
||||
private PathSettingsContainer fRcDataContainer;
|
||||
private boolean fIncludeCurrent;
|
||||
|
||||
|
||||
public CResourceDataContainer(PathSettingsContainer pathSettings, boolean includeCurrent){
|
||||
fRcDataContainer = pathSettings;
|
||||
fIncludeCurrent = includeCurrent;
|
||||
}
|
||||
|
||||
|
||||
public void changeCurrentPath(IPath path, boolean moveChildren){
|
||||
fRcDataContainer.setPath(path, moveChildren);
|
||||
}
|
||||
|
||||
|
||||
public IPath getCurrentPath(){
|
||||
return fRcDataContainer.getPath();
|
||||
}
|
||||
|
||||
|
||||
public CResourceData getCurrentResourceData(){
|
||||
return (CResourceData)fRcDataContainer.getValue();
|
||||
}
|
||||
|
||||
|
||||
public CResourceData getResourceData(IPath path, boolean exactPath) {
|
||||
PathSettingsContainer cr = fRcDataContainer.getChildContainer(path, false, exactPath);
|
||||
if(cr != null)
|
||||
|
@ -57,19 +57,20 @@ public class CResourceDataContainer {
|
|||
public CResourceData[] getResourceDatas(final int kind) {
|
||||
return getResourceDatas(kind, CResourceData.class);
|
||||
}
|
||||
|
||||
|
||||
public CResourceData[] getResourceDatas(int kind, Class<CResourceData> clazz){
|
||||
List<CResourceData> list = getRcDataList(kind);
|
||||
|
||||
CResourceData datas[] = (CResourceData[])Array.newInstance(clazz, list.size());
|
||||
|
||||
|
||||
return list.toArray(datas);
|
||||
}
|
||||
|
||||
|
||||
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(){
|
||||
|
||||
@Override
|
||||
public boolean visit(PathSettingsContainer container) {
|
||||
if(fIncludeCurrent || container != fRcDataContainer){
|
||||
CResourceData data = (CResourceData)container.getValue();
|
||||
|
@ -79,7 +80,7 @@ public class CResourceDataContainer {
|
|||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -93,16 +94,16 @@ public class CResourceDataContainer {
|
|||
public void removeResourceData(IPath path) {
|
||||
fRcDataContainer.removeChildContainer(path);
|
||||
}
|
||||
|
||||
|
||||
public void addResourceData(CResourceData data){
|
||||
PathSettingsContainer cr = fRcDataContainer.getChildContainer(data.getPath(), true, true);
|
||||
cr.setValue(data);
|
||||
}
|
||||
|
||||
|
||||
public CFileData getFileData(IPath path){
|
||||
return (CFileData)getResourceData(path, true, ICSettingBase.SETTING_FILE);
|
||||
}
|
||||
|
||||
|
||||
public CFolderData getFolderData(IPath path){
|
||||
return (CFolderData)getResourceData(path, true, ICSettingBase.SETTING_FOLDER);
|
||||
}
|
||||
|
|
|
@ -16,9 +16,9 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
|||
/**
|
||||
* A storage where stored data is organized by "kind".
|
||||
* In most cases kind is one of {@link ICLanguageSettingEntry}, i.e. include path, macro etc.
|
||||
*
|
||||
*
|
||||
* @param <T> - stored type
|
||||
*
|
||||
*
|
||||
* @see ICSettingEntry#INCLUDE_PATH
|
||||
* @see ICSettingEntry#INCLUDE_FILE
|
||||
* @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_OUPUT_PATH = 7;
|
||||
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_FILE
|
||||
| ICLanguageSettingEntry.MACRO
|
||||
|
@ -50,7 +50,7 @@ public class KindBasedStore<T> implements Cloneable {
|
|||
| ICLanguageSettingEntry.LIBRARY_PATH
|
||||
| ICLanguageSettingEntry.LIBRARY_FILE;
|
||||
|
||||
public static final int ORED_ALL_ENTRY_KINDS =
|
||||
public static final int ORED_ALL_ENTRY_KINDS =
|
||||
ICLanguageSettingEntry.INCLUDE_PATH
|
||||
| ICLanguageSettingEntry.INCLUDE_FILE
|
||||
| ICLanguageSettingEntry.MACRO
|
||||
|
@ -59,7 +59,7 @@ public class KindBasedStore<T> implements Cloneable {
|
|||
| ICLanguageSettingEntry.LIBRARY_FILE
|
||||
| ICLanguageSettingEntry.SOURCE_PATH
|
||||
| ICLanguageSettingEntry.OUTPUT_PATH;
|
||||
|
||||
|
||||
private static final int LANG_ENTRY_KINDS[] = new int[]{
|
||||
ICLanguageSettingEntry.INCLUDE_PATH,
|
||||
ICLanguageSettingEntry.INCLUDE_FILE,
|
||||
|
@ -81,7 +81,7 @@ public class KindBasedStore<T> implements Cloneable {
|
|||
};
|
||||
|
||||
// private static final int INEXISTENT_INDEX = -1;
|
||||
|
||||
|
||||
private Object[] fEntryStorage;
|
||||
|
||||
public KindBasedStore(){
|
||||
|
@ -162,11 +162,11 @@ public class KindBasedStore<T> implements Cloneable {
|
|||
fEntryStorage[index] = object;
|
||||
return old;
|
||||
}
|
||||
|
||||
|
||||
private class KindBasedInfo implements IKindBasedInfo<T> {
|
||||
int fIdex;
|
||||
int fKind;
|
||||
|
||||
|
||||
KindBasedInfo(int num, boolean isKind){
|
||||
if(isKind){
|
||||
fIdex = kindToIndex(num);
|
||||
|
@ -176,26 +176,29 @@ public class KindBasedStore<T> implements Cloneable {
|
|||
fKind = indexToKind(num);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public T getInfo() {
|
||||
@SuppressWarnings("unchecked")
|
||||
T info = (T)fEntryStorage[fIdex];
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getKind() {
|
||||
return fKind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T setInfo(T newInfo) {
|
||||
@SuppressWarnings("unchecked")
|
||||
T old = (T)fEntryStorage[fIdex];
|
||||
fEntryStorage[fIdex] = newInfo;
|
||||
return old;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public IKindBasedInfo<T>[] getContents(){
|
||||
@SuppressWarnings("unchecked")
|
||||
IKindBasedInfo<T> infos[] = new IKindBasedInfo[fEntryStorage.length];
|
||||
|
@ -204,11 +207,11 @@ public class KindBasedStore<T> implements Cloneable {
|
|||
}
|
||||
return infos;
|
||||
}
|
||||
|
||||
|
||||
public IKindBasedInfo<T> getInfo(int kind){
|
||||
return new KindBasedInfo(kind, true);
|
||||
}
|
||||
|
||||
|
||||
public void clear(){
|
||||
for(int i = 0; i < fEntryStorage.length; i++){
|
||||
fEntryStorage[i] = null;
|
||||
|
@ -226,6 +229,6 @@ public class KindBasedStore<T> implements Cloneable {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -990,6 +990,7 @@ public class PathEntryTranslator {
|
|||
final Set<PathEntryComposer> set = new HashSet<PathEntryComposer>();
|
||||
fStorage.accept(new IPathSettingsContainerVisitor() {
|
||||
|
||||
@Override
|
||||
public boolean visit(PathSettingsContainer container) {
|
||||
PathEntryCollector clr = (PathEntryCollector)container.getValue();
|
||||
clr.getLocalCollectedEntries(kind, list, set);
|
||||
|
@ -2033,6 +2034,7 @@ public class PathEntryTranslator {
|
|||
|
||||
final int kinds[] = KindBasedStore.getLanguageEntryKinds();
|
||||
rcDatas.accept(new IPathSettingsContainerVisitor() {
|
||||
@Override
|
||||
public boolean visit(PathSettingsContainer container) {
|
||||
CResourceData data = (CResourceData)container.getValue();
|
||||
if (data != null) {
|
||||
|
|
|
@ -181,6 +181,7 @@ public final class PathSettingsContainer {
|
|||
final List<PathSettingsContainer> list = new ArrayList<PathSettingsContainer>();
|
||||
accept(new IPathSettingsContainerVisitor(){
|
||||
|
||||
@Override
|
||||
public boolean visit(PathSettingsContainer container) {
|
||||
if(container != PathSettingsContainer.this || includeThis)
|
||||
list.add(container);
|
||||
|
@ -258,6 +259,7 @@ public final class PathSettingsContainer {
|
|||
final List<Object> list = new ArrayList<Object>();
|
||||
accept(new IPathSettingsContainerVisitor(){
|
||||
|
||||
@Override
|
||||
public boolean visit(PathSettingsContainer container) {
|
||||
if(container != PathSettingsContainer.this || includeThis)
|
||||
list.add(container.getValue());
|
||||
|
|
|
@ -17,13 +17,13 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.eclipse.cdt.core.model.CoreModelUtil;
|
||||
|
||||
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$
|
||||
|
||||
private Map<String, PathSettingsContainer> fChildrenMap;
|
||||
|
@ -38,7 +38,7 @@ public class PatternNameMap {
|
|||
StringCharArray(String string){
|
||||
fString = string;
|
||||
}
|
||||
|
||||
|
||||
char[] getCharArray(){
|
||||
if(fCharArray == null){
|
||||
fCharArray = fString.toCharArray();
|
||||
|
@ -50,10 +50,10 @@ public class PatternNameMap {
|
|||
public boolean equals(Object obj) {
|
||||
if(obj == this)
|
||||
return true;
|
||||
|
||||
|
||||
if(!(obj instanceof StringCharArray))
|
||||
return false;
|
||||
|
||||
|
||||
return fString.equals(((StringCharArray)obj).fString);
|
||||
}
|
||||
|
||||
|
@ -67,25 +67,28 @@ public class PatternNameMap {
|
|||
return fString;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class EmptyIterator implements Iterator<PathSettingsContainer>{
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathSettingsContainer next() {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private class ValuesCollection extends AbstractCollection<PathSettingsContainer> {
|
||||
|
||||
|
||||
private class Iter implements Iterator<PathSettingsContainer> {
|
||||
private Iterator<Entry<String, PathSettingsContainer>> fEntrySetIter;
|
||||
private Entry<String, PathSettingsContainer> fCur;
|
||||
|
@ -93,15 +96,18 @@ public class PatternNameMap {
|
|||
Iter (Iterator<Entry<String, PathSettingsContainer>> entryIter){
|
||||
this.fEntrySetIter = entryIter;
|
||||
}
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return fEntrySetIter.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathSettingsContainer next() {
|
||||
fCur = fEntrySetIter.next();
|
||||
return fCur.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
fEntrySetIter.remove();
|
||||
String name = fCur.getKey();
|
||||
|
@ -122,12 +128,12 @@ public class PatternNameMap {
|
|||
public int size() {
|
||||
return PatternNameMap.this.size();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clear(){
|
||||
PatternNameMap.this.clear();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o){
|
||||
return fChildrenMap != null ? fChildrenMap.containsValue(o) : false;
|
||||
|
@ -137,15 +143,15 @@ public class PatternNameMap {
|
|||
public /* PathSettingsContainer */ Object get(String name){
|
||||
return fChildrenMap != null ? fChildrenMap.get(name) : null;
|
||||
}
|
||||
|
||||
|
||||
public int size(){
|
||||
return fChildrenMap != null ? fChildrenMap.size() : 0;
|
||||
}
|
||||
|
||||
|
||||
public boolean isEmpty(){
|
||||
return fChildrenMap == null || fChildrenMap.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPatterns(){
|
||||
return fContainsDoubleStar || hasPatternsMap();
|
||||
}
|
||||
|
@ -157,7 +163,7 @@ public class PatternNameMap {
|
|||
public List<PathSettingsContainer> getValues(String name){
|
||||
if(fChildrenMap == null)
|
||||
return null;
|
||||
|
||||
|
||||
PathSettingsContainer val = fChildrenMap.get(name);
|
||||
if(hasPatternsMap()){
|
||||
List<PathSettingsContainer> list;
|
||||
|
@ -167,10 +173,10 @@ public class PatternNameMap {
|
|||
} else {
|
||||
list = null;
|
||||
}
|
||||
|
||||
|
||||
Map.Entry<PatternNameMap.StringCharArray,PathSettingsContainer> entry;
|
||||
StringCharArray strCA;
|
||||
char[] nameCharArray = name.toCharArray();
|
||||
char[] nameCharArray = name.toCharArray();
|
||||
for(Iterator<Map.Entry<PatternNameMap.StringCharArray,PathSettingsContainer>> iter = fPatternMap.entrySet().iterator(); iter.hasNext();){
|
||||
entry = iter.next();
|
||||
strCA = entry.getKey();
|
||||
|
@ -188,19 +194,19 @@ public class PatternNameMap {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public boolean containsDoubleStar(){
|
||||
return fContainsDoubleStar;
|
||||
}
|
||||
|
||||
|
||||
public /* PathSettingsContainer */ Object put(String name, /* PathSettingsContainer */Object value){
|
||||
return put(name, (PathSettingsContainer)value);
|
||||
}
|
||||
|
||||
|
||||
private PathSettingsContainer put(String name, PathSettingsContainer value){
|
||||
if(value == null)
|
||||
return (PathSettingsContainer)remove(name);
|
||||
|
||||
|
||||
PathSettingsContainer oldValue;
|
||||
if(fChildrenMap == null){
|
||||
fChildrenMap = new HashMap<String, PathSettingsContainer>();
|
||||
|
@ -208,22 +214,22 @@ public class PatternNameMap {
|
|||
} else {
|
||||
oldValue = fChildrenMap.get(name);
|
||||
}
|
||||
|
||||
|
||||
fChildrenMap.put(name, value);
|
||||
|
||||
|
||||
if(DOUBLE_STAR_PATTERN.equals(name)){
|
||||
fContainsDoubleStar = true;
|
||||
} else if(isPatternName(name)){
|
||||
StringCharArray strCA = new StringCharArray(name);
|
||||
if(fPatternMap == null)
|
||||
fPatternMap = new HashMap<StringCharArray, PathSettingsContainer>();
|
||||
|
||||
|
||||
fPatternMap.put(strCA, value);
|
||||
}
|
||||
|
||||
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
|
||||
public /* PathSettingsContainer */ Object remove(String name){
|
||||
if(fChildrenMap != null){
|
||||
PathSettingsContainer oldVal = fChildrenMap.remove(name);
|
||||
|
@ -240,7 +246,7 @@ public class PatternNameMap {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void removePattern(String name){
|
||||
if (fPatternMap != null){
|
||||
fPatternMap.remove(new StringCharArray(name));
|
||||
|
@ -248,7 +254,7 @@ public class PatternNameMap {
|
|||
fPatternMap = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static boolean hasSpecChars(String str){
|
||||
for(int i = 0; i < SPEC_CHARS.length; i++){
|
||||
if(str.indexOf(SPEC_CHARS[i]) != -1)
|
||||
|
@ -261,13 +267,13 @@ public class PatternNameMap {
|
|||
//TODO: check escape chars
|
||||
return hasSpecChars(str);
|
||||
}
|
||||
|
||||
|
||||
public void clear(){
|
||||
fChildrenMap = null;
|
||||
fPatternMap = null;
|
||||
fContainsDoubleStar = false;
|
||||
}
|
||||
|
||||
|
||||
public Collection<PathSettingsContainer> values(){
|
||||
if(fValues == null)
|
||||
fValues = new ValuesCollection();
|
||||
|
|
|
@ -50,7 +50,7 @@ public abstract class ResourceChangeHandlerBase implements IResourceChangeListen
|
|||
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();
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public abstract class ResourceChangeHandlerBase implements IResourceChangeListen
|
|||
fHandler = handler;
|
||||
// fRootDelta = rootDelta;
|
||||
}
|
||||
|
||||
|
||||
private IResource getResource(IPath path, IResource baseResource){
|
||||
switch(baseResource.getType()){
|
||||
case IResource.FILE:
|
||||
|
@ -80,24 +80,25 @@ public abstract class ResourceChangeHandlerBase implements IResourceChangeListen
|
|||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean checkInitHandleResourceMove(IResource fromRc, IResource toRc){
|
||||
if(fMoveMap.put(fromRc, toRc) == null){
|
||||
return fHandler.handleResourceMove(fromRc, toRc);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||
IResource dResource = delta.getResource();
|
||||
|
||||
|
||||
if(dResource.getType() == IResource.PROJECT && !shouldVisit((IProject)dResource))
|
||||
return false;
|
||||
|
||||
|
||||
boolean resume = true;
|
||||
boolean removed = false;
|
||||
|
||||
|
||||
switch (delta.getKind()) {
|
||||
case IResourceDelta.REMOVED:
|
||||
removed = true;
|
||||
|
@ -126,29 +127,30 @@ public abstract class ResourceChangeHandlerBase implements IResourceChangeListen
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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)
|
||||
*
|
||||
*
|
||||
* Handle the renaming and deletion of project resources
|
||||
* This is necessary in order to update ResourceConfigurations and AdditionalInputs
|
||||
*
|
||||
*
|
||||
* @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
|
||||
*/
|
||||
@Override
|
||||
public void resourceChanged(IResourceChangeEvent event) {
|
||||
if (event.getSource() instanceof IWorkspace) {
|
||||
IResourceMoveHandler handler = createResourceMoveHandler(event);
|
||||
doHandleResourceMove(event, handler);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected boolean shouldVisit(IProject project){
|
||||
try {
|
||||
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) {
|
||||
doHandleResourceMove(event, handler);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @since 5.1
|
||||
*/
|
||||
|
@ -194,9 +196,9 @@ public abstract class ResourceChangeHandlerBase implements IResourceChangeListen
|
|||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
handler.done();
|
||||
}
|
||||
|
||||
|
||||
protected abstract IResourceMoveHandler createResourceMoveHandler(IResourceChangeEvent event);
|
||||
}
|
||||
|
|
|
@ -58,14 +58,14 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
fElement = element;
|
||||
fParent = parent;
|
||||
fParentRefAlowed = alowReferencingParent;
|
||||
|
||||
|
||||
if(attributeFilters != null && attributeFilters.length != 0)
|
||||
fAttributeFilters = attributeFilters.clone();
|
||||
|
||||
|
||||
if(childFilters != null && childFilters.length != 0)
|
||||
fChildFilters = childFilters.clone();
|
||||
}
|
||||
|
||||
|
||||
// public String[] getAttributeFilters(){
|
||||
// if(fAttributeFilters != null)
|
||||
// return (String[])fAttributeFilters.clone();
|
||||
|
@ -77,7 +77,7 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
// return (String[])fChildFilters.clone();
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public boolean isParentRefAlowed(){
|
||||
// return fParentRefAlowed;
|
||||
// }
|
||||
|
@ -85,7 +85,7 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
private void createChildren(){
|
||||
if(fChildrenCreated)
|
||||
return;
|
||||
|
||||
|
||||
fChildrenCreated = true;
|
||||
NodeList list = fElement.getChildNodes();
|
||||
int size = list.getLength();
|
||||
|
@ -97,16 +97,16 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private XmlStorageElement createAddChild(Element element,
|
||||
boolean alowReferencingParent,
|
||||
String[] attributeFilters,
|
||||
String[] childFilters){
|
||||
XmlStorageElement child = createChild(element, alowReferencingParent, attributeFilters, childFilters);
|
||||
fChildList.add(child);
|
||||
return child;
|
||||
return child;
|
||||
}
|
||||
|
||||
|
||||
protected XmlStorageElement createChild(Element element,
|
||||
boolean alowReferencingParent,
|
||||
String[] attributeFilters,
|
||||
|
@ -114,6 +114,7 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
return new XmlStorageElement(element, this, alowReferencingParent, attributeFilters, childFilters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICStorageElement[] getChildren() {
|
||||
return getChildren(XmlStorageElement.class);
|
||||
}
|
||||
|
@ -136,16 +137,18 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
return fChildList.toArray(children);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICStorageElement getParent() {
|
||||
return fParentRefAlowed ? fParent : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttribute(String name) {
|
||||
if(isPropertyAlowed(name) && fElement.hasAttribute(name))
|
||||
return fElement.getAttribute(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private boolean isPropertyAlowed(String name){
|
||||
if(fAttributeFilters != null){
|
||||
return checkString(name, fAttributeFilters);
|
||||
|
@ -173,15 +176,16 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
// protected void childRemoved(ICStorageElement child) {
|
||||
// fChildList.remove(child);
|
||||
// }
|
||||
|
||||
|
||||
protected void removed(){
|
||||
// fElement.getParentNode().removeChild(fElement);
|
||||
fElement = null;
|
||||
// if(fParent != null)
|
||||
// ((XmlStorageElement)fParent).childRemoved(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void removeChild(ICStorageElement el) {
|
||||
if(el instanceof XmlStorageElement){
|
||||
ICStorageElement[] children = getChildren();
|
||||
|
@ -202,19 +206,22 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String name) {
|
||||
if(isPropertyAlowed(name))
|
||||
fElement.removeAttribute(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, String value) {
|
||||
if(isPropertyAlowed(name))
|
||||
fElement.setAttribute(name, value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clear(){
|
||||
createChildren();
|
||||
|
||||
|
@ -222,14 +229,14 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
for(int i = 0; i < children.length; i++){
|
||||
removeChild(children[i]);
|
||||
}
|
||||
|
||||
|
||||
NamedNodeMap map = fElement.getAttributes();
|
||||
for(int i = 0; i < map.getLength(); i++){
|
||||
Node attr = map.item(i);
|
||||
if(isPropertyAlowed(attr.getNodeName()))
|
||||
map.removeNamedItem(attr.getNodeName());
|
||||
}
|
||||
|
||||
|
||||
NodeList list = fElement.getChildNodes();
|
||||
for(int i = 0; i < list.getLength(); i++){
|
||||
Node node = list.item(i);
|
||||
|
@ -237,8 +244,8 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
fElement.removeChild(node);
|
||||
}
|
||||
}
|
||||
|
||||
public ICStorageElement createChild(String name,
|
||||
|
||||
public ICStorageElement createChild(String name,
|
||||
boolean alowReferencingParent,
|
||||
String[] attributeFilters,
|
||||
String[] childFilters) {
|
||||
|
@ -249,14 +256,17 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
return createAddChild(childElement, alowReferencingParent, attributeFilters, childFilters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return fElement.getNodeName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICStorageElement createChild(String name) {
|
||||
return createChild(name, true, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
Text text = getTextChild();
|
||||
if(text != null)
|
||||
|
@ -264,6 +274,7 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
Text text = getTextChild();
|
||||
if(value != null){
|
||||
|
@ -279,7 +290,7 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Text getTextChild(){
|
||||
NodeList nodes = fElement.getChildNodes();
|
||||
Text text = null;
|
||||
|
@ -293,16 +304,17 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICStorageElement importChild(ICStorageElement el) throws UnsupportedOperationException {
|
||||
return addChild(el, true, null, null);
|
||||
}
|
||||
|
||||
public ICStorageElement addChild(ICStorageElement el,
|
||||
public ICStorageElement addChild(ICStorageElement el,
|
||||
boolean alowReferencingParent,
|
||||
String[] attributeFilters,
|
||||
String[] childFilters) throws UnsupportedOperationException {
|
||||
|
||||
|
||||
if(!isChildAlowed(el.getName()))
|
||||
return null;
|
||||
|
||||
|
@ -316,14 +328,14 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
} else {
|
||||
xmlEl = (Element)xmlEl.cloneNode(true);
|
||||
}
|
||||
|
||||
|
||||
xmlEl = (Element)fElement.appendChild(xmlEl);
|
||||
return createAddChild(xmlEl, alowReferencingParent, attributeFilters, childFilters);
|
||||
} else {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String[] getAttributeFilters(){
|
||||
if(fAttributeFilters != null)
|
||||
return fAttributeFilters.clone();
|
||||
|
@ -339,20 +351,20 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
public boolean isParentRefAlowed(){
|
||||
return fParentRefAlowed;
|
||||
}
|
||||
|
||||
|
||||
public boolean matches(ICStorageElement el){
|
||||
if(!getName().equals(el.getName()))
|
||||
return false;
|
||||
|
||||
|
||||
if (!valuesMatch(getValue(), el.getValue()))
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
String[] attrs = getAttributeNames();
|
||||
String[] otherAttrs = el.getAttributeNames();
|
||||
if(attrs.length != otherAttrs.length)
|
||||
return false;
|
||||
|
||||
|
||||
if(attrs.length != 0){
|
||||
Set<String> set = new HashSet<String>(Arrays.asList(attrs));
|
||||
set.removeAll(Arrays.asList(otherAttrs));
|
||||
|
@ -365,21 +377,21 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
XmlStorageElement[] children = (XmlStorageElement[])getChildren();
|
||||
ICStorageElement[] otherChildren = el.getChildren();
|
||||
|
||||
|
||||
if(children.length != otherChildren.length)
|
||||
return false;
|
||||
|
||||
|
||||
if(children.length != 0){
|
||||
for(int i = 0; i < children.length; i++){
|
||||
if(!children[i].matches(otherChildren[i]))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -393,6 +405,7 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAttributeNames() {
|
||||
NamedNodeMap nodeMap = fElement.getAttributes();
|
||||
int length = nodeMap.getLength();
|
||||
|
@ -409,6 +422,7 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
/**
|
||||
* @since 5.1
|
||||
*/
|
||||
@Override
|
||||
public ICStorageElement createCopy() throws UnsupportedOperationException, CoreException {
|
||||
// todo Auto-generated method stub
|
||||
return null;
|
||||
|
@ -417,6 +431,7 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
/**
|
||||
* @since 5.1
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(ICStorageElement other) {
|
||||
// todo Auto-generated method stub
|
||||
return false;
|
||||
|
@ -425,6 +440,7 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
/**
|
||||
* @since 5.1
|
||||
*/
|
||||
@Override
|
||||
public ICStorageElement[] getChildrenByName(String name) {
|
||||
// todo Auto-generated method stub
|
||||
return null;
|
||||
|
@ -433,6 +449,7 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
/**
|
||||
* @since 5.1
|
||||
*/
|
||||
@Override
|
||||
public boolean hasAttribute(String name) {
|
||||
// todo Auto-generated method stub
|
||||
return false;
|
||||
|
@ -441,6 +458,7 @@ public class XmlStorageElement implements ICStorageElement {
|
|||
/**
|
||||
* @since 5.1
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildren() {
|
||||
// todo Auto-generated method stub
|
||||
return false;
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
|
||||
* and is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
*
|
||||
* Contributors:
|
||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class ASTCache {
|
||||
|
@ -43,7 +43,7 @@ public class ASTCache {
|
|||
public static int PARSE_MODE_FULL = ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT
|
||||
| ITranslationUnit.AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS
|
||||
| ITranslationUnit.AST_PARSE_INACTIVE_CODE;
|
||||
|
||||
|
||||
/** Fast parse mode (use PDOM) */
|
||||
public static int PARSE_MODE_FAST = ITranslationUnit.AST_SKIP_ALL_HEADERS
|
||||
| ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT
|
||||
|
@ -52,28 +52,28 @@ public class ASTCache {
|
|||
|
||||
/**
|
||||
* Do something with an AST.
|
||||
*
|
||||
*
|
||||
* @see #runOnAST(ILanguage, IASTTranslationUnit)
|
||||
*/
|
||||
public static interface ASTRunnable {
|
||||
/**
|
||||
* Do something with the given AST.
|
||||
*
|
||||
*
|
||||
* @param lang the language with which the AST has been created.
|
||||
* @param ast the translation unit AST, may be <code>null</code>
|
||||
* @return a status object
|
||||
*/
|
||||
IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException;
|
||||
}
|
||||
|
||||
|
||||
private final int fParseMode;
|
||||
private final Object fCacheMutex= new Object();
|
||||
|
||||
|
||||
/** The active translation unit for which to cache the AST */
|
||||
private ITranslationUnit fActiveTU;
|
||||
/** The cached AST if any */
|
||||
private IASTTranslationUnit fAST;
|
||||
/**
|
||||
/**
|
||||
* The timestamp of the last index write access at the time
|
||||
* the AST got cached. A cached AST becomes invalid on any index
|
||||
* write access afterwards.
|
||||
|
@ -107,11 +107,11 @@ public class ASTCache {
|
|||
IProgressMonitor progressMonitor) {
|
||||
if (tUnit == null)
|
||||
return null;
|
||||
|
||||
|
||||
while (true) {
|
||||
if (progressMonitor != null && progressMonitor.isCanceled())
|
||||
return null;
|
||||
|
||||
|
||||
final boolean isActiveElement;
|
||||
synchronized (fCacheMutex) {
|
||||
isActiveElement= tUnit.equals(fActiveTU);
|
||||
|
@ -132,7 +132,7 @@ public class ASTCache {
|
|||
if (!wait) {
|
||||
// no AST, no wait - we are done
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -141,12 +141,12 @@ public class ASTCache {
|
|||
try {
|
||||
// Wait for AST
|
||||
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();
|
||||
// Check whether active element is still valid
|
||||
if (fAST != null) {
|
||||
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;
|
||||
}
|
||||
// try again
|
||||
|
@ -158,20 +158,20 @@ public class ASTCache {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isActiveElement)
|
||||
aboutToBeReconciled(tUnit);
|
||||
|
||||
|
||||
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;
|
||||
try {
|
||||
ast= createAST(tUnit, index, progressMonitor);
|
||||
if (progressMonitor != null && progressMonitor.isCanceled())
|
||||
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 {
|
||||
if (isActiveElement) {
|
||||
if (fAST != null) {
|
||||
|
@ -191,7 +191,7 @@ public class ASTCache {
|
|||
* Executes {@link ASTRunnable#runOnAST(ILanguage, IASTTranslationUnit)} with the AST
|
||||
* provided by this cache for the given translation unit. Handles acquiring
|
||||
* and releasing the index read-lock for the client.
|
||||
*
|
||||
*
|
||||
* @param tUnit
|
||||
* the translation unit
|
||||
* @param wait
|
||||
|
@ -212,7 +212,7 @@ public class ASTCache {
|
|||
} catch (InterruptedException e) {
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
IASTTranslationUnit ast= acquireSharedAST(tUnit, index, wait, monitor);
|
||||
ILanguage lang= (tUnit instanceof TranslationUnit) ? ((TranslationUnit) tUnit).getLanguageOfContext() : tUnit.getLanguage();
|
||||
|
@ -286,12 +286,12 @@ public class ASTCache {
|
|||
assert Thread.holdsLock(fCacheMutex);
|
||||
if (fActiveTU != null && !fActiveTU.equals(tUnit)) {
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
disposeAST();
|
||||
|
@ -310,10 +310,10 @@ public class ASTCache {
|
|||
synchronized (fCacheMutex) {
|
||||
if (fAST == null)
|
||||
return;
|
||||
|
||||
|
||||
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;
|
||||
cache(null, null);
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ public class ASTCache {
|
|||
|
||||
/**
|
||||
* Creates a new translation unit 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 progressMonitor a progress monitor, may be <code>null</code>
|
||||
|
@ -331,9 +331,10 @@ public class ASTCache {
|
|||
if (progressMonitor != null && progressMonitor.isCanceled())
|
||||
return null;
|
||||
|
||||
final IASTTranslationUnit root[]= new IASTTranslationUnit[1];
|
||||
|
||||
final IASTTranslationUnit root[]= new IASTTranslationUnit[1];
|
||||
|
||||
SafeRunner.run(new ISafeRunnable() {
|
||||
@Override
|
||||
public void run() throws CoreException {
|
||||
try {
|
||||
if (progressMonitor != null && progressMonitor.isCanceled()) {
|
||||
|
@ -345,18 +346,19 @@ public class ASTCache {
|
|||
root[0]= null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
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$
|
||||
CCorePlugin.getDefault().getLog().log(status);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return root[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the given translation unit as active element to cache an AST for.
|
||||
*
|
||||
*
|
||||
* @param tUnit the translation unit
|
||||
*/
|
||||
public void setActiveElement(ITranslationUnit tUnit) {
|
||||
|
@ -369,12 +371,12 @@ public class ASTCache {
|
|||
cache(null, tUnit);
|
||||
}
|
||||
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.
|
||||
*
|
||||
*
|
||||
* @param tUnit the 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.
|
||||
*
|
||||
* @param tUnit the translation unit
|
||||
|
@ -393,15 +395,15 @@ public class ASTCache {
|
|||
public void aboutToBeReconciled(ITranslationUnit tUnit) {
|
||||
if (tUnit == null)
|
||||
return;
|
||||
|
||||
|
||||
synchronized (fCacheMutex) {
|
||||
if (fActiveTU == null || !fActiveTU.equals(tUnit)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
cache(null, tUnit);
|
||||
}
|
||||
|
@ -409,7 +411,7 @@ public class ASTCache {
|
|||
|
||||
/**
|
||||
* Informs that reconciling of the AST of the given translation unit has finished.
|
||||
*
|
||||
*
|
||||
* @param ast the translation unit AST
|
||||
* @param tUnit the translation unit
|
||||
*/
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
|
||||
|
@ -42,6 +42,7 @@ public class Archive extends Openable implements IArchive {
|
|||
binaryArchive = ar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinary[] getBinaries() throws CModelException {
|
||||
ICElement[] e = getChildren();
|
||||
IBinary[] b = new IBinary[e.length];
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
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$
|
||||
}
|
||||
|
||||
@Override
|
||||
public IArchive[] getArchives() throws CModelException {
|
||||
((ArchiveContainerInfo)getElementInfo()).sync();
|
||||
ICElement[] e = getChildren();
|
||||
|
|
|
@ -26,7 +26,7 @@ public class AsmLabel extends SourceManipulation implements IAsmLabel, IParent {
|
|||
|
||||
/**
|
||||
* Create a new assembly label.
|
||||
*
|
||||
*
|
||||
* @param parent the parent element (must be ITranslationUnit)
|
||||
* @param name the name of the label
|
||||
* @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()
|
||||
*/
|
||||
@Override
|
||||
public final boolean isGlobal() {
|
||||
return fIsGlobal;
|
||||
}
|
||||
|
@ -55,7 +56,7 @@ public class AsmLabel extends SourceManipulation implements IAsmLabel, IParent {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static boolean equals(AsmLabel lhs, AsmLabel rhs) {
|
||||
if (CElement.equals(lhs, rhs)) {
|
||||
return lhs.fIndex == rhs.fIndex && lhs.fIsGlobal == rhs.fIsGlobal;
|
||||
|
|
|
@ -22,14 +22,14 @@ import org.eclipse.cdt.core.parser.IToken;
|
|||
import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
|
||||
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.Token;
|
||||
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.
|
||||
* Recognizes preprocessor directives (#include and #define)
|
||||
* and labels.
|
||||
*
|
||||
*
|
||||
* @see AssemblyLanguage
|
||||
* @since 5.0
|
||||
*/
|
||||
|
@ -41,8 +41,10 @@ public class AsmModelBuilder implements IContributedModelBuilder {
|
|||
}
|
||||
|
||||
private static final class LexerLog implements ILexerLog {
|
||||
@Override
|
||||
public void handleComment(boolean isBlockComment, int offset, int endOffset) {
|
||||
}
|
||||
@Override
|
||||
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;
|
||||
|
||||
|
||||
static {
|
||||
fgDirectives= new HashMap<String, AsmDirective>();
|
||||
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("word", AsmDirective.DATA); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
private TranslationUnit fTranslationUnit;
|
||||
private char fLineSeparatorChar;
|
||||
private Map<String, Counter> fGlobals;
|
||||
private Map<String, Counter> fLabels;
|
||||
|
||||
|
||||
private int fLastLabelEndOffset;
|
||||
private AsmLabel fLastGlobalLabel;
|
||||
private SourceManipulation fLastLabel;
|
||||
|
@ -76,7 +78,7 @@ public class AsmModelBuilder implements IContributedModelBuilder {
|
|||
|
||||
/**
|
||||
* Creates a model builder for the given assembly translation unit.
|
||||
*
|
||||
*
|
||||
* @param tu the translation unit
|
||||
*/
|
||||
public AsmModelBuilder(ITranslationUnit tu) {
|
||||
|
@ -85,7 +87,7 @@ public class AsmModelBuilder implements IContributedModelBuilder {
|
|||
|
||||
/**
|
||||
* Configure the line separator character (in addition to normal newlines).
|
||||
*
|
||||
*
|
||||
* @param lineSeparatorChar
|
||||
*/
|
||||
public void setLineSeparatorCharacter(char lineSeparatorChar) {
|
||||
|
@ -95,6 +97,7 @@ public class AsmModelBuilder implements IContributedModelBuilder {
|
|||
/*
|
||||
* @see org.eclipse.cdt.core.model.IContributedModelBuilder#parse(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void parse(boolean quickParseMode) throws Exception {
|
||||
char[] source = fTranslationUnit.getContents();
|
||||
if (source == null) {
|
||||
|
@ -111,7 +114,7 @@ public class AsmModelBuilder implements IContributedModelBuilder {
|
|||
|
||||
/**
|
||||
* Build the model.
|
||||
*
|
||||
*
|
||||
* @param source
|
||||
* @throws CModelException
|
||||
*/
|
||||
|
@ -124,7 +127,7 @@ public class AsmModelBuilder implements IContributedModelBuilder {
|
|||
|
||||
final LexerOptions lexerOptions= new LexerOptions();
|
||||
fLexer= new Lexer(source, lexerOptions, new LexerLog(), null);
|
||||
|
||||
|
||||
// if true the next token is the first on a (logical) line
|
||||
boolean firstTokenOnLine= true;
|
||||
// next token can be an instruction or a label
|
||||
|
@ -207,7 +210,7 @@ public class AsmModelBuilder implements IContributedModelBuilder {
|
|||
fixupLastGlobalLabel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*
|
||||
* @throws CModelException
|
||||
*
|
||||
* @throws CModelException
|
||||
*/
|
||||
private void fixupLastGlobalLabel() throws CModelException {
|
||||
if (fLastLabel != null && fLastLabel != fLastGlobalLabel) {
|
||||
|
@ -327,8 +330,8 @@ public class AsmModelBuilder implements IContributedModelBuilder {
|
|||
|
||||
/**
|
||||
* Set the body position of the last label.
|
||||
*
|
||||
* @throws CModelException
|
||||
*
|
||||
* @throws CModelException
|
||||
*/
|
||||
private void fixupLastLabel() throws CModelException {
|
||||
if (fLastLabelEndOffset > 0) {
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -22,13 +22,13 @@ import java.util.Map;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
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.IBinaryFile;
|
||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryShared;
|
||||
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.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
|
@ -58,7 +58,7 @@ public class Binary extends Openable implements IBinary {
|
|||
private long longBSS;
|
||||
private String endian;
|
||||
private String soname;
|
||||
|
||||
|
||||
private long fLastModification;
|
||||
|
||||
private IBinaryObject binaryObject;
|
||||
|
@ -84,22 +84,27 @@ public class Binary extends Openable implements IBinary {
|
|||
showInBinaryContainer= determineShowInBinaryContainer(bin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSharedLib() {
|
||||
return getType() == IBinaryFile.SHARED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExecutable() {
|
||||
return getType() == IBinaryFile.EXECUTABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isObject() {
|
||||
return getType() == IBinaryFile.OBJECT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCore() {
|
||||
return getType() == IBinaryFile.CORE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDebug() {
|
||||
if (isObject() || isExecutable() || isSharedLib()) {
|
||||
if (hasDebug == null || hasChanged()) {
|
||||
|
@ -112,6 +117,7 @@ public class Binary extends Openable implements IBinary {
|
|||
return Boolean.valueOf(hasDebug).booleanValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCPU() {
|
||||
if (isObject() || isExecutable() || isSharedLib() || isCore()) {
|
||||
if (cpu == null || hasChanged()) {
|
||||
|
@ -122,6 +128,7 @@ public class Binary extends Openable implements IBinary {
|
|||
return (cpu == null ? "" : cpu); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getNeededSharedLibs() {
|
||||
if (isExecutable() || isSharedLib()) {
|
||||
if (needed == null || hasChanged()) {
|
||||
|
@ -134,6 +141,7 @@ public class Binary extends Openable implements IBinary {
|
|||
return (needed == null ? new String[0] : needed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getText() {
|
||||
if (isObject() || isExecutable() || isSharedLib()) {
|
||||
if (longText == -1 || hasChanged()) {
|
||||
|
@ -146,6 +154,7 @@ public class Binary extends Openable implements IBinary {
|
|||
return longText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getData() {
|
||||
if (isObject() || isExecutable() || isSharedLib()) {
|
||||
if (longData == -1 || hasChanged()) {
|
||||
|
@ -158,6 +167,7 @@ public class Binary extends Openable implements IBinary {
|
|||
return longData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBSS() {
|
||||
if (isObject() || isExecutable() || isSharedLib()) {
|
||||
if (longBSS == -1 || hasChanged()) {
|
||||
|
@ -170,6 +180,7 @@ public class Binary extends Openable implements IBinary {
|
|||
return longBSS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSoname() {
|
||||
if (isSharedLib()) {
|
||||
if (soname == null || hasChanged()) {
|
||||
|
@ -182,6 +193,7 @@ public class Binary extends Openable implements IBinary {
|
|||
return (soname == null ? "" : soname); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLittleEndian() {
|
||||
if (isObject() || isExecutable() || isSharedLib() || isCore()) {
|
||||
if (endian == null || hasChanged()) {
|
||||
|
@ -290,7 +302,7 @@ public class Binary extends Openable implements IBinary {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
|
@ -311,34 +323,34 @@ public class Binary extends Openable implements IBinary {
|
|||
ISourceFinder srcFinder = (ISourceFinder) getAdapter(ISourceFinder.class);
|
||||
try {
|
||||
for (String filename : sourceFiles) {
|
||||
|
||||
|
||||
// Find the file locally
|
||||
if (srcFinder != null) {
|
||||
String localPath = srcFinder.toLocalPath(filename);
|
||||
if (localPath != null) {
|
||||
filename = localPath;
|
||||
filename = localPath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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.
|
||||
// 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 file = new File(filename);
|
||||
|
||||
|
||||
// Create a translation unit for this file and add it as a child of the binary
|
||||
String id = CoreModel.getRegistedContentTypeId(getCProject().getProject(), file.getName());
|
||||
if (id == null) {
|
||||
// Don't add files we can't get an ID for.
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// See if this source file is already in the project.
|
||||
// We check this to determine if we should create a TranslationUnit or ExternalTranslationUnit
|
||||
IFile wkspFile = null;
|
||||
if (file.isAbsolute()) {
|
||||
IFile[] filesInWP = ResourceLookup.findFilesForLocation(new Path(filename));
|
||||
|
||||
|
||||
for (IFile element : filesInWP) {
|
||||
if (element.isAccessible()) {
|
||||
wkspFile = element;
|
||||
|
@ -346,7 +358,7 @@ public class Binary extends Openable implements IBinary {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TranslationUnit tu;
|
||||
if (wkspFile != null)
|
||||
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);
|
||||
}
|
||||
else {
|
||||
tu = new ExternalTranslationUnit(this, URIUtil.toURI(filename, true), id);
|
||||
tu = new ExternalTranslationUnit(this, URIUtil.toURI(filename, true), id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! info.includesChild(tu))
|
||||
info.addChild(tu);
|
||||
info.addChild(tu);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -376,11 +388,11 @@ public class Binary extends Openable implements IBinary {
|
|||
srcFinder.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void addFunction(OpenableInfo info, ISymbol symbol, Map<IPath, BinaryModule> hash) throws CModelException {
|
||||
IPath filename= symbol.getFilename();
|
||||
BinaryFunction function = null;
|
||||
|
@ -431,7 +443,7 @@ public class Binary extends Openable implements IBinary {
|
|||
variable.setLines(symbol.getStartLine(), symbol.getEndLine());
|
||||
info.addChild(variable);
|
||||
}
|
||||
|
||||
|
||||
//if (variable != null) {
|
||||
// if (!external) {
|
||||
// variable.getVariableInfo().setAccessControl(IConstants.AccStatic);
|
||||
|
@ -441,7 +453,7 @@ public class Binary extends Openable implements IBinary {
|
|||
|
||||
/**
|
||||
* @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
|
||||
* 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 {
|
||||
|
||||
// create buffer - translation units only use default buffer factory
|
||||
BufferManager bufManager = getBufferManager();
|
||||
BufferManager bufManager = getBufferManager();
|
||||
IBuffer buffer = getBufferFactory().createBuffer(this);
|
||||
if (buffer == null)
|
||||
if (buffer == null)
|
||||
return null;
|
||||
|
||||
|
||||
// set the buffer source
|
||||
if (buffer.getCharacters() == null){
|
||||
IBinaryObject bin = getBinaryObject();
|
||||
|
@ -496,13 +508,13 @@ public class Binary extends Openable implements IBinary {
|
|||
|
||||
// add buffer to buffer cache
|
||||
bufManager.addBuffer(buffer);
|
||||
|
||||
|
||||
// listen to buffer changes
|
||||
buffer.addBufferChangedListener(this);
|
||||
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.model.Openable#hasBuffer()
|
||||
*/
|
||||
|
@ -534,6 +546,7 @@ public class Binary extends Openable implements IBinary {
|
|||
super.closing(info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInBinaryContainer() {
|
||||
return showInBinaryContainer;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -38,6 +38,7 @@ public class BinaryContainer extends Openable implements IBinaryContainer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinary[] getBinaries() throws CModelException {
|
||||
sync();
|
||||
ICElement[] e = getChildren();
|
||||
|
|
|
@ -50,6 +50,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
|
|||
/* (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)
|
||||
*/
|
||||
@Override
|
||||
public void copy(ICElement container, ICElement sibling, String rename, boolean replace, IProgressMonitor monitor)
|
||||
throws CModelException {
|
||||
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this));
|
||||
|
@ -58,6 +59,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ISourceManipulation#delete(boolean, org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
public void delete(boolean force, IProgressMonitor monitor) throws CModelException {
|
||||
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this));
|
||||
}
|
||||
|
@ -65,6 +67,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
|
|||
/* (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)
|
||||
*/
|
||||
@Override
|
||||
public void move(ICElement container, ICElement sibling, String rename, boolean replace, IProgressMonitor monitor)
|
||||
throws CModelException {
|
||||
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this));
|
||||
|
@ -73,6 +76,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
|
|||
/* (non-Javadoc)
|
||||
* @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 {
|
||||
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this));
|
||||
}
|
||||
|
@ -80,6 +84,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ISourceReference#getSource()
|
||||
*/
|
||||
@Override
|
||||
public String getSource() throws CModelException {
|
||||
ITranslationUnit tu = getTranslationUnit();
|
||||
if (tu != null) {
|
||||
|
@ -100,11 +105,12 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ISourceReference#getSourceRange()
|
||||
*/
|
||||
@Override
|
||||
public ISourceRange getSourceRange() throws CModelException {
|
||||
return new SourceRange(getStartPos(),
|
||||
getLength(),
|
||||
getIdStartPos(),
|
||||
getIdLength(),
|
||||
getIdLength(),
|
||||
getStartLine(),
|
||||
getEndLine());
|
||||
}
|
||||
|
@ -112,6 +118,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ISourceReference#getTranslationUnit()
|
||||
*/
|
||||
@Override
|
||||
public ITranslationUnit getTranslationUnit() {
|
||||
if (fSourceTU == null) {
|
||||
ITranslationUnit tu = null;
|
||||
|
@ -171,6 +178,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IBinaryElement#getAddress()
|
||||
*/
|
||||
@Override
|
||||
public IAddress getAddress() throws CModelException {
|
||||
return addr;
|
||||
}
|
||||
|
@ -212,6 +220,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IBinaryElement#getBinary()
|
||||
*/
|
||||
@Override
|
||||
public IBinary getBinary() {
|
||||
ICElement current = this;
|
||||
do {
|
||||
|
@ -245,10 +254,12 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIndex() {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IFunctionDeclaration#getExceptions()
|
||||
*/
|
||||
@Override
|
||||
public String[] getExceptions() {
|
||||
return new String[0];
|
||||
}
|
||||
|
@ -33,6 +34,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IFunctionDeclaration#getNumberOfParameters()
|
||||
*/
|
||||
@Override
|
||||
public int getNumberOfParameters() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
|
@ -41,6 +43,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IFunctionDeclaration#getParameterInitializer(int)
|
||||
*/
|
||||
@Override
|
||||
public String getParameterInitializer(int pos) {
|
||||
// TODO Auto-generated method stub
|
||||
return new String();
|
||||
|
@ -49,6 +52,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IFunctionDeclaration#getParameterTypes()
|
||||
*/
|
||||
@Override
|
||||
public String[] getParameterTypes() {
|
||||
// TODO Auto-generated method stub
|
||||
return new String[0];
|
||||
|
@ -57,6 +61,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IFunctionDeclaration#getReturnType()
|
||||
*/
|
||||
@Override
|
||||
public String getReturnType() {
|
||||
// TODO Auto-generated method stub
|
||||
return new String();
|
||||
|
@ -65,6 +70,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IFunctionDeclaration#getSignature()
|
||||
*/
|
||||
@Override
|
||||
public String getSignature() {
|
||||
return getElementName();
|
||||
}
|
||||
|
@ -72,6 +78,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IDeclaration#isStatic()
|
||||
*/
|
||||
@Override
|
||||
public boolean isStatic() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
|
@ -80,6 +87,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IDeclaration#isConst()
|
||||
*/
|
||||
@Override
|
||||
public boolean isConst() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
|
@ -88,6 +96,7 @@ public class BinaryFunction extends BinaryElement implements IBinaryFunction {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IDeclaration#isVolatile()
|
||||
*/
|
||||
@Override
|
||||
public boolean isVolatile() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
|
|
|
@ -41,6 +41,7 @@ public class BinaryModule extends Parent implements IBinaryModule {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IBinaryModule#getBinaryElements()
|
||||
*/
|
||||
@Override
|
||||
public IBinaryElement[] getBinaryElements() throws CModelException {
|
||||
ICElement[] e = getChildren();
|
||||
IBinaryElement[] b = new IBinaryElement[e.length];
|
||||
|
@ -51,13 +52,15 @@ public class BinaryModule extends Parent implements IBinaryModule {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IBinaryElement#getAddress()
|
||||
*/
|
||||
@Override
|
||||
public IAddress getAddress() throws CModelException {
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IBinaryElement#getBinary()
|
||||
*/
|
||||
@Override
|
||||
public IBinary getBinary() {
|
||||
return (IBinary)getParent();
|
||||
}
|
||||
|
|
|
@ -80,9 +80,9 @@ public class BinaryRunner {
|
|||
}
|
||||
addDelta(cdelta);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private final ICProject cproject;
|
||||
private final Job runnerJob; // final fields don't need synchronization
|
||||
private IOutputEntry[] entries = new IOutputEntry[0];
|
||||
|
@ -182,6 +182,7 @@ public class BinaryRunner {
|
|||
textContentType = mgr.getContentType("org.eclipse.core.runtime.text"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(IResourceProxy proxy) throws CoreException {
|
||||
if (vMonitor.isCanceled()) {
|
||||
return false;
|
||||
|
@ -189,13 +190,13 @@ public class BinaryRunner {
|
|||
vMonitor.worked(1);
|
||||
// Attempt to speed things up by rejecting up front
|
||||
// Things we know should not be Binary files.
|
||||
|
||||
|
||||
// check if it's a file resource
|
||||
// and bail out early
|
||||
if (proxy.getType() != IResource.FILE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// check against known content types
|
||||
String name = proxy.getName();
|
||||
IContentType contentType = CCorePlugin.getContentType(project, name);
|
||||
|
@ -228,7 +229,7 @@ public class BinaryRunner {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private boolean isOnOutputEntry(IOutputEntry entry, IPath path) {
|
||||
if (entry.getPath().isPrefixOf(path) && !CoreModelUtil.isExcluded(path, entry.fullExclusionPatternChars())) {
|
||||
return true;
|
||||
|
|
|
@ -26,6 +26,7 @@ public class BinaryVariable extends BinaryElement implements IVariable {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IVariable#getInitializer()
|
||||
*/
|
||||
@Override
|
||||
public String getInitializer() {
|
||||
// TODO Auto-generated method stub
|
||||
return ""; //$NON-NLS-1$
|
||||
|
@ -34,6 +35,7 @@ public class BinaryVariable extends BinaryElement implements IVariable {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IVariableDeclaration#getTypeName()
|
||||
*/
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
// TODO Auto-generated method stub
|
||||
return ""; //$NON-NLS-1$
|
||||
|
@ -42,6 +44,7 @@ public class BinaryVariable extends BinaryElement implements IVariable {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IVariableDeclaration#setTypeName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setTypeName(String type) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
@ -49,6 +52,7 @@ public class BinaryVariable extends BinaryElement implements IVariable {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IDeclaration#isStatic()
|
||||
*/
|
||||
@Override
|
||||
public boolean isStatic() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
|
@ -57,6 +61,7 @@ public class BinaryVariable extends BinaryElement implements IVariable {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IDeclaration#isConst()
|
||||
*/
|
||||
@Override
|
||||
public boolean isConst() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
|
@ -65,9 +70,10 @@ public class BinaryVariable extends BinaryElement implements IVariable {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IDeclaration#isVolatile()
|
||||
*/
|
||||
@Override
|
||||
public boolean isVolatile() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ public class Buffer implements IBuffer {
|
|||
/**
|
||||
* @see IBuffer
|
||||
*/
|
||||
@Override
|
||||
public void addBufferChangedListener(IBufferChangedListener listener) {
|
||||
if (this.changeListeners == null) {
|
||||
this.changeListeners = new ArrayList<IBufferChangedListener>(5);
|
||||
|
@ -72,6 +73,7 @@ public class Buffer implements IBuffer {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.IBuffer#append(char[])
|
||||
*/
|
||||
@Override
|
||||
public void append(char[] text) {
|
||||
if (!isReadOnly()) {
|
||||
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)
|
||||
*/
|
||||
@Override
|
||||
public void append(String text) {
|
||||
if (text == null) {
|
||||
return;
|
||||
|
@ -99,6 +102,7 @@ public class Buffer implements IBuffer {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.IBuffer#close()
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
BufferChangedEvent event = null;
|
||||
synchronized (this.lock) {
|
||||
|
@ -115,6 +119,7 @@ public class Buffer implements IBuffer {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.IBuffer#getChar(int)
|
||||
*/
|
||||
@Override
|
||||
public char getChar(int position) {
|
||||
synchronized (this.lock) {
|
||||
if (position < this.gapStart) {
|
||||
|
@ -128,6 +133,7 @@ public class Buffer implements IBuffer {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.IBuffer#getCharacters()
|
||||
*/
|
||||
@Override
|
||||
public char[] getCharacters() {
|
||||
if (this.contents == null) return null;
|
||||
synchronized (this.lock) {
|
||||
|
@ -145,6 +151,7 @@ public class Buffer implements IBuffer {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.IBuffer#getContents()
|
||||
*/
|
||||
@Override
|
||||
public String getContents() {
|
||||
if (this.contents == null) return null;
|
||||
return new String(this.getCharacters());
|
||||
|
@ -153,6 +160,7 @@ public class Buffer implements IBuffer {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.IBuffer#getLength()
|
||||
*/
|
||||
@Override
|
||||
public int getLength() {
|
||||
synchronized (this.lock) {
|
||||
int length = this.gapEnd - this.gapStart;
|
||||
|
@ -163,6 +171,7 @@ public class Buffer implements IBuffer {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.IBuffer#getOwner()
|
||||
*/
|
||||
@Override
|
||||
public IOpenable getOwner() {
|
||||
return this.owner;
|
||||
}
|
||||
|
@ -170,6 +179,7 @@ public class Buffer implements IBuffer {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.IBuffer#getText(int, int)
|
||||
*/
|
||||
@Override
|
||||
public String getText(int offset, int length) {
|
||||
if (this.contents == null)
|
||||
return ""; //$NON-NLS-1$
|
||||
|
@ -190,6 +200,7 @@ public class Buffer implements IBuffer {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.IBuffer#getUnderlyingResource()
|
||||
*/
|
||||
@Override
|
||||
public IResource getUnderlyingResource() {
|
||||
return this.file;
|
||||
}
|
||||
|
@ -197,6 +208,7 @@ public class Buffer implements IBuffer {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.IBuffer#hasUnsavedChanges()
|
||||
*/
|
||||
@Override
|
||||
public boolean hasUnsavedChanges() {
|
||||
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()
|
||||
*/
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
return (this.flags & F_IS_CLOSED) != 0;
|
||||
}
|
||||
|
@ -211,6 +224,7 @@ public class Buffer implements IBuffer {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.IBuffer#isReadOnly()
|
||||
*/
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
if (this.file == null) {
|
||||
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) {
|
||||
final IBufferChangedListener listener = this.changeListeners.get(i);
|
||||
SafeRunner.run(new ISafeRunnable() {
|
||||
@Override
|
||||
public void handleException(Throwable exception) {
|
||||
Util.log(exception, "Exception occurred in listener of buffer change notification", ICLogConstants.CDT); //$NON-NLS-1$
|
||||
}
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
listener.bufferChanged(event);
|
||||
}
|
||||
|
@ -240,6 +256,7 @@ public class Buffer implements IBuffer {
|
|||
/**
|
||||
* @see IBuffer
|
||||
*/
|
||||
@Override
|
||||
public void removeBufferChangedListener(IBufferChangedListener listener) {
|
||||
if (this.changeListeners != null) {
|
||||
this.changeListeners.remove(listener);
|
||||
|
@ -251,6 +268,7 @@ public class Buffer implements IBuffer {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, char[])
|
||||
*/
|
||||
@Override
|
||||
public void replace(int position, int length, char[] text) {
|
||||
if (!isReadOnly()) {
|
||||
int textLength = text == null ? 0 : text.length;
|
||||
|
@ -277,13 +295,14 @@ public class Buffer implements IBuffer {
|
|||
if (textLength > 0) {
|
||||
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)
|
||||
*/
|
||||
@Override
|
||||
public void replace(int position, int length, String text) {
|
||||
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)
|
||||
*/
|
||||
@Override
|
||||
public void save(IProgressMonitor progress, boolean force)
|
||||
throws CModelException {
|
||||
// determine if saving is required
|
||||
// determine if saving is required
|
||||
if (isReadOnly() || this.file == null) {
|
||||
return;
|
||||
}
|
||||
synchronized (this.lock) {
|
||||
if (!hasUnsavedChanges())
|
||||
return;
|
||||
|
||||
|
||||
// use a platform operation to update the resource contents
|
||||
try {
|
||||
String encoding = null;
|
||||
|
@ -312,19 +332,19 @@ public class Buffer implements IBuffer {
|
|||
}
|
||||
String contents = this.getContents();
|
||||
if (contents == null) return;
|
||||
byte[] bytes = encoding == null
|
||||
? contents.getBytes()
|
||||
byte[] bytes = encoding == null
|
||||
? contents.getBytes()
|
||||
: contents.getBytes(encoding);
|
||||
ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
|
||||
|
||||
if (this.file.exists()) {
|
||||
this.file.setContents(
|
||||
stream,
|
||||
force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
|
||||
stream,
|
||||
force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
|
||||
null);
|
||||
} else {
|
||||
this.file.create(stream, force, null);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
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[])
|
||||
*/
|
||||
@Override
|
||||
public void setContents(char[] newContents) {
|
||||
// allow special case for first initialization
|
||||
// allow special case for first initialization
|
||||
// after creation by buffer factory
|
||||
if (this.contents == null) {
|
||||
this.contents = newContents;
|
||||
this.flags &= ~ (F_HAS_UNSAVED_CHANGES);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!isReadOnly()) {
|
||||
String string = null;
|
||||
if (newContents != null) {
|
||||
|
@ -368,13 +389,14 @@ public class Buffer implements IBuffer {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.IBuffer#setContents(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setContents(String newContents) {
|
||||
this.setContents(newContents.toCharArray());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Thus the gap is resized to actual size + the specified size and
|
||||
* moved to the given position.
|
||||
|
@ -414,7 +436,7 @@ public class Buffer implements IBuffer {
|
|||
this.gapStart = newGapStart;
|
||||
this.gapEnd = newGapEnd;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets this <code>Buffer</code> to be read only.
|
||||
*/
|
||||
|
@ -425,7 +447,7 @@ public class Buffer implements IBuffer {
|
|||
this.flags &= ~(F_IS_READ_ONLY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
@ -442,7 +464,7 @@ public class Buffer implements IBuffer {
|
|||
for (int i = 0; i < length; i++) {
|
||||
char car = contents[i];
|
||||
switch (car) {
|
||||
case '\n':
|
||||
case '\n':
|
||||
buffer.append("\\n\n"); //$NON-NLS-1$
|
||||
break;
|
||||
case '\r':
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.eclipse.core.resources.IResource;
|
|||
/**
|
||||
* The buffer manager manages the set of open buffers.
|
||||
* It implements an LRU cache of buffers.
|
||||
*
|
||||
*
|
||||
* 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)
|
||||
*/
|
||||
@Override
|
||||
public IBuffer createBuffer(IOpenable owner) {
|
||||
ICElement element = (ICElement)owner;
|
||||
|
||||
IResource resource = element.getResource();
|
||||
return
|
||||
return
|
||||
new Buffer(
|
||||
resource instanceof IFile ? (IFile)resource : null,
|
||||
owner,
|
||||
resource instanceof IFile ? (IFile)resource : null,
|
||||
owner,
|
||||
element.isReadOnly());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the open buffer associated with the given owner,
|
||||
* 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.
|
||||
* <p>
|
||||
* <p>
|
||||
* The <code>Enumeration</code> answered is thread safe.
|
||||
*
|
||||
* @see OverflowingLRUCache
|
||||
|
@ -140,8 +141,8 @@ public class BufferManager implements IBufferFactory {
|
|||
return openBuffers.elements();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Removes a buffer from the table of open buffers.
|
||||
*/
|
||||
|
|
|
@ -50,9 +50,10 @@ public class CContainer extends Openable implements ICContainer {
|
|||
|
||||
/**
|
||||
* Returns a the collection of binary files in this ccontainer
|
||||
*
|
||||
*
|
||||
* @see ICContainer#getBinaries()
|
||||
*/
|
||||
@Override
|
||||
public IBinary[] getBinaries() throws CModelException {
|
||||
List<?> list = getChildrenOfType(C_BINARY);
|
||||
IBinary[] array = new IBinary[list.size()];
|
||||
|
@ -63,6 +64,7 @@ public class CContainer extends Openable implements ICContainer {
|
|||
/**
|
||||
* @see ICContainer#getBinary(String)
|
||||
*/
|
||||
@Override
|
||||
public IBinary getBinary(String name) {
|
||||
IFile file = getContainer().getFile(new Path(name));
|
||||
return getBinary(file);
|
||||
|
@ -78,9 +80,10 @@ public class CContainer extends Openable implements ICContainer {
|
|||
|
||||
/**
|
||||
* Returns a the collection of archive files in this ccontainer
|
||||
*
|
||||
*
|
||||
* @see ICContainer#getArchives()
|
||||
*/
|
||||
@Override
|
||||
public IArchive[] getArchives() throws CModelException {
|
||||
List<?> list = getChildrenOfType(C_ARCHIVE);
|
||||
IArchive[] array = new IArchive[list.size()];
|
||||
|
@ -91,6 +94,7 @@ public class CContainer extends Openable implements ICContainer {
|
|||
/**
|
||||
* @see ICContainer#getArchive(String)
|
||||
*/
|
||||
@Override
|
||||
public IArchive getArchive(String name) {
|
||||
IFile file = getContainer().getFile(new Path(name));
|
||||
return getArchive(file);
|
||||
|
@ -107,6 +111,7 @@ public class CContainer extends Openable implements ICContainer {
|
|||
/**
|
||||
* @see ICContainer#getTranslationUnits()
|
||||
*/
|
||||
@Override
|
||||
public ITranslationUnit[] getTranslationUnits() throws CModelException {
|
||||
List<?> list = getChildrenOfType(C_UNIT);
|
||||
ITranslationUnit[] array = new ITranslationUnit[list.size()];
|
||||
|
@ -116,9 +121,10 @@ public class CContainer extends Openable implements ICContainer {
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.eclipse.cdt.core.model.ICContainer#getTranslationUnit(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ITranslationUnit getTranslationUnit(String name) {
|
||||
IFile file = getContainer().getFile(new Path(name));
|
||||
return getTranslationUnit(file);
|
||||
|
@ -131,9 +137,10 @@ public class CContainer extends Openable implements ICContainer {
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.eclipse.cdt.core.model.ICContainer#getCContainers()
|
||||
*/
|
||||
@Override
|
||||
public ICContainer[] getCContainers() throws CModelException {
|
||||
List<?> list = getChildrenOfType(C_CCONTAINER);
|
||||
ICContainer[] array = new ICContainer[list.size()];
|
||||
|
@ -143,9 +150,10 @@ public class CContainer extends Openable implements ICContainer {
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.eclipse.cdt.core.model.ICContainer#getCContainer(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ICContainer getCContainer(String name) {
|
||||
IFolder folder = getContainer().getFolder(new Path(name));
|
||||
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
|
||||
* receiver.
|
||||
*
|
||||
*
|
||||
* @see org.eclipse.cdt.core.model.ICContainer#getNonCResources()
|
||||
*/
|
||||
@Override
|
||||
public Object[] getNonCResources() throws CModelException {
|
||||
return ((CContainerInfo) getElementInfo()).getNonCResources(getResource());
|
||||
}
|
||||
|
@ -273,7 +282,7 @@ public class CContainer extends Openable implements ICContainer {
|
|||
}
|
||||
return celement;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICElement getHandleFromMemento(String token, MementoTokenizer memento) {
|
||||
switch (token.charAt(0)) {
|
||||
|
|
|
@ -41,7 +41,7 @@ import org.eclipse.core.runtime.Path;
|
|||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
public abstract class CElement extends PlatformObject implements ICElement {
|
||||
|
||||
|
||||
public static final char CEM_ESCAPE = '\\';
|
||||
public static final char CEM_CPROJECT = '=';
|
||||
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 int fType;
|
||||
|
||||
|
||||
protected ICElement fParent;
|
||||
|
||||
protected String fName;
|
||||
|
@ -63,7 +63,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
fName= name;
|
||||
fType= type;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// setters
|
||||
|
||||
public void setElementType (int type) {
|
||||
|
@ -90,44 +90,50 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
public void setElementName(String name) {
|
||||
fName = name;
|
||||
}
|
||||
|
||||
|
||||
public void setParent (ICElement parent) {
|
||||
fParent = parent;
|
||||
}
|
||||
|
||||
|
||||
// getters
|
||||
|
||||
|
||||
@Override
|
||||
public int getElementType() {
|
||||
return fType;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return fName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICElement getParent() {
|
||||
return fParent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPath getPath() {
|
||||
IResource res = getUnderlyingResource();
|
||||
if (res != null)
|
||||
return res.getFullPath();
|
||||
return new Path(getElementName());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public URI getLocationURI() {
|
||||
IResource res = getUnderlyingResource();
|
||||
|
||||
|
||||
if(res != null) {
|
||||
return res.getLocationURI();
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists() {
|
||||
try {
|
||||
return getElementInfo() != null;
|
||||
|
@ -201,7 +207,8 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
}
|
||||
return new ICElement[]{this};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly () {
|
||||
IResource r = getUnderlyingResource();
|
||||
if (r != null) {
|
||||
|
@ -209,14 +216,16 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
if (attributes != null) {
|
||||
return attributes.isReadOnly();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStructureKnown() throws CModelException {
|
||||
return getElementInfo().isStructureKnown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICModel getCModel () {
|
||||
ICElement current = this;
|
||||
do {
|
||||
|
@ -225,6 +234,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICProject getCProject() {
|
||||
ICElement current = this;
|
||||
do {
|
||||
|
@ -236,6 +246,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
protected void addChild(ICElement e) throws CModelException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IResource getUnderlyingResource() {
|
||||
IResource res = getResource();
|
||||
if (res == null) {
|
||||
|
@ -247,6 +258,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract IResource getResource() ;
|
||||
|
||||
protected abstract CElementInfo createElementInfo();
|
||||
|
@ -263,7 +275,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static boolean equals(ICElement lhs, ICElement rhs) {
|
||||
if (lhs == rhs) {
|
||||
return true;
|
||||
|
@ -277,19 +289,19 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
!lhsName.equals(rhsName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (lhs instanceof ISourceReference && rhs instanceof ISourceReference) {
|
||||
if (((ISourceReference) lhs).getIndex() != ((ISourceReference) rhs).getIndex()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ICElement lhsParent= lhs.getParent();
|
||||
ICElement rhsParent= rhs.getParent();
|
||||
if (lhsParent == rhsParent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return lhsParent != null && lhsParent.equals(rhsParent);
|
||||
}
|
||||
|
||||
|
@ -370,7 +382,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
return "UNKNOWN"; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close the C Element
|
||||
* @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.
|
||||
*/
|
||||
public IOpenable getOpenableParent() {
|
||||
if (fParent instanceof IOpenable) {
|
||||
if (fParent instanceof IOpenable) {
|
||||
return (IOpenable)fParent;
|
||||
}
|
||||
return null;
|
||||
|
@ -455,6 +467,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
/**
|
||||
* @see ICElement
|
||||
*/
|
||||
@Override
|
||||
public ICElement getAncestor(int ancestorType) {
|
||||
ICElement element = this;
|
||||
while (element != null) {
|
||||
|
@ -477,14 +490,14 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
}
|
||||
return parent != null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates and returns and not present exception for this element.
|
||||
*/
|
||||
protected CModelException newNotPresentException() {
|
||||
return new CModelException(new CModelStatus(ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the hash code for this Java element. By default,
|
||||
* 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() {
|
||||
return hashCode(this);
|
||||
}
|
||||
|
||||
|
||||
public static int hashCode(ICElement elem) {
|
||||
ICElement parent= elem.getParent();
|
||||
if (parent == null) {
|
||||
|
@ -505,7 +518,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
}
|
||||
return Util.combineHashCodes(elem.getElementName().hashCode(), parent.hashCode());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Test to see if two objects are identical
|
||||
* Subclasses should override accordingly
|
||||
|
@ -513,10 +526,11 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
public boolean isIdentical(CElement otherElement){
|
||||
return this.equals(otherElement);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICElement#accept(org.eclipse.cdt.core.model.ICElementVisitor)
|
||||
*/
|
||||
@Override
|
||||
public void accept(ICElementVisitor visitor) throws CoreException {
|
||||
// Visit me, return right away if the visitor doesn't want to visit my children
|
||||
if (!visitor.visit(this))
|
||||
|
@ -533,13 +547,14 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
/*
|
||||
* @see org.eclipse.cdt.core.model.ICElement#getHandleIdentifier()
|
||||
*/
|
||||
@Override
|
||||
public String getHandleIdentifier() {
|
||||
return getHandleMemento();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a string representation of this element.
|
||||
*
|
||||
*
|
||||
* @return the string representation
|
||||
*/
|
||||
public String getHandleMemento(){
|
||||
|
@ -550,7 +565,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
|
||||
/**
|
||||
* Append this elements memento string to the given buffer.
|
||||
*
|
||||
*
|
||||
* @param buff the buffer building the memento string
|
||||
*/
|
||||
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.
|
||||
*
|
||||
*
|
||||
* @param memento the memento tokenizer
|
||||
*/
|
||||
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.
|
||||
* The given token is the current delimiter indicating the type of the next token(s).
|
||||
*
|
||||
*
|
||||
* @param token the curren memento token
|
||||
* @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.
|
||||
*
|
||||
*
|
||||
* @param buffer the buffer to build the memento string
|
||||
* @param mementoName the name to escape
|
||||
*/
|
||||
|
|
|
@ -103,12 +103,12 @@ public class CElementDelta implements ICElementDelta {
|
|||
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
|
||||
if (!(fChangedElement.getElementType() >= ICElement.C_UNIT)) {
|
||||
fineGrained();
|
||||
}
|
||||
|
||||
|
||||
if (fAffectedChildren.length == 0) {
|
||||
fAffectedChildren = new ICElementDelta[] {child};
|
||||
return;
|
||||
|
@ -189,7 +189,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
// unknown -> existing child becomes the child with the existing child's flags
|
||||
int flags = existingChild.getFlags();
|
||||
fAffectedChildren[existingChildIndex] = child;
|
||||
|
@ -201,7 +201,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
/**
|
||||
* Creates the nested deltas resulting from an add operation.
|
||||
* 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.
|
||||
*/
|
||||
public void added(ICElement element) {
|
||||
|
@ -242,7 +242,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
/**
|
||||
* Creates the nested deltas resulting from a change operation.
|
||||
* 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.
|
||||
*/
|
||||
public void changed(ICElement element, int changeFlag) {
|
||||
|
@ -329,6 +329,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
/**
|
||||
* @see ICElementDelta
|
||||
*/
|
||||
@Override
|
||||
public ICElementDelta[] getAddedChildren() {
|
||||
return getChildrenOfType(ADDED);
|
||||
}
|
||||
|
@ -336,6 +337,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
/**
|
||||
* @see ICElementDelta
|
||||
*/
|
||||
@Override
|
||||
public ICElementDelta[] getAffectedChildren() {
|
||||
return fAffectedChildren;
|
||||
}
|
||||
|
@ -366,6 +368,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
/**
|
||||
* @see ICElementDelta
|
||||
*/
|
||||
@Override
|
||||
public ICElementDelta[] getChangedChildren() {
|
||||
return getChildrenOfType(CHANGED);
|
||||
}
|
||||
|
@ -415,6 +418,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
/**
|
||||
* @see ICElementDelta
|
||||
*/
|
||||
@Override
|
||||
public ICElement getElement() {
|
||||
return fChangedElement;
|
||||
}
|
||||
|
@ -422,6 +426,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
/**
|
||||
* @see ICElementDelta
|
||||
*/
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return fChangeFlags;
|
||||
}
|
||||
|
@ -429,6 +434,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
/**
|
||||
* @see ICElementDelta
|
||||
*/
|
||||
@Override
|
||||
public int getKind() {
|
||||
return fKind;
|
||||
}
|
||||
|
@ -436,6 +442,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
/**
|
||||
* @see ICElementDelta
|
||||
*/
|
||||
@Override
|
||||
public ICElement getMovedFromElement() {
|
||||
return fMovedFromHandle;
|
||||
}
|
||||
|
@ -443,6 +450,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
/**
|
||||
* @see ICElementDelta
|
||||
*/
|
||||
@Override
|
||||
public ICElement getMovedToElement() {
|
||||
return fMovedToHandle;
|
||||
}
|
||||
|
@ -450,6 +458,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
/**
|
||||
* @see ICElementDelta
|
||||
*/
|
||||
@Override
|
||||
public ICElementDelta[] getRemovedChildren() {
|
||||
return getChildrenOfType(REMOVED);
|
||||
}
|
||||
|
@ -457,6 +466,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
/**
|
||||
* Return the collection of resource deltas. Return null if none.
|
||||
*/
|
||||
@Override
|
||||
public IResourceDelta[] getResourceDeltas() {
|
||||
if (resourceDeltas == null)
|
||||
return null;
|
||||
|
@ -493,7 +503,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
/**
|
||||
* Creates the nested deltas resulting from an move operation.
|
||||
* 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.
|
||||
*/
|
||||
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.
|
||||
* 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.
|
||||
*/
|
||||
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.
|
||||
* 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.
|
||||
*/
|
||||
public void removed(ICElement element) {
|
||||
|
@ -580,7 +590,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
/**
|
||||
* Creates the nested deltas resulting from a change operation.
|
||||
* 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.
|
||||
*/
|
||||
public void binaryParserChanged(ICElement element) {
|
||||
|
@ -593,7 +603,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
/**
|
||||
* Creates the nested deltas resulting from a change operation.
|
||||
* 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.
|
||||
*/
|
||||
public void sourceAttached(ICElement element) {
|
||||
|
@ -606,7 +616,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
/**
|
||||
* Creates the nested deltas resulting from a change operation.
|
||||
* 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.
|
||||
*/
|
||||
public void sourceDetached(ICElement element) {
|
||||
|
@ -616,7 +626,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
insertDeltaTree(element, detachedDelta);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns a string representation of this delta's
|
||||
* structure suitable for debug purposes.
|
||||
*
|
||||
|
@ -761,7 +771,7 @@ public class CElementDelta implements ICElementDelta {
|
|||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns a string representation of this delta's
|
||||
* structure suitable for debug purposes.
|
||||
*/
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -48,6 +48,7 @@ public class CModel extends Openable implements ICModel {
|
|||
return super.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICProject[] getCProjects() throws CModelException {
|
||||
List<?> list = getChildrenOfType(C_PROJECT);
|
||||
ICProject[] array= new ICProject[list.size()];
|
||||
|
@ -58,9 +59,10 @@ public class CModel extends Openable implements ICModel {
|
|||
/**
|
||||
* ICModel#getCProject(String)
|
||||
*/
|
||||
@Override
|
||||
public ICProject getCProject(String name) {
|
||||
IProject project = ((IWorkspaceRoot) getResource()).getProject(name);
|
||||
return CModelManager.getDefault().create(project);
|
||||
IProject project = ((IWorkspaceRoot) getResource()).getProject(name);
|
||||
return CModelManager.getDefault().create(project);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,11 +103,13 @@ public class CModel extends Openable implements ICModel {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IWorkspace getWorkspace() {
|
||||
return getUnderlyingResource().getWorkspace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(ICElement[] elements, ICElement[] containers, ICElement[] siblings,
|
||||
String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException {
|
||||
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)
|
||||
throws CModelException {
|
||||
CModelOperation op;
|
||||
|
@ -128,6 +133,7 @@ public class CModel extends Openable implements ICModel {
|
|||
op.runOperation(monitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void move(ICElement[] elements, ICElement[] containers, ICElement[] siblings,
|
||||
String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException {
|
||||
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,
|
||||
boolean force, IProgressMonitor monitor) throws CModelException {
|
||||
CModelOperation op;
|
||||
|
@ -210,6 +217,7 @@ public class CModel extends Openable implements ICModel {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICModel#getNonCResources()
|
||||
*/
|
||||
@Override
|
||||
public Object[] getNonCResources() throws CModelException {
|
||||
return ((CModelInfo) getElementInfo()).getNonCResources();
|
||||
}
|
||||
|
@ -241,12 +249,12 @@ public class CModel extends Openable implements ICModel {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getHandleMemento(StringBuilder buff) {
|
||||
buff.append(getElementName());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected char getHandleMementoDelimiter() {
|
||||
Assert.isTrue(false, "Should not be called"); //$NON-NLS-1$
|
||||
|
|
|
@ -104,7 +104,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
|||
|
||||
/**
|
||||
* Create a model builder for the given translation unit.
|
||||
*
|
||||
*
|
||||
* @param tu the translation unit (must be a {@link TranslationUnit}
|
||||
* @param newElements element cache
|
||||
* @param monitor the progress monitor
|
||||
|
@ -118,10 +118,11 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
|||
/*
|
||||
* @see org.eclipse.cdt.core.model.IContributedModelBuilder#parse(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void parse(boolean quickParseMode) throws Exception {
|
||||
final IIndexManager indexManager= CCorePlugin.getIndexManager();
|
||||
IIndex index= indexManager.getIndex(fTranslationUnit.getCProject(), IIndexManager.ADD_DEPENDENCIES);
|
||||
|
||||
|
||||
try {
|
||||
if (index != null) {
|
||||
try {
|
||||
|
@ -229,6 +230,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
|||
// sort by offset
|
||||
final List<ICElement> children= getElementInfo(fTranslationUnit).internalGetChildren();
|
||||
Collections.sort(children, new Comparator<ICElement>() {
|
||||
@Override
|
||||
public int compare(ICElement o1, ICElement o2) {
|
||||
final SourceManipulationInfo info1= getSourceManipulationInfo((SourceManipulation) o1);
|
||||
final SourceManipulationInfo info2= getSourceManipulationInfo((SourceManipulation) o2);
|
||||
|
@ -589,7 +591,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
|||
final Enumeration element= new Enumeration (parent, enumName);
|
||||
setIndex(element);
|
||||
element.setActive(enumSpecifier.isActive());
|
||||
|
||||
|
||||
// add to parent
|
||||
parent.addChild(element);
|
||||
EnumerationInfo info= (EnumerationInfo) getElementInfo(element);
|
||||
|
@ -600,7 +602,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
|||
final IASTFileLocation enumLocation= enumSpecifier.getFileLocation();
|
||||
info.setIdPos(enumLocation.getNodeOffset(), type.length());
|
||||
}
|
||||
// add enumerators
|
||||
// add enumerators
|
||||
final IASTEnumerator[] enumerators= enumSpecifier.getEnumerators();
|
||||
for (final IASTEnumerator enumerator : enumerators) {
|
||||
createEnumerator(element, enumerator);
|
||||
|
@ -967,7 +969,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
|||
element.setParameterTypes(parameterTypes);
|
||||
element.setReturnType(returnType);
|
||||
setIndex(element);
|
||||
|
||||
|
||||
info= (FunctionInfo) getElementInfo(element);
|
||||
info.setConst(cppFunctionDeclarator.isConst());
|
||||
}
|
||||
|
@ -978,7 +980,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
|||
element.setParameterTypes(parameterTypes);
|
||||
element.setReturnType(returnType);
|
||||
setIndex(element);
|
||||
|
||||
|
||||
info= (FunctionInfo) getElementInfo(element);
|
||||
}
|
||||
element.setActive(functionDeclaration.isActive());
|
||||
|
@ -1053,7 +1055,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
|||
element.setParameterTypes(parameterTypes);
|
||||
element.setReturnType(returnType);
|
||||
setIndex(element);
|
||||
|
||||
|
||||
info= (FunctionInfo)getElementInfo(element);
|
||||
info.setConst(cppFunctionDeclarator.isConst());
|
||||
}
|
||||
|
@ -1073,7 +1075,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
|||
return null;
|
||||
}
|
||||
element.setActive(declarator.isActive());
|
||||
|
||||
|
||||
// TODO [cmodel] correctly resolve isStatic
|
||||
info.setStatic(declSpecifier.getStorageClass() == IASTDeclSpecifier.sc_static);
|
||||
|
||||
|
@ -1281,7 +1283,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
|||
|
||||
/**
|
||||
* Determine the scope for given name.
|
||||
*
|
||||
*
|
||||
* @param astName
|
||||
* @return the scope or <code>null</code>
|
||||
*/
|
||||
|
|
|
@ -230,7 +230,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
}
|
||||
if (res != null && !res.exists()) {
|
||||
res = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// In case this is an external resource see if we can find
|
||||
|
@ -343,7 +343,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check for binary on output entry
|
||||
if (celement == null && cproject.isOnOutputEntry(file)) {
|
||||
IBinaryFile bin = createBinaryFile(file);
|
||||
|
@ -371,12 +371,12 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
if (cproject.isOnOutputEntry(file)) {
|
||||
IPath resourcePath = file.getParent().getFullPath();
|
||||
ICElement cfolder = cproject.findElement(resourcePath);
|
||||
|
||||
|
||||
// Check if folder is a source root and use that instead
|
||||
ISourceRoot sourceRoot = cproject.findSourceRoot(resourcePath);
|
||||
if (sourceRoot != null)
|
||||
cfolder = sourceRoot;
|
||||
|
||||
|
||||
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
||||
ArchiveContainer vlib = (ArchiveContainer)cproject.getArchiveContainer();
|
||||
celement = new Archive(cfolder, file, (IBinaryArchive)bin);
|
||||
|
@ -405,7 +405,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
if (!Util.isNonZeroLengthFile(path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
IIncludeReference[] includeReferences = cproject.getIncludeReferences();
|
||||
for (IIncludeReference includeReference : includeReferences) {
|
||||
|
@ -414,7 +414,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
if (headerContentTypeId == null) {
|
||||
headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
|
||||
}
|
||||
|
||||
|
||||
// TODO: use URI
|
||||
return new ExternalTranslationUnit(includeReference, URIUtil.toURI(path), headerContentTypeId);
|
||||
}
|
||||
|
@ -439,7 +439,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
if (headerContentTypeId == null) {
|
||||
headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
|
||||
}
|
||||
|
||||
|
||||
// TODO: use URI
|
||||
return new ExternalTranslationUnit(includeReference, URIUtil.toURI(includePath), headerContentTypeId);
|
||||
}
|
||||
|
@ -449,10 +449,10 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a translation unit in the given project for the given location.
|
||||
*
|
||||
*
|
||||
* @param cproject
|
||||
* @param locationURI
|
||||
* @return ITranslationUnit
|
||||
|
@ -465,9 +465,9 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
if(!locationURI.isAbsolute()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
|
||||
final IProject project= cproject.getProject();
|
||||
|
||||
|
||||
IFileStore fileStore = null;
|
||||
try {
|
||||
fileStore = EFS.getStore(locationURI);
|
||||
|
@ -475,12 +475,12 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
CCorePlugin.log(e1);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
final String contentTypeId = CoreModel.getRegistedContentTypeId(project, fileStore.getName());
|
||||
if (!Util.isNonZeroLengthFile(locationURI)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
IIncludeReference[] includeReferences = cproject.getIncludeReferences();
|
||||
for (IIncludeReference includeReference : includeReferences) {
|
||||
|
@ -492,7 +492,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
if (headerContentTypeId == null) {
|
||||
headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
// an external translation unit for it.
|
||||
IFileInfo info = fileStore.fetchInfo();
|
||||
|
||||
|
||||
if (contentTypeId != null && info != null && info.exists()) {
|
||||
return new ExternalTranslationUnit(cproject, locationURI, contentTypeId);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -632,7 +632,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
if (parsers.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// Only if file has no extension, has an extension that is an integer
|
||||
// or is a binary file content type
|
||||
String ext = file.getFileExtension();
|
||||
|
@ -650,7 +650,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
baseFileName = baseFileName.removeFileExtension();
|
||||
ext = baseFileName.getFileExtension();
|
||||
} while (ext != null && ext.length() > 0);
|
||||
|
||||
|
||||
boolean isBinary= false;
|
||||
final IContentTypeManager ctm = Platform.getContentTypeManager();
|
||||
final IContentType ctbin = ctm.getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE);
|
||||
|
@ -662,7 +662,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
URI fileUri = file.getLocationURI();
|
||||
//Avoid name special devices, empty files and the like
|
||||
if (!Util.isNonZeroLengthFile(fileUri)) {
|
||||
|
@ -677,9 +677,9 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
}
|
||||
//return null;
|
||||
}
|
||||
|
||||
|
||||
int hints = 0;
|
||||
|
||||
|
||||
for (BinaryParserConfig parser2 : parsers) {
|
||||
IBinaryParser parser = null;
|
||||
try {
|
||||
|
@ -850,10 +850,11 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
* on the platform, and that the C Model should update any required
|
||||
* internal structures such that its elements remain consistent.
|
||||
* Translates <code>IResourceDeltas</code> into <code>ICElementDeltas</code>.
|
||||
*
|
||||
*
|
||||
* @see IResourceDelta
|
||||
* @see IResource
|
||||
*/
|
||||
@Override
|
||||
public void resourceChanged(IResourceChangeEvent event) {
|
||||
if (event.getSource() instanceof IWorkspace) {
|
||||
IResourceDelta delta = event.getDelta();
|
||||
|
@ -861,7 +862,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
switch (event.getType()) {
|
||||
case IResourceChangeEvent.PRE_DELETE:
|
||||
try {
|
||||
if (resource.getType() == IResource.PROJECT &&
|
||||
if (resource.getType() == IResource.PROJECT &&
|
||||
( ((IProject)resource).hasNature(CProjectNature.C_NATURE_ID) ||
|
||||
((IProject)resource).hasNature(CCProjectNature.CC_NATURE_ID) )){
|
||||
this.preDeleteProject((IProject) resource);}
|
||||
|
@ -871,7 +872,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
|
||||
case IResourceChangeEvent.PRE_CLOSE:
|
||||
try {
|
||||
if (resource.getType() == IResource.PROJECT &&
|
||||
if (resource.getType() == IResource.PROJECT &&
|
||||
( ((IProject)resource).hasNature(CProjectNature.C_NATURE_ID) ||
|
||||
((IProject)resource).hasNature(CCProjectNature.CC_NATURE_ID) )){
|
||||
this.preCloseProject((IProject) resource);}
|
||||
|
@ -899,6 +900,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(CProjectDescriptionEvent event) {
|
||||
switch(event.getEventType()) {
|
||||
case CProjectDescriptionEvent.APPLIED:
|
||||
|
@ -961,6 +963,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.content.IContentTypeManager.IContentTypeListener#contentTypeChanged()
|
||||
*/
|
||||
@Override
|
||||
public void contentTypeChanged(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) {
|
||||
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.
|
||||
* If the firing mode has been turned off, this has no effect.
|
||||
* Fire C Model deltas, flushing them after the fact.
|
||||
* If the firing mode has been turned off, this has no effect.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
void fire(ICElementDelta customDeltas, int eventType) {
|
||||
|
@ -1077,7 +1080,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
notifyListeners(deltaToNotify, ElementChangedEvent.POST_SHIFT, listeners, listenerMask, listenerCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void notifyListeners(ICElementDelta deltaToNotify, int eventType,
|
||||
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
|
||||
SafeRunner.run(new ISafeRunnable() {
|
||||
|
||||
@Override
|
||||
public void handleException(Throwable exception) {
|
||||
//CCorePlugin.log(exception, "Exception occurred in listener of C element change notification"); //$NON-NLS-1$
|
||||
CCorePlugin.log(exception);
|
||||
}
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
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)
|
||||
* 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
|
||||
* its ancestors). So returns without updating the cache.
|
||||
*/
|
||||
|
@ -1306,10 +1311,10 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
movedTo= delta.getMovedToPath();
|
||||
}
|
||||
LocalProjectScope.deletePreferences(res.getFullPath(), movedTo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void preDeleteProject(IProject project) {
|
||||
// remove binary parsers
|
||||
binaryParsersMap.remove(project);
|
||||
|
|
|
@ -198,6 +198,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
|
|||
/**
|
||||
* @see IProgressMonitor
|
||||
*/
|
||||
@Override
|
||||
public void beginTask(String name, int totalWork) {
|
||||
if (fMonitor != null) {
|
||||
fMonitor.beginTask(name, totalWork);
|
||||
|
@ -320,6 +321,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
|
|||
/**
|
||||
* @see IProgressMonitor
|
||||
*/
|
||||
@Override
|
||||
public void done() {
|
||||
if (fMonitor != null) {
|
||||
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.
|
||||
* Subclasses can override.
|
||||
*/
|
||||
|
@ -477,6 +479,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
|
|||
return !this.isReadOnly() && this.hasModifiedResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void internalWorked(double work) {
|
||||
if (fMonitor != null) {
|
||||
fMonitor.internalWorked(work);
|
||||
|
@ -486,6 +489,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
|
|||
/**
|
||||
* @see IProgressMonitor
|
||||
*/
|
||||
@Override
|
||||
public boolean isCanceled() {
|
||||
if (fMonitor != null) {
|
||||
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 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() {
|
||||
ArrayList<CModelOperation> stack = operationStacks.get();
|
||||
|
@ -562,7 +566,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
|
|||
ArrayList<CModelOperation> stack = getCurrentOperationStack();
|
||||
int size = stack.size();
|
||||
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)
|
||||
}
|
||||
return stack.remove(size-1);
|
||||
|
@ -593,6 +597,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
|
|||
* @see IWorkspaceRunnable
|
||||
* @exception CoreException if the operation fails
|
||||
*/
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
CModelManager manager= CModelManager.getDefault();
|
||||
int previousDeltaCount = manager.fCModelDeltas.size();
|
||||
|
@ -649,6 +654,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
|
|||
/**
|
||||
* @see IProgressMonitor
|
||||
*/
|
||||
@Override
|
||||
public void setCanceled(boolean b) {
|
||||
if (fMonitor != null) {
|
||||
fMonitor.setCanceled(b);
|
||||
|
@ -666,6 +672,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
|
|||
/**
|
||||
* @see IProgressMonitor
|
||||
*/
|
||||
@Override
|
||||
public void setTaskName(String name) {
|
||||
if (fMonitor != null) {
|
||||
fMonitor.setTaskName(name);
|
||||
|
@ -675,6 +682,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
|
|||
/**
|
||||
* @see IProgressMonitor
|
||||
*/
|
||||
@Override
|
||||
public void subTask(String name) {
|
||||
if (fMonitor != null) {
|
||||
fMonitor.subTask(name);
|
||||
|
@ -698,6 +706,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
|
|||
/**
|
||||
* @see IProgressMonitor
|
||||
*/
|
||||
@Override
|
||||
public void worked(int work) {
|
||||
if (fMonitor != null) {
|
||||
fMonitor.worked(work);
|
||||
|
|
|
@ -157,6 +157,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
|||
/**
|
||||
* @see ICModelStatus
|
||||
*/
|
||||
@Override
|
||||
public ICElement[] getElements() {
|
||||
return fElements;
|
||||
}
|
||||
|
@ -289,6 +290,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
|||
return exception.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPath getPath() {
|
||||
if (fPath == null) {
|
||||
return Path.EMPTY;
|
||||
|
@ -316,6 +318,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
|||
/**
|
||||
* @see ICModelStatus
|
||||
*/
|
||||
@Override
|
||||
public String getString() {
|
||||
if (fString == null) {
|
||||
return EMPTY_STRING;
|
||||
|
@ -333,6 +336,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
|||
/**
|
||||
* @see ICModelStatus
|
||||
*/
|
||||
@Override
|
||||
public boolean doesNotExist() {
|
||||
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
|
||||
* multi-status status.
|
||||
*
|
||||
*
|
||||
* @see IStatus#isMultiStatus()
|
||||
*/
|
||||
public static ICModelStatus newMultiStatus(ICModelStatus[] children) {
|
||||
|
|
|
@ -72,18 +72,22 @@ public class CProject extends Openable implements ICProject {
|
|||
super(parent, project, ICElement.C_PROJECT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinaryContainer getBinaryContainer() throws CModelException {
|
||||
return ((CProjectInfo) getElementInfo()).getBinaryContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IArchiveContainer getArchiveContainer() throws CModelException {
|
||||
return ((CProjectInfo) getElementInfo()).getArchiveContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IProject getProject() {
|
||||
return getUnderlyingResource().getProject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICElement findElement(IPath path) throws CModelException {
|
||||
ICElement celem = null;
|
||||
if (path.isAbsolute()) {
|
||||
|
@ -134,13 +138,13 @@ public class CProject extends Openable implements ICProject {
|
|||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
|
||||
if (this == o)
|
||||
return true;
|
||||
|
||||
|
||||
if (!(o instanceof CProject))
|
||||
return false;
|
||||
|
||||
|
||||
CProject other = (CProject) o;
|
||||
return getProject().equals(other.getProject());
|
||||
}
|
||||
|
@ -156,6 +160,7 @@ public class CProject extends Openable implements ICProject {
|
|||
return getProject().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIncludeReference[] getIncludeReferences() throws CModelException {
|
||||
CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this);
|
||||
IIncludeReference[] incRefs = null;
|
||||
|
@ -179,6 +184,7 @@ public class CProject extends Openable implements ICProject {
|
|||
return incRefs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILibraryReference[] getLibraryReferences() throws CModelException {
|
||||
CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this);
|
||||
ILibraryReference[] libRefs = null;
|
||||
|
@ -240,6 +246,7 @@ public class CProject extends Openable implements ICProject {
|
|||
/**
|
||||
* @see ICProject#getRequiredProjectNames()
|
||||
*/
|
||||
@Override
|
||||
public String[] getRequiredProjectNames() throws CModelException {
|
||||
return projectPrerequisites(getResolvedPathEntries());
|
||||
}
|
||||
|
@ -252,6 +259,7 @@ public class CProject extends Openable implements ICProject {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.ICProject#getOption(String, boolean)
|
||||
*/
|
||||
@Override
|
||||
public String getOption(String optionName, boolean inheritCCoreOptions) {
|
||||
if (CModelManager.OptionNames.contains(optionName)) {
|
||||
IEclipsePreferences preferences = getPreferences();
|
||||
|
@ -269,6 +277,7 @@ public class CProject extends Openable implements ICProject {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.ICProject#getOptions(boolean)
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> getOptions(boolean inheritCCoreOptions) {
|
||||
// initialize to the defaults from CCorePlugin options pool
|
||||
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)
|
||||
*/
|
||||
@Override
|
||||
public void setOption(String optionName, String optionValue) {
|
||||
if (!CModelManager.OptionNames.contains(optionName))
|
||||
return; // unrecognized option
|
||||
|
@ -307,7 +317,7 @@ public class CProject extends Openable implements ICProject {
|
|||
} else {
|
||||
projectPreferences.put(optionName, optionValue);
|
||||
}
|
||||
|
||||
|
||||
// Dump changes
|
||||
try {
|
||||
projectPreferences.flush();
|
||||
|
@ -319,6 +329,7 @@ public class CProject extends Openable implements ICProject {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.ICProject#setOptions(Map)
|
||||
*/
|
||||
@Override
|
||||
public void setOptions(Map<String, String> newOptions) {
|
||||
Preferences preferences = new Preferences();
|
||||
setPreferences(preferences); // always reset (26255)
|
||||
|
@ -397,6 +408,7 @@ public class CProject extends Openable implements ICProject {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICProject#getResolvedCPathEntries()
|
||||
*/
|
||||
@Override
|
||||
public IPathEntry[] getResolvedPathEntries() throws CModelException {
|
||||
return CoreModel.getResolvedPathEntries(this);
|
||||
}
|
||||
|
@ -404,6 +416,7 @@ public class CProject extends Openable implements ICProject {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICProject#getRawCPathEntries()
|
||||
*/
|
||||
@Override
|
||||
public IPathEntry[] getRawPathEntries() throws CModelException {
|
||||
return CoreModel.getRawPathEntries(this);
|
||||
}
|
||||
|
@ -411,6 +424,7 @@ public class CProject extends Openable implements ICProject {
|
|||
/* (non-Javadoc)
|
||||
* @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 {
|
||||
CoreModel.setRawPathEntries(this, newEntries, monitor);
|
||||
}
|
||||
|
@ -418,6 +432,7 @@ public class CProject extends Openable implements ICProject {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICProject#getSourceRoot(org.eclipse.cdt.core.model.ISourceEntry)
|
||||
*/
|
||||
@Override
|
||||
public ISourceRoot getSourceRoot(ISourceEntry entry) throws CModelException {
|
||||
return getSourceRoot(new CSourceEntry(entry.getPath(), entry.getExclusionPatterns(), 0));
|
||||
}
|
||||
|
@ -444,6 +459,7 @@ public class CProject extends Openable implements ICProject {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICProject#findSourceRoot()
|
||||
*/
|
||||
@Override
|
||||
public ISourceRoot findSourceRoot(IResource res) {
|
||||
try {
|
||||
ISourceRoot[] roots = getAllSourceRoots();
|
||||
|
@ -460,6 +476,7 @@ public class CProject extends Openable implements ICProject {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICProject#findSourceRoot()
|
||||
*/
|
||||
@Override
|
||||
public ISourceRoot findSourceRoot(IPath path) {
|
||||
try {
|
||||
ISourceRoot[] roots = getAllSourceRoots();
|
||||
|
@ -472,10 +489,11 @@ public class CProject extends Openable implements ICProject {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICProject#getSourceRoots()
|
||||
*/
|
||||
@Override
|
||||
public ISourceRoot[] getSourceRoots() throws CModelException {
|
||||
Object[] children = getChildren();
|
||||
ArrayList<ISourceRoot> result = new ArrayList<ISourceRoot>(children.length);
|
||||
|
@ -489,10 +507,11 @@ public class CProject extends Openable implements ICProject {
|
|||
|
||||
/**
|
||||
* Get all source roots.
|
||||
*
|
||||
*
|
||||
* @return all source roots
|
||||
* @throws CModelException
|
||||
*/
|
||||
@Override
|
||||
public ISourceRoot[] getAllSourceRoots() throws CModelException {
|
||||
CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this);
|
||||
ISourceRoot[] roots = null;
|
||||
|
@ -510,6 +529,7 @@ public class CProject extends Openable implements ICProject {
|
|||
return roots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOutputEntry[] getOutputEntries() throws CModelException {
|
||||
CProjectInfo pinfo = (CProjectInfo) CModelManager.getDefault().peekAtInfo(this);
|
||||
IOutputEntry[] outs = null;
|
||||
|
@ -528,7 +548,7 @@ public class CProject extends Openable implements ICProject {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public IOutputEntry[] getOutputEntries(IPathEntry[] entries) throws CModelException {
|
||||
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) {
|
||||
IPath path = resource.getFullPath();
|
||||
|
||||
|
||||
// ensure that folders are only excluded if all of their children are excluded
|
||||
if (resource.getType() == IResource.FOLDER || resource.getType() == IResource.PROJECT) {
|
||||
path = path.append("*"); //$NON-NLS-1$
|
||||
|
@ -606,7 +627,7 @@ public class CProject extends Openable implements ICProject {
|
|||
if(cfg != null)
|
||||
entries = cfg.getResolvedSourceEntries();
|
||||
}
|
||||
|
||||
|
||||
if(entries != null){
|
||||
ArrayList<ISourceRoot> list = new ArrayList<ISourceRoot>(entries.length);
|
||||
for (ICSourceEntry sourceEntry : entries) {
|
||||
|
@ -624,14 +645,14 @@ public class CProject extends Openable implements ICProject {
|
|||
List<ISourceRoot> sourceRoots = computeSourceRoots();
|
||||
List<ICContainer> children = new ArrayList<ICContainer>(sourceRoots.size());
|
||||
children.addAll(sourceRoots);
|
||||
|
||||
|
||||
boolean projectIsSourceRoot = false;
|
||||
for (ISourceRoot sourceRoot : sourceRoots)
|
||||
if (sourceRoot.getResource().equals(getProject())) {
|
||||
projectIsSourceRoot = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Now look for output folders
|
||||
try {
|
||||
IResource[] resources = getProject().members();
|
||||
|
@ -644,7 +665,7 @@ public class CProject extends Openable implements ICProject {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
// have already added this.
|
||||
|
@ -655,7 +676,7 @@ public class CProject extends Openable implements ICProject {
|
|||
} catch (CoreException e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
|
||||
info.setChildren(children);
|
||||
if (info instanceof CProjectInfo) {
|
||||
CProjectInfo pinfo = (CProjectInfo)info;
|
||||
|
@ -664,10 +685,11 @@ public class CProject extends Openable implements ICProject {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see ICProject
|
||||
*/
|
||||
@Override
|
||||
public boolean isOnSourceRoot(ICElement element) {
|
||||
try {
|
||||
ISourceRoot[] roots = getSourceRoots();
|
||||
|
@ -685,6 +707,7 @@ public class CProject extends Openable implements ICProject {
|
|||
/*
|
||||
* @see ICProject
|
||||
*/
|
||||
@Override
|
||||
public boolean isOnSourceRoot(IResource resource) {
|
||||
try {
|
||||
ISourceRoot[] roots = getSourceRoots();
|
||||
|
@ -713,6 +736,7 @@ public class CProject extends Openable implements ICProject {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICProject#getNonCResources()
|
||||
*/
|
||||
@Override
|
||||
public Object[] getNonCResources() throws CModelException {
|
||||
return ((CProjectInfo) getElementInfo()).getNonCResources(getResource());
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.eclipse.core.resources.IResourceDelta;
|
|||
/**
|
||||
* In this case, no delta for specific element passed
|
||||
* Instead we'll notify Outline about offsets change.
|
||||
*
|
||||
*
|
||||
* @author Oleg Krasilnikov
|
||||
*/
|
||||
public class CShiftData implements ICElementDelta {
|
||||
|
@ -26,7 +26,7 @@ public class CShiftData implements ICElementDelta {
|
|||
private final int offset;
|
||||
private final int size;
|
||||
private final int lines;
|
||||
|
||||
|
||||
public CShiftData(ICElement element, int offset, int size, int lines) {
|
||||
this.element = element;
|
||||
this.offset = offset;
|
||||
|
@ -37,18 +37,19 @@ public class CShiftData implements ICElementDelta {
|
|||
public int getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
public int getLines() {
|
||||
return lines;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICElementDelta#getAddedChildren()
|
||||
*/
|
||||
@Override
|
||||
public ICElementDelta[] getAddedChildren() {
|
||||
return new ICElementDelta[0];
|
||||
}
|
||||
|
@ -56,6 +57,7 @@ public class CShiftData implements ICElementDelta {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICElementDelta#getAffectedChildren()
|
||||
*/
|
||||
@Override
|
||||
public ICElementDelta[] getAffectedChildren() {
|
||||
return new ICElementDelta[0];
|
||||
}
|
||||
|
@ -63,6 +65,7 @@ public class CShiftData implements ICElementDelta {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICElementDelta#getChangedChildren()
|
||||
*/
|
||||
@Override
|
||||
public ICElementDelta[] getChangedChildren() {
|
||||
return new ICElementDelta[0];
|
||||
}
|
||||
|
@ -70,6 +73,7 @@ public class CShiftData implements ICElementDelta {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICElementDelta#getElement()
|
||||
*/
|
||||
@Override
|
||||
public ICElement getElement() {
|
||||
return element;
|
||||
}
|
||||
|
@ -77,6 +81,7 @@ public class CShiftData implements ICElementDelta {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICElementDelta#getFlags()
|
||||
*/
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return 0;
|
||||
}
|
||||
|
@ -84,6 +89,7 @@ public class CShiftData implements ICElementDelta {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICElementDelta#getKind()
|
||||
*/
|
||||
@Override
|
||||
public int getKind() {
|
||||
return 0;
|
||||
}
|
||||
|
@ -91,6 +97,7 @@ public class CShiftData implements ICElementDelta {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICElementDelta#getMovedFromElement()
|
||||
*/
|
||||
@Override
|
||||
public ICElement getMovedFromElement() {
|
||||
return null;
|
||||
}
|
||||
|
@ -98,6 +105,7 @@ public class CShiftData implements ICElementDelta {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICElementDelta#getMovedToElement()
|
||||
*/
|
||||
@Override
|
||||
public ICElement getMovedToElement() {
|
||||
return null;
|
||||
}
|
||||
|
@ -105,6 +113,7 @@ public class CShiftData implements ICElementDelta {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICElementDelta#getRemovedChildren()
|
||||
*/
|
||||
@Override
|
||||
public ICElementDelta[] getRemovedChildren() {
|
||||
return new ICElementDelta[0];
|
||||
}
|
||||
|
@ -112,6 +121,7 @@ public class CShiftData implements ICElementDelta {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICElementDelta#getResourceDeltas()
|
||||
*/
|
||||
@Override
|
||||
public IResourceDelta[] getResourceDeltas() {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -72,9 +72,9 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
|||
|
||||
List<IPathEntryStoreListener> listeners;
|
||||
IProject fProject;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public DefaultPathEntryStore(IProject project) {
|
||||
fProject = project;
|
||||
|
@ -84,6 +84,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
|||
CCorePlugin.getDefault().getCDescriptorManager().addDescriptorListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPathEntry[] getRawPathEntries() throws CoreException {
|
||||
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(fProject, false);
|
||||
if (cdesc != null) {
|
||||
|
@ -91,17 +92,18 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
|||
ICStorageElement entry = cdesc.getProjectStorageElement(PATH_ENTRY_ID);
|
||||
for (ICStorageElement childNode : entry.getChildrenByName(PATH_ENTRY))
|
||||
pathEntries.add(decodePathEntry(fProject, childNode));
|
||||
IPathEntry[] entries = new IPathEntry[pathEntries.size()];
|
||||
IPathEntry[] entries = new IPathEntry[pathEntries.size()];
|
||||
pathEntries.toArray(entries);
|
||||
return entries;
|
||||
}
|
||||
return NO_PATHENTRIES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRawPathEntries(IPathEntry[] newRawEntries) throws CoreException {
|
||||
if (Arrays.equals(newRawEntries, getRawPathEntries())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
||||
ICStorageElement rootElement = descriptor.getProjectStorageElement(PATH_ENTRY_ID);
|
||||
// Clear out all current children
|
||||
|
@ -116,11 +118,11 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
|||
|
||||
static IPathEntry decodePathEntry(IProject project, ICStorageElement element) throws CModelException {
|
||||
IPath projectPath = project.getFullPath();
|
||||
|
||||
|
||||
// kind
|
||||
String kindAttr = element.getAttribute(ATTRIBUTE_KIND);
|
||||
int kind = PathEntry.kindFromString(kindAttr);
|
||||
|
||||
|
||||
// exported flag
|
||||
boolean isExported = false;
|
||||
if (element.hasAttribute(ATTRIBUTE_EXPORTED)) {
|
||||
|
@ -157,13 +159,13 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// recreate the entry
|
||||
switch (kind) {
|
||||
case IPathEntry.CDT_PROJECT :
|
||||
return CoreModel.newProjectEntry(path, isExported);
|
||||
case IPathEntry.CDT_LIBRARY : {
|
||||
IPath libraryPath = new Path(element.getAttribute(ATTRIBUTE_LIBRARY));
|
||||
IPath libraryPath = new Path(element.getAttribute(ATTRIBUTE_LIBRARY));
|
||||
// source attachment info (optional)
|
||||
IPath sourceAttachmentPath = element.hasAttribute(ATTRIBUTE_SOURCEPATH) ? new Path(
|
||||
element.getAttribute(ATTRIBUTE_SOURCEPATH)) : null;
|
||||
|
@ -171,7 +173,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
|||
element.getAttribute(ATTRIBUTE_ROOTPATH)) : null;
|
||||
IPath sourceAttachmentPrefixMapping = element.hasAttribute(ATTRIBUTE_PREFIXMAPPING) ? new Path(
|
||||
element.getAttribute(ATTRIBUTE_PREFIXMAPPING)) : null;
|
||||
|
||||
|
||||
if (!baseRef.isEmpty()) {
|
||||
return CoreModel.newLibraryRefEntry(path, baseRef, libraryPath);
|
||||
}
|
||||
|
@ -207,7 +209,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
|||
case IPathEntry.CDT_INCLUDE_FILE: {
|
||||
// include path info
|
||||
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 : {
|
||||
String macroName = element.getAttribute(ATTRIBUTE_NAME);
|
||||
|
@ -276,7 +278,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
|||
element.setAttribute(ATTRIBUTE_LIBRARY, libraryPath.toString());
|
||||
IPath sourcePath = lib.getSourceAttachmentPath();
|
||||
if (sourcePath != null) {
|
||||
// translate to project relative from absolute
|
||||
// translate to project relative from absolute
|
||||
if (projectPath != null && projectPath.isPrefixOf(sourcePath)) {
|
||||
if (sourcePath.segment(0).equals(projectPath.segment(0))) {
|
||||
sourcePath = sourcePath.removeFirstSegments(1);
|
||||
|
@ -356,9 +358,10 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.eclipse.cdt.core.ICDescriptorListener#descriptorChanged(org.eclipse.cdt.core.CDescriptorEvent)
|
||||
*/
|
||||
@Override
|
||||
public void descriptorChanged(CDescriptorEvent event) {
|
||||
if (event.getType() == CDescriptorEvent.CDTPROJECT_CHANGED
|
||||
/*|| event.getType() == CDescriptorEvent.CDTPROJECT_ADDED*/) {
|
||||
|
@ -373,13 +376,15 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
|||
/* (non-Javadoc)
|
||||
* @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);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.resources.IPathEntryStore#removePathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener)
|
||||
*/
|
||||
@Override
|
||||
public void removePathEntryStoreListener(IPathEntryStoreListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
@ -396,6 +401,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.resources.IPathEntryStore#fireClosedChangedEvent(IProject)
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, fProject, PathEntryStoreChangedEvent.STORE_CLOSED);
|
||||
IPathEntryStoreListener[] observers = new IPathEntryStoreListener[listeners.size()];
|
||||
|
@ -406,14 +412,17 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
|||
CCorePlugin.getDefault().getCDescriptorManager().removeDescriptorListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IProject getProject() {
|
||||
return fProject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICExtensionReference getExtensionReference() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICConfigExtensionReference getConfigExtensionReference() {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.eclipse.cdt.core.model.IEnumeration;
|
|||
public class Enumeration extends SourceManipulation implements IEnumeration{
|
||||
|
||||
public Enumeration(ICElement parent, String name) {
|
||||
super(parent, name, ICElement.C_ENUMERATION);
|
||||
super(parent, name, ICElement.C_ENUMERATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,6 +34,7 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.IVariableDeclaration#getTypeName()
|
||||
*/
|
||||
@Override
|
||||
public String getTypeName() throws CModelException {
|
||||
return getEnumerationInfo().getTypeName();
|
||||
}
|
||||
|
@ -48,6 +49,7 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.IDeclaration#isConst()
|
||||
*/
|
||||
@Override
|
||||
public boolean isConst() throws CModelException {
|
||||
return getEnumerationInfo().isConst();
|
||||
}
|
||||
|
@ -55,6 +57,7 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.IDeclaration#isStatic()
|
||||
*/
|
||||
@Override
|
||||
public boolean isStatic() throws CModelException {
|
||||
return getEnumerationInfo().isStatic();
|
||||
}
|
||||
|
@ -62,6 +65,7 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.IDeclaration#isVolatile()
|
||||
*/
|
||||
@Override
|
||||
public boolean isVolatile() throws CModelException {
|
||||
return getEnumerationInfo().isVolatile();
|
||||
}
|
||||
|
@ -88,6 +92,6 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
|
|||
*/
|
||||
public void setVolatile(boolean isVolatile) throws CModelException {
|
||||
getEnumerationInfo().setVolatile(isVolatile);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,19 +16,20 @@ import org.eclipse.cdt.core.model.IEnumerator;
|
|||
public class Enumerator extends SourceManipulation implements IEnumerator{
|
||||
|
||||
String constantExpression = ""; //$NON-NLS-1$
|
||||
|
||||
|
||||
public Enumerator(ICElement parent, String name) {
|
||||
super(parent, name, ICElement.C_ENUMERATOR);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected CElementInfo createElementInfo () {
|
||||
return new SourceManipulationInfo(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.IEnumerator#getConstantExpression()
|
||||
*/
|
||||
@Override
|
||||
public String getConstantExpression() {
|
||||
return constantExpression;
|
||||
}
|
||||
|
|
|
@ -17,11 +17,12 @@ import org.eclipse.cdt.core.model.IField;
|
|||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
|
||||
public class Field extends VariableDeclaration implements IField {
|
||||
|
||||
|
||||
public Field(ICElement parent, String name) {
|
||||
super(parent, name, ICElement.C_FIELD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMutable() throws CModelException{
|
||||
return getFieldInfo().isMutable();
|
||||
}
|
||||
|
@ -70,6 +71,7 @@ public class Field extends VariableDeclaration implements IField {
|
|||
getFieldInfo().setStatic(isStatic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTAccessVisibility getVisibility() throws CModelException {
|
||||
return getFieldInfo().getVisibility();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.cdt.core.model.IFunctionDeclaration;
|
|||
public class FunctionDeclaration extends SourceManipulation implements IFunctionDeclaration {
|
||||
protected String[] fParameterTypes;
|
||||
protected String returnType;
|
||||
|
||||
|
||||
public FunctionDeclaration(ICElement parent, String name) {
|
||||
super(parent, name, ICElement.C_FUNCTION_DECLARATION);
|
||||
fParameterTypes= fgEmptyStrings;
|
||||
|
@ -31,6 +31,7 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
|
|||
fParameterTypes= fgEmptyStrings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReturnType(){
|
||||
if (returnType != null) {
|
||||
return returnType;
|
||||
|
@ -42,22 +43,25 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
|
|||
returnType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfParameters() {
|
||||
return fParameterTypes == null ? 0 : fParameterTypes.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getParameterTypes() {
|
||||
return fParameterTypes;
|
||||
}
|
||||
|
||||
|
||||
public void setParameterTypes(String[] parameterTypes) {
|
||||
fParameterTypes = parameterTypes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSignature() throws CModelException{
|
||||
return getSignature(this);
|
||||
}
|
||||
|
||||
|
||||
public static String getSignature(IFunctionDeclaration func) {
|
||||
StringBuffer sig = new StringBuffer(func.getElementName());
|
||||
sig.append(getParameterClause(func.getParameterTypes()));
|
||||
|
@ -68,17 +72,17 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
|
|||
sig.append(" volatile"); //$NON-NLS-1$
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
}
|
||||
}
|
||||
return sig.toString();
|
||||
}
|
||||
|
||||
|
||||
public String getParameterClause() {
|
||||
return getParameterClause(getParameterTypes());
|
||||
}
|
||||
|
||||
|
||||
public static String getParameterClause(String[] paramTypes){
|
||||
StringBuffer sig = new StringBuffer();
|
||||
|
||||
|
||||
if(paramTypes.length > 0){
|
||||
sig.append("("); //$NON-NLS-1$
|
||||
int i = 0;
|
||||
|
@ -92,13 +96,15 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
|
|||
else{
|
||||
sig.append("()"); //$NON-NLS-1$
|
||||
}
|
||||
return sig.toString();
|
||||
return sig.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getParameterInitializer(int pos) {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String[] getExceptions(){
|
||||
return new String[] {};
|
||||
}
|
||||
|
@ -107,11 +113,11 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
|
|||
protected CElementInfo createElementInfo () {
|
||||
return new FunctionInfo(this);
|
||||
}
|
||||
|
||||
|
||||
protected FunctionInfo getFunctionInfo() throws CModelException{
|
||||
return (FunctionInfo) getElementInfo();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other instanceof IFunctionDeclaration) {
|
||||
|
@ -119,17 +125,18 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static boolean equals(IFunctionDeclaration lhs, IFunctionDeclaration rhs) {
|
||||
return CElement.equals(lhs, rhs) &&
|
||||
return CElement.equals(lhs, rhs) &&
|
||||
Util.equalArraysOrNull(lhs.getParameterTypes(), rhs.getParameterTypes()) &&
|
||||
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()
|
||||
*/
|
||||
@Override
|
||||
public boolean isConst() throws CModelException{
|
||||
return getFunctionInfo().isConst();
|
||||
}
|
||||
|
@ -142,6 +149,7 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
|
|||
* Returns the isStatic.
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean isStatic() throws CModelException {
|
||||
return getFunctionInfo().isStatic();
|
||||
}
|
||||
|
@ -150,6 +158,7 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
|
|||
* Returns the isVolatile.
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean isVolatile() throws CModelException {
|
||||
return getFunctionInfo().isVolatile();
|
||||
}
|
||||
|
|
|
@ -16,23 +16,25 @@ import org.eclipse.cdt.core.model.ICElement;
|
|||
import org.eclipse.cdt.core.model.IFunctionTemplate;
|
||||
|
||||
public class FunctionTemplate extends Function implements IFunctionTemplate {
|
||||
|
||||
|
||||
protected Template fTemplate;
|
||||
|
||||
|
||||
public FunctionTemplate(ICElement parent, String name) {
|
||||
super(parent, name, ICElement.C_TEMPLATE_FUNCTION);
|
||||
fTemplate = new Template(name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the parameterTypes.
|
||||
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes()
|
||||
* @return String[]
|
||||
*/
|
||||
@Override
|
||||
public String[] getTemplateParameterTypes() {
|
||||
return fTemplate.getTemplateParameterTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTemplateArguments() {
|
||||
return fTemplate.getTemplateArguments();
|
||||
}
|
||||
|
@ -47,6 +49,7 @@ public class FunctionTemplate extends Function implements IFunctionTemplate {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
|
||||
*/
|
||||
@Override
|
||||
public int getNumberOfTemplateParameters() {
|
||||
return fTemplate.getNumberOfTemplateParameters();
|
||||
}
|
||||
|
@ -55,13 +58,14 @@ public class FunctionTemplate extends Function implements IFunctionTemplate {
|
|||
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
|
||||
*/
|
||||
/*
|
||||
* The signature in the outline view will be:
|
||||
* The class X followed by its template parameters,
|
||||
* then the scope resolution, then the function name,
|
||||
* followed by its template parameters, folowed by its
|
||||
* normal parameter list, then a colon then the function's
|
||||
* The signature in the outline view will be:
|
||||
* The class X followed by its template parameters,
|
||||
* then the scope resolution, then the function name,
|
||||
* followed by its template parameters, folowed by its
|
||||
* normal parameter list, then a colon then the function's
|
||||
* return type.
|
||||
*/
|
||||
*/
|
||||
@Override
|
||||
public String getTemplateSignature() throws CModelException {
|
||||
StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature());
|
||||
sig.append(this.getParameterClause());
|
||||
|
@ -71,7 +75,7 @@ public class FunctionTemplate extends Function implements IFunctionTemplate {
|
|||
if (isVolatile()) {
|
||||
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(this.getReturnType());
|
||||
}
|
||||
|
|
|
@ -24,14 +24,17 @@ public class FunctionTemplateDeclaration extends FunctionDeclaration implements
|
|||
fTemplate = new Template(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTemplateParameterTypes() {
|
||||
return fTemplate.getTemplateParameterTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTemplateArguments() {
|
||||
return fTemplate.getTemplateArguments();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateSignature() throws CModelException {
|
||||
StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature());
|
||||
sig.append(this.getParameterClause());
|
||||
|
@ -40,14 +43,15 @@ public class FunctionTemplateDeclaration extends FunctionDeclaration implements
|
|||
if(isVolatile())
|
||||
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(this.getReturnType());
|
||||
}
|
||||
|
||||
|
||||
return sig.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfTemplateParameters() {
|
||||
return fTemplate.getNumberOfTemplateParameters();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.eclipse.cdt.core.model.ICElement;
|
|||
import org.eclipse.cdt.core.model.IInclude;
|
||||
|
||||
public class Include extends SourceManipulation implements IInclude {
|
||||
|
||||
|
||||
private String fullPath;
|
||||
private final boolean standard;
|
||||
private boolean fIsResolved= true;
|
||||
|
@ -26,10 +26,12 @@ public class Include extends SourceManipulation implements IInclude {
|
|||
standard = isStandard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIncludeName() {
|
||||
return getElementName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStandard() {
|
||||
return standard;
|
||||
}
|
||||
|
@ -37,6 +39,7 @@ public class Include extends SourceManipulation implements IInclude {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IInclude#getFullFileName()
|
||||
*/
|
||||
@Override
|
||||
public String getFullFileName() {
|
||||
return fullPath;
|
||||
}
|
||||
|
@ -44,6 +47,7 @@ public class Include extends SourceManipulation implements IInclude {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IInclude#isLocal()
|
||||
*/
|
||||
@Override
|
||||
public boolean isLocal() {
|
||||
return !isStandard();
|
||||
}
|
||||
|
@ -63,6 +67,7 @@ public class Include extends SourceManipulation implements IInclude {
|
|||
/*
|
||||
* @see org.eclipse.cdt.core.model.IInclude#isResolved()
|
||||
*/
|
||||
@Override
|
||||
public boolean isResolved() {
|
||||
return fIsResolved;
|
||||
}
|
||||
|
@ -77,13 +82,13 @@ public class Include extends SourceManipulation implements IInclude {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static boolean equals(IInclude lhs, IInclude rhs) {
|
||||
return CElement.equals(lhs, rhs)
|
||||
&& lhs.isActive() == rhs.isActive()
|
||||
&& lhs.isActive() == rhs.isActive()
|
||||
&& lhs.isResolved() == rhs.isResolved()
|
||||
&& lhs.isLocal() == rhs.isLocal()
|
||||
&& (lhs.getFullFileName() == rhs.getFullFileName()
|
||||
&& (lhs.getFullFileName() == rhs.getFullFileName()
|
||||
|| lhs.getFullFileName() != null && lhs.getFullFileName().equals(rhs.getFullFileName()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,18 +33,20 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry {
|
|||
|
||||
/**
|
||||
* Returns the include path
|
||||
*
|
||||
*
|
||||
* @return IPath
|
||||
*/
|
||||
@Override
|
||||
public IPath getIncludePath() {
|
||||
return includePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not it a system include path
|
||||
*
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean isSystemInclude() {
|
||||
return isSystemInclude;
|
||||
}
|
||||
|
@ -95,6 +97,7 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IIncludeEntry#getFullIncludePath()
|
||||
*/
|
||||
@Override
|
||||
public IPath getFullIncludePath() {
|
||||
final IPath inc = getIncludePath();
|
||||
if (!basePath.isEmpty()) {
|
||||
|
@ -110,7 +113,7 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry {
|
|||
}
|
||||
return loc.append(inc);
|
||||
}
|
||||
|
||||
|
||||
if (!inc.isAbsolute()) {
|
||||
IPath resPath = getPath();
|
||||
IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(resPath.append(inc));
|
||||
|
|
|
@ -33,9 +33,10 @@ public class IncludeFileEntry extends APathEntry implements IIncludeFileEntry {
|
|||
|
||||
/**
|
||||
* Returns the include path
|
||||
*
|
||||
*
|
||||
* @return IPath
|
||||
*/
|
||||
@Override
|
||||
public IPath getIncludeFilePath() {
|
||||
return includeFilePath;
|
||||
}
|
||||
|
@ -83,6 +84,7 @@ public class IncludeFileEntry extends APathEntry implements IIncludeFileEntry {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IIncludeEntry#getFullIncludePath()
|
||||
*/
|
||||
@Override
|
||||
public IPath getFullIncludeFilePath() {
|
||||
final IPath inc = getIncludeFilePath();
|
||||
if (!basePath.isEmpty()) {
|
||||
|
@ -98,7 +100,7 @@ public class IncludeFileEntry extends APathEntry implements IIncludeFileEntry {
|
|||
}
|
||||
return loc.append(inc);
|
||||
}
|
||||
|
||||
|
||||
if (!inc.isAbsolute()) {
|
||||
IPath resPath = getPath();
|
||||
IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(resPath.append(inc));
|
||||
|
|
|
@ -41,7 +41,7 @@ import org.eclipse.core.runtime.Path;
|
|||
* IncludeReference
|
||||
*/
|
||||
public class IncludeReference extends Openable implements IIncludeReference {
|
||||
|
||||
|
||||
final IIncludeEntry fIncludeEntry;
|
||||
final IPath fPath;
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
|||
}
|
||||
return file != null && file.isDirectory();
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.model.CElement#createElementInfo()
|
||||
*/
|
||||
|
@ -88,6 +88,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IIncludeReference#getIncludeEntry()
|
||||
*/
|
||||
@Override
|
||||
public IIncludeEntry getIncludeEntry() {
|
||||
return fIncludeEntry;
|
||||
}
|
||||
|
@ -103,6 +104,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IIncludeReference#getAffectedPath()
|
||||
*/
|
||||
@Override
|
||||
public IPath getAffectedPath() {
|
||||
return fIncludeEntry.getPath();
|
||||
}
|
||||
|
@ -124,7 +126,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
|||
String[] names = null;
|
||||
if (file != null && file.isDirectory()) {
|
||||
names = file.list();
|
||||
|
||||
|
||||
if (names != null) {
|
||||
IPath path = new Path(file.getAbsolutePath());
|
||||
for (String name : names) {
|
||||
|
@ -175,8 +177,9 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IIncludeReference#isOnIncludeEntry(org.eclipse.core.runtime.IPath)
|
||||
*/
|
||||
@Override
|
||||
public boolean isOnIncludeEntry(IPath path) {
|
||||
if (fIncludeEntry.getFullIncludePath().isPrefixOf(path)
|
||||
if (fIncludeEntry.getFullIncludePath().isPrefixOf(path)
|
||||
&& !CoreModelUtil.isExcluded(path, fIncludeEntry.fullExclusionPatternChars())) {
|
||||
return true;
|
||||
}
|
||||
|
@ -190,7 +193,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
|||
public IPath getPath() {
|
||||
return fPath;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ICElement getHandleFromMemento(String token, MementoTokenizer memento) {
|
||||
return null;
|
||||
|
|
|
@ -31,19 +31,22 @@ public class LanguageDescriptor extends CExtensionDescriptor implements
|
|||
private String fContentTypeIds[];
|
||||
private String fId;
|
||||
private IContentType[] fContentTypes;
|
||||
|
||||
|
||||
|
||||
public LanguageDescriptor(IConfigurationElement el) {
|
||||
super(el);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILanguage getLanguage() {
|
||||
if(fLanguage == null){
|
||||
SafeRunner.run(new ISafeRunnable(){
|
||||
@Override
|
||||
public void handleException(Throwable exception) {
|
||||
CCorePlugin.log(exception);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
fLanguage = (ILanguage)getConfigurationElement().createExecutableExtension(ATTRIBUTE_CLASS);
|
||||
}
|
||||
|
@ -52,13 +55,14 @@ public class LanguageDescriptor extends CExtensionDescriptor implements
|
|||
return fLanguage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getContentTypeIds() {
|
||||
if(fContentTypeIds == null){
|
||||
fContentTypeIds = calculateCintentTypeIds();
|
||||
}
|
||||
return fContentTypeIds;
|
||||
}
|
||||
|
||||
|
||||
private String[] calculateCintentTypeIds(){
|
||||
IConfigurationElement el = getConfigurationElement();
|
||||
IConfigurationElement children[] = el.getChildren();
|
||||
|
@ -80,10 +84,10 @@ public class LanguageDescriptor extends CExtensionDescriptor implements
|
|||
ids = t;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ids;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getId(){
|
||||
if(fId == null)
|
||||
|
@ -91,26 +95,27 @@ public class LanguageDescriptor extends CExtensionDescriptor implements
|
|||
return fId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IContentType[] getContentTypes() {
|
||||
if(fContentTypes == null){
|
||||
fContentTypes = calculateContentTypes(getContentTypeIds());
|
||||
}
|
||||
return fContentTypes;
|
||||
}
|
||||
|
||||
|
||||
private IContentType[] calculateContentTypes(String ids[]){
|
||||
IContentType cTypes[] = new IContentType[ids.length];
|
||||
|
||||
if(ids.length > 0){
|
||||
int num = 0;
|
||||
IContentTypeManager manager = Platform.getContentTypeManager();
|
||||
|
||||
IContentTypeManager manager = Platform.getContentTypeManager();
|
||||
|
||||
for (int k = 0; k < ids.length; ++k) {
|
||||
IContentType langContType = manager.getContentType(ids[k]);
|
||||
if(langContType != null)
|
||||
cTypes[num++] = langContType;
|
||||
}
|
||||
|
||||
|
||||
if(num < ids.length){
|
||||
IContentType tmp[] = new IContentType[num];
|
||||
System.arraycopy(cTypes, 0, tmp, 0, num);
|
||||
|
|
|
@ -25,7 +25,7 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry {
|
|||
IPath sourceAttachmentPrefixMapping;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param basePath
|
||||
* @param baseRef
|
||||
* @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
|
||||
*/
|
||||
@Override
|
||||
public IPath getSourceAttachmentPath() {
|
||||
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
|
||||
* not applicable
|
||||
*/
|
||||
@Override
|
||||
public IPath getSourceAttachmentRootPath() {
|
||||
return sourceAttachmentRootPath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -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
|
||||
* not applicable
|
||||
*/
|
||||
@Override
|
||||
public IPath getSourceAttachmentPrefixMapping() {
|
||||
return sourceAttachmentPrefixMapping;
|
||||
}
|
||||
|
@ -143,6 +146,7 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry {
|
|||
return super.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPath getFullLibraryPath() {
|
||||
IPath p;
|
||||
IPath lib = getLibraryPath();
|
||||
|
@ -178,6 +182,7 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ILibraryEntry#getLibraryPath()
|
||||
*/
|
||||
@Override
|
||||
public IPath getLibraryPath() {
|
||||
return libraryPath;
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ public class LibraryReference extends Parent implements ILibraryReference {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ILibraryReference#getLibraryEntry()
|
||||
*/
|
||||
@Override
|
||||
public ILibraryEntry getLibraryEntry() {
|
||||
return entry;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class LibraryReferenceArchive extends Archive implements ILibraryReferenc
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ICElement#getPath()
|
||||
|
@ -64,6 +64,7 @@ public class LibraryReferenceArchive extends Archive implements ILibraryReferenc
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ILibraryReference#getLibraryEntry()
|
||||
*/
|
||||
@Override
|
||||
public ILibraryEntry getLibraryEntry() {
|
||||
return entry;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* QNX Software Systems - Initial API and implementation
|
||||
* 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
|
||||
* /
|
||||
*******************************************************************************/
|
||||
|
@ -79,6 +79,7 @@ public class LibraryReferenceShared extends Binary implements ILibraryReference
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ILibraryReference#getLibraryEntry()
|
||||
*/
|
||||
@Override
|
||||
public ILibraryEntry getLibraryEntry() {
|
||||
return entry;
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@ import org.eclipse.cdt.core.model.ICElement;
|
|||
import org.eclipse.cdt.core.model.IMacro;
|
||||
|
||||
public class Macro extends SourceManipulation implements IMacro {
|
||||
|
||||
|
||||
private boolean fFunctionStyle = false;
|
||||
|
||||
|
||||
public void setFunctionStyle(boolean isFunctionStyle) {
|
||||
this.fFunctionStyle = isFunctionStyle;
|
||||
}
|
||||
|
@ -26,10 +26,12 @@ public class Macro extends SourceManipulation implements IMacro {
|
|||
super(parent, name, ICElement.C_MACRO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifierList() {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTokenSequence() {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
@ -39,6 +41,7 @@ public class Macro extends SourceManipulation implements IMacro {
|
|||
return new SourceManipulationInfo(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFunctionStyle() {
|
||||
return fFunctionStyle;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public class MacroEntry extends APathEntry implements IMacroEntry {
|
|||
* Returns the macro name.
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
public String getMacroName() {
|
||||
return macroName;
|
||||
}
|
||||
|
@ -40,6 +41,7 @@ public class MacroEntry extends APathEntry implements IMacroEntry {
|
|||
* Returns the macro value.
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
public String getMacroValue() {
|
||||
return macroValue;
|
||||
}
|
||||
|
@ -84,7 +86,7 @@ public class MacroEntry extends APathEntry implements IMacroEntry {
|
|||
}
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
|
|
|
@ -32,9 +32,10 @@ public class MacroFileEntry extends APathEntry implements IMacroFileEntry {
|
|||
|
||||
/**
|
||||
* Returns the macro file path
|
||||
*
|
||||
*
|
||||
* @return IPath
|
||||
*/
|
||||
@Override
|
||||
public IPath getMacroFilePath() {
|
||||
return macroFilePath;
|
||||
}
|
||||
|
@ -81,6 +82,7 @@ public class MacroFileEntry extends APathEntry implements IMacroFileEntry {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IIncludeEntry#getFullIncludePath()
|
||||
*/
|
||||
@Override
|
||||
public IPath getFullMacroFilePath() {
|
||||
IPath p;
|
||||
IPath inc = getMacroFilePath();
|
||||
|
@ -95,7 +97,7 @@ public class MacroFileEntry extends APathEntry implements IMacroFileEntry {
|
|||
p = loc.append(inc);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
p = inc;
|
||||
|
||||
if (!p.isAbsolute()) {
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.eclipse.cdt.core.model.IMethodDeclaration;
|
|||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
|
||||
public class MethodDeclaration extends FunctionDeclaration implements IMethodDeclaration{
|
||||
|
||||
|
||||
boolean isConst = false;
|
||||
boolean isConstructor = false;
|
||||
boolean isDestructor = false;
|
||||
|
@ -31,11 +31,13 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
|
|||
public MethodDeclaration(ICElement parent, String name, int type){
|
||||
super(parent, name, type);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isConstructor(){
|
||||
return isConstructor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDestructor() {
|
||||
return isDestructor;
|
||||
}
|
||||
|
@ -48,10 +50,12 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
|
|||
this.isDestructor = isDestructor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOperator(){
|
||||
return getElementName().startsWith("operator"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPureVirtual() throws CModelException{
|
||||
return getMethodInfo().isPureVirtual();
|
||||
}
|
||||
|
@ -60,6 +64,7 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
|
|||
getMethodInfo().setPureVirtual(isPureVirtual);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInline() throws CModelException{
|
||||
return getMethodInfo().isInline();
|
||||
}
|
||||
|
@ -68,6 +73,7 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
|
|||
getMethodInfo().setInline(isInline);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVirtual() throws CModelException{
|
||||
return getMethodInfo().isVirtual();
|
||||
}
|
||||
|
@ -76,6 +82,7 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
|
|||
getMethodInfo().setVirtual(isVirtual);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFriend() throws CModelException{
|
||||
return getMethodInfo().isFriend();
|
||||
}
|
||||
|
@ -94,23 +101,24 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
|
|||
this.isConst = isConst;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTAccessVisibility getVisibility() throws CModelException{
|
||||
return getMethodInfo().getVisibility();
|
||||
}
|
||||
|
||||
|
||||
public void setVisibility(ASTAccessVisibility visibility) throws CModelException{
|
||||
getMethodInfo().setVisibility(visibility);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected CElementInfo createElementInfo () {
|
||||
return new MethodInfo(this);
|
||||
}
|
||||
|
||||
|
||||
protected MethodInfo getMethodInfo() throws CModelException{
|
||||
return (MethodInfo) getElementInfo();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other instanceof IMethodDeclaration) {
|
||||
|
@ -127,6 +135,6 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -18,21 +18,23 @@ import org.eclipse.cdt.core.model.IMethodTemplate;
|
|||
public class MethodTemplate extends Method implements IMethodTemplate {
|
||||
|
||||
protected Template fTemplate;
|
||||
|
||||
|
||||
public MethodTemplate(ICElement parent, String name) {
|
||||
super(parent, name, ICElement.C_TEMPLATE_METHOD);
|
||||
fTemplate = new Template(name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the parameterTypes.
|
||||
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes()
|
||||
* @return String[]
|
||||
*/
|
||||
@Override
|
||||
public String[] getTemplateParameterTypes() {
|
||||
return fTemplate.getTemplateParameterTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTemplateArguments() {
|
||||
return fTemplate.getTemplateArguments();
|
||||
}
|
||||
|
@ -48,22 +50,24 @@ public class MethodTemplate extends Method implements IMethodTemplate {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
|
||||
*/
|
||||
@Override
|
||||
public int getNumberOfTemplateParameters() {
|
||||
return fTemplate.getNumberOfTemplateParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
|
||||
*/
|
||||
*/
|
||||
/*
|
||||
* The signature in the outline view will be:
|
||||
* The class X followed by its template parameters,
|
||||
* then the scope resolution, then the function name,
|
||||
* followed by its template parameters, folowed by its
|
||||
* normal parameter list, then a colon then the function's
|
||||
* The signature in the outline view will be:
|
||||
* The class X followed by its template parameters,
|
||||
* then the scope resolution, then the function name,
|
||||
* followed by its template parameters, folowed by its
|
||||
* normal parameter list, then a colon then the function's
|
||||
* return type.
|
||||
*/
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String getTemplateSignature() throws CModelException {
|
||||
StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature());
|
||||
sig.append(this.getParameterClause());
|
||||
|
@ -72,11 +76,11 @@ public class MethodTemplate extends Method implements IMethodTemplate {
|
|||
if(isVolatile())
|
||||
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(this.getReturnType());
|
||||
}
|
||||
|
||||
|
||||
return sig.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,14 +24,17 @@ public class MethodTemplateDeclaration extends MethodDeclaration implements IMet
|
|||
fTemplate = new Template(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTemplateParameterTypes() {
|
||||
return fTemplate.getTemplateParameterTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTemplateArguments() {
|
||||
return fTemplate.getTemplateArguments();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateSignature() throws CModelException {
|
||||
StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature());
|
||||
sig.append(this.getParameterClause());
|
||||
|
@ -40,15 +43,16 @@ public class MethodTemplateDeclaration extends MethodDeclaration implements IMet
|
|||
if(isVolatile())
|
||||
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(this.getReturnType());
|
||||
}
|
||||
|
||||
|
||||
return sig.toString();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfTemplateParameters() {
|
||||
return fTemplate.getNumberOfTemplateParameters();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ public class Namespace extends SourceManipulation implements INamespace{
|
|||
* Returns the typeName.
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ public class NullBinaryParser extends PlatformObject implements IBinaryParser {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.IBinaryParser#getBinary(org.eclipse.core.runtime.IPath)
|
||||
*/
|
||||
@Override
|
||||
public IBinaryFile getBinary(byte[] data, IPath path) throws IOException {
|
||||
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)
|
||||
* @see org.eclipse.cdt.core.IBinaryParser#getBinary(org.eclipse.core.runtime.IPath)
|
||||
*/
|
||||
@Override
|
||||
public IBinaryFile getBinary(IPath path) throws IOException {
|
||||
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)
|
||||
* @see org.eclipse.cdt.core.IBinaryParser#getFormat()
|
||||
*/
|
||||
@Override
|
||||
public String getFormat() {
|
||||
return CCorePlugin.getResourceString("CoreModel.NullBinaryParser.Null_Format"); //$NON-NLS-1$
|
||||
}
|
||||
|
@ -46,6 +49,7 @@ public class NullBinaryParser extends PlatformObject implements IBinaryParser {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.IBinaryParser#isBinary(byte[], org.eclipse.core.runtime.IPath)
|
||||
*/
|
||||
@Override
|
||||
public boolean isBinary(byte[] array, IPath path) {
|
||||
return false;
|
||||
}
|
||||
|
@ -53,6 +57,7 @@ public class NullBinaryParser extends PlatformObject implements IBinaryParser {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.IBinaryParser#getBufferSize()
|
||||
*/
|
||||
@Override
|
||||
public int getHintBufferSize() {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -27,7 +27,7 @@ import org.eclipse.core.runtime.IPath;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
public abstract class Openable extends Parent implements IOpenable {
|
||||
protected IResource resource;
|
||||
protected IResource resource;
|
||||
|
||||
public Openable(ICElement parent, IPath path, int type) {
|
||||
// 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) {
|
||||
this(parent, resource, resource.getName(), type);
|
||||
}
|
||||
|
||||
|
||||
public Openable(ICElement parent, IResource res, String name, int type) {
|
||||
super(parent, name, type);
|
||||
resource = res;
|
||||
|
@ -57,6 +57,7 @@ public abstract class Openable extends Parent implements IOpenable {
|
|||
*
|
||||
* @see IBufferChangedListener
|
||||
*/
|
||||
@Override
|
||||
public void bufferChanged(BufferChangedEvent event) {
|
||||
if (event.getBuffer().isClosed()) {
|
||||
CModelManager.getDefault().getElementsOutOfSynchWithBuffers().remove(this);
|
||||
|
@ -64,7 +65,7 @@ public abstract class Openable extends Parent implements IOpenable {
|
|||
} else {
|
||||
CModelManager.getDefault().getElementsOutOfSynchWithBuffers().put(this, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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()
|
||||
*/
|
||||
@Override
|
||||
public IBuffer getBuffer() throws CModelException {
|
||||
if (hasBuffer()) {
|
||||
// ensure element is open
|
||||
|
@ -132,7 +134,7 @@ public abstract class Openable extends Parent implements IOpenable {
|
|||
protected BufferManager getBufferManager() {
|
||||
return BufferManager.getDefaultBufferManager();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if this element may have an associated source buffer,
|
||||
* 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()
|
||||
*/
|
||||
@Override
|
||||
public boolean hasUnsavedChanges() throws CModelException{
|
||||
if (isReadOnly() || !isOpen()) {
|
||||
return false;
|
||||
|
@ -165,22 +168,24 @@ public abstract class Openable extends Parent implements IOpenable {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses must override as required.
|
||||
*
|
||||
*
|
||||
* @see org.eclipse.cdt.core.model.IOpenable#isConsistent()
|
||||
*/
|
||||
@Override
|
||||
public boolean isConsistent() throws CModelException {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.IOpenable#isOpen()
|
||||
*/
|
||||
*/
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
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)
|
||||
*/
|
||||
@Override
|
||||
public void makeConsistent(IProgressMonitor pm) throws CModelException {
|
||||
makeConsistent(pm, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void makeConsistent(IProgressMonitor monitor, boolean forced) throws CModelException {
|
||||
// only translation units can be inconsistent
|
||||
// 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)
|
||||
*/
|
||||
@Override
|
||||
public void open(IProgressMonitor pm) throws CModelException {
|
||||
getElementInfo(pm);
|
||||
}
|
||||
|
@ -249,7 +257,7 @@ public abstract class Openable extends Parent implements IOpenable {
|
|||
if (CModelManager.VERBOSE){
|
||||
System.out.println("OPENING Element ("+ Thread.currentThread()+"): " + this); //$NON-NLS-1$//$NON-NLS-2$
|
||||
}
|
||||
|
||||
|
||||
// open the parent if necessary
|
||||
openParent(info, newElements, monitor);
|
||||
if (monitor != null && monitor.isCanceled())
|
||||
|
@ -268,7 +276,7 @@ public abstract class Openable extends Parent implements IOpenable {
|
|||
newElements.remove(this);
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
// remove out of sync buffer for this element
|
||||
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)
|
||||
*/
|
||||
@Override
|
||||
public void save(IProgressMonitor pm, boolean force) throws CModelException {
|
||||
IResource res = getResource();
|
||||
if (res != null) {
|
||||
|
@ -289,7 +298,7 @@ public abstract class Openable extends Parent implements IOpenable {
|
|||
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, this));
|
||||
}
|
||||
IBuffer buf = getBuffer();
|
||||
if (buf != null) {
|
||||
if (buf != null) {
|
||||
buf.save(pm, force);
|
||||
this.makeConsistent(pm); // update the element info of this element
|
||||
}
|
||||
|
|
|
@ -28,27 +28,30 @@ public class PathEntry implements IPathEntry {
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.eclipse.cdt.core.IPathEntry#getEntryKind()
|
||||
*/
|
||||
@Override
|
||||
public IPath getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.eclipse.cdt.core.IPathEntry#getEntryKind()
|
||||
*/
|
||||
@Override
|
||||
public int getEntryKind() {
|
||||
return entryKind;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.eclipse.cdt.core.IPathEntry#isExported()
|
||||
*/
|
||||
@Override
|
||||
public boolean isExported() {
|
||||
return isExported;
|
||||
}
|
||||
|
@ -80,7 +83,7 @@ public class PathEntry implements IPathEntry {
|
|||
}
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the kind from its <code>String</code> form.
|
||||
*/
|
||||
|
|
|
@ -114,7 +114,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
// Synchronized the access of the cache entries.
|
||||
protected Map<ICProject, ArrayList<IPathEntry>> resolvedMap = new Hashtable<ICProject, ArrayList<IPathEntry>>();
|
||||
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
|
||||
private Map<IProject, IPathEntryStore> storeMap = new HashMap<IProject, IPathEntryStore>();
|
||||
|
@ -122,7 +122,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
private static PathEntryManager pathEntryManager;
|
||||
|
||||
protected ConcurrentLinkedQueue<PathEntryProblem> markerProblems = new ConcurrentLinkedQueue<PathEntryProblem>();
|
||||
|
||||
|
||||
//Setting up a generate markers job, it does not get scheduled
|
||||
Job markerTask = new GenerateMarkersJob("PathEntry Marker Job"); //$NON-NLS-1$
|
||||
|
||||
|
@ -132,11 +132,11 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
private class PathEntryProblem {
|
||||
IProject project;
|
||||
ICModelStatus[] problems;
|
||||
|
||||
|
||||
public PathEntryProblem(IProject project, ICModelStatus[] problems) {
|
||||
this.project = project;
|
||||
this.problems = problems;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PathEntryContainerLock implements IPathEntryContainer {
|
||||
|
@ -153,27 +153,30 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getPathEntries()
|
||||
*/
|
||||
@Override
|
||||
public IPathEntry[] getPathEntries() {
|
||||
return NO_PATHENTRIES;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getDescription()
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return new String("Lock container"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getPath()
|
||||
*/
|
||||
@Override
|
||||
public IPath getPath() {
|
||||
return Path.EMPTY;
|
||||
}
|
||||
|
@ -294,8 +297,8 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
|
||||
IMacroEntry[] macros = macroList.toArray(new IMacroEntry[macroList.size()]);
|
||||
macroList.clear();
|
||||
|
||||
// For the macros the closest symbol will override
|
||||
|
||||
// For the macros the closest symbol will override
|
||||
// /projec/src/file.c --> NDEBUG=1
|
||||
// /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
|
||||
// /project/src/file.c --> /usr/local/include
|
||||
// /project --> /usr/include
|
||||
//
|
||||
//
|
||||
// /usr/local/include must come first.
|
||||
//
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
public PathEntryResolveInfo getResolveInfo(ICProject cproject, boolean useCache) throws CModelException{
|
||||
PathEntryResolveInfo info = resolvedInfoMap.get(cproject);
|
||||
if (info == null && useCache){
|
||||
|
@ -450,20 +453,20 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
if (info == null || !useCache || !getResolveInfoValidState(cproject)){
|
||||
Object[] resolved = getResolvedPathEntries(cproject, false, false);
|
||||
if (resolved != null)
|
||||
info = (PathEntryResolveInfo)resolved[1];
|
||||
info = (PathEntryResolveInfo)resolved[1];
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
private void setResolveInfoValidState(ICProject cproject, boolean valid){
|
||||
Object v = valid ? null : Boolean.FALSE;
|
||||
resolveInfoValidState.set(cproject, v);
|
||||
}
|
||||
|
||||
|
||||
private boolean getResolveInfoValidState(ICProject cproject){
|
||||
return resolveInfoValidState.get(cproject) == null;
|
||||
}
|
||||
|
||||
|
||||
protected IPathEntry[] removeCachedResolvedPathEntries(ICProject cproject) {
|
||||
ArrayList<IPathEntry> resolvedListEntries = resolvedMap.remove(cproject);
|
||||
resolvedInfoMap.remove(cproject);
|
||||
|
@ -523,7 +526,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
|
||||
/**
|
||||
* This method will not expand container extending IPathEntryContainerExtension
|
||||
*
|
||||
*
|
||||
* @param cproject
|
||||
* @param generateMarkers
|
||||
* @return
|
||||
|
@ -745,12 +748,14 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
// causing some grief
|
||||
SafeRunner.run(new ISafeRunnable() {
|
||||
|
||||
@Override
|
||||
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$
|
||||
CCorePlugin.log(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
initializer.initialize(containerPath, project);
|
||||
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
|
||||
* identify the registered container initializer.
|
||||
* <p>
|
||||
*
|
||||
*
|
||||
* @param containerID -
|
||||
* a containerID identifying a registered initializer
|
||||
* @return PathEntryContainerInitializer - the registered container
|
||||
|
@ -1011,7 +1016,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
throw new CModelException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Collects path entry errors for each project and generate error markers for these errors
|
||||
* @param project - Project with path entry errors
|
||||
|
@ -1031,7 +1036,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
}
|
||||
|
||||
@Override
|
||||
public IStatus runInWorkspace(IProgressMonitor monitor) {
|
||||
public IStatus runInWorkspace(IProgressMonitor monitor) {
|
||||
while (markerProblems.peek() != null && !monitor.isCanceled()) {
|
||||
PathEntryProblem problem = markerProblems.poll();
|
||||
IProject project = problem.project;
|
||||
|
@ -1044,7 +1049,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
return Status.OK_STATUS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean needDelta(ICProject cproject){
|
||||
try {
|
||||
PathEntryStoreProxy store = (PathEntryStoreProxy)getPathEntryStore(cproject.getProject(), false);
|
||||
|
@ -1172,7 +1177,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
flag = ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE;
|
||||
break;
|
||||
}
|
||||
case IPathEntry.CDT_MACRO: {
|
||||
case IPathEntry.CDT_MACRO: {
|
||||
IMacroEntry macro = (IMacroEntry)entry;
|
||||
IPath path = macro.getPath();
|
||||
celement = CoreModel.getDefault().create(path);
|
||||
|
@ -1286,7 +1291,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
// }
|
||||
// return store;
|
||||
}
|
||||
|
||||
|
||||
// private IPathEntryStore createDefaultStore(IProject project){
|
||||
// if (CProjectDescriptionManager.getInstance().isNewStyleIndexCfg(project)){
|
||||
// return new ConfigBasedPathEntryStore(project);
|
||||
|
@ -1296,9 +1301,10 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.eclipse.cdt.core.resources.IPathEntryStoreListener#pathEntryStoreChanged(org.eclipse.cdt.core.resources.PathEntryChangedEvent)
|
||||
*/
|
||||
@Override
|
||||
public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
|
||||
IProject project = event.getProject();
|
||||
|
||||
|
@ -1329,9 +1335,10 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.eclipse.cdt.core.model.IElementChangedListener#elementChanged(org.eclipse.cdt.core.model.ElementChangedEvent)
|
||||
*/
|
||||
@Override
|
||||
public void elementChanged(ElementChangedEvent event) {
|
||||
try {
|
||||
if (processDelta(event.getDelta()) == true) {
|
||||
|
@ -1369,7 +1376,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
protected boolean processDelta(ICElementDelta delta) throws CModelException {
|
||||
int kind = delta.getKind();
|
||||
ICElement element = delta.getElement();
|
||||
int type = element.getElementType();
|
||||
int type = element.getElementType();
|
||||
|
||||
// handle open, closing and removing of projects
|
||||
if ( type == ICElement.C_PROJECT) {
|
||||
|
@ -1392,11 +1399,11 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
containerRemove(cproject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// project change, traverse children.
|
||||
}
|
||||
}
|
||||
if (element instanceof IWorkingCopy) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1464,7 +1471,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
updatePathEntry.schedule();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ICModelStatus validatePathEntry(ICProject cProject, IPathEntry[] entries) {
|
||||
return PathEntryUtil.validatePathEntry(cProject, entries);
|
||||
}
|
||||
|
|
|
@ -30,12 +30,12 @@ import org.eclipse.core.runtime.CoreException;
|
|||
public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPathEntryStore, IPathEntryStoreListener {
|
||||
private List<IPathEntryStoreListener> fListeners;
|
||||
private IPathEntryStore fStore;
|
||||
|
||||
|
||||
public PathEntryStoreProxy(IProject project){
|
||||
super(project, PathEntryManager.PATHENTRY_STORE_UNIQ_ID);
|
||||
fListeners = Collections.synchronizedList(new ArrayList<IPathEntryStoreListener>());
|
||||
}
|
||||
|
||||
|
||||
public IPathEntryStore getStore(){
|
||||
providerRequested();
|
||||
return fStore;
|
||||
|
@ -43,13 +43,15 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
|
|||
/* (non-Javadoc)
|
||||
* @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);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.resources.IPathEntryStore#removePathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener)
|
||||
*/
|
||||
@Override
|
||||
public void removePathEntryStoreListener(IPathEntryStoreListener listener) {
|
||||
fListeners.remove(listener);
|
||||
}
|
||||
|
@ -58,7 +60,7 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
|
|||
PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, project, PathEntryStoreChangedEvent.CONTENT_CHANGED);
|
||||
notifyListeners(evt);
|
||||
}
|
||||
|
||||
|
||||
private void notifyListeners(PathEntryStoreChangedEvent evt){
|
||||
IPathEntryStoreListener[] observers = new IPathEntryStoreListener[fListeners.size()];
|
||||
fListeners.toArray(observers);
|
||||
|
@ -86,30 +88,35 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
|
|||
return super.getProject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICExtensionReference getExtensionReference() {
|
||||
//TODO: calculate
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICConfigExtensionReference getConfigExtensionReference() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPathEntry[] getRawPathEntries() throws CoreException {
|
||||
providerRequested();
|
||||
return fStore.getRawPathEntries();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRawPathEntries(IPathEntry[] entries) throws CoreException {
|
||||
providerRequested();
|
||||
fStore.setRawPathEntries(entries);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
|
||||
notifyListeners(event);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Object createDefaultProvider(ICConfigurationDescription cfgDes,
|
||||
boolean newStile) {
|
||||
|
@ -148,10 +155,10 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
|
|||
@Override
|
||||
protected boolean doHandleEvent(CProjectDescriptionEvent event) {
|
||||
IPathEntryStore oldStore = fStore;
|
||||
boolean result = super.doHandleEvent(event);
|
||||
boolean result = super.doHandleEvent(event);
|
||||
if(!result)
|
||||
postProcessProviderChange(fStore, oldStore);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,24 +16,25 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
|||
|
||||
/**
|
||||
* A progress monitor accepting a <code>ICancelable</code> object to receive the cancel request.
|
||||
*
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
public class ProgressMonitorAndCanceler extends NullProgressMonitor implements ICanceler {
|
||||
|
||||
private ICancelable fCancelable;
|
||||
|
||||
@Override
|
||||
public void setCancelable(ICancelable cancelable) {
|
||||
fCancelable= cancelable;
|
||||
checkCanceled();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setCanceled(boolean canceled) {
|
||||
super.setCanceled(canceled);
|
||||
checkCanceled();
|
||||
}
|
||||
|
||||
|
||||
private void checkCanceled() {
|
||||
if (fCancelable != null && isCanceled()) {
|
||||
fCancelable.cancel();
|
||||
|
|
|
@ -32,7 +32,7 @@ public class Region implements IRegion {
|
|||
|
||||
/**
|
||||
* Creates an empty region.
|
||||
*
|
||||
*
|
||||
* @see IRegion
|
||||
*/
|
||||
public Region() {
|
||||
|
@ -42,6 +42,7 @@ public class Region implements IRegion {
|
|||
/**
|
||||
* @see IRegion#add(ICElement)
|
||||
*/
|
||||
@Override
|
||||
public void add(ICElement element) {
|
||||
if (!contains(element)) {
|
||||
// "new" element added to region
|
||||
|
@ -54,6 +55,7 @@ public class Region implements IRegion {
|
|||
/**
|
||||
* @see IRegion
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(ICElement element) {
|
||||
|
||||
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
|
||||
* order.
|
||||
*
|
||||
*
|
||||
*/
|
||||
private ArrayList<ICElement> getAncestors(ICElement element) {
|
||||
ArrayList<ICElement> parents = new ArrayList<ICElement>();
|
||||
|
@ -93,6 +95,7 @@ public class Region implements IRegion {
|
|||
/**
|
||||
* @see IRegion
|
||||
*/
|
||||
@Override
|
||||
public ICElement[] getElements() {
|
||||
int size = fRootElements.size();
|
||||
ICElement[] roots = new ICElement[size];
|
||||
|
@ -106,6 +109,7 @@ public class Region implements IRegion {
|
|||
/**
|
||||
* @see IRegion#remove(ICElement)
|
||||
*/
|
||||
@Override
|
||||
public boolean remove(ICElement element) {
|
||||
|
||||
removeAllChildren(element);
|
||||
|
@ -115,7 +119,7 @@ public class Region implements IRegion {
|
|||
/**
|
||||
* Removes any children of this element that are contained within this
|
||||
* region as this parent is about to be added to the region.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Children are all children, not just direct children.
|
||||
*/
|
||||
|
|
|
@ -52,6 +52,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
|
|||
/**
|
||||
* @see ISourceManipulation
|
||||
*/
|
||||
@Override
|
||||
public void copy(ICElement container, ICElement sibling, String rename, boolean force,
|
||||
IProgressMonitor monitor) throws CModelException {
|
||||
if (container == null) {
|
||||
|
@ -73,6 +74,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
|
|||
/**
|
||||
* @see ISourceManipulation
|
||||
*/
|
||||
@Override
|
||||
public void delete(boolean force, IProgressMonitor monitor) throws CModelException {
|
||||
ICElement[] elements = new ICElement[] {this};
|
||||
getCModel().delete(elements, force, monitor);
|
||||
|
@ -81,6 +83,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
|
|||
/**
|
||||
* @see ISourceManipulation
|
||||
*/
|
||||
@Override
|
||||
public void move(ICElement container, ICElement sibling, String rename, boolean force,
|
||||
IProgressMonitor monitor) throws CModelException {
|
||||
if (container == null) {
|
||||
|
@ -102,6 +105,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
|
|||
/**
|
||||
* @see ISourceManipulation
|
||||
*/
|
||||
@Override
|
||||
public void rename(String name, boolean force, IProgressMonitor monitor) throws CModelException {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("element.nullName"); //$NON-NLS-1$
|
||||
|
@ -115,6 +119,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
|
|||
/**
|
||||
* @see IMember
|
||||
*/
|
||||
@Override
|
||||
public ITranslationUnit getTranslationUnit() {
|
||||
try {
|
||||
return getSourceManipulationInfo().getTranslationUnit();
|
||||
|
@ -152,6 +157,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
|
|||
/**
|
||||
* @see ISourceReference
|
||||
*/
|
||||
@Override
|
||||
public String getSource() throws CModelException {
|
||||
return getSourceManipulationInfo().getSource();
|
||||
}
|
||||
|
@ -159,6 +165,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
|
|||
/**
|
||||
* @see ISourceReference
|
||||
*/
|
||||
@Override
|
||||
public ISourceRange getSourceRange() throws CModelException {
|
||||
return getSourceManipulationInfo().getSourceRange();
|
||||
}
|
||||
|
@ -175,7 +182,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
|
|||
public IResource getResource() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected CElementInfo createElementInfo () {
|
||||
return new SourceManipulationInfo(this);
|
||||
|
@ -184,9 +191,9 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
|
|||
protected SourceManipulationInfo getSourceManipulationInfo() throws CModelException {
|
||||
return (SourceManipulationInfo)getElementInfo();
|
||||
}
|
||||
|
||||
|
||||
public boolean isIdentical(SourceManipulation other) throws CModelException{
|
||||
return (this.equals(other)
|
||||
return (this.equals(other)
|
||||
&& (this.getSourceManipulationInfo().hasSameContentsAs(other.getSourceManipulationInfo())));
|
||||
}
|
||||
|
||||
|
@ -199,7 +206,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
|
|||
if (openableParent == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
newElements.put(this, info);
|
||||
|
||||
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) {
|
||||
try {
|
||||
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_DECLARATION:
|
||||
for (ICElement element2 : children) {
|
||||
if (elementType == element2.getElementType()
|
||||
if (elementType == element2.getElementType()
|
||||
&& elementName.equals(element2.getElementName())) {
|
||||
assert element2 instanceof IFunctionDeclaration;
|
||||
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_UNION:
|
||||
for (ICElement element2 : children) {
|
||||
if (elementType == element2.getElementType()
|
||||
if (elementType == element2.getElementType()
|
||||
&& elementName.equals(element2.getElementName())) {
|
||||
assert element2 instanceof ITemplate;
|
||||
String[] templateParams= ((ITemplate)element2).getTemplateParameterTypes();
|
||||
|
@ -329,7 +336,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
|
|||
break;
|
||||
default:
|
||||
for (ICElement element2 : children) {
|
||||
if (elementType == element2.getElementType()
|
||||
if (elementType == element2.getElementType()
|
||||
&& elementName.equals(element2.getElementName())) {
|
||||
element= (CElement) element2;
|
||||
break;
|
||||
|
@ -362,14 +369,16 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
|
|||
return CElement.CEM_SOURCEELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return fIsActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIndex() {
|
||||
return fIndex;
|
||||
}
|
||||
|
||||
|
||||
public void setActive(boolean active) {
|
||||
fIsActive= active;
|
||||
}
|
||||
|
@ -377,12 +386,12 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
|
|||
public void setIndex(int i) {
|
||||
fIndex= (short) i;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Util.combineHashCodes(fIndex, super.hashCode());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other instanceof ISourceReference) {
|
||||
|
|
|
@ -50,6 +50,7 @@ class SourceRange implements ISourceRange {
|
|||
/**
|
||||
* @see ISourceRange
|
||||
*/
|
||||
@Override
|
||||
public int getLength() {
|
||||
return length;
|
||||
}
|
||||
|
@ -57,24 +58,29 @@ class SourceRange implements ISourceRange {
|
|||
/**
|
||||
* @see ISourceRange
|
||||
*/
|
||||
@Override
|
||||
public int getStartPos() {
|
||||
return startPos;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
@Override
|
||||
public int getIdStartPos() {
|
||||
return idStartPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdLength() {
|
||||
return idLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartLine() {
|
||||
return startLine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEndLine() {
|
||||
return endLine;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ public class SourceRoot extends CContainer implements ISourceRoot {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ISourceRoot#isOnclasspath(org.eclipse.cdt.core.model.ICElement)
|
||||
*/
|
||||
@Override
|
||||
public boolean isOnSourceEntry(ICElement element) {
|
||||
IPath path = element.getPath();
|
||||
return this.isOnSourceEntry(path);
|
||||
|
@ -58,13 +59,15 @@ public class SourceRoot extends CContainer implements ISourceRoot {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ISourceRoot#isOnSourceEntry(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
@Override
|
||||
public boolean isOnSourceEntry(IResource res) {
|
||||
IPath path = res.getFullPath();
|
||||
return isOnSourceEntry(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnSourceEntry(IPath path) {
|
||||
if (sourceEntry.getFullPath().isPrefixOf(path)
|
||||
if (sourceEntry.getFullPath().isPrefixOf(path)
|
||||
&& !CoreModelUtil.isExcluded(path, sourceEntry.fullExclusionPatternChars())) {
|
||||
return true;
|
||||
}
|
||||
|
@ -86,7 +89,7 @@ public class SourceRoot extends CContainer implements ISourceRoot {
|
|||
}
|
||||
((CElement)getParent()).getHandleMemento(buff);
|
||||
buff.append(getHandleMementoDelimiter());
|
||||
escapeMementoName(buff, path.toString());
|
||||
escapeMementoName(buff, path.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,19 +24,21 @@ import org.eclipse.cdt.core.model.IStructure;
|
|||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
|
||||
public class Structure extends StructureDeclaration implements IStructure {
|
||||
|
||||
|
||||
Map<String, ASTAccessVisibility> superClassesNames = new TreeMap<String, ASTAccessVisibility>();
|
||||
|
||||
public Structure(ICElement parent, int kind, String name) {
|
||||
super(parent, name, kind);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField[] getFields() throws CModelException {
|
||||
List<ICElement> fields = new ArrayList<ICElement>();
|
||||
fields.addAll(getChildrenOfType(ICElement.C_FIELD));
|
||||
return fields.toArray(new IField[fields.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField getField(String name) {
|
||||
try {
|
||||
IField[] fields = getFields();
|
||||
|
@ -50,6 +52,7 @@ public class Structure extends StructureDeclaration implements IStructure {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMethodDeclaration[] getMethods() throws CModelException {
|
||||
List<ICElement> methods = new ArrayList<ICElement>();
|
||||
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()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMethodDeclaration getMethod(String name) {
|
||||
try {
|
||||
IMethodDeclaration[] methods = getMethods();
|
||||
|
@ -70,6 +74,7 @@ public class Structure extends StructureDeclaration implements IStructure {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstract() throws CModelException {
|
||||
IMethodDeclaration[] methods = getMethods();
|
||||
for (IMethodDeclaration method : methods) {
|
||||
|
@ -79,14 +84,16 @@ public class Structure extends StructureDeclaration implements IStructure {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSuperClassesNames(){
|
||||
return superClassesNames.keySet().toArray(new String[superClassesNames.keySet().size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTAccessVisibility getSuperClassAccess(String name){
|
||||
return superClassesNames.get(name);
|
||||
}
|
||||
|
||||
|
||||
public void addSuperClass(String name) {
|
||||
superClassesNames.put(name, ASTAccessVisibility.PUBLIC);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ public class StructureDeclaration extends SourceManipulation implements IStructu
|
|||
super(parent, name, kind);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() throws CModelException {
|
||||
return getStructureInfo().getTypeName();
|
||||
}
|
||||
|
@ -32,14 +33,17 @@ public class StructureDeclaration extends SourceManipulation implements IStructu
|
|||
getStructureInfo().setTypeName(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnion() throws CModelException {
|
||||
return getStructureInfo().isUnion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClass() throws CModelException {
|
||||
return getStructureInfo().isClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStruct() throws CModelException {
|
||||
return getStructureInfo().isStruct();
|
||||
}
|
||||
|
@ -56,6 +60,7 @@ public class StructureDeclaration extends SourceManipulation implements IStructu
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IDeclaration#isStatic()
|
||||
*/
|
||||
@Override
|
||||
public boolean isStatic() throws CModelException {
|
||||
return getStructureInfo().isStatic();
|
||||
}
|
||||
|
@ -63,6 +68,7 @@ public class StructureDeclaration extends SourceManipulation implements IStructu
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IDeclaration#isConst()
|
||||
*/
|
||||
@Override
|
||||
public boolean isConst() throws CModelException {
|
||||
return getStructureInfo().isConst();
|
||||
}
|
||||
|
@ -70,6 +76,7 @@ public class StructureDeclaration extends SourceManipulation implements IStructu
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IDeclaration#isVolatile()
|
||||
*/
|
||||
@Override
|
||||
public boolean isVolatile() throws CModelException {
|
||||
return getStructureInfo().isVolatile();
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.eclipse.cdt.core.model.IStructureTemplate;
|
|||
public class StructureTemplate extends Structure implements IStructureTemplate {
|
||||
|
||||
protected Template fTemplate;
|
||||
|
||||
|
||||
public StructureTemplate(ICElement parent, int kind, String name) {
|
||||
super(parent, kind, name);
|
||||
fTemplate = new Template(name);
|
||||
|
@ -27,10 +27,12 @@ public class StructureTemplate extends Structure implements IStructureTemplate {
|
|||
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes()
|
||||
* @return String[]
|
||||
*/
|
||||
@Override
|
||||
public String[] getTemplateParameterTypes() {
|
||||
return fTemplate.getTemplateParameterTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTemplateArguments() {
|
||||
return fTemplate.getTemplateArguments();
|
||||
}
|
||||
|
@ -46,13 +48,15 @@ public class StructureTemplate extends Structure implements IStructureTemplate {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
|
||||
*/
|
||||
@Override
|
||||
public int getNumberOfTemplateParameters() {
|
||||
return fTemplate.getNumberOfTemplateParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
|
||||
*/
|
||||
*/
|
||||
@Override
|
||||
public String getTemplateSignature() {
|
||||
return fTemplate.getTemplateSignature();
|
||||
}
|
||||
|
|
|
@ -25,10 +25,12 @@ public class StructureTemplateDeclaration extends StructureDeclaration implement
|
|||
fTemplate = new Template(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTemplateParameterTypes() {
|
||||
return fTemplate.getTemplateParameterTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTemplateArguments() {
|
||||
return fTemplate.getTemplateArguments();
|
||||
}
|
||||
|
@ -37,10 +39,12 @@ public class StructureTemplateDeclaration extends StructureDeclaration implement
|
|||
fTemplate.setTemplateInfo(templateParameterTypes, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateSignature() throws CModelException {
|
||||
return fTemplate.getTemplateSignature();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfTemplateParameters() {
|
||||
return fTemplate.getNumberOfTemplateParameters();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class Template implements ITemplate {
|
|||
protected String[] fTemplateParameterTypes;
|
||||
protected String[] fTemplateArgs;
|
||||
protected String fName;
|
||||
|
||||
|
||||
public Template(String name) {
|
||||
fName = name;
|
||||
fTemplateParameterTypes= fgEmptyList;
|
||||
|
@ -29,10 +29,12 @@ public class Template implements ITemplate {
|
|||
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes()
|
||||
* @return String[]
|
||||
*/
|
||||
@Override
|
||||
public String[] getTemplateParameterTypes() {
|
||||
return fTemplateParameterTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTemplateArguments() {
|
||||
return fTemplateArgs;
|
||||
}
|
||||
|
@ -48,13 +50,15 @@ public class Template implements ITemplate {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfTemplateParameters() {
|
||||
return fTemplateParameterTypes == null ? 0 : fTemplateParameterTypes.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
|
||||
*/
|
||||
*/
|
||||
@Override
|
||||
public String getTemplateSignature() {
|
||||
StringBuffer sig = new StringBuffer(fName);
|
||||
if(getNumberOfTemplateParameters() > 0){
|
||||
|
|
|
@ -117,10 +117,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
setContentTypeID(idType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITranslationUnit getTranslationUnit() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInclude createInclude(String includeName, boolean isStd, ICElement sibling,
|
||||
IProgressMonitor monitor) throws CModelException {
|
||||
CreateIncludeOperation op = new CreateIncludeOperation(includeName, isStd, this);
|
||||
|
@ -131,6 +133,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return getInclude(includeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IUsing createUsing(String usingName, boolean isDirective, ICElement sibling,
|
||||
IProgressMonitor monitor) throws CModelException {
|
||||
CreateIncludeOperation op = new CreateIncludeOperation(usingName, isDirective, this);
|
||||
|
@ -141,6 +144,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return getUsing(usingName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public INamespace createNamespace(String namespace, ICElement sibling,
|
||||
IProgressMonitor monitor) throws CModelException {
|
||||
CreateNamespaceOperation op = new CreateNamespaceOperation(namespace, this);
|
||||
|
@ -151,6 +155,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return getNamespace(namespace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICElement getElementAtLine(int line) throws CModelException {
|
||||
ICElement[] celements = getChildren();
|
||||
for (ICElement celement : celements) {
|
||||
|
@ -164,6 +169,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICElement getElementAtOffset(int pos) throws CModelException {
|
||||
ICElement e = getSourceElementAtOffset(pos);
|
||||
if (e == this) {
|
||||
|
@ -172,6 +178,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICElement[] getElementsAtOffset(int pos) throws CModelException {
|
||||
ICElement[] e = getSourceElementsAtOffset(pos);
|
||||
if (e.length == 1 && e[0] == this) {
|
||||
|
@ -180,6 +187,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICElement getElement(String name) {
|
||||
if (name == null || name.length() == 0) {
|
||||
return null;
|
||||
|
@ -218,6 +226,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInclude getInclude(String name) {
|
||||
try {
|
||||
ICElement[] celements = getChildren();
|
||||
|
@ -233,6 +242,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInclude[] getIncludes() throws CModelException {
|
||||
ICElement[] celements = getChildren();
|
||||
ArrayList<ICElement> aList = new ArrayList<ICElement>();
|
||||
|
@ -244,6 +254,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return aList.toArray(new IInclude[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IUsing getUsing(String name) {
|
||||
try {
|
||||
ICElement[] celements = getChildren();
|
||||
|
@ -259,6 +270,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IUsing[] getUsings() throws CModelException {
|
||||
ICElement[] celements = getChildren();
|
||||
ArrayList<ICElement> aList = new ArrayList<ICElement>();
|
||||
|
@ -270,6 +282,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return aList.toArray(new IUsing[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public INamespace getNamespace(String name) {
|
||||
try {
|
||||
String[] names = name.split("::"); //$NON-NLS-1$
|
||||
|
@ -298,6 +311,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INamespace[] getNamespaces() throws CModelException {
|
||||
ICElement[] celements = getChildren();
|
||||
ArrayList<ICElement> elementList = new ArrayList<ICElement>();
|
||||
|
@ -313,6 +327,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
location = loc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPath getLocation() {
|
||||
if (location == null) {
|
||||
IFile file = getFile();
|
||||
|
@ -324,7 +339,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
}
|
||||
return UNCPathConverter.toPath(location);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public URI getLocationURI() {
|
||||
if (location == null) {
|
||||
|
@ -346,28 +361,34 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(ICElement container, ICElement sibling, String rename, boolean force,
|
||||
IProgressMonitor monitor) throws CModelException {
|
||||
getSourceManipulationInfo().copy(container, sibling, rename, force, monitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(boolean force, IProgressMonitor monitor) throws CModelException {
|
||||
getSourceManipulationInfo().delete(force, monitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void move(ICElement container, ICElement sibling, String rename, boolean force,
|
||||
IProgressMonitor monitor) throws CModelException {
|
||||
getSourceManipulationInfo().move(container, sibling, rename, force, monitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(String name, boolean force, IProgressMonitor monitor) throws CModelException {
|
||||
getSourceManipulationInfo().rename(name, force, monitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSource() throws CModelException {
|
||||
return getSourceManipulationInfo().getSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISourceRange getSourceRange() throws CModelException {
|
||||
return getSourceManipulationInfo().getSourceRange();
|
||||
}
|
||||
|
@ -391,9 +412,9 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
/**
|
||||
* Returns true if this handle represents the same Java element
|
||||
* as the given handle.
|
||||
*
|
||||
*
|
||||
* <p>Compilation units must also check working copy state;
|
||||
*
|
||||
*
|
||||
* @see Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
|
@ -402,6 +423,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return super.equals(o) && !((ITranslationUnit) o).isWorkingCopy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorkingCopy findSharedWorkingCopy() {
|
||||
return CModelManager.getDefault().findSharedWorkingCopy(null, this);
|
||||
}
|
||||
|
@ -442,6 +464,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return unitInfo.isStructureKnown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getContents() {
|
||||
try {
|
||||
IBuffer buffer = this.getBuffer();
|
||||
|
@ -451,19 +474,23 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IProblemRequestor requestor)
|
||||
throws CModelException {
|
||||
return CModelManager.getDefault().getSharedWorkingCopy(null, this, requestor, monitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorkingCopy getWorkingCopy() throws CModelException {
|
||||
return this.getWorkingCopy(null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorkingCopy getWorkingCopy(IProgressMonitor monitor) throws CModelException {
|
||||
return getWorkingCopy(monitor, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorkingCopy getWorkingCopy(IProgressMonitor monitor, IBufferFactory factory) throws CModelException {
|
||||
WorkingCopy workingCopy;
|
||||
IFile file= getFile();
|
||||
|
@ -513,7 +540,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
if (!computeAST && isConsistent()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// create a new info and make it the current info
|
||||
// (this will remove the info and its children just before storing the new infos)
|
||||
CModelManager manager = CModelManager.getDefault();
|
||||
|
@ -559,6 +586,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorkingCopy() {
|
||||
return false;
|
||||
}
|
||||
|
@ -601,6 +629,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<?, ?> parse() {
|
||||
throw new UnsupportedOperationException("Deprecated method"); //$NON-NLS-1$
|
||||
}
|
||||
|
@ -655,10 +684,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return problemRequestor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHeaderUnit() {
|
||||
return isHeaderContentType(contentTypeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSourceUnit() {
|
||||
return isSourceContentType(contentTypeId);
|
||||
}
|
||||
|
@ -678,16 +709,19 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
|| LanguageManager.getInstance().isContributedContentType(contentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCLanguage() {
|
||||
return CCorePlugin.CONTENT_TYPE_CSOURCE.equals(contentTypeId)
|
||||
|| CCorePlugin.CONTENT_TYPE_CHEADER.equals(contentTypeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCXXLanguage() {
|
||||
return CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(contentTypeId)
|
||||
|| CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(contentTypeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isASMLanguage() {
|
||||
return CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(contentTypeId);
|
||||
}
|
||||
|
@ -705,20 +739,21 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILanguage getLanguage() throws CoreException {
|
||||
ILanguage language = null;
|
||||
|
||||
|
||||
ICProject cProject = getCProject();
|
||||
IProject project= cProject.getProject();
|
||||
|
||||
|
||||
ICProjectDescription description = CoreModel.getDefault().getProjectDescription(project, false);
|
||||
ICConfigurationDescription configuration;
|
||||
|
||||
|
||||
if (description == null) {
|
||||
// TODO: Sometimes, CoreModel returns a null ICProjectDescription
|
||||
// so for now, fall back to configuration-less language determination.
|
||||
|
@ -726,7 +761,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
} else {
|
||||
configuration = description.getActiveConfiguration();
|
||||
}
|
||||
|
||||
|
||||
IFile file= getFile();
|
||||
if (file != null) {
|
||||
language = LanguageManager.getInstance().getLanguageForFile(file, configuration, contentTypeId);
|
||||
|
@ -738,6 +773,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return language;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentTypeId() {
|
||||
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
|
||||
* not the parse of a translation unit was successful without having access to
|
||||
* the <code>CElementInfo</code> object associated with the translation unit
|
||||
*
|
||||
*
|
||||
* @param wasSuccessful
|
||||
*/
|
||||
@Override
|
||||
public void setIsStructureKnown(boolean wasSuccessful) {
|
||||
try {
|
||||
this.getElementInfo().setIsStructureKnown(wasSuccessful);
|
||||
|
@ -769,10 +806,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTTranslationUnit getAST() throws CoreException {
|
||||
return getAST(null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTTranslationUnit getAST(IIndex index, int style) throws CoreException {
|
||||
return getAST(index, style, null);
|
||||
}
|
||||
|
@ -782,12 +821,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
ITranslationUnit configureWith = getConfigureWith(contextToHeader);
|
||||
if (configureWith == this)
|
||||
contextToHeader= null;
|
||||
|
||||
|
||||
IScannerInfo scanInfo= configureWith.getScannerInfo((style & AST_SKIP_IF_NO_BUILD_INFO) == 0);
|
||||
if (scanInfo == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
FileContent fileContent= FileContent.create(this);
|
||||
if (fileContent == null) {
|
||||
return null;
|
||||
|
@ -833,19 +872,19 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
} else {
|
||||
fileContentsProvider= IncludeFileContentProvider.getSavedFilesProvider();
|
||||
}
|
||||
|
||||
|
||||
if (index != null && (style & AST_SKIP_INDEXED_HEADERS) != 0) {
|
||||
IndexBasedFileContentProvider ibcf= new IndexBasedFileContentProvider(index, pathResolver, linkageID,
|
||||
fileContentsProvider);
|
||||
ibcf.setContextToHeaderGap(contextToHeader);
|
||||
fileContentsProvider= ibcf;
|
||||
}
|
||||
|
||||
|
||||
if (fileContentsProvider instanceof InternalFileContentProvider) {
|
||||
final ProjectIndexerIncludeResolutionHeuristics heuristics = new ProjectIndexerIncludeResolutionHeuristics(cprj.getProject(), pathResolver);
|
||||
((InternalFileContentProvider) fileContentsProvider).setIncludeResolutionHeuristics(heuristics);
|
||||
}
|
||||
|
||||
|
||||
return fileContentsProvider;
|
||||
}
|
||||
|
||||
|
@ -874,7 +913,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (best != null && contextOfBest != best) {
|
||||
return new IIndexFile[] { contextOfBest, best };
|
||||
}
|
||||
|
@ -897,10 +936,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
}
|
||||
return indexFile;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
String path = indexFile.getLocation().getURI().getPath();
|
||||
|
@ -912,28 +951,29 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
}
|
||||
|
||||
private ITranslationUnit getConfigureWith(IIndexFile[] contextToHeader) throws CoreException {
|
||||
if (contextToHeader != null) {
|
||||
if (contextToHeader != null) {
|
||||
ITranslationUnit configureWith = CoreModelUtil.findTranslationUnitForLocation(
|
||||
contextToHeader[0].getLocation(), getCProject());
|
||||
if (configureWith != null)
|
||||
if (configureWith != null)
|
||||
return configureWith;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTCompletionNode getCompletionNode(IIndex index, int style, int offset) throws CoreException {
|
||||
IIndexFile[] contextToHeader = getContextToHeader(index, style);
|
||||
ITranslationUnit configureWith = getConfigureWith(contextToHeader);
|
||||
if (configureWith == this)
|
||||
contextToHeader= null;
|
||||
|
||||
|
||||
IScannerInfo scanInfo = configureWith.getScannerInfo((style & ITranslationUnit.AST_SKIP_IF_NO_BUILD_INFO) == 0);
|
||||
if (scanInfo == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
FileContent fileContent= FileContent.create(this);
|
||||
|
||||
|
||||
ILanguage language= configureWith.getLanguage();
|
||||
fLanguageOfContext= language;
|
||||
if (language != null) {
|
||||
|
@ -952,6 +992,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public org.eclipse.cdt.core.parser.CodeReader getCodeReader() {
|
||||
IPath location= getLocation();
|
||||
|
@ -960,12 +1001,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
if (isWorkingCopy()) {
|
||||
return new org.eclipse.cdt.core.parser.CodeReader(location.toOSString(), getContents());
|
||||
}
|
||||
|
||||
|
||||
IResource res= getResource();
|
||||
try {
|
||||
if (res instanceof IFile)
|
||||
return InternalParserUtil.createWorkspaceFileReader(location.toOSString(), (IFile) res, null);
|
||||
else
|
||||
else
|
||||
return InternalParserUtil.createExternalFileReader(location.toOSString(), null);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
|
@ -975,6 +1016,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IScannerInfo getScannerInfo(boolean force) {
|
||||
IResource resource = getResource();
|
||||
ICProject project = getCProject();
|
||||
|
@ -984,7 +1026,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
if (!force && CoreModel.isScannerInformationEmpty(infoResource)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(rproject);
|
||||
if (provider != null) {
|
||||
IScannerInfo scanInfo = provider.getScannerInformation(infoResource);
|
||||
|
@ -996,7 +1038,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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}.
|
||||
|
@ -1159,30 +1201,35 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected char getHandleMementoDelimiter() {
|
||||
return CElement.CEM_TRANSLATIONUNIT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIndex() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public IWorkingCopy findSharedWorkingCopy(IBufferFactory bufferFactory) {
|
||||
return CModelManager.getDefault().findSharedWorkingCopy(bufferFactory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IBufferFactory factory, IProblemRequestor requestor) throws CModelException {
|
||||
return CModelManager.getDefault().getSharedWorkingCopy(factory, this, requestor, monitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IBufferFactory factory) throws CModelException {
|
||||
return CModelManager.getDefault().getSharedWorkingCopy(factory, this, null, monitor);
|
||||
|
|
|
@ -24,6 +24,7 @@ public class TypeDef extends SourceManipulation implements ITypeDef {
|
|||
* Returns the typeName.
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ public class Using extends SourceManipulation implements IUsing {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IUsing#isDirective()
|
||||
*/
|
||||
@Override
|
||||
public boolean isDirective() {
|
||||
return directive;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.eclipse.cdt.core.model.ICElement;
|
|||
import org.eclipse.cdt.core.model.IVariable;
|
||||
|
||||
public class Variable extends VariableDeclaration implements IVariable {
|
||||
|
||||
|
||||
public Variable(ICElement parent, String name) {
|
||||
super(parent, name, ICElement.C_VARIABLE);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ public class Variable extends VariableDeclaration implements IVariable {
|
|||
super(parent, name, kind);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInitializer() {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.eclipse.cdt.core.model.ICElement;
|
|||
import org.eclipse.cdt.core.model.IVariableDeclaration;
|
||||
|
||||
public class VariableDeclaration extends SourceManipulation implements IVariableDeclaration {
|
||||
|
||||
|
||||
public VariableDeclaration(ICElement parent, String name) {
|
||||
super(parent, name, ICElement.C_VARIABLE_DECLARATION);
|
||||
}
|
||||
|
@ -25,14 +25,17 @@ public class VariableDeclaration extends SourceManipulation implements IVariable
|
|||
super(parent, name, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() throws CModelException {
|
||||
return getVariableInfo().getTypeName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTypeName(String type) throws CModelException {
|
||||
getVariableInfo().setTypeString(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConst() throws CModelException {
|
||||
return getVariableInfo().isConst();
|
||||
}
|
||||
|
@ -41,6 +44,7 @@ public class VariableDeclaration extends SourceManipulation implements IVariable
|
|||
getVariableInfo().setConst(isConst);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVolatile() throws CModelException {
|
||||
return getVariableInfo().isVolatile();
|
||||
}
|
||||
|
@ -49,6 +53,7 @@ public class VariableDeclaration extends SourceManipulation implements IVariable
|
|||
getVariableInfo().setVolatile(isVolatile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatic() throws CModelException {
|
||||
return getVariableInfo().isStatic();
|
||||
}
|
||||
|
@ -60,7 +65,7 @@ public class VariableDeclaration extends SourceManipulation implements IVariable
|
|||
public VariableInfo getVariableInfo() throws CModelException{
|
||||
return (VariableInfo) getElementInfo();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected CElementInfo createElementInfo () {
|
||||
return new VariableInfo(this);
|
||||
|
|
|
@ -17,15 +17,16 @@ public class VariableTemplate extends Variable implements ITemplate {
|
|||
|
||||
protected static final String[] fgEmptyList= new String[] {};
|
||||
protected String[] templateParameterTypes;
|
||||
|
||||
|
||||
public VariableTemplate(ICElement parent, String name) {
|
||||
super(parent, name, ICElement.C_TEMPLATE_VARIABLE);
|
||||
templateParameterTypes= fgEmptyList;
|
||||
templateParameterTypes= fgEmptyList;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
|
||||
*/
|
||||
@Override
|
||||
public int getNumberOfTemplateParameters() {
|
||||
return templateParameterTypes == null ? 0 : templateParameterTypes.length;
|
||||
}
|
||||
|
@ -33,10 +34,12 @@ public class VariableTemplate extends Variable implements ITemplate {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes()
|
||||
*/
|
||||
@Override
|
||||
public String[] getTemplateParameterTypes() {
|
||||
return templateParameterTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTemplateArguments() {
|
||||
return fgEmptyList;
|
||||
}
|
||||
|
@ -51,6 +54,7 @@ public class VariableTemplate extends Variable implements ITemplate {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
|
||||
*/
|
||||
@Override
|
||||
public String getTemplateSignature() throws CModelException {
|
||||
StringBuffer sig = new StringBuffer(getElementName());
|
||||
if(getNumberOfTemplateParameters() > 0){
|
||||
|
@ -67,10 +71,10 @@ public class VariableTemplate extends Variable implements ITemplate {
|
|||
else{
|
||||
sig.append("<>"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
sig.append(" : "); //$NON-NLS-1$
|
||||
sig.append(this.getTypeName());
|
||||
|
||||
|
||||
return sig.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,13 +38,13 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
* the timestamp of the resource it was created from.
|
||||
*/
|
||||
public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||
|
||||
|
||||
/**
|
||||
* If set, this is the factory that will be used to create the buffer.
|
||||
*/
|
||||
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
|
||||
* copy is not managed. When destroyed, this counter is
|
||||
* 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)
|
||||
*/
|
||||
@Override
|
||||
public void commit(boolean force, IProgressMonitor monitor) throws CModelException {
|
||||
ITranslationUnit original = this.getOriginalElement();
|
||||
if (original.exists()) {
|
||||
|
@ -94,8 +95,8 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
|
||||
if (originalRes.exists()) {
|
||||
originalRes.setContents(
|
||||
stream,
|
||||
force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
|
||||
stream,
|
||||
force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
|
||||
null);
|
||||
} else {
|
||||
originalRes.create(
|
||||
|
@ -108,12 +109,13 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
} catch (CoreException e) {
|
||||
throw new CModelException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.IWorkingCopy#destroy()
|
||||
*/
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (--this.useCount > 0) {
|
||||
return;
|
||||
|
@ -151,17 +153,18 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return this == o;
|
||||
return this == o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the original element the specified working copy element was created from,
|
||||
* or <code>null</code> if this is not a working copy element.
|
||||
*
|
||||
*
|
||||
* @param workingCopyElement the specified working copy element
|
||||
* @return the original element the specified working copy element was created from,
|
||||
* or <code>null</code> if this is not a working copy element
|
||||
*/
|
||||
@Override
|
||||
public ICElement getOriginal(ICElement workingCopyElement) {
|
||||
// It has to come from the same workingCopy, meaning ours.
|
||||
if (workingCopyElement instanceof ISourceReference) {
|
||||
|
@ -207,10 +210,11 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.IWorkingCopy#getOriginalElement()
|
||||
*/
|
||||
@Override
|
||||
public ITranslationUnit getOriginalElement() {
|
||||
IFile file= getFile();
|
||||
if (file != null) {
|
||||
|
@ -224,12 +228,12 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
*/
|
||||
@Override
|
||||
public IWorkingCopy getSharedWorkingCopy(IProgressMonitor monitor, IProblemRequestor requestor) {
|
||||
return this;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.ITranslationUnit#getWorkingCopy()
|
||||
*/
|
||||
*/
|
||||
@Override
|
||||
public IWorkingCopy getWorkingCopy() {
|
||||
return this;
|
||||
|
@ -246,6 +250,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
/**
|
||||
* @see IWorkingCopy
|
||||
*/
|
||||
@Override
|
||||
public boolean isBasedOn(IResource resource) {
|
||||
if (resource.getType() != IResource.FILE) {
|
||||
return false;
|
||||
|
@ -282,12 +287,12 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
public void open(IProgressMonitor monitor) throws CModelException {
|
||||
if (this.useCount == 0) { // was destroyed
|
||||
throw newNotPresentException();
|
||||
}
|
||||
}
|
||||
super.open(monitor);
|
||||
//if (monitor != null && monitor.isCanceled()) return;
|
||||
//if (this.problemRequestor != null && this.problemRequestor.isActive()){
|
||||
// this.problemRequestor.beginReporting();
|
||||
// TranslationUnitProblemFinder.process(this, this.problemRequestor, monitor);
|
||||
// TranslationUnitProblemFinder.process(this, this.problemRequestor, monitor);
|
||||
// this.problemRequestor.endReporting();
|
||||
//}
|
||||
}
|
||||
|
@ -298,10 +303,10 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
@Override
|
||||
protected IBuffer openBuffer(IProgressMonitor pm) throws CModelException {
|
||||
if (this.useCount == 0) throw newNotPresentException();
|
||||
|
||||
|
||||
// create buffer - working copies may use custom buffer factory
|
||||
IBuffer buffer = getBufferFactory().createBuffer(this);
|
||||
if (buffer == null)
|
||||
if (buffer == null)
|
||||
return null;
|
||||
|
||||
// set the buffer source if needed
|
||||
|
@ -333,20 +338,22 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
// listen to buffer changes
|
||||
buffer.addBufferChangedListener(this);
|
||||
|
||||
return buffer;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.IWorkingCopy#reconcile()
|
||||
*/
|
||||
@Override
|
||||
public IMarker[] reconcile() throws CModelException {
|
||||
reconcile(false, null);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.IWorkingCopy#reconcile(boolean, org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
public void reconcile(boolean forceProblemDetection, IProgressMonitor monitor) throws CModelException {
|
||||
reconcile(false, forceProblemDetection, monitor);
|
||||
}
|
||||
|
@ -354,6 +361,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
/**
|
||||
* @see org.eclipse.cdt.core.model.IWorkingCopy#restore()
|
||||
*/
|
||||
@Override
|
||||
public void restore() throws CModelException{
|
||||
if (this.useCount == 0) throw newNotPresentException(); //was destroyed
|
||||
|
||||
|
@ -362,7 +370,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
if (buffer == null) return;
|
||||
buffer.setContents(original.getContents());
|
||||
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
|
||||
// (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)
|
||||
*/
|
||||
@Override
|
||||
public IASTTranslationUnit reconcile(boolean computeAST, boolean forceProblemDetection, IProgressMonitor monitor)
|
||||
throws CModelException {
|
||||
if (this.useCount == 0)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.model.ext;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -42,7 +42,7 @@ import org.eclipse.jface.text.Region;
|
|||
abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
||||
protected static final String[] EMPTY_STRING_ARRAY = new String[0];
|
||||
private static final ICElement[] NO_CHILDREN = new ICElement[0];
|
||||
|
||||
|
||||
private ICElement fParent;
|
||||
private String fName;
|
||||
private int fType;
|
||||
|
@ -54,7 +54,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
public CElementHandle(ICElement parent, int type, String name) {
|
||||
fParent= parent;
|
||||
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
|
||||
if (name.length() > 0 && name.charAt(0)=='{') {
|
||||
fName= ""; //$NON-NLS-1$
|
||||
|
@ -64,7 +64,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
}
|
||||
fRegion= new Region(0,0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof ICElement) {
|
||||
|
@ -79,6 +79,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Object getAdapter(Class adapter) {
|
||||
return null;
|
||||
|
@ -89,6 +90,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
fTimestamp= timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISourceRange getSourceRange() throws CModelException {
|
||||
IRegion region= fRegion;
|
||||
ITranslationUnit tu= getTranslationUnit();
|
||||
|
@ -103,10 +105,12 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
return new SourceRange(startpos, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSource() throws CModelException {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ITranslationUnit getTranslationUnit() {
|
||||
ICElement parent= fParent;
|
||||
do {
|
||||
|
@ -118,58 +122,72 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
while (parent != null);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void accept(ICElementVisitor visitor) throws CoreException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICElement getAncestor(int ancestorType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICModel getCModel() {
|
||||
return fParent.getCModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICProject getCProject() {
|
||||
return fParent.getCProject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return fName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getElementType() {
|
||||
return fType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICElement getParent() {
|
||||
return fParent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPath getPath() {
|
||||
return getTranslationUnit().getPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getLocationURI() {
|
||||
return getTranslationUnit().getLocationURI();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IResource getResource() {
|
||||
return getTranslationUnit().getResource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IResource getUnderlyingResource() {
|
||||
return getResource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStructureKnown() throws CModelException {
|
||||
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 setTypeName(String type) throws CModelException {
|
||||
}
|
||||
|
||||
|
@ -224,7 +242,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
public boolean isFriend() throws CModelException {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean isInline() throws CModelException {
|
||||
return false;
|
||||
}
|
||||
|
@ -248,7 +266,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
public String getInitializer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public boolean isAbstract() throws CModelException {
|
||||
return false;
|
||||
}
|
||||
|
@ -260,7 +278,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
public String[] getSuperClassesNames() {
|
||||
return EMPTY_STRING_ARRAY;
|
||||
}
|
||||
|
||||
|
||||
protected String[] extractParameterTypes(IFunction func) {
|
||||
IParameter[] params= func.getParameters();
|
||||
String[] parameterTypes= new String[params.length];
|
||||
|
@ -273,7 +291,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
}
|
||||
return parameterTypes;
|
||||
}
|
||||
|
||||
|
||||
protected ASTAccessVisibility getVisibility(IBinding binding) {
|
||||
if (binding instanceof ICPPMember) {
|
||||
ICPPMember member= (ICPPMember) binding;
|
||||
|
@ -292,6 +310,7 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
/**
|
||||
* @see ICElement
|
||||
*/
|
||||
@Override
|
||||
public String getHandleIdentifier() {
|
||||
ICElement cModelElement= mapToModelElement();
|
||||
if (cModelElement != null) {
|
||||
|
@ -309,10 +328,12 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIndex() {
|
||||
return fIndex;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
*******************************************************************************/
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatic() throws CModelException {
|
||||
return false;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue