1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 06:02:11 +02:00

allow to define quick fixes for gcc problems (not codan) as well

This commit is contained in:
Alena Laskavaia 2010-07-22 01:48:07 +00:00
parent 93ab595f8c
commit ec4b080977
4 changed files with 27 additions and 11 deletions

View file

@ -102,12 +102,11 @@
<viewShortcut id="org.eclipse.cdt.codan.internal.ui.views.ProblemDetails"/>
</perspectiveExtension>
</extension>
<extension
<extension
point="org.eclipse.ui.ide.markerResolution">
<markerResolutionGenerator
class="org.eclipse.cdt.codan.internal.ui.CodanProblemMarkerResolutionGenerator"
markerType="org.eclipse.cdt.codan.core.codanProblem">
markerType="org.eclipse.cdt.core.problem">
</markerResolutionGenerator>
</extension>
</plugin>

View file

@ -7,7 +7,6 @@
</appinfo>
<documentation>
Extension point to plugin quick fix for codan markers
</documentation>
</annotation>
@ -65,10 +64,11 @@
</appinfo>
</annotation>
</attribute>
<attribute name="problemId" type="string" use="required">
<attribute name="problemId" type="string">
<annotation>
<documentation>
Problem id of the problem for which quick fix is defined
Problem id of the problem for which quick fix is defined.
If this is not codan problem (for example gcc error), it can be ommitted. Message pattern must be used in this case.
</documentation>
<appinfo>
<meta.attribute kind="identifier" basedOn="org.eclipse.cdt.codan.core.checkers/checker/problem/@id"/>

View file

@ -48,7 +48,7 @@ public class CodanProblemMarkerResolutionGenerator implements
readExtensions();
}
String id = marker.getAttribute(IMarker.PROBLEM, null);
if (id == null)
if (id == null && resolutions.get(null) == null)
return new IMarkerResolution[0];
String message = marker.getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$
Collection<ConditionalResolution> collection = resolutions.get(id);
@ -62,7 +62,8 @@ public class CodanProblemMarkerResolutionGenerator implements
continue;
}
if (res.res instanceof AbstractCodanCMarkerResolution) {
if (!((AbstractCodanCMarkerResolution)res.res).isApplicable(marker))
if (!((AbstractCodanCMarkerResolution) res.res)
.isApplicable(marker))
continue;
}
list.add(res.res);
@ -97,7 +98,9 @@ public class CodanProblemMarkerResolutionGenerator implements
IConfigurationElement configurationElement) {
if (configurationElement.getName().equals("resolution")) { //$NON-NLS-1$
String id = configurationElement.getAttribute("problemId"); //$NON-NLS-1$
if (id == null) {
String messagePattern = configurationElement
.getAttribute("messagePattern"); //$NON-NLS-1$
if (id == null && messagePattern == null) {
CodanUIActivator.log("Extension for " + EXTENSION_POINT_NAME //$NON-NLS-1$
+ " problemId is not defined"); //$NON-NLS-1$
return;
@ -110,8 +113,6 @@ public class CodanProblemMarkerResolutionGenerator implements
CodanUIActivator.log(e);
return;
}
String messagePattern = configurationElement
.getAttribute("messagePattern"); //$NON-NLS-1$
if (messagePattern != null) {
try {
Pattern.compile(messagePattern);

View file

@ -230,4 +230,20 @@ public abstract class AbstractCodanCMarkerResolution implements
IIndex index = CCorePlugin.getIndexManager().getIndex(cProject);
return index;
}
/**
* @param marker
* @return
*/
public String getProblemId(IMarker marker) {
return CodanProblemMarker.getProblemId(marker);
}
/**
* @param marker
* @return
*/
public String getProblemMessage(IMarker marker) {
return CodanProblemMarker.getMessage(marker);
}
}