Cleanup
This commit is contained in:
parent
d88cdc599b
commit
7cf1419cc4
@ -70,11 +70,6 @@
|
|||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<!-- ExtensionPoint für die QuickFixes der ReplaceMarker Quelle: http://wiki.eclipse.org/FAQ_How_do_I_implement_Quick_Fixes_for_my_own_language%3F -->
|
<!-- ExtensionPoint für die QuickFixes der ReplaceMarker Quelle: http://wiki.eclipse.org/FAQ_How_do_I_implement_Quick_Fixes_for_my_own_language%3F -->
|
||||||
<extension point="org.eclipse.ui.ide.markerResolution">
|
|
||||||
<markerResolutionGenerator
|
|
||||||
markerType="typinferenzplugin.replacemarker"
|
|
||||||
class="typinferenzplugin.marker.QuickFixer"/>
|
|
||||||
</extension>
|
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.ui.menus">
|
point="org.eclipse.ui.menus">
|
||||||
<menuContribution
|
<menuContribution
|
||||||
|
@ -7,6 +7,8 @@ import org.eclipse.swt.events.SelectionListener;
|
|||||||
import org.eclipse.swt.widgets.Menu;
|
import org.eclipse.swt.widgets.Menu;
|
||||||
import org.eclipse.swt.widgets.MenuItem;
|
import org.eclipse.swt.widgets.MenuItem;
|
||||||
|
|
||||||
|
import typinferenzplugin.TypeReplaceMarker;
|
||||||
|
|
||||||
public class InsertTypeContribution extends ContributionItem {
|
public class InsertTypeContribution extends ContributionItem {
|
||||||
JavEditor editorContext;
|
JavEditor editorContext;
|
||||||
|
|
||||||
@ -15,29 +17,45 @@ public class InsertTypeContribution extends ContributionItem {
|
|||||||
this.editorContext = editorContext;
|
this.editorContext = editorContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final class SelectionHandler implements SelectionListener {
|
||||||
|
final TypeReplaceMarker marker;
|
||||||
|
|
||||||
|
SelectionHandler(TypeReplaceMarker marker) {
|
||||||
|
this.marker = marker;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
editorContext.runReplaceMarker(marker);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fill(Menu menu, int index) {
|
public void fill(Menu menu, int index) {
|
||||||
new MenuItem(menu, SWT.SEPARATOR, 0);
|
new MenuItem(menu, SWT.SEPARATOR, 0);
|
||||||
var parent = new MenuItem(menu, SWT.CASCADE, 0);
|
if (editorContext.currentMarkers.size() > 1) {
|
||||||
parent.setText("Typ einsetzen");
|
var parent = new MenuItem(menu, SWT.CASCADE, 0);
|
||||||
var subMenu = new Menu(parent);
|
parent.setText("Typ einsetzen");
|
||||||
parent.setMenu(subMenu);
|
var subMenu = new Menu(parent);
|
||||||
for (var marker : editorContext.currentMarkers) {
|
parent.setMenu(subMenu);
|
||||||
var item = new MenuItem(subMenu, SWT.PUSH);
|
for (var marker : editorContext.currentMarkers) {
|
||||||
item.setText(marker.getInsertPoint().getInsertString());
|
var item = new MenuItem(subMenu, SWT.PUSH);
|
||||||
item.addSelectionListener(new SelectionListener() {
|
item.setText(marker.getInsertPoint().getInsertString());
|
||||||
@Override
|
item.addSelectionListener(new SelectionHandler(marker));
|
||||||
public void widgetSelected(SelectionEvent e) {
|
}
|
||||||
editorContext.runReplaceMarker(marker);
|
} else {
|
||||||
}
|
var marker = editorContext.currentMarkers.get(0);
|
||||||
|
var item = new MenuItem(menu, SWT.PUSH, 0);
|
||||||
@Override
|
item.setText(marker.getInsertPoint().getInsertString() + " einsetzen");
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {
|
item.addSelectionListener(new SelectionHandler(marker));
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
package typinferenzplugin.marker;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IMarker;
|
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
|
||||||
import org.eclipse.ui.IMarkerResolution;
|
|
||||||
|
|
||||||
public class QuickFix implements IMarkerResolution {
|
|
||||||
String label;
|
|
||||||
QuickFix(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
public void run(IMarker marker) {
|
|
||||||
MessageDialog.openInformation(null, "QuickFix Demo",
|
|
||||||
"This quick-fix is not yet implemented");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package typinferenzplugin.marker;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IMarker;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.ui.IMarkerResolution;
|
|
||||||
import org.eclipse.ui.IMarkerResolutionGenerator;
|
|
||||||
|
|
||||||
public class QuickFixer implements IMarkerResolutionGenerator {
|
|
||||||
|
|
||||||
public IMarkerResolution[] getResolutions(IMarker mk) {
|
|
||||||
return new IMarkerResolution[] {
|
|
||||||
new QuickFix("Fix #1 for ")
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user