1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +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$
IASTDeclarator d = memchr.getDeclarators()[0];
final IASTNodeLocation[] declaratorLocations = d.getNodeLocations();
IASTFileLocation f = d.getFileLocation();
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$
@ -325,9 +324,9 @@ public class DOMLocationMacroTests extends AST2BaseTest {
}
public void testBug94933() throws Exception {
StringBuffer buffer = new StringBuffer( "#define API extern\n" );
buffer.append( "#define MYAPI API\n");
buffer.append( "MYAPI void func() {}" );
StringBuffer buffer = new StringBuffer( "#define API extern\n" ); //$NON-NLS-1$
buffer.append( "#define MYAPI API\n"); //$NON-NLS-1$
buffer.append( "MYAPI void func() {}" ); //$NON-NLS-1$
String code = buffer.toString();
for (ParserLanguage p = ParserLanguage.C; p != null; p = (p == ParserLanguage.C) ? ParserLanguage.CPP
: null) {

View file

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

View file

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

View file

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