1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-08 08:45:44 +02:00

Bug 317538: added access methods to details provider as well

This commit is contained in:
Alena Laskavaia 2010-06-22 02:20:04 +00:00
parent 3d0baee8fb
commit 2c2fd351e0

View file

@ -12,13 +12,17 @@ package org.eclipse.cdt.codan.ui;
import org.eclipse.cdt.codan.core.CodanRuntime; import org.eclipse.cdt.codan.core.CodanRuntime;
import org.eclipse.cdt.codan.core.model.IProblem; import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.internal.core.model.CodanProblemMarker;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
/** /**
* Abstract class that provides stubs for problems details. * Abstract class that provides stubs for problems details.
* This class intended to be extended by the users of codanProblemDetails extension point. * This class intended to be extended by the users of codanProblemDetails
* One instance of this class would exists at runtime. To query for results, framework * extension point.
* would synchronize on this class object, set setMarker then call other getStyled* methods * One instance of this class would exists at runtime. To query for results,
* framework
* would synchronize on this class object, set setMarker then call other
* getStyled* methods
* to obtain data. * to obtain data.
*/ */
public abstract class AbstractCodanProblemDetailsProvider { public abstract class AbstractCodanProblemDetailsProvider {
@ -36,6 +40,7 @@ public abstract class AbstractCodanProblemDetailsProvider {
/** /**
* Get marker associated with this provider * Get marker associated with this provider
*
* @return * @return
*/ */
public IMarker getMarker() { public IMarker getMarker() {
@ -44,6 +49,7 @@ public abstract class AbstractCodanProblemDetailsProvider {
/** /**
* Convenience method to return marker message * Convenience method to return marker message
*
* @return * @return
*/ */
protected String getProblemMessage() { protected String getProblemMessage() {
@ -53,6 +59,7 @@ public abstract class AbstractCodanProblemDetailsProvider {
/** /**
* Convenience method to return codan problem id * Convenience method to return codan problem id
*
* @return * @return
*/ */
protected String getProblemId() { protected String getProblemId() {
@ -61,36 +68,65 @@ public abstract class AbstractCodanProblemDetailsProvider {
} }
/** /**
* return true if provider can provide details for given marker (previously set by setMarker) * return true if provider can provide details for given marker (previously
* set by setMarker)
*
* @param id - id of the problem * @param id - id of the problem
* @return true if details are available for given marker * @return true if details are available for given marker
*/ */
public abstract boolean isApplicable(String id); public abstract boolean isApplicable(String id);
/**
* Returns problem arguments by index (set by checker when reporting
* problem)
*
* @since 1.1
*/
public String getProblemArgument(int index) {
return CodanProblemMarker.getProblemArgument(marker, index);
}
/**
* Return the arguments of a problem that checker passed to "reportProblem"
* method
*
* @param marker - problem marker
* @return problem arguments, can not be null. Can be 0 sized array.
* @since 1.1
*/
public String[] getProblemArguments() {
return CodanProblemMarker.getProblemArguments(marker);
}
/** /**
* Return styled problem message. This text would be used in Link widget. * Return styled problem message. This text would be used in Link widget.
* String can include <a> tags to which would be * String can include <a> tags to which would be
* visible as hyperlinks and newline characters (\n). Default message if * visible as hyperlinks and newline characters (\n). Default message if
* marker message plus location. Ampersand (&) should be escape because * marker message plus location. Ampersand (&) should be escape because
* it is interpreted as mnemonic for control navigation (can use espaceForLink method). <br> * it is interpreted as mnemonic for control navigation (can use
* espaceForLink method). <br>
* This method intended to be overriden by the client. * This method intended to be overriden by the client.
*/ */
public String getStyledProblemMessage() { public String getStyledProblemMessage() {
String message = escapeForLink(getProblemMessage()); String message = escapeForLink(getProblemMessage());
String href = getLocationHRef(); String href = getLocationHRef();
String link = href.replaceFirst("^file:", ""); //$NON-NLS-1$ //$NON-NLS-2$ String link = href.replaceFirst("^file:", ""); //$NON-NLS-1$ //$NON-NLS-2$
link = link.replaceFirst("#(\\d+)$", ":$1"); //$NON-NLS-1$//$NON-NLS-2$ link = link.replaceFirst("#(\\d+)$", ":$1"); //$NON-NLS-1$//$NON-NLS-2$
return "<a href=\"" + href + "\">" + link + "</a> \n" + message; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ return "<a href=\"" + href + "\">" + link + "</a> \n" + message; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
} }
protected String getLocationHRef() { protected String getLocationHRef() {
return CodanEditorUtility.getLocationHRef(marker); return CodanEditorUtility.getLocationHRef(marker);
} }
/** /**
* Return styled problem description. This text would be used in Link widget. * Return styled problem description. This text would be used in Link
* widget.
* String can include <a> tags to which would be * String can include <a> tags to which would be
* visible as hyperlinks and newline characters (\n). * visible as hyperlinks and newline characters (\n).
* Ampersand (&) should be escape because * Ampersand (&) should be escape because
* it is interpreted as mnemonic for control navigation (can use espaceForLink method). * it is interpreted as mnemonic for control navigation (can use
* espaceForLink method).
* *
* Default implementation return desciption of codan problem. <br> * Default implementation return desciption of codan problem. <br>
* This method intended to be overriden by the client. * This method intended to be overriden by the client.
@ -100,7 +136,8 @@ public abstract class AbstractCodanProblemDetailsProvider {
String id = getProblemId(); String id = getProblemId();
if (id == null) if (id == null)
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
IProblem problem = CodanRuntime.getInstance().getCheckersRegistry().getDefaultProfile().findProblem(id); IProblem problem = CodanRuntime.getInstance().getCheckersRegistry()
.getDefaultProfile().findProblem(id);
return escapeForLink(problem.getDescription()); return escapeForLink(problem.getDescription());
} }