Author: dazarov
Date: 2012-10-12 14:10:47 -0400 (Fri, 12 Oct 2012)
New Revision: 44494
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddAttributeMarkerResolution.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
Log:
"Add missing required attribute(s)" quick fix for "Missing required
attribute" WTP problem marker
https://issues.jboss.org/browse/JBIDE-12390
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddAttributeMarkerResolution.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddAttributeMarkerResolution.java 2012-10-12
17:57:59 UTC (rev 44493)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/AddAttributeMarkerResolution.java 2012-10-12
18:10:47 UTC (rev 44494)
@@ -14,12 +14,14 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.IMarkerResolution2;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.DocumentProviderRegistry;
import org.eclipse.ui.texteditor.IDocumentProvider;
@@ -37,7 +39,7 @@
* @author Daniel Azarov
*
*/
-public class AddAttributeMarkerResolution implements IQuickFix{
+public class AddAttributeMarkerResolution implements IMarkerResolution2,
IJavaCompletionProposal{
private IFile file;
private int start, end;
@@ -97,9 +99,11 @@
String text = "<"+node.getNodeName()+" ";
NamedNodeMap attributes = node.getAttributes();
- for(int i = 0; i < attributes.getLength(); i++){
- Node att = attributes.item(i);
- text += att.getNodeName()+"=\""+att.getNodeValue()+"\"
";
+ if(attributes != null){
+ for(int i = 0; i < attributes.getLength(); i++){
+ Node att = attributes.item(i);
+ text += att.getNodeName()+"=\""+att.getNodeValue()+"\"
";
+ }
}
text += attributeName+"=\"\">";
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2012-10-12
17:57:59 UTC (rev 44493)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2012-10-12
18:10:47 UTC (rev 44494)
@@ -377,7 +377,7 @@
public boolean hasResolutions(IMarker marker) {
try{
String message = (String)marker.getAttribute(IMarker.MESSAGE);
- return message.startsWith(UNKNOWN_TAG);
+ return message.startsWith(UNKNOWN_TAG) || message.startsWith(MISSING_ATTRIBUTE);
}catch(CoreException ex){
WebUiPlugin.getPluginLog().logError(ex);
}
@@ -387,7 +387,7 @@
@Override
public boolean hasProposals(Annotation annotation, Position position) {
String message = annotation.getText();
- return message.startsWith(UNKNOWN_TAG);
+ return message.startsWith(UNKNOWN_TAG) || message.startsWith(MISSING_ATTRIBUTE);
}
@Override