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:
parent
93ab595f8c
commit
ec4b080977
4 changed files with 27 additions and 11 deletions
|
@ -102,12 +102,11 @@
|
||||||
<viewShortcut id="org.eclipse.cdt.codan.internal.ui.views.ProblemDetails"/>
|
<viewShortcut id="org.eclipse.cdt.codan.internal.ui.views.ProblemDetails"/>
|
||||||
</perspectiveExtension>
|
</perspectiveExtension>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.ui.ide.markerResolution">
|
point="org.eclipse.ui.ide.markerResolution">
|
||||||
<markerResolutionGenerator
|
<markerResolutionGenerator
|
||||||
class="org.eclipse.cdt.codan.internal.ui.CodanProblemMarkerResolutionGenerator"
|
class="org.eclipse.cdt.codan.internal.ui.CodanProblemMarkerResolutionGenerator"
|
||||||
markerType="org.eclipse.cdt.codan.core.codanProblem">
|
markerType="org.eclipse.cdt.core.problem">
|
||||||
</markerResolutionGenerator>
|
</markerResolutionGenerator>
|
||||||
</extension>
|
</extension>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
</appinfo>
|
</appinfo>
|
||||||
<documentation>
|
<documentation>
|
||||||
Extension point to plugin quick fix for codan markers
|
Extension point to plugin quick fix for codan markers
|
||||||
|
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
|
|
||||||
|
@ -65,10 +64,11 @@
|
||||||
</appinfo>
|
</appinfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="problemId" type="string" use="required">
|
<attribute name="problemId" type="string">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<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>
|
</documentation>
|
||||||
<appinfo>
|
<appinfo>
|
||||||
<meta.attribute kind="identifier" basedOn="org.eclipse.cdt.codan.core.checkers/checker/problem/@id"/>
|
<meta.attribute kind="identifier" basedOn="org.eclipse.cdt.codan.core.checkers/checker/problem/@id"/>
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class CodanProblemMarkerResolutionGenerator implements
|
||||||
readExtensions();
|
readExtensions();
|
||||||
}
|
}
|
||||||
String id = marker.getAttribute(IMarker.PROBLEM, null);
|
String id = marker.getAttribute(IMarker.PROBLEM, null);
|
||||||
if (id == null)
|
if (id == null && resolutions.get(null) == null)
|
||||||
return new IMarkerResolution[0];
|
return new IMarkerResolution[0];
|
||||||
String message = marker.getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$
|
String message = marker.getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$
|
||||||
Collection<ConditionalResolution> collection = resolutions.get(id);
|
Collection<ConditionalResolution> collection = resolutions.get(id);
|
||||||
|
@ -62,7 +62,8 @@ public class CodanProblemMarkerResolutionGenerator implements
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (res.res instanceof AbstractCodanCMarkerResolution) {
|
if (res.res instanceof AbstractCodanCMarkerResolution) {
|
||||||
if (!((AbstractCodanCMarkerResolution)res.res).isApplicable(marker))
|
if (!((AbstractCodanCMarkerResolution) res.res)
|
||||||
|
.isApplicable(marker))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
list.add(res.res);
|
list.add(res.res);
|
||||||
|
@ -97,7 +98,9 @@ public class CodanProblemMarkerResolutionGenerator implements
|
||||||
IConfigurationElement configurationElement) {
|
IConfigurationElement configurationElement) {
|
||||||
if (configurationElement.getName().equals("resolution")) { //$NON-NLS-1$
|
if (configurationElement.getName().equals("resolution")) { //$NON-NLS-1$
|
||||||
String id = configurationElement.getAttribute("problemId"); //$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$
|
CodanUIActivator.log("Extension for " + EXTENSION_POINT_NAME //$NON-NLS-1$
|
||||||
+ " problemId is not defined"); //$NON-NLS-1$
|
+ " problemId is not defined"); //$NON-NLS-1$
|
||||||
return;
|
return;
|
||||||
|
@ -110,8 +113,6 @@ public class CodanProblemMarkerResolutionGenerator implements
|
||||||
CodanUIActivator.log(e);
|
CodanUIActivator.log(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String messagePattern = configurationElement
|
|
||||||
.getAttribute("messagePattern"); //$NON-NLS-1$
|
|
||||||
if (messagePattern != null) {
|
if (messagePattern != null) {
|
||||||
try {
|
try {
|
||||||
Pattern.compile(messagePattern);
|
Pattern.compile(messagePattern);
|
||||||
|
|
|
@ -230,4 +230,20 @@ public abstract class AbstractCodanCMarkerResolution implements
|
||||||
IIndex index = CCorePlugin.getIndexManager().getIndex(cProject);
|
IIndex index = CCorePlugin.getIndexManager().getIndex(cProject);
|
||||||
return index;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue