mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics.
This commit is contained in:
parent
f4600b8703
commit
6f5df15c4f
3 changed files with 44 additions and 50 deletions
|
@ -8,10 +8,8 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Doug Schaefer (QNX) - Initial API and implementation
|
* Doug Schaefer (QNX) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* IBM Corporation
|
* IBM Corporation - Language management feature (see Bugzilla 151850)
|
||||||
* - Language managment feature (see Bugzilla 151850)
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.model;
|
package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -84,19 +82,19 @@ public class LanguageManager {
|
||||||
return map.get(id);
|
return map.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashMap<String, ILanguageDescriptor> getDescriptorCache(){
|
private HashMap<String, ILanguageDescriptor> getDescriptorCache() {
|
||||||
if(fIdToLanguageDescriptorCache == null){
|
if (fIdToLanguageDescriptorCache == null) {
|
||||||
fIdToLanguageDescriptorCache = createDescriptorCache();
|
fIdToLanguageDescriptorCache = createDescriptorCache();
|
||||||
}
|
}
|
||||||
return fIdToLanguageDescriptorCache;
|
return fIdToLanguageDescriptorCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILanguageDescriptor[] getLanguageDescriptors(){
|
public ILanguageDescriptor[] getLanguageDescriptors() {
|
||||||
HashMap<String, ILanguageDescriptor> map = getDescriptorCache();
|
HashMap<String, ILanguageDescriptor> map = getDescriptorCache();
|
||||||
return map.values().toArray(new ILanguageDescriptor[map.size()]);
|
return map.values().toArray(new ILanguageDescriptor[map.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashMap<String, ILanguageDescriptor> createDescriptorCache(){
|
private HashMap<String, ILanguageDescriptor> createDescriptorCache() {
|
||||||
HashMap<String, ILanguageDescriptor> map = new HashMap<String, ILanguageDescriptor>();
|
HashMap<String, ILanguageDescriptor> map = new HashMap<String, ILanguageDescriptor>();
|
||||||
IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
|
IConfigurationElement[] configs= Platform.getExtensionRegistry().getConfigurationElementsFor(LANGUAGE_EXTENSION_POINT_ID);
|
||||||
for (int j = 0; j < configs.length; ++j) {
|
for (int j = 0; j < configs.length; ++j) {
|
||||||
|
@ -109,21 +107,21 @@ public class LanguageManager {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashMap<String, List<ILanguageDescriptor>> getContentTypeToDescriptorCache(){
|
private HashMap<String, List<ILanguageDescriptor>> getContentTypeToDescriptorCache() {
|
||||||
if(fContentTypeToDescriptorListCache == null){
|
if (fContentTypeToDescriptorListCache == null) {
|
||||||
fContentTypeToDescriptorListCache = createContentTypeToDescriptorCache();
|
fContentTypeToDescriptorListCache = createContentTypeToDescriptorCache();
|
||||||
}
|
}
|
||||||
return fContentTypeToDescriptorListCache;
|
return fContentTypeToDescriptorListCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, ILanguageDescriptor[]> getContentTypeIdToLanguageDescriptionsMap(){
|
public Map<String, ILanguageDescriptor[]> getContentTypeIdToLanguageDescriptionsMap() {
|
||||||
HashMap<String, ILanguageDescriptor[]> map = new HashMap<String, ILanguageDescriptor[]>();
|
HashMap<String, ILanguageDescriptor[]> map = new HashMap<String, ILanguageDescriptor[]>();
|
||||||
Map<String, List<ILanguageDescriptor>> cache = getContentTypeToDescriptorCache();
|
Map<String, List<ILanguageDescriptor>> cache = getContentTypeToDescriptorCache();
|
||||||
|
|
||||||
for(Iterator<Entry<String, List<ILanguageDescriptor>>> iter = cache.entrySet().iterator(); iter.hasNext();){
|
for (Iterator<Entry<String, List<ILanguageDescriptor>>> iter = cache.entrySet().iterator(); iter.hasNext();) {
|
||||||
Entry<String, List<ILanguageDescriptor>> entry = iter.next();
|
Entry<String, List<ILanguageDescriptor>> entry = iter.next();
|
||||||
List<ILanguageDescriptor> list = entry.getValue();
|
List<ILanguageDescriptor> list = entry.getValue();
|
||||||
if(list.size() > 0){
|
if (list.size() > 0) {
|
||||||
ILanguageDescriptor[] dess = list.toArray(new ILanguageDescriptor[list.size()]);
|
ILanguageDescriptor[] dess = list.toArray(new ILanguageDescriptor[list.size()]);
|
||||||
map.put(entry.getKey(), dess);
|
map.put(entry.getKey(), dess);
|
||||||
}
|
}
|
||||||
|
@ -133,21 +131,21 @@ public class LanguageManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private HashMap<String, List<ILanguageDescriptor>> createContentTypeToDescriptorCache(){
|
private HashMap<String, List<ILanguageDescriptor>> createContentTypeToDescriptorCache() {
|
||||||
HashMap<String, List<ILanguageDescriptor>> map = new HashMap<String, List<ILanguageDescriptor>>();
|
HashMap<String, List<ILanguageDescriptor>> map = new HashMap<String, List<ILanguageDescriptor>>();
|
||||||
Map<String, ILanguageDescriptor> dc = getDescriptorCache();
|
Map<String, ILanguageDescriptor> dc = getDescriptorCache();
|
||||||
|
|
||||||
List<ILanguageDescriptor> list;
|
List<ILanguageDescriptor> list;
|
||||||
IContentType type;
|
IContentType type;
|
||||||
String id;
|
String id;
|
||||||
for(Iterator<ILanguageDescriptor> iter = dc.values().iterator(); iter.hasNext();){
|
for (Iterator<ILanguageDescriptor> iter = dc.values().iterator(); iter.hasNext();) {
|
||||||
ILanguageDescriptor des = iter.next();
|
ILanguageDescriptor des = iter.next();
|
||||||
IContentType types[] = des.getContentTypes();
|
IContentType types[] = des.getContentTypes();
|
||||||
for(int i = 0; i < types.length; i++){
|
for (int i = 0; i < types.length; i++) {
|
||||||
type = types[i];
|
type = types[i];
|
||||||
id = type.getId();
|
id = type.getId();
|
||||||
list = map.get(id);
|
list = map.get(id);
|
||||||
if(list == null){
|
if (list == null) {
|
||||||
list = new ArrayList<ILanguageDescriptor>();
|
list = new ArrayList<ILanguageDescriptor>();
|
||||||
map.put(id, list);
|
map.put(id, list);
|
||||||
}
|
}
|
||||||
|
@ -169,7 +167,7 @@ public class LanguageManager {
|
||||||
String langId = getLanguageID(languageElem);
|
String langId = getLanguageID(languageElem);
|
||||||
if (langId.equals(id)) {
|
if (langId.equals(id)) {
|
||||||
final ILanguage[] result= new ILanguage[]{null};
|
final ILanguage[] result= new ILanguage[]{null};
|
||||||
SafeRunner.run(new ISafeRunnable(){
|
SafeRunner.run(new ISafeRunnable() {
|
||||||
public void handleException(Throwable exception) {
|
public void handleException(Throwable exception) {
|
||||||
CCorePlugin.log(exception);
|
CCorePlugin.log(exception);
|
||||||
}
|
}
|
||||||
|
@ -227,8 +225,8 @@ public class LanguageManager {
|
||||||
* @deprecated use getRegisteredContentTypes() instead.
|
* @deprecated use getRegisteredContentTypes() instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public ArrayList/*<String>*/<String> getAllContentTypes() {
|
public ArrayList<String> getAllContentTypes() {
|
||||||
ArrayList/*<String>*/<String> allTypes = new ArrayList<String>();
|
ArrayList<String> allTypes = new ArrayList<String>();
|
||||||
allTypes.add(CCorePlugin.CONTENT_TYPE_ASMSOURCE);
|
allTypes.add(CCorePlugin.CONTENT_TYPE_ASMSOURCE);
|
||||||
allTypes.add(CCorePlugin.CONTENT_TYPE_CHEADER);
|
allTypes.add(CCorePlugin.CONTENT_TYPE_CHEADER);
|
||||||
allTypes.add(CCorePlugin.CONTENT_TYPE_CSOURCE);
|
allTypes.add(CCorePlugin.CONTENT_TYPE_CSOURCE);
|
||||||
|
@ -261,7 +259,7 @@ public class LanguageManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> collectContentTypeIds() {
|
private Set<String> collectContentTypeIds() {
|
||||||
HashSet/*<String>*/<String> allTypes = new HashSet<String>();
|
HashSet<String> allTypes = new HashSet<String>();
|
||||||
allTypes.add(CCorePlugin.CONTENT_TYPE_ASMSOURCE);
|
allTypes.add(CCorePlugin.CONTENT_TYPE_ASMSOURCE);
|
||||||
allTypes.add(CCorePlugin.CONTENT_TYPE_CHEADER);
|
allTypes.add(CCorePlugin.CONTENT_TYPE_CHEADER);
|
||||||
allTypes.add(CCorePlugin.CONTENT_TYPE_CSOURCE);
|
allTypes.add(CCorePlugin.CONTENT_TYPE_CSOURCE);
|
||||||
|
@ -331,7 +329,7 @@ public class LanguageManager {
|
||||||
for (int i = 0; i < configs.length; i++) {
|
for (int i = 0; i < configs.length; i++) {
|
||||||
final IConfigurationElement element = configs[i];
|
final IConfigurationElement element = configs[i];
|
||||||
if (ELEMENT_PDOM_LINKAGE_FACTORY.equals(element.getName())) {
|
if (ELEMENT_PDOM_LINKAGE_FACTORY.equals(element.getName())) {
|
||||||
SafeRunner.run(new ISafeRunnable(){
|
SafeRunner.run(new ISafeRunnable() {
|
||||||
public void handleException(Throwable exception) {
|
public void handleException(Throwable exception) {
|
||||||
CCorePlugin.log(exception);
|
CCorePlugin.log(exception);
|
||||||
}
|
}
|
||||||
|
@ -369,14 +367,14 @@ public class LanguageManager {
|
||||||
final IConfigurationElement languageElem = configs[j];
|
final IConfigurationElement languageElem = configs[j];
|
||||||
if (ELEMENT_LANGUAGE.equals(languageElem.getName())) {
|
if (ELEMENT_LANGUAGE.equals(languageElem.getName())) {
|
||||||
String langId = getLanguageID(languageElem);
|
String langId = getLanguageID(languageElem);
|
||||||
final ILanguage[] result= new ILanguage[]{null};
|
final ILanguage[] result= new ILanguage[] { null };
|
||||||
SafeRunner.run(new ISafeRunnable(){
|
SafeRunner.run(new ISafeRunnable() {
|
||||||
public void handleException(Throwable exception) {
|
public void handleException(Throwable exception) {
|
||||||
CCorePlugin.log(exception);
|
CCorePlugin.log(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
result[0]= (ILanguage)languageElem.createExecutableExtension(ATTRIBUTE_CLASS);
|
result[0]= (ILanguage) languageElem.createExecutableExtension(ATTRIBUTE_CLASS);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (result[0] != null) {
|
if (result[0] != null) {
|
||||||
|
@ -490,8 +488,7 @@ public class LanguageManager {
|
||||||
|
|
||||||
IContentType contentType = CContentTypes.getContentType(project, fullPathToFile);
|
IContentType contentType = CContentTypes.getContentType(project, fullPathToFile);
|
||||||
|
|
||||||
if(contentType == null)
|
if (contentType == null) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,8 +557,7 @@ public class LanguageManager {
|
||||||
public ILanguage getLanguageForFile(IFile file, ICConfigurationDescription configuration) throws CoreException {
|
public ILanguage getLanguageForFile(IFile file, ICConfigurationDescription configuration) throws CoreException {
|
||||||
return getLanguageForFile(file, configuration, null);
|
return getLanguageForFile(file, configuration, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an ILanguage representing the language to be used for the given file.
|
* Returns an ILanguage representing the language to be used for the given file.
|
||||||
* @return an ILanguage representing the language to be used for the given file
|
* @return an ILanguage representing the language to be used for the given file
|
||||||
|
@ -572,12 +568,12 @@ public class LanguageManager {
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public ILanguage getLanguageForFile(IFile file, ICConfigurationDescription configuration, String contentTypeId) throws CoreException {
|
public ILanguage getLanguageForFile(IFile file, ICConfigurationDescription configuration,
|
||||||
|
String contentTypeId) throws CoreException {
|
||||||
IProject project = file.getProject();
|
IProject project = file.getProject();
|
||||||
|
|
||||||
if (contentTypeId == null) {
|
if (contentTypeId == null) {
|
||||||
IContentType contentType=
|
IContentType contentType= CContentTypes.getContentType(project, file.getLocation().toString());
|
||||||
CContentTypes.getContentType(project, file.getLocation().toString());
|
|
||||||
if (contentType == null) {
|
if (contentType == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,8 @@ class PDOMCache {
|
||||||
* Returns the instance of the cache
|
* Returns the instance of the cache
|
||||||
*/
|
*/
|
||||||
public static PDOMCache getInstance() {
|
public static PDOMCache getInstance() {
|
||||||
synchronized(singletonMutex) {
|
synchronized (singletonMutex) {
|
||||||
if(singleton == null) {
|
if (singleton == null) {
|
||||||
singleton = new PDOMCache();
|
singleton = new PDOMCache();
|
||||||
}
|
}
|
||||||
return singleton;
|
return singleton;
|
||||||
|
@ -55,23 +55,22 @@ class PDOMCache {
|
||||||
* @return a PDOM instance or null if the PDOM version was too old
|
* @return a PDOM instance or null if the PDOM version was too old
|
||||||
*/
|
*/
|
||||||
public PDOM getPDOM(IPath path, IIndexLocationConverter converter) {
|
public PDOM getPDOM(IPath path, IIndexLocationConverter converter) {
|
||||||
|
if (path == null){
|
||||||
if (path==null){
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
PDOM result= null;
|
PDOM result= null;
|
||||||
File file = path.toFile();
|
File file = path.toFile();
|
||||||
|
|
||||||
synchronized(path2pdom) {
|
synchronized (path2pdom) {
|
||||||
if(path2pdom.containsKey(file)) {
|
if (path2pdom.containsKey(file)) {
|
||||||
result= path2pdom.get(file);
|
result= path2pdom.get(file);
|
||||||
}
|
}
|
||||||
if(result==null) {
|
if (result == null) {
|
||||||
try {
|
try {
|
||||||
result= new PDOM(file, converter, LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
|
result= new PDOM(file, converter, LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
|
||||||
path2pdom.put(file, result);
|
path2pdom.put(file, result);
|
||||||
} catch(CoreException ce) {
|
} catch (CoreException ce) {
|
||||||
CCorePlugin.log(ce);
|
CCorePlugin.log(ce);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.viewsupport;
|
package org.eclipse.cdt.internal.ui.viewsupport;
|
||||||
|
|
||||||
|
@ -108,8 +108,7 @@ public class IndexUI {
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
return index.findBinding(name);
|
return index.findBinding(name);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
String name= element.getElementName();
|
String name= element.getElementName();
|
||||||
name= name.substring(name.lastIndexOf(':')+1);
|
name= name.substring(name.lastIndexOf(':')+1);
|
||||||
IIndexBinding[] bindings= index.findBindings(name.toCharArray(), IndexFilter.ALL, new NullProgressMonitor());
|
IIndexBinding[] bindings= index.findBindings(name.toCharArray(), IndexFilter.ALL, new NullProgressMonitor());
|
||||||
|
@ -190,9 +189,9 @@ public class IndexUI {
|
||||||
for (IIndexFile file : files) {
|
for (IIndexFile file : files) {
|
||||||
if (linkageID == -1 || file.getLinkageID() == linkageID) {
|
if (linkageID == -1 || file.getLinkageID() == linkageID) {
|
||||||
String elementName= element.getElementName();
|
String elementName= element.getElementName();
|
||||||
int idx= elementName.lastIndexOf(":")+1; //$NON-NLS-1$
|
int idx= elementName.lastIndexOf(":") + 1; //$NON-NLS-1$
|
||||||
ISourceRange pos= sf.getSourceRange();
|
ISourceRange pos= sf.getSourceRange();
|
||||||
IRegion region = getConvertedRegion(tu, file, pos.getIdStartPos()+idx, pos.getIdLength()-idx);
|
IRegion region = getConvertedRegion(tu, file, pos.getIdStartPos() + idx, pos.getIdLength() - idx);
|
||||||
IIndexName[] names= file.findNames(region.getOffset(), region.getLength());
|
IIndexName[] names= file.findNames(region.getOffset(), region.getLength());
|
||||||
for (IIndexName name2 : names) {
|
for (IIndexName name2 : names) {
|
||||||
IIndexName name = name2;
|
IIndexName name = name2;
|
||||||
|
@ -223,9 +222,11 @@ public class IndexUI {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IRegion getConvertedRegion(ITranslationUnit tu, IIndexFile file, int pos, int length) throws CoreException {
|
private static IRegion getConvertedRegion(ITranslationUnit tu, IIndexFile file, int pos,
|
||||||
|
int length) throws CoreException {
|
||||||
IRegion region= new Region(pos, length);
|
IRegion region= new Region(pos, length);
|
||||||
IPositionConverter converter= CCorePlugin.getPositionTrackerManager().findPositionConverter(tu, file.getTimestamp());
|
IPositionConverter converter=
|
||||||
|
CCorePlugin.getPositionTrackerManager().findPositionConverter(tu, file.getTimestamp());
|
||||||
if (converter != null) {
|
if (converter != null) {
|
||||||
region= converter.actualToHistoric(region);
|
region= converter.actualToHistoric(region);
|
||||||
}
|
}
|
||||||
|
@ -248,7 +249,7 @@ public class IndexUI {
|
||||||
int bestDiff= Integer.MAX_VALUE;
|
int bestDiff= Integer.MAX_VALUE;
|
||||||
IIndexInclude best= null;
|
IIndexInclude best= null;
|
||||||
for (IIndexInclude candidate : includes) {
|
for (IIndexInclude candidate : includes) {
|
||||||
int diff= Math.abs(candidate.getNameOffset()- region.getOffset());
|
int diff= Math.abs(candidate.getNameOffset() - region.getOffset());
|
||||||
if (diff > bestDiff) {
|
if (diff > bestDiff) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +289,6 @@ public class IndexUI {
|
||||||
if (definition != null) {
|
if (definition != null) {
|
||||||
result.add(definition);
|
result.add(definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return result.toArray(new ICElementHandle[result.size()]);
|
return result.toArray(new ICElementHandle[result.size()]);
|
||||||
}
|
}
|
||||||
|
@ -513,7 +513,6 @@ public class IndexUI {
|
||||||
if (result == null)
|
if (result == null)
|
||||||
result= new ArrayList<IBinding>(instances.size());
|
result= new ArrayList<IBinding>(instances.size());
|
||||||
|
|
||||||
|
|
||||||
for (ICPPTemplateInstance inst : instances) {
|
for (ICPPTemplateInstance inst : instances) {
|
||||||
if (!ASTInternal.hasDeclaration(inst)) {
|
if (!ASTInternal.hasDeclaration(inst)) {
|
||||||
result.add(inst);
|
result.add(inst);
|
||||||
|
|
Loading…
Add table
Reference in a new issue