mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
fixed usage of improper attribute for problem id, added marker groupping support
This commit is contained in:
parent
d535cea64c
commit
992cf58f31
10 changed files with 150 additions and 29 deletions
|
@ -42,7 +42,7 @@
|
||||||
name="category">
|
name="category">
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute
|
<attribute
|
||||||
name="org.eclipse.core.resources.problemmarker">
|
name="id">
|
||||||
</attribute>
|
</attribute>
|
||||||
<persistent
|
<persistent
|
||||||
value="true">
|
value="true">
|
||||||
|
|
|
@ -21,6 +21,9 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public interface ICodanProblemMarker {
|
public interface ICodanProblemMarker {
|
||||||
|
public static final String ID = "id"; //$NON-NLS-1$
|
||||||
|
public static final String CATEGORY = "category"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return problem location
|
* @return problem location
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -140,7 +140,7 @@ public class CodanMarkerProblemReporter extends AbstractProblemReporter
|
||||||
Collection<IProblem> problems = reg.getRefProblems(checker);
|
Collection<IProblem> problems = reg.getRefProblems(checker);
|
||||||
for (int i = 0; i < markers.length; i++) {
|
for (int i = 0; i < markers.length; i++) {
|
||||||
IMarker m = markers[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<IProblem> iterator = problems.iterator(); iterator
|
for (Iterator<IProblem> iterator = problems.iterator(); iterator
|
||||||
.hasNext();) {
|
.hasNext();) {
|
||||||
IProblem iProblem = iterator.next();
|
IProblem iProblem = iterator.next();
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.cdt.codan.internal.core.model;
|
package org.eclipse.cdt.codan.internal.core.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.codan.core.model.IProblem;
|
import org.eclipse.cdt.codan.core.model.IProblem;
|
||||||
|
@ -54,23 +55,55 @@ public class CodanProblemCategory implements IProblemCategory, Cloneable {
|
||||||
if (object instanceof IProblemCategory) {
|
if (object instanceof IProblemCategory) {
|
||||||
IProblemCategory cat = (IProblemCategory) object;
|
IProblemCategory cat = (IProblemCategory) object;
|
||||||
IProblem found = findProblem(cat, id);
|
IProblem found = findProblem(cat, id);
|
||||||
if (found != null) return found;
|
if (found != null)
|
||||||
|
return found;
|
||||||
} else if (object instanceof IProblem) {
|
} else if (object instanceof IProblem) {
|
||||||
IProblem p = (IProblem) object;
|
IProblem p = (IProblem) object;
|
||||||
if (p.getId().equals(id)) return p;
|
if (p.getId().equals(id))
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
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<IProblemCategory> list = new ArrayList<IProblemCategory>();
|
||||||
|
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) {
|
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();
|
Object[] children = cat.getChildren();
|
||||||
for (Object object : children) {
|
for (Object object : children) {
|
||||||
if (object instanceof IProblemCategory) {
|
if (object instanceof IProblemCategory) {
|
||||||
IProblemCategory cat2 = (IProblemCategory) object;
|
IProblemCategory cat2 = (IProblemCategory) object;
|
||||||
IProblemCategory found = findCategory(cat2, id);
|
IProblemCategory found = findCategory(cat2, id);
|
||||||
if (found != null) return found;
|
if (found != null)
|
||||||
|
return found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -86,7 +119,8 @@ public class CodanProblemCategory implements IProblemCategory, Cloneable {
|
||||||
try {
|
try {
|
||||||
CodanProblemCategory clone = (CodanProblemCategory) super.clone();
|
CodanProblemCategory clone = (CodanProblemCategory) super.clone();
|
||||||
clone.list = new ArrayList<IProblemElement>();
|
clone.list = new ArrayList<IProblemElement>();
|
||||||
for (Iterator<IProblemElement> iterator = this.list.iterator(); iterator.hasNext();) {
|
for (Iterator<IProblemElement> iterator = this.list.iterator(); iterator
|
||||||
|
.hasNext();) {
|
||||||
IProblemElement child = iterator.next();
|
IProblemElement child = iterator.next();
|
||||||
clone.list.add((IProblemElement) child.clone());
|
clone.list.add((IProblemElement) child.clone());
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,9 @@ import java.util.Properties;
|
||||||
import org.eclipse.cdt.codan.core.model.CodanSeverity;
|
import org.eclipse.cdt.codan.core.model.CodanSeverity;
|
||||||
import org.eclipse.cdt.codan.core.model.ICodanProblemMarker;
|
import org.eclipse.cdt.codan.core.model.ICodanProblemMarker;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblem;
|
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.IProblemLocation;
|
||||||
|
import org.eclipse.cdt.codan.core.model.IProblemProfile;
|
||||||
import org.eclipse.cdt.codan.internal.core.CheckersRegistry;
|
import org.eclipse.cdt.codan.internal.core.CheckersRegistry;
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
@ -95,12 +97,16 @@ public class CodanProblemMarker implements ICodanProblemMarker {
|
||||||
marker.setAttribute(IMarker.MESSAGE, message);
|
marker.setAttribute(IMarker.MESSAGE, message);
|
||||||
marker.setAttribute(IMarker.SEVERITY, severity);
|
marker.setAttribute(IMarker.SEVERITY, severity);
|
||||||
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
|
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_END, loc.getEndingChar());
|
||||||
marker.setAttribute(IMarker.CHAR_START, loc.getStartingChar());
|
marker.setAttribute(IMarker.CHAR_START, loc.getStartingChar());
|
||||||
marker.setAttribute("org.eclipse.cdt.core.problem", 42); //$NON-NLS-1$
|
marker.setAttribute("org.eclipse.cdt.core.problem", 42); //$NON-NLS-1$
|
||||||
String propArgs = serializeArgs(args);
|
String propArgs = serializeArgs(args);
|
||||||
marker.setAttribute(PROBLEM_ARGS, propArgs);
|
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;
|
return marker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +198,7 @@ public class CodanProblemMarker implements ICodanProblemMarker {
|
||||||
*/
|
*/
|
||||||
public static String getProblemId(IMarker marker) {
|
public static String getProblemId(IMarker marker) {
|
||||||
try {
|
try {
|
||||||
return (String) marker.getAttribute(IMarker.PROBLEM);
|
return (String) marker.getAttribute(ICodanProblemMarker.ID);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -240,14 +246,23 @@ public class CodanProblemMarker implements ICodanProblemMarker {
|
||||||
if (id == null)
|
if (id == null)
|
||||||
return null;
|
return null;
|
||||||
IResource resource = marker.getResource();
|
IResource resource = marker.getResource();
|
||||||
CodanProblem problem = (CodanProblem) ((CodanProblem) CheckersRegistry
|
IProblemProfile profile = getProfile(resource);
|
||||||
.getInstance().getResourceProfile(resource).findProblem(id))
|
CodanProblem problem = (CodanProblem) ((CodanProblem) profile.findProblem(id)).clone();
|
||||||
.clone();
|
|
||||||
CodanSeverity sev = getSeverity(marker);
|
CodanSeverity sev = getSeverity(marker);
|
||||||
problem.setSeverity(sev);
|
problem.setSeverity(sev);
|
||||||
return problem;
|
return problem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param resource
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static IProblemProfile getProfile(IResource resource) {
|
||||||
|
IProblemProfile profile = CheckersRegistry.getInstance()
|
||||||
|
.getResourceProfile(resource);
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param marker
|
* @param marker
|
||||||
* @return location object using marker attributes
|
* @return location object using marker attributes
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.internal.ui.cxx;
|
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.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
|
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
|
||||||
import org.eclipse.cdt.ui.text.ICCompletionProposal;
|
import org.eclipse.cdt.ui.text.ICCompletionProposal;
|
||||||
|
@ -63,7 +64,7 @@ public abstract class AbstractCodanCQuickFixProcessor implements IQuickFixProces
|
||||||
IMarker m = markers[i];
|
IMarker m = markers[i];
|
||||||
int start = m.getAttribute(IMarker.CHAR_START, -1);
|
int start = m.getAttribute(IMarker.CHAR_START, -1);
|
||||||
if (start==loc.getOffset()) {
|
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);
|
return getCorrections(context, id, m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,4 +116,58 @@
|
||||||
markerType="org.eclipse.cdt.core.problem">
|
markerType="org.eclipse.cdt.core.problem">
|
||||||
</markerResolutionGenerator>
|
</markerResolutionGenerator>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.ide.markerSupport">
|
||||||
|
<markerTypeCategory
|
||||||
|
name="Code Analysis Problem">
|
||||||
|
<markerTypeReference
|
||||||
|
id="org.eclipse.cdt.codan.core.codanProblem">
|
||||||
|
</markerTypeReference>
|
||||||
|
</markerTypeCategory>
|
||||||
|
<markerGrouping
|
||||||
|
id="org.eclipse.cdt.codan.ui.markerGrouping"
|
||||||
|
label="Codan Problem Type">
|
||||||
|
</markerGrouping>
|
||||||
|
<markerAttributeGrouping
|
||||||
|
attribute="category"
|
||||||
|
defaultGroupingEntry="org.eclipse.cdt.codan.ui.markerGroupingUnknown"
|
||||||
|
markerType="org.eclipse.cdt.codan.core.codanProblem">
|
||||||
|
<markerAttributeMapping
|
||||||
|
markerGroupingEntry="org.eclipse.cdt.codan.core.categories.ProgrammingProblems"
|
||||||
|
value="org.eclipse.cdt.codan.core.categories.ProgrammingProblems">
|
||||||
|
</markerAttributeMapping>
|
||||||
|
<markerAttributeMapping
|
||||||
|
markerGroupingEntry="org.eclipse.cdt.codan.core.categories.CompilerErrors"
|
||||||
|
value="org.eclipse.cdt.codan.core.categories.CompilerErrors">
|
||||||
|
</markerAttributeMapping>
|
||||||
|
<markerAttributeMapping
|
||||||
|
markerGroupingEntry="org.eclipse.cdt.codan.core.categories.CodeStyle"
|
||||||
|
value="org.eclipse.cdt.codan.core.categories.CodeStyle">
|
||||||
|
</markerAttributeMapping>
|
||||||
|
</markerAttributeGrouping>
|
||||||
|
<markerGroupingEntry
|
||||||
|
id="org.eclipse.cdt.codan.ui.markerGroupingUnknown"
|
||||||
|
label="Unknown"
|
||||||
|
markerGrouping="org.eclipse.cdt.codan.ui.markerGrouping"
|
||||||
|
priority="90">
|
||||||
|
</markerGroupingEntry>
|
||||||
|
<markerGroupingEntry
|
||||||
|
id="org.eclipse.cdt.codan.core.categories.ProgrammingProblems"
|
||||||
|
label="Programming Problems"
|
||||||
|
markerGrouping="org.eclipse.cdt.codan.ui.markerGrouping"
|
||||||
|
priority="10">
|
||||||
|
</markerGroupingEntry>
|
||||||
|
<markerGroupingEntry
|
||||||
|
id="org.eclipse.cdt.codan.core.categories.CompilerErrors"
|
||||||
|
label="Compiler Errors"
|
||||||
|
markerGrouping="org.eclipse.cdt.codan.ui.markerGrouping"
|
||||||
|
priority="2">
|
||||||
|
</markerGroupingEntry>
|
||||||
|
<markerGroupingEntry
|
||||||
|
id="org.eclipse.cdt.codan.core.categories.CodeStyle"
|
||||||
|
label="Coding Style"
|
||||||
|
markerGrouping="org.eclipse.cdt.codan.ui.markerGrouping"
|
||||||
|
priority="80">
|
||||||
|
</markerGroupingEntry>
|
||||||
|
</extension>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -19,6 +19,7 @@ import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
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.internal.core.model.CodanProblemMarker;
|
||||||
import org.eclipse.cdt.codan.ui.AbstractCodanCMarkerResolution;
|
import org.eclipse.cdt.codan.ui.AbstractCodanCMarkerResolution;
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
|
@ -50,7 +51,7 @@ public class CodanProblemMarkerResolutionGenerator implements
|
||||||
if (resolutionsLoaded == false) {
|
if (resolutionsLoaded == false) {
|
||||||
readExtensions();
|
readExtensions();
|
||||||
}
|
}
|
||||||
String id = marker.getAttribute(IMarker.PROBLEM, null);
|
String id = marker.getAttribute(ICodanProblemMarker.ID, null);
|
||||||
if (id == null && resolutions.get(null) == 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$
|
||||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.codan.internal.ui.views;
|
||||||
|
|
||||||
import java.util.Collection;
|
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.internal.ui.CodanUIActivator;
|
||||||
import org.eclipse.cdt.codan.ui.AbstractCodanProblemDetailsProvider;
|
import org.eclipse.cdt.codan.ui.AbstractCodanProblemDetailsProvider;
|
||||||
import org.eclipse.cdt.codan.ui.CodanEditorUtility;
|
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.
|
* 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.
|
* codanProblemDetails extension point.
|
||||||
*/
|
*/
|
||||||
public class ProblemDetails extends ViewPart {
|
public class ProblemDetails extends ViewPart {
|
||||||
|
@ -48,7 +49,8 @@ public class ProblemDetails extends ViewPart {
|
||||||
*/
|
*/
|
||||||
private Link message;
|
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 Link description;
|
||||||
private GenericCodanProblemDetailsProvider genProvider = new GenericCodanProblemDetailsProvider();
|
private GenericCodanProblemDetailsProvider genProvider = new GenericCodanProblemDetailsProvider();
|
||||||
|
@ -64,6 +66,7 @@ public class ProblemDetails extends ViewPart {
|
||||||
* This is a callback that will allow us
|
* This is a callback that will allow us
|
||||||
* to create the area and initialize it.
|
* to create the area and initialize it.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void createPartControl(Composite parent) {
|
public void createPartControl(Composite parent) {
|
||||||
final String problemsViewId = "org.eclipse.ui.views.ProblemView"; //$NON-NLS-1$
|
final String problemsViewId = "org.eclipse.ui.views.ProblemView"; //$NON-NLS-1$
|
||||||
area = new Composite(parent, SWT.NONE);
|
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
|
// link file format example "file:/tmp/file.c#42", 42 is the line number
|
||||||
if (link.startsWith("file:")) { //$NON-NLS-1$
|
if (link.startsWith("file:")) { //$NON-NLS-1$
|
||||||
try {
|
try {
|
||||||
CodanEditorUtility.openInEditor(link, curProvider.getMarker().getResource());
|
CodanEditorUtility.openInEditor(link, curProvider
|
||||||
} catch (PartInitException e1) {
|
.getMarker().getResource());
|
||||||
CodanUIActivator.log(e1);
|
} catch (PartInitException e1) {
|
||||||
}
|
CodanUIActivator.log(e1);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (link.startsWith("help:")) { //$NON-NLS-1$
|
if (link.startsWith("help:")) { //$NON-NLS-1$
|
||||||
|
@ -99,9 +103,11 @@ public class ProblemDetails extends ViewPart {
|
||||||
description = new Link(area, SWT.WRAP);
|
description = new Link(area, SWT.WRAP);
|
||||||
description.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
description.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||||
description.addSelectionListener(linkSelAdapter);
|
description.addSelectionListener(linkSelAdapter);
|
||||||
ISelectionService ser = (ISelectionService) getSite().getService(ISelectionService.class);
|
ISelectionService ser = (ISelectionService) getSite().getService(
|
||||||
|
ISelectionService.class);
|
||||||
ser.addSelectionListener(new ISelectionListener() {
|
ser.addSelectionListener(new ISelectionListener() {
|
||||||
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
|
public void selectionChanged(IWorkbenchPart part,
|
||||||
|
ISelection selection) {
|
||||||
if (part.getSite().getId().equals(problemsViewId)) {
|
if (part.getSite().getId().equals(problemsViewId)) {
|
||||||
processSelection(selection);
|
processSelection(selection);
|
||||||
}
|
}
|
||||||
|
@ -115,10 +121,12 @@ public class ProblemDetails extends ViewPart {
|
||||||
if (selection == null || selection.isEmpty())
|
if (selection == null || selection.isEmpty())
|
||||||
return;
|
return;
|
||||||
if (selection instanceof IStructuredSelection) {
|
if (selection instanceof IStructuredSelection) {
|
||||||
Object firstElement = ((IStructuredSelection) selection).getFirstElement();
|
Object firstElement = ((IStructuredSelection) selection)
|
||||||
|
.getFirstElement();
|
||||||
IMarker marker = null;
|
IMarker marker = null;
|
||||||
if (firstElement instanceof IAdaptable) {
|
if (firstElement instanceof IAdaptable) {
|
||||||
marker = (IMarker) ((IAdaptable) firstElement).getAdapter(IMarker.class);
|
marker = (IMarker) ((IAdaptable) firstElement)
|
||||||
|
.getAdapter(IMarker.class);
|
||||||
} else if (firstElement instanceof IMarker) {
|
} else if (firstElement instanceof IMarker) {
|
||||||
marker = (IMarker) firstElement;
|
marker = (IMarker) firstElement;
|
||||||
}
|
}
|
||||||
|
@ -130,8 +138,9 @@ public class ProblemDetails extends ViewPart {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void queryProviders(IMarker marker) {
|
private void queryProviders(IMarker marker) {
|
||||||
String id = marker.getAttribute(IMarker.PROBLEM, "id"); //$NON-NLS-1$
|
String id = marker.getAttribute(ICodanProblemMarker.ID, "id"); //$NON-NLS-1$
|
||||||
Collection<AbstractCodanProblemDetailsProvider> providers = ProblemDetailsExtensions.getProviders(id);
|
Collection<AbstractCodanProblemDetailsProvider> providers = ProblemDetailsExtensions
|
||||||
|
.getProviders(id);
|
||||||
for (AbstractCodanProblemDetailsProvider provider : providers) {
|
for (AbstractCodanProblemDetailsProvider provider : providers) {
|
||||||
synchronized (provider) {
|
synchronized (provider) {
|
||||||
provider.setMarker(marker);
|
provider.setMarker(marker);
|
||||||
|
@ -148,10 +157,12 @@ public class ProblemDetails extends ViewPart {
|
||||||
private void applyProvider(AbstractCodanProblemDetailsProvider provider) {
|
private void applyProvider(AbstractCodanProblemDetailsProvider provider) {
|
||||||
curProvider = provider;
|
curProvider = provider;
|
||||||
setTextSafe(message, provider, provider.getStyledProblemMessage());
|
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 {
|
try {
|
||||||
control.setText(text);
|
control.setText(text);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -163,6 +174,7 @@ public class ProblemDetails extends ViewPart {
|
||||||
/**
|
/**
|
||||||
* Passing the focus request to the area's control.
|
* Passing the focus request to the area's control.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setFocus() {
|
public void setFocus() {
|
||||||
message.setFocus();
|
message.setFocus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.cdt.codan.ui;
|
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.ICodanProblemMarker;
|
||||||
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.cdt.codan.internal.core.model.CodanProblemMarker;
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
|
@ -63,7 +64,7 @@ public abstract class AbstractCodanProblemDetailsProvider {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected String getProblemId() {
|
protected String getProblemId() {
|
||||||
String id = marker.getAttribute(IMarker.PROBLEM, (String) null);
|
String id = marker.getAttribute(ICodanProblemMarker.ID, (String) null);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue