mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-15 20:25:46 +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:
parent
acb86c08b9
commit
bc812babe8
2 changed files with 12 additions and 4 deletions
|
@ -2318,11 +2318,17 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
- context.context_directive_start) {
|
- 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
|
// check if a sub node of the macro is the selection // TODO
|
||||||
// determine how this can be kept in sync with logic in
|
// determine how this can be kept in sync with logic in
|
||||||
// getAllPreprocessorStatements (i.e. 1:1 mapping)
|
// getAllPreprocessorStatements (i.e. 1:1 mapping)
|
||||||
if (context instanceof _MacroDefinition) {
|
if (context.contains( globalOffset ) && context instanceof _MacroDefinition) {
|
||||||
if (globalOffset == ((_MacroDefinition) context).nameOffset
|
if (globalOffset == ((_MacroDefinition) context).nameOffset
|
||||||
&& length == ((_MacroDefinition) context).name.length)
|
&& length == ((_MacroDefinition) context).name.length)
|
||||||
result = createASTMacroDefinition(
|
result = createASTMacroDefinition(
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class ShowInDOMViewAction extends ActionDelegate implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FindDisplayNode implements Runnable {
|
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;
|
private static final String IASTNode_NOT_FOUND = IAST_NODE_NOT_FOUND;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
@ -155,7 +155,9 @@ public class ShowInDOMViewAction extends ActionDelegate implements
|
||||||
if (tu != null && file != null && view instanceof DOMAST) {
|
if (tu != null && file != null && view instanceof DOMAST) {
|
||||||
IASTNode node = tu.selectNodeForLocation(file, offset, length);
|
IASTNode node = tu.selectNodeForLocation(file, offset, length);
|
||||||
if (node != null && ((DOMAST)view).getContentProvider() instanceof DOMAST.ViewContentProvider) {
|
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 {
|
} else {
|
||||||
showMessage(IASTNode_NOT_FOUND);
|
showMessage(IASTNode_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue