mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 06:55:23 +02:00
Makes relevant methods/options of AbstractLanguage available in ILanguage + cleanup.
This commit is contained in:
parent
e885c18bc4
commit
8565f9f346
10 changed files with 145 additions and 161 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,11 +9,9 @@
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.model;
|
package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
|
@ -27,40 +25,6 @@ import org.eclipse.core.runtime.PlatformObject;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractLanguage extends PlatformObject implements ILanguage {
|
public abstract class AbstractLanguage extends PlatformObject implements ILanguage {
|
||||||
/**
|
|
||||||
* Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
|
||||||
* Instructs the parser to skip function and method bodies.
|
|
||||||
*/
|
|
||||||
public final static int OPTION_SKIP_FUNCTION_BODIES= 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
|
||||||
* Instructs the parser to add comment nodes to the ast.
|
|
||||||
*/
|
|
||||||
public final static int OPTION_ADD_COMMENTS= 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
|
||||||
* Performance optimization, instructs the parser not to create image-locations.
|
|
||||||
* When using this option {@link IASTName#getImageLocation()} will always return <code>null</code>.
|
|
||||||
*/
|
|
||||||
public final static int OPTION_NO_IMAGE_LOCATIONS= 4;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated, throws an UnsupportedOperationException
|
|
||||||
*/
|
|
||||||
final public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, int style) throws CoreException {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated, throws an UnsupportedOperationException
|
|
||||||
*/
|
|
||||||
final public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, ICodeReaderFactory codeReaderFactory,
|
|
||||||
int style) throws CoreException {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.core.model.ILanguage#getName()
|
* @see org.eclipse.cdt.core.model.ILanguage#getName()
|
||||||
*/
|
*/
|
||||||
|
@ -72,21 +36,6 @@ public abstract class AbstractLanguage extends PlatformObject implements ILangua
|
||||||
return getId();
|
return getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an AST for the source code provided by <code>reader</code>.
|
|
||||||
* As an option you can supply
|
|
||||||
* @param reader source code to be parsed.
|
|
||||||
* @param scanInfo provides include paths and defined symbols.
|
|
||||||
* @param fileCreator factory that provides CodeReaders for files included
|
|
||||||
* by the source code being parsed.
|
|
||||||
* @param index (optional) index to use to provide support for ambiguity
|
|
||||||
* resolution.
|
|
||||||
* @param options A combination of
|
|
||||||
* {@link #OPTION_SKIP_FUNCTION_BODIES} and {@link #OPTION_ADD_COMMENTS} or <code>0</code>.
|
|
||||||
* @param log logger
|
|
||||||
* @return an AST for the source code provided by reader.
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index, int options, IParserLogService log)
|
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index, int options, IParserLogService log)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
// for backwards compatibility
|
// for backwards compatibility
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 QNX Software Systems and others.
|
* Copyright (c) 2005, 2008 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,7 +10,6 @@
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.model;
|
package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
|
@ -32,8 +31,31 @@ import org.eclipse.core.runtime.IAdaptable;
|
||||||
*/
|
*/
|
||||||
public interface ILanguage extends IAdaptable {
|
public interface ILanguage extends IAdaptable {
|
||||||
|
|
||||||
//public static final QualifiedName KEY = new QualifiedName(CCorePlugin.PLUGIN_ID, "language"); //$NON-NLS-1$
|
/**
|
||||||
public static final String KEY = "language"; //$NON-NLS-1$
|
* Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
||||||
|
* Instructs the parser to skip function and method bodies.
|
||||||
|
*/
|
||||||
|
public final static int OPTION_SKIP_FUNCTION_BODIES= 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
||||||
|
* Instructs the parser to add comment nodes to the ast.
|
||||||
|
*/
|
||||||
|
public final static int OPTION_ADD_COMMENTS= 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
||||||
|
* Performance optimization, instructs the parser not to create image-locations.
|
||||||
|
* When using this option {@link IASTName#getImageLocation()} will always return <code>null</code>.
|
||||||
|
*/
|
||||||
|
public final static int OPTION_NO_IMAGE_LOCATIONS= 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
||||||
|
* Marks the ast as being based on a source-file rather than a header-file. This makes a difference
|
||||||
|
* when bindings from the AST are used for searching the index, e.g. for static variables.
|
||||||
|
*/
|
||||||
|
public final static int OPTION_IS_SOURCE_UNIT= 8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the language id for this language.
|
* Return the language id for this language.
|
||||||
|
@ -55,21 +77,6 @@ public interface ILanguage extends IAdaptable {
|
||||||
*/
|
*/
|
||||||
public String getName();
|
public String getName();
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link ITranslationUnit#getAST()}.
|
|
||||||
*/
|
|
||||||
public IASTTranslationUnit getASTTranslationUnit(
|
|
||||||
ITranslationUnit file,
|
|
||||||
int style) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use {@link ITranslationUnit#getAST(...)}.
|
|
||||||
*/
|
|
||||||
public IASTTranslationUnit getASTTranslationUnit(
|
|
||||||
ITranslationUnit file,
|
|
||||||
ICodeReaderFactory codeReaderFactory,
|
|
||||||
int style) throws CoreException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the AST completion node for the given offset.
|
* Return the AST completion node for the given offset.
|
||||||
*
|
*
|
||||||
|
@ -109,6 +116,8 @@ public interface ILanguage extends IAdaptable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an AST for the source code provided by <code>reader</code>.
|
* Construct an AST for the source code provided by <code>reader</code>.
|
||||||
|
* Fully equivalent to
|
||||||
|
* <code> getASTTranslationUnit(reader, scanInfo, fileCreator, index, 0, log) </code>
|
||||||
* @param reader source code to be parsed.
|
* @param reader source code to be parsed.
|
||||||
* @param scanInfo provides include paths and defined symbols.
|
* @param scanInfo provides include paths and defined symbols.
|
||||||
* @param fileCreator factory that provides CodeReaders for files included
|
* @param fileCreator factory that provides CodeReaders for files included
|
||||||
|
@ -119,5 +128,29 @@ public interface ILanguage extends IAdaptable {
|
||||||
* @return an AST for the source code provided by reader.
|
* @return an AST for the source code provided by reader.
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index, IParserLogService log) throws CoreException;
|
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo,
|
||||||
|
ICodeReaderFactory fileCreator, IIndex index, IParserLogService log)
|
||||||
|
throws CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct an AST for the source code provided by <code>reader</code>.
|
||||||
|
* As an option you can supply
|
||||||
|
* @param reader source code to be parsed.
|
||||||
|
* @param scanInfo provides include paths and defined symbols.
|
||||||
|
* @param fileCreator factory that provides CodeReaders for files included
|
||||||
|
* by the source code being parsed.
|
||||||
|
* @param index (optional) index to use to provide support for ambiguity
|
||||||
|
* resolution.
|
||||||
|
* @param options A combination of
|
||||||
|
* {@link #OPTION_SKIP_FUNCTION_BODIES}, {@link #OPTION_ADD_COMMENTS},
|
||||||
|
* {@link #OPTION_NO_IMAGE_LOCATIONS}, {@link #OPTION_IS_SOURCE_UNIT},
|
||||||
|
* or <code>0</code>.
|
||||||
|
* @param log logger
|
||||||
|
* @return an AST for the source code provided by reader.
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo,
|
||||||
|
ICodeReaderFactory fileCreator, IIndex index, int options, IParserLogService log)
|
||||||
|
throws CoreException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -221,13 +220,13 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
|
|
||||||
public IInclude[] getIncludes() throws CModelException {
|
public IInclude[] getIncludes() throws CModelException {
|
||||||
ICElement[] celements = getChildren();
|
ICElement[] celements = getChildren();
|
||||||
ArrayList aList = new ArrayList();
|
ArrayList<ICElement> aList = new ArrayList<ICElement>();
|
||||||
for (int i = 0; i < celements.length; i++) {
|
for (int i = 0; i < celements.length; i++) {
|
||||||
if (celements[i].getElementType() == ICElement.C_INCLUDE) {
|
if (celements[i].getElementType() == ICElement.C_INCLUDE) {
|
||||||
aList.add(celements[i]);
|
aList.add(celements[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (IInclude[]) aList.toArray(new IInclude[0]);
|
return aList.toArray(new IInclude[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IUsing getUsing(String name) {
|
public IUsing getUsing(String name) {
|
||||||
|
@ -247,13 +246,13 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
|
|
||||||
public IUsing[] getUsings() throws CModelException {
|
public IUsing[] getUsings() throws CModelException {
|
||||||
ICElement[] celements = getChildren();
|
ICElement[] celements = getChildren();
|
||||||
ArrayList aList = new ArrayList();
|
ArrayList<ICElement> aList = new ArrayList<ICElement>();
|
||||||
for (int i = 0; i < celements.length; i++) {
|
for (int i = 0; i < celements.length; i++) {
|
||||||
if (celements[i].getElementType() == ICElement.C_USING) {
|
if (celements[i].getElementType() == ICElement.C_USING) {
|
||||||
aList.add(celements[i]);
|
aList.add(celements[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (IUsing[]) aList.toArray(new IUsing[0]);
|
return aList.toArray(new IUsing[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public INamespace getNamespace(String name) {
|
public INamespace getNamespace(String name) {
|
||||||
|
@ -286,13 +285,13 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
|
|
||||||
public INamespace[] getNamespaces() throws CModelException {
|
public INamespace[] getNamespaces() throws CModelException {
|
||||||
ICElement[] celements = getChildren();
|
ICElement[] celements = getChildren();
|
||||||
ArrayList aList = new ArrayList();
|
ArrayList<ICElement> aList = new ArrayList<ICElement>();
|
||||||
for (int i = 0; i < celements.length; i++) {
|
for (int i = 0; i < celements.length; i++) {
|
||||||
if (celements[i].getElementType() == ICElement.C_NAMESPACE) {
|
if (celements[i].getElementType() == ICElement.C_NAMESPACE) {
|
||||||
aList.add(celements[i]);
|
aList.add(celements[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (INamespace[]) aList.toArray(new INamespace[0]);
|
return aList.toArray(new INamespace[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setLocationURI(URI loc) {
|
protected void setLocationURI(URI loc) {
|
||||||
|
@ -786,24 +785,17 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
fLanguageOfContext= language;
|
fLanguageOfContext= language;
|
||||||
if (language != null) {
|
if (language != null) {
|
||||||
ICodeReaderFactory crf= getCodeReaderFactory(style, index, language.getLinkageID());
|
ICodeReaderFactory crf= getCodeReaderFactory(style, index, language.getLinkageID());
|
||||||
IASTTranslationUnit ast= null;
|
int options= 0;
|
||||||
if (language instanceof AbstractLanguage) {
|
if ((style & AST_SKIP_FUNCTION_BODIES) != 0) {
|
||||||
int options= 0;
|
options |= ILanguage.OPTION_SKIP_FUNCTION_BODIES;
|
||||||
if ((style & AST_SKIP_FUNCTION_BODIES) != 0) {
|
|
||||||
options |= AbstractLanguage.OPTION_SKIP_FUNCTION_BODIES;
|
|
||||||
}
|
|
||||||
if ((style & AST_CREATE_COMMENT_NODES) != 0) {
|
|
||||||
options |= AbstractLanguage.OPTION_ADD_COMMENTS;
|
|
||||||
}
|
|
||||||
ast= ((AbstractLanguage)language).getASTTranslationUnit(reader, scanInfo, crf, index, options, ParserUtil.getParserLogService());
|
|
||||||
}
|
}
|
||||||
else {
|
if ((style & AST_CREATE_COMMENT_NODES) != 0) {
|
||||||
ast= language.getASTTranslationUnit(reader, scanInfo, crf, index, ParserUtil.getParserLogService());
|
options |= ILanguage.OPTION_ADD_COMMENTS;
|
||||||
}
|
}
|
||||||
if (ast != null) {
|
if (isSourceUnit()) {
|
||||||
ast.setIsHeaderUnit(isHeaderUnit());
|
options |= ILanguage.OPTION_IS_SOURCE_UNIT;
|
||||||
}
|
}
|
||||||
return ast;
|
return ((AbstractLanguage)language).getASTTranslationUnit(reader, scanInfo, crf, index, options, ParserUtil.getParserLogService());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -836,7 +828,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
IIndexFile indexFile= index.getFile(CTX_LINKAGES[i], ifl);
|
IIndexFile indexFile= index.getFile(CTX_LINKAGES[i], ifl);
|
||||||
if (indexFile != null) {
|
if (indexFile != null) {
|
||||||
// bug 199412, when a source-file includes itself the context may recurse.
|
// bug 199412, when a source-file includes itself the context may recurse.
|
||||||
HashSet visited= new HashSet();
|
HashSet<IIndexFile> visited= new HashSet<IIndexFile>();
|
||||||
visited.add(indexFile);
|
visited.add(indexFile);
|
||||||
indexFile = getParsedInContext(indexFile);
|
indexFile = getParsedInContext(indexFile);
|
||||||
while (indexFile != null && visited.add(indexFile)) {
|
while (indexFile != null && visited.add(indexFile)) {
|
||||||
|
|
|
@ -115,12 +115,13 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
|
||||||
|
|
||||||
IScanner scanner= createScanner(reader, scanInfo, codeReaderFactory, log);
|
IScanner scanner= createScanner(reader, scanInfo, codeReaderFactory, log);
|
||||||
scanner.setScanComments((options & OPTION_ADD_COMMENTS) != 0);
|
scanner.setScanComments((options & OPTION_ADD_COMMENTS) != 0);
|
||||||
scanner.setComputeImageLocations((options & AbstractLanguage.OPTION_NO_IMAGE_LOCATIONS) == 0);
|
scanner.setComputeImageLocations((options & OPTION_NO_IMAGE_LOCATIONS) == 0);
|
||||||
|
|
||||||
ISourceCodeParser parser= createParser(scanner, log, index, false, options);
|
ISourceCodeParser parser= createParser(scanner, log, index, false, options);
|
||||||
|
|
||||||
// Parse
|
// Parse
|
||||||
IASTTranslationUnit ast= parser.parse();
|
IASTTranslationUnit ast= parser.parse();
|
||||||
|
ast.setIsHeaderUnit((options & OPTION_IS_SOURCE_UNIT) == 0);
|
||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,8 +205,8 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
|
||||||
|
|
||||||
CharArrayIntMap additionalKeywords = getScannerExtensionConfiguration().getAdditionalKeywords();
|
CharArrayIntMap additionalKeywords = getScannerExtensionConfiguration().getAdditionalKeywords();
|
||||||
if (additionalKeywords != null) {
|
if (additionalKeywords != null) {
|
||||||
for (Iterator iterator = additionalKeywords.toList().iterator(); iterator.hasNext(); ) {
|
for (Iterator<char[]> iterator = additionalKeywords.toList().iterator(); iterator.hasNext(); ) {
|
||||||
char[] name = (char[]) iterator.next();
|
char[] name = iterator.next();
|
||||||
keywords.add(new String(name));
|
keywords.add(new String(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,8 +224,8 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
|
||||||
Set<String> keywords = new HashSet<String>(KeywordSets.getKeywords(KeywordSetKey.PP_DIRECTIVE, getParserLanguage()));
|
Set<String> keywords = new HashSet<String>(KeywordSets.getKeywords(KeywordSetKey.PP_DIRECTIVE, getParserLanguage()));
|
||||||
CharArrayIntMap additionalKeywords= getScannerExtensionConfiguration().getAdditionalPreprocessorKeywords();
|
CharArrayIntMap additionalKeywords= getScannerExtensionConfiguration().getAdditionalPreprocessorKeywords();
|
||||||
if (additionalKeywords != null) {
|
if (additionalKeywords != null) {
|
||||||
for (Iterator iterator = additionalKeywords.toList().iterator(); iterator.hasNext(); ) {
|
for (Iterator<char[]> iterator = additionalKeywords.toList().iterator(); iterator.hasNext(); ) {
|
||||||
char[] name = (char[]) iterator.next();
|
char[] name = iterator.next();
|
||||||
keywords.add(new String(name));
|
keywords.add(new String(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2007 IBM Corporation and others.
|
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -111,8 +111,8 @@ public class CharTable extends HashTable {
|
||||||
removeEntry(i, hash);
|
removeEntry(i, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List toList(){
|
public List<char[]> toList(){
|
||||||
List list = new ArrayList( size() );
|
List<char[]> list = new ArrayList<char[]>( size() );
|
||||||
int size = size();
|
int size = size();
|
||||||
for( int i = 0; i < size; i++ ){
|
for( int i = 0; i < size; i++ ){
|
||||||
list.add( keyAt( i ) );
|
list.add( keyAt( i ) );
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class CASTTranslationUnit extends CASTNode implements IASTTranslationUnit
|
||||||
private CScope compilationUnit = null;
|
private CScope compilationUnit = null;
|
||||||
private ILocationResolver resolver;
|
private ILocationResolver resolver;
|
||||||
private IIndex index;
|
private IIndex index;
|
||||||
private boolean fIsHeader;
|
private boolean fIsHeader= true;
|
||||||
private IIndexFileSet fIndexFileSet;
|
private IIndexFileSet fIndexFileSet;
|
||||||
|
|
||||||
public IASTTranslationUnit getTranslationUnit() {
|
public IASTTranslationUnit getTranslationUnit() {
|
||||||
|
|
|
@ -87,9 +87,12 @@ public class CPPASTTranslationUnit extends CPPASTNode implements ICPPASTTranslat
|
||||||
private ILocationResolver resolver;
|
private ILocationResolver resolver;
|
||||||
private IIndex index;
|
private IIndex index;
|
||||||
private IIndexFileSet fIndexFileSet;
|
private IIndexFileSet fIndexFileSet;
|
||||||
private boolean fIsHeader;
|
private boolean fIsHeader= true;
|
||||||
private HashMap<IIndexScope, IScope> fMappedScopes= new HashMap<IIndexScope, IScope>();
|
private HashMap<IIndexScope, IScope> fMappedScopes= new HashMap<IIndexScope, IScope>();
|
||||||
|
|
||||||
|
public CPPASTTranslationUnit() {
|
||||||
|
}
|
||||||
|
|
||||||
public IASTTranslationUnit getTranslationUnit() {
|
public IASTTranslationUnit getTranslationUnit() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -36,6 +36,7 @@ import org.eclipse.cdt.core.index.IIndexMacro;
|
||||||
import org.eclipse.cdt.core.index.IIndexManager;
|
import org.eclipse.cdt.core.index.IIndexManager;
|
||||||
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.AbstractLanguage;
|
import org.eclipse.cdt.core.model.AbstractLanguage;
|
||||||
|
import org.eclipse.cdt.core.model.ILanguage;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
|
import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
|
@ -86,11 +87,11 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
private int fUpdateFlags= IIndexManager.UPDATE_ALL;
|
private int fUpdateFlags= IIndexManager.UPDATE_ALL;
|
||||||
private boolean fIndexHeadersWithoutContext= true;
|
private boolean fIndexHeadersWithoutContext= true;
|
||||||
private boolean fIndexFilesWithoutConfiguration= true;
|
private boolean fIndexFilesWithoutConfiguration= true;
|
||||||
private HashMap fFileInfos= new HashMap();
|
private HashMap<FileKey, FileInfo> fFileInfos= new HashMap<FileKey, FileInfo>();
|
||||||
|
|
||||||
private Object[] fFilesToUpdate;
|
private Object[] fFilesToUpdate;
|
||||||
private List fFilesToRemove = new ArrayList();
|
private List<Object> fFilesToRemove = new ArrayList<Object>();
|
||||||
private List fFilesUpFront= new ArrayList();
|
private List<String> fFilesUpFront= new ArrayList<String>();
|
||||||
private int fASTOptions;
|
private int fASTOptions;
|
||||||
|
|
||||||
protected IWritableIndex fIndex;
|
protected IWritableIndex fIndex;
|
||||||
|
@ -135,8 +136,6 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
return "______"; //$NON-NLS-1$
|
return "______"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private final IASTTranslationUnit createAST(String code, AbstractLanguage lang, IScannerInfo scanInfo,
|
private final IASTTranslationUnit createAST(String code, AbstractLanguage lang, IScannerInfo scanInfo,
|
||||||
int options, IProgressMonitor monitor) throws CoreException {
|
int options, IProgressMonitor monitor) throws CoreException {
|
||||||
String dummyName= getASTPathForParsingUpFront();
|
String dummyName= getASTPathForParsingUpFront();
|
||||||
|
@ -156,12 +155,10 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
if (codeReader == null) {
|
if (codeReader == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (fResolver.isSourceUnit(tu)) {
|
||||||
IASTTranslationUnit ast= createAST(language, codeReader, scanInfo, options, pm);
|
options |= ILanguage.OPTION_IS_SOURCE_UNIT;
|
||||||
if (ast != null && !fResolver.isSourceUnit(tu)) {
|
|
||||||
ast.setIsHeaderUnit(true);
|
|
||||||
}
|
}
|
||||||
return ast;
|
return createAST(language, codeReader, scanInfo, options, pm);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final IASTTranslationUnit createAST(AbstractLanguage language, CodeReader codeReader,
|
private final IASTTranslationUnit createAST(AbstractLanguage language, CodeReader codeReader,
|
||||||
|
@ -203,9 +200,9 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
}
|
}
|
||||||
fTodoTaskUpdater= createTodoTaskUpdater();
|
fTodoTaskUpdater= createTodoTaskUpdater();
|
||||||
|
|
||||||
fASTOptions= AbstractLanguage.OPTION_ADD_COMMENTS | AbstractLanguage.OPTION_NO_IMAGE_LOCATIONS;
|
fASTOptions= ILanguage.OPTION_ADD_COMMENTS | ILanguage.OPTION_NO_IMAGE_LOCATIONS;
|
||||||
if (getSkipReferences() == SKIP_ALL_REFERENCES) {
|
if (getSkipReferences() == SKIP_ALL_REFERENCES) {
|
||||||
fASTOptions |= AbstractLanguage.OPTION_SKIP_FUNCTION_BODIES;
|
fASTOptions |= ILanguage.OPTION_SKIP_FUNCTION_BODIES;
|
||||||
}
|
}
|
||||||
|
|
||||||
fIndex.resetCacheCounters();
|
fIndex.resetCacheCounters();
|
||||||
|
@ -214,8 +211,8 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
// split into sources and headers, remove excluded sources.
|
// split into sources and headers, remove excluded sources.
|
||||||
final HashMap files= new HashMap();
|
final HashMap<Integer, List<Object>> files= new HashMap<Integer, List<Object>>();
|
||||||
final ArrayList ifilesToRemove= new ArrayList();
|
final ArrayList<IIndexFragmentFile> ifilesToRemove= new ArrayList<IIndexFragmentFile>();
|
||||||
extractFiles(files, ifilesToRemove, monitor);
|
extractFiles(files, ifilesToRemove, monitor);
|
||||||
|
|
||||||
// remove files from index
|
// remove files from index
|
||||||
|
@ -237,7 +234,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void extractFiles(Map files, List iFilesToRemove, IProgressMonitor monitor) throws CoreException {
|
private void extractFiles(Map<Integer, List<Object>> files, List<IIndexFragmentFile> iFilesToRemove, IProgressMonitor monitor) throws CoreException {
|
||||||
final boolean force= (fUpdateFlags & IIndexManager.UPDATE_ALL) != 0;
|
final boolean force= (fUpdateFlags & IIndexManager.UPDATE_ALL) != 0;
|
||||||
final boolean checkTimestamps= (fUpdateFlags & IIndexManager.UPDATE_CHECK_TIMESTAMPS) != 0;
|
final boolean checkTimestamps= (fUpdateFlags & IIndexManager.UPDATE_CHECK_TIMESTAMPS) != 0;
|
||||||
final boolean checkConfig= (fUpdateFlags & IIndexManager.UPDATE_CHECK_CONFIGURATION) != 0;
|
final boolean checkConfig= (fUpdateFlags & IIndexManager.UPDATE_CHECK_CONFIGURATION) != 0;
|
||||||
|
@ -311,7 +308,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
|
|
||||||
private void requestUpdate(int linkageID, IIndexFileLocation ifl, IIndexFragmentFile ifile) {
|
private void requestUpdate(int linkageID, IIndexFileLocation ifl, IIndexFragmentFile ifile) {
|
||||||
FileKey key= new FileKey(linkageID, ifl.getURI());
|
FileKey key= new FileKey(linkageID, ifl.getURI());
|
||||||
FileInfo info= (FileInfo) fFileInfos.get(key);
|
FileInfo info= fFileInfos.get(key);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
info= createFileInfo(key, null);
|
info= createFileInfo(key, null);
|
||||||
}
|
}
|
||||||
|
@ -321,7 +318,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
|
|
||||||
private void setIndexed(int linkageID, IIndexFileLocation ifl) {
|
private void setIndexed(int linkageID, IIndexFileLocation ifl) {
|
||||||
FileKey key= new FileKey(linkageID, ifl.getURI());
|
FileKey key= new FileKey(linkageID, ifl.getURI());
|
||||||
FileInfo info= (FileInfo) fFileInfos.get(key);
|
FileInfo info= fFileInfos.get(key);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
info= createFileInfo(key, null);
|
info= createFileInfo(key, null);
|
||||||
}
|
}
|
||||||
|
@ -338,7 +335,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
|
|
||||||
private FileInfo getFileInfo(int linkageID, IIndexFileLocation ifl) {
|
private FileInfo getFileInfo(int linkageID, IIndexFileLocation ifl) {
|
||||||
FileKey key= new FileKey(linkageID, ifl.getURI());
|
FileKey key= new FileKey(linkageID, ifl.getURI());
|
||||||
return (FileInfo) fFileInfos.get(key);
|
return fFileInfos.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSourceUnitConfigChange(Object tu, IIndexFragmentFile ifile) {
|
private boolean isSourceUnitConfigChange(Object tu, IIndexFragmentFile ifile) {
|
||||||
|
@ -368,11 +365,11 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void store(Object tu, int linkageID, boolean isSourceUnit, Map files) {
|
private void store(Object tu, int linkageID, boolean isSourceUnit, Map<Integer, List<Object>> files) {
|
||||||
Integer key = getFileListKey(linkageID, isSourceUnit);
|
Integer key = getFileListKey(linkageID, isSourceUnit);
|
||||||
List list= (List) files.get(key);
|
List<Object> list= files.get(key);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list= new LinkedList();
|
list= new LinkedList<Object>();
|
||||||
files.put(key, list);
|
files.put(key, list);
|
||||||
}
|
}
|
||||||
list.add(tu);
|
list.add(tu);
|
||||||
|
@ -383,11 +380,11 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeFilesInIndex(List filesToRemove, List ifilesToRemove, IProgressMonitor monitor) throws InterruptedException, CoreException {
|
private void removeFilesInIndex(List<Object> filesToRemove, List<IIndexFragmentFile> ifilesToRemove, IProgressMonitor monitor) throws InterruptedException, CoreException {
|
||||||
if (!filesToRemove.isEmpty() || !ifilesToRemove.isEmpty()) {
|
if (!filesToRemove.isEmpty() || !ifilesToRemove.isEmpty()) {
|
||||||
fIndex.acquireWriteLock(1);
|
fIndex.acquireWriteLock(1);
|
||||||
try {
|
try {
|
||||||
for (Iterator iterator = fFilesToRemove.iterator(); iterator.hasNext();) {
|
for (Iterator<Object> iterator = fFilesToRemove.iterator(); iterator.hasNext();) {
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -400,11 +397,11 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
}
|
}
|
||||||
updateInfo(0, 0, -1);
|
updateInfo(0, 0, -1);
|
||||||
}
|
}
|
||||||
for (Iterator iterator = ifilesToRemove.iterator(); iterator.hasNext();) {
|
for (Iterator<IIndexFragmentFile> iterator = ifilesToRemove.iterator(); iterator.hasNext();) {
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IIndexFragmentFile ifile= (IIndexFragmentFile) iterator.next();
|
IIndexFragmentFile ifile= iterator.next();
|
||||||
fIndex.clearFile(ifile, null);
|
fIndex.clearFile(ifile, null);
|
||||||
updateInfo(0, 0, -1);
|
updateInfo(0, 0, -1);
|
||||||
}
|
}
|
||||||
|
@ -416,11 +413,11 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseFilesUpFront(IProgressMonitor monitor) throws CoreException {
|
private void parseFilesUpFront(IProgressMonitor monitor) throws CoreException {
|
||||||
for (Iterator iter = fFilesUpFront.iterator(); iter.hasNext();) {
|
for (Iterator<String> iter = fFilesUpFront.iterator(); iter.hasNext();) {
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String upfront= (String) iter.next();
|
String upfront= iter.next();
|
||||||
String filePath = upfront;
|
String filePath = upfront;
|
||||||
filePath= filePath.trim();
|
filePath= filePath.trim();
|
||||||
if (filePath.length() == 0) {
|
if (filePath.length() == 0) {
|
||||||
|
@ -461,11 +458,11 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
fFilesUpFront.clear();
|
fFilesUpFront.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseLinkage(int linkageID, Map fileListMap, IProgressMonitor monitor) throws CoreException, InterruptedException {
|
private void parseLinkage(int linkageID, Map<Integer, List<Object>> fileListMap, IProgressMonitor monitor) throws CoreException, InterruptedException {
|
||||||
// sources
|
// sources
|
||||||
List files= (List) fileListMap.get(getFileListKey(linkageID, true));
|
List<Object> files= fileListMap.get(getFileListKey(linkageID, true));
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
for (Iterator iter = files.iterator(); iter.hasNext();) {
|
for (Iterator<Object> iter = files.iterator(); iter.hasNext();) {
|
||||||
if (monitor.isCanceled())
|
if (monitor.isCanceled())
|
||||||
return;
|
return;
|
||||||
final Object tu= iter.next();
|
final Object tu= iter.next();
|
||||||
|
@ -484,10 +481,10 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
// headers with context
|
// headers with context
|
||||||
HashMap contextMap= new HashMap();
|
HashMap<IIndexFragmentFile, Object> contextMap= new HashMap<IIndexFragmentFile, Object>();
|
||||||
files= (List) fileListMap.get(getFileListKey(linkageID, false));
|
files= fileListMap.get(getFileListKey(linkageID, false));
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
for (Iterator iter = files.iterator(); iter.hasNext();) {
|
for (Iterator<Object> iter = files.iterator(); iter.hasNext();) {
|
||||||
if (monitor.isCanceled())
|
if (monitor.isCanceled())
|
||||||
return;
|
return;
|
||||||
final Object header= iter.next();
|
final Object header= iter.next();
|
||||||
|
@ -515,7 +512,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
|
|
||||||
// headers without context
|
// headers without context
|
||||||
contextMap= null;
|
contextMap= null;
|
||||||
for (Iterator iter = files.iterator(); iter.hasNext();) {
|
for (Iterator<Object> iter = files.iterator(); iter.hasNext();) {
|
||||||
if (monitor.isCanceled())
|
if (monitor.isCanceled())
|
||||||
return;
|
return;
|
||||||
final Object header= iter.next();
|
final Object header= iter.next();
|
||||||
|
@ -535,7 +532,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Object NO_CONTEXT= new Object();
|
private static Object NO_CONTEXT= new Object();
|
||||||
private Object findContext(IIndexFragmentFile ifile, HashMap contextMap) {
|
private Object findContext(IIndexFragmentFile ifile, HashMap<IIndexFragmentFile, Object> contextMap) {
|
||||||
Object cachedContext= contextMap.get(ifile);
|
Object cachedContext= contextMap.get(ifile);
|
||||||
if (cachedContext != null) {
|
if (cachedContext != null) {
|
||||||
return cachedContext == NO_CONTEXT ? null : cachedContext;
|
return cachedContext == NO_CONTEXT ? null : cachedContext;
|
||||||
|
@ -602,8 +599,8 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeToIndex(final int linkageID, IASTTranslationUnit ast, int configHash, IProgressMonitor pm) throws CoreException, InterruptedException {
|
private void writeToIndex(final int linkageID, IASTTranslationUnit ast, int configHash, IProgressMonitor pm) throws CoreException, InterruptedException {
|
||||||
HashSet enteredASTFilePaths= new HashSet();
|
HashSet<String> enteredASTFilePaths= new HashSet<String>();
|
||||||
ArrayList orderedIFLs= new ArrayList();
|
ArrayList<IIndexFileLocation> orderedIFLs= new ArrayList<IIndexFileLocation>();
|
||||||
final String astPath = ast.getFilePath();
|
final String astPath = ast.getFilePath();
|
||||||
enteredASTFilePaths.add(astPath);
|
enteredASTFilePaths.add(astPath);
|
||||||
|
|
||||||
|
@ -619,7 +616,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
orderedIFLs.add(fResolver.resolveASTPath(astPath));
|
orderedIFLs.add(fResolver.resolveASTPath(astPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
IIndexFileLocation[] ifls= (IIndexFileLocation[]) orderedIFLs.toArray(new IIndexFileLocation[orderedIFLs.size()]);
|
IIndexFileLocation[] ifls= orderedIFLs.toArray(new IIndexFileLocation[orderedIFLs.size()]);
|
||||||
addSymbols(ast, ifls, fIndex, 1, false, configHash, fTodoTaskUpdater, pm);
|
addSymbols(ast, ifls, fIndex, 1, false, configHash, fTodoTaskUpdater, pm);
|
||||||
for (int i = 0; i < ifls.length; i++) {
|
for (int i = 0; i < ifls.length; i++) {
|
||||||
ifl= ifls[i];
|
ifl= ifls[i];
|
||||||
|
@ -631,7 +628,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collectOrderedIFLs(final int linkageID, IASTInclusionNode inclusion, HashSet enteredASTFilePaths, ArrayList orderedIFLs) throws CoreException {
|
private void collectOrderedIFLs(final int linkageID, IASTInclusionNode inclusion, HashSet<String> enteredASTFilePaths, ArrayList<IIndexFileLocation> orderedIFLs) throws CoreException {
|
||||||
final IASTPreprocessorIncludeStatement id= inclusion.getIncludeDirective();
|
final IASTPreprocessorIncludeStatement id= inclusion.getIncludeDirective();
|
||||||
if (id.isActive() && id.isResolved()) {
|
if (id.isActive() && id.isResolved()) {
|
||||||
final String path= id.getPath();
|
final String path= id.getPath();
|
||||||
|
@ -705,12 +702,12 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
|
|
||||||
private static int computeHashCode(IScannerInfo scannerInfo) {
|
private static int computeHashCode(IScannerInfo scannerInfo) {
|
||||||
int result= 0;
|
int result= 0;
|
||||||
Map macros= scannerInfo.getDefinedSymbols();
|
Map<String, String> macros= scannerInfo.getDefinedSymbols();
|
||||||
if (macros != null) {
|
if (macros != null) {
|
||||||
for (Iterator i = macros.entrySet().iterator(); i.hasNext();) {
|
for (Iterator<Map.Entry<String,String>> i = macros.entrySet().iterator(); i.hasNext();) {
|
||||||
Map.Entry entry = (Map.Entry) i.next();
|
Map.Entry<String,String> entry = i.next();
|
||||||
String key = (String) entry.getKey();
|
String key = entry.getKey();
|
||||||
String value = (String) entry.getValue();
|
String value = entry.getValue();
|
||||||
result= addToHashcode(result, key);
|
result= addToHashcode(result, key);
|
||||||
if (value != null && value.length() > 0) {
|
if (value != null && value.length() > 0) {
|
||||||
result= addToHashcode(result, value);
|
result= addToHashcode(result, value);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2007 IBM Corporation and others.
|
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -115,10 +115,11 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
||||||
return null;
|
return null;
|
||||||
IScanner scanner = null;
|
IScanner scanner = null;
|
||||||
ISourceCodeParser parser = null;
|
ISourceCodeParser parser = null;
|
||||||
|
boolean[] isSource= {false};
|
||||||
|
|
||||||
if( configuration == null || configuration.getParserDialect() == null)
|
if( configuration == null || configuration.getParserDialect() == null)
|
||||||
{
|
{
|
||||||
ParserLanguage l = getLanguage(filename, project);
|
ParserLanguage l = getLanguage(filename, project, isSource);
|
||||||
IScannerExtensionConfiguration scannerExtensionConfiguration;
|
IScannerExtensionConfiguration scannerExtensionConfiguration;
|
||||||
if( l == ParserLanguage.CPP )
|
if( l == ParserLanguage.CPP )
|
||||||
scannerExtensionConfiguration = CPP_GNU_SCANNER_EXTENSION;
|
scannerExtensionConfiguration = CPP_GNU_SCANNER_EXTENSION;
|
||||||
|
@ -169,7 +170,9 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Parse
|
// Parse
|
||||||
return parser.parse();
|
IASTTranslationUnit ast= parser.parse();
|
||||||
|
ast.setIsHeaderUnit(!isSource[0]);
|
||||||
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTCompletionNode getCompletionNode(IStorage fileToParse, IProject project, int offset,
|
public IASTCompletionNode getCompletionNode(IStorage fileToParse, IProject project, int offset,
|
||||||
|
@ -199,7 +202,8 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
||||||
|
|
||||||
CodeReader reader = fileCreator.createCodeReaderForTranslationUnit(filename);
|
CodeReader reader = fileCreator.createCodeReaderForTranslationUnit(filename);
|
||||||
|
|
||||||
ParserLanguage l = getLanguage(filename, project);
|
boolean[] isSource= {false};
|
||||||
|
ParserLanguage l = getLanguage(filename, project, isSource);
|
||||||
IScannerExtensionConfiguration scannerExtensionConfiguration = null;
|
IScannerExtensionConfiguration scannerExtensionConfiguration = null;
|
||||||
if (l == ParserLanguage.CPP)
|
if (l == ParserLanguage.CPP)
|
||||||
scannerExtensionConfiguration = CPP_GNU_SCANNER_EXTENSION;
|
scannerExtensionConfiguration = CPP_GNU_SCANNER_EXTENSION;
|
||||||
|
@ -242,23 +246,25 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
||||||
return dialects;
|
return dialects;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ParserLanguage getLanguage( String filename, IProject project )
|
private ParserLanguage getLanguage( String filename, IProject project, boolean[] isSource ) {
|
||||||
{
|
|
||||||
//FIXME: ALAIN, for headers should we assume CPP ??
|
//FIXME: ALAIN, for headers should we assume CPP ??
|
||||||
// The problem is that it really depends on how the header was included.
|
// The problem is that it really depends on how the header was included.
|
||||||
String id = null;
|
String id = null;
|
||||||
|
isSource[0]= false;
|
||||||
IContentType contentType = CCorePlugin.getContentType(project, filename);
|
IContentType contentType = CCorePlugin.getContentType(project, filename);
|
||||||
if (contentType != null) {
|
if (contentType != null) {
|
||||||
id = contentType.getId();
|
id = contentType.getId();
|
||||||
}
|
}
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
if (CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id)) {
|
if (CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id)) {
|
||||||
|
isSource[0]= true;
|
||||||
return ParserLanguage.CPP;
|
return ParserLanguage.CPP;
|
||||||
} else if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(id)) {
|
} else if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(id)) {
|
||||||
return ParserLanguage.CPP;
|
return ParserLanguage.CPP;
|
||||||
} else if (CCorePlugin.CONTENT_TYPE_CHEADER.equals(id)) {
|
} else if (CCorePlugin.CONTENT_TYPE_CHEADER.equals(id)) {
|
||||||
return ParserLanguage.C;
|
return ParserLanguage.C;
|
||||||
} else if (CCorePlugin.CONTENT_TYPE_CSOURCE.equals(id)) {
|
} else if (CCorePlugin.CONTENT_TYPE_CSOURCE.equals(id)) {
|
||||||
|
isSource[0]= true;
|
||||||
return ParserLanguage.C;
|
return ParserLanguage.C;
|
||||||
} else if (CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(id)) {
|
} else if (CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(id)) {
|
||||||
// ???
|
// ???
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -104,11 +104,13 @@ public class CStructureCreator extends StructureCreator {
|
||||||
CodeReader reader= new CodeReader(document.get().toCharArray());
|
CodeReader reader= new CodeReader(document.get().toCharArray());
|
||||||
|
|
||||||
// determine the language
|
// determine the language
|
||||||
ILanguage language= determineLanguage(element);
|
boolean isSource[]= {false};
|
||||||
|
ILanguage language= determineLanguage(element, isSource);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IASTTranslationUnit ast;
|
IASTTranslationUnit ast;
|
||||||
ast= language.getASTTranslationUnit(reader, scanInfo, codeReaderFactory, null, ParserUtil.getParserLogService());
|
int options= isSource[0] ? ILanguage.OPTION_IS_SOURCE_UNIT : 0;
|
||||||
|
ast= language.getASTTranslationUnit(reader, scanInfo, codeReaderFactory, null, options, ParserUtil.getParserLogService());
|
||||||
CStructureCreatorVisitor structureCreator= new CStructureCreatorVisitor(root);
|
CStructureCreatorVisitor structureCreator= new CStructureCreatorVisitor(root);
|
||||||
// build structure
|
// build structure
|
||||||
ast.accept(structureCreator);
|
ast.accept(structureCreator);
|
||||||
|
@ -125,7 +127,7 @@ public class CStructureCreator extends StructureCreator {
|
||||||
* @param element
|
* @param element
|
||||||
* @return a language instance
|
* @return a language instance
|
||||||
*/
|
*/
|
||||||
private ILanguage determineLanguage(Object element) {
|
private ILanguage determineLanguage(Object element, boolean[] isSource) {
|
||||||
ILanguage language= null;
|
ILanguage language= null;
|
||||||
if (element instanceof ResourceNode) {
|
if (element instanceof ResourceNode) {
|
||||||
IResource resource= ((ResourceNode)element).getResource();
|
IResource resource= ((ResourceNode)element).getResource();
|
||||||
|
@ -134,6 +136,7 @@ public class CStructureCreator extends StructureCreator {
|
||||||
if (tUnit != null) {
|
if (tUnit != null) {
|
||||||
try {
|
try {
|
||||||
language= tUnit.getLanguage();
|
language= tUnit.getLanguage();
|
||||||
|
isSource[0]= tUnit.isSourceUnit();
|
||||||
} catch (CoreException exc) {
|
} catch (CoreException exc) {
|
||||||
// silently ignored
|
// silently ignored
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue