mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 11:25:35 +02:00
Cosmetics.
This commit is contained in:
parent
4946010ddd
commit
5854ece2d4
5 changed files with 24 additions and 36 deletions
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.callhierarchy;
|
package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -24,9 +23,7 @@ import org.eclipse.swt.widgets.Display;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
|
||||||
|
|
||||||
public class CHDropTargetListener implements DropTargetListener {
|
public class CHDropTargetListener implements DropTargetListener {
|
||||||
|
|
||||||
private CHViewPart fCallHierarchy;
|
private CHViewPart fCallHierarchy;
|
||||||
private ICElement fInput;
|
private ICElement fInput;
|
||||||
private boolean fEnabled= true;
|
private boolean fEnabled= true;
|
||||||
|
@ -56,7 +53,7 @@ public class CHDropTargetListener implements DropTargetListener {
|
||||||
private ICElement checkLocalSelection() {
|
private ICElement checkLocalSelection() {
|
||||||
ISelection sel= LocalSelectionTransfer.getTransfer().getSelection();
|
ISelection sel= LocalSelectionTransfer.getTransfer().getSelection();
|
||||||
if (sel instanceof IStructuredSelection) {
|
if (sel instanceof IStructuredSelection) {
|
||||||
for (Iterator<?> iter = ((IStructuredSelection)sel).iterator(); iter.hasNext();) {
|
for (Iterator<?> iter = ((IStructuredSelection) sel).iterator(); iter.hasNext();) {
|
||||||
Object element = iter.next();
|
Object element = iter.next();
|
||||||
if (element instanceof ICElement) {
|
if (element instanceof ICElement) {
|
||||||
return (ICElement) element;
|
return (ICElement) element;
|
||||||
|
@ -85,8 +82,7 @@ public class CHDropTargetListener implements DropTargetListener {
|
||||||
public void drop(DropTargetEvent event) {
|
public void drop(DropTargetEvent event) {
|
||||||
if (fInput == null) {
|
if (fInput == null) {
|
||||||
Display.getCurrent().beep();
|
Display.getCurrent().beep();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
fCallHierarchy.setInput(fInput);
|
fCallHierarchy.setInput(fInput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,8 +93,7 @@ public class CHDropTargetListener implements DropTargetListener {
|
||||||
private void checkOperation(DropTargetEvent event) {
|
private void checkOperation(DropTargetEvent event) {
|
||||||
if (fEnabled && (event.operations & DND.DROP_COPY) != 0) {
|
if (fEnabled && (event.operations & DND.DROP_COPY) != 0) {
|
||||||
event.detail= DND.DROP_COPY;
|
event.detail= DND.DROP_COPY;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
event.detail= DND.DROP_NONE;
|
event.detail= DND.DROP_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,8 +101,8 @@ public class CHQueries {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void findCalledBy2(IIndex index, IBinding callee, boolean includeOrdinaryCalls, ICProject project, CalledByResult result)
|
private static void findCalledBy2(IIndex index, IBinding callee, boolean includeOrdinaryCalls,
|
||||||
throws CoreException {
|
ICProject project, CalledByResult result) throws CoreException {
|
||||||
IIndexName[] names= index.findNames(callee, IIndex.FIND_REFERENCES | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
|
IIndexName[] names= index.findNames(callee, IIndex.FIND_REFERENCES | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
|
||||||
for (IIndexName rname : names) {
|
for (IIndexName rname : names) {
|
||||||
if (includeOrdinaryCalls || rname.couldBePolymorphicMethodCall()) {
|
if (includeOrdinaryCalls || rname.couldBePolymorphicMethodCall()) {
|
||||||
|
|
|
@ -136,8 +136,7 @@ public class CallHierarchyUI {
|
||||||
CHMessages.CallHierarchyUI_openFailureMessage);
|
CHMessages.CallHierarchyUI_openFailureMessage);
|
||||||
}
|
}
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
} catch (CoreException e) {
|
||||||
catch (CoreException e) {
|
|
||||||
return e.getStatus();
|
return e.getStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,7 +150,8 @@ public class CallHierarchyUI {
|
||||||
private static ICElement[] findDefinitions(ICProject project, IEditorInput editorInput, ITextSelection sel)
|
private static ICElement[] findDefinitions(ICProject project, IEditorInput editorInput, ITextSelection sel)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
try {
|
try {
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
|
IIndex index= CCorePlugin.getIndexManager().getIndex(project,
|
||||||
|
IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
|
||||||
|
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
|
@ -190,8 +190,7 @@ public class CallHierarchyUI {
|
||||||
return NO_ELEMENTS;
|
return NO_ELEMENTS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -226,7 +225,8 @@ public class CallHierarchyUI {
|
||||||
final ITranslationUnit tu= CModelUtil.getTranslationUnit(input);
|
final ITranslationUnit tu= CModelUtil.getTranslationUnit(input);
|
||||||
if (tu != null) {
|
if (tu != null) {
|
||||||
final ICProject project= tu.getCProject();
|
final ICProject project= tu.getCProject();
|
||||||
final IIndex index= CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
|
final IIndex index= CCorePlugin.getIndexManager().getIndex(project,
|
||||||
|
IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
|
||||||
|
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
|
@ -242,21 +242,18 @@ public class CallHierarchyUI {
|
||||||
IIndexName name= IndexUI.elementToName(index, input);
|
IIndexName name= IndexUI.elementToName(index, input);
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
ICElementHandle handle= IndexUI.getCElementForName(tu, index, name);
|
ICElementHandle handle= IndexUI.getCElementForName(tu, index, name);
|
||||||
return new ICElement[] {handle};
|
return new ICElement[] { handle };
|
||||||
}
|
}
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (CoreException e) {
|
||||||
catch (CoreException e) {
|
|
||||||
CUIPlugin.log(e);
|
CUIPlugin.log(e);
|
||||||
}
|
} catch (InterruptedException e) {
|
||||||
catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
return new ICElement[] {input};
|
return new ICElement[] { input };
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean needToFindDefinition(ICElement elem) {
|
private static boolean needToFindDefinition(ICElement elem) {
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.eclipse.cdt.ui.actions.SelectionDispatchAction;
|
||||||
|
|
||||||
|
|
||||||
public class OpenCallHierarchyAction extends SelectionDispatchAction {
|
public class OpenCallHierarchyAction extends SelectionDispatchAction {
|
||||||
|
|
||||||
private ITextEditor fEditor;
|
private ITextEditor fEditor;
|
||||||
|
|
||||||
public OpenCallHierarchyAction(IWorkbenchSite site) {
|
public OpenCallHierarchyAction(IWorkbenchSite site) {
|
||||||
|
@ -73,8 +72,7 @@ public class OpenCallHierarchyAction extends SelectionDispatchAction {
|
||||||
ICElement elem= (ICElement) getAdapter(selectedObject, ICElement.class);
|
ICElement elem= (ICElement) getAdapter(selectedObject, ICElement.class);
|
||||||
if (elem != null) {
|
if (elem != null) {
|
||||||
setEnabled(isValidElement(elem));
|
setEnabled(isValidElement(elem));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.callhierarchy;
|
package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
|
|
||||||
import org.eclipse.jface.action.IAction;
|
import org.eclipse.jface.action.IAction;
|
||||||
|
@ -31,7 +30,6 @@ import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.internal.ui.browser.opentype.ElementSelectionDialog;
|
import org.eclipse.cdt.internal.ui.browser.opentype.ElementSelectionDialog;
|
||||||
|
|
||||||
public class OpenElementInCallHierarchyAction implements IWorkbenchWindowActionDelegate {
|
public class OpenElementInCallHierarchyAction implements IWorkbenchWindowActionDelegate {
|
||||||
|
|
||||||
private static final int[] VISIBLE_TYPES = {
|
private static final int[] VISIBLE_TYPES = {
|
||||||
ICElement.C_FUNCTION, ICElement.C_METHOD, ICElement.C_VARIABLE, ICElement.C_ENUMERATOR,
|
ICElement.C_FUNCTION, ICElement.C_METHOD, ICElement.C_VARIABLE, ICElement.C_ENUMERATOR,
|
||||||
ICElement.C_FUNCTION_DECLARATION, ICElement.C_METHOD_DECLARATION, ICElement.C_VARIABLE_DECLARATION };
|
ICElement.C_FUNCTION_DECLARATION, ICElement.C_METHOD_DECLARATION, ICElement.C_VARIABLE_DECLARATION };
|
||||||
|
@ -59,10 +57,10 @@ public class OpenElementInCallHierarchyAction implements IWorkbenchWindowActionD
|
||||||
}
|
}
|
||||||
if (elements == null || elements.length == 0) {
|
if (elements == null || elements.length == 0) {
|
||||||
String title = CHMessages.OpenElementInCallHierarchyAction_errorDlgTitle;
|
String title = CHMessages.OpenElementInCallHierarchyAction_errorDlgTitle;
|
||||||
String message = NLS.bind(CHMessages.OpenElementInCallHierarchyAction_errorNoDefinition, info.getQualifiedTypeName().toString());
|
String message = NLS.bind(CHMessages.OpenElementInCallHierarchyAction_errorNoDefinition,
|
||||||
|
info.getQualifiedTypeName().toString());
|
||||||
MessageDialog.openError(getShell(), title, message);
|
MessageDialog.openError(getShell(), title, message);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
CallHierarchyUI.open(fWorkbenchWindow, elements[0]);
|
CallHierarchyUI.open(fWorkbenchWindow, elements[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue