mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Java 1.5-style loops, etc.
This commit is contained in:
parent
6322c0691d
commit
da28cc19fc
6 changed files with 50 additions and 106 deletions
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Gil Barash - Initial implementation
|
* Gil Barash - Initial implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.internal.checkers.ui.quickfix;
|
package org.eclipse.cdt.codan.internal.checkers.ui.quickfix;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ import org.eclipse.ltk.core.refactoring.Change;
|
||||||
public class CaseBreakQuickFixBreak extends AbstractAstRewriteQuickFix {
|
public class CaseBreakQuickFixBreak extends AbstractAstRewriteQuickFix {
|
||||||
@Override
|
@Override
|
||||||
public boolean isApplicable(IMarker marker) {
|
public boolean isApplicable(IMarker marker) {
|
||||||
int line = marker.getAttribute(IMarker.LINE_NUMBER, -1) - 1;
|
int line = marker.getAttribute(IMarker.LINE_NUMBER, 0) - 1;
|
||||||
if (line < 0)
|
if (line < 0)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -45,17 +45,18 @@ public class CaseBreakQuickFixBreak extends AbstractAstRewriteQuickFix {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTStatement getStmtBeforeBreak(IMarker marker, IASTTranslationUnit ast) throws BadLocationException {
|
protected IASTStatement getStmtBeforeBreak(IMarker marker, IASTTranslationUnit ast) throws BadLocationException {
|
||||||
int line = marker.getAttribute(IMarker.LINE_NUMBER, -1) - 1;
|
int line = marker.getAttribute(IMarker.LINE_NUMBER, 0) - 1;
|
||||||
if (line < 0)
|
if (line < 0)
|
||||||
return null;
|
return null;
|
||||||
IRegion lineInformation = getDocument().getLineInformation(line);
|
IRegion lineInformation = getDocument().getLineInformation(line);
|
||||||
IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
|
IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
|
||||||
IASTNode containedNode = nodeSelector.findFirstContainedNode(lineInformation.getOffset(), lineInformation.getLength());
|
IASTNode containedNode = nodeSelector.findFirstContainedNode(lineInformation.getOffset(), lineInformation.getLength());
|
||||||
IASTNode beforeBreakNode = null;
|
IASTNode beforeBreakNode = null;
|
||||||
if (containedNode != null)
|
if (containedNode != null) {
|
||||||
beforeBreakNode = CxxAstUtils.getEnclosingStatement(containedNode);
|
beforeBreakNode = CxxAstUtils.getEnclosingStatement(containedNode);
|
||||||
else
|
} else {
|
||||||
beforeBreakNode = nodeSelector.findEnclosingNode(lineInformation.getOffset(), lineInformation.getLength());
|
beforeBreakNode = nodeSelector.findEnclosingNode(lineInformation.getOffset(), lineInformation.getLength());
|
||||||
|
}
|
||||||
if (beforeBreakNode instanceof IASTCompoundStatement) {
|
if (beforeBreakNode instanceof IASTCompoundStatement) {
|
||||||
while (beforeBreakNode != null) {
|
while (beforeBreakNode != null) {
|
||||||
if (beforeBreakNode.getParent() instanceof IASTCompoundStatement
|
if (beforeBreakNode.getParent() instanceof IASTCompoundStatement
|
||||||
|
@ -79,7 +80,7 @@ public class CaseBreakQuickFixBreak extends AbstractAstRewriteQuickFix {
|
||||||
try {
|
try {
|
||||||
IASTTranslationUnit ast = getTranslationUnitViaEditor(marker).getAST(index, ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
|
IASTTranslationUnit ast = getTranslationUnitViaEditor(marker).getAST(index, ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
|
||||||
IASTStatement beforeBreak = getStmtBeforeBreak(marker, ast);
|
IASTStatement beforeBreak = getStmtBeforeBreak(marker, ast);
|
||||||
if (beforeBreak.getParent() instanceof IASTCompoundStatement) {
|
if (beforeBreak != null && beforeBreak.getParent() instanceof IASTCompoundStatement) {
|
||||||
IASTCompoundStatement enclosingStatement = (IASTCompoundStatement) beforeBreak.getParent();
|
IASTCompoundStatement enclosingStatement = (IASTCompoundStatement) beforeBreak.getParent();
|
||||||
IASTStatement after = getAfterStatement(beforeBreak);
|
IASTStatement after = getAfterStatement(beforeBreak);
|
||||||
ASTRewrite r = ASTRewrite.create(enclosingStatement.getTranslationUnit());
|
ASTRewrite r = ASTRewrite.create(enclosingStatement.getTranslationUnit());
|
||||||
|
|
|
@ -43,12 +43,9 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
||||||
public static final String PARAM_EMPTY_CASE = "empty_case_param"; //$NON-NLS-1$
|
public static final String PARAM_EMPTY_CASE = "empty_case_param"; //$NON-NLS-1$
|
||||||
public static final String PARAM_NO_BREAK_COMMENT = "no_break_comment"; //$NON-NLS-1$
|
public static final String PARAM_NO_BREAK_COMMENT = "no_break_comment"; //$NON-NLS-1$
|
||||||
public static final String DEFAULT_NO_BREAK_COMMENT = "no break"; //$NON-NLS-1$
|
public static final String DEFAULT_NO_BREAK_COMMENT = "no break"; //$NON-NLS-1$
|
||||||
private Boolean _checkLastCase; // Should we check the last case in the switch?
|
private boolean fCheckLastCase; // Should we check the last case in the switch?
|
||||||
private Boolean _checkEmptyCase; // Should we check an empty case (a case without any statements within it)
|
private boolean fCheckEmptyCase; // Should we check an empty case (a case without any statements within it)
|
||||||
private String _noBreakComment; // The comment suppressing this warning
|
private String fNoBreakComment; // The comment suppressing this warning
|
||||||
|
|
||||||
public CaseBreakChecker() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This visitor looks for "switch" statements and invokes "SwitchVisitor" on them.
|
* This visitor looks for "switch" statements and invokes "SwitchVisitor" on them.
|
||||||
|
@ -99,10 +96,10 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
||||||
// Next is case or end of switch - means this one is the last
|
// Next is case or end of switch - means this one is the last
|
||||||
if (prevCase != null && (isCaseStatement(next) || next == null)) {
|
if (prevCase != null && (isCaseStatement(next) || next == null)) {
|
||||||
// Check that current statement end with break or any other exit statement
|
// Check that current statement end with break or any other exit statement
|
||||||
if (!_checkEmptyCase && isCaseStatement(curr) && next != null) {
|
if (!fCheckEmptyCase && isCaseStatement(curr) && next != null) {
|
||||||
continue; // Empty case and we don't care
|
continue; // Empty case and we don't care
|
||||||
}
|
}
|
||||||
if (!_checkLastCase && next == null) {
|
if (!fCheckLastCase && next == null) {
|
||||||
continue; // Last case and we don't care
|
continue; // Last case and we don't care
|
||||||
}
|
}
|
||||||
if (!isProducedByMacroExpansion(prevCase) && isFallThroughStamement(curr)) {
|
if (!isProducedByMacroExpansion(prevCase) && isFallThroughStamement(curr)) {
|
||||||
|
@ -116,7 +113,7 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
||||||
}
|
}
|
||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
String str = getTrimmedComment(comment);
|
String str = getTrimmedComment(comment);
|
||||||
if (str.toLowerCase().contains(_noBreakComment.toLowerCase()))
|
if (str.toLowerCase().contains(fNoBreakComment.toLowerCase()))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
reportProblem(curr, prevCase);
|
reportProblem(curr, prevCase);
|
||||||
|
@ -162,7 +159,7 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reportProblem(IASTStatement curr, IASTStatement prevCase) {
|
private void reportProblem(IASTStatement curr, IASTStatement prevCase) {
|
||||||
reportProblem(ER_ID, getProblemLocationAtEndOfNode(curr));
|
reportProblem(ER_ID, getProblemLocationAtEndOfNode(curr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,9 +224,9 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processAst(IASTTranslationUnit ast) {
|
public void processAst(IASTTranslationUnit ast) {
|
||||||
_checkLastCase = (Boolean) getPreference(getProblemById(ER_ID, getFile()), PARAM_LAST_CASE);
|
fCheckLastCase = (Boolean) getPreference(getProblemById(ER_ID, getFile()), PARAM_LAST_CASE);
|
||||||
_checkEmptyCase = (Boolean) getPreference(getProblemById(ER_ID, getFile()), PARAM_EMPTY_CASE);
|
fCheckEmptyCase = (Boolean) getPreference(getProblemById(ER_ID, getFile()), PARAM_EMPTY_CASE);
|
||||||
_noBreakComment = (String) getPreference(getProblemById(ER_ID, getFile()), PARAM_NO_BREAK_COMMENT);
|
fNoBreakComment = (String) getPreference(getProblemById(ER_ID, getFile()), PARAM_NO_BREAK_COMMENT);
|
||||||
SwitchFindingVisitor visitor = new SwitchFindingVisitor();
|
SwitchFindingVisitor visitor = new SwitchFindingVisitor();
|
||||||
ast.accept(visitor);
|
ast.accept(visitor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems (Alena Laskavaia) - initial API and implementation
|
* QNX Software Systems (Alena Laskavaia) - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.core.model;
|
package org.eclipse.cdt.codan.core.model;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ public abstract class AbstractProblemReporter implements IProblemReporter {
|
||||||
IProblem problem = CheckersRegistry.getInstance().getResourceProfile(file).findProblem(id);
|
IProblem problem = CheckersRegistry.getInstance().getResourceProfile(file).findProblem(id);
|
||||||
if (problem == null)
|
if (problem == null)
|
||||||
throw new IllegalArgumentException("Id is not registered:" + id); //$NON-NLS-1$
|
throw new IllegalArgumentException("Id is not registered:" + id); //$NON-NLS-1$
|
||||||
if (problem.isEnabled() == false)
|
if (!problem.isEnabled())
|
||||||
return; // skip
|
return; // skip
|
||||||
ICodanProblemMarker codanProblemMarker = new CodanProblemMarker(problem, loc, args);
|
ICodanProblemMarker codanProblemMarker = new CodanProblemMarker(problem, loc, args);
|
||||||
reportProblem(codanProblemMarker);
|
reportProblem(codanProblemMarker);
|
||||||
|
|
|
@ -6,14 +6,13 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Alena Laskavaia - initial API and implementation
|
* Alena Laskavaia - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
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.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
||||||
import org.eclipse.cdt.codan.core.CodanRuntime;
|
import org.eclipse.cdt.codan.core.CodanRuntime;
|
||||||
|
@ -36,16 +35,15 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
/**
|
/**
|
||||||
* Problem reported that created eclipse markers
|
* Problem reported that created eclipse markers
|
||||||
*/
|
*/
|
||||||
public class CodanMarkerProblemReporter extends AbstractProblemReporter implements
|
public class CodanMarkerProblemReporter extends AbstractProblemReporter
|
||||||
IProblemReporterPersistent, IProblemReporterSessionPersistent {
|
implements IProblemReporterPersistent, IProblemReporterSessionPersistent {
|
||||||
private IResource resource;
|
private IResource resource;
|
||||||
private IChecker checker;
|
private IChecker checker;
|
||||||
private ArrayList<ICodanProblemMarker> toAdd = new ArrayList<ICodanProblemMarker>();
|
private ArrayList<ICodanProblemMarker> toAdd = new ArrayList<ICodanProblemMarker>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create instance, which can be use as factory for
|
* Create instance, which can be use as factory for
|
||||||
* IProblemReporterSessionPersistent or
|
* IProblemReporterSessionPersistent or as IProblemReporterPersistent.
|
||||||
* as IProblemReporterPersistent.
|
|
||||||
*/
|
*/
|
||||||
public CodanMarkerProblemReporter() {
|
public CodanMarkerProblemReporter() {
|
||||||
super();
|
super();
|
||||||
|
@ -117,9 +115,8 @@ public class CodanMarkerProblemReporter extends AbstractProblemReporter implemen
|
||||||
@Override
|
@Override
|
||||||
public void run(IProgressMonitor monitor) throws CoreException {
|
public void run(IProgressMonitor monitor) throws CoreException {
|
||||||
Collection<IMarker> markers = findResourceMarkers(file, checker);
|
Collection<IMarker> markers = findResourceMarkers(file, checker);
|
||||||
for (Iterator<IMarker> iterator = markers.iterator(); iterator.hasNext();) {
|
for (IMarker marker : markers) {
|
||||||
IMarker iMarker = iterator.next();
|
marker.delete();
|
||||||
iMarker.delete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, null, IWorkspace.AVOID_UPDATE, null);
|
}, null, IWorkspace.AVOID_UPDATE, null);
|
||||||
|
@ -146,9 +143,8 @@ public class CodanMarkerProblemReporter extends AbstractProblemReporter implemen
|
||||||
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(ICodanProblemMarker.ID, ""); //$NON-NLS-1$
|
String id = m.getAttribute(ICodanProblemMarker.ID, ""); //$NON-NLS-1$
|
||||||
for (Iterator<IProblem> iterator = problems.iterator(); iterator.hasNext();) {
|
for (IProblem problem : problems) {
|
||||||
IProblem iProblem = iterator.next();
|
if (problem.getId().equals(id)) {
|
||||||
if (iProblem.getId().equals(id)) {
|
|
||||||
res.add(m);
|
res.add(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,10 +172,11 @@ public class CodanMarkerProblemReporter extends AbstractProblemReporter implemen
|
||||||
@Override
|
@Override
|
||||||
public void done() {
|
public void done() {
|
||||||
if (checker != null) {
|
if (checker != null) {
|
||||||
if (toAdd.size() == 0)
|
if (toAdd.isEmpty()) {
|
||||||
deleteProblems(false);
|
deleteProblems(false);
|
||||||
else
|
} else {
|
||||||
reconcileMarkers();
|
reconcileMarkers();
|
||||||
|
}
|
||||||
toAdd.clear();
|
toAdd.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,8 +187,7 @@ public class CodanMarkerProblemReporter extends AbstractProblemReporter implemen
|
||||||
@Override
|
@Override
|
||||||
public void run(IProgressMonitor monitor) throws CoreException {
|
public void run(IProgressMonitor monitor) throws CoreException {
|
||||||
Collection<IMarker> markers = findResourceMarkers(resource, checker);
|
Collection<IMarker> markers = findResourceMarkers(resource, checker);
|
||||||
for (Iterator<IMarker> iterator = markers.iterator(); iterator.hasNext();) {
|
for (IMarker m : markers) {
|
||||||
IMarker m = iterator.next();
|
|
||||||
ICodanProblemMarker cm = similarMarker(m);
|
ICodanProblemMarker cm = similarMarker(m);
|
||||||
if (cm == null) {
|
if (cm == null) {
|
||||||
m.delete();
|
m.delete();
|
||||||
|
@ -200,8 +196,7 @@ public class CodanMarkerProblemReporter extends AbstractProblemReporter implemen
|
||||||
toAdd.remove(cm);
|
toAdd.remove(cm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Iterator<ICodanProblemMarker> iterator = toAdd.iterator(); iterator.hasNext();) {
|
for (ICodanProblemMarker cm : toAdd) {
|
||||||
ICodanProblemMarker cm = iterator.next();
|
|
||||||
cm.createMarker();
|
cm.createMarker();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,8 +239,7 @@ public class CodanMarkerProblemReporter extends AbstractProblemReporter implemen
|
||||||
protected ICodanProblemMarker similarMarker(IMarker m) {
|
protected ICodanProblemMarker similarMarker(IMarker m) {
|
||||||
ICodanProblemMarker mcm = CodanProblemMarker.createCodanProblemMarkerFromResourceMarker(m);
|
ICodanProblemMarker mcm = CodanProblemMarker.createCodanProblemMarkerFromResourceMarker(m);
|
||||||
ArrayList<ICodanProblemMarker> cand = new ArrayList<ICodanProblemMarker>();
|
ArrayList<ICodanProblemMarker> cand = new ArrayList<ICodanProblemMarker>();
|
||||||
for (Iterator<ICodanProblemMarker> iterator = toAdd.iterator(); iterator.hasNext();) {
|
for (ICodanProblemMarker cm : toAdd) {
|
||||||
ICodanProblemMarker cm = iterator.next();
|
|
||||||
if (mcm.equals(cm))
|
if (mcm.equals(cm))
|
||||||
return cm;
|
return cm;
|
||||||
if (markersAreSimilar(mcm, cm)) {
|
if (markersAreSimilar(mcm, cm)) {
|
||||||
|
@ -276,11 +270,6 @@ public class CodanMarkerProblemReporter extends AbstractProblemReporter implemen
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see IProblemReporterSessionPersistent#deleteProblems(boolean)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteProblems(boolean all) {
|
public void deleteProblems(boolean all) {
|
||||||
if (all)
|
if (all)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems (Alena Laskavaia) - initial API and implementation
|
* QNX Software Systems (Alena Laskavaia) - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.internal.core.model;
|
package org.eclipse.cdt.codan.internal.core.model;
|
||||||
|
|
||||||
|
@ -40,11 +40,6 @@ public class CodanProblemMarker implements ICodanProblemMarker {
|
||||||
private IProblem problem;
|
private IProblem problem;
|
||||||
private Object args[];
|
private Object args[];
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object[] getArgs() {
|
|
||||||
return args;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param problem
|
* @param problem
|
||||||
* @param loc
|
* @param loc
|
||||||
|
@ -56,41 +51,26 @@ public class CodanProblemMarker implements ICodanProblemMarker {
|
||||||
this.args = args;
|
this.args = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* (non-Javadoc)
|
public Object[] getArgs() {
|
||||||
*
|
return args;
|
||||||
* @see org.eclipse.cdt.codan.core.model.ICodanProblemMarker#getLocation()
|
}
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IProblemLocation getLocation() {
|
public IProblemLocation getLocation() {
|
||||||
return loc;
|
return loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.codan.core.model.ICodanProblemMarker#getProblem()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IProblem getProblem() {
|
public IProblem getProblem() {
|
||||||
return problem;
|
return problem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.codan.core.model.ICodanProblemMarker#getResource()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IResource getResource() {
|
public IResource getResource() {
|
||||||
return loc.getFile();
|
return loc.getFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.codan.core.model.ICodanProblemMarker#createMarker()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IMarker createMarker() throws CoreException {
|
public IMarker createMarker() throws CoreException {
|
||||||
IResource file = loc.getFile();
|
IResource file = loc.getFile();
|
||||||
|
@ -112,11 +92,6 @@ public class CodanProblemMarker implements ICodanProblemMarker {
|
||||||
return marker;
|
return marker;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.codan.core.model.ICodanProblemMarker#createMessage()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String createMessage() {
|
public String createMessage() {
|
||||||
String messagePattern = problem.getMessagePattern();
|
String messagePattern = problem.getMessagePattern();
|
||||||
|
@ -130,10 +105,6 @@ public class CodanProblemMarker implements ICodanProblemMarker {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param args2
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private static String serializeArgs(Object[] args) {
|
private static String serializeArgs(Object[] args) {
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
Properties prop = new Properties();
|
Properties prop = new Properties();
|
||||||
|
@ -155,7 +126,7 @@ public class CodanProblemMarker implements ICodanProblemMarker {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the argument of a problem that checker passed to "reportProblem"
|
* Returns the argument of a problem that checker passed to "reportProblem"
|
||||||
* method
|
* method
|
||||||
*
|
*
|
||||||
* @param marker - problem marker
|
* @param marker - problem marker
|
||||||
|
@ -169,7 +140,7 @@ public class CodanProblemMarker implements ICodanProblemMarker {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the arguments of a problem that checker passed to "reportProblem"
|
* Returns the arguments of a problem that checker passed to "reportProblem"
|
||||||
* method
|
* method
|
||||||
*
|
*
|
||||||
* @param marker - problem marker
|
* @param marker - problem marker
|
||||||
|
@ -194,7 +165,7 @@ public class CodanProblemMarker implements ICodanProblemMarker {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return problemId from marker
|
* Returns problemId from marker
|
||||||
*
|
*
|
||||||
* @param marker
|
* @param marker
|
||||||
* @return codan problemId
|
* @return codan problemId
|
||||||
|
@ -225,7 +196,7 @@ public class CodanProblemMarker implements ICodanProblemMarker {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to restore CodamProblemMaker from the resource marker
|
* Attempts to restore CodamProblemMaker from the resource marker
|
||||||
*
|
*
|
||||||
* @param marker
|
* @param marker
|
||||||
* @return new instanceof of ICodanProblemMarker or null if marker is not
|
* @return new instanceof of ICodanProblemMarker or null if marker is not
|
||||||
|
@ -239,10 +210,6 @@ public class CodanProblemMarker implements ICodanProblemMarker {
|
||||||
return new CodanProblemMarker(problem, loc, getProblemArguments(marker));
|
return new CodanProblemMarker(problem, loc, getProblemArguments(marker));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param marker
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static CodanProblem getProblem(IMarker marker) {
|
public static CodanProblem getProblem(IMarker marker) {
|
||||||
String id = getProblemId(marker);
|
String id = getProblemId(marker);
|
||||||
if (id == null)
|
if (id == null)
|
||||||
|
@ -255,10 +222,6 @@ public class CodanProblemMarker implements ICodanProblemMarker {
|
||||||
return problem;
|
return problem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param resource
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static IProblemProfile getProfile(IResource resource) {
|
public static IProblemProfile getProfile(IResource resource) {
|
||||||
IProblemProfile profile = CheckersRegistry.getInstance().getResourceProfile(resource);
|
IProblemProfile profile = CheckersRegistry.getInstance().getResourceProfile(resource);
|
||||||
return profile;
|
return profile;
|
||||||
|
@ -276,11 +239,6 @@ public class CodanProblemMarker implements ICodanProblemMarker {
|
||||||
return loc;
|
return loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param marker
|
|
||||||
* @param res
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
public static void setProblemArguments(IMarker marker, String[] args) throws CoreException {
|
public static void setProblemArguments(IMarker marker, String[] args) throws CoreException {
|
||||||
String propArgs = serializeArgs(args);
|
String propArgs = serializeArgs(args);
|
||||||
marker.setAttribute(PROBLEM_ARGS, propArgs);
|
marker.setAttribute(PROBLEM_ARGS, propArgs);
|
||||||
|
|
|
@ -241,7 +241,7 @@ class LocationCtxContainer extends LocationCtx {
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
return -idx;
|
return -idx;
|
||||||
}
|
}
|
||||||
return idx+1;
|
return idx + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] computeLineOffsets() {
|
private int[] computeLineOffsets() {
|
||||||
|
@ -255,7 +255,6 @@ class LocationCtxContainer extends LocationCtx {
|
||||||
int[] result= new int[offsets.size()];
|
int[] result= new int[offsets.size()];
|
||||||
for (int i = 0; i < result.length; i++) {
|
for (int i = 0; i < result.length; i++) {
|
||||||
result[i]= offsets.get(i).intValue();
|
result[i]= offsets.get(i).intValue();
|
||||||
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue