1
0
Fork 0
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:
Jeff Johnston 2019-04-26 11:46:41 -04:00
parent 225ee8550a
commit 5edac6e20c

View file

@ -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