1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 09:45:39 +02:00

Added function style macros. Redid how macros are handled in the fast indexer. And a few minor bug fixes in the Actions.

This commit is contained in:
Doug Schaefer 2006-05-10 19:25:09 +00:00
parent 4a428df9d4
commit be3041c07d
15 changed files with 192 additions and 93 deletions

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.core.dom;
import org.eclipse.cdt.core.parser.CodeReader; import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.ICodeReaderCache; import org.eclipse.cdt.core.parser.ICodeReaderCache;
import org.eclipse.cdt.core.parser.IScanner;
/** /**
* This is the interface that an AST Service uses to delegate the construction * This is the interface that an AST Service uses to delegate the construction
@ -42,7 +43,7 @@ public interface ICodeReaderFactory {
* @param path * @param path
* @return CodeReader for contents at that path. * @return CodeReader for contents at that path.
*/ */
public CodeReader createCodeReaderForInclusion(String path); public CodeReader createCodeReaderForInclusion(IScanner scanner, String path);
/** /**
* Returns the ICodeReaderCache used for this ICodeReaderFacotry. * Returns the ICodeReaderCache used for this ICodeReaderFacotry.

View file

@ -29,7 +29,9 @@ public interface IScanner {
public void setContentAssistMode( int offset ); public void setContentAssistMode( int offset );
public void setASTFactory( IASTFactory f ); public void setASTFactory( IASTFactory f );
public void addDefinition(char[] key, char[] value); public IMacro addDefinition(char[] key, char[] value);
public IMacro addDefinition(char[] name, char[][] params, char[] expansion);
public Map getDefinitions(); public Map getDefinitions();
public String[] getIncludePaths(); public String[] getIncludePaths();

View file

@ -1410,17 +1410,13 @@ abstract class BaseScanner implements IScanner {
pushContext(r.buffer, d); pushContext(r.buffer, d);
} }
/* public IMacro addDefinition(char[] key, char[] value) {
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.IScanner#addDefinition(java.lang.String,
* java.lang.String)
*/
public void addDefinition(char[] key, char[] value) {
int idx = CharArrayUtils.indexOf('(', key); int idx = CharArrayUtils.indexOf('(', key);
if (idx == -1) if (idx == -1) {
definitions.put(key, new ObjectStyleMacro(key, value)); IMacro macro = new ObjectStyleMacro(key, value);
else { definitions.put(key, macro);
return macro;
} else {
pushContext(key); pushContext(key);
bufferPos[bufferStackPos] = idx; bufferPos[bufferStackPos] = idx;
char[][] args = null; char[][] args = null;
@ -1432,25 +1428,22 @@ abstract class BaseScanner implements IScanner {
if (args != null) { if (args != null) {
key = CharArrayUtils.extract(key, 0, idx); key = CharArrayUtils.extract(key, 0, idx);
definitions.put(key, new FunctionStyleMacro(key, value, args)); return addDefinition(key, args, value);
} } else
return null;
} }
} }
/* public IMacro addDefinition(char[] name, char[][] params, char[] expansion) {
* (non-Javadoc) IMacro macro = new FunctionStyleMacro(name, expansion, params);
* definitions.put(name, macro);
* @see org.eclipse.cdt.core.parser.IScanner#getCount() return macro;
*/ }
public int getCount() { public int getCount() {
return count; return count;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.parser.IScanner#getDefinitions()
*/
public Map getDefinitions() { public Map getDefinitions() {
CharArrayObjectMap objMap = getRealDefinitions(); CharArrayObjectMap objMap = getRealDefinitions();
int size = objMap.size(); int size = objMap.size();

View file

@ -76,40 +76,45 @@ public class DOMScanner extends BaseScanner {
private void registerMacros() { private void registerMacros() {
for( int i = 0; i < definitions.size(); ++i ) for( int i = 0; i < definitions.size(); ++i )
{ {
IMacro m = (IMacro) definitions.get( definitions.keyAt(i) ); registerMacro((IMacro)definitions.get(definitions.keyAt(i)));
if( m instanceof ObjectStyleMacro && ((ObjectStyleMacro)m).attachment != null ) }
continue; }
if( m instanceof DynamicStyleMacro ) private void registerMacro(IMacro m) {
{ if (m == null)
DynamicStyleMacro macro = (DynamicStyleMacro) m; return;
macro.attachment = locationMap.registerBuiltinDynamicStyleMacro( macro ); if (m instanceof ObjectStyleMacro && ((ObjectStyleMacro)m).attachment != null)
} return;
else if( m instanceof DynamicFunctionStyleMacro )
{ if (m instanceof DynamicStyleMacro) {
DynamicFunctionStyleMacro macro = (DynamicFunctionStyleMacro) m; DynamicStyleMacro macro = (DynamicStyleMacro) m;
macro.attachment = locationMap.registerBuiltinDynamicFunctionStyleMacro( macro ); macro.attachment = locationMap.registerBuiltinDynamicStyleMacro( macro );
} } else if (m instanceof DynamicFunctionStyleMacro) {
else if( m instanceof FunctionStyleMacro ) DynamicFunctionStyleMacro macro = (DynamicFunctionStyleMacro) m;
{ macro.attachment = locationMap.registerBuiltinDynamicFunctionStyleMacro( macro );
FunctionStyleMacro macro = (FunctionStyleMacro) m; } else if (m instanceof FunctionStyleMacro) {
macro.attachment = locationMap.registerBuiltinFunctionStyleMacro( macro ); FunctionStyleMacro macro = (FunctionStyleMacro) m;
} macro.attachment = locationMap.registerBuiltinFunctionStyleMacro( macro );
else if( m instanceof ObjectStyleMacro ) } else if (m instanceof ObjectStyleMacro) {
{ ObjectStyleMacro macro = (ObjectStyleMacro) m;
ObjectStyleMacro macro = (ObjectStyleMacro) m; macro.attachment = locationMap.registerBuiltinObjectStyleMacro( macro );
macro.attachment = locationMap.registerBuiltinObjectStyleMacro( macro );
}
} }
} }
/* public IMacro addDefinition(char[] key, char[] value) {
* (non-Javadoc) IMacro macro = super.addDefinition(key, value);
* if (locationMap != null)
* @see org.eclipse.cdt.core.parser.IScanner#getLocationResolver() registerMacro(macro);
*/ return macro;
}
public IMacro addDefinition(char[] name, char[][] params, char[] expansion) {
IMacro macro = super.addDefinition(name, params, expansion);
if (locationMap != null)
registerMacro(macro);
return macro;
}
public ILocationResolver getLocationResolver() { public ILocationResolver getLocationResolver() {
if (locationMap instanceof ILocationResolver) if (locationMap instanceof ILocationResolver)
return (ILocationResolver) locationMap; return (ILocationResolver) locationMap;
@ -170,7 +175,7 @@ public class DOMScanner extends BaseScanner {
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#createReaderDuple(java.lang.String) * @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#createReaderDuple(java.lang.String)
*/ */
protected CodeReader createReaderDuple(String finalPath) { protected CodeReader createReaderDuple(String finalPath) {
return codeReaderFactory.createCodeReaderForInclusion(finalPath); return codeReaderFactory.createCodeReaderForInclusion(this, finalPath);
} }
/* /*

View file

@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ICodeReaderFactory;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.parser.CodeReader; import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.ICodeReaderCache; import org.eclipse.cdt.core.parser.ICodeReaderCache;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.internal.core.dom.parser.EmptyCodeReaderCache; import org.eclipse.cdt.internal.core.dom.parser.EmptyCodeReaderCache;
/** /**
@ -50,7 +51,7 @@ public class FileCodeReaderFactory implements ICodeReaderFactory {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(java.lang.String) * @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(java.lang.String)
*/ */
public CodeReader createCodeReaderForInclusion(String path) { public CodeReader createCodeReaderForInclusion(IScanner scanner, String path) {
return cache.get(path); return cache.get(path);
} }

View file

@ -68,13 +68,14 @@ public class PDOM extends PlatformObject
private final IPath dbPath; private final IPath dbPath;
private Database db; private Database db;
public static final int VERSION = 5; public static final int VERSION = 6;
// 0 - the beginning of it all // 0 - the beginning of it all
// 1 - first change to kick off upgrades // 1 - first change to kick off upgrades
// 2 - added file inclusions // 2 - added file inclusions
// 3 - added macros and change string implementation // 3 - added macros and change string implementation
// 4 - added parameters in C++ // 4 - added parameters in C++
// 5 - added types and restructured nodes a bit // 5 - added types and restructured nodes a bit
// 6 - function style macros.
public static final int LINKAGES = Database.DATA_AREA; public static final int LINKAGES = Database.DATA_AREA;
public static final int FILE_INDEX = Database.DATA_AREA + 4; public static final int FILE_INDEX = Database.DATA_AREA + 4;

View file

@ -23,11 +23,13 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.CodeReader; import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.ICodeReaderCache; import org.eclipse.cdt.core.parser.ICodeReaderCache;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.ParserUtil; import org.eclipse.cdt.core.parser.ParserUtil;
import org.eclipse.cdt.internal.core.pdom.db.IString; import org.eclipse.cdt.internal.core.pdom.db.IString;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile; import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMInclude; import org.eclipse.cdt.internal.core.pdom.dom.PDOMInclude;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMMacro; import org.eclipse.cdt.internal.core.pdom.dom.PDOMMacro;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMMacroParameter;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
@ -39,8 +41,10 @@ import org.eclipse.core.runtime.Status;
public class PDOMCodeReaderFactory implements ICodeReaderFactory { public class PDOMCodeReaderFactory implements ICodeReaderFactory {
private final PDOM pdom; private final PDOM pdom;
private List workingCopies = new ArrayList(1); private List workingCopies = new ArrayList(1);
private Set skippedHeaders = new HashSet();
private static final char[] EMPTY_CHARS = new char[0];
public PDOMCodeReaderFactory(PDOM pdom) { public PDOMCodeReaderFactory(PDOM pdom) {
this.pdom = pdom; this.pdom = pdom;
@ -55,10 +59,6 @@ public class PDOMCodeReaderFactory implements ICodeReaderFactory {
return 0; return 0;
} }
public Set getSkippedHeaders() {
return skippedHeaders;
}
public CodeReader createCodeReaderForTranslationUnit(String path) { public CodeReader createCodeReaderForTranslationUnit(String path) {
return ParserUtil.createReader(path, return ParserUtil.createReader(path,
workingCopies != null ? workingCopies.iterator() : null); workingCopies != null ? workingCopies.iterator() : null);
@ -68,7 +68,7 @@ public class PDOMCodeReaderFactory implements ICodeReaderFactory {
return new CodeReader(tu.getResource().getLocation().toOSString(), tu.getContents()); return new CodeReader(tu.getResource().getLocation().toOSString(), tu.getContents());
} }
private void fillMacros(PDOMFile file, StringBuffer buffer, Set visited) throws CoreException { private void fillMacros(PDOMFile file, IScanner scanner, Set visited) throws CoreException {
IString filename = file.getFileName(); IString filename = file.getFileName();
if (visited.contains(filename)) if (visited.contains(filename))
return; return;
@ -77,23 +77,32 @@ public class PDOMCodeReaderFactory implements ICodeReaderFactory {
// Follow the includes // Follow the includes
PDOMInclude include = file.getFirstInclude(); PDOMInclude include = file.getFirstInclude();
while (include != null) { while (include != null) {
fillMacros(include.getIncludes(), buffer, visited); fillMacros(include.getIncludes(), scanner, visited);
include = include.getNextInIncludes(); include = include.getNextInIncludes();
} }
// Add in my macros now // Add in my macros now
PDOMMacro macro = file.getFirstMacro(); PDOMMacro macro = file.getFirstMacro();
while (macro != null) { while (macro != null) {
buffer.append("#define "); //$NON-NLS-1$ char[] name = macro.getName().getChars();
buffer.append(macro.getName().getChars()); char[] expansion = macro.getExpansion().getChars();
buffer.append(' ');
buffer.append(macro.getExpansion().getChars()); PDOMMacroParameter param = macro.getFirstParameter();
buffer.append('\n'); if (param != null) {
List paramList = new ArrayList();
while (param != null) {
paramList.add(param.getName().getChars());
param = param.getNextParameter();
}
char[][] params = (char[][])paramList.toArray(new char[paramList.size()][]);
scanner.addDefinition(name, params, expansion);
} else
scanner.addDefinition(name, expansion);
macro = macro.getNextMacro(); macro = macro.getNextMacro();
} }
} }
public CodeReader createCodeReaderForInclusion(String path) { public CodeReader createCodeReaderForInclusion(IScanner scanner, String path) {
// Don't parse inclusion if it is already captured // Don't parse inclusion if it is already captured
try { try {
try { try {
@ -106,15 +115,10 @@ public class PDOMCodeReaderFactory implements ICodeReaderFactory {
} }
PDOMFile file = pdom.getFile(path); PDOMFile file = pdom.getFile(path);
if (file != null) { if (file != null) {
// Already got things from here, pass in a magic // Already got things from here,
// buffer with the macros in it // add the macros to the scanner
skippedHeaders.add(path); fillMacros(file, scanner, new HashSet());
StringBuffer buffer = new StringBuffer(); return new CodeReader(path, EMPTY_CHARS);
fillMacros(file, buffer, new HashSet());
int length = buffer.length();
char[] chars = new char[length];
buffer.getChars(0, length, chars, 0);
return new CodeReader(path, chars);
} }
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(new CoreException(new Status(IStatus.ERROR, CCorePlugin.log(new CoreException(new Status(IStatus.ERROR,

View file

@ -11,6 +11,8 @@
package org.eclipse.cdt.internal.core.pdom.dom; package org.eclipse.cdt.internal.core.pdom.dom;
import org.eclipse.cdt.core.dom.ast.IASTFunctionStyleMacroParameter;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorFunctionStyleMacroDefinition;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.cdt.internal.core.pdom.db.Database;
@ -28,10 +30,11 @@ public class PDOMMacro {
private final int record; private final int record;
private static final int NAME = 0; private static final int NAME = 0;
private static final int EXPANSION = 4; private static final int FIRST_PARAMETER = 4;
private static final int NEXT_MACRO = 8; private static final int EXPANSION = 8;
private static final int NEXT_MACRO = 12;
private static final int RECORD_SIZE = 12; private static final int RECORD_SIZE = 16;
public PDOMMacro(PDOM pdom, int record) { public PDOMMacro(PDOM pdom, int record) {
this.pdom = pdom; this.pdom = pdom;
@ -46,6 +49,20 @@ public class PDOMMacro {
db.putInt(record + NAME, db.newString(macro.getName().toCharArray()).getRecord()); db.putInt(record + NAME, db.newString(macro.getName().toCharArray()).getRecord());
db.putInt(record + EXPANSION, db.newString(macro.getExpansion()).getRecord()); db.putInt(record + EXPANSION, db.newString(macro.getExpansion()).getRecord());
setNextMacro(0); setNextMacro(0);
PDOMMacroParameter last = null;
if (macro instanceof IASTPreprocessorFunctionStyleMacroDefinition) {
IASTPreprocessorFunctionStyleMacroDefinition func = (IASTPreprocessorFunctionStyleMacroDefinition)macro;
IASTFunctionStyleMacroParameter[] params = func.getParameters();
for (int i = params.length - 1; i >= 0; --i) {
IASTFunctionStyleMacroParameter param = params[i];
PDOMMacroParameter pdomParam = new PDOMMacroParameter(pdom, param.getParameter());
if (last != null)
pdomParam.setNextParameter(last);
last = pdomParam;
}
}
db.putInt(record + FIRST_PARAMETER, last != null ? last.getRecord() : 0);
} }
public int getRecord() { public int getRecord() {
@ -80,4 +97,10 @@ public class PDOMMacro {
public void setNextMacro(int rec) throws CoreException { public void setNextMacro(int rec) throws CoreException {
pdom.getDB().putInt(record + NEXT_MACRO, rec); pdom.getDB().putInt(record + NEXT_MACRO, rec);
} }
public PDOMMacroParameter getFirstParameter() throws CoreException {
int rec = pdom.getDB().getInt(record + FIRST_PARAMETER);
return rec != 0 ? new PDOMMacroParameter(pdom, rec) : null;
}
} }

View file

@ -0,0 +1,67 @@
/*******************************************************************************
* Copyright (c) 2006 QNX Software Systems and others.
* All rights reserved. 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:
* QNX - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.db.IString;
import org.eclipse.core.runtime.CoreException;
/**
* @author Doug Schaefer
*
*/
public class PDOMMacroParameter {
private final PDOM pdom;
private final int record;
private static final int NEXT = 0;
private static final int NAME = 4;
private static final int RECORD_SIZE = 8;
public PDOMMacroParameter(PDOM pdom, int record) {
this.pdom = pdom;
this.record = record;
}
public PDOMMacroParameter(PDOM pdom, String name) throws CoreException {
Database db = pdom.getDB();
this.pdom = pdom;
this.record = db.malloc(RECORD_SIZE);
db.putInt(record + NEXT, 0);
db.putInt(record + NAME, db.newString(name).getRecord());
}
public int getRecord() {
return record;
}
public void setNextParameter(PDOMMacroParameter next) throws CoreException {
int rec = next != null ? next.getRecord() : 0;
pdom.getDB().putInt(record + NEXT, rec);
}
public PDOMMacroParameter getNextParameter() throws CoreException {
int rec = pdom.getDB().getInt(record + NEXT);
return rec != 0 ? new PDOMMacroParameter(pdom, rec) : null;
}
public IString getName() throws CoreException {
Database db = pdom.getDB();
return db.getString(db.getInt(record + NAME));
}
}

View file

@ -149,7 +149,7 @@ class PDOMFastHandleDelta extends PDOMFastIndexerJob {
file.clear(); file.clear();
// Add the new symbols // Add the new symbols
addSymbols(tu.getLanguage(), ast, codeReaderFactory.getSkippedHeaders()); addSymbols(tu.getLanguage(), ast);
} finally { } finally {
pdom.releaseWriteLock(); pdom.releaseWriteLock();
} }

View file

@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.pdom.indexer.fast;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
@ -71,7 +70,7 @@ public abstract class PDOMFastIndexerJob extends Job {
pdom.acquireWriteLock(); pdom.acquireWriteLock();
try { try {
addSymbols(language, ast, codeReaderFactory.getSkippedHeaders()); addSymbols(language, ast);
} finally { } finally {
pdom.releaseWriteLock(); pdom.releaseWriteLock();
} }
@ -80,7 +79,7 @@ public abstract class PDOMFastIndexerJob extends Job {
pdom.fireChange(); pdom.fireChange();
} }
protected void addSymbols(ILanguage language, IASTTranslationUnit ast, Set skippedHeaders) throws InterruptedException, CoreException { protected void addSymbols(ILanguage language, IASTTranslationUnit ast) throws InterruptedException, CoreException {
final PDOMLinkage linkage = pdom.getLinkage(language); final PDOMLinkage linkage = pdom.getLinkage(language);
if (linkage == null) if (linkage == null)
return; return;
@ -112,9 +111,6 @@ public abstract class PDOMFastIndexerJob extends Job {
continue; // skip built-ins and command line macros continue; // skip built-ins and command line macros
String filename = sourceLoc.getFileName(); String filename = sourceLoc.getFileName();
if (skippedHeaders.contains(filename))
continue;
PDOMFile sourceFile = getCachedFile(filename); PDOMFile sourceFile = getCachedFile(filename);
sourceFile.addMacro(macro); sourceFile.addMacro(macro);
} }

View file

@ -12,12 +12,14 @@ package org.eclipse.cdt.internal.core.dom;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import org.eclipse.cdt.core.dom.CDOM; import org.eclipse.cdt.core.dom.CDOM;
import org.eclipse.cdt.core.dom.ICodeReaderFactory; import org.eclipse.cdt.core.dom.ICodeReaderFactory;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopyProvider; import org.eclipse.cdt.core.model.IWorkingCopyProvider;
import org.eclipse.cdt.core.parser.CodeReader; import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.ICodeReaderCache; import org.eclipse.cdt.core.parser.ICodeReaderCache;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.ParserUtil; import org.eclipse.cdt.core.parser.ParserUtil;
import org.eclipse.cdt.internal.core.parser.ast.EmptyIterator; import org.eclipse.cdt.internal.core.parser.ast.EmptyIterator;
@ -70,7 +72,7 @@ public class PartialWorkingCopyCodeReaderFactory
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(java.lang.String) * @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(java.lang.String)
*/ */
public CodeReader createCodeReaderForInclusion(String path) { public CodeReader createCodeReaderForInclusion(IScanner scanner, String path) {
return cache.get( path ); return cache.get( path );
} }

View file

@ -17,6 +17,7 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.parser.CodeReader; import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.CodeReaderCache; import org.eclipse.cdt.core.parser.CodeReaderCache;
import org.eclipse.cdt.core.parser.ICodeReaderCache; import org.eclipse.cdt.core.parser.ICodeReaderCache;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Preferences;
/** /**
@ -85,7 +86,7 @@ public class SavedCodeReaderFactory implements ICodeReaderFactory {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(java.lang.String) * @see org.eclipse.cdt.core.dom.ICodeReaderFactory#createCodeReaderForInclusion(java.lang.String)
*/ */
public CodeReader createCodeReaderForInclusion(String path) { public CodeReader createCodeReaderForInclusion(IScanner scanner, String path) {
return cache.get(path); return cache.get(path);
} }

View file

@ -45,7 +45,7 @@ public class FindDeclarationsAction extends IndexAction {
ICProject project = binding.getPDOM().getProject(); ICProject project = binding.getPDOM().getProject();
PDOMSearchBindingQuery query = new PDOMSearchBindingQuery( PDOMSearchBindingQuery query = new PDOMSearchBindingQuery(
new ICElement[] { project }, new ICElement[] { project },
getBinding(), binding,
PDOMSearchBindingQuery.FIND_DECLARATIONS | PDOMSearchBindingQuery.FIND_DEFINITIONS); PDOMSearchBindingQuery.FIND_DECLARATIONS | PDOMSearchBindingQuery.FIND_DEFINITIONS);
NewSearchUI.activateSearchResultView(); NewSearchUI.activateSearchResultView();

View file

@ -555,6 +555,9 @@ public class SelectionParseAction extends Action {
*/ */
protected void open(IASTName name) throws CoreException { protected void open(IASTName name) throws CoreException {
IASTFileLocation fileloc = name.getFileLocation(); IASTFileLocation fileloc = name.getFileLocation();
if (fileloc == null)
// no source location - TODO spit out an error in the status bar
return;
int currentOffset = fileloc.getNodeOffset(); int currentOffset = fileloc.getNodeOffset();
int currentLength = fileloc.getNodeLength(); int currentLength = fileloc.getNodeLength();