1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

added codan marker generator

its required for some cdt classes like console parsers

Change-Id: Ibde68774656a15c735dce08d5f3041dc56a7266f
Signed-off-by: Alena Laskavaia <elaskavaia.cdt@gmail.com>
This commit is contained in:
Alena Laskavaia 2015-03-04 15:09:41 -05:00 committed by Gerrit Code Review @ Eclipse.org
parent 6c8408c1d5
commit 82274d4060
4 changed files with 71 additions and 2 deletions

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.cdt.codan.core.cxx;singleton:=true
Bundle-Version: 3.2.0.qualifier
Bundle-Version: 3.3.0.qualifier
Bundle-Activator: org.eclipse.cdt.codan.core.cxx.Activator
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.cdt.core,
@ -12,6 +12,7 @@ Require-Bundle: org.eclipse.core.runtime,
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.cdt.codan.core.cxx,
org.eclipse.cdt.codan.core.cxx.externaltool,
org.eclipse.cdt.codan.core.cxx.internal.externaltool,
org.eclipse.cdt.codan.core.cxx.internal.model;x-friends:="org.eclipse.cdt.codan.checkers.ui,org.eclipse.cdt.codan.ui,org.eclipse.cdt.codan.ui.cxx",
org.eclipse.cdt.codan.core.cxx.internal.model.cfg;x-friends:="org.eclipse.cdt.codan.core.test",
org.eclipse.cdt.codan.core.cxx.model

View file

@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<version>3.2.0-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.codan.core.cxx</artifactId>
<packaging>eclipse-plugin</packaging>
</project>

View file

@ -0,0 +1,63 @@
/*******************************************************************************
* Copyright (c) 2015 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alena Laskavaia - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.core.cxx.model;
import org.eclipse.cdt.codan.core.CodanRuntime;
import org.eclipse.cdt.codan.core.model.IProblemLocation;
import org.eclipse.cdt.codan.core.model.IProblemLocationFactory;
import org.eclipse.cdt.codan.core.model.IProblemReporter;
import org.eclipse.cdt.codan.internal.core.model.CodanProblemLocation;
import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.core.ProblemMarkerInfo;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
/**
* Default implementation of IMarkerGenerator for API's that require such thing
*
* @since 3.3
*/
public class CodanMarkerGenerator implements IMarkerGenerator {
private final String problemId;
private final IProblemReporter reporter;
public CodanMarkerGenerator(String problemId) {
this.problemId = problemId;
this.reporter = CodanRuntime.getInstance().getProblemReporter();
}
public CodanMarkerGenerator(String problemId, IProblemReporter reporter) {
this.problemId = problemId;
this.reporter = reporter;
}
@Deprecated
public void addMarker(IResource file, int lineNumber, String description, int severity, String variableName) {
addMarker(new ProblemMarkerInfo(file, lineNumber, description, severity, variableName));
}
@Override
public void addMarker(ProblemMarkerInfo info) {
reporter.reportProblem(getProblemId(info.severity), createProblemLocation(info), info.description, info.variableName);
}
protected String getProblemId(int severity) {
return problemId;
}
protected IProblemLocation createProblemLocation(ProblemMarkerInfo info) {
IProblemLocationFactory factory = CodanRuntime.getInstance().getProblemLocationFactory();
if (info.file instanceof IFile)
return factory.createProblemLocation((IFile) info.file, info.startChar, info.endChar, info.lineNumber);
else
return new CodanProblemLocation(info.file, info.startChar, info.endChar, info.lineNumber);
}
}

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.codan.internal.core.model;
import org.eclipse.cdt.codan.core.model.IProblemLocation;
import org.eclipse.cdt.codan.core.model.IProblemLocationFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
/**
* Factory class that allows to create problem locations
@ -33,4 +34,8 @@ public class ProblemLocationFactory implements IProblemLocationFactory {
public IProblemLocation createProblemLocation(IFile file, int startChar, int endChar, int line) {
return new CodanProblemLocation(file, startChar, endChar, line);
}
public IProblemLocation createProblemLocation(IResource resource, int startChar, int endChar, int line) {
return new CodanProblemLocation(resource, startChar, endChar, line);
}
}