1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-30 21:55:31 +02:00

Fix Bug 92605 - [LocationMap] context_directive_end is off by 1 somewhere

Updated DOMAST Find In View action accordingly.
This commit is contained in:
John Camelon 2005-04-25 18:08:50 +00:00
parent acb86c08b9
commit bc812babe8
2 changed files with 12 additions and 4 deletions

View file

@ -2316,13 +2316,19 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
if (globalOffset == context.context_directive_start
&& length == context.context_directive_end
- context.context_directive_start) {
result = createPreprocessorStatement(context);
result = createPreprocessorStatement(context);
}
else if( context instanceof _MacroExpansion && globalOffset == context.context_directive_start )
{
_MacroExpansion expansion = (_MacroExpansion)context;
if( expansion.definition.getName().length == length )
result = expansion.getName();
}
// check if a sub node of the macro is the selection // TODO
// determine how this can be kept in sync with logic in
// getAllPreprocessorStatements (i.e. 1:1 mapping)
if (context instanceof _MacroDefinition) {
if (context.contains( globalOffset ) && context instanceof _MacroDefinition) {
if (globalOffset == ((_MacroDefinition) context).nameOffset
&& length == ((_MacroDefinition) context).name.length)
result = createASTMacroDefinition(

View file

@ -123,7 +123,7 @@ public class ShowInDOMViewAction extends ActionDelegate implements
}
private class FindDisplayNode implements Runnable {
private static final String IAST_NODE_NOT_FOUND = "IASTNode not found for the selection. Try refreshing the AST View if changes were made to the source."; //$NON-NLS-1$
private static final String IAST_NODE_NOT_FOUND = "IASTNode not found for the selection. "; //$NON-NLS-1$
private static final String IASTNode_NOT_FOUND = IAST_NODE_NOT_FOUND;
int offset = 0;
int length = 0;
@ -155,7 +155,9 @@ public class ShowInDOMViewAction extends ActionDelegate implements
if (tu != null && file != null && view instanceof DOMAST) {
IASTNode node = tu.selectNodeForLocation(file, offset, length);
if (node != null && ((DOMAST)view).getContentProvider() instanceof DOMAST.ViewContentProvider) {
((DOMAST.ViewContentProvider)((DOMAST)view).getContentProvider()).findAndSelect(node, true); // use offsets when searching for node equality
boolean success = ((DOMAST.ViewContentProvider)((DOMAST)view).getContentProvider()).findAndSelect(node, true); // use offsets when searching for node equality
if( ! success )
showMessage(IASTNode_NOT_FOUND);
} else {
showMessage(IASTNode_NOT_FOUND);
}