diff --git a/codan/org.eclipse.cdt.codan.core/plugin.xml b/codan/org.eclipse.cdt.codan.core/plugin.xml
index c1caee4cce8..7e4ad96a3c5 100644
--- a/codan/org.eclipse.cdt.codan.core/plugin.xml
+++ b/codan/org.eclipse.cdt.codan.core/plugin.xml
@@ -42,7 +42,7 @@
name="category">
+ name="id">
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanProblemMarker.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanProblemMarker.java
index d8021e52805..150c4cc2ab0 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanProblemMarker.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanProblemMarker.java
@@ -21,6 +21,9 @@ import org.eclipse.core.runtime.CoreException;
* @since 2.0
*/
public interface ICodanProblemMarker {
+ public static final String ID = "id"; //$NON-NLS-1$
+ public static final String CATEGORY = "category"; //$NON-NLS-1$
+
/**
* @return problem location
*/
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanMarkerProblemReporter.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanMarkerProblemReporter.java
index eda96e061fc..29825e4b120 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanMarkerProblemReporter.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanMarkerProblemReporter.java
@@ -140,7 +140,7 @@ public class CodanMarkerProblemReporter extends AbstractProblemReporter
Collection problems = reg.getRefProblems(checker);
for (int i = 0; i < markers.length; i++) {
IMarker m = markers[i];
- String id = m.getAttribute(IMarker.PROBLEM, ""); //$NON-NLS-1$
+ String id = m.getAttribute(ICodanProblemMarker.ID, ""); //$NON-NLS-1$
for (Iterator iterator = problems.iterator(); iterator
.hasNext();) {
IProblem iProblem = iterator.next();
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemCategory.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemCategory.java
index 015621143ec..1388eaa5f3f 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemCategory.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemCategory.java
@@ -11,6 +11,7 @@
package org.eclipse.cdt.codan.internal.core.model;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import org.eclipse.cdt.codan.core.model.IProblem;
@@ -54,23 +55,55 @@ public class CodanProblemCategory implements IProblemCategory, Cloneable {
if (object instanceof IProblemCategory) {
IProblemCategory cat = (IProblemCategory) object;
IProblem found = findProblem(cat, id);
- if (found != null) return found;
+ if (found != null)
+ return found;
} else if (object instanceof IProblem) {
IProblem p = (IProblem) object;
- if (p.getId().equals(id)) return p;
+ if (p.getId().equals(id))
+ return p;
}
}
return null;
}
+ /**
+ * Find all categories in which problem with id present
+ *
+ * @param c - root category
+ * @param id - problem id
+ * @return list of categories
+ */
+ public static IProblemCategory[] findProblemCategories(IProblemCategory c,
+ String id) {
+ ArrayList list = new ArrayList();
+ Object[] children = c.getChildren();
+ for (Object object : children) {
+ if (object instanceof IProblemCategory) {
+ IProblemCategory cat = (IProblemCategory) object;
+ IProblemCategory[] found = findProblemCategories(cat, id);
+ if (found.length > 0) {
+ list.addAll(Arrays.asList(found));
+ }
+ } else if (object instanceof IProblem) {
+ IProblem p = (IProblem) object;
+ if (p.getId().equals(id)) {
+ list.add(c);
+ }
+ }
+ }
+ return list.toArray(new IProblemCategory[list.size()]);
+ }
+
public static IProblemCategory findCategory(IProblemCategory cat, String id) {
- if (cat.getId().equals(id)) return cat;
+ if (cat.getId().equals(id))
+ return cat;
Object[] children = cat.getChildren();
for (Object object : children) {
if (object instanceof IProblemCategory) {
IProblemCategory cat2 = (IProblemCategory) object;
IProblemCategory found = findCategory(cat2, id);
- if (found != null) return found;
+ if (found != null)
+ return found;
}
}
return null;
@@ -86,7 +119,8 @@ public class CodanProblemCategory implements IProblemCategory, Cloneable {
try {
CodanProblemCategory clone = (CodanProblemCategory) super.clone();
clone.list = new ArrayList();
- for (Iterator iterator = this.list.iterator(); iterator.hasNext();) {
+ for (Iterator iterator = this.list.iterator(); iterator
+ .hasNext();) {
IProblemElement child = iterator.next();
clone.list.add((IProblemElement) child.clone());
}
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemMarker.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemMarker.java
index 4b61832771d..a1e86b7d1ae 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemMarker.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemMarker.java
@@ -20,7 +20,9 @@ import java.util.Properties;
import org.eclipse.cdt.codan.core.model.CodanSeverity;
import org.eclipse.cdt.codan.core.model.ICodanProblemMarker;
import org.eclipse.cdt.codan.core.model.IProblem;
+import org.eclipse.cdt.codan.core.model.IProblemCategory;
import org.eclipse.cdt.codan.core.model.IProblemLocation;
+import org.eclipse.cdt.codan.core.model.IProblemProfile;
import org.eclipse.cdt.codan.internal.core.CheckersRegistry;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
@@ -95,12 +97,16 @@ public class CodanProblemMarker implements ICodanProblemMarker {
marker.setAttribute(IMarker.MESSAGE, message);
marker.setAttribute(IMarker.SEVERITY, severity);
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
- marker.setAttribute(IMarker.PROBLEM, problem.getId());
+ marker.setAttribute(ID, problem.getId());
marker.setAttribute(IMarker.CHAR_END, loc.getEndingChar());
marker.setAttribute(IMarker.CHAR_START, loc.getStartingChar());
marker.setAttribute("org.eclipse.cdt.core.problem", 42); //$NON-NLS-1$
String propArgs = serializeArgs(args);
marker.setAttribute(PROBLEM_ARGS, propArgs);
+ IProblemCategory[] cats = CodanProblemCategory.findProblemCategories(
+ getProfile(file).getRoot(), problem.getId());
+ String cat = cats.length > 0 ? cats[0].getId() : ""; //$NON-NLS-1$
+ marker.setAttribute(CATEGORY, cat);
return marker;
}
@@ -192,7 +198,7 @@ public class CodanProblemMarker implements ICodanProblemMarker {
*/
public static String getProblemId(IMarker marker) {
try {
- return (String) marker.getAttribute(IMarker.PROBLEM);
+ return (String) marker.getAttribute(ICodanProblemMarker.ID);
} catch (CoreException e) {
return null;
}
@@ -240,14 +246,23 @@ public class CodanProblemMarker implements ICodanProblemMarker {
if (id == null)
return null;
IResource resource = marker.getResource();
- CodanProblem problem = (CodanProblem) ((CodanProblem) CheckersRegistry
- .getInstance().getResourceProfile(resource).findProblem(id))
- .clone();
+ IProblemProfile profile = getProfile(resource);
+ CodanProblem problem = (CodanProblem) ((CodanProblem) profile.findProblem(id)).clone();
CodanSeverity sev = getSeverity(marker);
problem.setSeverity(sev);
return problem;
}
+ /**
+ * @param resource
+ * @return
+ */
+ public static IProblemProfile getProfile(IResource resource) {
+ IProblemProfile profile = CheckersRegistry.getInstance()
+ .getResourceProfile(resource);
+ return profile;
+ }
+
/**
* @param marker
* @return location object using marker attributes
diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/AbstractCodanCQuickFixProcessor.java b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/AbstractCodanCQuickFixProcessor.java
index add06210d02..b9b0cce822b 100644
--- a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/AbstractCodanCQuickFixProcessor.java
+++ b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/AbstractCodanCQuickFixProcessor.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.codan.internal.ui.cxx;
+import org.eclipse.cdt.codan.core.model.ICodanProblemMarker;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
import org.eclipse.cdt.ui.text.ICCompletionProposal;
@@ -63,7 +64,7 @@ public abstract class AbstractCodanCQuickFixProcessor implements IQuickFixProces
IMarker m = markers[i];
int start = m.getAttribute(IMarker.CHAR_START, -1);
if (start==loc.getOffset()) {
- String id = m.getAttribute(IMarker.PROBLEM,""); //$NON-NLS-1$
+ String id = m.getAttribute(ICodanProblemMarker.ID,""); //$NON-NLS-1$
return getCorrections(context, id, m);
}
}
diff --git a/codan/org.eclipse.cdt.codan.ui/plugin.xml b/codan/org.eclipse.cdt.codan.ui/plugin.xml
index 26183423681..65e508b7b57 100644
--- a/codan/org.eclipse.cdt.codan.ui/plugin.xml
+++ b/codan/org.eclipse.cdt.codan.ui/plugin.xml
@@ -116,4 +116,58 @@
markerType="org.eclipse.cdt.core.problem">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanProblemMarkerResolutionGenerator.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanProblemMarkerResolutionGenerator.java
index ed513fa4be6..abd646a8d75 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanProblemMarkerResolutionGenerator.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanProblemMarkerResolutionGenerator.java
@@ -19,6 +19,7 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.eclipse.cdt.codan.core.model.ICodanProblemMarker;
import org.eclipse.cdt.codan.internal.core.model.CodanProblemMarker;
import org.eclipse.cdt.codan.ui.AbstractCodanCMarkerResolution;
import org.eclipse.core.resources.IMarker;
@@ -50,7 +51,7 @@ public class CodanProblemMarkerResolutionGenerator implements
if (resolutionsLoaded == false) {
readExtensions();
}
- String id = marker.getAttribute(IMarker.PROBLEM, null);
+ String id = marker.getAttribute(ICodanProblemMarker.ID, null);
if (id == null && resolutions.get(null) == null)
return new IMarkerResolution[0];
String message = marker.getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetails.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetails.java
index 3f164af1e53..1189a2992cd 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetails.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetails.java
@@ -12,6 +12,7 @@ package org.eclipse.cdt.codan.internal.ui.views;
import java.util.Collection;
+import org.eclipse.cdt.codan.core.model.ICodanProblemMarker;
import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
import org.eclipse.cdt.codan.ui.AbstractCodanProblemDetailsProvider;
import org.eclipse.cdt.codan.ui.CodanEditorUtility;
@@ -34,7 +35,7 @@ import org.eclipse.ui.part.ViewPart;
/**
* Problems Details view show details for selected problem marker.
- * Other plugins can contribute to override default behaviour using
+ * Other plugins can contribute to override default behaviour using
* codanProblemDetails extension point.
*/
public class ProblemDetails extends ViewPart {
@@ -48,7 +49,8 @@ public class ProblemDetails extends ViewPart {
*/
private Link message;
/**
- * Control for problem description which can include links to help or web-sites with extra info
+ * Control for problem description which can include links to help or
+ * web-sites with extra info
*/
private Link description;
private GenericCodanProblemDetailsProvider genProvider = new GenericCodanProblemDetailsProvider();
@@ -64,6 +66,7 @@ public class ProblemDetails extends ViewPart {
* This is a callback that will allow us
* to create the area and initialize it.
*/
+ @Override
public void createPartControl(Composite parent) {
final String problemsViewId = "org.eclipse.ui.views.ProblemView"; //$NON-NLS-1$
area = new Composite(parent, SWT.NONE);
@@ -81,10 +84,11 @@ public class ProblemDetails extends ViewPart {
// link file format example "file:/tmp/file.c#42", 42 is the line number
if (link.startsWith("file:")) { //$NON-NLS-1$
try {
- CodanEditorUtility.openInEditor(link, curProvider.getMarker().getResource());
- } catch (PartInitException e1) {
- CodanUIActivator.log(e1);
- }
+ CodanEditorUtility.openInEditor(link, curProvider
+ .getMarker().getResource());
+ } catch (PartInitException e1) {
+ CodanUIActivator.log(e1);
+ }
return;
}
if (link.startsWith("help:")) { //$NON-NLS-1$
@@ -99,9 +103,11 @@ public class ProblemDetails extends ViewPart {
description = new Link(area, SWT.WRAP);
description.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
description.addSelectionListener(linkSelAdapter);
- ISelectionService ser = (ISelectionService) getSite().getService(ISelectionService.class);
+ ISelectionService ser = (ISelectionService) getSite().getService(
+ ISelectionService.class);
ser.addSelectionListener(new ISelectionListener() {
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ public void selectionChanged(IWorkbenchPart part,
+ ISelection selection) {
if (part.getSite().getId().equals(problemsViewId)) {
processSelection(selection);
}
@@ -115,10 +121,12 @@ public class ProblemDetails extends ViewPart {
if (selection == null || selection.isEmpty())
return;
if (selection instanceof IStructuredSelection) {
- Object firstElement = ((IStructuredSelection) selection).getFirstElement();
+ Object firstElement = ((IStructuredSelection) selection)
+ .getFirstElement();
IMarker marker = null;
if (firstElement instanceof IAdaptable) {
- marker = (IMarker) ((IAdaptable) firstElement).getAdapter(IMarker.class);
+ marker = (IMarker) ((IAdaptable) firstElement)
+ .getAdapter(IMarker.class);
} else if (firstElement instanceof IMarker) {
marker = (IMarker) firstElement;
}
@@ -130,8 +138,9 @@ public class ProblemDetails extends ViewPart {
}
private void queryProviders(IMarker marker) {
- String id = marker.getAttribute(IMarker.PROBLEM, "id"); //$NON-NLS-1$
- Collection providers = ProblemDetailsExtensions.getProviders(id);
+ String id = marker.getAttribute(ICodanProblemMarker.ID, "id"); //$NON-NLS-1$
+ Collection providers = ProblemDetailsExtensions
+ .getProviders(id);
for (AbstractCodanProblemDetailsProvider provider : providers) {
synchronized (provider) {
provider.setMarker(marker);
@@ -148,10 +157,12 @@ public class ProblemDetails extends ViewPart {
private void applyProvider(AbstractCodanProblemDetailsProvider provider) {
curProvider = provider;
setTextSafe(message, provider, provider.getStyledProblemMessage());
- setTextSafe(description, provider, provider.getStyledProblemDescription());
+ setTextSafe(description, provider,
+ provider.getStyledProblemDescription());
}
- protected void setTextSafe(Link control, AbstractCodanProblemDetailsProvider provider, String text) {
+ protected void setTextSafe(Link control,
+ AbstractCodanProblemDetailsProvider provider, String text) {
try {
control.setText(text);
} catch (Exception e) {
@@ -163,6 +174,7 @@ public class ProblemDetails extends ViewPart {
/**
* Passing the focus request to the area's control.
*/
+ @Override
public void setFocus() {
message.setFocus();
}
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanProblemDetailsProvider.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanProblemDetailsProvider.java
index 083941f87e7..508d3101648 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanProblemDetailsProvider.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanProblemDetailsProvider.java
@@ -11,6 +11,7 @@
package org.eclipse.cdt.codan.ui;
import org.eclipse.cdt.codan.core.CodanRuntime;
+import org.eclipse.cdt.codan.core.model.ICodanProblemMarker;
import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.internal.core.model.CodanProblemMarker;
import org.eclipse.core.resources.IMarker;
@@ -63,7 +64,7 @@ public abstract class AbstractCodanProblemDetailsProvider {
* @return
*/
protected String getProblemId() {
- String id = marker.getAttribute(IMarker.PROBLEM, (String) null);
+ String id = marker.getAttribute(ICodanProblemMarker.ID, (String) null);
return id;
}