mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +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) {
|
||||
if (selection == null || selection.isEmpty() || selection.getLength() <= 0)
|
||||
return false;
|
||||
final int offset = selection.getOffset();
|
||||
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;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue