mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Bug 546395 - Added "copy qualified name" feature
- fix isValidSelection() to not bog down performance Change-Id: I8d3b595c988f09c731d76b8174f5175b31115460
This commit is contained in:
parent
225ee8550a
commit
5edac6e20c
1 changed files with 1 additions and 17 deletions
|
@ -82,23 +82,7 @@ public class CopyQualifiedNameAction extends TextEditorAction {
|
||||||
private boolean isValidSelection(ITextSelection selection) {
|
private boolean isValidSelection(ITextSelection selection) {
|
||||||
if (selection == null || selection.isEmpty() || selection.getLength() <= 0)
|
if (selection == null || selection.isEmpty() || selection.getLength() <= 0)
|
||||||
return false;
|
return false;
|
||||||
final int offset = selection.getOffset();
|
return true;
|
||||||
final int length = selection.getLength();
|
|
||||||
ITranslationUnit translationUnit = (ITranslationUnit) CDTUITools
|
|
||||||
.getEditorInputCElement(fEditor.getEditorInput());
|
|
||||||
String qualName = null;
|
|
||||||
try {
|
|
||||||
IASTTranslationUnit ast = translationUnit.getAST(null, 0);
|
|
||||||
if (ast != null) {
|
|
||||||
IASTNode enclosingNode = ast.getNodeSelector(null).findEnclosingNode(offset, length);
|
|
||||||
NameVisitor n = new NameVisitor();
|
|
||||||
enclosingNode.accept(n);
|
|
||||||
qualName = n.getQualifiedName();
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return qualName != null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue