| Previous CloneSet | Next CloneSet | Back to Main Report |
| Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
|---|---|---|---|---|
| 79 | 2 | 5 | 0.993 | type_declarations |
| Clone Abstraction | Parameter Bindings |
| Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
|---|---|---|---|
| 1 | 79 | 46 | plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindExceptionOccurrencesAction.java |
| 2 | 79 | 45 | plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindImplementOccurrencesAction.java |
| ||||
/**
* Action to find all originators of a exception (e.g. method invocations,
* class casts, ...) for a given exception.
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
*
* @since 3.1
*/
public class FindExceptionOccurrencesAction extends SelectionDispatchAction {
private JavaEditor fEditor;
/**
* Note: This constructor is for internal use only. Clients should not call this constructor.
*
* @param editor the Java editor
*/
public FindExceptionOccurrencesAction(JavaEditor editor) {
this(editor.getEditorSite());
fEditor = editor;
setEnabled(getEditorInput(editor) != null);
}
/**
* Creates a new <code>FindExceptionOccurrencesAction</code>. The action
* requires that the selection provided by the site's selection provider is of type
* <code>IStructuredSelection</code>.
*
* @param site the site providing context information for this action
*/
public FindExceptionOccurrencesAction(IWorkbenchSite site) {
super(site);
setText(ActionMessages.FindExceptionOccurrences_text);
setToolTipText(ActionMessages.FindExceptionOccurrences_toolTip);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FIND_EXCEPTION_OCCURRENCES);
}
//---- Text Selection ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
public void selectionChanged(ITextSelection selection) {
}
/**
* {@inheritDoc}
*
* @since 3.2
*/
public void selectionChanged(IStructuredSelection selection) {
setEnabled(getMember(selection) != null);
}
/* (non-JavaDoc)
* Method declared in SelectionDispatchAction.
*/
public final void run(ITextSelection ts) {
IJavaElement input = getEditorInput(fEditor);
if ( !ActionUtil.isProcessable(getShell(), input))
return;
FindOccurrencesEngine engine = FindOccurrencesEngine.create(input, new ExceptionOccurrencesFinder());
try {
String result = engine.run(ts.getOffset(), ts.getLength());
if (result != null)
showMessage(getShell(), fEditor, result);
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
}
private static IJavaElement getEditorInput(JavaEditor editor) {
IEditorInput input = editor.getEditorInput();
if (input instanceof IClassFileEditorInput)
return ((IClassFileEditorInput) input).getClassFile();
return JavaPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(input);
}
private static void showMessage(Shell shell, JavaEditor editor, String msg) {
IEditorStatusLine statusLine = (IEditorStatusLine) editor.getAdapter(IEditorStatusLine.class );
if (statusLine != null)
statusLine.setMessage(true, msg, null);
shell.getDisplay().beep();
}
private IMember getMember(IStructuredSelection selection) {
return null;
}
}
|
| ||||
/**
* Action to find all implement occurrences of an extended class or an implemented interface.
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
*
* @since 3.1
*/
public class FindImplementOccurrencesAction extends SelectionDispatchAction {
private JavaEditor fEditor;
/**
* Note: This constructor is for internal use only. Clients should not call this constructor.
*
* @param editor the Java editor
*/
public FindImplementOccurrencesAction(JavaEditor editor) {
this(editor.getEditorSite());
fEditor = editor;
setEnabled(getEditorInput(editor) != null);
}
/**
* Creates a new <code>FindImplementOccurrencesAction</code>. The action
* requires that the selection provided by the site's selection provider is of type
* <code>IStructuredSelection</code>.
*
* @param site the site providing context information for this action
*/
public FindImplementOccurrencesAction(IWorkbenchSite site) {
super(site);
setText(ActionMessages.FindImplementOccurrencesAction_text);
setToolTipText(ActionMessages.FindImplementOccurrencesAction_toolTip);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FIND_IMPLEMENT_OCCURRENCES);
}
//---- Text Selection ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
public void selectionChanged(ITextSelection selection) {
}
/**
* {@inheritDoc}
*
* @since 3.2
*/
public void selectionChanged(IStructuredSelection selection) {
setEnabled(getMember(selection) != null);
}
/*
* @see org.eclipse.jdt.ui.actions.SelectionDispatchAction#run(org.eclipse.jface.text.ITextSelection)
*/
public final void run(ITextSelection ts) {
IJavaElement input = getEditorInput(fEditor);
if ( !ActionUtil.isProcessable(getShell(), input))
return;
FindOccurrencesEngine engine = FindOccurrencesEngine.create(input, new ImplementOccurrencesFinder());
try {
String result = engine.run(ts.getOffset(), ts.getLength());
if (result != null)
showMessage(getShell(), fEditor, result);
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
}
private static IJavaElement getEditorInput(JavaEditor editor) {
IEditorInput input = editor.getEditorInput();
if (input instanceof IClassFileEditorInput)
return ((IClassFileEditorInput) input).getClassFile();
return JavaPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(input);
}
private static void showMessage(Shell shell, JavaEditor editor, String msg) {
IEditorStatusLine statusLine = (IEditorStatusLine) editor.getAdapter(IEditorStatusLine.class );
if (statusLine != null)
statusLine.setMessage(true, msg, null);
shell.getDisplay().beep();
}
private IMember getMember(IStructuredSelection selection) {
return null;
}
}
|
| |||
/**
* Action to find all implement occurrences of an extended class or an implemented interface.
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
*
* @since 3.1
*/
/**
* Action to find all originators of a exception (e.g. method invocations,
* class casts, ...) for a given exception.
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
*
* @since 3.1
*/
public class [[#variableba6359c0]]extends SelectionDispatchAction {
private JavaEditor fEditor;
/**
* Note: This constructor is for internal use only. Clients should not call this constructor.
*
* @param editor the Java editor
*/
public [[#variableba6359c0]](JavaEditor editor) {
this(editor.getEditorSite());
fEditor = editor;
setEnabled(getEditorInput(editor) != null);
}
/**
* Creates a new <code>FindImplementOccurrencesAction</code>. The action
* requires that the selection provided by the site's selection provider is of type
* <code>IStructuredSelection</code>.
*
* @param site the site providing context information for this action
*/
/**
* Creates a new <code>FindExceptionOccurrencesAction</code>. The action
* requires that the selection provided by the site's selection provider is of type
* <code>IStructuredSelection</code>.
*
* @param site the site providing context information for this action
*/
public [[#variableba6359c0]](IWorkbenchSite site) {
super(site);
setText(ActionMessages. [[#variableba6358c0]]);
setToolTipText(ActionMessages. [[#variableba635860]]);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds. [[#variable5fac0d60]]);
}
//---- Text Selection ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
public void selectionChanged(ITextSelection selection) {
}
/**
* {@inheritDoc}
*
* @since 3.2
*/
public void selectionChanged(IStructuredSelection selection) {
setEnabled(getMember(selection) != null);
}
/*
* @see org.eclipse.jdt.ui.actions.SelectionDispatchAction#run(org.eclipse.jface.text.ITextSelection)
*/
/* (non-JavaDoc)
* Method declared in SelectionDispatchAction.
*/
public final void run(ITextSelection ts) {
IJavaElement input = getEditorInput(fEditor);
if ( !ActionUtil.isProcessable(getShell(), input))
return;
FindOccurrencesEngine engine = FindOccurrencesEngine.create(input, new [[#variableba6358a0]]());
try {
String result = engine.run(ts.getOffset(), ts.getLength());
if (result != null)
showMessage(getShell(), fEditor, result);
}
catch (JavaModelException e) {
JavaPlugin.log(e);
}
}
private static IJavaElement getEditorInput(JavaEditor editor) {
IEditorInput input = editor.getEditorInput();
if (input instanceof IClassFileEditorInput)
return ((IClassFileEditorInput) input).getClassFile();
return JavaPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(input);
}
private static void showMessage(Shell shell, JavaEditor editor, String msg) {
IEditorStatusLine statusLine = (IEditorStatusLine) editor.getAdapter(IEditorStatusLine.class );
if (statusLine != null)
statusLine.setMessage(true, msg, null);
shell.getDisplay().beep();
}
private IMember getMember(IStructuredSelection selection) {
return null;
}
}
|
| CloneAbstraction |
| Parameter Index | Clone Instance | Parameter Name | Value |
|---|---|---|---|
| 1 | 1 | [[#ba6359c0]] | FindImplementOccurrencesAction |
| 1 | 2 | [[#ba6359c0]] | FindExceptionOccurrencesAction |
| 2 | 1 | [[#ba6358c0]] | FindImplementOccurrencesAction_text |
| 2 | 2 | [[#ba6358c0]] | FindExceptionOccurrences_text |
| 3 | 1 | [[#ba635860]] | FindImplementOccurrencesAction_toolTip |
| 3 | 2 | [[#ba635860]] | FindExceptionOccurrences_toolTip |
| 4 | 1 | [[#5fac0d60]] | FIND_IMPLEMENT_OCCURRENCES |
| 4 | 2 | [[#5fac0d60]] | FIND_EXCEPTION_OCCURRENCES |
| 5 | 1 | [[#ba6358a0]] | ImplementOccurrencesFinder |
| 5 | 2 | [[#ba6358a0]] | ExceptionOccurrencesFinder |