Jump to: navigation, search

Talk:FAQ How do I implement Quick Fixes for my own language?

Revision as of 08:42, 13 November 2012 by Linedsubset.live.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

I have followed the steps to implement the quickfixes and I've not been able to get it right. Here is what I did:

First I added the extension to the plugin.xml file directly:

<?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.4"?> <plugin>

  <extension point="org.eclipse.ui.ide.markerResolution">
  	<markerResolutionGenerator
     markerType="org.eclipse.core.resources.problemmarker"
     class="org.eclipse.escript.quickfix.QuickFixer"/>
  </extension>
  <extension
        point="org.eclipse.ui.commands">
     <category
           name="Sample Category"
           id="QuickFixer.commands.category">
     </category>
     <command
           name="Sample Command"
           categoryId="QuickFixer.commands.category"
           id="QuickFixer.commands.sampleCommand">
     </command>
  </extension>
  <extension
        point="org.eclipse.ui.handlers">
     <handler
           commandId="QuickFixer.commands.sampleCommand"
           class="quickfixer.handlers.SampleHandler">
     </handler>
  </extension>
  <extension
        point="org.eclipse.ui.bindings">
     <key
           commandId="QuickFixer.commands.sampleCommand"
           contextId="org.eclipse.ui.contexts.window"
           sequence="M1+6"
           schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
     </key>
  </extension>
  <extension
        point="org.eclipse.ui.menus">
     <menuContribution
           locationURI="menu:org.eclipse.ui.main.menu?after=additions">
        <menu
              label="Sample Menu"
              mnemonic="M"
              id="QuickFixer.menus.sampleMenu">
           <command
                 commandId="QuickFixer.commands.sampleCommand"
                 mnemonic="S"
                 id="QuickFixer.menus.sampleCommand">
           </command>
        </menu>
     </menuContribution>
     <menuContribution
           locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
        <toolbar
              id="QuickFixer.toolbars.sampleToolbar">
           <command
                 commandId="QuickFixer.commands.sampleCommand"
                 icon="icons/sample.gif"
                 tooltip="Say hello world"
                 id="QuickFixer.toolbars.sampleCommand">
           </command>
        </toolbar>
     </menuContribution>
  </extension>

</plugin>


THEN i created the class QuickFixer:

package quickfixer;

import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.CoreException; import org.eclipse.ui.IMarkerResolution; import org.eclipse.ui.IMarkerResolutionGenerator;


class QuickFixer implements IMarkerResolutionGenerator {


public IMarkerResolution[] getResolutions(IMarker mk) {

try {

Object problem = mk.getAttribute("Whatsup"); return new IMarkerResolution[] { new QuickFix("Fix #1 for "+problem), new QuickFix("Fix #2 for "+problem), }; } catch(CoreException e) { return new IMarkerResolution[0]; } } } FOLLOWING this, I created the class QuickFix:

package quickfixer;

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 mk) {

MessageDialog.openInformation(null, "QuickFix Demo",

"This quick-fix is not yet implemented");


}

}

And when i run the plugin, I don't get any message dialog boxes for the two additional quickfixes and I don't even have the additional quickfixes in the list proposed by the quickfix component