1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-31 21:05:37 +02:00

Partial fix for Bug 102182 - [F3] Open Declaration on macro not working in particular project

This commit is contained in:
John Camelon 2005-07-04 21:52:01 +00:00
parent b8a6e21b4b
commit 7197ddb46d
4 changed files with 18 additions and 9 deletions

View file

@ -250,7 +250,6 @@ public class DOMLocationMacroTests extends AST2BaseTest {
assertEquals( flat.getNodeLength(), "_PTR _EXFUN(memchr,(const _PTR, int, size_t));".length() ); //$NON-NLS-1$ assertEquals( flat.getNodeLength(), "_PTR _EXFUN(memchr,(const _PTR, int, size_t));".length() ); //$NON-NLS-1$
IASTDeclarator d = memchr.getDeclarators()[0]; IASTDeclarator d = memchr.getDeclarators()[0];
final IASTNodeLocation[] declaratorLocations = d.getNodeLocations();
IASTFileLocation f = d.getFileLocation(); IASTFileLocation f = d.getFileLocation();
assertEquals( code.indexOf( "_PTR _EXFUN(memchr,(const _PTR, int, size_t))"), f.getNodeOffset() ); //$NON-NLS-1$ assertEquals( code.indexOf( "_PTR _EXFUN(memchr,(const _PTR, int, size_t))"), f.getNodeOffset() ); //$NON-NLS-1$
assertEquals( "_PTR _EXFUN(memchr,(const _PTR, int, size_t))".length(), f.getNodeLength() ); //$NON-NLS-1$ assertEquals( "_PTR _EXFUN(memchr,(const _PTR, int, size_t))".length(), f.getNodeLength() ); //$NON-NLS-1$
@ -325,9 +324,9 @@ public class DOMLocationMacroTests extends AST2BaseTest {
} }
public void testBug94933() throws Exception { public void testBug94933() throws Exception {
StringBuffer buffer = new StringBuffer( "#define API extern\n" ); StringBuffer buffer = new StringBuffer( "#define API extern\n" ); //$NON-NLS-1$
buffer.append( "#define MYAPI API\n"); buffer.append( "#define MYAPI API\n"); //$NON-NLS-1$
buffer.append( "MYAPI void func() {}" ); buffer.append( "MYAPI void func() {}" ); //$NON-NLS-1$
String code = buffer.toString(); String code = buffer.toString();
for (ParserLanguage p = ParserLanguage.C; p != null; p = (p == ParserLanguage.C) ? ParserLanguage.CPP for (ParserLanguage p = ParserLanguage.C; p != null; p = (p == ParserLanguage.C) ? ParserLanguage.CPP
: null) { : null) {

View file

@ -77,6 +77,8 @@ public class DOMScanner extends BaseScanner {
for( int i = 0; i < definitions.size(); ++i ) for( int i = 0; i < definitions.size(); ++i )
{ {
IMacro m = (IMacro) definitions.get( definitions.keyAt(i) ); IMacro m = (IMacro) definitions.get( definitions.keyAt(i) );
if( m instanceof ObjectStyleMacro && ((ObjectStyleMacro)m).attachment != null )
continue;
if( m instanceof DynamicStyleMacro ) if( m instanceof DynamicStyleMacro )
{ {

View file

@ -1925,7 +1925,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
*/ */
public IMacroDefinition defineObjectStyleMacro(ObjectStyleMacro m, public IMacroDefinition defineObjectStyleMacro(ObjectStyleMacro m,
int startOffset, int nameOffset, int nameEndOffset, int endOffset) { int startOffset, int nameOffset, int nameEndOffset, int endOffset) {
final _ObjectMacroDefinition objectMacroDefinition = new _ObjectMacroDefinition( _ObjectMacroDefinition objectMacroDefinition = new _ObjectMacroDefinition(
currentContext, startOffset, endOffset, m.name, nameOffset, currentContext, startOffset, endOffset, m.name, nameOffset,
m.expansion); m.expansion);
currentContext.addSubContext(objectMacroDefinition); currentContext.addSubContext(objectMacroDefinition);
@ -2479,13 +2479,18 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
} }
private IASTName[] createNameArray(_MacroDefinition definition) { private IASTName[] createNameArray(_MacroDefinition definition) {
if( definition == null ) return EMPTY_NAME_ARRAY;
IASTName [] result = new IASTName[1]; IASTName [] result = new IASTName[1];
if( definition.astNode == null ) if( definition.astNode == null )
{ {
IASTPreprocessorMacroDefinition astNode = createASTMacroDefinition(definition); IASTPreprocessorMacroDefinition astNode = createASTMacroDefinition(definition);
definition.astNode = astNode; definition.astNode = astNode;
result[0] = definition.astNode.getName();
}
else
{
result[0] = definition.astNode.getName();
} }
result[0] = definition.astNode.getName();
return result; return result;
} }

View file

@ -150,9 +150,12 @@ public class OpenDeclarationsAction extends SelectionParseAction implements IUpd
if ( domNames[0].getTranslationUnit() != null ) { if ( domNames[0].getTranslationUnit() != null ) {
IASTFileLocation location = domNames[0].getFileLocation(); IASTFileLocation location = domNames[0].getFileLocation();
fileName = location.getFileName(); if( location != null )
start = location.getNodeOffset(); {
end = location.getNodeOffset() + location.getNodeLength(); fileName = location.getFileName();
start = location.getNodeOffset();
end = location.getNodeOffset() + location.getNodeLength();
}
} }
if (fileName != null) { if (fileName != null) {