diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CheckersUiActivator.java b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CheckersUiActivator.java index 7a3d418e728..1c383142703 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CheckersUiActivator.java +++ b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CheckersUiActivator.java @@ -19,13 +19,11 @@ import org.osgi.framework.BundleContext; * The activator class controls the plug-in life cycle */ public class CheckersUiActivator extends AbstractUIPlugin { - // The plug-in ID public static final String PLUGIN_ID = "org.eclipse.cdt.codan.checkers.ui"; //$NON-NLS-1$ - // The shared instance private static CheckersUiActivator plugin; - + /** * The constructor */ @@ -34,7 +32,10 @@ public class CheckersUiActivator extends AbstractUIPlugin { /* * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + * + * @see + * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext + * ) */ public void start(BundleContext context) throws Exception { super.start(context); @@ -43,7 +44,10 @@ public class CheckersUiActivator extends AbstractUIPlugin { /* * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + * + * @see + * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext + * ) */ public void stop(BundleContext context) throws Exception { plugin = null; @@ -52,18 +56,18 @@ public class CheckersUiActivator extends AbstractUIPlugin { /** * Returns the shared instance - * + * * @return the shared instance */ public static CheckersUiActivator getDefault() { return plugin; } - + /** * Logs the specified status with this plug-in's log. * * @param status - * status to log + * status to log */ public static void log(IStatus status) { getDefault().getLog().log(status); @@ -73,7 +77,7 @@ public class CheckersUiActivator extends AbstractUIPlugin { * Logs an internal error with the specified throwable * * @param e - * the exception to be logged + * the exception to be logged */ public static void log(Throwable e) { log(new Status(IStatus.ERROR, PLUGIN_ID, 1, "Internal Error", e)); //$NON-NLS-1$ @@ -83,10 +87,9 @@ public class CheckersUiActivator extends AbstractUIPlugin { * Logs an internal error with the specified message. * * @param message - * the error message to log + * the error message to log */ public static void log(String message) { log(new Status(IStatus.ERROR, PLUGIN_ID, 1, message, null)); } - } diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/AbstractAstRewriteQuickFix.java b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/AbstractAstRewriteQuickFix.java index df811bc2500..171066fffce 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/AbstractAstRewriteQuickFix.java +++ b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/AbstractAstRewriteQuickFix.java @@ -23,9 +23,9 @@ import org.eclipse.jface.text.FindReplaceDocumentAdapter; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; -public abstract class AbstractAstRewriteQuickFix extends - AbstractCodanCMarkerResolution { +public abstract class AbstractAstRewriteQuickFix extends AbstractCodanCMarkerResolution { private IDocument document; + @Override public void apply(final IMarker marker, IDocument document) { try { @@ -69,7 +69,7 @@ public abstract class AbstractAstRewriteQuickFix extends public IDocument getDocument() { return document; } - + /** * @param marker * @param ast @@ -77,8 +77,7 @@ public abstract class AbstractAstRewriteQuickFix extends * @return * @throws BadLocationException */ - public IASTName getAstNameFromProblemArgument(IMarker marker, - IASTTranslationUnit ast, int argumentIndex) { + public IASTName getAstNameFromProblemArgument(IMarker marker, IASTTranslationUnit ast, int argumentIndex) { IASTName astName = null; int pos = getOffset(marker, getDocument()); String name = null; @@ -89,8 +88,7 @@ public abstract class AbstractAstRewriteQuickFix extends } if (name == null) return null; - FindReplaceDocumentAdapter dad = new FindReplaceDocumentAdapter( - getDocument()); + FindReplaceDocumentAdapter dad = new FindReplaceDocumentAdapter(getDocument()); IRegion region; try { region = dad.find(pos, name, @@ -99,8 +97,7 @@ public abstract class AbstractAstRewriteQuickFix extends } catch (BadLocationException e) { return null; } - astName = getASTNameFromPositions(ast, region.getOffset(), - region.getLength()); + astName = getASTNameFromPositions(ast, region.getOffset(), region.getLength()); return astName; } } diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByReferenceQuickFix.java b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByReferenceQuickFix.java index 96fd9846842..4c845aa1246 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByReferenceQuickFix.java +++ b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/CatchByReferenceQuickFix.java @@ -27,8 +27,7 @@ public class CatchByReferenceQuickFix extends AbstractCodanCMarkerResolution { } public void apply(IMarker marker, IDocument document) { - FindReplaceDocumentAdapter dad = new FindReplaceDocumentAdapter( - document); + FindReplaceDocumentAdapter dad = new FindReplaceDocumentAdapter(document); try { int pos = getOffset(marker, document); dad.find(pos, " ", /* forwardSearch *///$NON-NLS-1$ diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixAssignmentInCondition.java b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixAssignmentInCondition.java index 981f9ef705d..f076ec40fed 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixAssignmentInCondition.java +++ b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixAssignmentInCondition.java @@ -21,19 +21,16 @@ import org.eclipse.jface.text.IDocument; /** * quick fix for assignment in condition */ -public class QuickFixAssignmentInCondition extends - AbstractCodanCMarkerResolution { +public class QuickFixAssignmentInCondition extends AbstractCodanCMarkerResolution { public String getLabel() { return Messages.QuickFixAssignmentInCondition_Message; } - @Override public void apply(IMarker marker, IDocument document) { int pos = getOffset(marker, document); try { - FindReplaceDocumentAdapter dad = new FindReplaceDocumentAdapter( - document); + FindReplaceDocumentAdapter dad = new FindReplaceDocumentAdapter(document); dad.find(pos, "=", /* forwardSearch *///$NON-NLS-1$ true, /* caseSensitive */false, /* wholeWord */false, /* regExSearch */false); diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateField.java b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateField.java index 5c3a1e3f4f1..07372f06066 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateField.java +++ b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateField.java @@ -39,27 +39,22 @@ public class QuickFixCreateField extends AbstractAstRewriteQuickFix { public void modifyAST(IIndex index, IMarker marker) { CxxAstUtils utils = CxxAstUtils.getInstance(); try { - IASTTranslationUnit ast = getTranslationUnitViaEditor(marker) - .getAST(index, ITranslationUnit.AST_SKIP_INDEXED_HEADERS); + IASTTranslationUnit ast = getTranslationUnitViaEditor(marker).getAST(index, ITranslationUnit.AST_SKIP_INDEXED_HEADERS); IASTName astName = getASTNameFromMarker(marker, ast); if (astName == null) { return; } - IASTDeclaration declaration = utils - .createDeclaration(astName, ast.getASTNodeFactory(), index); - IASTCompositeTypeSpecifier targetCompositeType = utils - .getEnclosingCompositeTypeSpecifier(astName); + IASTDeclaration declaration = utils.createDeclaration(astName, ast.getASTNodeFactory(), index); + IASTCompositeTypeSpecifier targetCompositeType = utils.getEnclosingCompositeTypeSpecifier(astName); if (targetCompositeType == null) { // We're not in an inline method; // check if we're in a method at all - targetCompositeType = utils.getCompositeTypeFromFunction( - utils.getEnclosingFunction(astName), index); + targetCompositeType = utils.getCompositeTypeFromFunction(utils.getEnclosingFunction(astName), index); if (targetCompositeType == null) { return; } } - ASTRewrite r = ASTRewrite.create(targetCompositeType - .getTranslationUnit()); + ASTRewrite r = ASTRewrite.create(targetCompositeType.getTranslationUnit()); IASTNode where = findInsertionPlace(targetCompositeType); r.insertBefore(targetCompositeType, where, declaration, null); Change c = r.rewriteAST(); @@ -69,8 +64,6 @@ public class QuickFixCreateField extends AbstractAstRewriteQuickFix { } } - - /** * Suggests a default place to insert a field: * @@ -96,8 +89,7 @@ public class QuickFixCreateField extends AbstractAstRewriteQuickFix { // Get initial candidate at the beginning (after class name and // composite type specifiers) for (IASTNode child : children) { - if (child instanceof IASTName - || child instanceof ICPPASTBaseSpecifier) { + if (child instanceof IASTName || child instanceof ICPPASTBaseSpecifier) { continue; } bestMatch = child; @@ -109,21 +101,16 @@ public class QuickFixCreateField extends AbstractAstRewriteQuickFix { IASTNode child = children[i]; if (child instanceof ICPPASTVisibilityLabel) { ICPPASTVisibilityLabel label = (ICPPASTVisibilityLabel) child; - inDesiredAccessibilityContext = (wantPublicContext && label - .getVisibility() == ICPPASTVisibilityLabel.v_public) + inDesiredAccessibilityContext = (wantPublicContext && label.getVisibility() == ICPPASTVisibilityLabel.v_public) || (!wantPublicContext && label.getVisibility() == ICPPASTVisibilityLabel.v_private); - } else if (inDesiredAccessibilityContext - && (child instanceof IASTDeclaration) - && !(child instanceof IASTFunctionDefinition)) { + } else if (inDesiredAccessibilityContext && (child instanceof IASTDeclaration) && !(child instanceof IASTFunctionDefinition)) { // TODO: the above condition needs to also check if child is not // a typedef for (IASTNode gchild : child.getChildren()) { - if ((gchild instanceof IASTDeclarator) - && !(gchild instanceof IASTFunctionDeclarator)) { + if ((gchild instanceof IASTDeclarator) && !(gchild instanceof IASTFunctionDeclarator)) { // Before the next node or at the end (= after the // current node) - bestMatch = (i + 1 < children.length) ? children[i + 1] - : null; + bestMatch = (i + 1 < children.length) ? children[i + 1] : null; break; } } diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateLocalVariable.java b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateLocalVariable.java index 2d2f98a7a2b..0864abbed43 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateLocalVariable.java +++ b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateLocalVariable.java @@ -58,16 +58,13 @@ public class QuickFixCreateLocalVariable extends AbstractAstRewriteQuickFix { } ASTRewrite r = ASTRewrite.create(ast); INodeFactory factory = ast.getASTNodeFactory(); - IASTDeclaration declaration = utils.createDeclaration(astName, factory, - index); - IASTDeclarationStatement newStatement = factory - .newDeclarationStatement(declaration); + IASTDeclaration declaration = utils.createDeclaration(astName, factory, index); + IASTDeclarationStatement newStatement = factory.newDeclarationStatement(declaration); IASTNode targetStatement = utils.getEnclosingStatement(astName); if (targetStatement == null) { return; } - r.insertBefore(targetStatement.getParent(), targetStatement, - newStatement, null); + r.insertBefore(targetStatement.getParent(), targetStatement, newStatement, null); Change c = r.rewriteAST(); try { c.perform(new NullProgressMonitor()); diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateParameter.java b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateParameter.java index 2bd7ccac8a9..74149a0fb3e 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateParameter.java +++ b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixCreateParameter.java @@ -44,25 +44,19 @@ public class QuickFixCreateParameter extends AbstractAstRewriteQuickFix { @Override public void modifyAST(IIndex index, IMarker marker) { CxxAstUtils utils = CxxAstUtils.getInstance(); - CompositeChange c = new CompositeChange( - Messages.QuickFixCreateParameter_0); + CompositeChange c = new CompositeChange(Messages.QuickFixCreateParameter_0); try { ITranslationUnit baseTU = getTranslationUnitViaEditor(marker); - IASTTranslationUnit baseAST = baseTU.getAST(index, - ITranslationUnit.AST_SKIP_INDEXED_HEADERS); + IASTTranslationUnit baseAST = baseTU.getAST(index, ITranslationUnit.AST_SKIP_INDEXED_HEADERS); IASTName astName = getASTNameFromMarker(marker, baseAST); if (astName == null) { return; } - IASTDeclaration declaration = CxxAstUtils.getInstance() - .createDeclaration(astName, baseAST.getASTNodeFactory(), index); + IASTDeclaration declaration = CxxAstUtils.getInstance().createDeclaration(astName, baseAST.getASTNodeFactory(), index); // We'll need a FunctionParameterDeclaration later - final IASTDeclSpecifier finalDeclSpec = (IASTDeclSpecifier) declaration - .getChildren()[0]; - final IASTDeclarator finalDeclarator = (IASTDeclarator) declaration - .getChildren()[1]; - IASTFunctionDefinition function = utils - .getEnclosingFunction(astName); + final IASTDeclSpecifier finalDeclSpec = (IASTDeclSpecifier) declaration.getChildren()[0]; + final IASTDeclarator finalDeclarator = (IASTDeclarator) declaration.getChildren()[1]; + IASTFunctionDefinition function = utils.getEnclosingFunction(astName); if (function == null) { return; } @@ -71,21 +65,18 @@ public class QuickFixCreateParameter extends AbstractAstRewriteQuickFix { function.accept(nameFinderVisitor); IASTName funcName = nameFinderVisitor.name; IBinding binding = funcName.resolveBinding(); - IIndexName[] declarations = index.findNames(binding, - IIndex.FIND_DECLARATIONS_DEFINITIONS); + IIndexName[] declarations = index.findNames(binding, IIndex.FIND_DECLARATIONS_DEFINITIONS); if (declarations.length == 0) { return; } HashMap cachedASTs = new HashMap(); HashMap cachedRewrites = new HashMap(); for (IIndexName iname : declarations) { - ITranslationUnit declTU = utils - .getTranslationUnitFromIndexName(iname); + ITranslationUnit declTU = utils.getTranslationUnitFromIndexName(iname); ASTRewrite rewrite; IASTTranslationUnit declAST; if (!cachedASTs.containsKey(declTU)) { - declAST = declTU.getAST(index, - ITranslationUnit.AST_SKIP_INDEXED_HEADERS); + declAST = declTU.getAST(index, ITranslationUnit.AST_SKIP_INDEXED_HEADERS); rewrite = ASTRewrite.create(declAST); cachedASTs.put(declTU, declAST); cachedRewrites.put(declTU, rewrite); @@ -94,9 +85,8 @@ public class QuickFixCreateParameter extends AbstractAstRewriteQuickFix { rewrite = cachedRewrites.get(declTU); } IASTFileLocation fileLocation = iname.getFileLocation(); - IASTName declName = declAST.getNodeSelector(null) - .findEnclosingName(fileLocation.getNodeOffset(), - fileLocation.getNodeLength()); + IASTName declName = declAST.getNodeSelector(null).findEnclosingName(fileLocation.getNodeOffset(), + fileLocation.getNodeLength()); if (declName == null) { continue; } @@ -109,8 +99,7 @@ public class QuickFixCreateParameter extends AbstractAstRewriteQuickFix { } functionDecl = (IASTFunctionDeclarator) n; } - IASTParameterDeclaration newParam = factory - .newParameterDeclaration(finalDeclSpec, finalDeclarator); + IASTParameterDeclaration newParam = factory.newParameterDeclaration(finalDeclSpec, finalDeclarator); rewrite.insertBefore(functionDecl, null, newParam, null); } for (ASTRewrite rewrite : cachedRewrites.values()) { diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/SuggestedParenthesisQuickFix.java b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/SuggestedParenthesisQuickFix.java index c51c1f66538..73cad3d1913 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/SuggestedParenthesisQuickFix.java +++ b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/SuggestedParenthesisQuickFix.java @@ -17,8 +17,7 @@ import org.eclipse.core.resources.IMarker; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; -public class SuggestedParenthesisQuickFix extends - AbstractCodanCMarkerResolution { +public class SuggestedParenthesisQuickFix extends AbstractCodanCMarkerResolution { public String getLabel() { return Messages.SuggestedParenthesisQuickFix_Message; } @@ -39,7 +38,7 @@ public class SuggestedParenthesisQuickFix extends return; try { document.replace(charStart, 0, "("); //$NON-NLS-1$ - document.replace(charEnd+1, 0, ")"); //$NON-NLS-1$ + document.replace(charEnd + 1, 0, ")"); //$NON-NLS-1$ } catch (BadLocationException e) { CheckersUiActivator.log(e); } diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentInConditionChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentInConditionChecker.java index 2a60e140205..1693229363e 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentInConditionChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentInConditionChecker.java @@ -37,8 +37,7 @@ public class AssignmentInConditionChecker extends AbstractIndexAstChecker { } public int visit(IASTExpression expression) { - if (isAssignmentExpression(expression) - && isUsedAsCondition(expression)) { + if (isAssignmentExpression(expression) && isUsedAsCondition(expression)) { reportProblem(ER_ID, expression, expression.getRawSignature()); } return PROCESS_CONTINUE; @@ -54,16 +53,13 @@ public class AssignmentInConditionChecker extends AbstractIndexAstChecker { private boolean isUsedAsCondition(IASTExpression expression) { ASTNodeProperty prop = expression.getPropertyInParent(); - if (prop == IASTForStatement.CONDITION - || prop == IASTIfStatement.CONDITION - || prop == IASTWhileStatement.CONDITIONEXPRESSION + if (prop == IASTForStatement.CONDITION || prop == IASTIfStatement.CONDITION || prop == IASTWhileStatement.CONDITIONEXPRESSION || prop == IASTDoStatement.CONDITION) return true; if (prop == IASTUnaryExpression.OPERAND) { - IASTUnaryExpression expr = (IASTUnaryExpression) expression - .getParent(); - if (expr.getOperator() == IASTUnaryExpression.op_bracketedPrimary && - expr.getPropertyInParent() == IASTConditionalExpression.LOGICAL_CONDITION) { + IASTUnaryExpression expr = (IASTUnaryExpression) expression.getParent(); + if (expr.getOperator() == IASTUnaryExpression.op_bracketedPrimary + && expr.getPropertyInParent() == IASTConditionalExpression.LOGICAL_CONDITION) { return true; } } diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentToItselfChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentToItselfChecker.java index 09d1a330492..6b4d6f4d7ef 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentToItselfChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentToItselfChecker.java @@ -22,16 +22,15 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; * a[f()]=a[f()] - but who write codes like that? */ public class AssignmentToItselfChecker extends AbstractIndexAstChecker { - private static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem"; //$NON-NLS-1$ - + public void processAst(IASTTranslationUnit ast) { // traverse the ast using the visitor pattern. ast.accept(new ASTVisitor() { { // constructor shouldVisitExpressions = true; } - + // visit expressions public int visit(IASTExpression expression) { if (isAssignmentToItself(expression)) { @@ -39,7 +38,7 @@ public class AssignmentToItselfChecker extends AbstractIndexAstChecker { } return PROCESS_CONTINUE; } - + private boolean isAssignmentToItself(IASTExpression e) { if (e instanceof IASTBinaryExpression) { IASTBinaryExpression binExpr = (IASTBinaryExpression) e; @@ -48,8 +47,8 @@ public class AssignmentToItselfChecker extends AbstractIndexAstChecker { String op2 = binExpr.getOperand2().getRawSignature(); String expr = binExpr.getRawSignature(); return op1.equals(op2) - // when macro is used RawSignature returns macro name, see Bug 321933 - && !op1.equals(expr); + // when macro is used RawSignature returns macro name, see Bug 321933 + && !op1.equals(expr); } } return false; diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CaseBreakChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CaseBreakChecker.java index 5a00dbff76d..30dd5cd7b16 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CaseBreakChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CaseBreakChecker.java @@ -28,8 +28,7 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -public class CaseBreakChecker extends AbstractIndexAstChecker implements - ICheckerWithPreferences { +public class CaseBreakChecker extends AbstractIndexAstChecker implements ICheckerWithPreferences { public static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem"; //$NON-NLS-1$ public static final String PARAM_LAST_CASE = "last_case_param"; //$NON-NLS-1$ public static final String PARAM_EMPTY_CASE = "empty_case_param"; //$NON-NLS-1$ @@ -74,8 +73,7 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements * @return Is the next comment located after 'node' */ public boolean isNextAfterThis(IASTNode node) { - return (_comments[_next].getFileLocation().getNodeOffset() > node - .getFileLocation().getNodeOffset()); + return (_comments[_next].getFileLocation().getNodeOffset() > node.getFileLocation().getNodeOffset()); } /** @@ -83,8 +81,7 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements * @return Is the next comment located after 'node' ends */ public boolean isNextAfterThisEnds(IASTNode node) { - return (_comments[_next].getFileLocation().getNodeOffset() > node - .getFileLocation().getNodeOffset() + return (_comments[_next].getFileLocation().getNodeOffset() > node.getFileLocation().getNodeOffset() + node.getFileLocation().getNodeLength()); } @@ -112,8 +109,7 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements public int visit(IASTStatement statement) { if (statement instanceof IASTSwitchStatement) { // Are we already visiting this statement? - if (_switchStatement == null - || !statement.equals(_switchStatement)) { + if (_switchStatement == null || !statement.equals(_switchStatement)) { SwitchVisitor switch_visitor = new SwitchVisitor(statement); statement.accept(switch_visitor); return PROCESS_SKIP; @@ -157,8 +153,7 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements * @return Was a "break" statement the last statement in this case */ private boolean breakFoundPrevious() { - return _prev_normal_stmnt_offset < _prev_break_stmnt_offset - && _prev_case_stmnt_offset < _prev_break_stmnt_offset; + return _prev_normal_stmnt_offset < _prev_break_stmnt_offset && _prev_case_stmnt_offset < _prev_break_stmnt_offset; } /** @@ -198,8 +193,7 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements @Override public int visit(IASTStatement statement) { - if (statement instanceof IASTCaseStatement - || statement instanceof IASTDefaultStatement) { + if (statement instanceof IASTCaseStatement || statement instanceof IASTDefaultStatement) { if (_first_case_statement) { /* * This is the first "case", i.e. the beginning of the @@ -214,8 +208,7 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements */ IASTComment comment = null; // Do we have a comment which is before this "case" statement (but after the previous statement)? - while (_commentsIt.hasNext() - && !_commentsIt.isNextAfterThis(statement)) { + while (_commentsIt.hasNext() && !_commentsIt.isNextAfterThis(statement)) { comment = _commentsIt.getNext(); _commentsIt.advance(); } @@ -226,19 +219,15 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements checkPreviousCase(comment, false); } /* Update variables with the new opened "case" */ - _prev_case_stmnt_offset = statement.getFileLocation() - .getNodeOffset(); + _prev_case_stmnt_offset = statement.getFileLocation().getNodeOffset(); _prev_case_stmnt = statement; } else if (isBreakOrExitStatement(statement)) { // A "break" statement - _prev_break_stmnt_offset = statement.getFileLocation() - .getNodeOffset(); + _prev_break_stmnt_offset = statement.getFileLocation().getNodeOffset(); } else { // a non-switch related statement - _prev_normal_stmnt_offset = statement.getFileLocation() - .getNodeOffset(); + _prev_normal_stmnt_offset = statement.getFileLocation().getNodeOffset(); } /* advance comments we already passed */ - while (_commentsIt.hasNext() - && !_commentsIt.isNextAfterThis(statement)) + while (_commentsIt.hasNext() && !_commentsIt.isNextAfterThis(statement)) _commentsIt.advance(); return super.visit(statement); // This would handle nested "switch"s } @@ -249,12 +238,10 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements * Are we leaving the "switch" altogether? (we need to see how the * last "case" ended) */ - if (_checkLastCase && statement instanceof IASTCompoundStatement - && statement.getParent() == _switchStatement) { + if (_checkLastCase && statement instanceof IASTCompoundStatement && statement.getParent() == _switchStatement) { IASTComment comment = null; // is "Next" still in the switch's scope? if it is it was after the last statement - while (_commentsIt.hasNext() - && !_commentsIt.isNextAfterThisEnds(statement)) { + while (_commentsIt.hasNext() && !_commentsIt.isNextAfterThisEnds(statement)) { comment = _commentsIt.getNext(); _commentsIt.advance(); } @@ -280,36 +267,23 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements */ public boolean isBreakOrExitStatement(IASTStatement statement) { CxxAstUtils utils = CxxAstUtils.getInstance(); - return statement instanceof IASTBreakStatement - || statement instanceof IASTReturnStatement - || statement instanceof IASTContinueStatement - || statement instanceof IASTGotoStatement + return statement instanceof IASTBreakStatement || statement instanceof IASTReturnStatement + || statement instanceof IASTContinueStatement || statement instanceof IASTGotoStatement || utils.isThrowStatement(statement) || utils.isExitStatement(statement); } public void initPreferences(IProblemWorkingCopy problem) { super.initPreferences(problem); - addPreference( - problem, - PARAM_NO_BREAK_COMMENT, - CheckersMessages.CaseBreakChecker_DefaultNoBreakCommentDescription, + addPreference(problem, PARAM_NO_BREAK_COMMENT, CheckersMessages.CaseBreakChecker_DefaultNoBreakCommentDescription, DEFAULT_NO_BREAK_COMMENT); - addPreference(problem, PARAM_LAST_CASE, - CheckersMessages.CaseBreakChecker_LastCaseDescription, - Boolean.TRUE); - addPreference(problem, PARAM_EMPTY_CASE, - CheckersMessages.CaseBreakChecker_EmptyCaseDescription, - Boolean.FALSE); - + addPreference(problem, PARAM_LAST_CASE, CheckersMessages.CaseBreakChecker_LastCaseDescription, Boolean.TRUE); + addPreference(problem, PARAM_EMPTY_CASE, CheckersMessages.CaseBreakChecker_EmptyCaseDescription, Boolean.FALSE); } public void processAst(IASTTranslationUnit ast) { - _checkLastCase = (Boolean) getPreference( - getProblemById(ER_ID, getFile()), PARAM_LAST_CASE); - _checkEmptyCase = (Boolean) getPreference( - getProblemById(ER_ID, getFile()), PARAM_EMPTY_CASE); - _noBreakComment = (String) getPreference( - getProblemById(ER_ID, getFile()), PARAM_NO_BREAK_COMMENT); + _checkLastCase = (Boolean) getPreference(getProblemById(ER_ID, getFile()), PARAM_LAST_CASE); + _checkEmptyCase = (Boolean) getPreference(getProblemById(ER_ID, getFile()), PARAM_EMPTY_CASE); + _noBreakComment = (String) getPreference(getProblemById(ER_ID, getFile()), PARAM_NO_BREAK_COMMENT); SwitchFindingVisitor visitor = new SwitchFindingVisitor(); _commentsIt = new CommentsIterator(ast.getComments()); ast.accept(visitor); diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CatchByReference.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CatchByReference.java index 540db47122b..3373f76a2cb 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CatchByReference.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CatchByReference.java @@ -59,8 +59,7 @@ public class CatchByReference extends AbstractIndexAstChecker { if (stmt instanceof ICPPASTTryBlockStatement) { try { ICPPASTTryBlockStatement tblock = (ICPPASTTryBlockStatement) stmt; - ICPPASTCatchHandler[] catchHandlers = tblock - .getCatchHandlers(); + ICPPASTCatchHandler[] catchHandlers = tblock.getCatchHandlers(); for (int i = 0; i < catchHandlers.length; i++) { ICPPASTCatchHandler catchHandler = catchHandlers[i]; IASTDeclaration decl = catchHandler.getDeclaration(); @@ -69,15 +68,10 @@ public class CatchByReference extends AbstractIndexAstChecker { IASTDeclSpecifier spec = sdecl.getDeclSpecifier(); if (!usesReference(catchHandler)) { if (spec instanceof IASTNamedTypeSpecifier) { - IASTName tname = ((IASTNamedTypeSpecifier) spec) - .getName(); - IType typeName = (IType) tname - .resolveBinding(); - typeName = CxxAstUtils.getInstance() - .unwindTypedef(typeName); - if (typeName instanceof IBasicType - || typeName instanceof IPointerType - || typeName == null) + IASTName tname = ((IASTNamedTypeSpecifier) spec).getName(); + IType typeName = (IType) tname.resolveBinding(); + typeName = CxxAstUtils.getInstance().unwindTypedef(typeName); + if (typeName instanceof IBasicType || typeName instanceof IPointerType || typeName == null) continue; if (typeName instanceof IProblemBinding && !shouldReportForUnknownType()) continue; @@ -106,12 +100,10 @@ public class CatchByReference extends AbstractIndexAstChecker { private boolean usesReference(ICPPASTCatchHandler catchHandler) { IASTDeclaration declaration = catchHandler.getDeclaration(); if (declaration instanceof IASTSimpleDeclaration) { - IASTDeclarator[] declarators = ((IASTSimpleDeclaration) declaration) - .getDeclarators(); + IASTDeclarator[] declarators = ((IASTSimpleDeclaration) declaration).getDeclarators(); for (int i = 0; i < declarators.length; i++) { IASTDeclarator d = declarators[i]; - IASTPointerOperator[] pointerOperators = d - .getPointerOperators(); + IASTPointerOperator[] pointerOperators = d.getPointerOperators(); for (int j = 0; j < pointerOperators.length; j++) { IASTPointerOperator po = pointerOperators[j]; if (po instanceof ICPPASTReferenceOperator) { @@ -130,16 +122,13 @@ public class CatchByReference extends AbstractIndexAstChecker { @Override public void initPreferences(IProblemWorkingCopy problem) { super.initPreferences(problem); - addPreference(problem, PARAM_UNKNOWN_TYPE, - CheckersMessages.CatchByReference_ReportForUnknownType, Boolean.FALSE); - addListPreference(problem, PARAM_EXCEPT_ARG_LIST, - CheckersMessages.GenericParameter_ParameterExceptions, + addPreference(problem, PARAM_UNKNOWN_TYPE, CheckersMessages.CatchByReference_ReportForUnknownType, Boolean.FALSE); + addListPreference(problem, PARAM_EXCEPT_ARG_LIST, CheckersMessages.GenericParameter_ParameterExceptions, CheckersMessages.GenericParameter_ParameterExceptionsItem); } public boolean isFilteredArg(String arg) { - Object[] arr = (Object[]) getPreference( - getProblemById(ER_ID, getFile()), PARAM_EXCEPT_ARG_LIST); + Object[] arr = (Object[]) getPreference(getProblemById(ER_ID, getFile()), PARAM_EXCEPT_ARG_LIST); for (int i = 0; i < arr.length; i++) { String str = (String) arr[i]; if (arg.equals(str)) @@ -152,7 +141,6 @@ public class CatchByReference extends AbstractIndexAstChecker { * @return */ public boolean shouldReportForUnknownType() { - return (Boolean) getPreference(getProblemById(ER_ID, getFile()), - PARAM_UNKNOWN_TYPE); + return (Boolean) getPreference(getProblemById(ER_ID, getFile()), PARAM_UNKNOWN_TYPE); } } diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CheckersMessages.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CheckersMessages.java index 1990b4f024c..86cd9f2da55 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CheckersMessages.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/CheckersMessages.java @@ -28,9 +28,7 @@ public class CheckersMessages extends NLS { public static String StatementHasNoEffectChecker_ParameterMacro; public static String SuggestedParenthesisChecker_SuggestParanthesesAroundNot; public static String SuspiciousSemicolonChecker_ParamElse; - public static String ProblemBindingChecker_Candidates; - static { // initialize resource bundle NLS.initializeMessages(BUNDLE_NAME, CheckersMessages.class); diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/NamingConventionFunctionChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/NamingConventionFunctionChecker.java index 7e4c21a4a03..166115bdc49 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/NamingConventionFunctionChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/NamingConventionFunctionChecker.java @@ -28,13 +28,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; * regular expression defining the style. * */ -public class NamingConventionFunctionChecker extends AbstractIndexAstChecker - implements ICheckerWithPreferences { +public class NamingConventionFunctionChecker extends AbstractIndexAstChecker implements ICheckerWithPreferences { private static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker"; //$NON-NLS-1$ public static final String PARAM_KEY = "pattern"; //$NON-NLS-1$ public static final String PARAM_METHODS = "macro"; //$NON-NLS-1$ public static final String PARAM_EXCEPT_ARG_LIST = "exceptions"; //$NON-NLS-1$ - + public void processAst(IASTTranslationUnit ast) { final IProblem pt = getProblemById(ER_ID, getFile()); try { @@ -47,8 +46,7 @@ public class NamingConventionFunctionChecker extends AbstractIndexAstChecker if (element instanceof IASTFunctionDefinition) { String parameter = (String) getPreference(pt, PARAM_KEY); Pattern pattern = Pattern.compile(parameter); - IASTName astName = ((IASTFunctionDefinition) element) - .getDeclarator().getName(); + IASTName astName = ((IASTFunctionDefinition) element).getDeclarator().getName(); String name = astName.toString(); if (astName instanceof ICPPASTQualifiedName) { if (!shouldReportCppMethods()) @@ -59,10 +57,9 @@ public class NamingConventionFunctionChecker extends AbstractIndexAstChecker name = cppAstName.getLastName().toString(); if (name.startsWith("~")) // destructor //$NON-NLS-1$ return PROCESS_SKIP; - IASTName[] names = cppAstName.getNames(); - if (names.length>=2) { - if (names[names.length-1].toString().equals(names[names.length-2].toString())) { + if (names.length >= 2) { + if (names[names.length - 1].toString().equals(names[names.length - 2].toString())) { // constructor return PROCESS_SKIP; } @@ -89,29 +86,19 @@ public class NamingConventionFunctionChecker extends AbstractIndexAstChecker */ public void initPreferences(IProblemWorkingCopy problem) { super.initPreferences(problem); - addPreference( - problem, - PARAM_KEY, - CheckersMessages.NamingConventionFunctionChecker_LabelNamePattern, - "^[a-z]"); //$NON-NLS-1$ - addPreference(problem, PARAM_METHODS, - "Also check C++ method names", - Boolean.TRUE); - addListPreference( - problem, - PARAM_EXCEPT_ARG_LIST, - CheckersMessages.GenericParameter_ParameterExceptions, + addPreference(problem, PARAM_KEY, CheckersMessages.NamingConventionFunctionChecker_LabelNamePattern, "^[a-z]"); //$NON-NLS-1$ + addPreference(problem, PARAM_METHODS, "Also check C++ method names", Boolean.TRUE); + addListPreference(problem, PARAM_EXCEPT_ARG_LIST, CheckersMessages.GenericParameter_ParameterExceptions, CheckersMessages.GenericParameter_ParameterExceptionsItem); } + public boolean shouldReportCppMethods() { - return (Boolean) getPreference(getProblemById(ER_ID, getFile()), - PARAM_METHODS); - } - public boolean isFilteredArg(String arg) { - return isFilteredArg(arg, getProblemById(ER_ID, getFile()), - PARAM_EXCEPT_ARG_LIST); + return (Boolean) getPreference(getProblemById(ER_ID, getFile()), PARAM_METHODS); } + public boolean isFilteredArg(String arg) { + return isFilteredArg(arg, getProblemById(ER_ID, getFile()), PARAM_EXCEPT_ARG_LIST); + } @Override public boolean runInEditor() { diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/NonVirtualDestructor.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/NonVirtualDestructor.java index c4bdbad66c8..1ba7ffc7559 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/NonVirtualDestructor.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/NonVirtualDestructor.java @@ -60,7 +60,7 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker { if (destructorName instanceof ICPPInternalBinding) { ICPPInternalBinding bin = (ICPPInternalBinding) destructorName; IASTNode[] decls = bin.getDeclarations(); - if (decls!=null && decls.length>0) + if (decls != null && decls.length > 0) ast = decls[0]; } reportProblem(ER_ID, ast, clazz, method, destructorName.getName()); @@ -80,8 +80,7 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker { * @param decl * @throws DOMException */ - private boolean hasErrorCondition(IASTDeclSpecifier decl) - throws DOMException { + private boolean hasErrorCondition(IASTDeclSpecifier decl) throws DOMException { ICPPASTCompositeTypeSpecifier spec = (ICPPASTCompositeTypeSpecifier) decl; className = spec.getName(); IBinding binding = className.getBinding(); @@ -123,8 +122,7 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker { // class does not have virtual methods but has virtual // destructor // - not an error - if (hasOwnVirtualMethod == false && hasDestructor == true - && hasOwnNonVirDestructor == false) { + if (hasOwnVirtualMethod == false && hasDestructor == true && hasOwnNonVirDestructor == false) { return false; } ICPPMethod[] allDeclaredMethods = type.getAllDeclaredMethods(); diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ProblemBindingChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ProblemBindingChecker.java index 28f3a9478d4..94f6219d11a 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ProblemBindingChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ProblemBindingChecker.java @@ -73,77 +73,56 @@ public class ProblemBindingChecker extends AbstractIndexAstChecker { IASTNode parentNode = name.getParent(); // Don't report multiple problems with qualified names if (parentNode instanceof ICPPASTQualifiedName) { - if (((ICPPASTQualifiedName) parentNode) - .resolveBinding() instanceof IProblemBinding) + if (((ICPPASTQualifiedName) parentNode).resolveBinding() instanceof IProblemBinding) return PROCESS_CONTINUE; } String contextFlagsString = createContextFlagsString(name); IProblemBinding problemBinding = (IProblemBinding) binding; int id = problemBinding.getID(); if (id == IProblemBinding.SEMANTIC_INVALID_OVERLOAD) { - reportProblem(ERR_ID_OverloadProblem, name, - name.getRawSignature(), - contextFlagsString); + reportProblem(ERR_ID_OverloadProblem, name, name.getRawSignature(), contextFlagsString); return PROCESS_CONTINUE; } if (id == IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP) { String candidatesString = getCandidatesString(problemBinding); - reportProblem(ERR_ID_AmbiguousProblem, name, - name.getRawSignature(), - candidatesString, contextFlagsString); + reportProblem(ERR_ID_AmbiguousProblem, name, name.getRawSignature(), candidatesString, contextFlagsString); return PROCESS_CONTINUE; } if (id == IProblemBinding.SEMANTIC_CIRCULAR_INHERITANCE) { String typeString; IASTNode problemNode; if (parentNode instanceof IASTFieldReference) { - IASTExpression ownerExpression = ((IASTFieldReference) parentNode) - .getFieldOwner(); - typeString = ASTTypeUtil - .getType(ownerExpression - .getExpressionType()); + IASTExpression ownerExpression = ((IASTFieldReference) parentNode).getFieldOwner(); + typeString = ASTTypeUtil.getType(ownerExpression.getExpressionType()); problemNode = ownerExpression; } else { problemNode = name; typeString = name.getRawSignature(); } - reportProblem(ERR_ID_CircularReferenceProblem, - problemNode, typeString, - contextFlagsString); + reportProblem(ERR_ID_CircularReferenceProblem, problemNode, typeString, contextFlagsString); return PROCESS_CONTINUE; } if (id == IProblemBinding.SEMANTIC_INVALID_REDECLARATION) { - reportProblem(ERR_ID_RedeclarationProblem, - name, name.getRawSignature(), - contextFlagsString); + reportProblem(ERR_ID_RedeclarationProblem, name, name.getRawSignature(), contextFlagsString); return PROCESS_CONTINUE; } if (id == IProblemBinding.SEMANTIC_INVALID_REDEFINITION) { - reportProblem(ERR_ID_RedefinitionProblem, name, - name.getRawSignature(), - contextFlagsString); + reportProblem(ERR_ID_RedefinitionProblem, name, name.getRawSignature(), contextFlagsString); return PROCESS_CONTINUE; } if (id == IProblemBinding.SEMANTIC_MEMBER_DECLARATION_NOT_FOUND) { - reportProblem( - ERR_ID_MemberDeclarationNotFoundProblem, - name, contextFlagsString); + reportProblem(ERR_ID_MemberDeclarationNotFoundProblem, name, contextFlagsString); return PROCESS_CONTINUE; } if (id == IProblemBinding.SEMANTIC_LABEL_STATEMENT_NOT_FOUND) { - reportProblem( - ERR_ID_LabelStatementNotFoundProblem, - name, name.getRawSignature(), - contextFlagsString); + reportProblem(ERR_ID_LabelStatementNotFoundProblem, name, name.getRawSignature(), contextFlagsString); return PROCESS_CONTINUE; } if (id == IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS) { // We use the templateName since we don't want the whole // argument list to be underlined. That way we can see which argument is invalid. IASTNode templateName = getTemplateName(name); - reportProblem( - ERR_ID_InvalidTemplateArgumentsProblem, - templateName, contextFlagsString); + reportProblem(ERR_ID_InvalidTemplateArgumentsProblem, templateName, contextFlagsString); return PROCESS_CONTINUE; } // From this point, we'll deal only with NAME_NOT_FOUND problems. @@ -152,15 +131,11 @@ public class ProblemBindingChecker extends AbstractIndexAstChecker { return PROCESS_CONTINUE; } if (isFunctionCall(parentNode)) { - handleFunctionProblem(name, problemBinding, - contextFlagsString); + handleFunctionProblem(name, problemBinding, contextFlagsString); } else if (parentNode instanceof IASTFieldReference) { - handleMemberProblem(name, parentNode, - problemBinding, contextFlagsString); + handleMemberProblem(name, parentNode, problemBinding, contextFlagsString); } else if (parentNode instanceof IASTNamedTypeSpecifier) { - reportProblem(ERR_ID_TypeResolutionProblem, - name, name.getRawSignature(), - contextFlagsString); + reportProblem(ERR_ID_TypeResolutionProblem, name, name.getRawSignature(), contextFlagsString); } // Probably a variable else { @@ -199,8 +174,7 @@ public class ProblemBindingChecker extends AbstractIndexAstChecker { return false; } @SuppressWarnings("restriction") - IASTDeclarator innermostDeclarator = ASTQueries - .findInnermostDeclarator(function.getDeclarator()); + IASTDeclarator innermostDeclarator = ASTQueries.findInnermostDeclarator(function.getDeclarator()); IBinding binding = innermostDeclarator.getName().resolveBinding(); return (binding instanceof ICPPMethod); } @@ -211,42 +185,32 @@ public class ProblemBindingChecker extends AbstractIndexAstChecker { return (function != null); } - private void handleFunctionProblem(IASTName name, - IProblemBinding problemBinding, String contextFlagsString) - throws DOMException { + private void handleFunctionProblem(IASTName name, IProblemBinding problemBinding, String contextFlagsString) throws DOMException { if (problemBinding.getCandidateBindings().length == 0) { - reportProblem(ERR_ID_FunctionResolutionProblem, name.getLastName(), - name.getRawSignature(), contextFlagsString); + reportProblem(ERR_ID_FunctionResolutionProblem, name.getLastName(), name.getRawSignature(), contextFlagsString); } else { String candidatesString = getCandidatesString(problemBinding); - reportProblem(ERR_ID_InvalidArguments, name.getLastName(), - candidatesString, contextFlagsString); + reportProblem(ERR_ID_InvalidArguments, name.getLastName(), candidatesString, contextFlagsString); } } - private void handleMemberProblem(IASTName name, IASTNode parentNode, - IProblemBinding problemBinding, String contextFlagsString) + private void handleMemberProblem(IASTName name, IASTNode parentNode, IProblemBinding problemBinding, String contextFlagsString) throws DOMException { IASTNode parentParentNode = parentNode.getParent(); if (parentParentNode instanceof IASTFunctionCallExpression) { if (problemBinding.getCandidateBindings().length == 0) { - reportProblem(ERR_ID_MethodResolutionProblem, - name.getLastName(), name.getRawSignature(), - contextFlagsString); + reportProblem(ERR_ID_MethodResolutionProblem, name.getLastName(), name.getRawSignature(), contextFlagsString); } else { String candidatesString = getCandidatesString(problemBinding); - reportProblem(ERR_ID_InvalidArguments, name.getLastName(), - candidatesString, contextFlagsString); + reportProblem(ERR_ID_InvalidArguments, name.getLastName(), candidatesString, contextFlagsString); } } else { - reportProblem(ERR_ID_FieldResolutionProblem, name.getLastName(), - name.getRawSignature(), contextFlagsString); + reportProblem(ERR_ID_FieldResolutionProblem, name.getLastName(), name.getRawSignature(), contextFlagsString); } } private void handleVariableProblem(IASTName name, String contextFlagsString) { - reportProblem(ERR_ID_VariableResolutionProblem, name, - name.getRawSignature(), contextFlagsString); + reportProblem(ERR_ID_VariableResolutionProblem, name, name.getRawSignature(), contextFlagsString); } private boolean isFunctionCall(IASTNode parentNode) { @@ -254,11 +218,7 @@ public class ProblemBindingChecker extends AbstractIndexAstChecker { IASTIdExpression expression = (IASTIdExpression) parentNode; IASTNode parentParentNode = expression.getParent(); if (parentParentNode instanceof IASTFunctionCallExpression - && expression - .getPropertyInParent() - .getName() - .equals(IASTFunctionCallExpression.FUNCTION_NAME - .getName())) { + && expression.getPropertyInParent().getName().equals(IASTFunctionCallExpression.FUNCTION_NAME.getName())) { return true; } } @@ -280,8 +240,7 @@ public class ProblemBindingChecker extends AbstractIndexAstChecker { * @return A string of the candidates, one per line * @throws DOMException */ - private String getCandidatesString(IProblemBinding problemBinding) - throws DOMException { + private String getCandidatesString(IProblemBinding problemBinding) throws DOMException { String candidatesString = "\n" + CheckersMessages.ProblemBindingChecker_Candidates + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ String lastSignature = ""; //$NON-NLS-1$ for (IBinding candidateBinding : problemBinding.getCandidateBindings()) { @@ -314,14 +273,11 @@ public class ProblemBindingChecker extends AbstractIndexAstChecker { * @return A string of the function signature * @throws DOMException */ - private String getFunctionSignature(ICPPFunction functionBinding) - throws DOMException { + private String getFunctionSignature(ICPPFunction functionBinding) throws DOMException { IFunctionType functionType = functionBinding.getType(); - String returnTypeString = ASTTypeUtil.getType(functionBinding.getType() - .getReturnType()) + " "; //$NON-NLS-1$ + String returnTypeString = ASTTypeUtil.getType(functionBinding.getType().getReturnType()) + " "; //$NON-NLS-1$ String functionName = functionBinding.getName(); - String parameterTypeString = ASTTypeUtil - .getParameterTypeString(functionType); + String parameterTypeString = ASTTypeUtil.getParameterTypeString(functionType); return returnTypeString + functionName + parameterTypeString; } } diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java index 2a4d5626a10..351e1dbab69 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java @@ -48,7 +48,7 @@ import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression; *
  • Function declared as returning non-void has no return (requires control * flow graph) */ -public class ReturnChecker extends AbstractAstFunctionChecker { +public class ReturnChecker extends AbstractAstFunctionChecker { public static final String PARAM_IMPLICIT = "implicit"; //$NON-NLS-1$ public static final String RET_NO_VALUE_ID = "org.eclipse.cdt.codan.checkers.noreturn"; //$NON-NLS-1$ public static final String RET_ERR_VALUE_ID = "org.eclipse.cdt.codan.checkers.errreturnvalue"; //$NON-NLS-1$ @@ -64,31 +64,30 @@ public class ReturnChecker extends AbstractAstFunctionChecker { this.func = func; this.hasret = false; } + public int visit(IASTDeclaration element) { - if (element!=func) - return PROCESS_SKIP; // skip inner functions + if (element != func) + return PROCESS_SKIP; // skip inner functions return PROCESS_CONTINUE; } + public int visit(IASTStatement stmt) { if (stmt instanceof IASTReturnStatement) { hasret = true; IASTReturnStatement ret = (IASTReturnStatement) stmt; if (!isVoid(func) && !isConstructorDestructor()) { - if (checkImplicitReturn(RET_NO_VALUE_ID) - || isExplicitReturn(func)) { - + if (checkImplicitReturn(RET_NO_VALUE_ID) || isExplicitReturn(func)) { if (ret.getReturnValue() == null) reportProblem(RET_NO_VALUE_ID, ret); } } else { if (ret.getReturnValue() != null) { IType type = ret.getReturnValue().getExpressionType(); - if (isVoid(type)) + if (isVoid(type)) return PROCESS_SKIP; reportProblem(RET_ERR_VALUE_ID, ret.getReturnValue()); } } - return PROCESS_SKIP; } if (stmt instanceof IASTExpressionStatement) { @@ -101,20 +100,20 @@ public class ReturnChecker extends AbstractAstFunctionChecker { } return PROCESS_CONTINUE; } + /** - * @return + * @return * */ public boolean isConstructorDestructor() { if (func instanceof ICPPASTFunctionDefinition) { IBinding method = func.getDeclarator().getName().resolveBinding(); - if (method instanceof ICPPConstructor || method instanceof ICPPMethod && ((ICPPMethod)method).isDestructor()) { + if (method instanceof ICPPConstructor || method instanceof ICPPMethod && ((ICPPMethod) method).isDestructor()) { return true; } } return false; } - } /* @@ -129,8 +128,7 @@ public class ReturnChecker extends AbstractAstFunctionChecker { func.accept(visitor); if (!visitor.hasret) { // no return at all - if (!isVoid(func) - && (checkImplicitReturn(RET_NORET_ID) || isExplicitReturn(func))) { + if (!isVoid(func) && (checkImplicitReturn(RET_NORET_ID) || isExplicitReturn(func))) { if (endsWithNoExitNode(func)) reportProblem(RET_NORET_ID, func.getDeclSpecifier()); } @@ -143,7 +141,7 @@ public class ReturnChecker extends AbstractAstFunctionChecker { */ protected boolean checkImplicitReturn(String id) { final IProblem pt = getProblemById(id, getFile()); - return (Boolean) getPreference(pt,PARAM_IMPLICIT); + return (Boolean) getPreference(pt, PARAM_IMPLICIT); } /** @@ -151,8 +149,7 @@ public class ReturnChecker extends AbstractAstFunctionChecker { * @return */ protected boolean endsWithNoExitNode(IASTFunctionDefinition func) { - IControlFlowGraph graph = CxxModelsCache.getInstance() - .getControlFlowGraph(func); + IControlFlowGraph graph = CxxModelsCache.getInstance().getControlFlowGraph(func); Iterator exitNodeIterator = graph.getExitNodeIterator(); boolean noexitop = false; for (; exitNodeIterator.hasNext();) { @@ -189,9 +186,11 @@ public class ReturnChecker extends AbstractAstFunctionChecker { } return false; } + /** * check if type if void * (uses deprecated API for compatibility with 6.0) + * * @param type * @throws DOMException */ @@ -199,7 +198,7 @@ public class ReturnChecker extends AbstractAstFunctionChecker { public boolean isVoid(IType type) { if (type instanceof IBasicType) { try { - if (((IBasicType) type).getType()==IBasicType.t_void) + if (((IBasicType) type).getType() == IBasicType.t_void) return true; } catch (DOMException e) { return false; @@ -207,6 +206,7 @@ public class ReturnChecker extends AbstractAstFunctionChecker { } return false; } + /** * @param func * @return @@ -217,10 +217,8 @@ public class ReturnChecker extends AbstractAstFunctionChecker { if (declSpecifier instanceof IASTSimpleDeclSpecifier) { type = ((IASTSimpleDeclSpecifier) declSpecifier).getType(); } else if (declSpecifier instanceof IASTNamedTypeSpecifier) { - IBinding binding = ((IASTNamedTypeSpecifier) declSpecifier) - .getName().resolveBinding(); - IType utype = CxxAstUtils.getInstance().unwindTypedef( - (IType) binding); + IBinding binding = ((IASTNamedTypeSpecifier) declSpecifier).getName().resolveBinding(); + IType utype = CxxAstUtils.getInstance().unwindTypedef((IType) binding); if (isVoid(utype)) return IASTSimpleDeclSpecifier.t_void; } @@ -230,10 +228,8 @@ public class ReturnChecker extends AbstractAstFunctionChecker { /* checker must implement @link ICheckerWithPreferences */ public void initPreferences(IProblemWorkingCopy problem) { super.initPreferences(problem); - if (problem.getId().equals(RET_NO_VALUE_ID) - || problem.getId().equals(RET_NORET_ID)) { - addPreference(problem, PARAM_IMPLICIT, - CheckersMessages.ReturnChecker_Param0, Boolean.FALSE); + if (problem.getId().equals(RET_NO_VALUE_ID) || problem.getId().equals(RET_NORET_ID)) { + addPreference(problem, PARAM_IMPLICIT, CheckersMessages.ReturnChecker_Param0, Boolean.FALSE); } } } diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnStyleChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnStyleChecker.java index d47e0513f81..5c72c562c91 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnStyleChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnStyleChecker.java @@ -20,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; public class ReturnStyleChecker extends AbstractIndexAstChecker { public final String ERR_ID = "org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem"; //$NON-NLS-1$ - + @Override public boolean runInEditor() { return true; @@ -35,21 +35,17 @@ public class ReturnStyleChecker extends AbstractIndexAstChecker { @Override public int visit(IASTStatement statement) { if (statement instanceof IASTReturnStatement) { - boolean isValidStyle = false; - IASTNode[] children = statement.getChildren(); - if (children.length == 0) { isValidStyle = true; - } else if (children.length == 1 - && children[0] instanceof IASTUnaryExpression) { + } else if (children.length == 1 && children[0] instanceof IASTUnaryExpression) { IASTUnaryExpression unaryExpression = (IASTUnaryExpression) children[0]; if (unaryExpression.getOperator() == IASTUnaryExpression.op_bracketedPrimary) { isValidStyle = true; } } - if(!isValidStyle) { + if (!isValidStyle) { reportProblem(ERR_ID, statement); } } @@ -57,5 +53,4 @@ public class ReturnStyleChecker extends AbstractIndexAstChecker { } }); } - } diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/StatementHasNoEffectChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/StatementHasNoEffectChecker.java index b6f7065c198..ed023fb8870 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/StatementHasNoEffectChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/StatementHasNoEffectChecker.java @@ -55,11 +55,9 @@ public class StatementHasNoEffectChecker extends AbstractIndexAstChecker { @Override public int visit(IASTStatement stmt) { if (stmt instanceof IASTExpressionStatement) { - IASTExpression expression = ((IASTExpressionStatement) stmt) - .getExpression(); + IASTExpression expression = ((IASTExpressionStatement) stmt).getExpression(); if (hasNoEffect(expression)) { - boolean inMacro = CxxAstUtils.getInstance().isInMacro( - expression); + boolean inMacro = CxxAstUtils.getInstance().isInMacro(expression); boolean shouldReportInMacro = shouldReportInMacro(); if (inMacro && !shouldReportInMacro) return PROCESS_SKIP; @@ -88,8 +86,7 @@ public class StatementHasNoEffectChecker extends AbstractIndexAstChecker { switch (binExpr.getOperator()) { case IASTBinaryExpression.op_logicalOr: case IASTBinaryExpression.op_logicalAnd: - return hasNoEffect(binExpr.getOperand1()) - && hasNoEffect(binExpr.getOperand2()); + return hasNoEffect(binExpr.getOperand1()) && hasNoEffect(binExpr.getOperand2()); } return true; } @@ -130,25 +127,20 @@ public class StatementHasNoEffectChecker extends AbstractIndexAstChecker { @Override public void initPreferences(IProblemWorkingCopy problem) { super.initPreferences(problem); - addPreference(problem, PARAM_MACRO_ID, - CheckersMessages.StatementHasNoEffectChecker_ParameterMacro, - Boolean.TRUE); - addListPreference(problem, PARAM_EXCEPT_ARG_LIST, - CheckersMessages.GenericParameter_ParameterExceptions, + addPreference(problem, PARAM_MACRO_ID, CheckersMessages.StatementHasNoEffectChecker_ParameterMacro, Boolean.TRUE); + addListPreference(problem, PARAM_EXCEPT_ARG_LIST, CheckersMessages.GenericParameter_ParameterExceptions, CheckersMessages.GenericParameter_ParameterExceptionsItem); } public boolean isFilteredArg(String arg) { - return isFilteredArg(arg, getProblemById(ER_ID, getFile()), - PARAM_EXCEPT_ARG_LIST); + return isFilteredArg(arg, getProblemById(ER_ID, getFile()), PARAM_EXCEPT_ARG_LIST); } /** * @return */ public boolean shouldReportInMacro() { - return (Boolean) getPreference(getProblemById(ER_ID, getFile()), - PARAM_MACRO_ID); + return (Boolean) getPreference(getProblemById(ER_ID, getFile()), PARAM_MACRO_ID); } public boolean isPossibleAssignment(IASTBinaryExpression expr) { diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/SuggestedParenthesisChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/SuggestedParenthesisChecker.java index 659703db6a5..16eb9537a46 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/SuggestedParenthesisChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/SuggestedParenthesisChecker.java @@ -35,8 +35,6 @@ public class SuggestedParenthesisChecker extends AbstractIndexAstChecker { public static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem"; //$NON-NLS-1$ public static final String PARAM_NOT = "paramNot"; //$NON-NLS-1$ - - public void processAst(IASTTranslationUnit ast) { // traverse the ast using the visitor pattern. ast.accept(new ExpressionVisitor()); @@ -121,8 +119,7 @@ public class SuggestedParenthesisChecker extends AbstractIndexAstChecker { } public boolean isParamNot() { - return (Boolean) getPreference(getProblemById(ER_ID, getFile()), - PARAM_NOT); + return (Boolean) getPreference(getProblemById(ER_ID, getFile()), PARAM_NOT); } /* @@ -135,7 +132,6 @@ public class SuggestedParenthesisChecker extends AbstractIndexAstChecker { @Override public void initPreferences(IProblemWorkingCopy problem) { super.initPreferences(problem); - addPreference(problem, PARAM_NOT, - CheckersMessages.SuggestedParenthesisChecker_SuggestParanthesesAroundNot, Boolean.FALSE); + addPreference(problem, PARAM_NOT, CheckersMessages.SuggestedParenthesisChecker_SuggestParanthesesAroundNot, Boolean.FALSE); } } diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/SuspiciousSemicolonChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/SuspiciousSemicolonChecker.java index 4996a0517b4..ff8273fbbb9 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/SuspiciousSemicolonChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/SuspiciousSemicolonChecker.java @@ -35,14 +35,11 @@ public class SuspiciousSemicolonChecker extends AbstractIndexAstChecker { @Override public int visit(IASTStatement statement) { if (statement instanceof IASTIfStatement) { - IASTStatement thenStmt = ((IASTIfStatement) statement) - .getThenClause(); - IASTStatement elseStmt = ((IASTIfStatement) statement) - .getElseClause(); + IASTStatement thenStmt = ((IASTIfStatement) statement).getThenClause(); + IASTStatement elseStmt = ((IASTIfStatement) statement).getElseClause(); if (elseStmt != null && doNotReportIfElse() == true) return PROCESS_CONTINUE; - if (thenStmt instanceof IASTNullStatement - && noMacroInvolved(thenStmt)) { + if (thenStmt instanceof IASTNullStatement && noMacroInvolved(thenStmt)) { reportProblem(ER_ID, thenStmt, (Object) null); } } @@ -57,19 +54,14 @@ public class SuspiciousSemicolonChecker extends AbstractIndexAstChecker { } protected boolean noMacroInvolved(IASTStatement node) { - IASTNodeSelector nodeSelector = node.getTranslationUnit() - .getNodeSelector(node.getTranslationUnit().getFilePath()); + IASTNodeSelector nodeSelector = node.getTranslationUnit().getNodeSelector(node.getTranslationUnit().getFilePath()); IASTFileLocation fileLocation = node.getFileLocation(); - IASTPreprocessorMacroExpansion macro = nodeSelector - .findEnclosingMacroExpansion(fileLocation.getNodeOffset() - 1, - 1); + IASTPreprocessorMacroExpansion macro = nodeSelector.findEnclosingMacroExpansion(fileLocation.getNodeOffset() - 1, 1); return macro == null; } public void initPreferences(IProblemWorkingCopy problem) { super.initPreferences(problem); - addPreference(problem, PARAM_ELSE, - CheckersMessages.SuspiciousSemicolonChecker_ParamElse, - Boolean.FALSE); + addPreference(problem, PARAM_ELSE, CheckersMessages.SuspiciousSemicolonChecker_ParamElse, Boolean.FALSE); } } diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/fs/CFormatStringParser.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/fs/CFormatStringParser.java index 7c6410ac029..3ae0ccff458 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/fs/CFormatStringParser.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/fs/CFormatStringParser.java @@ -8,7 +8,6 @@ * Contributors: * Meisam Fathi - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.codan.internal.checkers.fs; import java.util.Collection; @@ -19,16 +18,15 @@ import java.util.regex.Pattern; /** * This class parses the format string argument and extracts all %s tokens. + * * @version 0.2, June 04, 2010 * @author Meisam Fathi */ public class CFormatStringParser { - /** * At least one digit should be present */ private static final String DIGIT_PATTERN = "[0-9][0-9]*";//$NON-NLS-1$ - /** * The general format for a format string argument is * "%[*][size][modifier]type", in which type is one of the following items: @@ -46,7 +44,6 @@ public class CFormatStringParser { * for more information. */ private static final String STRING_FORMAT_PATTERN = "%[\\*]?[0-9]*[hlL]?[cdeEfgGsuxX]";//$NON-NLS-1$ - /** * If there is an asterisk in the format argument, then it cannot be * vulnerable. If there is a [modifier] (i.e. hlL), then compiler warns. @@ -57,29 +54,24 @@ public class CFormatStringParser { * @see #FORMAT_STRING_PATTERN */ private static final String VULNERABLE_PATTERN = "%[0-9]*s";//$NON-NLS-1$ - /** * The pattern which represents a string format. */ private final Pattern argumentPattern; - /** * The matcher which matches string format arguments. */ private final Matcher argumentMatcher; - /** * The pattern which may lead to vulnerability in scanf * function calls. */ private final Pattern vulnerablePattern; - /** * I guess, this must be a concurrent Collection, but I'm not sure. -- * Meisam */ private final Collection vulnerableArguments; - public final static int ARGUMENT_SIZE_NOT_SPECIFIED = -1; /** @@ -88,10 +80,8 @@ public class CFormatStringParser { * @param argument */ protected CFormatStringParser(final String argument) { - this.argumentPattern = Pattern.compile(STRING_FORMAT_PATTERN); this.argumentMatcher = this.argumentPattern.matcher(argument); - this.vulnerablePattern = Pattern.compile(VULNERABLE_PATTERN); this.vulnerableArguments = new ConcurrentLinkedQueue(); extractVulnerableArguments(); @@ -120,22 +110,19 @@ public class CFormatStringParser { * I'm not sure if clearing the collection is necessary. -- Meisam Fathi */ this.vulnerableArguments.clear(); - boolean hasMore = this.argumentMatcher.find(); int indexOfCurrentArgument = 0; while (hasMore) { final String formatString = this.argumentMatcher.group(); final String matchedArgument = formatString; - final Matcher vulnerabilityMatcher = this.vulnerablePattern - .matcher(matchedArgument); + final Matcher vulnerabilityMatcher = this.vulnerablePattern.matcher(matchedArgument); final boolean isVulnerable = vulnerabilityMatcher.find(); if (isVulnerable) { final int argumentSize = parseArgumentSize(formatString); - final VulnerableFormatStringArgument vulnerableArgument = new VulnerableFormatStringArgument( - indexOfCurrentArgument, formatString, argumentSize); + final VulnerableFormatStringArgument vulnerableArgument = new VulnerableFormatStringArgument(indexOfCurrentArgument, + formatString, argumentSize); this.vulnerableArguments.add(vulnerableArgument); } - hasMore = this.argumentMatcher.find(); indexOfCurrentArgument++; } @@ -144,7 +131,8 @@ public class CFormatStringParser { /** * This method takes a string as input. The format of the input string is * %[0-9]*s. If there is no digit present in the given string it returns - * ARGUMENT_SIZE_NOT_SPECIFIED, otherwise it returns the number specified after "%". For example: + * ARGUMENT_SIZE_NOT_SPECIFIED, otherwise it returns the number + * specified after "%". For example: *
      *
    • %s ==> -1
    • *
    • %123s ==> 123
    • @@ -154,19 +142,17 @@ public class CFormatStringParser { *
    * * @param formatString - * The given format string. - * @return Either ARGUMENT_SIZE_NOT_SPECIFIED or the number embedded in the input string. + * The given format string. + * @return Either ARGUMENT_SIZE_NOT_SPECIFIED or the number embedded in the + * input string. */ private int parseArgumentSize(final String formatString) { - // The minimum possible size for a string of format %[0-9]*s final int MINIMUM_POSSIBLE_SIZE = 2; - int argumentSize = ARGUMENT_SIZE_NOT_SPECIFIED; if (formatString.length() > MINIMUM_POSSIBLE_SIZE) { final Pattern numberPattern = Pattern.compile(DIGIT_PATTERN); final Matcher numberMatcher = numberPattern.matcher(formatString); - if (numberMatcher.find()) { final String sizeModifierString = numberMatcher.group(); argumentSize = Integer.parseInt(sizeModifierString); diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/fs/ScanfFormatStringSecurityChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/fs/ScanfFormatStringSecurityChecker.java index d9c80e13f0b..1eca5d8c772 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/fs/ScanfFormatStringSecurityChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/fs/ScanfFormatStringSecurityChecker.java @@ -29,37 +29,37 @@ import org.eclipse.cdt.core.dom.ast.IType; * e.g: *

    * - * int f() {
    - * char inputstr[5];
    - * scanf("%s", inputstr); // detects vulnerability here
    - * return 0;
    + * int f() {
    + * char inputstr[5];
    + * scanf("%s", inputstr); // detects vulnerability here
    + * return 0;
    * } *
    *

    * e.g: *

    * - * int f(void) {
    - * char inputstr[5];
    - * int inputval;
    - * int i = 5;
    - * scanf("%d %9s", inputval, inputstr); // detects vulnerability here
    - * printf("%d" ,i);
    - * return 0;
    - * }
    + * int f(void) {
    + * char inputstr[5];
    + * int inputval;
    + * int i = 5;
    + * scanf("%d %9s", inputval, inputstr); // detects vulnerability here
    + * printf("%d" ,i);
    + * return 0;
    + * }
    *

    *

    * e.g: *

    * - * int main(void) {
    - * char inputstr[5];
    - * int inputval;
    - * int i = 5;
    - * scanf("%4s %i", inputstr, inputval); // no vulnerability here
    - * printf("%d" ,i);
    - * return 0;
    - * }
    + * int main(void) {
    + * char inputstr[5];
    + * int inputval;
    + * int i = 5;
    + * scanf("%4s %i", inputstr, inputval); // no vulnerability here
    + * printf("%d" ,i);
    + * return 0;
    + * }
    *
    * * @version 0.3 July 29, 2010 @@ -68,7 +68,6 @@ import org.eclipse.cdt.core.dom.ast.IType; */ public class ScanfFormatStringSecurityChecker extends AbstractIndexAstChecker { private static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem"; //$NON-NLS-1$ - private final static VulnerableFunction[] VULNERABLE_FUNCTIONS = {// // list of all format string vulnerable functions new VulnerableFunction("scanf", 0), //$NON-NLS-1$ @@ -85,7 +84,6 @@ public class ScanfFormatStringSecurityChecker extends AbstractIndexAstChecker { private static final class VulnerableFunction { private final String name; - private final int formatStringArgumentIndex; private VulnerableFunction(String name, int formatStringArgumentIndex) { @@ -106,7 +104,6 @@ public class ScanfFormatStringSecurityChecker extends AbstractIndexAstChecker { public int getFormatStringArgumentIndex() { return formatStringArgumentIndex; } - } private class FormatStringVisitor extends ASTVisitor { @@ -121,22 +118,15 @@ public class ScanfFormatStringSecurityChecker extends AbstractIndexAstChecker { if (vulnerableFunction == null) { return PROCESS_CONTINUE; } - IASTInitializerClause[] arguments = callExpression - .getArguments(); - int stringArgumentIndex = vulnerableFunction - .getFormatStringArgumentIndex(); - - detectFaulyArguments(callExpression, arguments, - stringArgumentIndex); - + IASTInitializerClause[] arguments = callExpression.getArguments(); + int stringArgumentIndex = vulnerableFunction.getFormatStringArgumentIndex(); + detectFaulyArguments(callExpression, arguments, stringArgumentIndex); } return PROCESS_CONTINUE; } - private VulnerableFunction getVulnerableFunctionForExpression( - IASTFunctionCallExpression callExpression) { - String rawSignature = callExpression.getFunctionNameExpression() - .getRawSignature(); + private VulnerableFunction getVulnerableFunctionForExpression(IASTFunctionCallExpression callExpression) { + String rawSignature = callExpression.getFunctionNameExpression().getRawSignature(); for (int i = 0; i < VULNERABLE_FUNCTIONS.length; i++) { if (VULNERABLE_FUNCTIONS[i].getName().equals(rawSignature)) { return VULNERABLE_FUNCTIONS[i]; @@ -145,57 +135,41 @@ public class ScanfFormatStringSecurityChecker extends AbstractIndexAstChecker { return null; } - private void detectFaulyArguments( - IASTFunctionCallExpression callExpression, - IASTInitializerClause[] arguments, int formatStringArgumentIndex) { + private void detectFaulyArguments(IASTFunctionCallExpression callExpression, IASTInitializerClause[] arguments, + int formatStringArgumentIndex) { final IASTInitializerClause formatArgument = arguments[formatStringArgumentIndex]; final String formatArgumentValue = formatArgument.getRawSignature(); - final CFormatStringParser formatStringParser = new CFormatStringParser( - formatArgumentValue); - + final CFormatStringParser formatStringParser = new CFormatStringParser(formatArgumentValue); if (!formatStringParser.isVulnerable()) { return; } - // match arguments; final Iterator vulnerableArgumentsIterator = formatStringParser .getVulnerableArgumentsIterator(); - while (vulnerableArgumentsIterator.hasNext()) { - final VulnerableFormatStringArgument currentArgument = vulnerableArgumentsIterator - .next(); + final VulnerableFormatStringArgument currentArgument = vulnerableArgumentsIterator.next(); final int argumentIndex = currentArgument.getArgumentIndex(); final int argumentSize = currentArgument.getArgumentSize(); - if (argumentSize == CFormatStringParser.ARGUMENT_SIZE_NOT_SPECIFIED) { - reportProblem(ER_ID, callExpression, - callExpression.getRawSignature()); + reportProblem(ER_ID, callExpression, callExpression.getRawSignature()); } - // else there some size is specified, so it should be less than // or equal // the size of the string variable. - int suspectArgumentIndex = 1 + formatStringArgumentIndex - + argumentIndex; + int suspectArgumentIndex = 1 + formatStringArgumentIndex + argumentIndex; IASTInitializerClause suspectArgument = arguments[suspectArgumentIndex]; - if (suspectArgument instanceof IASTIdExpression) { final IASTIdExpression idExpression = (IASTIdExpression) suspectArgument; - IType expressionType = idExpression.getExpressionType(); if (expressionType instanceof IArrayType) { IArrayType arrayExpressionType = (IArrayType) expressionType; - long arraySize = arrayExpressionType.getSize() - .numericalValue().longValue(); - + long arraySize = arrayExpressionType.getSize().numericalValue().longValue(); if (argumentSize > arraySize) { - reportProblem(ER_ID, idExpression, - idExpression.getRawSignature()); + reportProblem(ER_ID, idExpression, idExpression.getRawSignature()); } } } } - } } } diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/fs/VulnerableFormatStringArgument.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/fs/VulnerableFormatStringArgument.java index 0a6beee57fc..33aeba0ba6c 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/fs/VulnerableFormatStringArgument.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/fs/VulnerableFormatStringArgument.java @@ -15,23 +15,20 @@ package org.eclipse.cdt.codan.internal.checkers.fs; * @author Meisam Fathi */ public class VulnerableFormatStringArgument { - /** * The index of the argument that is matched, starting at zero. */ private final int indexOfArgument; - /** * The string format argument that may contain the fault */ private final String argument; - /** * the size of the argument. *

      - *
    • %15s ==> 15 + *
    • %15s ==> 15 *
    • %128s ==> 128 - *
    • %s ==> infinity + *
    • %s ==> infinity *
    */ private final int size; @@ -40,8 +37,7 @@ public class VulnerableFormatStringArgument { * @param indexOfCurrentArgument * @param group */ - public VulnerableFormatStringArgument(final int indexOfArgument, - final String rgument, final int size) { + public VulnerableFormatStringArgument(final int indexOfArgument, final String rgument, final int size) { this.indexOfArgument = indexOfArgument; this.argument = rgument; this.size = size; @@ -67,5 +63,4 @@ public class VulnerableFormatStringArgument { public int getArgumentSize() { return this.size; } - } \ No newline at end of file diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/Activator.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/Activator.java index 4a9aaffd58e..eca8b348aea 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/Activator.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/Activator.java @@ -19,13 +19,11 @@ import org.osgi.framework.BundleContext; * The activator class controls the plug-in life cycle */ public class Activator extends Plugin { - // The plug-in ID public static final String PLUGIN_ID = "org.eclipse.cdt.codan.core.cxx"; //$NON-NLS-1$ - // The shared instance private static Activator plugin; - + /** * The constructor */ @@ -34,7 +32,9 @@ public class Activator extends Plugin { /* * (non-Javadoc) - * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) + * + * @see + * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) */ public void start(BundleContext context) throws Exception { super.start(context); @@ -43,7 +43,9 @@ public class Activator extends Plugin { /* * (non-Javadoc) - * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) + * + * @see + * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) */ public void stop(BundleContext context) throws Exception { plugin = null; @@ -52,17 +54,18 @@ public class Activator extends Plugin { /** * Returns the shared instance - * + * * @return the shared instance */ public static Activator getDefault() { return plugin; } + /** * Logs the specified status with this plug-in's log. * * @param status - * status to log + * status to log */ public static void log(IStatus status) { getDefault().getLog().log(status); @@ -72,7 +75,7 @@ public class Activator extends Plugin { * Logs an internal error with the specified throwable * * @param e - * the exception to be logged + * the exception to be logged */ public static void log(Throwable e) { log(new Status(IStatus.ERROR, PLUGIN_ID, 1, "Internal Error", e)); //$NON-NLS-1$ @@ -82,7 +85,7 @@ public class Activator extends Plugin { * Logs an internal error with the specified message. * * @param message - * the error message to log + * the error message to log */ public static void log(String message) { log(new Status(IStatus.ERROR, PLUGIN_ID, 1, message, null)); diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtils.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtils.java index c615e92c2ae..5a64e661746 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtils.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtils.java @@ -59,11 +59,8 @@ import org.eclipse.core.runtime.Path; * Useful functions for doing code analysis on c/c++ AST */ public final class CxxAstUtils { - public static class NameFinderVisitor extends ASTVisitor { - public IASTName name; - { shouldVisitNames = true; } @@ -74,7 +71,6 @@ public final class CxxAstUtils { return PROCESS_ABORT; } } - private static CxxAstUtils instance; private CxxAstUtils() { @@ -107,13 +103,10 @@ public final class CxxAstUtils { } public boolean isInMacro(IASTNode node) { - IASTNodeSelector nodeSelector = node.getTranslationUnit() - .getNodeSelector(node.getTranslationUnit().getFilePath()); + IASTNodeSelector nodeSelector = node.getTranslationUnit().getNodeSelector(node.getTranslationUnit().getFilePath()); IASTFileLocation fileLocation = node.getFileLocation(); - - IASTPreprocessorMacroExpansion macro = nodeSelector - .findEnclosingMacroExpansion(fileLocation.getNodeOffset(), - fileLocation.getNodeLength()); + IASTPreprocessorMacroExpansion macro = nodeSelector.findEnclosingMacroExpansion(fileLocation.getNodeOffset(), + fileLocation.getNodeLength()); return macro != null; } @@ -124,8 +117,7 @@ public final class CxxAstUtils { return (IASTFunctionDefinition) node; } - public IASTCompositeTypeSpecifier getEnclosingCompositeTypeSpecifier( - IASTNode node) { + public IASTCompositeTypeSpecifier getEnclosingCompositeTypeSpecifier(IASTNode node) { while (node != null && !(node instanceof IASTCompositeTypeSpecifier)) { node = node.getParent(); } @@ -141,47 +133,36 @@ public final class CxxAstUtils { /** * @param astName - * a name for the declaration + * a name for the declaration * @param factory - * the factory - * @param index + * the factory + * @param index * @return */ - public IASTDeclaration createDeclaration(IASTName astName, - INodeFactory factory, IIndex index) { - + public IASTDeclaration createDeclaration(IASTName astName, INodeFactory factory, IIndex index) { // Depending on context, either a type or a declaration is easier to // infer - IType inferredType = null; IASTSimpleDeclaration declaration = null; - inferredType = tryInferTypeFromBinaryExpr(astName); if (inferredType == null) declaration = tryInferTypeFromFunctionCall(astName, factory, index); - // After the inference, create the statement is needed - if (declaration != null) { // A declaration was generated return declaration; } else if (inferredType != null) { // A type was inferred, create the // declaration and return it - DeclarationGenerator generator = DeclarationGenerator - .create(factory); - IASTDeclarator declarator = generator.createDeclaratorFromType( - inferredType, astName.toCharArray()); - IASTDeclSpecifier declspec = generator - .createDeclSpecFromType(inferredType); - IASTSimpleDeclaration simpleDeclaration = factory - .newSimpleDeclaration(declspec); + DeclarationGenerator generator = DeclarationGenerator.create(factory); + IASTDeclarator declarator = generator.createDeclaratorFromType(inferredType, astName.toCharArray()); + IASTDeclSpecifier declspec = generator.createDeclSpecFromType(inferredType); + IASTSimpleDeclaration simpleDeclaration = factory.newSimpleDeclaration(declspec); simpleDeclaration.addDeclarator(declarator); return simpleDeclaration; } else { // Fallback - return a `void` declaration IASTDeclarator declarator = factory.newDeclarator(astName.copy()); IASTSimpleDeclSpecifier declspec = factory.newSimpleDeclSpecifier(); declspec.setType(Kind.eInt); - IASTSimpleDeclaration simpleDeclaration = factory - .newSimpleDeclaration(declspec); + IASTSimpleDeclaration simpleDeclaration = factory.newSimpleDeclaration(declspec); simpleDeclaration.addDeclarator(declarator); return simpleDeclaration; } @@ -194,8 +175,7 @@ public final class CxxAstUtils { * @return inferred type or null if couldn't infer */ private IType tryInferTypeFromBinaryExpr(IASTName astName) { - if (astName.getParent() instanceof IASTIdExpression - && astName.getParent().getParent() instanceof IASTBinaryExpression) { + if (astName.getParent() instanceof IASTIdExpression && astName.getParent().getParent() instanceof IASTBinaryExpression) { IASTNode binaryExpr = astName.getParent().getParent(); for (IASTNode node : binaryExpr.getChildren()) { if (node != astName.getParent()) { @@ -210,28 +190,23 @@ public final class CxxAstUtils { /** * For a function call, tries to find a matching function declaration. * Checks the argument count. - * @param index + * + * @param index * * @return a generated declaration or null if not suitable */ - private IASTSimpleDeclaration tryInferTypeFromFunctionCall( - IASTName astName, INodeFactory factory, IIndex index) { - if (astName.getParent() instanceof IASTIdExpression - && astName.getParent().getParent() instanceof IASTFunctionCallExpression + private IASTSimpleDeclaration tryInferTypeFromFunctionCall(IASTName astName, INodeFactory factory, IIndex index) { + if (astName.getParent() instanceof IASTIdExpression && astName.getParent().getParent() instanceof IASTFunctionCallExpression && astName.getParent().getPropertyInParent() == IASTFunctionCallExpression.ARGUMENT) { - - IASTFunctionCallExpression call = (IASTFunctionCallExpression) astName - .getParent().getParent(); + IASTFunctionCallExpression call = (IASTFunctionCallExpression) astName.getParent().getParent(); NameFinderVisitor visitor = new NameFinderVisitor(); call.getFunctionNameExpression().accept(visitor); IASTName funcname = visitor.name; - int expectedParametersNum = 0; int targetParameterNum = -1; for (IASTNode n : call.getChildren()) { if (n.getPropertyInParent() == IASTFunctionCallExpression.ARGUMENT) { - if (n instanceof IASTIdExpression - && n.getChildren()[0] == astName) { + if (n instanceof IASTIdExpression && n.getChildren()[0] == astName) { targetParameterNum = expectedParametersNum; } expectedParametersNum++; @@ -240,13 +215,11 @@ public final class CxxAstUtils { if (targetParameterNum == -1) { return null; } - IBinding[] bindings; { IBinding binding = funcname.resolveBinding(); if (binding instanceof IProblemBinding) { - bindings = ((IProblemBinding) binding) - .getCandidateBindings(); + bindings = ((IProblemBinding) binding).getCandidateBindings(); } else { bindings = new IBinding[] { binding }; } @@ -266,44 +239,32 @@ public final class CxxAstUtils { } } for (IIndexName decl : declSet) { - // for now, just use the first overload found - ITranslationUnit tu = getTranslationUnitFromIndexName(decl); - IASTName name = (IASTName) tu.getAST(null, - ITranslationUnit.AST_SKIP_INDEXED_HEADERS) - .getNodeSelector(null).findEnclosingNode( - decl.getNodeOffset(), decl.getNodeLength()); - + IASTName name = (IASTName) tu.getAST(null, ITranslationUnit.AST_SKIP_INDEXED_HEADERS).getNodeSelector(null) + .findEnclosingNode(decl.getNodeOffset(), decl.getNodeLength()); IASTNode fdecl = name; while (fdecl instanceof IASTName) { fdecl = fdecl.getParent(); } assert (fdecl instanceof IASTFunctionDeclarator); - // find the needed param number int nthParam = 0; for (IASTNode child : fdecl.getChildren()) { if (child instanceof IASTParameterDeclaration) { if (nthParam == targetParameterNum) { IASTParameterDeclaration pd = (IASTParameterDeclaration) child; - IASTDeclSpecifier declspec = pd - .getDeclSpecifier().copy(); - IASTDeclarator declarator = pd.getDeclarator() - .copy(); - setNameInNestedDeclarator(declarator, astName - .copy()); - IASTSimpleDeclaration declaration = factory - .newSimpleDeclaration(declspec); + IASTDeclSpecifier declspec = pd.getDeclSpecifier().copy(); + IASTDeclarator declarator = pd.getDeclarator().copy(); + setNameInNestedDeclarator(declarator, astName.copy()); + IASTSimpleDeclaration declaration = factory.newSimpleDeclaration(declspec); declaration.addDeclarator(declarator); return declaration; } nthParam++; } - } name.getParent(); - } } catch (InterruptedException e) { // skip @@ -312,25 +273,21 @@ public final class CxxAstUtils { } finally { index.releaseReadLock(); } - } return null; } - private void setNameInNestedDeclarator(IASTDeclarator declarator, - IASTName astName) { + private void setNameInNestedDeclarator(IASTDeclarator declarator, IASTName astName) { while (declarator.getNestedDeclarator() != null) { declarator = declarator.getNestedDeclarator(); } declarator.setName(astName); } - public ITranslationUnit getTranslationUnitFromIndexName(IIndexName decl) - throws CoreException { + public ITranslationUnit getTranslationUnitFromIndexName(IIndexName decl) throws CoreException { Path path = new Path(decl.getFile().getLocation().getFullPath()); IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); - ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create( - file); + ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create(file); return tu; } @@ -339,17 +296,14 @@ public final class CxxAstUtils { * Otherwise, returns null. * * @param function - * the function definition to check + * the function definition to check * @param index - * the index to use for name lookup + * the index to use for name lookup * @return Either a type specifier or null */ - public IASTCompositeTypeSpecifier getCompositeTypeFromFunction( - final IASTFunctionDefinition function, final IIndex index) { - + public IASTCompositeTypeSpecifier getCompositeTypeFromFunction(final IASTFunctionDefinition function, final IIndex index) { // return value to be set via visitor final IASTCompositeTypeSpecifier returnSpecifier[] = { null }; - function.accept(new ASTVisitor() { { shouldVisitDeclarators = true; @@ -358,43 +312,31 @@ public final class CxxAstUtils { @Override public int visit(IASTName name) { - if (!(name instanceof ICPPASTQualifiedName && name.getParent() - .getParent() == function)) + if (!(name instanceof ICPPASTQualifiedName && name.getParent().getParent() == function)) return PROCESS_CONTINUE; - ICPPASTQualifiedName qname = (ICPPASTQualifiedName) name; - // A qualified name may have 1 name, but in our case needs to // have 2. // The pre-last name is either a namespace or a class. if (qname.getChildren().length < 2) { return PROCESS_CONTINUE; } - IASTName namePart = (IASTName) qname.getChildren()[qname - .getChildren().length - 2]; - + IASTName namePart = (IASTName) qname.getChildren()[qname.getChildren().length - 2]; IBinding binding = namePart.resolveBinding(); try { index.acquireReadLock(); IIndexName[] declarations = index.findDeclarations(binding); - // Check the declarations and use first suitable for (IIndexName decl : declarations) { - ITranslationUnit tu = getTranslationUnitFromIndexName(decl); - IASTNode node = tu.getAST(index, - ITranslationUnit.AST_SKIP_INDEXED_HEADERS) - .getNodeSelector(null).findEnclosingNode( - decl.getNodeOffset(), - decl.getNodeLength()); + IASTNode node = tu.getAST(index, ITranslationUnit.AST_SKIP_INDEXED_HEADERS).getNodeSelector(null) + .findEnclosingNode(decl.getNodeOffset(), decl.getNodeLength()); IASTCompositeTypeSpecifier specifier = getEnclosingCompositeTypeSpecifier(node); - if (specifier != null) { returnSpecifier[0] = specifier; break; } } - } catch (InterruptedException e) { return PROCESS_ABORT; } catch (CoreException e) { @@ -403,14 +345,12 @@ public final class CxxAstUtils { } finally { index.releaseReadLock(); } - return PROCESS_ABORT; } - }); return returnSpecifier[0]; } - + /** * @param body * @return @@ -418,8 +358,7 @@ public final class CxxAstUtils { public boolean isThrowStatement(IASTNode body) { if (!(body instanceof IASTExpressionStatement)) return false; - IASTExpression expression = ((IASTExpressionStatement) body) - .getExpression(); + IASTExpression expression = ((IASTExpressionStatement) body).getExpression(); if (!(expression instanceof IASTUnaryExpression)) return false; return ((IASTUnaryExpression) expression).getOperator() == IASTUnaryExpression.op_throw; @@ -428,12 +367,10 @@ public final class CxxAstUtils { public boolean isExitStatement(IASTNode body) { if (!(body instanceof IASTExpressionStatement)) return false; - IASTExpression expression = ((IASTExpressionStatement) body) - .getExpression(); + IASTExpression expression = ((IASTExpressionStatement) body).getExpression(); if (!(expression instanceof IASTFunctionCallExpression)) return false; - IASTExpression functionNameExpression = ((IASTFunctionCallExpression) expression) - .getFunctionNameExpression(); + IASTExpression functionNameExpression = ((IASTFunctionCallExpression) expression).getFunctionNameExpression(); return functionNameExpression.getRawSignature().equals("exit"); //$NON-NLS-1$ } } diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/CxxCodanReconciler.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/CxxCodanReconciler.java index f823169c573..5c48524a448 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/CxxCodanReconciler.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/CxxCodanReconciler.java @@ -25,23 +25,20 @@ import org.eclipse.core.runtime.IProgressMonitor; * */ public class CxxCodanReconciler { - private CodanBuilder builder = (CodanBuilder) CodanRuntime.getInstance() - .getBuilder(); + private CodanBuilder builder = (CodanBuilder) CodanRuntime.getInstance().getBuilder(); - public void reconciledAst(IASTTranslationUnit ast, IResource resource, - IProgressMonitor monitor) { + public void reconciledAst(IASTTranslationUnit ast, IResource resource, IProgressMonitor monitor) { if (ast == null) return; IProject project = resource.getProject(); - if (project==null) return; + if (project == null) + return; try { - if (project.hasNature(CProjectNature.C_NATURE_ID) - || project.hasNature(CCProjectNature.CC_NATURE_ID)) { + if (project.hasNature(CProjectNature.C_NATURE_ID) || project.hasNature(CCProjectNature.CC_NATURE_ID)) { builder.runInEditor(ast, resource, monitor); } } catch (CoreException e) { // ignore } - } } diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/ControlFlowGraphBuilder.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/ControlFlowGraphBuilder.java index 632f8d531ea..c5f9bd9d847 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/ControlFlowGraphBuilder.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/ControlFlowGraphBuilder.java @@ -86,8 +86,7 @@ public class ControlFlowGraphBuilder { for (Iterator iterator = dead.iterator(); iterator.hasNext();) { IBasicBlock ds = (IBasicBlock) iterator.next(); IBasicBlock dl = findLast(ds); - if (dl != null && dl.getOutgoingSize() == 0 - && dl != returnExit) { + if (dl != null && dl.getOutgoingSize() == 0 && dl != returnExit) { ((AbstractBasicBlock) dl).addOutgoing(returnExit); } } @@ -124,9 +123,7 @@ public class ControlFlowGraphBuilder { IBasicBlock last = createSubGraph(prev, node); prev = last; } - } else if (body instanceof IASTExpressionStatement - || body instanceof IASTDeclarationStatement - || body instanceof IASTNullStatement) { + } else if (body instanceof IASTExpressionStatement || body instanceof IASTDeclarationStatement || body instanceof IASTNullStatement) { if (isThrowStatement(body) || isExitStatement(body)) { CxxExitNode node = createExitNode(prev, body); return node; @@ -204,8 +201,7 @@ public class ControlFlowGraphBuilder { * @param body * @return */ - private IBasicBlock createTry(IBasicBlock prev, - ICPPASTTryBlockStatement body) { + private IBasicBlock createTry(IBasicBlock prev, ICPPASTTryBlockStatement body) { DecisionNode ifNode = factory.createDecisionNode(body); addOutgoing(prev, ifNode); IConnectorNode mergeNode = factory.createConnectorNode(); @@ -217,11 +213,9 @@ public class ControlFlowGraphBuilder { ICPPASTCatchHandler[] catchHandlers = body.getCatchHandlers(); for (int i = 0; i < catchHandlers.length; i++) { ICPPASTCatchHandler handler = catchHandlers[i]; - IBranchNode handlerNode = factory.createBranchNode(handler - .getDeclaration()); + IBranchNode handlerNode = factory.createBranchNode(handler.getDeclaration()); addOutgoing(ifNode, handlerNode); - IBasicBlock els = createSubGraph(handlerNode, - handler.getCatchBody()); + IBasicBlock els = createSubGraph(handlerNode, handler.getCatchBody()); addJump(els, mergeNode); } return mergeNode; @@ -234,8 +228,7 @@ public class ControlFlowGraphBuilder { private boolean isThrowStatement(IASTNode body) { if (!(body instanceof IASTExpressionStatement)) return false; - IASTExpression expression = ((IASTExpressionStatement) body) - .getExpression(); + IASTExpression expression = ((IASTExpressionStatement) body).getExpression(); if (!(expression instanceof IASTUnaryExpression)) return false; return ((IASTUnaryExpression) expression).getOperator() == IASTUnaryExpression.op_throw; @@ -244,12 +237,10 @@ public class ControlFlowGraphBuilder { private boolean isExitStatement(IASTNode body) { if (!(body instanceof IASTExpressionStatement)) return false; - IASTExpression expression = ((IASTExpressionStatement) body) - .getExpression(); + IASTExpression expression = ((IASTExpressionStatement) body).getExpression(); if (!(expression instanceof IASTFunctionCallExpression)) return false; - IASTExpression functionNameExpression = ((IASTFunctionCallExpression) expression) - .getFunctionNameExpression(); + IASTExpression functionNameExpression = ((IASTFunctionCallExpression) expression).getFunctionNameExpression(); return functionNameExpression.getRawSignature().equals("exit"); //$NON-NLS-1$ } @@ -287,8 +278,7 @@ public class ControlFlowGraphBuilder { * @return */ protected IBasicBlock createIf(IBasicBlock prev, IASTIfStatement body) { - DecisionNode ifNode = factory.createDecisionNode(body - .getConditionExpression()); + DecisionNode ifNode = factory.createDecisionNode(body.getConditionExpression()); addOutgoing(prev, ifNode); IConnectorNode mergeNode = factory.createConnectorNode(); ifNode.setMergeNode(mergeNode); @@ -309,8 +299,7 @@ public class ControlFlowGraphBuilder { * @return */ private IBasicBlock createSwitch(IBasicBlock prev, IASTSwitchStatement body) { - DecisionNode node = factory.createDecisionNode(body - .getControllerExpression()); + DecisionNode node = factory.createDecisionNode(body.getControllerExpression()); addOutgoing(prev, node); IConnectorNode conn = factory.createConnectorNode(); node.setMergeNode(conn); @@ -324,8 +313,7 @@ public class ControlFlowGraphBuilder { * @param def * @param body */ - private void createSwitchBody(DecisionNode switchNode, - IConnectorNode mergeNode, IASTStatement body) { + private void createSwitchBody(DecisionNode switchNode, IConnectorNode mergeNode, IASTStatement body) { if (!(body instanceof IASTCompoundStatement)) return; // bad IASTCompoundStatement comp = (IASTCompoundStatement) body; @@ -333,8 +321,7 @@ public class ControlFlowGraphBuilder { IBasicBlock prev = switchNode; for (int i = 0; i < children.length; i++) { IASTNode elem = children[i]; - if (elem instanceof IASTCaseStatement - || elem instanceof IASTDefaultStatement) { + if (elem instanceof IASTCaseStatement || elem instanceof IASTDefaultStatement) { IBranchNode lbl = null; if (elem instanceof IASTCaseStatement) { IASTCaseStatement caseSt = (IASTCaseStatement) elem; @@ -370,16 +357,14 @@ public class ControlFlowGraphBuilder { */ private IBasicBlock createFor(IBasicBlock prev, IASTForStatement forNode) { // add initializer - IPlainNode init = factory.createPlainNode(forNode - .getInitializerStatement()); + IPlainNode init = factory.createPlainNode(forNode.getInitializerStatement()); addOutgoing(prev, init); prev = init; // add continue connector IConnectorNode beforeCheck = factory.createConnectorNode(); addOutgoing(prev, beforeCheck); // decision node - CxxDecisionNode decision = factory.createDecisionNode(forNode - .getConditionExpression()); + CxxDecisionNode decision = factory.createDecisionNode(forNode.getConditionExpression()); addOutgoing(beforeCheck, decision); // add break connector IConnectorNode nBreak = factory.createConnectorNode(); @@ -397,8 +382,7 @@ public class ControlFlowGraphBuilder { outerContinue = savedContinue; outerBreak = savedBreak; // inc - IPlainNode inc = factory.createPlainNode(forNode - .getIterationExpression()); + IPlainNode inc = factory.createPlainNode(forNode.getIterationExpression()); addOutgoing(endBody, nContinue); addOutgoing(nContinue, inc); // connect with backward link @@ -420,8 +404,7 @@ public class ControlFlowGraphBuilder { IConnectorNode nContinue = factory.createConnectorNode(); addOutgoing(prev, nContinue); // decision node - CxxDecisionNode decision = factory.createDecisionNode(body - .getCondition()); + CxxDecisionNode decision = factory.createDecisionNode(body.getCondition()); addOutgoing(nContinue, decision); // add break connector IConnectorNode nBreak = factory.createConnectorNode(); @@ -465,8 +448,7 @@ public class ControlFlowGraphBuilder { // add continue connector addOutgoing(endBody, nContinue); // decision node - CxxDecisionNode decision = factory.createDecisionNode(body - .getCondition()); + CxxDecisionNode decision = factory.createDecisionNode(body.getCondition()); addOutgoing(nContinue, decision); // then branch IBranchNode thenNode = factory.createBranchNode(IBranchNode.THEN); @@ -489,8 +471,7 @@ public class ControlFlowGraphBuilder { return addJump(prev, conn, false); } - private IJumpNode addJump(IBasicBlock prev, IConnectorNode conn, - boolean backward) { + private IJumpNode addJump(IBasicBlock prev, IConnectorNode conn, boolean backward) { if (prev instanceof IJumpNode) return (IJumpNode) prev; if (prev instanceof IExitNode) diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxBranchNode.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxBranchNode.java index 72a47dbfd73..a9d74c955b9 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxBranchNode.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxBranchNode.java @@ -19,8 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; public class CxxBranchNode extends BranchNode { private IASTNode labelData; - - CxxBranchNode(IASTNode label) { + CxxBranchNode(IASTNode label) { super(label.getRawSignature()); this.labelData = label; } @@ -32,6 +31,6 @@ public class CxxBranchNode extends BranchNode { */ @Override public String toString() { - return labelData.getRawSignature()+":"; //$NON-NLS-1$ + return labelData.getRawSignature() + ":"; //$NON-NLS-1$ } } diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxControlFlowGraph.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxControlFlowGraph.java index 01e2fb8c578..f7a71043cdd 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxControlFlowGraph.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxControlFlowGraph.java @@ -32,8 +32,10 @@ public class CxxControlFlowGraph extends ControlFlowGraph { public static CxxControlFlowGraph build(IASTFunctionDefinition def) { return new ControlFlowGraphBuilder().build(def); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override @@ -41,5 +43,4 @@ public class CxxControlFlowGraph extends ControlFlowGraph { // TODO Auto-generated method stub return super.toString(); } - } diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxDecisionNode.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxDecisionNode.java index 21e19618a10..01b70c65cd7 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxDecisionNode.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxDecisionNode.java @@ -19,7 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; public class CxxDecisionNode extends DecisionNode { /** * @param node - * the node to set + * the node to set */ public void setNode(IASTNode node) { setData(node); diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxExitNode.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxExitNode.java index 794c91e4bc6..0bec8a24c6b 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxExitNode.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxExitNode.java @@ -20,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; public class CxxExitNode extends ExitNode implements IExitNode { /** * @param node - * the node to set + * the node to set */ public void setNode(IASTNode node) { setData(node); diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxPlainNode.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxPlainNode.java index 87640bb4edd..5d36a481a33 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxPlainNode.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxPlainNode.java @@ -17,11 +17,9 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; * TODO: add description */ public class CxxPlainNode extends PlainNode { - - /** * @param node - * the node to set + * the node to set */ public void setNode(IASTNode node) { setData(node); diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxStartNode.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxStartNode.java index d5817e24b04..6f250330f9d 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxStartNode.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/CxxStartNode.java @@ -7,8 +7,7 @@ * * Contributors: * Alena Laskavaia - initial API and implementation - *******************************************************************************/ - + *******************************************************************************/ package org.eclipse.cdt.codan.core.cxx.internal.model.cfg; import org.eclipse.cdt.codan.internal.core.cfg.StartNode; @@ -17,15 +16,16 @@ import org.eclipse.cdt.codan.internal.core.cfg.StartNode; * TODO: add description */ public class CxxStartNode extends StartNode { - /** * @param next */ public CxxStartNode() { super(); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/AbstractAstFunctionChecker.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/AbstractAstFunctionChecker.java index 3c8ee5b24ae..b3668773dcd 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/AbstractAstFunctionChecker.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/AbstractAstFunctionChecker.java @@ -19,8 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; /** * Abstract class for checkers that do all the work on function definition level */ -public abstract class AbstractAstFunctionChecker extends - AbstractIndexAstChecker implements ICheckerWithPreferences { +public abstract class AbstractAstFunctionChecker extends AbstractIndexAstChecker implements ICheckerWithPreferences { public void processAst(IASTTranslationUnit ast) { // traverse the ast using the visitor pattern. ast.accept(new ASTVisitor() { @@ -30,7 +29,7 @@ public abstract class AbstractAstFunctionChecker extends public int visit(IASTDeclaration element) { if (element instanceof IASTFunctionDefinition) { - processFunction((IASTFunctionDefinition) element); + processFunction((IASTFunctionDefinition) element); } // visit all nodes to support inner functions within class definitions // and gcc extensions @@ -43,9 +42,7 @@ public abstract class AbstractAstFunctionChecker extends * Process function. * * @param func - * - ast node representing function definition + * - ast node representing function definition */ protected abstract void processFunction(IASTFunctionDefinition func); - - } diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/AbstractCIndexChecker.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/AbstractCIndexChecker.java index a433ef8671c..e9a5570a1bf 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/AbstractCIndexChecker.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/AbstractCIndexChecker.java @@ -34,10 +34,11 @@ public abstract class AbstractCIndexChecker extends AbstractCheckerWithProblemPr return file; } - void processFile(IFile file) throws CoreException, InterruptedException { + void processFile(IFile file) throws CoreException, InterruptedException { // create translation unit and access index ICElement model = CoreModel.getDefault().create(file); - if (!(model instanceof ITranslationUnit)) return; // not a C/C++ file + if (!(model instanceof ITranslationUnit)) + return; // not a C/C++ file ITranslationUnit tu = (ITranslationUnit) model; index = CCorePlugin.getIndexManager().getIndex(tu.getCProject()); // lock the index for read access diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/AbstractIndexAstChecker.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/AbstractIndexAstChecker.java index ca28daa251a..d72bb2ff00c 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/AbstractIndexAstChecker.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/AbstractIndexAstChecker.java @@ -33,8 +33,8 @@ import org.eclipse.core.runtime.Path; * * Clients may extend this class. */ -public abstract class AbstractIndexAstChecker extends AbstractCheckerWithProblemPreferences implements - ICAstChecker, IRunnableInEditorChecker { +public abstract class AbstractIndexAstChecker extends AbstractCheckerWithProblemPreferences implements ICAstChecker, + IRunnableInEditorChecker { private IFile file; protected IFile getFile() { @@ -63,7 +63,8 @@ public abstract class AbstractIndexAstChecker extends AbstractCheckerWithProblem } public synchronized boolean processResource(IResource resource) { - if (!shouldProduceProblems(resource)) return false; + if (!shouldProduceProblems(resource)) + return false; if (resource instanceof IFile) { IFile file = (IFile) resource; try { @@ -82,8 +83,7 @@ public abstract class AbstractIndexAstChecker extends AbstractCheckerWithProblem public void reportProblem(String id, IASTNode astNode, Object... args) { IASTFileLocation astLocation = astNode.getFileLocation(); IPath location = new Path(astLocation.getFileName()); - IFile astFile = ResourceLookup.selectFileForLocation(location, - getProject()); + IFile astFile = ResourceLookup.selectFileForLocation(location, getProject()); if (astFile == null) { astFile = file; } @@ -94,15 +94,10 @@ public abstract class AbstractIndexAstChecker extends AbstractCheckerWithProblem IProblemLocation loc; int line = astLocation.getStartingLineNumber(); if (line == astLocation.getEndingLineNumber()) - loc = getRuntime().getProblemLocationFactory() - .createProblemLocation( - astFile, - astLocation.getNodeOffset(), - astLocation.getNodeOffset() - + astLocation.getNodeLength(), line); + loc = getRuntime().getProblemLocationFactory().createProblemLocation(astFile, astLocation.getNodeOffset(), + astLocation.getNodeOffset() + astLocation.getNodeLength(), line); else - loc = getRuntime().getProblemLocationFactory() - .createProblemLocation(astFile, line); + loc = getRuntime().getProblemLocationFactory().createProblemLocation(astFile, line); reportProblem(id, loc, args); } @@ -121,11 +116,10 @@ public abstract class AbstractIndexAstChecker extends AbstractCheckerWithProblem @SuppressWarnings("restriction") public synchronized void processModel(Object model) { if (model instanceof IASTTranslationUnit) { - CxxModelsCache.getInstance().clearCash(); + CxxModelsCache.getInstance().clearCash(); IASTTranslationUnit ast = (IASTTranslationUnit) model; IPath location = new Path(ast.getFilePath()); - IFile astFile = ResourceLookup.selectFileForLocation(location, - getProject()); + IFile astFile = ResourceLookup.selectFileForLocation(location, getProject()); file = astFile; processAst(ast); } diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/CxxModelsCache.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/CxxModelsCache.java index 028d8b31167..0a32ee0184c 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/CxxModelsCache.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/CxxModelsCache.java @@ -33,7 +33,6 @@ public class CxxModelsCache { private ITranslationUnit tu; private IIndex index; private WeakHashMap cfgmap = new WeakHashMap(0); - private static CxxModelsCache instance = new CxxModelsCache(); public static CxxModelsCache getInstance() { @@ -42,20 +41,20 @@ public class CxxModelsCache { public synchronized IControlFlowGraph getControlFlowGraph(IASTFunctionDefinition func) { IControlFlowGraph cfg = cfgmap.get(func); - if (cfg!=null) return cfg; + if (cfg != null) + return cfg; cfg = CxxControlFlowGraph.build(func); - if (cfgmap.size()>20) { // if too many function better drop the cash XXX should be LRU + if (cfgmap.size() > 20) { // if too many function better drop the cash XXX should be LRU cfgmap.clear(); } cfgmap.put(func, cfg); return cfg; } - public synchronized IASTTranslationUnit getAst(IFile file) - throws CoreException, InterruptedException { + + public synchronized IASTTranslationUnit getAst(IFile file) throws CoreException, InterruptedException { if (file.equals(this.file)) { return ast; } - // create translation unit and access index ICElement celement = CoreModel.getDefault().create(file); if (!(celement instanceof ITranslationUnit)) @@ -88,8 +87,7 @@ public class CxxModelsCache { index = null; } - public synchronized IIndex getIndex(IFile file) - throws CoreException, InterruptedException { + public synchronized IIndex getIndex(IFile file) throws CoreException, InterruptedException { if (file.equals(this.file)) { return index; } diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/ICAstChecker.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/ICAstChecker.java index 23474f8a5e9..5fd92d1c0d0 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/ICAstChecker.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/ICAstChecker.java @@ -14,7 +14,8 @@ import org.eclipse.cdt.codan.core.model.IChecker; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; /** - * Checker that can/want to process C/C++ AST (Abstract Syntax Tree) of a program + * Checker that can/want to process C/C++ AST (Abstract Syntax Tree) of a + * program * Default implementation {@link AbstractIndexAstChecker} * * Clients may implement and extend this interface. @@ -28,8 +29,9 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; public interface ICAstChecker extends IChecker { /** * Run this checker on a given ast. - * Ast locks would be obtained by the framework before calling this method. - * @param ast + * Ast locks would be obtained by the framework before calling this method. + * + * @param ast */ void processAst(IASTTranslationUnit ast); } diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/ICIndexChecker.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/ICIndexChecker.java index 6032a1d0a91..c8e71620966 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/ICIndexChecker.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/ICIndexChecker.java @@ -27,6 +27,7 @@ import org.eclipse.cdt.core.model.ITranslationUnit; public interface ICIndexChecker extends IChecker { /** * Run checker on translation unit + * * @param unit - translation unit */ void processUnit(ITranslationUnit unit); diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/cfg/ControlFlowGraphTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/cfg/ControlFlowGraphTest.java index 231292c9d6e..63d226ae0ca 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/cfg/ControlFlowGraphTest.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/cfg/ControlFlowGraphTest.java @@ -51,8 +51,7 @@ public class ControlFlowGraphTest extends CodanFastCxxAstTestCase { @Override public int visit(IASTDeclaration decl) { if (decl instanceof IASTFunctionDefinition) { - graph = new ControlFlowGraphBuilder() - .build((IASTFunctionDefinition) decl); + graph = new ControlFlowGraphBuilder().build((IASTFunctionDefinition) decl); return PROCESS_ABORT; } return PROCESS_CONTINUE; @@ -72,8 +71,7 @@ public class ControlFlowGraphTest extends CodanFastCxxAstTestCase { assertNotNull(graph); assertNotNull(graph.getStartNode()); Collection nodes = graph.getNodes(); - for (Iterator iterator = nodes.iterator(); iterator - .hasNext();) { + for (Iterator iterator = nodes.iterator(); iterator.hasNext();) { IBasicBlock node = iterator.next(); checkNode(node, decision); } @@ -88,8 +86,7 @@ public class ControlFlowGraphTest extends CodanFastCxxAstTestCase { IBasicBlock b = incomingNodes[i]; if (b == null) { // check if dead node - Iterator iterator = graph - .getUnconnectedNodeIterator(); + Iterator iterator = graph.getUnconnectedNodeIterator(); boolean dead = false; for (; iterator.hasNext();) { IBasicBlock d = iterator.next(); @@ -112,8 +109,7 @@ public class ControlFlowGraphTest extends CodanFastCxxAstTestCase { fail("Block " + node + " inconsitent next/prev " + b); } if (node instanceof IDecisionNode && decision) { - assertTrue("decision node outgoing size " + node.getOutgoingSize(), - node.getOutgoingSize() > 1); + assertTrue("decision node outgoing size " + node.getOutgoingSize(), node.getOutgoingSize() > 1); assertNotNull(((IDecisionNode) node).getMergeNode()); } } diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtilsTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtilsTest.java index 8ab4ee946b6..4d8a8d4ab14 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtilsTest.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/cxx/CxxAstUtilsTest.java @@ -63,8 +63,7 @@ public class CxxAstUtilsTest extends CodanFastCxxAstTestCase { IASTSimpleDeclaration sdecl = (IASTSimpleDeclaration) decl; IASTDeclSpecifier spec = sdecl.getDeclSpecifier(); if (spec instanceof IASTNamedTypeSpecifier) { - IASTName tname = ((IASTNamedTypeSpecifier) spec) - .getName(); + IASTName tname = ((IASTNamedTypeSpecifier) spec).getName(); IType typeName = (IType) tname.resolveBinding(); result[0] = instance.unwindTypedef(typeName); } @@ -96,9 +95,7 @@ public class CxxAstUtilsTest extends CodanFastCxxAstTestCase { @Override public int visit(IASTStatement stmt) { if (stmt instanceof IASTExpressionStatement) { - boolean check = instance - .isInMacro(((IASTExpressionStatement) stmt) - .getExpression()); + boolean check = instance.isInMacro(((IASTExpressionStatement) stmt).getExpression()); result[i] = check; i++; } diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/CaseBreakCheckerTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/CaseBreakCheckerTest.java index 09dda958973..2f17be29d93 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/CaseBreakCheckerTest.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/CaseBreakCheckerTest.java @@ -309,8 +309,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase { public void testGeneral1() { setEmpty(true); loadCodeAndRun(getAboveComment()); - checkErrorLines(4, 6, 7, 11, 14, 16, 19, 20, 24, 27, 32, 37, 41, 46, - 49, 51); + checkErrorLines(4, 6, 7, 11, 14, 16, 19, 20, 24, 27, 32, 37, 41, 46, 49, 51); } // void foo(void) { @@ -429,14 +428,12 @@ public class CaseBreakCheckerTest extends CheckerTestCase { } private void setLast(boolean val) { - IProblemPreference pref = getPreference(CaseBreakChecker.ER_ID, - CaseBreakChecker.PARAM_LAST_CASE); + IProblemPreference pref = getPreference(CaseBreakChecker.ER_ID, CaseBreakChecker.PARAM_LAST_CASE); pref.setValue(val); } private void setEmpty(boolean val) { - IProblemPreference pref = getPreference(CaseBreakChecker.ER_ID, - CaseBreakChecker.PARAM_EMPTY_CASE); + IProblemPreference pref = getPreference(CaseBreakChecker.ER_ID, CaseBreakChecker.PARAM_EMPTY_CASE); pref.setValue(val); } diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/CatchByReferenceTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/CatchByReferenceTest.java index 58237fa62c0..a0a239d063c 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/CatchByReferenceTest.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/CatchByReferenceTest.java @@ -108,8 +108,7 @@ public class CatchByReferenceTest extends CheckerTestCase { // } // } public void test_class_unknown() { - setPreferenceValue(CatchByReference.ER_ID, - CatchByReference.PARAM_UNKNOWN_TYPE, false); + setPreferenceValue(CatchByReference.ER_ID, CatchByReference.PARAM_UNKNOWN_TYPE, false); loadCodeAndRun(getAboveComment()); checkNoErrors(); } @@ -121,8 +120,7 @@ public class CatchByReferenceTest extends CheckerTestCase { // } // } public void test_class_unknown_on() { - setPreferenceValue(CatchByReference.ER_ID, - CatchByReference.PARAM_UNKNOWN_TYPE, true); + setPreferenceValue(CatchByReference.ER_ID, CatchByReference.PARAM_UNKNOWN_TYPE, true); loadCodeAndRun(getAboveComment()); checkErrorLine(4); } diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnCheckerTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnCheckerTest.java index 4939dab5789..d048137826c 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnCheckerTest.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnCheckerTest.java @@ -132,8 +132,7 @@ public class ReturnCheckerTest extends CheckerTestCase { // } // }; public void testContructor_Bug323602() { - IProblemPreference macro = getPreference(ReturnChecker.RET_NO_VALUE_ID, - ReturnChecker.PARAM_IMPLICIT); + IProblemPreference macro = getPreference(ReturnChecker.RET_NO_VALUE_ID, ReturnChecker.PARAM_IMPLICIT); macro.setValue(Boolean.TRUE); loadCodeAndRunCpp(getAboveComment()); checkNoErrors(); diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnStyleCheckerTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnStyleCheckerTest.java index 3adfc6b00cd..e8d2af590c0 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnStyleCheckerTest.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnStyleCheckerTest.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.codan.core.internal.checkers; import org.eclipse.cdt.codan.core.test.CheckerTestCase; public class ReturnStyleCheckerTest extends CheckerTestCase { - @Override public void setUp() throws Exception { super.setUp(); diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/StatementHasNoEffectCheckerTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/StatementHasNoEffectCheckerTest.java index 7d36d0e5db4..5eee2a5f565 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/StatementHasNoEffectCheckerTest.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/StatementHasNoEffectCheckerTest.java @@ -151,9 +151,7 @@ public class StatementHasNoEffectCheckerTest extends CheckerTestCase { // } @SuppressWarnings("restriction") public void testInMacro() { - IProblemPreference macro = getPreference( - StatementHasNoEffectChecker.ER_ID, - StatementHasNoEffectChecker.PARAM_MACRO_ID); + IProblemPreference macro = getPreference(StatementHasNoEffectChecker.ER_ID, StatementHasNoEffectChecker.PARAM_MACRO_ID); macro.setValue(Boolean.TRUE); loadCodeAndRun(getAboveComment()); checkErrorLine(4); @@ -177,9 +175,7 @@ public class StatementHasNoEffectCheckerTest extends CheckerTestCase { // } @SuppressWarnings("restriction") public void testInMacroParamOff() { - IProblemPreference macro = getPreference( - StatementHasNoEffectChecker.ER_ID, - StatementHasNoEffectChecker.PARAM_MACRO_ID); + IProblemPreference macro = getPreference(StatementHasNoEffectChecker.ER_ID, StatementHasNoEffectChecker.PARAM_MACRO_ID); macro.setValue(Boolean.FALSE); loadCodeAndRun(getAboveComment()); checkNoErrors(); diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/SuggestedParenthesisCheckerTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/SuggestedParenthesisCheckerTest.java index 2fcad7ad081..e988b1c060d 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/SuggestedParenthesisCheckerTest.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/SuggestedParenthesisCheckerTest.java @@ -24,9 +24,7 @@ public class SuggestedParenthesisCheckerTest extends CheckerTestCase { // if (!a<10) b=4; // error here on line 3 // } public void test1() { - IProblemPreference macro = getPreference( - SuggestedParenthesisChecker.ER_ID, - SuggestedParenthesisChecker.PARAM_NOT); + IProblemPreference macro = getPreference(SuggestedParenthesisChecker.ER_ID, SuggestedParenthesisChecker.PARAM_NOT); macro.setValue(Boolean.TRUE); loadCodeAndRun(getAboveComment()); checkErrorLine(3); diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CheckerTestCase.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CheckerTestCase.java index f16c16fd660..beb283f3395 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CheckerTestCase.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CheckerTestCase.java @@ -67,9 +67,7 @@ public class CheckerTestCase extends CodanTestCase { m = markers[j]; line = getLine(m); mfile = m.getResource().getName(); - if (line.equals(expectedLine) - && (problemId == null || problemId - .equals(CodanProblemMarker.getProblemId(m)))) { + if (line.equals(expectedLine) && (problemId == null || problemId.equals(CodanProblemMarker.getProblemId(m)))) { found = true; if (file != null && !file.getName().equals(mfile)) found = false; @@ -111,8 +109,7 @@ public class CheckerTestCase extends CodanTestCase { // all good } else { IMarker m = markers[0]; - fail("Found " + markers.length + " errors but should not. First " - + CodanProblemMarker.getProblemId(m) + " at line " + fail("Found " + markers.length + " errors but should not. First " + CodanProblemMarker.getProblemId(m) + " at line " + getLine(m)); } } @@ -143,16 +140,9 @@ public class CheckerTestCase extends CodanTestCase { * */ protected void runCodan() { - CodanRuntime - .getInstance() - .getBuilder() - .processResource(cproject.getProject(), - new NullProgressMonitor()); + CodanRuntime.getInstance().getBuilder().processResource(cproject.getProject(), new NullProgressMonitor()); try { - markers = cproject.getProject() - .findMarkers( - IProblemReporter.GENERIC_CODE_ANALYSIS_MARKER_TYPE, - true, 1); + markers = cproject.getProject().findMarkers(IProblemReporter.GENERIC_CODE_ANALYSIS_MARKER_TYPE, true, 1); } catch (CoreException e) { fail(e.getMessage()); } @@ -164,16 +154,13 @@ public class CheckerTestCase extends CodanTestCase { * @return */ protected IProblemPreference getPreference(String problemId, String paramId) { - IProblem problem = CodanRuntime.getInstance().getCheckersRegistry() - .getResourceProfile(cproject.getResource()) + IProblem problem = CodanRuntime.getInstance().getCheckersRegistry().getResourceProfile(cproject.getResource()) .findProblem(problemId); - IProblemPreference pref = ((MapProblemPreference) problem - .getPreference()).getChildDescriptor(paramId); + IProblemPreference pref = ((MapProblemPreference) problem.getPreference()).getChildDescriptor(paramId); return pref; } - protected IProblemPreference setPreferenceValue(String problemId, - String paramId, Object value) { + protected IProblemPreference setPreferenceValue(String problemId, String paramId, Object value) { IProblemPreference param = getPreference(problemId, paramId); param.setValue(value); return param; @@ -196,8 +183,7 @@ public class CheckerTestCase extends CodanTestCase { } protected void enableProblems(String... ids) { - IProblemProfile profile = CodanRuntime.getInstance() - .getCheckersRegistry().getWorkspaceProfile(); + IProblemProfile profile = CodanRuntime.getInstance().getCheckersRegistry().getWorkspaceProfile(); IProblem[] problems = profile.getProblems(); for (int i = 0; i < problems.length; i++) { IProblem p = problems[i]; @@ -210,8 +196,7 @@ public class CheckerTestCase extends CodanTestCase { } } } - CodanRuntime.getInstance().getCheckersRegistry() - .updateProfile(cproject.getProject(), profile); + CodanRuntime.getInstance().getCheckersRegistry().updateProfile(cproject.getProject(), profile); return; } } diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanCoreTestActivator.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanCoreTestActivator.java index 94ac5ab8539..4ad8daca883 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanCoreTestActivator.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanCoreTestActivator.java @@ -19,7 +19,6 @@ import org.osgi.framework.BundleContext; public class CodanCoreTestActivator extends Plugin { // The plug-in ID public static final String PLUGIN_ID = "org.eclipse.cdt.codan.core.test"; //$NON-NLS-1$ - // The shared instance private static CodanCoreTestActivator plugin; @@ -31,7 +30,9 @@ public class CodanCoreTestActivator extends Plugin { /* * (non-Javadoc) - * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) + * + * @see + * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) */ @Override public void start(BundleContext context) throws Exception { @@ -41,7 +42,9 @@ public class CodanCoreTestActivator extends Plugin { /* * (non-Javadoc) - * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) + * + * @see + * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) */ @Override public void stop(BundleContext context) throws Exception { @@ -51,7 +54,7 @@ public class CodanCoreTestActivator extends Plugin { /** * Returns the shared instance - * + * * @return the shared instance */ public static CodanCoreTestActivator getDefault() { diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanFastCxxAstTestCase.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanFastCxxAstTestCase.java index b6a488efd42..1bf928bd0a0 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanFastCxxAstTestCase.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanFastCxxAstTestCase.java @@ -57,9 +57,7 @@ public abstract class CodanFastCxxAstTestCase extends TestCase { protected StringBuffer[] getContents(int sections) { try { CodanCoreTestActivator plugin = CodanCoreTestActivator.getDefault(); - return TestSourceReader.getContentsForTest(plugin == null ? null - : plugin.getBundle(), "src", getClass(), getName(), - sections); + return TestSourceReader.getContentsForTest(plugin == null ? null : plugin.getBundle(), "src", getClass(), getName(), sections); } catch (IOException e) { fail(e.getMessage()); return null; @@ -73,18 +71,16 @@ public abstract class CodanFastCxxAstTestCase extends TestCase { /** * @return - * + * */ public IASTTranslationUnit parse(String code) { - return parse(code, isCpp() ? ParserLanguage.CPP : ParserLanguage.C, - true); + return parse(code, isCpp() ? ParserLanguage.CPP : ParserLanguage.C, true); } protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean gcc) { FileContent codeReader = FileContent.create("code.c", code.toCharArray()); IScannerInfo scannerInfo = new ScannerInfo(); - IScanner scanner = AST2BaseTest.createScanner(codeReader, lang, - ParserMode.COMPLETE_PARSE, scannerInfo); + IScanner scanner = AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); ISourceCodeParser parser2 = null; if (lang == ParserLanguage.CPP) { ICPPParserExtensionConfiguration config = null; @@ -92,8 +88,7 @@ public abstract class CodanFastCxxAstTestCase extends TestCase { config = new GPPParserExtensionConfiguration(); else config = new ANSICPPParserExtensionConfiguration(); - parser2 = new GNUCPPSourceParser(scanner, - ParserMode.COMPLETE_PARSE, NULL_LOG, config); + parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config); } else { ICParserExtensionConfiguration config = null; if (gcc) @@ -121,7 +116,7 @@ public abstract class CodanFastCxxAstTestCase extends TestCase { /** * Override if any of code that test tried to parse has errors, otherwise * parse method would assert - * + * * @return */ protected boolean hasCodeErrors() { @@ -152,7 +147,7 @@ public abstract class CodanFastCxxAstTestCase extends TestCase { } void runCodan(IASTTranslationUnit tu) { - IProblemReporter problemReporter = CodanRuntime.getInstance() .getProblemReporter(); + IProblemReporter problemReporter = CodanRuntime.getInstance().getProblemReporter(); CodanRuntime.getInstance().setProblemReporter(new IProblemReporter() { public void reportProblem(String problemId, IProblemLocation loc, Object... args) { codanproblems.add(new ProblemInstance(problemId, loc, args)); diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanTestCase.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanTestCase.java index 3c5aaccd6bb..c4301c907a4 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanTestCase.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanTestCase.java @@ -63,7 +63,7 @@ public class CodanTestCase extends BaseTestCase { /** * Override for c++ (i.e. at least one c++ test) - * + * * @return is c++ tests */ public boolean isCpp() { @@ -82,9 +82,7 @@ public class CodanTestCase extends BaseTestCase { public void tearDown() throws CoreException { if (cproject != null) { try { - cproject.getProject().delete( - IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, - new NullProgressMonitor()); + cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor()); } catch (CoreException e) { throw e; } @@ -100,8 +98,7 @@ public class CodanTestCase extends BaseTestCase { for (int i = 0; i < projects.length; i++) { IProject p = projects[i]; if (p.getName().startsWith("Codan")) { - p.delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, - new NullProgressMonitor()); + p.delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor()); } } } @@ -116,10 +113,8 @@ public class CodanTestCase extends BaseTestCase { workspace.run(new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { // Create the cproject - ICProject cproject = cpp ? CProjectHelper.createCCProject( - projectName, null, IPDOMManager.ID_NO_INDEXER) - : CProjectHelper.createCProject(projectName, null, - IPDOMManager.ID_NO_INDEXER); + ICProject cproject = cpp ? CProjectHelper.createCCProject(projectName, null, IPDOMManager.ID_NO_INDEXER) + : CProjectHelper.createCProject(projectName, null, IPDOMManager.ID_NO_INDEXER); cprojects[0] = cproject; } }, null); @@ -138,8 +133,7 @@ public class CodanTestCase extends BaseTestCase { } }, null); // Index the cproject - CCorePlugin.getIndexManager().setIndexerId(cproject, - IPDOMManager.ID_FAST_INDEXER); + CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER); CCorePlugin.getIndexManager().reindex(cproject); // wait until the indexer is done assertTrue(CCorePlugin.getIndexManager().joinIndexer(1000 * 60, // 1 min @@ -178,8 +172,7 @@ public class CodanTestCase extends BaseTestCase { protected StringBuffer[] getContents(int sections) { try { CodanCoreTestActivator plugin = CodanCoreTestActivator.getDefault(); - return TestSourceReader.getContentsForTest(plugin.getBundle(), - "src", getClass(), getName(), sections); + return TestSourceReader.getContentsForTest(plugin.getBundle(), "src", getClass(), getName(), sections); } catch (IOException e) { fail(e.getMessage()); return null; @@ -194,8 +187,7 @@ public class CodanTestCase extends BaseTestCase { if (sep != -1) { String line = code.substring(0, sep); code = code.substring(sep + 1); - String fileName = line.substring(indf + fileKey.length()) - .trim(); + String fileName = line.substring(indf + fileKey.length()).trim(); return loadcode(code, new File(tmpDir, fileName)); } } @@ -218,8 +210,7 @@ public class CodanTestCase extends BaseTestCase { private File loadcode(String code, File testFile) { try { tempFiles.add(testFile); - TestUtils.saveFile( - new ByteArrayInputStream(code.trim().getBytes()), testFile); + TestUtils.saveFile(new ByteArrayInputStream(code.trim().getBytes()), testFile); currentFile = testFile; try { cproject.getProject().refreshLocal(1, null); diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/TestUtils.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/TestUtils.java index 581cd677e1e..020c60bb21f 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/TestUtils.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/TestUtils.java @@ -24,8 +24,7 @@ import java.net.URL; */ @SuppressWarnings("nls") public class TestUtils { - public static File saveFile(InputStream st, File testFile) - throws FileNotFoundException, IOException { + public static File saveFile(InputStream st, File testFile) throws FileNotFoundException, IOException { BufferedReader r = new BufferedReader(new InputStreamReader(st)); String line; PrintStream wr = new PrintStream(testFile); diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixTestCase.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixTestCase.java index 947a4262516..0782edc5472 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixTestCase.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/QuickFixTestCase.java @@ -57,8 +57,7 @@ public abstract class QuickFixTestCase extends CheckerTestCase { public static void closeWelcome() { try { - IWorkbenchWindow window = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow(); + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchPage activePage = window.getActivePage(); IWorkbenchPart activePart = activePage.getActivePart(); if (activePart.getTitle().equals("Welcome")) { @@ -77,16 +76,14 @@ public abstract class QuickFixTestCase extends CheckerTestCase { quickFix = createQuickFix(); display = PlatformUI.getWorkbench().getDisplay(); closeWelcome(); - IPreferenceStore store = CodanUIActivator.getDefault() - .getPreferenceStore(cproject.getProject()); + IPreferenceStore store = CodanUIActivator.getDefault().getPreferenceStore(cproject.getProject()); // turn off editor reconsiler store.setValue(PreferenceConstants.P_RUN_IN_EDITOR, false); } @Override public void tearDown() throws CoreException { - IWorkbenchPage[] pages = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getPages(); + IWorkbenchPage[] pages = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPages(); for (IWorkbenchPage page : pages) { page.closeAllEditors(false); dispatch(200); @@ -147,7 +144,6 @@ public abstract class QuickFixTestCase extends CheckerTestCase { * @param expected */ public void assertContainedIn(String expected, String result) { - assertTrue( - "Text <" + expected + "> not found in <" + result + ">", result.contains(expected)); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ + assertTrue("Text <" + expected + "> not found in <" + result + ">", result.contains(expected)); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ } } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java index 90e5d83c9a1..9b67ff99154 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java @@ -75,7 +75,7 @@ public class CodanCorePlugin extends Plugin { * Logs the specified status with this plug-in's log. * * @param status - * status to log + * status to log */ public static void log(IStatus status) { getDefault().getLog().log(status); @@ -85,7 +85,7 @@ public class CodanCorePlugin extends Plugin { * Logs an internal error with the specified throwable * * @param e - * the exception to be logged + * the exception to be logged */ public static void log(Throwable e) { log(new Status(IStatus.ERROR, PLUGIN_ID, 1, "Internal Error", e)); //$NON-NLS-1$ @@ -95,7 +95,7 @@ public class CodanCorePlugin extends Plugin { * Logs an internal error with the specified message. * * @param message - * the error message to log + * the error message to log */ public static void log(String message) { log(new Status(IStatus.ERROR, PLUGIN_ID, 1, message, null)); diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java index 063f1809392..24b9e7714c2 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java @@ -56,10 +56,8 @@ public abstract class AbstractChecker implements IChecker { * it will be error message (not recommended because of * internationalization) */ - public void reportProblem(String id, IFile file, int lineNumber, - Object... args) { - getProblemReporter().reportProblem(id, - createProblemLocation(file, lineNumber), args); + public void reportProblem(String id, IFile file, int lineNumber, Object... args) { + getProblemReporter().reportProblem(id, createProblemLocation(file, lineNumber), args); } /** @@ -73,8 +71,7 @@ public abstract class AbstractChecker implements IChecker { * @return problem instance */ public IProblem getProblemById(String id, IResource file) { - IProblem problem = CheckersRegistry.getInstance() - .getResourceProfile(file).findProblem(id); + IProblem problem = CheckersRegistry.getInstance().getResourceProfile(file).findProblem(id); if (problem == null) throw new IllegalArgumentException("Id is not registered"); //$NON-NLS-1$ return problem; @@ -92,8 +89,7 @@ public abstract class AbstractChecker implements IChecker { * - line */ public void reportProblem(String id, IFile file, int lineNumber) { - getProblemReporter().reportProblem(id, - createProblemLocation(file, lineNumber), new Object[] {}); + getProblemReporter().reportProblem(id, createProblemLocation(file, lineNumber), new Object[] {}); } /** @@ -127,8 +123,7 @@ public abstract class AbstractChecker implements IChecker { * @return instance of IProblemLocation */ protected IProblemLocation createProblemLocation(IFile file, int line) { - return getRuntime().getProblemLocationFactory().createProblemLocation( - file, line); + return getRuntime().getProblemLocationFactory().createProblemLocation(file, line); } /** @@ -143,10 +138,8 @@ public abstract class AbstractChecker implements IChecker { * exclusive. * @return instance of IProblemLocation */ - protected IProblemLocation createProblemLocation(IFile file, int startChar, - int endChar) { - return getRuntime().getProblemLocationFactory().createProblemLocation( - file, startChar, endChar); + protected IProblemLocation createProblemLocation(IFile file, int startChar, int endChar) { + return getRuntime().getProblemLocationFactory().createProblemLocation(file, startChar, endChar); } /** @@ -164,8 +157,7 @@ public abstract class AbstractChecker implements IChecker { * @param loc - problem location * @param args - extra problem arguments */ - public void reportProblem(String problemId, IProblemLocation loc, - Object... args) { + public void reportProblem(String problemId, IProblemLocation loc, Object... args) { getProblemReporter().reportProblem(problemId, loc, args); } @@ -196,23 +188,19 @@ public abstract class AbstractChecker implements IChecker { */ public boolean before(IResource resource) { IChecker checker = this; - IProblemReporter problemReporter = CodanRuntime.getInstance() - .getProblemReporter(); + IProblemReporter problemReporter = CodanRuntime.getInstance().getProblemReporter(); IProblemReporter sessionReporter = problemReporter; if (problemReporter instanceof IProblemReporterSessionPersistent) { // create session problem reporter - sessionReporter = ((IProblemReporterSessionPersistent) problemReporter) - .createReporter(resource, checker); + sessionReporter = ((IProblemReporterSessionPersistent) problemReporter).createReporter(resource, checker); ((IProblemReporterSessionPersistent) sessionReporter).start(); } else if (problemReporter instanceof IProblemReporterPersistent) { // delete markers if checker can possibly run on this // resource this way if checker is not enabled markers would be // deleted too - ((IProblemReporterPersistent) problemReporter).deleteProblems( - resource, checker); + ((IProblemReporterPersistent) problemReporter).deleteProblems(resource, checker); } - ((AbstractChecker) checker).setContext(new CheckerInvocationContext( - resource, sessionReporter)); + ((AbstractChecker) checker).setContext(new CheckerInvocationContext(resource, sessionReporter)); return true; } @@ -222,8 +210,7 @@ public abstract class AbstractChecker implements IChecker { public boolean after(IResource resource) { if (getContext().getProblemReporter() instanceof IProblemReporterSessionPersistent) { // delete general markers - ((IProblemReporterSessionPersistent) getContext() - .getProblemReporter()).done(); + ((IProblemReporterSessionPersistent) getContext().getProblemReporter()).done(); } return true; } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractCheckerWithProblemPreferences.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractCheckerWithProblemPreferences.java index 80efe393f4f..4a01cff2612 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractCheckerWithProblemPreferences.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractCheckerWithProblemPreferences.java @@ -29,8 +29,7 @@ import org.eclipse.core.runtime.IPath; * Checker can produce several problems, but preferences are per problem. * Sharing preferences between problems is not supported now. */ -public abstract class AbstractCheckerWithProblemPreferences extends - AbstractChecker implements ICheckerWithPreferences { +public abstract class AbstractCheckerWithProblemPreferences extends AbstractChecker implements ICheckerWithPreferences { /** * Checker that actually has parameter must override this */ @@ -47,8 +46,8 @@ public abstract class AbstractCheckerWithProblemPreferences extends * @return scope problem preference, null if not defined */ public FileScopeProblemPreference getScopePreference(IProblem problem) { - FileScopeProblemPreference scope = (FileScopeProblemPreference) getTopLevelPreferenceMap( - problem).getChildDescriptor(FileScopeProblemPreference.KEY); + FileScopeProblemPreference scope = (FileScopeProblemPreference) getTopLevelPreferenceMap(problem).getChildDescriptor( + FileScopeProblemPreference.KEY); return scope; } @@ -63,14 +62,10 @@ public abstract class AbstractCheckerWithProblemPreferences extends * @return true if checker should report problems, fails otherwise. */ public boolean shouldProduceProblems(IResource res) { - Collection refProblems = getRuntime().getCheckersRegistry() - .getRefProblems(this); - for (Iterator iterator = refProblems.iterator(); iterator - .hasNext();) { + Collection refProblems = getRuntime().getCheckersRegistry().getRefProblems(this); + for (Iterator iterator = refProblems.iterator(); iterator.hasNext();) { IProblem checkerProblem = iterator.next(); - if (shouldProduceProblem( - getProblemById(checkerProblem.getId(), res), - res.getLocation())) + if (shouldProduceProblem(getProblemById(checkerProblem.getId(), res), res.getLocation())) return true; } return false; @@ -99,10 +94,8 @@ public abstract class AbstractCheckerWithProblemPreferences extends } @Override - public void reportProblem(String problemId, IProblemLocation loc, - Object... args) { - if (shouldProduceProblem(getProblemById(problemId, loc.getFile()), loc - .getFile().getLocation())) + public void reportProblem(String problemId, IProblemLocation loc, Object... args) { + if (shouldProduceProblem(getProblemById(problemId, loc.getFile()), loc.getFile().getLocation())) super.reportProblem(problemId, loc, args); } @@ -119,11 +112,9 @@ public abstract class AbstractCheckerWithProblemPreferences extends * - parameter default value * @return - parameter info object */ - public IProblemPreference addPreference(IProblemWorkingCopy problem, - String key, String label, Object defaultValue) { + public IProblemPreference addPreference(IProblemWorkingCopy problem, String key, String label, Object defaultValue) { MapProblemPreference map = getTopLevelPreferenceMap(problem); - BasicProblemPreference info = new BasicProblemPreference(key, label, - PreferenceType.typeOf(defaultValue)); + BasicProblemPreference info = new BasicProblemPreference(key, label, PreferenceType.typeOf(defaultValue)); map.addChildDescriptor(info); setDefaultPreferenceValue(problem, key, defaultValue); return info; @@ -144,12 +135,10 @@ public abstract class AbstractCheckerWithProblemPreferences extends * values or set different element type * */ - public ListProblemPreference addListPreference(IProblemWorkingCopy problem, - String key, String label, String itemLabel) { + public ListProblemPreference addListPreference(IProblemWorkingCopy problem, String key, String label, String itemLabel) { MapProblemPreference map = getTopLevelPreferenceMap(problem); ListProblemPreference list = new ListProblemPreference(key, label); - list.setChildDescriptor(new BasicProblemPreference( - ListProblemPreference.COMMON_DESCRIPTOR_KEY, itemLabel, + list.setChildDescriptor(new BasicProblemPreference(ListProblemPreference.COMMON_DESCRIPTOR_KEY, itemLabel, PreferenceType.TYPE_STRING)); return (ListProblemPreference) map.addChildDescriptor(list); } @@ -162,8 +151,7 @@ public abstract class AbstractCheckerWithProblemPreferences extends * @param defaultValue - default value of the preference * @return added preference */ - public IProblemPreference addPreference(IProblemWorkingCopy problem, - IProblemPreference pref, Object defaultValue) { + public IProblemPreference addPreference(IProblemWorkingCopy problem, IProblemPreference pref, Object defaultValue) { MapProblemPreference map = getTopLevelPreferenceMap(problem); String key = pref.getKey(); pref = map.addChildDescriptor(pref); @@ -179,8 +167,7 @@ public abstract class AbstractCheckerWithProblemPreferences extends * @param key - preference key * @param defaultValue - value of preference to be set */ - protected void setDefaultPreferenceValue(IProblemWorkingCopy problem, - String key, Object defaultValue) { + protected void setDefaultPreferenceValue(IProblemWorkingCopy problem, String key, Object defaultValue) { MapProblemPreference map = getTopLevelPreferenceMap(problem); if (map.getChildValue(key) == null) map.setChildValue(key, defaultValue); @@ -197,8 +184,7 @@ public abstract class AbstractCheckerWithProblemPreferences extends * @return top level preference if it is a map */ protected MapProblemPreference getTopLevelPreferenceMap(IProblem problem) { - MapProblemPreference map = (MapProblemPreference) problem - .getPreference(); + MapProblemPreference map = (MapProblemPreference) problem.getPreference(); if (map == null) { map = new MapProblemPreference(AbstractProblemPreference.PARAM, ""); //$NON-NLS-1$ if (problem instanceof IProblemWorkingCopy) { @@ -217,8 +203,7 @@ public abstract class AbstractCheckerWithProblemPreferences extends * @return value of the preference */ public Object getPreference(IProblem problem, String key) { - return ((MapProblemPreference) problem.getPreference()) - .getChildValue(key); + return ((MapProblemPreference) problem.getPreference()).getChildValue(key); } /** @@ -229,8 +214,7 @@ public abstract class AbstractCheckerWithProblemPreferences extends * @return true if argument matches of the names in the exception list * @since 2.0 */ - public boolean isFilteredArg(String arg, IProblem problem, - String exceptionListParamId) { + public boolean isFilteredArg(String arg, IProblem problem, String exceptionListParamId) { Object[] arr = (Object[]) getPreference(problem, exceptionListParamId); for (int i = 0; i < arr.length; i++) { String str = (String) arr[i]; diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractProblemReporter.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractProblemReporter.java index 1dc13b027e2..366fa6d1fd1 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractProblemReporter.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractProblemReporter.java @@ -26,14 +26,12 @@ public abstract class AbstractProblemReporter implements IProblemReporter { throw new NullPointerException("file"); //$NON-NLS-1$ if (id == null) throw new NullPointerException("id"); //$NON-NLS-1$ - IProblem problem = CheckersRegistry.getInstance() - .getResourceProfile(file).findProblem(id); + IProblem problem = CheckersRegistry.getInstance().getResourceProfile(file).findProblem(id); if (problem == null) throw new IllegalArgumentException("Id is not registered:" + id); //$NON-NLS-1$ if (problem.isEnabled() == false) return; // skip - ICodanProblemMarker codanProblemMarker = new CodanProblemMarker( - problem, loc, args); + ICodanProblemMarker codanProblemMarker = new CodanProblemMarker(problem, loc, args); reportProblem(codanProblemMarker); } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java index 04189aed4be..a4a0f56dc0b 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java @@ -59,8 +59,7 @@ public interface ICheckersRegistry extends Iterable { * @param parentCategoryId * - parent category id */ - public abstract void addCategory(IProblemCategory category, - String parentCategoryId); + public abstract void addCategory(IProblemCategory category, String parentCategoryId); /** * Add problem reference to a checker, i.e. claim that checker can produce diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java index 6db3ea93a69..07a237ae833 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java @@ -20,20 +20,20 @@ import org.eclipse.cdt.codan.core.param.IProblemPreference; * determined by runtime. If it is the case - two Problems should be created * (i.e. one for error and one for warning). All of problem attributes are * defined in a checker extension point. - * + * *

    * EXPERIMENTAL. This class or interface has been added as part * of a work in progress. There is no guarantee that this API will work or that * it will remain the same. *

    - * + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface IProblem extends IProblemElement { /** * Name of the problem - user visible "title", not the message - * + * * @return title of the problem */ String getName(); @@ -41,7 +41,7 @@ public interface IProblem extends IProblemElement { /** * Unique problem id. Should be qualified by plugin name to maintain * uniqueness. - * + * * @return unique problem id */ String getId(); @@ -49,21 +49,21 @@ public interface IProblem extends IProblemElement { /** * Returns true if the problem is enabled in current context * (usually within profile) - * + * * @return true if enabled */ boolean isEnabled(); /** * Returns current severity - * + * * @return severity */ CodanSeverity getSeverity(); /** * Message pattern, java patter like 'Variable {0} is never used here' - * + * * @return pattern */ String getMessagePattern(); @@ -71,21 +71,21 @@ public interface IProblem extends IProblemElement { /** * Returns root preference descriptor or null if not defined (used by UI to * generate user controls for changing parameters) - * + * * @return root preference or null */ public IProblemPreference getPreference(); /** * Returns short description of a problem - * + * * @return description */ public String getDescription(); /** * Returns marker id for the problem - * + * * @return marker id */ public String getMarkerType(); diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemElement.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemElement.java index 3068aeb36d4..d0dc3611125 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemElement.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemElement.java @@ -11,7 +11,7 @@ package org.eclipse.cdt.codan.core.model; /** - * Problem category {@link IProblemCategory} or problem {@link IProblem} + * Problem category {@link IProblemCategory} or problem {@link IProblem} * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. @@ -19,9 +19,11 @@ package org.eclipse.cdt.codan.core.model; public interface IProblemElement extends Cloneable { /** * clone method should be implemented to support problem cloning + * * @see {@link Object#clone} * @return new object which is copy of this one - * @throws CloneNotSupportedException - it is declared with this exception but it should NOT throw it + * @throws CloneNotSupportedException - it is declared with this exception + * but it should NOT throw it */ Object clone() throws CloneNotSupportedException; } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocationFactory.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocationFactory.java index 4710bb12f02..76c6cc63fca 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocationFactory.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocationFactory.java @@ -46,8 +46,7 @@ public interface IProblemLocationFactory { * exclusive. * @return instance of IProblemLocation */ - public IProblemLocation createProblemLocation(IFile file, int startChar, - int endChar); + public IProblemLocation createProblemLocation(IFile file, int startChar, int endChar); /** * Create and return instance of IProblemLocation @@ -55,13 +54,13 @@ public interface IProblemLocationFactory { * @param astFile - file where problem is found * @param startChar - start char of the problem in the file, is * zero-relative - * @param endChar - end char of the problem in the file, is zero-relative and + * @param endChar - end char of the problem in the file, is zero-relative + * and * exclusive. * * @param line * - start line number (for visualisation purposes) * @return instance of IProblemLocation */ - public IProblemLocation createProblemLocation(IFile astFile, - int startChar, int endChar, int line); + public IProblemLocation createProblemLocation(IFile astFile, int startChar, int endChar, int line); } \ No newline at end of file diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java index 48327a1a360..7a22c8280ab 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java @@ -38,6 +38,5 @@ public interface IProblemReporter { * @param args - custom arguments, can be none, in this case default message * is reported */ - public void reportProblem(String problemId, IProblemLocation loc, - Object... args); + public void reportProblem(String problemId, IProblemLocation loc, Object... args); } \ No newline at end of file diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporterSessionPersistent.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporterSessionPersistent.java index edf7a63bab0..6b86914eb59 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporterSessionPersistent.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporterSessionPersistent.java @@ -61,6 +61,5 @@ public interface IProblemReporterSessionPersistent extends IProblemReporter { * @return * @since 2.0 */ - public IProblemReporterSessionPersistent createReporter(IResource resource, - IChecker checker); + public IProblemReporterSessionPersistent createReporter(IResource resource, IChecker checker); } \ No newline at end of file diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemWorkingCopy.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemWorkingCopy.java index d28bd5dd1e7..d74d19ffc1c 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemWorkingCopy.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemWorkingCopy.java @@ -14,13 +14,13 @@ import org.eclipse.cdt.codan.core.param.IProblemPreference; /** * Modifiable problem. - * + * *

    * EXPERIMENTAL. This class or interface has been added as part * of a work in progress. There is no guarantee that this API will work or that * it will remain the same. *

    - * + * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ @@ -28,14 +28,14 @@ public interface IProblemWorkingCopy extends IProblem { /** * Set severity for this this problem instance. Severity can only be changed * in profile not by checker when printing problems. - * + * * @param sev - codan severity */ void setSeverity(CodanSeverity sev); /** * Sets checker enablement. - * + * * @param enabled - true if problem is enabled in profile */ void setEnabled(boolean enabled); @@ -44,8 +44,9 @@ public interface IProblemWorkingCopy extends IProblem { * Sets default message pattern. UI would call this method if user does not * like default settings, checker should not use method, default message * pattern should be set in checker extension - * - * @param messagePattern - java style message patter, e.g. "Variable {0} is never used". + * + * @param messagePattern - java style message patter, e.g. + * "Variable {0} is never used". */ void setMessagePattern(String messagePattern); @@ -53,15 +54,15 @@ public interface IProblemWorkingCopy extends IProblem { * Sets value for the checker parameter, checker may set value during * initialization only, which would the default. User control this values * through ui later. - * + * * @param pref - preference to set - * + * */ public void setPreference(IProblemPreference pref); /** * Sets problem description - * + * * @param desc - problem description - short version, but longer than name */ public void setDescription(String desc); diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IBranchNode.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IBranchNode.java index 77e7fb38791..ec0005df95c 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IBranchNode.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IBranchNode.java @@ -16,8 +16,7 @@ package org.eclipse.cdt.codan.core.model.cfg; * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ -public interface IBranchNode extends IBasicBlock, ISingleIncoming, - ISingleOutgoing { +public interface IBranchNode extends IBasicBlock, ISingleIncoming, ISingleOutgoing { /** * Then branch of "if" statement */ diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IPlainNode.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IPlainNode.java index fac55996583..61932404868 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IPlainNode.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IPlainNode.java @@ -17,6 +17,5 @@ package org.eclipse.cdt.codan.core.model.cfg; * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ -public interface IPlainNode extends IBasicBlock, ISingleOutgoing, - ISingleIncoming { +public interface IPlainNode extends IBasicBlock, ISingleOutgoing, ISingleIncoming { } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/AbstractProblemPreference.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/AbstractProblemPreference.java index 91969fcc225..b45b68a2904 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/AbstractProblemPreference.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/AbstractProblemPreference.java @@ -58,8 +58,7 @@ public abstract class AbstractProblemPreference implements IProblemPreference { if (isValidIdentifier(key)) this.key = key; else - throw new IllegalArgumentException( - "Key must have java identifier syntax or number, i.e no dots and other funky stuff: " + key); //$NON-NLS-1$ + throw new IllegalArgumentException("Key must have java identifier syntax or number, i.e no dots and other funky stuff: " + key); //$NON-NLS-1$ } protected boolean isValidIdentifier(String id) { @@ -128,8 +127,7 @@ public abstract class AbstractProblemPreference implements IProblemPreference { */ protected StreamTokenizer getImportTokenizer(String str) { ByteArrayInputStream st = new ByteArrayInputStream(str.getBytes()); - StreamTokenizer tokenizer = new StreamTokenizer(new InputStreamReader( - st)); + StreamTokenizer tokenizer = new StreamTokenizer(new InputStreamReader(st)); tokenizer.resetSyntax(); tokenizer.quoteChar('"'); tokenizer.wordChars('_', '_'); @@ -166,8 +164,7 @@ public abstract class AbstractProblemPreference implements IProblemPreference { * @param tokenizer * @throws IOException */ - public abstract void importValue(StreamTokenizer tokenizer) - throws IOException; + public abstract void importValue(StreamTokenizer tokenizer) throws IOException; public void importValue(String str) { StreamTokenizer tokenizer = getImportTokenizer(str); diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/BasicProblemPreference.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/BasicProblemPreference.java index 7c61f4dc2d4..d38f1912a14 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/BasicProblemPreference.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/BasicProblemPreference.java @@ -111,8 +111,7 @@ public class BasicProblemPreference extends AbstractProblemPreference { setValue(new File(str)); break; default: - throw new IllegalArgumentException(getType() - + " is not supported for basic type"); //$NON-NLS-1$ + throw new IllegalArgumentException(getType() + " is not supported for basic type"); //$NON-NLS-1$ } } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/FileScopeProblemPreference.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/FileScopeProblemPreference.java index bdb36f01c91..1f2206b3df6 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/FileScopeProblemPreference.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/FileScopeProblemPreference.java @@ -148,22 +148,19 @@ public class FileScopeProblemPreference extends AbstractProblemPreference { exclusion = exc.toArray(new IPath[exc.size()]); } - private void checkChar(StreamTokenizer tokenizer, char c) - throws IOException { + private void checkChar(StreamTokenizer tokenizer, char c) throws IOException { tokenizer.nextToken(); if (tokenizer.ttype != c) throw new IllegalArgumentException("Expected " + c); //$NON-NLS-1$ } - private void checkKeyword(StreamTokenizer tokenizer, String keyword) - throws IOException { + private void checkKeyword(StreamTokenizer tokenizer, String keyword) throws IOException { tokenizer.nextToken(); if (tokenizer.sval == null || !tokenizer.sval.equals(keyword)) throw new IllegalArgumentException("Expected " + keyword); //$NON-NLS-1$ } - protected List importPathList(StreamTokenizer tokenizer, - String keyword) throws IOException { + protected List importPathList(StreamTokenizer tokenizer, String keyword) throws IOException { checkKeyword(tokenizer, keyword); checkChar(tokenizer, '='); checkChar(tokenizer, '>'); @@ -217,8 +214,7 @@ public class FileScopeProblemPreference extends AbstractProblemPreference { */ @Override public Object clone() { - FileScopeProblemPreference scope = (FileScopeProblemPreference) super - .clone(); + FileScopeProblemPreference scope = (FileScopeProblemPreference) super.clone(); scope.setValue(this); return scope; } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/IProblemPreference.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/IProblemPreference.java index 6b0c3168190..3d73d09d919 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/IProblemPreference.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/IProblemPreference.java @@ -22,6 +22,5 @@ package org.eclipse.cdt.codan.core.param; * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ -public interface IProblemPreference extends Cloneable, IProblemPreferenceValue, - IProblemPreferenceDescriptor { +public interface IProblemPreference extends Cloneable, IProblemPreferenceValue, IProblemPreferenceDescriptor { } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/LaunchTypeProblemPreference.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/LaunchTypeProblemPreference.java index 33024d982a4..c283ee0a882 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/LaunchTypeProblemPreference.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/LaunchTypeProblemPreference.java @@ -35,8 +35,7 @@ public class LaunchTypeProblemPreference extends MapProblemPreference { CheckerLaunchMode[] values = CheckerLaunchMode.values(); for (int i = 0; i < values.length; i++) { CheckerLaunchMode checkerLaunchMode = values[i]; - BasicProblemPreference desc = new BasicProblemPreference( - checkerLaunchMode.name(), checkerLaunchMode.name(), + BasicProblemPreference desc = new BasicProblemPreference(checkerLaunchMode.name(), checkerLaunchMode.name(), PreferenceType.TYPE_BOOLEAN); IProblemPreference desc1 = addChildDescriptor(desc); if (checkerLaunchMode == CheckerLaunchMode.USE_PARENT) diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/ListProblemPreference.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/ListProblemPreference.java index 333cb3132fc..28d46f6fa29 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/ListProblemPreference.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/ListProblemPreference.java @@ -21,8 +21,8 @@ import java.util.Iterator; * * @noextend This class is not intended to be extended by clients. */ -public class ListProblemPreference extends AbstractProblemPreference implements - IProblemPreferenceCompositeValue, IProblemPreferenceCompositeDescriptor { +public class ListProblemPreference extends AbstractProblemPreference implements IProblemPreferenceCompositeValue, + IProblemPreferenceCompositeDescriptor { /** * Constant that represent a key for "shared" child preference (descriptor) * of all elements @@ -57,8 +57,7 @@ public class ListProblemPreference extends AbstractProblemPreference implements childDescriptor = desc; if (desc != null) { childDescriptor.setValue(null); - ((AbstractProblemPreference) childDescriptor) - .setKey(COMMON_DESCRIPTOR_KEY); + ((AbstractProblemPreference) childDescriptor).setKey(COMMON_DESCRIPTOR_KEY); } return desc; } @@ -95,8 +94,7 @@ public class ListProblemPreference extends AbstractProblemPreference implements */ public IProblemPreference getChildDescriptor(int i) { Object value = list.get(i); - AbstractProblemPreference desc = (AbstractProblemPreference) childDescriptor - .clone(); + AbstractProblemPreference desc = (AbstractProblemPreference) childDescriptor.clone(); desc.setKey(String.valueOf(i)); desc.setValue(value); return desc; @@ -109,8 +107,7 @@ public class ListProblemPreference extends AbstractProblemPreference implements * @throws NumberFormatException * if key is not number */ - public IProblemPreference getChildDescriptor(String key) - throws NumberFormatException { + public IProblemPreference getChildDescriptor(String key) throws NumberFormatException { if (key == null || key.equals(COMMON_DESCRIPTOR_KEY)) { // return common descriptor return getChildDescriptor(); @@ -118,8 +115,7 @@ public class ListProblemPreference extends AbstractProblemPreference implements Integer iv = Integer.valueOf(key); if (iv.intValue() >= list.size()) { // create one - AbstractProblemPreference clone = (AbstractProblemPreference) childDescriptor - .clone(); + AbstractProblemPreference clone = (AbstractProblemPreference) childDescriptor.clone(); clone.setKey(key); return clone; } @@ -193,8 +189,7 @@ public class ListProblemPreference extends AbstractProblemPreference implements public Object clone() { ListProblemPreference list1 = (ListProblemPreference) super.clone(); list1.list = new ArrayList(); - list1.setChildDescriptor((IProblemPreference) getChildDescriptor() - .clone()); + list1.setChildDescriptor((IProblemPreference) getChildDescriptor().clone()); for (Iterator iterator = list.iterator(); iterator.hasNext();) { Object value = iterator.next(); list1.addChildValue(value); diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/MapProblemPreference.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/MapProblemPreference.java index fffc89de0e2..7a3e36ba245 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/MapProblemPreference.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/param/MapProblemPreference.java @@ -30,8 +30,8 @@ import org.eclipse.cdt.codan.core.model.AbstractCheckerWithProblemPreferences; * * @noextend This class is not intended to be extended by clients. */ -public class MapProblemPreference extends AbstractProblemPreference implements - IProblemPreferenceCompositeValue, IProblemPreferenceCompositeDescriptor { +public class MapProblemPreference extends AbstractProblemPreference implements IProblemPreferenceCompositeValue, + IProblemPreferenceCompositeDescriptor { protected LinkedHashMap hash = new LinkedHashMap(); /** @@ -84,8 +84,7 @@ public class MapProblemPreference extends AbstractProblemPreference implements * values. */ public IProblemPreference[] getChildDescriptors() { - return hash.values().toArray( - new IProblemPreference[hash.values().size()]); + return hash.values().toArray(new IProblemPreference[hash.values().size()]); } /** @@ -119,8 +118,7 @@ public class MapProblemPreference extends AbstractProblemPreference implements public Object clone() { MapProblemPreference map = (MapProblemPreference) super.clone(); map.hash = new LinkedHashMap(); - for (Iterator iterator = hash.keySet().iterator(); iterator - .hasNext();) { + for (Iterator iterator = hash.keySet().iterator(); iterator.hasNext();) { String key = iterator.next(); map.hash.put(key, (IProblemPreference) hash.get(key).clone()); } @@ -129,8 +127,7 @@ public class MapProblemPreference extends AbstractProblemPreference implements public String exportValue() { StringBuffer buf = new StringBuffer("{"); //$NON-NLS-1$ - for (Iterator iterator = hash.keySet().iterator(); iterator - .hasNext();) { + for (Iterator iterator = hash.keySet().iterator(); iterator.hasNext();) { String key = iterator.next(); IProblemPreference d = hash.get(key); buf.append(key + "=>" + d.exportValue()); //$NON-NLS-1$ @@ -166,12 +163,10 @@ public class MapProblemPreference extends AbstractProblemPreference implements String key = tokenizer.sval; token = tokenizer.nextToken(); if (token != '=') - throw new IllegalArgumentException( - String.valueOf((char) token)); + throw new IllegalArgumentException(String.valueOf((char) token)); token = tokenizer.nextToken(); if (token != '>') - throw new IllegalArgumentException( - String.valueOf((char) token)); + throw new IllegalArgumentException(String.valueOf((char) token)); IProblemPreference desc = getChildDescriptor(key); if (desc == null && LaunchTypeProblemPreference.KEY.equals(key)) { desc = new LaunchTypeProblemPreference(); @@ -185,8 +180,7 @@ public class MapProblemPreference extends AbstractProblemPreference implements if (token == '}') break; if (token != ',') - throw new IllegalArgumentException( - String.valueOf((char) token)); + throw new IllegalArgumentException(String.valueOf((char) token)); } } catch (IOException e) { throw new IllegalArgumentException(e); @@ -227,8 +221,7 @@ public class MapProblemPreference extends AbstractProblemPreference implements @Override public Object getValue() { LinkedHashMap map = new LinkedHashMap(); - for (Iterator iterator = hash.values().iterator(); iterator - .hasNext();) { + for (Iterator iterator = hash.values().iterator(); iterator.hasNext();) { IProblemPreference pref = iterator.next(); map.put(pref.getKey(), pref.getValue()); } @@ -247,11 +240,9 @@ public class MapProblemPreference extends AbstractProblemPreference implements @Override public void setValue(Object value) { Map map = (Map) value; - LinkedHashMap hash2 = (LinkedHashMap) hash - .clone(); + LinkedHashMap hash2 = (LinkedHashMap) hash.clone(); hash.clear(); - for (Iterator iterator = map.keySet().iterator(); iterator - .hasNext();) { + for (Iterator iterator = map.keySet().iterator(); iterator.hasNext();) { String key = iterator.next(); Object value2 = map.get(key); if (value2 instanceof IProblemPreference) { diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CharOperation.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CharOperation.java index 7790814b2b6..3f18645a1c0 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CharOperation.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CharOperation.java @@ -46,9 +46,9 @@ public final class CharOperation { * * * @param array - * the array that is concanated with the suffix character + * the array that is concanated with the suffix character * @param suffix - * the suffix character + * the suffix character * @return the new array */ public static final char[] append(char[] array, char suffix) { @@ -97,28 +97,26 @@ public final class CharOperation { * * * @param target - * the given target + * the given target * @param index - * the given index + * the given index * @param array - * the given array + * the given array * @param start - * the given start index + * the given start index * @param end - * the given end index + * the given end index * * @return the new array * @throws NullPointerException - * if the target array is null + * if the target array is null */ - public static final char[] append(char[] target, int index, char[] array, - int start, int end) { + public static final char[] append(char[] target, int index, char[] array, int start, int end) { int targetLength = target.length; int subLength = end - start; int newTargetLength = subLength + index; if (newTargetLength > targetLength) { - System.arraycopy(target, 0, target = new char[newTargetLength * 2], - 0, index); + System.arraycopy(target, 0, target = new char[newTargetLength * 2], 0, index); } System.arraycopy(array, start, target, index, subLength); return target; @@ -160,9 +158,9 @@ public final class CharOperation { * * * @param first - * the first array to concatenate + * the first array to concatenate * @param second - * the second array to concatenate + * the second array to concatenate * @return the concatenation of the two arrays, or null if the two arrays * are null. */ @@ -209,9 +207,9 @@ public final class CharOperation { * * * @param first - * the first array to concatenate + * the first array to concatenate * @param second - * the array to add at the end of the first array + * the array to add at the end of the first array * @return a new array adding the second array at the end of first array, or * null if the two arrays are null. */ @@ -280,12 +278,12 @@ public final class CharOperation { *

    * * @param array - * the given array + * the given array * @param prefix - * the given prefix + * the given prefix * @return the result of the comparison * @exception NullPointerException - * if either array or prefix is null + * if either array or prefix is null */ public static final int compareWith(char[] array, char[] prefix) { int arrayLength = array.length; @@ -333,9 +331,9 @@ public final class CharOperation { * * * @param first - * the first array to concatenate + * the first array to concatenate * @param second - * the second array to concatenate + * the second array to concatenate * @return the concatenation of the two arrays, or null if the two arrays * are null. */ @@ -400,11 +398,11 @@ public final class CharOperation { * * * @param first - * the first array to concatenate + * the first array to concatenate * @param second - * the second array to concatenate + * the second array to concatenate * @param third - * the third array to concatenate + * the third array to concatenate * * @return the concatenation of the three arrays, or null if the three * arrays are null. @@ -460,17 +458,16 @@ public final class CharOperation { * * * @param first - * the first array to concatenate + * the first array to concatenate * @param second - * the second array to concatenate + * the second array to concatenate * @param separator - * the character to insert + * the character to insert * @return the concatenation of the two arrays inserting the separator * character * between the two arrays , or null if the two arrays are null. */ - public static final char[] concat(char[] first, char[] second, - char separator) { + public static final char[] concat(char[] first, char[] second, char separator) { if (first == null) return second; if (second == null) @@ -545,21 +542,20 @@ public final class CharOperation { * * * @param first - * the first array to concatenate + * the first array to concatenate * @param sep1 - * the character to insert + * the character to insert * @param second - * the second array to concatenate + * the second array to concatenate * @param sep2 - * the character to insert + * the character to insert * @param third - * the second array to concatenate + * the second array to concatenate * @return the concatenation of the three arrays inserting the sep1 * character between the * two arrays and sep2 between the last two. */ - public static final char[] concat(char[] first, char sep1, char[] second, - char sep2, char[] third) { + public static final char[] concat(char[] first, char sep1, char[] second, char sep2, char[] third) { if (first == null) return concat(second, third, sep2); if (second == null) @@ -604,12 +600,12 @@ public final class CharOperation { * * * @param prefix - * the prefix character + * the prefix character * @param array - * the array that is concanated with the prefix and suffix - * characters + * the array that is concanated with the prefix and suffix + * characters * @param suffix - * the suffix character + * the suffix character * @return the new array */ public static final char[] concat(char prefix, char[] array, char suffix) { @@ -653,17 +649,16 @@ public final class CharOperation { * * * @param name - * the given name + * the given name * @param array - * the given array + * the given array * @param separator - * the given separator + * the given separator * @return the concatenation of the given array parts using the given * separator between each * part and appending the given name at the end */ - public static final char[] concatWith(char[] name, char[][] array, - char separator) { + public static final char[] concatWith(char[] name, char[][] array, char separator) { int nameLength = name == null ? 0 : name.length; if (nameLength == 0) return concatWith(array, separator); @@ -721,17 +716,16 @@ public final class CharOperation { * * * @param array - * the given array + * the given array * @param name - * the given name + * the given name * @param separator - * the given separator + * the given separator * @return the concatenation of the given array parts using the given * separator between each * part and appending the given name at the end */ - public static final char[] concatWith(char[][] array, char[] name, - char separator) { + public static final char[] concatWith(char[][] array, char[] name, char separator) { int nameLength = name == null ? 0 : name.length; if (nameLength == 0) return concatWith(array, separator); @@ -780,9 +774,9 @@ public final class CharOperation { * * * @param array - * the given array + * the given array * @param separator - * the given separator + * the given separator * @return the concatenation of the given array parts using the given * separator between each part */ @@ -807,8 +801,7 @@ public final class CharOperation { while (--index >= 0) { length = array[index].length; if (length > 0) { - System.arraycopy(array[index], 0, result, (size -= length), - length); + System.arraycopy(array[index], 0, result, (size -= length), length); if (--size >= 0) result[size] = separator; } @@ -839,13 +832,13 @@ public final class CharOperation { * * * @param character - * the character to search + * the character to search * @param array - * the array in which the search is done + * the array in which the search is done * @return true if the array contains an occurrence of character, false * otherwise. * @exception NullPointerException - * if array is null. + * if array is null. */ public static final boolean contains(char character, char[][] array) { for (int i = array.length; --i >= 0;) { @@ -880,13 +873,13 @@ public final class CharOperation { * * * @param character - * the character to search + * the character to search * @param array - * the array in which the search is done + * the array in which the search is done * @return true if the array contains an occurrence of character, false * otherwise. * @exception NullPointerException - * if array is null. + * if array is null. */ public static final boolean contains(char character, char[] array) { for (int i = array.length; --i >= 0;) @@ -899,7 +892,7 @@ public final class CharOperation { * Answers a deep copy of the toCopy array. * * @param toCopy - * the array to copy + * the array to copy * @return a deep copy of the toCopy array. */ public static final char[][] deepCopy(char[][] toCopy) { @@ -938,14 +931,14 @@ public final class CharOperation { * * * @param array - * the array to check + * the array to check * @param toBeFound - * the array to find + * the array to find * @return true if array ends with the sequence of characters contained in * toBeFound, * otherwise false. * @exception NullPointerException - * if array is null or toBeFound is null + * if array is null or toBeFound is null */ public static final boolean endsWith(char[] array, char[] toBeFound) { int i = toBeFound.length; @@ -993,9 +986,9 @@ public final class CharOperation { * * * @param first - * the first array + * the first array * @param second - * the second array + * the second array * @return true if the two arrays are identical character by character, * otherwise false */ @@ -1053,17 +1046,16 @@ public final class CharOperation { * * * @param first - * the first array + * the first array * @param second - * the second array + * the second array * @param isCaseSensitive - * check whether or not the equality should be case sensitive + * check whether or not the equality should be case sensitive * @return true if the two arrays are identical character by character * according to the value * of isCaseSensitive, otherwise false */ - public static final boolean equals(char[][] first, char[][] second, - boolean isCaseSensitive) { + public static final boolean equals(char[][] first, char[][] second, boolean isCaseSensitive) { if (isCaseSensitive) { return equals(first, second); } @@ -1114,9 +1106,9 @@ public final class CharOperation { * * * @param first - * the first array + * the first array * @param second - * the second array + * the second array * @return true if the two arrays are identical character by character, * otherwise false */ @@ -1174,17 +1166,16 @@ public final class CharOperation { * * * @param first - * the first array + * the first array * @param second - * the second array + * the second array * @param isCaseSensitive - * check whether or not the equality should be case sensitive + * check whether or not the equality should be case sensitive * @return true if the two arrays are identical character by character * according to the value * of isCaseSensitive, otherwise false */ - public static final boolean equals(char[] first, char[] second, - boolean isCaseSensitive) { + public static final boolean equals(char[] first, char[] second, boolean isCaseSensitive) { if (isCaseSensitive) { return equals(first, second); } @@ -1195,8 +1186,7 @@ public final class CharOperation { if (first.length != second.length) return false; for (int i = first.length; --i >= 0;) - if (Character.toLowerCase(first[i]) != Character - .toLowerCase(second[i])) + if (Character.toLowerCase(first[i]) != Character.toLowerCase(second[i])) return false; return true; } @@ -1246,21 +1236,20 @@ public final class CharOperation { * * * @param fragment - * the fragment to check + * the fragment to check * @param name - * the array to check + * the array to check * @param startIndex - * the starting index + * the starting index * @param isCaseSensitive - * check whether or not the equality should be case sensitive + * check whether or not the equality should be case sensitive * @return true if the name contains the fragment at the starting index * startIndex according to the * value of isCaseSensitive, otherwise false. * @exception NullPointerException - * if fragment or name is null. + * if fragment or name is null. */ - public static final boolean fragmentEquals(char[] fragment, char[] name, - int startIndex, boolean isCaseSensitive) { + public static final boolean fragmentEquals(char[] fragment, char[] name, int startIndex, boolean isCaseSensitive) { int max = fragment.length; if (name.length < max + startIndex) return false; @@ -1273,8 +1262,7 @@ public final class CharOperation { } for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name - if (Character.toLowerCase(fragment[i]) != Character - .toLowerCase(name[i + startIndex])) + if (Character.toLowerCase(fragment[i]) != Character.toLowerCase(name[i + startIndex])) return false; return true; } @@ -1283,10 +1271,10 @@ public final class CharOperation { * Answers a hashcode for the array * * @param array - * the array for which a hashcode is required + * the array for which a hashcode is required * @return the hashcode * @exception NullPointerException - * if array is null + * if array is null */ public static final int hashCode(char[] array) { int hash = 0; @@ -1324,7 +1312,7 @@ public final class CharOperation { * * * @param c - * the character to check + * the character to check * @return true if c is a whitespace according to the JLS, otherwise false. */ public static boolean isWhitespace(char c) { @@ -1364,14 +1352,14 @@ public final class CharOperation { * * * @param toBeFound - * the character to search + * the character to search * @param array - * the array to be searched + * the array to be searched * @return the first index in the array for which the corresponding * character is * equal to toBeFound, -1 otherwise * @exception NullPointerException - * if array is null + * if array is null */ public static final int indexOf(char toBeFound, char[] array) { for (int i = 0; i < array.length; i++) @@ -1413,18 +1401,18 @@ public final class CharOperation { * * * @param toBeFound - * the character to search + * the character to search * @param array - * the array to be searched + * the array to be searched * @param start - * the starting index + * the starting index * @return the first index in the array for which the corresponding * character is * equal to toBeFound, -1 otherwise * @exception NullPointerException - * if array is null + * if array is null * @exception ArrayIndexOutOfBoundsException - * if start is lower than 0 + * if start is lower than 0 */ public static final int indexOf(char toBeFound, char[] array, int start) { for (int i = start; i < array.length; i++) @@ -1457,15 +1445,15 @@ public final class CharOperation { * * * @param toBeFound - * the character to search + * the character to search * @param array - * the array to be searched + * the array to be searched * @return the last index in the array for which the corresponding character * is * equal to toBeFound starting from the end of the array, -1 * otherwise * @exception NullPointerException - * if array is null + * if array is null */ public static final int lastIndexOf(char toBeFound, char[] array) { for (int i = array.length; --i >= 0;) @@ -1507,21 +1495,20 @@ public final class CharOperation { * * * @param toBeFound - * the character to search + * the character to search * @param array - * the array to be searched + * the array to be searched * @param startIndex - * the stopping index + * the stopping index * @return the last index in the array for which the corresponding character * is * equal to toBeFound stopping at the index startIndex, -1 otherwise * @exception NullPointerException - * if array is null + * if array is null * @exception ArrayIndexOutOfBoundsException - * if startIndex is lower than 0 + * if startIndex is lower than 0 */ - public static final int lastIndexOf(char toBeFound, char[] array, - int startIndex) { + public static final int lastIndexOf(char toBeFound, char[] array, int startIndex) { for (int i = array.length; --i >= startIndex;) if (toBeFound == array[i]) return i; @@ -1564,25 +1551,24 @@ public final class CharOperation { * * * @param toBeFound - * the character to search + * the character to search * @param array - * the array to be searched + * the array to be searched * @param startIndex - * the stopping index + * the stopping index * @param endIndex - * the starting index + * the starting index * @return the last index in the array for which the corresponding character * is * equal to toBeFound starting from endIndex to startIndex, -1 * otherwise * @exception NullPointerException - * if array is null + * if array is null * @exception ArrayIndexOutOfBoundsException - * if endIndex is greater or equals to array length or - * starting is lower than 0 + * if endIndex is greater or equals to array length or + * starting is lower than 0 */ - public static final int lastIndexOf(char toBeFound, char[] array, - int startIndex, int endIndex) { + public static final int lastIndexOf(char toBeFound, char[] array, int startIndex, int endIndex) { for (int i = endIndex; --i >= startIndex;) if (toBeFound == array[i]) return i; @@ -1599,12 +1585,12 @@ public final class CharOperation { * * * @param array - * the array + * the array * @param separator - * the given separator + * the given separator * @return the last portion of a name given a separator * @exception NullPointerException - * if array is null + * if array is null */ final static public char[] lastSegment(char[] array, char separator) { int pos = lastIndexOf(separator, array); @@ -1651,22 +1637,20 @@ public final class CharOperation { * * * @param pattern - * the given pattern + * the given pattern * @param name - * the given name + * the given name * @param isCaseSensitive - * flag to know whether or not the matching should be case - * sensitive + * flag to know whether or not the matching should be case + * sensitive * @return true if the pattern matches the given name, false otherwise */ - public static final boolean match(char[] pattern, char[] name, - boolean isCaseSensitive) { + public static final boolean match(char[] pattern, char[] name, boolean isCaseSensitive) { if (name == null) return false; // null name cannot match if (pattern == null) return true; // null pattern is equivalent to '*' - return match(pattern, 0, pattern.length, name, 0, name.length, - isCaseSensitive, true); + return match(pattern, 0, pattern.length, name, 0, name.length, isCaseSensitive, true); } /** @@ -1708,31 +1692,28 @@ public final class CharOperation { * * * @param pattern - * the given pattern + * the given pattern * @param patternStart - * the given pattern start + * the given pattern start * @param patternEnd - * the given pattern end + * the given pattern end * @param name - * the given name + * the given name * @param nameStart - * the given name start + * the given name start * @param nameEnd - * the given name end + * the given name end * @param isCaseSensitive - * flag to know if the matching should be case sensitive + * flag to know if the matching should be case sensitive * @return true if the a sub-pattern matches the subpart of the given name, * false otherwise */ - public static final boolean match(char[] pattern, int patternStart, - int patternEnd, char[] name, int nameStart, int nameEnd, + public static final boolean match(char[] pattern, int patternStart, int patternEnd, char[] name, int nameStart, int nameEnd, boolean isCaseSensitive) { - return match(pattern, patternStart, patternEnd, name, nameStart, - nameEnd, isCaseSensitive, false); + return match(pattern, patternStart, patternEnd, name, nameStart, nameEnd, isCaseSensitive, false); } - public static final boolean match(char[] pattern, int patternStart, - int patternEnd, char[] name, int nameStart, int nameEnd, + public static final boolean match(char[] pattern, int patternStart, int patternEnd, char[] name, int nameStart, int nameEnd, boolean isCaseSensitive, boolean allowEscaping) { if (name == null) return false; // null name cannot match @@ -1747,8 +1728,7 @@ public final class CharOperation { /* check first segment */ char patternChar = 0; boolean isEscaped = false; - while ((iPattern < patternEnd) - && ((patternChar = pattern[iPattern]) != '*' || (patternChar == '*' && isEscaped))) { + while ((iPattern < patternEnd) && ((patternChar = pattern[iPattern]) != '*' || (patternChar == '*' && isEscaped))) { if (allowEscaping && pattern[iPattern] == '\\' && !isEscaped) { iPattern++; isEscaped = true; @@ -1757,8 +1737,7 @@ public final class CharOperation { isEscaped = false; if (iName == nameEnd) return false; - if (patternChar != (isCaseSensitive ? name[iName] : Character - .toLowerCase(name[iName])) && patternChar != '?') { + if (patternChar != (isCaseSensitive ? name[iName] : Character.toLowerCase(name[iName])) && patternChar != '?') { return false; } iName++; @@ -1789,9 +1768,7 @@ public final class CharOperation { continue checkSegment; } /* check current name character */ - if ((isCaseSensitive ? name[iName] : Character - .toLowerCase(name[iName])) != patternChar - && patternChar != '?') { + if ((isCaseSensitive ? name[iName] : Character.toLowerCase(name[iName])) != patternChar && patternChar != '?') { iPattern = segmentStart; // mismatch - restart current segment iName = ++prefixStart; continue checkSegment; @@ -1799,8 +1776,7 @@ public final class CharOperation { iName++; iPattern++; } - return (segmentStart == patternEnd) - || (iName == nameEnd && iPattern == patternEnd) + return (segmentStart == patternEnd) || (iName == nameEnd && iPattern == patternEnd) || (iPattern == patternEnd - 1 && pattern[iPattern] == '*'); } @@ -1823,19 +1799,18 @@ public final class CharOperation { * name will be lowercased character per character as comparing. * * @param pattern - * the given pattern + * the given pattern * @param filepath - * the given path + * the given path * @param isCaseSensitive - * to find out whether or not the matching should be case - * sensitive + * to find out whether or not the matching should be case + * sensitive * @param pathSeparator - * the given path separator + * the given path separator * @return true if the pattern matches the filepath using the pathSepatator, * false otherwise */ - public static final boolean pathMatch(char[] pattern, char[] filepath, - boolean isCaseSensitive, char pathSeparator) { + public static final boolean pathMatch(char[] pattern, char[] filepath, boolean isCaseSensitive, char pathSeparator) { if (filepath == null) return false; // null name cannot match if (pattern == null) @@ -1850,8 +1825,7 @@ public final class CharOperation { } else { pSegmentStart = 1; } - int pSegmentEnd = CharOperation.indexOf(pathSeparator, pattern, - pSegmentStart + 1); + int pSegmentEnd = CharOperation.indexOf(pathSeparator, pattern, pSegmentStart + 1); if (pSegmentEnd < 0) pSegmentEnd = pLength; // special case: pattern foo\ is equivalent to foo\** @@ -1866,29 +1840,24 @@ public final class CharOperation { if (fSegmentStart != pSegmentStart) { return false; // both must start with a separator or none. } - int fSegmentEnd = CharOperation.indexOf(pathSeparator, filepath, - fSegmentStart + 1); + int fSegmentEnd = CharOperation.indexOf(pathSeparator, filepath, fSegmentStart + 1); if (fSegmentEnd < 0) fSegmentEnd = fLength; // first segments while (pSegmentStart < pLength && !freeLeadingDoubleStar - && !(pSegmentEnd == pLength && freeTrailingDoubleStar || (pSegmentEnd == pSegmentStart + 2 - && pattern[pSegmentStart] == '*' && pattern[pSegmentStart + 1] == '*'))) { + && !(pSegmentEnd == pLength && freeTrailingDoubleStar || (pSegmentEnd == pSegmentStart + 2 && pattern[pSegmentStart] == '*' && pattern[pSegmentStart + 1] == '*'))) { if (fSegmentStart >= fLength) return false; - if (!CharOperation.match(pattern, pSegmentStart, pSegmentEnd, - filepath, fSegmentStart, fSegmentEnd, isCaseSensitive)) { + if (!CharOperation.match(pattern, pSegmentStart, pSegmentEnd, filepath, fSegmentStart, fSegmentEnd, isCaseSensitive)) { return false; } // jump to next segment - pSegmentEnd = CharOperation.indexOf(pathSeparator, pattern, - pSegmentStart = pSegmentEnd + 1); + pSegmentEnd = CharOperation.indexOf(pathSeparator, pattern, pSegmentStart = pSegmentEnd + 1); // skip separator if (pSegmentEnd < 0) pSegmentEnd = pLength; - fSegmentEnd = CharOperation.indexOf(pathSeparator, filepath, - fSegmentStart = fSegmentEnd + 1); + fSegmentEnd = CharOperation.indexOf(pathSeparator, filepath, fSegmentStart = fSegmentEnd + 1); // skip separator if (fSegmentEnd < 0) fSegmentEnd = fLength; @@ -1896,10 +1865,8 @@ public final class CharOperation { /* check sequence of doubleStar+segment */ int pSegmentRestart; if ((pSegmentStart >= pLength && freeTrailingDoubleStar) - || (pSegmentEnd == pSegmentStart + 2 - && pattern[pSegmentStart] == '*' && pattern[pSegmentStart + 1] == '*')) { - pSegmentEnd = CharOperation.indexOf(pathSeparator, pattern, - pSegmentStart = pSegmentEnd + 1); + || (pSegmentEnd == pSegmentStart + 2 && pattern[pSegmentStart] == '*' && pattern[pSegmentStart + 1] == '*')) { + pSegmentEnd = CharOperation.indexOf(pathSeparator, pattern, pSegmentStart = pSegmentEnd + 1); // skip separator if (pSegmentEnd < 0) pSegmentEnd = pLength; @@ -1915,30 +1882,24 @@ public final class CharOperation { if (freeTrailingDoubleStar) return true; // mismatch - restart current path segment - pSegmentEnd = CharOperation.indexOf(pathSeparator, pattern, - pSegmentStart = pSegmentRestart); + pSegmentEnd = CharOperation.indexOf(pathSeparator, pattern, pSegmentStart = pSegmentRestart); if (pSegmentEnd < 0) pSegmentEnd = pLength; - fSegmentRestart = CharOperation.indexOf(pathSeparator, - filepath, fSegmentRestart + 1); + fSegmentRestart = CharOperation.indexOf(pathSeparator, filepath, fSegmentRestart + 1); // skip separator if (fSegmentRestart < 0) { fSegmentRestart = fLength; } else { fSegmentRestart++; } - fSegmentEnd = CharOperation.indexOf(pathSeparator, filepath, - fSegmentStart = fSegmentRestart); + fSegmentEnd = CharOperation.indexOf(pathSeparator, filepath, fSegmentStart = fSegmentRestart); if (fSegmentEnd < 0) fSegmentEnd = fLength; continue checkSegment; } /* path segment is ending */ - if (pSegmentEnd == pSegmentStart + 2 - && pattern[pSegmentStart] == '*' - && pattern[pSegmentStart + 1] == '*') { - pSegmentEnd = CharOperation.indexOf(pathSeparator, pattern, - pSegmentStart = pSegmentEnd + 1); + if (pSegmentEnd == pSegmentStart + 2 && pattern[pSegmentStart] == '*' && pattern[pSegmentStart + 1] == '*') { + pSegmentEnd = CharOperation.indexOf(pathSeparator, pattern, pSegmentStart = pSegmentEnd + 1); // skip separator if (pSegmentEnd < 0) pSegmentEnd = pLength; @@ -1949,43 +1910,35 @@ public final class CharOperation { continue checkSegment; } /* chech current path segment */ - if (!CharOperation.match(pattern, pSegmentStart, pSegmentEnd, - filepath, fSegmentStart, fSegmentEnd, isCaseSensitive)) { + if (!CharOperation.match(pattern, pSegmentStart, pSegmentEnd, filepath, fSegmentStart, fSegmentEnd, isCaseSensitive)) { // mismatch - restart current path segment - pSegmentEnd = CharOperation.indexOf(pathSeparator, pattern, - pSegmentStart = pSegmentRestart); + pSegmentEnd = CharOperation.indexOf(pathSeparator, pattern, pSegmentStart = pSegmentRestart); if (pSegmentEnd < 0) pSegmentEnd = pLength; - fSegmentRestart = CharOperation.indexOf(pathSeparator, - filepath, fSegmentRestart + 1); + fSegmentRestart = CharOperation.indexOf(pathSeparator, filepath, fSegmentRestart + 1); // skip separator if (fSegmentRestart < 0) { fSegmentRestart = fLength; } else { fSegmentRestart++; } - fSegmentEnd = CharOperation.indexOf(pathSeparator, filepath, - fSegmentStart = fSegmentRestart); + fSegmentEnd = CharOperation.indexOf(pathSeparator, filepath, fSegmentStart = fSegmentRestart); if (fSegmentEnd < 0) fSegmentEnd = fLength; continue checkSegment; } // jump to next segment - pSegmentEnd = CharOperation.indexOf(pathSeparator, pattern, - pSegmentStart = pSegmentEnd + 1); + pSegmentEnd = CharOperation.indexOf(pathSeparator, pattern, pSegmentStart = pSegmentEnd + 1); // skip separator if (pSegmentEnd < 0) pSegmentEnd = pLength; - fSegmentEnd = CharOperation.indexOf(pathSeparator, filepath, - fSegmentStart = fSegmentEnd + 1); + fSegmentEnd = CharOperation.indexOf(pathSeparator, filepath, fSegmentStart = fSegmentEnd + 1); // skip separator if (fSegmentEnd < 0) fSegmentEnd = fLength; } - return (pSegmentRestart >= pSegmentEnd) - || (fSegmentStart >= fLength && pSegmentStart >= pLength) - || (pSegmentStart == pLength - 2 - && pattern[pSegmentStart] == '*' && pattern[pSegmentStart + 1] == '*') + return (pSegmentRestart >= pSegmentEnd) || (fSegmentStart >= fLength && pSegmentStart >= pLength) + || (pSegmentStart == pLength - 2 && pattern[pSegmentStart] == '*' && pattern[pSegmentStart + 1] == '*') || (pSegmentStart == pLength && freeTrailingDoubleStar); } @@ -2012,13 +1965,13 @@ public final class CharOperation { * * * @param toBeFound - * the given character + * the given character * @param array - * the given array + * the given array * @return the number of occurrences of the given character in the given * array, 0 if any * @exception NullPointerException - * if array is null + * if array is null */ public static final int occurencesOf(char toBeFound, char[] array) { int count = 0; @@ -2054,15 +2007,15 @@ public final class CharOperation { * * * @param toBeFound - * the given character + * the given character * @param array - * the given array + * the given array * @return the number of occurrences of the given character in the given * array, 0 if any * @exception NullPointerException - * if array is null + * if array is null * @exception ArrayIndexOutOfBoundsException - * if start is lower than 0 + * if start is lower than 0 */ public static final int occurencesOf(char toBeFound, char[] array, int start) { int count = 0; @@ -2095,13 +2048,13 @@ public final class CharOperation { * * * @param prefix - * the given prefix + * the given prefix * @param name - * the given name + * the given name * @return true if the given name starts with the given prefix, false * otherwise * @exception NullPointerException - * if the given name is null or if the given prefix is null + * if the given name is null or if the given prefix is null */ public static final boolean prefixEquals(char[] prefix, char[] name) { int max = prefix.length; @@ -2140,19 +2093,18 @@ public final class CharOperation { * * * @param prefix - * the given prefix + * the given prefix * @param name - * the given name + * the given name * @param isCaseSensitive - * to find out whether or not the comparison should be case - * sensitive + * to find out whether or not the comparison should be case + * sensitive * @return true if the given name starts with the given prefix, false * otherwise * @exception NullPointerException - * if the given name is null or if the given prefix is null + * if the given name is null or if the given prefix is null */ - public static final boolean prefixEquals(char[] prefix, char[] name, - boolean isCaseSensitive) { + public static final boolean prefixEquals(char[] prefix, char[] name, boolean isCaseSensitive) { int max = prefix.length; if (name.length < max) return false; @@ -2165,8 +2117,7 @@ public final class CharOperation { } for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name - if (Character.toLowerCase(prefix[i]) != Character - .toLowerCase(name[i])) + if (Character.toLowerCase(prefix[i]) != Character.toLowerCase(name[i])) return false; return true; } @@ -2198,16 +2149,15 @@ public final class CharOperation { * * * @param array - * the given array + * the given array * @param toBeReplaced - * the character to be replaced + * the character to be replaced * @param replacementChar - * the replacement character + * the replacement character * @exception NullPointerException - * if the given array is null + * if the given array is null */ - public static final void replace(char[] array, char toBeReplaced, - char replacementChar) { + public static final void replace(char[] array, char toBeReplaced, char replacementChar) { if (toBeReplaced != replacementChar) { for (int i = 0, max = array.length; i < max; i++) { if (array[i] == toBeReplaced) @@ -2243,18 +2193,17 @@ public final class CharOperation { * * * @param array - * the given array + * the given array * @param toBeReplaced - * characters to be replaced + * characters to be replaced * @param replacementChars - * the replacement characters + * the replacement characters * @return a new array of characters with substitutions or the given array * if none * @exception NullPointerException - * if the given array is null + * if the given array is null */ - public static final char[] replace(char[] array, char[] toBeReplaced, - char[] replacementChars) { + public static final char[] replace(char[] array, char[] toBeReplaced, char[] replacementChars) { int max = array.length; int replacedLength = toBeReplaced.length; int replacementLength = replacementChars.length; @@ -2270,25 +2219,21 @@ public final class CharOperation { continue next; } if (occurrenceCount == starts.length) { - System.arraycopy(starts, 0, - starts = new int[occurrenceCount * 2], 0, - occurrenceCount); + System.arraycopy(starts, 0, starts = new int[occurrenceCount * 2], 0, occurrenceCount); } starts[occurrenceCount++] = i; } } if (occurrenceCount == 0) return array; - char[] result = new char[max + occurrenceCount - * (replacementLength - replacedLength)]; + char[] result = new char[max + occurrenceCount * (replacementLength - replacedLength)]; int inStart = 0, outStart = 0; for (int i = 0; i < occurrenceCount; i++) { int offset = starts[i] - inStart; System.arraycopy(array, inStart, result, outStart, offset); inStart += offset; outStart += offset; - System.arraycopy(replacementChars, 0, result, outStart, - replacementLength); + System.arraycopy(replacementChars, 0, result, outStart, replacementLength); inStart += replacedLength; outStart += replacementLength; } @@ -2331,9 +2276,9 @@ public final class CharOperation { * * * @param divider - * the given divider + * the given divider * @param array - * the given array + * the given array * @return a new array which is the split of the given array using the given * divider and triming each subarray to remove * whitespaces equals to ' ' @@ -2358,8 +2303,7 @@ public final class CharOperation { while (end > start && array[end] == ' ') end--; split[currentWord] = new char[end - start + 1]; - System.arraycopy(array, start, split[currentWord++], 0, end - - start + 1); + System.arraycopy(array, start, split[currentWord++], 0, end - start + 1); last = i + 1; } } @@ -2401,9 +2345,9 @@ public final class CharOperation { * * * @param divider - * the given divider + * the given divider * @param array - * the given array + * the given array * @return a new array which is the split of the given array using the given * divider */ @@ -2450,21 +2394,20 @@ public final class CharOperation { * * * @param divider - * the given divider + * the given divider * @param array - * the given array + * the given array * @param start - * the given starting index + * the given starting index * @param end - * the given ending index + * the given ending index * @return a new array which is the split of the given array using the given * divider * @exception ArrayIndexOutOfBoundsException - * if start is lower than 0 or end is greater than the array - * length + * if start is lower than 0 or end is greater than the array + * length */ - public static final char[][] splitOn(char divider, char[] array, int start, - int end) { + public static final char[][] splitOn(char divider, char[] array, int start, int end) { if (array == null) return NO_CHAR_CHAR; final int length = array.length; @@ -2518,16 +2461,16 @@ public final class CharOperation { * * * @param array - * the given array + * the given array * @param start - * the given starting index + * the given starting index * @param end - * the given ending index + * the given ending index * @return a new array which is a copy of the given array starting at the * given start and * ending at the given end * @exception NullPointerException - * if the given array is null + * if the given array is null */ public static final char[][] subarray(char[][] array, int start, int end) { if (end == -1) @@ -2573,16 +2516,16 @@ public final class CharOperation { * * * @param array - * the given array + * the given array * @param start - * the given starting index + * the given starting index * @param end - * the given ending index + * the given ending index * @return a new array which is a copy of the given array starting at the * given start and * ending at the given end * @exception NullPointerException - * if the given array is null + * if the given array is null */ public static final char[] subarray(char[] array, int start, int end) { if (end == -1) @@ -2620,7 +2563,7 @@ public final class CharOperation { * * * @param chars - * the chars to convert + * the chars to convert * @return the result of a char[] conversion to lowercase */ final static public char[] toLowerCase(char[] chars) { @@ -2633,8 +2576,7 @@ public final class CharOperation { char lc = Character.toLowerCase(c); if ((c != lc) || (lowerChars != null)) { if (lowerChars == null) { - System.arraycopy(chars, 0, lowerChars = new char[length], - 0, i); + System.arraycopy(chars, 0, lowerChars = new char[length], 0, i); } lowerChars[i] = lc; } @@ -2663,7 +2605,7 @@ public final class CharOperation { * * * @param chars - * the given array + * the given array * @return a new array removing leading and trailing spaces (' ') */ final static public char[] trim(char[] chars) { @@ -2702,7 +2644,7 @@ public final class CharOperation { * * * @param array - * the given array + * the given array * @return a string which is the concatenation of the given array using the * '.' as a separator */ diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckerInvocationContext.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckerInvocationContext.java index 69b75bb4056..2a48927ae31 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckerInvocationContext.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckerInvocationContext.java @@ -25,8 +25,7 @@ public class CheckerInvocationContext implements ICheckerInvocationContext { * @param resource * @param sessionReporter */ - public CheckerInvocationContext(IResource resource, - IProblemReporter sessionReporter) { + public CheckerInvocationContext(IResource resource, IProblemReporter sessionReporter) { this.resource = resource; this.sessionReporter = sessionReporter; } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegistry.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegistry.java index 249be2e3c56..464eaa77308 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegistry.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegistry.java @@ -65,8 +65,7 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { } private void readCheckersRegistry() { - IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint( - CodanCorePlugin.PLUGIN_ID, EXTENSION_POINT_NAME); + IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(CodanCorePlugin.PLUGIN_ID, EXTENSION_POINT_NAME); if (ep == null) return; IConfigurationElement[] elements = ep.getConfigurationElements(); @@ -117,8 +116,7 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { if (name == null) return; CodanProblemCategory cat = new CodanProblemCategory(id, name); - String category = getAtt(configurationElement, - "parentCategory", false); //$NON-NLS-1$ + String category = getAtt(configurationElement, "parentCategory", false); //$NON-NLS-1$ addCategory(cat, category); } } @@ -145,8 +143,7 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { return; } boolean hasRef = false; - IConfigurationElement[] children2 = - configurationElement.getChildren(PROBLEM_ELEMENT); + IConfigurationElement[] children2 = configurationElement.getChildren(PROBLEM_ELEMENT); if (children2 != null) { for (IConfigurationElement ref : children2) { IProblem p = processProblem(ref); @@ -154,8 +151,7 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { hasRef = true; } } - IConfigurationElement[] children1 = - configurationElement.getChildren("problemRef"); //$NON-NLS-1$ + IConfigurationElement[] children1 = configurationElement.getChildren("problemRef"); //$NON-NLS-1$ if (children1 != null) { for (IConfigurationElement ref : children1) { hasRef = true; @@ -216,13 +212,11 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { return null; } - private static String getAtt(IConfigurationElement configurationElement, - String name) { + private static String getAtt(IConfigurationElement configurationElement, String name) { return getAtt(configurationElement, name, true); } - private static String getAtt(IConfigurationElement configurationElement, - String name, boolean req) { + private static String getAtt(IConfigurationElement configurationElement, String name, boolean req) { String elementValue = configurationElement.getAttribute(name); if (elementValue == null && req) CodanCorePlugin.log("Extension " //$NON-NLS-1$ @@ -234,7 +228,7 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.codan.core.model.ICheckersRegistry#iterator() */ public Iterator iterator() { @@ -252,7 +246,7 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { /* * (non-Javadoc) - * + * * @see * org.eclipse.cdt.codan.core.model.ICheckersRegistry#addChecker(org.eclipse * .cdt.codan.core.model.IChecker) @@ -263,7 +257,7 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { /* * (non-Javadoc) - * + * * @see * org.eclipse.cdt.codan.core.model.ICheckersRegistry#addProblem(org.eclipse * .cdt.codan.core.model.IProblem, java.lang.String) @@ -277,7 +271,7 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { /* * (non-Javadoc) - * + * * @see * org.eclipse.cdt.codan.core.model.ICheckersRegistry#addCategory(org.eclipse * .cdt.codan.core.model.IProblemCategory, java.lang.String) @@ -291,7 +285,7 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { /* * (non-Javadoc) - * + * * @see * org.eclipse.cdt.codan.core.model.ICheckersRegistry#addRefProblem(org. * eclipse.cdt.codan.core.model.IChecker, @@ -308,7 +302,7 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { /** * Returns list of problems registered for given checker - * + * * @return collection of problems or null */ public Collection getRefProblems(IChecker checker) { @@ -317,7 +311,7 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { /* * (non-Javadoc) - * + * * @see * org.eclipse.cdt.codan.core.model.ICheckersRegistry#getDefaultProfile() */ @@ -327,7 +321,7 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { /* * (non-Javadoc) - * + * * @see * org.eclipse.cdt.codan.core.model.ICheckersRegistry#getWorkspaceProfile() */ @@ -358,7 +352,7 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { /* * (non-Javadoc) - * + * * @see * org.eclipse.cdt.codan.core.model.ICheckersRegistry#getResourceProfile * (org.eclipse.core.resources.IResource) @@ -371,10 +365,8 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { prof = (IProblemProfile) getWorkspaceProfile().clone(); // load default values CodanPreferencesLoader loader = new CodanPreferencesLoader(prof); - Preferences projectNode = - CodanPreferencesLoader.getProjectNode((IProject) element); - boolean useWorkspace = projectNode.getBoolean(PreferenceConstants.P_USE_PARENT, - false); + Preferences projectNode = CodanPreferencesLoader.getProjectNode((IProject) element); + boolean useWorkspace = projectNode.getBoolean(PreferenceConstants.P_USE_PARENT, false); if (!useWorkspace) { loader.load(projectNode); } @@ -394,7 +386,7 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { /* * (non-Javadoc) - * + * * @seeorg.eclipse.cdt.codan.core.model.ICheckersRegistry# * getResourceProfileWorkingCopy(org.eclipse.core.resources.IResource) */ @@ -409,9 +401,10 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { } /** - * Tests if a checker is enabled (needs to be run) or not. Checker is enabled + * Tests if a checker is enabled (needs to be run) or not. Checker is + * enabled * if at least one problem it reports is enabled. - * + * * @param checker * @param resource * @return true if the checker is enabled @@ -434,19 +427,17 @@ public class CheckersRegistry implements Iterable, ICheckersRegistry { /** * Tests if a checker needs to run in a specific launch mode. - * + * * @param checker * @param resource * @param mode * @return true if the checker should run. */ - public boolean isCheckerEnabledForLaunchMode(IChecker checker, IResource resource, - CheckerLaunchMode mode) { + public boolean isCheckerEnabledForLaunchMode(IChecker checker, IResource resource, CheckerLaunchMode mode) { IProblemProfile resourceProfile = getResourceProfile(resource); Collection refProblems = getRefProblems(checker); boolean enabled = false; - for (Iterator iterator = refProblems.iterator(); iterator - .hasNext();) { + for (Iterator iterator = refProblems.iterator(); iterator.hasNext();) { IProblem p = iterator.next(); // we need to check problem enablement in particular profile IProblem problem = resourceProfile.findProblem(p.getId()); diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanApplication.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanApplication.java index 29d876aef7c..1adbf6c23b6 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanApplication.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanApplication.java @@ -38,8 +38,7 @@ public class CodanApplication implements IApplication { private boolean all = false; public Object start(IApplicationContext context) throws Exception { - String[] args = (String[]) context.getArguments().get( - "application.args"); //$NON-NLS-1$ + String[] args = (String[]) context.getArguments().get("application.args"); //$NON-NLS-1$ if (args == null || args.length == 0) { help(); return EXIT_OK; @@ -51,8 +50,7 @@ public class CodanApplication implements IApplication { @Override protected void reportProblem(ICodanProblemMarker pm) { IResource file = pm.getResource(); - System.out.println(file.getLocation() - + ":" + pm.getLocation().getLineNumber() + ": " //$NON-NLS-1$ //$NON-NLS-2$ + System.out.println(file.getLocation() + ":" + pm.getLocation().getLineNumber() + ": " //$NON-NLS-1$ //$NON-NLS-2$ + pm.createMessage()); } }); @@ -65,15 +63,11 @@ public class CodanApplication implements IApplication { log(Messages.CodanApplication_LogRunProject + project); IProject wProject = root.getProject(project); if (!wProject.exists()) { - System.err - .println( // - NLS.bind( - Messages.CodanApplication_Error_ProjectDoesNotExists, - project)); + System.err.println( // + NLS.bind(Messages.CodanApplication_Error_ProjectDoesNotExists, project)); continue; } - codanBuilder.processResource(wProject, - new NullProgressMonitor()); + codanBuilder.processResource(wProject, new NullProgressMonitor()); } } return EXIT_OK; diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanBuilder.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanBuilder.java index eedcc978f48..4ae80fce30a 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanBuilder.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanBuilder.java @@ -31,8 +31,7 @@ import org.eclipse.core.runtime.SubProgressMonitor; /** * Implementation of {@link ICodanBuilder} */ -public class CodanBuilder extends IncrementalProjectBuilder implements - ICodanBuilder { +public class CodanBuilder extends IncrementalProjectBuilder implements ICodanBuilder { /** * codan builder id */ @@ -76,8 +75,7 @@ public class CodanBuilder extends IncrementalProjectBuilder implements */ @SuppressWarnings("rawtypes") @Override - protected IProject[] build(int kind, Map args, IProgressMonitor monitor) - throws CoreException { + protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { if (kind == FULL_BUILD) { fullBuild(monitor); } else { @@ -92,19 +90,14 @@ public class CodanBuilder extends IncrementalProjectBuilder implements } public void processResource(IResource resource, IProgressMonitor monitor) { - processResource(resource, monitor, null, - CheckerLaunchMode.RUN_ON_FULL_BUILD); + processResource(resource, monitor, null, CheckerLaunchMode.RUN_ON_FULL_BUILD); } - public void processResourceDelta(IResource resource, - IProgressMonitor monitor) { - processResource(resource, monitor, null, - CheckerLaunchMode.RUN_ON_INC_BUILD); + public void processResourceDelta(IResource resource, IProgressMonitor monitor) { + processResource(resource, monitor, null, CheckerLaunchMode.RUN_ON_INC_BUILD); } - protected void processResource(IResource resource, - IProgressMonitor monitor, Object model, - CheckerLaunchMode checkerLaunchMode) { + protected void processResource(IResource resource, IProgressMonitor monitor, Object model, CheckerLaunchMode checkerLaunchMode) { CheckersRegistry chegistry = CheckersRegistry.getInstance(); int checkers = chegistry.getCheckersSize(); int memsize = 0; @@ -118,27 +111,21 @@ public class CodanBuilder extends IncrementalProjectBuilder implements } int tick = 1000; // System.err.println("processing " + resource); - monitor.beginTask(Messages.CodanBuilder_Code_Analysis_On + resource, - checkers + memsize * tick); + monitor.beginTask(Messages.CodanBuilder_Code_Analysis_On + resource, checkers + memsize * tick); try { for (IChecker checker : chegistry) { try { if (monitor.isCanceled()) return; - if (checker.enabledInContext(resource) - && chegistry.isCheckerEnabledForLaunchMode(checker, - resource, checkerLaunchMode)) { + if (checker.enabledInContext(resource) && chegistry.isCheckerEnabledForLaunchMode(checker, resource, checkerLaunchMode)) { synchronized (checker) { try { checker.before(resource); - if (chegistry.isCheckerEnabled(checker, - resource)) { + if (chegistry.isCheckerEnabled(checker, resource)) { //long time = System.currentTimeMillis(); if (checkerLaunchMode == CheckerLaunchMode.RUN_AS_YOU_TYPE) { - if (checker.runInEditor() - && checker instanceof IRunnableInEditorChecker) { - ((IRunnableInEditorChecker) checker) - .processModel(model); + if (checker.runInEditor() && checker instanceof IRunnableInEditorChecker) { + ((IRunnableInEditorChecker) checker).processModel(model); } } else { checker.processResource(resource); @@ -160,16 +147,14 @@ public class CodanBuilder extends IncrementalProjectBuilder implements CodanCorePlugin.log(e); } } - if (resource instanceof IContainer - && (checkerLaunchMode == CheckerLaunchMode.RUN_ON_FULL_BUILD)) { + if (resource instanceof IContainer && (checkerLaunchMode == CheckerLaunchMode.RUN_ON_FULL_BUILD)) { try { IResource[] members = ((IContainer) resource).members(); for (int i = 0; i < members.length; i++) { if (monitor.isCanceled()) return; IResource member = members[i]; - processResource(member, new SubProgressMonitor(monitor, - tick)); + processResource(member, new SubProgressMonitor(monitor, tick)); } } catch (CoreException e) { CodanCorePlugin.log(e); @@ -189,13 +174,11 @@ public class CodanBuilder extends IncrementalProjectBuilder implements return true; } - protected void fullBuild(final IProgressMonitor monitor) - throws CoreException { + protected void fullBuild(final IProgressMonitor monitor) throws CoreException { processResource(getProject(), monitor); } - protected void incrementalBuild(IResourceDelta delta, - IProgressMonitor monitor) throws CoreException { + protected void incrementalBuild(IResourceDelta delta, IProgressMonitor monitor) throws CoreException { // the visitor does the work. delta.accept(new CodanDeltaVisitor(monitor)); } @@ -207,11 +190,9 @@ public class CodanBuilder extends IncrementalProjectBuilder implements * @param resource - resource to process * @param monitor - progress monitor */ - public void runInEditor(Object model, IResource resource, - IProgressMonitor monitor) { + public void runInEditor(Object model, IResource resource, IProgressMonitor monitor) { if (model == null) return; - processResource(resource, monitor, model, - CheckerLaunchMode.RUN_AS_YOU_TYPE); + processResource(resource, monitor, model, CheckerLaunchMode.RUN_AS_YOU_TYPE); } } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanPreferencesLoader.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanPreferencesLoader.java index 28584d368f2..523a287d39b 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanPreferencesLoader.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanPreferencesLoader.java @@ -135,8 +135,7 @@ public class CodanPreferencesLoader { * @param problemId * @param storePreferences */ - private void setProblemPreferenceValues(String problemId, - Preferences storePreferences) { + private void setProblemPreferenceValues(String problemId, Preferences storePreferences) { IProblem prob = baseModel.findProblem(problemId); String prefKey = getPreferencesKey(problemId); if (prefKey == null) @@ -161,8 +160,7 @@ public class CodanPreferencesLoader { public static Preferences getProjectNode(IProject project) { if (!project.exists()) return null; - Preferences prefNode = new ProjectScope(project) - .getNode(CodanCorePlugin.PLUGIN_ID); + Preferences prefNode = new ProjectScope(project).getNode(CodanCorePlugin.PLUGIN_ID); if (prefNode == null) return null; return prefNode; @@ -174,8 +172,7 @@ public class CodanPreferencesLoader { * @return project preferences node */ public static Preferences getWorkspaceNode() { - Preferences prefNode = new InstanceScope() - .getNode(CodanCorePlugin.PLUGIN_ID); + Preferences prefNode = new InstanceScope().getNode(CodanCorePlugin.PLUGIN_ID); if (prefNode == null) return null; return prefNode; diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodeAnlysisNature.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodeAnlysisNature.java index f73ee6114d5..21f47e00f73 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodeAnlysisNature.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodeAnlysisNature.java @@ -50,8 +50,7 @@ public class CodeAnlysisNature implements IProjectNature { if (commands[i].getBuilderName().equals(CodanBuilder.BUILDER_ID)) { ICommand[] newCommands = new ICommand[commands.length - 1]; System.arraycopy(commands, 0, newCommands, 0, i); - System.arraycopy(commands, i + 1, newCommands, i, - commands.length - i - 1); + System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1); description.setBuildSpec(newCommands); project.setDescription(description, null); return; diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleIncomingNode.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleIncomingNode.java index 9054f2a69c3..fbc59304344 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleIncomingNode.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleIncomingNode.java @@ -17,8 +17,7 @@ import org.eclipse.cdt.codan.core.model.cfg.ISingleIncoming; * Abstract node with one incoming arc (node) * */ -public abstract class AbstractSingleIncomingNode extends AbstractBasicBlock - implements ISingleIncoming { +public abstract class AbstractSingleIncomingNode extends AbstractBasicBlock implements ISingleIncoming { private IBasicBlock prev; /** diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleOutgoingNode.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleOutgoingNode.java index e4f7fcfba29..d23e15b754b 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleOutgoingNode.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/AbstractSingleOutgoingNode.java @@ -17,8 +17,7 @@ import org.eclipse.cdt.codan.core.model.cfg.ISingleOutgoing; * Abstract implementation of basic block with single outgoing arc (node) * */ -public abstract class AbstractSingleOutgoingNode extends AbstractBasicBlock - implements ISingleOutgoing { +public abstract class AbstractSingleOutgoingNode extends AbstractBasicBlock implements ISingleOutgoing { private IBasicBlock next; /** diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ConnectorNode.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ConnectorNode.java index 7c918187222..18ce3d0848b 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ConnectorNode.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ConnectorNode.java @@ -19,8 +19,7 @@ import org.eclipse.cdt.codan.core.model.cfg.IJumpNode; /** * TODO: add description */ -public class ConnectorNode extends AbstractSingleOutgoingNode implements - IConnectorNode { +public class ConnectorNode extends AbstractSingleOutgoingNode implements IConnectorNode { protected ArrayList incoming = new ArrayList(2); protected ConnectorNode() { diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ControlFlowGraph.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ControlFlowGraph.java index 8960d937fcf..c7de910f757 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ControlFlowGraph.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/ControlFlowGraph.java @@ -49,15 +49,12 @@ public class ControlFlowGraph implements IControlFlowGraph { public void setExitNodes(Collection exitNodes) { if (this.exitNodes != null) - throw new IllegalArgumentException( - "Cannot modify already exiting connector"); //$NON-NLS-1$ - this.exitNodes = Collections.unmodifiableList(new ArrayList( - exitNodes)); + throw new IllegalArgumentException("Cannot modify already exiting connector"); //$NON-NLS-1$ + this.exitNodes = Collections.unmodifiableList(new ArrayList(exitNodes)); } public void setUnconnectedNodes(Collection nodes) { - this.deadNodes = Collections - .unmodifiableList(new ArrayList(nodes)); + this.deadNodes = Collections.unmodifiableList(new ArrayList(nodes)); } /* @@ -122,8 +119,7 @@ public class ControlFlowGraph implements IControlFlowGraph { public Collection getNodes() { Collection result = new LinkedHashSet(); getNodes(getStartNode(), result); - for (Iterator iterator = deadNodes.iterator(); iterator - .hasNext();) { + for (Iterator iterator = deadNodes.iterator(); iterator.hasNext();) { IBasicBlock d = iterator.next(); getNodes(d, result); } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/DecisionNode.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/DecisionNode.java index df0da9c734e..9353d1fb6a5 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/DecisionNode.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/DecisionNode.java @@ -21,8 +21,7 @@ import org.eclipse.cdt.codan.core.model.cfg.IDecisionNode; /** * @see {@link IDecisionNode} */ -public class DecisionNode extends AbstractSingleIncomingNode implements - IDecisionNode { +public class DecisionNode extends AbstractSingleIncomingNode implements IDecisionNode { private List next = new ArrayList(2); private IConnectorNode conn; diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/JumpNode.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/JumpNode.java index b5198d0ac59..eb8999bfe1d 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/JumpNode.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/cfg/JumpNode.java @@ -54,8 +54,7 @@ public class JumpNode extends AbstractSingleIncomingNode implements IJumpNode { public void setJump(IConnectorNode jump, boolean backward) { if (this.jump != null && this.jump != jump) - throw new IllegalArgumentException( - "Cannot modify exiting connector"); //$NON-NLS-1$ + throw new IllegalArgumentException("Cannot modify exiting connector"); //$NON-NLS-1$ this.jump = jump; this.backward = backward; } 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 ea00a9afe0c..7bf2616a9a4 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 @@ -36,8 +36,7 @@ import org.eclipse.core.runtime.IProgressMonitor; /** * Problem reported that created eclipse markers */ -public class CodanMarkerProblemReporter extends AbstractProblemReporter - implements IProblemReporterPersistent, +public class CodanMarkerProblemReporter extends AbstractProblemReporter implements IProblemReporterPersistent, IProblemReporterSessionPersistent { private IResource resource; private IChecker checker; @@ -92,8 +91,7 @@ public class CodanMarkerProblemReporter extends AbstractProblemReporter public void deleteProblems(IResource file) { try { - file.deleteMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, true, - IResource.DEPTH_ZERO); + file.deleteMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, true, IResource.DEPTH_ZERO); } catch (CoreException ce) { ce.printStackTrace(); } @@ -101,11 +99,7 @@ public class CodanMarkerProblemReporter extends AbstractProblemReporter public void deleteAllProblems() { try { - ResourcesPlugin - .getWorkspace() - .getRoot() - .deleteMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, true, - IResource.DEPTH_INFINITE); + ResourcesPlugin.getWorkspace().getRoot().deleteMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, true, IResource.DEPTH_INFINITE); } catch (CoreException e) { CodanCorePlugin.log(e); } @@ -115,10 +109,8 @@ public class CodanMarkerProblemReporter extends AbstractProblemReporter try { ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { - Collection markers = findResourceMarkers(file, - checker); - for (Iterator iterator = markers.iterator(); iterator - .hasNext();) { + Collection markers = findResourceMarkers(file, checker); + for (Iterator iterator = markers.iterator(); iterator.hasNext();) { IMarker iMarker = iterator.next(); iMarker.delete(); } @@ -129,29 +121,23 @@ public class CodanMarkerProblemReporter extends AbstractProblemReporter } } - protected Collection findResourceMarkers(IResource resource, - IChecker checker) throws CoreException { + protected Collection findResourceMarkers(IResource resource, IChecker checker) throws CoreException { Collection res = new ArrayList(); IMarker[] markers; if (resource.exists()) { - markers = resource.findMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, - true, IResource.DEPTH_INFINITE); + markers = resource.findMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, true, IResource.DEPTH_INFINITE); } else { if (resource.getProject() == null || !resource.getProject().isAccessible()) return res; // non resource markers attached to a project itself - markers = resource.getProject().findMarkers( - GENERIC_CODE_ANALYSIS_MARKER_TYPE, true, - IResource.DEPTH_ZERO); + markers = resource.getProject().findMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, true, IResource.DEPTH_ZERO); } - ICheckersRegistry reg = CodanRuntime.getInstance() - .getCheckersRegistry(); + ICheckersRegistry reg = CodanRuntime.getInstance().getCheckersRegistry(); Collection problems = reg.getRefProblems(checker); for (int i = 0; i < markers.length; i++) { IMarker m = markers[i]; String id = m.getAttribute(ICodanProblemMarker.ID, ""); //$NON-NLS-1$ - for (Iterator iterator = problems.iterator(); iterator - .hasNext();) { + for (Iterator iterator = problems.iterator(); iterator.hasNext();) { IProblem iProblem = iterator.next(); if (iProblem.getId().equals(id)) { res.add(m); @@ -167,8 +153,7 @@ public class CodanMarkerProblemReporter extends AbstractProblemReporter * @return session aware problem reporter * @since 1.1 */ - public IProblemReporterSessionPersistent createReporter(IResource resource, - IChecker checker) { + public IProblemReporterSessionPersistent createReporter(IResource resource, IChecker checker) { return new CodanMarkerProblemReporter(resource, checker); } @@ -191,10 +176,8 @@ public class CodanMarkerProblemReporter extends AbstractProblemReporter try { ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { - Collection markers = findResourceMarkers(resource, - checker); - for (Iterator iterator = markers.iterator(); iterator - .hasNext();) { + Collection markers = findResourceMarkers(resource, checker); + for (Iterator iterator = markers.iterator(); iterator.hasNext();) { IMarker m = iterator.next(); ICodanProblemMarker cm = similarMarker(m); if (cm == null) { @@ -204,8 +187,7 @@ public class CodanMarkerProblemReporter extends AbstractProblemReporter toAdd.remove(cm); } } - for (Iterator iterator = toAdd - .iterator(); iterator.hasNext();) { + for (Iterator iterator = toAdd.iterator(); iterator.hasNext();) { ICodanProblemMarker cm = iterator.next(); cm.createMarker(); } @@ -244,11 +226,9 @@ public class CodanMarkerProblemReporter extends AbstractProblemReporter * @return */ protected ICodanProblemMarker similarMarker(IMarker m) { - ICodanProblemMarker mcm = CodanProblemMarker - .createCodanProblemMarkerFromResourceMarker(m); + ICodanProblemMarker mcm = CodanProblemMarker.createCodanProblemMarkerFromResourceMarker(m); ArrayList cand = new ArrayList(); - for (Iterator iterator = toAdd.iterator(); iterator - .hasNext();) { + for (Iterator iterator = toAdd.iterator(); iterator.hasNext();) { ICodanProblemMarker cm = iterator.next(); if (mcm.equals(cm)) return cm; diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblem.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblem.java index 9a4a9a4e22d..b2149d830ae 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblem.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblem.java @@ -19,7 +19,6 @@ import org.eclipse.cdt.codan.core.param.IProblemPreference; * A type of problems reported by Codan. */ public class CodanProblem implements IProblemWorkingCopy, Cloneable { - private String id; private String name; private String messagePattern; @@ -73,7 +72,7 @@ public class CodanProblem implements IProblemWorkingCopy, Cloneable { /* * (non-Javadoc) - * + * * @see java.lang.Object#clone() */ @Override @@ -100,7 +99,7 @@ public class CodanProblem implements IProblemWorkingCopy, Cloneable { /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.codan.core.model.IProblem#getMessagePattern() */ public String getMessagePattern() { @@ -113,7 +112,7 @@ public class CodanProblem implements IProblemWorkingCopy, Cloneable { /** * @param messagePattern - * the message to set + * the message to set */ public void setMessagePattern(String messagePattern) { checkSet(); @@ -127,7 +126,7 @@ public class CodanProblem implements IProblemWorkingCopy, Cloneable { /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.codan.core.model.IProblem#getDescription() */ public String getDescription() { @@ -136,7 +135,7 @@ public class CodanProblem implements IProblemWorkingCopy, Cloneable { /* * (non-Javadoc) - * + * * @see * org.eclipse.cdt.codan.core.model.IProblemWorkingCopy#setDescription(java * .lang.String) @@ -147,7 +146,7 @@ public class CodanProblem implements IProblemWorkingCopy, Cloneable { /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.codan.core.model.IProblem#getMarkerType() */ public String getMarkerType() { @@ -156,7 +155,7 @@ public class CodanProblem implements IProblemWorkingCopy, Cloneable { /** * Sets the marker id for the problem. - + * * @param markerType */ public void setMarkerType(String markerType) { 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 1388eaa5f3f..57320f5257e 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 @@ -73,8 +73,7 @@ public class CodanProblemCategory implements IProblemCategory, Cloneable { * @param id - problem id * @return list of categories */ - public static IProblemCategory[] findProblemCategories(IProblemCategory c, - String id) { + public static IProblemCategory[] findProblemCategories(IProblemCategory c, String id) { ArrayList list = new ArrayList(); Object[] children = c.getChildren(); for (Object object : children) { @@ -119,8 +118,7 @@ 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/CodanProblemLocation.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemLocation.java index 6dcbca5449d..a4e38059ba1 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemLocation.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemLocation.java @@ -25,8 +25,7 @@ public class CodanProblemLocation extends AbstractProblemLocation { * @param endChar - end char, absolute file offset, exclusive * @param line - line number */ - public CodanProblemLocation(IResource file, int startChar, int endChar, - int line) { + public CodanProblemLocation(IResource file, int startChar, int endChar, int line) { super(file, startChar, endChar); this.line = line; } 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 168e18d1854..b5dd4a5e74b 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 @@ -49,8 +49,7 @@ public class CodanProblemMarker implements ICodanProblemMarker { * @param loc * @param args */ - public CodanProblemMarker(IProblem problem, IProblemLocation loc, - Object[] args) { + public CodanProblemMarker(IProblem problem, IProblemLocation loc, Object[] args) { this.problem = problem; this.loc = loc; this.args = args; @@ -102,8 +101,7 @@ public class CodanProblemMarker implements ICodanProblemMarker { marker.setAttribute(IMarker.CHAR_START, loc.getStartingChar()); String propArgs = serializeArgs(args); marker.setAttribute(PROBLEM_ARGS, propArgs); - IProblemCategory[] cats = CodanProblemCategory.findProblemCategories( - getProfile(file).getRoot(), problem.getId()); + 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; @@ -227,8 +225,7 @@ public class CodanProblemMarker implements ICodanProblemMarker { * @return new instanceof of ICodanProblemMarker or null if marker is not * codan marker */ - public static ICodanProblemMarker createCodanProblemMarkerFromResourceMarker( - IMarker marker) { + public static ICodanProblemMarker createCodanProblemMarkerFromResourceMarker(IMarker marker) { CodanProblem problem = getProblem(marker); if (problem == null) return null; @@ -246,8 +243,7 @@ public class CodanProblemMarker implements ICodanProblemMarker { return null; IResource resource = marker.getResource(); IProblemProfile profile = getProfile(resource); - CodanProblem problem = (CodanProblem) ((CodanProblem) profile - .findProblem(id)).clone(); + CodanProblem problem = (CodanProblem) ((CodanProblem) profile.findProblem(id)).clone(); CodanSeverity sev = getSeverity(marker); problem.setSeverity(sev); return problem; @@ -258,8 +254,7 @@ public class CodanProblemMarker implements ICodanProblemMarker { * @return */ public static IProblemProfile getProfile(IResource resource) { - IProblemProfile profile = CheckersRegistry.getInstance() - .getResourceProfile(resource); + IProblemProfile profile = CheckersRegistry.getInstance().getResourceProfile(resource); return profile; } @@ -271,8 +266,7 @@ public class CodanProblemMarker implements ICodanProblemMarker { int line = marker.getAttribute(IMarker.LINE_NUMBER, -1); int charend = marker.getAttribute(IMarker.CHAR_END, -1); int charstart = marker.getAttribute(IMarker.CHAR_START, -1); - CodanProblemLocation loc = new CodanProblemLocation( - marker.getResource(), charstart, charend, line); + CodanProblemLocation loc = new CodanProblemLocation(marker.getResource(), charstart, charend, line); return loc; } @@ -281,8 +275,7 @@ public class CodanProblemMarker implements ICodanProblemMarker { * @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); marker.setAttribute(PROBLEM_ARGS, propArgs); } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemLocationFactory.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemLocationFactory.java index 835f6bfac15..df3c444bcd3 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemLocationFactory.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemLocationFactory.java @@ -35,8 +35,7 @@ public class ProblemLocationFactory implements IProblemLocationFactory { * @seeorg.eclipse.cdt.codan.core.model.IProblemLocationFactory# * createProblemLocation(org.eclipse.core.resources.IFile, int, int) */ - public IProblemLocation createProblemLocation(IFile file, int startChar, - int endChar) { + public IProblemLocation createProblemLocation(IFile file, int startChar, int endChar) { return new CodanProblemLocation(file, startChar, endChar); } @@ -46,8 +45,7 @@ public class ProblemLocationFactory implements IProblemLocationFactory { * @seeorg.eclipse.cdt.codan.core.model.IProblemLocationFactory# * createProblemLocation(org.eclipse.core.resources.IFile, int, int, int) */ - public IProblemLocation createProblemLocation(IFile file, int startChar, - int endChar, int line) { + public IProblemLocation createProblemLocation(IFile file, int startChar, int endChar, int line) { return new CodanProblemLocation(file, startChar, endChar, line); } } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemProfile.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemProfile.java index 1eb045b9aa3..6a696d1c550 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemProfile.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemProfile.java @@ -67,7 +67,8 @@ public class ProblemProfile implements IProblemProfile, Cloneable { } public void addProblem(IProblem p, IProblemCategory cat) { - if (cat == null) cat = getRoot(); + if (cat == null) + cat = getRoot(); ((CodanProblemCategory) cat).addChild(p); } diff --git a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/Activator.java b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/Activator.java index 77d06451184..b49e385fdc9 100644 --- a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/Activator.java +++ b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/Activator.java @@ -17,13 +17,11 @@ import org.osgi.framework.BundleContext; * The activator class controls the plug-in life cycle */ public class Activator extends Plugin { - // The plug-in ID public static final String PLUGIN_ID = "org.eclipse.cdt.codan.examples"; //$NON-NLS-1$ - // The shared instance private static Activator plugin; - + /** * The constructor */ @@ -32,7 +30,9 @@ public class Activator extends Plugin { /* * (non-Javadoc) - * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) + * + * @see + * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) */ public void start(BundleContext context) throws Exception { super.start(context); @@ -41,7 +41,9 @@ public class Activator extends Plugin { /* * (non-Javadoc) - * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) + * + * @see + * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) */ public void stop(BundleContext context) throws Exception { plugin = null; @@ -50,11 +52,10 @@ public class Activator extends Plugin { /** * Returns the shared instance - * + * * @return the shared instance */ public static Activator getDefault() { return plugin; } - } diff --git a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/GrepChecker.java b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/GrepChecker.java index 5829ce0da27..44e55695d25 100644 --- a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/GrepChecker.java +++ b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/GrepChecker.java @@ -46,16 +46,13 @@ public class GrepChecker extends AbstractCheckerWithProblemPreferences { } void processFile(IFile file) { - Collection refProblems = getRuntime().getCheckersRegistry() - .getRefProblems(this); - for (Iterator iterator = refProblems.iterator(); iterator - .hasNext();) { + Collection refProblems = getRuntime().getCheckersRegistry().getRefProblems(this); + for (Iterator iterator = refProblems.iterator(); iterator.hasNext();) { IProblem checkerProblem = iterator.next(); IProblem problem = getProblemById(checkerProblem.getId(), file); if (shouldProduceProblem(problem, file.getLocation())) { // do something - Object[] values = (Object[]) getPreference(problem, - PARAM_STRING_LIST); + Object[] values = (Object[]) getPreference(problem, PARAM_STRING_LIST); if (values.length == 0) continue; // nothing to do externalRun(file, values, problem); @@ -81,8 +78,7 @@ public class GrepChecker extends AbstractCheckerWithProblemPreferences { for (int i = 0; i < values.length; i++) { String str = (String) values[i]; if (line.contains(str)) { - reportProblem(problem.getId(), file, iline, "Found " - + str); + reportProblem(problem.getId(), file, iline, "Found " + str); } } } @@ -104,7 +100,6 @@ public class GrepChecker extends AbstractCheckerWithProblemPreferences { @Override public void initPreferences(IProblemWorkingCopy problem) { super.initPreferences(problem); - addListPreference(problem, PARAM_STRING_LIST, "Search strings", - "Search string"); + addListPreference(problem, PARAM_STRING_LIST, "Search strings", "Search string"); } } diff --git a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/NamingConventionFunctionIIndexChecker.java b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/NamingConventionFunctionIIndexChecker.java index f99d01a1013..3105617b63f 100644 --- a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/NamingConventionFunctionIIndexChecker.java +++ b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/NamingConventionFunctionIIndexChecker.java @@ -28,8 +28,7 @@ import org.eclipse.cdt.core.model.ITranslationUnit; * @author Alena * */ -public class NamingConventionFunctionIIndexChecker extends - AbstractCIndexChecker implements ICheckerWithPreferences { +public class NamingConventionFunctionIIndexChecker extends AbstractCIndexChecker implements ICheckerWithPreferences { private static final String DEFAULT_PATTERN = "^[a-z]"; // name starts with english lowercase letter //$NON-NLS-1$ public static final String PARAM_KEY = "pattern"; //$NON-NLS-1$ private static final String ER_ID = "org.eclipse.cdt.codan.examples.checkers.NamingConventionFunctionProblem"; //$NON-NLS-1$ @@ -47,8 +46,7 @@ public class NamingConventionFunctionIIndexChecker extends unit.accept(new ICElementVisitor() { public boolean visit(ICElement element) { if (element.getElementType() == ICElement.C_FUNCTION) { - String parameter = (String) pt.getPreference() - .getValue(); + String parameter = (String) pt.getPreference().getValue(); Pattern pattern = Pattern.compile(parameter); String name = element.getElementName(); if (!pattern.matcher(name).find()) { @@ -74,8 +72,7 @@ public class NamingConventionFunctionIIndexChecker extends */ public void initPreferences(IProblemWorkingCopy problem) { super.initPreferences(problem); - IProblemPreference info = new BasicProblemPreference(PARAM_KEY, - "Name Pattern"); + IProblemPreference info = new BasicProblemPreference(PARAM_KEY, "Name Pattern"); addPreference(problem, info, DEFAULT_PATTERN); } diff --git a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/FlexlintHelpLink.java b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/FlexlintHelpLink.java index f37dabdbf9d..4c8b5d3af71 100644 --- a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/FlexlintHelpLink.java +++ b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/uicontrib/FlexlintHelpLink.java @@ -44,6 +44,4 @@ public class FlexlintHelpLink extends AbstractCodanProblemDetailsProvider { String url = "http://www.gimpel-online.com/MsgRef.html#" + helpId; return "" + url + ""; } - - } diff --git a/codan/org.eclipse.cdt.codan.ui.cfgview/src/org/eclipse/cdt/codan/ui/cfgview/ControlFlowGraphPlugin.java b/codan/org.eclipse.cdt.codan.ui.cfgview/src/org/eclipse/cdt/codan/ui/cfgview/ControlFlowGraphPlugin.java index 5c04087efa2..ad7784d8e7a 100644 --- a/codan/org.eclipse.cdt.codan.ui.cfgview/src/org/eclipse/cdt/codan/ui/cfgview/ControlFlowGraphPlugin.java +++ b/codan/org.eclipse.cdt.codan.ui.cfgview/src/org/eclipse/cdt/codan/ui/cfgview/ControlFlowGraphPlugin.java @@ -10,13 +10,11 @@ import org.osgi.framework.BundleContext; * The activator class controls the plug-in life cycle */ public class ControlFlowGraphPlugin extends AbstractUIPlugin { - // The plug-in ID public static final String PLUGIN_ID = "org.eclipse.cdt.codan.ui.cfgview"; //$NON-NLS-1$ - // The shared instance private static ControlFlowGraphPlugin plugin; - + /** * The constructor */ @@ -25,7 +23,10 @@ public class ControlFlowGraphPlugin extends AbstractUIPlugin { /* * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + * + * @see + * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext + * ) */ public void start(BundleContext context) throws Exception { super.start(context); @@ -34,7 +35,10 @@ public class ControlFlowGraphPlugin extends AbstractUIPlugin { /* * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + * + * @see + * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext + * ) */ public void stop(BundleContext context) throws Exception { plugin = null; @@ -43,7 +47,7 @@ public class ControlFlowGraphPlugin extends AbstractUIPlugin { /** * Returns the shared instance - * + * * @return the shared instance */ public static ControlFlowGraphPlugin getDefault() { @@ -53,7 +57,7 @@ public class ControlFlowGraphPlugin extends AbstractUIPlugin { /** * Returns an image descriptor for the image file at the given * plug-in relative path - * + * * @param path the path * @return the image descriptor */ @@ -61,22 +65,20 @@ public class ControlFlowGraphPlugin extends AbstractUIPlugin { ImageRegistry registry = getImageRegistry(); ImageDescriptor descriptor = registry.getDescriptor(key); if (descriptor == null) { - descriptor = imageDescriptorFromPlugin(PLUGIN_ID,key); + descriptor = imageDescriptorFromPlugin(PLUGIN_ID, key); registry.put(key, descriptor); } return descriptor; } - + public Image getImage(String key) { ImageRegistry registry = getImageRegistry(); Image image = registry.get(key); if (image == null) { - ImageDescriptor descriptor = imageDescriptorFromPlugin(PLUGIN_ID,key); + ImageDescriptor descriptor = imageDescriptorFromPlugin(PLUGIN_ID, key); registry.put(key, descriptor); image = registry.get(key); } return image; } - - } diff --git a/codan/org.eclipse.cdt.codan.ui.cfgview/src/org/eclipse/cdt/codan/ui/cfgview/views/ControlFlowGraphView.java b/codan/org.eclipse.cdt.codan.ui.cfgview/src/org/eclipse/cdt/codan/ui/cfgview/views/ControlFlowGraphView.java index 66c3755c9b1..5a8b6b84440 100644 --- a/codan/org.eclipse.cdt.codan.ui.cfgview/src/org/eclipse/cdt/codan/ui/cfgview/views/ControlFlowGraphView.java +++ b/codan/org.eclipse.cdt.codan.ui.cfgview/src/org/eclipse/cdt/codan/ui/cfgview/views/ControlFlowGraphView.java @@ -96,9 +96,10 @@ public class ControlFlowGraphView extends ViewPart { private Action action1; private Action doubleClickAction; - class DeadNodes extends ArrayList {} - class ViewContentProvider implements IStructuredContentProvider, - ITreeContentProvider { + class DeadNodes extends ArrayList { + } + + class ViewContentProvider implements IStructuredContentProvider, ITreeContentProvider { public void inputChanged(Viewer v, Object oldInput, Object newInput) { } @@ -117,32 +118,29 @@ public class ControlFlowGraphView extends ViewPart { if (parent instanceof Collection) { return ((Collection) parent).toArray(); } else if (parent instanceof IControlFlowGraph) { - Collection blocks = getFlat( - ((IControlFlowGraph) parent).getStartNode(), - new ArrayList()); + Collection blocks = getFlat(((IControlFlowGraph) parent).getStartNode(), new ArrayList()); DeadNodes dead = new DeadNodes(); Iterator iter = ((IControlFlowGraph) parent).getUnconnectedNodeIterator(); for (; iter.hasNext();) { IBasicBlock iBasicBlock = (IBasicBlock) iter.next(); - dead.add(iBasicBlock); + dead.add(iBasicBlock); } ArrayList all = new ArrayList(); all.addAll(blocks); - if (dead.size()>0) all.add(dead); + if (dead.size() > 0) + all.add(dead); return all.toArray(); } else if (parent instanceof IDecisionNode) { ArrayList blocks = new ArrayList(); - IBasicBlock[] outgoingNodes = ((IDecisionNode) parent) - .getOutgoingNodes(); + IBasicBlock[] outgoingNodes = ((IDecisionNode) parent).getOutgoingNodes(); for (int i = 0; i < outgoingNodes.length; i++) { - IBasicBlock arc= outgoingNodes[i]; + IBasicBlock arc = outgoingNodes[i]; blocks.add(arc); } blocks.add(((IDecisionNode) parent).getMergeNode()); return blocks.toArray(); } else if (parent instanceof IBranchNode) { - Collection blocks = getFlat(((IBranchNode) parent) - .getOutgoing(), new ArrayList()); + Collection blocks = getFlat(((IBranchNode) parent).getOutgoing(), new ArrayList()); return blocks.toArray(); } return new Object[0]; @@ -157,16 +155,14 @@ public class ControlFlowGraphView extends ViewPart { * @param startNode * @return */ - public Collection getFlat(IBasicBlock node, - Collection list) { + public Collection getFlat(IBasicBlock node, Collection list) { list.add(node); if (node instanceof IJumpNode) return list; if (node instanceof ISingleOutgoing) { getFlat(((ISingleOutgoing) node).getOutgoing(), list); } else if (node instanceof IDecisionNode) { - getFlat(((IDecisionNode) node).getMergeNode().getOutgoing(), - list); + getFlat(((IDecisionNode) node).getMergeNode().getOutgoing(), list); } return list; } @@ -181,9 +177,9 @@ public class ControlFlowGraphView extends ViewPart { strdata = ((AbstractBasicBlock) obj).toStringData(); } if (obj instanceof IConnectorNode) { - strdata = blockHexLabel(obj) ; + strdata = blockHexLabel(obj); } else if (obj instanceof IJumpNode) { - strdata = "jump to "+blockHexLabel(((IJumpNode) obj).getJumpNode()); + strdata = "jump to " + blockHexLabel(((IJumpNode) obj).getJumpNode()); } return obj.getClass().getSimpleName() + ": " + strdata; } @@ -198,8 +194,7 @@ public class ControlFlowGraphView extends ViewPart { public Image getImage(Object obj) { String imageKey = "task.png"; - if (obj instanceof IDecisionNode - || obj instanceof IControlFlowGraph) + if (obj instanceof IDecisionNode || obj instanceof IControlFlowGraph) imageKey = "decision.png"; else if (obj instanceof IExitNode) imageKey = "exit.png"; @@ -211,8 +206,7 @@ public class ControlFlowGraphView extends ViewPart { imageKey = "labeled.png"; else if (obj instanceof IConnectorNode) imageKey = "connector.png"; - return ControlFlowGraphPlugin.getDefault().getImage( - "icons/" + imageKey); + return ControlFlowGraphPlugin.getDefault().getImage("icons/" + imageKey); } } @@ -279,15 +273,11 @@ public class ControlFlowGraphView extends ViewPart { private void makeActions() { action1 = new Action() { public void run() { - IEditorPart e = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage() - .getActiveEditor(); - ITranslationUnit tu = (ITranslationUnit) CDTUITools - .getEditorInputCElement(e.getEditorInput()); + IEditorPart e = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + ITranslationUnit tu = (ITranslationUnit) CDTUITools.getEditorInputCElement(e.getEditorInput()); Job job = new SharedASTJob("Job Name", tu) { @Override - public IStatus runOnAST(ILanguage lang, - IASTTranslationUnit ast) throws CoreException { + public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException { processAst(ast); return Status.OK_STATUS; } @@ -297,13 +287,11 @@ public class ControlFlowGraphView extends ViewPart { }; action1.setText("Synchronize"); action1.setToolTipText("Synchronize"); - action1.setImageDescriptor(ControlFlowGraphPlugin.getDefault() - .getImageDescriptor("icons/refresh_view.gif")); + action1.setImageDescriptor(ControlFlowGraphPlugin.getDefault().getImageDescriptor("icons/refresh_view.gif")); doubleClickAction = new Action() { public void run() { ISelection selection = viewer.getSelection(); - Object obj = ((IStructuredSelection) selection) - .getFirstElement(); + Object obj = ((IStructuredSelection) selection).getFirstElement(); showMessage("Double-click detected on " + obj.toString()); } }; @@ -318,8 +306,7 @@ public class ControlFlowGraphView extends ViewPart { } private void showMessage(String message) { - MessageDialog.openInformation(viewer.getControl().getShell(), - "Control Flow Graph", message); + MessageDialog.openInformation(viewer.getControl().getShell(), "Control Flow Graph", message); } protected void processAst(IASTTranslationUnit ast) { @@ -331,8 +318,7 @@ public class ControlFlowGraphView extends ViewPart { public int visit(IASTDeclaration decl) { if (decl instanceof IASTFunctionDefinition) { - CxxControlFlowGraph graph = new ControlFlowGraphBuilder() - .build((IASTFunctionDefinition) decl); + CxxControlFlowGraph graph = new ControlFlowGraphBuilder().build((IASTFunctionDefinition) decl); functions.add(graph); return PROCESS_SKIP; } @@ -367,11 +353,9 @@ public class ControlFlowGraphView extends ViewPart { this.aPart = part; } - protected boolean open(String filename) throws PartInitException, - CModelException { + protected boolean open(String filename) throws PartInitException, CModelException { IPath path = new Path(filename); - IFile f = ResourcesPlugin.getWorkspace().getRoot() - .getFileForLocation(path); + IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path); if (f != null) { EditorUtility.openInEditor(f); return true; @@ -415,13 +399,10 @@ public class ControlFlowGraphView extends ViewPart { // } } if (aPart instanceof AbstractTextEditor) { - ((AbstractTextEditor) aPart).selectAndReveal(loc - .getNodeOffset(), loc.getNodeLength()); + ((AbstractTextEditor) aPart).selectAndReveal(loc.getNodeOffset(), loc.getNodeLength()); } else - System.out.println(A_PART_INSTANCEOF - + aPart.getClass().getName()); - aPart.getSite().getPage().activate( - aPart.getSite().getPage().findView(ID)); + System.out.println(A_PART_INSTANCEOF + aPart.getClass().getName()); + aPart.getSite().getPage().activate(aPart.getSite().getPage().findView(ID)); } } } 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 b9b0cce822b..456184ac31e 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 @@ -25,7 +25,8 @@ import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; /** - * Abstract class IQuickFixProcessor - not used right now because it does not work + * Abstract class IQuickFixProcessor - not used right now because it does not + * work * properly for non hardcoded errors *

    * EXPERIMENTAL. This class or interface has been added as part @@ -53,22 +54,21 @@ public abstract class AbstractCodanCQuickFixProcessor implements IQuickFixProces * .cdt.ui.text.IInvocationContext, * org.eclipse.cdt.ui.text.IProblemLocation[]) */ - public ICCompletionProposal[] getCorrections(IInvocationContext context, - IProblemLocation[] locations) throws CoreException { - if (locations==null || locations.length==0) return null; + public ICCompletionProposal[] getCorrections(IInvocationContext context, IProblemLocation[] locations) throws CoreException { + if (locations == null || locations.length == 0) + return null; IProblemLocation loc = locations[0]; - IPath location= context.getTranslationUnit().getLocation(); + IPath location = context.getTranslationUnit().getLocation(); IFile astFile = ResourceLookup.selectFileForLocation(location, context.getTranslationUnit().getCProject().getProject()); IMarker[] markers = astFile.findMarkers(loc.getMarkerType(), false, 1); for (int i = 0; i < markers.length; i++) { IMarker m = markers[i]; int start = m.getAttribute(IMarker.CHAR_START, -1); - if (start==loc.getOffset()) { - String id = m.getAttribute(ICodanProblemMarker.ID,""); //$NON-NLS-1$ + if (start == loc.getOffset()) { + String id = m.getAttribute(ICodanProblemMarker.ID, ""); //$NON-NLS-1$ return getCorrections(context, id, m); } } - return null; } @@ -87,12 +87,12 @@ public abstract class AbstractCodanCQuickFixProcessor implements IQuickFixProces } return position; } + /** * @param context * @param loc * @param marker * @return */ - public abstract ICCompletionProposal[] getCorrections(IInvocationContext context, - String problemId, IMarker marker); + public abstract ICCompletionProposal[] getCorrections(IInvocationContext context, String problemId, IMarker marker); } \ No newline at end of file diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Activator.java b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Activator.java index 7dcbaaa90f6..60851c11b18 100644 --- a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Activator.java +++ b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Activator.java @@ -17,13 +17,11 @@ import org.osgi.framework.BundleContext; * The activator class controls the plug-in life cycle */ public class Activator extends AbstractUIPlugin { - // The plug-in ID public static final String PLUGIN_ID = "org.eclipse.cdt.codan.internal.ui.cxx"; //$NON-NLS-1$ - // The shared instance private static Activator plugin; - + /** * The constructor */ @@ -32,7 +30,10 @@ public class Activator extends AbstractUIPlugin { /* * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + * + * @see + * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext + * ) */ public void start(BundleContext context) throws Exception { super.start(context); @@ -41,7 +42,10 @@ public class Activator extends AbstractUIPlugin { /* * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + * + * @see + * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext + * ) */ public void stop(BundleContext context) throws Exception { plugin = null; @@ -50,11 +54,10 @@ public class Activator extends AbstractUIPlugin { /** * Returns the shared instance - * + * * @return the shared instance */ public static Activator getDefault() { return plugin; } - } diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/CodanCReconciler.java b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/CodanCReconciler.java index 6ce024299e2..3c44ab1981f 100644 --- a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/CodanCReconciler.java +++ b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/CodanCReconciler.java @@ -75,8 +75,7 @@ public class CodanCReconciler implements ICReconcilingListener { * .eclipse.cdt.core.dom.ast.IASTTranslationUnit, boolean, * org.eclipse.core.runtime.IProgressMonitor) */ - public void reconciled(IASTTranslationUnit ast, boolean force, - IProgressMonitor progressMonitor) { + public void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor) { if (ast == null) return; String filePath = ast.getFilePath(); @@ -88,8 +87,7 @@ public class CodanCReconciler implements ICReconcilingListener { if (resources != null && resources.length > 0) { IFile resource = resources[0]; IProject project = resource.getProject(); - IPreferenceStore store = CodanUIActivator.getDefault() - .getPreferenceStore(project); + IPreferenceStore store = CodanUIActivator.getDefault().getPreferenceStore(project); if (store.getBoolean(PreferenceConstants.P_RUN_IN_EDITOR)) { reconsiler.reconciledAst(ast, resource, progressMonitor); } diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Startup.java b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Startup.java index dd87ec837c7..ae0c1bb48ee 100644 --- a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Startup.java +++ b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Startup.java @@ -81,8 +81,7 @@ public class Startup implements IStartup { }; page.addPartListener(partListener); // check current open editors - IEditorReference[] editorReferences = page - .getEditorReferences(); + IEditorReference[] editorReferences = page.getEditorReferences(); for (int i = 0; i < editorReferences.length; i++) { IEditorReference ref = editorReferences[i]; partListener.partOpened(ref); 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 abd646a8d75..33caabceefe 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 @@ -30,8 +30,7 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.ui.IMarkerResolution; import org.eclipse.ui.IMarkerResolutionGenerator; -public class CodanProblemMarkerResolutionGenerator implements - IMarkerResolutionGenerator { +public class CodanProblemMarkerResolutionGenerator implements IMarkerResolutionGenerator { private static final String EXTENSION_POINT_NAME = "codanMarkerResolution"; //$NON-NLS-1$ private static Map> resolutions = new HashMap>(); private static boolean resolutionsLoaded = false; @@ -40,8 +39,7 @@ public class CodanProblemMarkerResolutionGenerator implements IMarkerResolution res; String messagePattern; - public ConditionalResolution(IMarkerResolution res2, - String messagePattern2) { + public ConditionalResolution(IMarkerResolution res2, String messagePattern2) { res = res2; messagePattern = messagePattern2; } @@ -58,8 +56,7 @@ public class CodanProblemMarkerResolutionGenerator implements Collection collection = resolutions.get(id); if (collection != null) { ArrayList list = new ArrayList(); - for (Iterator iterator = collection - .iterator(); iterator.hasNext();) { + for (Iterator iterator = collection.iterator(); iterator.hasNext();) { ConditionalResolution res = iterator.next(); if (res.messagePattern != null) { try { @@ -71,14 +68,12 @@ public class CodanProblemMarkerResolutionGenerator implements setArgumentsFromPattern(matcher, marker); } } catch (Exception e) { - CodanUIActivator - .log("Cannot compile regex: " + res.messagePattern); //$NON-NLS-1$ + CodanUIActivator.log("Cannot compile regex: " + res.messagePattern); //$NON-NLS-1$ continue; } } if (res.res instanceof AbstractCodanCMarkerResolution) { - if (!((AbstractCodanCMarkerResolution) res.res) - .isApplicable(marker)) + if (!((AbstractCodanCMarkerResolution) res.res).isApplicable(marker)) continue; } list.add(res.res); @@ -112,8 +107,7 @@ public class CodanProblemMarkerResolutionGenerator implements } private static synchronized void readExtensions() { - IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint( - CodanUIActivator.PLUGIN_ID, EXTENSION_POINT_NAME); + IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(CodanUIActivator.PLUGIN_ID, EXTENSION_POINT_NAME); if (ep == null) return; try { @@ -131,12 +125,10 @@ public class CodanProblemMarkerResolutionGenerator implements /** * @param configurationElement */ - private static void processResolution( - IConfigurationElement configurationElement) { + private static void processResolution(IConfigurationElement configurationElement) { if (configurationElement.getName().equals("resolution")) { //$NON-NLS-1$ String id = configurationElement.getAttribute("problemId"); //$NON-NLS-1$ - String messagePattern = configurationElement - .getAttribute("messagePattern"); //$NON-NLS-1$ + String messagePattern = configurationElement.getAttribute("messagePattern"); //$NON-NLS-1$ if (id == null && messagePattern == null) { CodanUIActivator.log("Extension for " + EXTENSION_POINT_NAME //$NON-NLS-1$ + " problemId is not defined"); //$NON-NLS-1$ @@ -144,8 +136,7 @@ public class CodanProblemMarkerResolutionGenerator implements } IMarkerResolution res; try { - res = (IMarkerResolution) configurationElement - .createExecutableExtension("class");//$NON-NLS-1$ + res = (IMarkerResolution) configurationElement.createExecutableExtension("class");//$NON-NLS-1$ } catch (CoreException e) { CodanUIActivator.log(e); return; @@ -156,19 +147,16 @@ public class CodanProblemMarkerResolutionGenerator implements } catch (Exception e) { // bad pattern log and ignore CodanUIActivator.log("Extension for " //$NON-NLS-1$ - + EXTENSION_POINT_NAME - + " messagePattern is invalid: " + e.getMessage()); //$NON-NLS-1$ + + EXTENSION_POINT_NAME + " messagePattern is invalid: " + e.getMessage()); //$NON-NLS-1$ return; } } - ConditionalResolution co = new ConditionalResolution(res, - messagePattern); + ConditionalResolution co = new ConditionalResolution(res, messagePattern); addResolution(id, co); } } - public static void addResolution(String id, IMarkerResolution res, - String messagePattern) { + public static void addResolution(String id, IMarkerResolution res, String messagePattern) { addResolution(id, new ConditionalResolution(res, messagePattern)); } diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIActivator.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIActivator.java index e53026946b7..0af0fe7dba2 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIActivator.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIActivator.java @@ -77,7 +77,7 @@ public class CodanUIActivator extends AbstractUIPlugin { * relative path * * @param path - * the path + * the path * @return the image descriptor */ public static ImageDescriptor getImageDescriptor(String path) { @@ -88,7 +88,7 @@ public class CodanUIActivator extends AbstractUIPlugin { * Logs the specified status with this plug-in's log. * * @param status - * status to log + * status to log */ public static void log(IStatus status) { getDefault().getLog().log(status); @@ -98,7 +98,7 @@ public class CodanUIActivator extends AbstractUIPlugin { * Logs an internal error with the specified throwable * * @param e - * the exception to be logged + * the exception to be logged */ public static void log(Throwable e) { log(new Status(IStatus.ERROR, PLUGIN_ID, 1, "Internal Error", e)); //$NON-NLS-1$ @@ -108,7 +108,7 @@ public class CodanUIActivator extends AbstractUIPlugin { * Logs an internal error with the specified message. * * @param message - * the error message to log + * the error message to log */ public static void log(String message) { log(new Status(IStatus.ERROR, PLUGIN_ID, 1, message, null)); @@ -119,8 +119,7 @@ public class CodanUIActivator extends AbstractUIPlugin { */ public IPreferenceStore getCorePreferenceStore() { if (preferenceCoreStore == null) { - preferenceCoreStore = new ScopedPreferenceStore( - new InstanceScope(), CodanCorePlugin.PLUGIN_ID); + preferenceCoreStore = new ScopedPreferenceStore(new InstanceScope(), CodanCorePlugin.PLUGIN_ID); } return preferenceCoreStore; } diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/OpenProblemPreferences.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/OpenProblemPreferences.java index d98a05f9489..08abbe8e861 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/OpenProblemPreferences.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/OpenProblemPreferences.java @@ -21,19 +21,16 @@ public class OpenProblemPreferences implements IObjectActionDelegate { public void run(IAction action) { if (selection instanceof IStructuredSelection) { - Object firstElement = ((IStructuredSelection) selection) - .getFirstElement(); // TODO support multiple + Object firstElement = ((IStructuredSelection) selection).getFirstElement(); // TODO support multiple if (firstElement instanceof IMarker) { IMarker marker = (IMarker) firstElement; String id = CodanProblemMarker.getProblemId(marker); if (id == null) return; IResource resource = marker.getResource(); - IProblemProfile profile = CodanProblemMarker - .getProfile(resource); + IProblemProfile profile = CodanProblemMarker.getProfile(resource); CodanProblem problem = ((CodanProblem) profile.findProblem(id)); - new CustomizeProblemDialog(targetPart.getSite().getShell(), - problem, resource).open(); + new CustomizeProblemDialog(targetPart.getSite().getShell(), problem, resource).open(); } } } diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/RunCodeAnalysis.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/RunCodeAnalysis.java index fdea5db0a10..06ca236eff7 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/RunCodeAnalysis.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/RunCodeAnalysis.java @@ -55,10 +55,8 @@ public class RunCodeAnalysis implements IObjectActionDelegate { } if (o instanceof IResource) { IResource res = (IResource) o; - SubProgressMonitor subMon = new SubProgressMonitor( - monitor, 100); - CodanRuntime.getInstance().getBuilder() - .processResource(res, subMon); + SubProgressMonitor subMon = new SubProgressMonitor(monitor, 100); + CodanRuntime.getInstance().getBuilder().processResource(res, subMon); if (subMon.isCanceled()) return Status.CANCEL_STATUS; } diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/ToggleNatureAction.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/ToggleNatureAction.java index 94c51f051f8..352faec95d1 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/ToggleNatureAction.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/ToggleNatureAction.java @@ -34,15 +34,13 @@ public class ToggleNatureAction implements IObjectActionDelegate { */ public void run(IAction action) { if (selection instanceof IStructuredSelection) { - for (Iterator it = ((IStructuredSelection) selection).iterator(); it - .hasNext();) { + for (Iterator it = ((IStructuredSelection) selection).iterator(); it.hasNext();) { Object element = it.next(); IProject project = null; if (element instanceof IProject) { project = (IProject) element; } else if (element instanceof IAdaptable) { - project = (IProject) ((IAdaptable) element) - .getAdapter(IProject.class); + project = (IProject) ((IAdaptable) element).getAdapter(IProject.class); } if (project != null) { toggleNature(project, !hasCodanNature(project)); @@ -92,7 +90,7 @@ public class ToggleNatureAction implements IObjectActionDelegate { * Toggles codan nature on a project * * @param project - * to have codan nature added or removed + * to have codan nature added or removed */ public void toggleNature(IProject project, boolean add) { try { @@ -104,8 +102,7 @@ public class ToggleNatureAction implements IObjectActionDelegate { // Remove the nature String[] newNatures = new String[natures.length - 1]; System.arraycopy(natures, 0, newNatures, 0, i); - System.arraycopy(natures, i + 1, newNatures, i, - natures.length - i - 1); + System.arraycopy(natures, i + 1, newNatures, i, natures.length - i - 1); description.setNatureIds(newNatures); project.setDescription(description, null); return; diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CustomizeProblemDialog.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CustomizeProblemDialog.java index 8b35f1d6c32..14c598a191e 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CustomizeProblemDialog.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/CustomizeProblemDialog.java @@ -36,8 +36,7 @@ public class CustomizeProblemDialog extends TitleAreaDialog { * @param selectedProblem * @param iResource */ - public CustomizeProblemDialog(Shell parentShell, IProblem selectedProblem, - IResource resource) { + public CustomizeProblemDialog(Shell parentShell, IProblem selectedProblem, IResource resource) { super(parentShell); this.problem = selectedProblem; this.resource = resource; @@ -48,7 +47,7 @@ public class CustomizeProblemDialog extends TitleAreaDialog { * Stores edit values into problem working copy * * @param problem - * - problem working copy + * - problem working copy */ public void save(IProblemWorkingCopy problem) { comp.save(problem); diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/ExclusionInclusionEntryDialog.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/ExclusionInclusionEntryDialog.java index 5367e8bbb38..71805af2aa2 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/ExclusionInclusionEntryDialog.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/dialogs/ExclusionInclusionEntryDialog.java @@ -59,8 +59,7 @@ public class ExclusionInclusionEntryDialog extends StatusDialog { private List fExistingPatterns; private boolean fIsExclusion; - public ExclusionInclusionEntryDialog(Shell parent, boolean isExclusion, - String patternToEdit, List existingPatterns, + public ExclusionInclusionEntryDialog(Shell parent, boolean isExclusion, String patternToEdit, List existingPatterns, FileScopeProblemPreference entryToEdit) { super(parent); fIsExclusion = isExclusion; @@ -72,28 +71,23 @@ public class ExclusionInclusionEntryDialog extends StatusDialog { } else { title = CodanUIMessages.ExclusionInclusionEntryDialog_exclude_edit_title; } - message = MessageFormat - .format(CodanUIMessages.ExclusionInclusionEntryDialog_exclude_pattern_label, - BasicElementLabels.getPathLabel( - entryToEdit.getPath(), false)); + message = MessageFormat.format(CodanUIMessages.ExclusionInclusionEntryDialog_exclude_pattern_label, + BasicElementLabels.getPathLabel(entryToEdit.getPath(), false)); } else { if (patternToEdit == null) { title = CodanUIMessages.ExclusionInclusionEntryDialog_include_add_title; } else { title = CodanUIMessages.ExclusionInclusionEntryDialog_include_edit_title; } - message = MessageFormat - .format(CodanUIMessages.ExclusionInclusionEntryDialog_include_pattern_label, - BasicElementLabels.getPathLabel( - entryToEdit.getPath(), false)); + message = MessageFormat.format(CodanUIMessages.ExclusionInclusionEntryDialog_include_pattern_label, + BasicElementLabels.getPathLabel(entryToEdit.getPath(), false)); } setTitle(title); if (patternToEdit != null) { fExistingPatterns.remove(patternToEdit); } IProject currProject = entryToEdit.getProject(); - IWorkspaceRoot root = currProject != null ? currProject.getWorkspace() - .getRoot() : ResourcesPlugin.getWorkspace().getRoot(); + IWorkspaceRoot root = currProject != null ? currProject.getWorkspace().getRoot() : ResourcesPlugin.getWorkspace().getRoot(); IResource res = root.findMember(entryToEdit.getPath()); if (res instanceof IContainer) { fCurrSourceFolder = (IContainer) res; @@ -102,8 +96,7 @@ public class ExclusionInclusionEntryDialog extends StatusDialog { ExclusionPatternAdapter adapter = new ExclusionPatternAdapter(); fExclusionPatternDialog = new StringButtonDialogField(adapter); fExclusionPatternDialog.setLabelText(message); - fExclusionPatternDialog - .setButtonLabel(CodanUIMessages.ExclusionInclusionEntryDialog_pattern_button); + fExclusionPatternDialog.setButtonLabel(CodanUIMessages.ExclusionInclusionEntryDialog_pattern_button); fExclusionPatternDialog.setDialogFieldListener(adapter); fExclusionPatternDialog.enableButton(fCurrSourceFolder != null); if (patternToEdit == null) { @@ -125,33 +118,26 @@ public class ExclusionInclusionEntryDialog extends StatusDialog { inner.setLayout(layout); Label description = new Label(inner, SWT.WRAP); if (fIsExclusion) { - description - .setText(CodanUIMessages.ExclusionInclusionEntryDialog_exclude_description); + description.setText(CodanUIMessages.ExclusionInclusionEntryDialog_exclude_description); } else { - description - .setText(CodanUIMessages.ExclusionInclusionEntryDialog_include_description); + description.setText(CodanUIMessages.ExclusionInclusionEntryDialog_include_description); } GridData gd = new GridData(); gd.horizontalSpan = 2; gd.widthHint = convertWidthInCharsToPixels(80); description.setLayoutData(gd); fExclusionPatternDialog.doFillIntoGrid(inner, 3); - LayoutUtil.setWidthHint(fExclusionPatternDialog.getLabelControl(null), - widthHint); - LayoutUtil.setHorizontalSpan( - fExclusionPatternDialog.getLabelControl(null), 2); - LayoutUtil.setWidthHint(fExclusionPatternDialog.getTextControl(null), - widthHint); - LayoutUtil.setHorizontalGrabbing(fExclusionPatternDialog - .getTextControl(null)); + LayoutUtil.setWidthHint(fExclusionPatternDialog.getLabelControl(null), widthHint); + LayoutUtil.setHorizontalSpan(fExclusionPatternDialog.getLabelControl(null), 2); + LayoutUtil.setWidthHint(fExclusionPatternDialog.getTextControl(null), widthHint); + LayoutUtil.setHorizontalGrabbing(fExclusionPatternDialog.getTextControl(null)); fExclusionPatternDialog.postSetFocusOnDialogField(parent.getDisplay()); applyDialogFont(composite); return composite; } // -------- ExclusionPatternAdapter -------- - private class ExclusionPatternAdapter implements IDialogFieldListener, - IStringButtonAdapter { + private class ExclusionPatternAdapter implements IDialogFieldListener, IStringButtonAdapter { // -------- IDialogFieldListener public void dialogFieldChanged(DialogField field) { doStatusLineUpdate(); @@ -177,19 +163,16 @@ public class ExclusionInclusionEntryDialog extends StatusDialog { protected void checkIfPatternValid() { String pattern = fExclusionPatternDialog.getText().trim(); if (pattern.length() == 0) { - fExclusionPatternStatus - .setError(CodanUIMessages.ExclusionInclusionEntryDialog_error_empty); + fExclusionPatternStatus.setError(CodanUIMessages.ExclusionInclusionEntryDialog_error_empty); return; } IPath path = new Path(pattern); if (path.isAbsolute() || path.getDevice() != null) { - fExclusionPatternStatus - .setError(CodanUIMessages.ExclusionInclusionEntryDialog_error_notrelative); + fExclusionPatternStatus.setError(CodanUIMessages.ExclusionInclusionEntryDialog_error_notrelative); return; } if (fExistingPatterns.contains(pattern)) { - fExclusionPatternStatus - .setError(CodanUIMessages.ExclusionInclusionEntryDialog_error_exists); + fExclusionPatternStatus.setError(CodanUIMessages.ExclusionInclusionEntryDialog_error_exists); return; } fExclusionPattern = pattern; @@ -219,21 +202,17 @@ public class ExclusionInclusionEntryDialog extends StatusDialog { message = CodanUIMessages.ExclusionInclusionEntryDialog_ChooseInclusionPattern_description; } IPath initialPath = new Path(fExclusionPatternDialog.getText()); - IPath[] res = chooseExclusionPattern(getShell(), fCurrSourceFolder, - title, message, initialPath, false); + IPath[] res = chooseExclusionPattern(getShell(), fCurrSourceFolder, title, message, initialPath, false); if (res == null) { return null; } return res[0]; } - public static IPath[] chooseExclusionPattern(Shell shell, - IContainer currentSourceFolder, String title, String message, + public static IPath[] chooseExclusionPattern(Shell shell, IContainer currentSourceFolder, String title, String message, IPath initialPath, boolean multiSelection) { - Class[] acceptedClasses = new Class[] { IFolder.class, IFile.class, - IProject.class }; - ISelectionStatusValidator validator = new TypedElementSelectionValidator( - acceptedClasses, multiSelection); + Class[] acceptedClasses = new Class[] { IFolder.class, IFile.class, IProject.class }; + ISelectionStatusValidator validator = new TypedElementSelectionValidator(acceptedClasses, multiSelection); ViewerFilter filter = new TypedViewerFilter(acceptedClasses); ILabelProvider lp = new WorkbenchLabelProvider(); ITreeContentProvider cp = new WorkbenchContentProvider(); @@ -253,8 +232,7 @@ public class ExclusionInclusionEntryDialog extends StatusDialog { } } } - ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog( - shell, lp, cp); + ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, lp, cp); dialog.setTitle(title); dialog.setValidator(validator); dialog.setMessage(message); @@ -265,13 +243,11 @@ public class ExclusionInclusionEntryDialog extends StatusDialog { dialog.setHelpAvailable(false); if (dialog.open() == Window.OK) { Object[] objects = dialog.getResult(); - int existingSegments = currentSourceFolder.getFullPath() - .segmentCount(); + int existingSegments = currentSourceFolder.getFullPath().segmentCount(); IPath[] resArr = new IPath[objects.length]; for (int i = 0; i < objects.length; i++) { IResource currRes = (IResource) objects[i]; - IPath path = currRes.getFullPath() - .removeFirstSegments(existingSegments).makeRelative(); + IPath path = currRes.getFullPath().removeFirstSegments(existingSegments).makeRelative(); if (currRes instanceof IContainer) { path = path.addTrailingSeparator(); } diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java index d0f35b75283..e11cfb89b0f 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java @@ -21,8 +21,7 @@ import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.ui.IWorkbenchPropertyPage; -public class BuildPropertyPage extends FieldEditorPreferencePage implements - IWorkbenchPropertyPage { +public class BuildPropertyPage extends FieldEditorPreferencePage implements IWorkbenchPropertyPage { private IAdaptable element; /** @@ -41,11 +40,9 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements */ @Override protected void createFieldEditors() { - addField(new BooleanFieldEditor(PreferenceConstants.P_RUN_ON_BUILD, - CodanUIMessages.BuildPropertyPage_RunWithBuild, + addField(new BooleanFieldEditor(PreferenceConstants.P_RUN_ON_BUILD, CodanUIMessages.BuildPropertyPage_RunWithBuild, getFieldEditorParent())); - addField(new BooleanFieldEditor(PreferenceConstants.P_RUN_IN_EDITOR, - CodanUIMessages.BuildPropertyPage_RunAsYouType, + addField(new BooleanFieldEditor(PreferenceConstants.P_RUN_IN_EDITOR, CodanUIMessages.BuildPropertyPage_RunAsYouType, getFieldEditorParent())); } @@ -55,10 +52,8 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements if (result) { IAdaptable res = getElement(); if (res instanceof IProject) { - boolean runOnBuild = getPreferenceStore().getBoolean( - PreferenceConstants.P_RUN_ON_BUILD); - new ToggleNatureAction().toggleNature((IProject) res, - runOnBuild); + boolean runOnBuild = getPreferenceStore().getBoolean(PreferenceConstants.P_RUN_ON_BUILD); + new ToggleNatureAction().toggleNature((IProject) res, runOnBuild); // if (runOnBuild == false) { // boolean openQuestion = MessageDialog // .openQuestion( @@ -96,8 +91,7 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements public void setElement(IAdaptable element) { this.element = element; if (getElement() != null) { - IPreferenceStore scoped = CodanUIActivator.getDefault() - .getPreferenceStore(((IProject) getElement())); + IPreferenceStore scoped = CodanUIActivator.getDefault().getPreferenceStore(((IProject) getElement())); setPreferenceStore(scoped); } } diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CheckedTreeEditor.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CheckedTreeEditor.java index ce55a32e8e4..629d3941458 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CheckedTreeEditor.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CheckedTreeEditor.java @@ -37,8 +37,7 @@ import org.eclipse.swt.widgets.Tree; * getListSeparator framework methods. *

    */ -public abstract class CheckedTreeEditor extends FieldEditor implements - ICheckStateListener { +public abstract class CheckedTreeEditor extends FieldEditor implements ICheckStateListener { /** * The list widget; null if none (before creation or after * disposal). @@ -58,11 +57,11 @@ public abstract class CheckedTreeEditor extends FieldEditor implements * Creates a list field editor. * * @param name - * the name of the preference this field editor works on + * the name of the preference this field editor works on * @param labelText - * the label text of the field editor + * the label text of the field editor * @param parent - * the parent of the field editor's control + * the parent of the field editor's control */ public CheckedTreeEditor(String name, String labelText, Composite parent) { init(name, labelText); @@ -188,8 +187,7 @@ public abstract class CheckedTreeEditor extends FieldEditor implements */ protected void doLoadDefault() { if (getTreeControl() != null) { - String s = getPreferenceStore().getDefaultString( - getPreferenceName()); + String s = getPreferenceStore().getDefaultString(getPreferenceName()); getViewer().setInput(modelFromString(s)); } } @@ -208,15 +206,14 @@ public abstract class CheckedTreeEditor extends FieldEditor implements * Returns this field editor's list control. * * @param parent - * the parent control + * the parent control * @return the list control */ public Tree createListControl(Composite parent) { Tree table = (Tree) getTreeControl(); if (table == null) { listParent = parent; - treeViewer = new CheckboxTreeViewer(parent, SWT.BORDER | SWT.MULTI - | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION); + treeViewer = new CheckboxTreeViewer(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION); table = treeViewer.getTree(); table.setFont(parent.getFont()); treeViewer.addCheckStateListener(this); diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java index 7ae9e4f48e1..b44d38d68aa 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java @@ -57,7 +57,6 @@ import org.eclipse.ui.preferences.ScopedPreferenceStore; public class CodanPreferencePage extends FieldEditorOverlayPage implements IWorkbenchPreferencePage { private static final String EMPTY_STRING = ""; //$NON-NLS-1$ private static final String SINGLE_PLACEHOLDER_ONLY = "{0}"; //$NON-NLS-1$ - private IProblemProfile profile; private ISelectionChangedListener problemSelectionListener; private IProblem selectedProblem; @@ -70,8 +69,7 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements IWork public CodanPreferencePage() { super(GRID); - setPreferenceStore(new ScopedPreferenceStore(new InstanceScope(), - CodanCorePlugin.PLUGIN_ID)); + setPreferenceStore(new ScopedPreferenceStore(new InstanceScope(), CodanCorePlugin.PLUGIN_ID)); // setDescription("Code Analysis Preference Page"); problemSelectionListener = new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { @@ -102,14 +100,12 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements IWork public void createFieldEditors() { checkedTreeEditor = new ProblemsTreeEditor(getFieldEditorParent(), profile); addField(checkedTreeEditor); - checkedTreeEditor.getTreeViewer().addSelectionChangedListener( - problemSelectionListener); - checkedTreeEditor.getTreeViewer().addDoubleClickListener( - new IDoubleClickListener() { - public void doubleClick(DoubleClickEvent event) { - openCustomizeDialog(); - } - }); + checkedTreeEditor.getTreeViewer().addSelectionChangedListener(problemSelectionListener); + checkedTreeEditor.getTreeViewer().addDoubleClickListener(new IDoubleClickListener() { + public void doubleClick(DoubleClickEvent event) { + openCustomizeDialog(); + } + }); GridData layoutData = new GridData(GridData.FILL, GridData.FILL, true, true); layoutData.heightHint = 400; checkedTreeEditor.getTreeViewer().getControl().setLayoutData(layoutData); @@ -124,9 +120,8 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements IWork */ @Override protected Control createContents(Composite parent) { - profile = isPropertyPage() ? - getRegistry().getResourceProfileWorkingCopy((IResource) getElement()) : - getRegistry().getWorkspaceProfile(); + profile = isPropertyPage() ? getRegistry().getResourceProfileWorkingCopy((IResource) getElement()) : getRegistry() + .getWorkspaceProfile(); Composite comp = (Composite) super.createContents(parent); createInfoControl(comp); return comp; @@ -140,10 +135,8 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements IWork info.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); info.setLayout(new GridLayout(2, false)); info.setText(CodanUIMessages.CodanPreferencePage_Info); - GridDataFactory gdLab = - GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).grab(false, false); - GridDataFactory gdFact = - GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).grab(true, true); + GridDataFactory gdLab = GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).grab(false, false); + GridDataFactory gdFact = GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).grab(true, true); // message Label labelMessage = new Label(info, SWT.NONE); labelMessage.setText(CodanUIMessages.CodanPreferencePage_MessageLabel); @@ -151,26 +144,20 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements IWork infoMessage = new Label(info, SWT.WRAP); infoMessage.setLayoutData(gdFact.copy().create()); // description -// Label labelDesc = new Label(info, SWT.NONE); -// labelDesc.setText(CodanUIMessages.CodanPreferencePage_Description); -// labelDesc.setLayoutData(gdLab.create()); + // Label labelDesc = new Label(info, SWT.NONE); + // labelDesc.setText(CodanUIMessages.CodanPreferencePage_Description); + // labelDesc.setLayoutData(gdLab.create()); infoDesc = new Label(info, SWT.WRAP); PixelConverter pixelConverter = new PixelConverter(comp); - infoDesc.setLayoutData(gdFact - .copy() - .span(2, 1) - .hint(SWT.DEFAULT, - pixelConverter.convertHeightInCharsToPixels(3)) - .create()); + infoDesc.setLayoutData(gdFact.copy().span(2, 1).hint(SWT.DEFAULT, pixelConverter.convertHeightInCharsToPixels(3)).create()); // params -// Label labelParams = new Label(info, SWT.NONE); -// labelParams.setText(CodanUIMessages.CodanPreferencePage_Parameters); -// labelParams.setLayoutData(gdLab.create()); -// infoParams = new Label(info, SWT.NONE); -// infoParams.setLayoutData(gdFact.create()); + // Label labelParams = new Label(info, SWT.NONE); + // labelParams.setText(CodanUIMessages.CodanPreferencePage_Parameters); + // labelParams.setLayoutData(gdLab.create()); + // infoParams = new Label(info, SWT.NONE); + // infoParams.setLayoutData(gdFact.create()); infoButton = new Button(info, SWT.PUSH); - infoButton.setLayoutData( - GridDataFactory.swtDefaults().span(2, 1).align(SWT.END, SWT.BEGINNING).create()); + infoButton.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).align(SWT.END, SWT.BEGINNING).create()); infoButton.setText(CodanUIMessages.CodanPreferencePage_Customize); infoButton.addSelectionListener(new SelectionAdapter() { @Override @@ -210,15 +197,14 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements IWork } private void saveWidgetValues() { - CodanUIActivator.getDefault().getDialogSettings().put(getWidgetId(), - selectedProblem == null ? EMPTY_STRING : selectedProblem.getId()); + CodanUIActivator.getDefault().getDialogSettings() + .put(getWidgetId(), selectedProblem == null ? EMPTY_STRING : selectedProblem.getId()); } private void restoreWidgetValues() { String id = CodanUIActivator.getDefault().getDialogSettings().get(getWidgetId()); if (id != null && id.length() > 0 && checkedTreeEditor != null) { - checkedTreeEditor.getTreeViewer().setSelection( - new StructuredSelection(profile.findProblem(id)), true); + checkedTreeEditor.getTreeViewer().setSelection(new StructuredSelection(profile.findProblem(id)), true); } else { setSelectedProblem(null); } @@ -233,9 +219,9 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements IWork private void updateProblemInfo() { if (selectedProblem == null) { - infoMessage.setText(EMPTY_STRING); - infoDesc.setText(EMPTY_STRING); -// infoParams.setText(""); //$NON-NLS-1$ + infoMessage.setText(EMPTY_STRING); + infoDesc.setText(EMPTY_STRING); + // infoParams.setText(""); //$NON-NLS-1$ infoButton.setEnabled(false); } else { String description = selectedProblem.getDescription(); @@ -245,16 +231,15 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements IWork String message = CodanUIMessages.CodanPreferencePage_NoInfo; if (SINGLE_PLACEHOLDER_ONLY.equals(messagePattern)) { message = EMPTY_STRING; - } - else if (messagePattern != null) { + } else if (messagePattern != null) { message = MessageFormat.format(messagePattern, "X", "Y", "Z"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } infoMessage.setText(message); infoDesc.setText(description); -// IProblemPreference pref = selectedProblem.getPreference(); -// infoParams.setText(pref == null ? -// CodanUIMessages.CodanPreferencePage_NoInfo : -// CodanUIMessages.CodanPreferencePage_HasPreferences); + // IProblemPreference pref = selectedProblem.getPreference(); + // infoParams.setText(pref == null ? + // CodanUIMessages.CodanPreferencePage_NoInfo : + // CodanUIMessages.CodanPreferencePage_HasPreferences); infoButton.setEnabled(true); } info.layout(true); @@ -263,7 +248,8 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements IWork /* * (non-Javadoc) * - * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + * @see + * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) */ public void init(IWorkbench workbench) { } @@ -271,8 +257,7 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements IWork protected void openCustomizeDialog() { if (selectedProblem == null) return; - CustomizeProblemDialog dialog = new CustomizeProblemDialog(getShell(), selectedProblem, - (IResource) getElement()); + CustomizeProblemDialog dialog = new CustomizeProblemDialog(getShell(), selectedProblem, (IResource) getElement()); dialog.open(); } } \ No newline at end of file diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FieldEditorOverlayPage.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FieldEditorOverlayPage.java index bff873700df..22f63b14d1e 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FieldEditorOverlayPage.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FieldEditorOverlayPage.java @@ -46,15 +46,13 @@ import org.eclipse.ui.preferences.ScopedPreferenceStore; /** * @author Berthold Daum */ -public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage - implements IWorkbenchPropertyPage { +public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage implements IWorkbenchPropertyPage { // Stores all created field editors private List editors = new ArrayList(); // Stores owning element of properties private IAdaptable element; // Additional buttons for property pages - private Button useWorkspaceSettingsButton, useProjectSettingsButton, - configureButton; + private Button useWorkspaceSettingsButton, useProjectSettingsButton, configureButton; // Overlay preference store for property pages private IPreferenceStore overlayStore; // The image descriptor of this pages title image @@ -167,10 +165,8 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage IAdaptable e = getElement(); if (e != null) { ProjectScope ps = new ProjectScope((IProject) e); - ScopedPreferenceStore scoped = new ScopedPreferenceStore(ps, - CodanCorePlugin.PLUGIN_ID); - scoped.setSearchContexts(new IScopeContext[] { ps, - new InstanceScope() }); + ScopedPreferenceStore scoped = new ScopedPreferenceStore(ps, CodanCorePlugin.PLUGIN_ID); + scoped.setSearchContexts(new IScopeContext[] { ps, new InstanceScope() }); overlayStore = scoped; } // Set overlay store as current preference store @@ -211,13 +207,10 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage Composite radioGroup = new Composite(comp, SWT.NONE); radioGroup.setLayout(new GridLayout()); radioGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - useWorkspaceSettingsButton = createRadioButton(radioGroup, - CodanUIMessages.OverlayPage_Use_Workspace_Settings); - useProjectSettingsButton = createRadioButton(radioGroup, - CodanUIMessages.OverlayPage_Use_Project_Settings); + useWorkspaceSettingsButton = createRadioButton(radioGroup, CodanUIMessages.OverlayPage_Use_Workspace_Settings); + useProjectSettingsButton = createRadioButton(radioGroup, CodanUIMessages.OverlayPage_Use_Project_Settings); configureButton = new Button(comp, SWT.PUSH); - configureButton - .setText(CodanUIMessages.OverlayPage_Configure_Workspace_Settings); + configureButton.setText(CodanUIMessages.OverlayPage_Configure_Workspace_Settings); configureButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -226,8 +219,7 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage }); // Set workspace/project radio buttons try { - Boolean useWorkspace = getPreferenceStore().getBoolean( - PreferenceConstants.P_USE_PARENT); + Boolean useWorkspace = getPreferenceStore().getBoolean(PreferenceConstants.P_USE_PARENT); if (useWorkspace) { useWorkspaceSettingsButton.setSelection(true); } else { @@ -254,8 +246,7 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - configureButton - .setEnabled(button == useWorkspaceSettingsButton); + configureButton.setEnabled(button == useWorkspaceSettingsButton); updateFieldEditors(); } }); @@ -312,8 +303,7 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage boolean result = super.performOk(); if (result && isPropertyPage()) { // Save state of radiobuttons in project properties - getPreferenceStore().setValue(PreferenceConstants.P_USE_PARENT, - !useProjectSettingsButton.getSelection()); + getPreferenceStore().setValue(PreferenceConstants.P_USE_PARENT, !useProjectSettingsButton.getSelection()); } return result; } @@ -342,8 +332,7 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage protected void configureWorkspaceSettings() { try { // create a new instance of the current class - IPreferencePage page = (IPreferencePage) this.getClass() - .newInstance(); + IPreferencePage page = (IPreferencePage) this.getClass().newInstance(); page.setTitle(getTitle()); page.setImageDescriptor(image); // and show it @@ -367,8 +356,7 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage final IPreferenceNode targetNode = new PreferenceNode(id, page); PreferenceManager manager = new PreferenceManager(); manager.addToRoot(targetNode); - final PreferenceDialog dialog = new PreferenceDialog(getControl() - .getShell(), manager); + final PreferenceDialog dialog = new PreferenceDialog(getControl().getShell(), manager); BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() { public void run() { dialog.create(); diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FileScopePreferencePage.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FileScopePreferencePage.java index 149dee99351..3c829f15b90 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FileScopePreferencePage.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/FileScopePreferencePage.java @@ -61,9 +61,7 @@ public class FileScopePreferencePage extends PreferencePage { setDescription(CodanUIMessages.ExclusionInclusionDialog_description2); fCurrElement = entryToEdit; fCurrProject = entryToEdit.getProject(); - IWorkspaceRoot root = fCurrProject != null ? fCurrProject - .getWorkspace().getRoot() : ResourcesPlugin.getWorkspace() - .getRoot(); + IWorkspaceRoot root = fCurrProject != null ? fCurrProject.getWorkspace().getRoot() : ResourcesPlugin.getWorkspace().getRoot(); IResource res = root.findMember(entryToEdit.getPath()); if (res instanceof IContainer) { fCurrSourceFolder = (IContainer) res; @@ -72,26 +70,18 @@ public class FileScopePreferencePage extends PreferencePage { fCurrSourceFolder = root; String excLabel = CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_label; ImageDescriptor excDescriptor = null; //JavaPluginImages.DESC_OBJS_EXCLUSION_FILTER_ATTRIB; - String[] excButtonLabels = new String[] { - CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_add, + String[] excButtonLabels = new String[] { CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_add, CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_add_multiple, - CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_edit, - null, + CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_edit, null, CodanUIMessages.ExclusionInclusionDialog_exclusion_pattern_remove }; String incLabel = CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_label; ImageDescriptor incDescriptor = null; //JavaPluginImages.DESC_OBJS_INCLUSION_FILTER_ATTRIB; - String[] incButtonLabels = new String[] { - CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_add, + String[] incButtonLabels = new String[] { CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_add, CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_add_multiple, - CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_edit, - null, + CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_edit, null, CodanUIMessages.ExclusionInclusionDialog_inclusion_pattern_remove }; - fExclusionPatternList = createListContents(entryToEdit, - FileScopeProblemPreference.EXCLUSION, excLabel, null, - excButtonLabels); - fInclusionPatternList = createListContents(entryToEdit, - FileScopeProblemPreference.INCLUSION, incLabel, null, - incButtonLabels); + fExclusionPatternList = createListContents(entryToEdit, FileScopeProblemPreference.EXCLUSION, excLabel, null, excButtonLabels); + fInclusionPatternList = createListContents(entryToEdit, FileScopeProblemPreference.INCLUSION, incLabel, null, incButtonLabels); } @Override @@ -105,15 +95,11 @@ public class FileScopePreferencePage extends PreferencePage { inner.setLayout(layout); inner.setLayoutData(new GridData(GridData.FILL_BOTH)); fInclusionPatternList.doFillIntoGrid(inner, 3); - LayoutUtil.setHorizontalSpan( - fInclusionPatternList.getLabelControl(null), 2); - LayoutUtil.setHorizontalGrabbing(fInclusionPatternList - .getListControl(null)); + LayoutUtil.setHorizontalSpan(fInclusionPatternList.getLabelControl(null), 2); + LayoutUtil.setHorizontalGrabbing(fInclusionPatternList.getListControl(null)); fExclusionPatternList.doFillIntoGrid(inner, 3); - LayoutUtil.setHorizontalSpan( - fExclusionPatternList.getLabelControl(null), 2); - LayoutUtil.setHorizontalGrabbing(fExclusionPatternList - .getListControl(null)); + LayoutUtil.setHorizontalSpan(fExclusionPatternList.getLabelControl(null), 2); + LayoutUtil.setHorizontalGrabbing(fExclusionPatternList.getListControl(null)); setControl(inner); Dialog.applyDialogFont(inner); return inner; @@ -124,8 +110,7 @@ public class FileScopePreferencePage extends PreferencePage { public ExclusionInclusionLabelProvider(String descriptorPath) { if (descriptorPath != null) { - ImageDescriptor d = CodanUIActivator - .getImageDescriptor(descriptorPath); + ImageDescriptor d = CodanUIActivator.getImageDescriptor(descriptorPath); } fElementImage = null; // XXX } @@ -141,12 +126,10 @@ public class FileScopePreferencePage extends PreferencePage { } } - private ListDialogField createListContents( - FileScopeProblemPreference entryToEdit, String key, String label, - String descriptor, String[] buttonLabels) { + private ListDialogField createListContents(FileScopeProblemPreference entryToEdit, String key, String label, String descriptor, + String[] buttonLabels) { ExclusionPatternAdapter adapter = new ExclusionPatternAdapter(); - ListDialogField patternList = new ListDialogField(adapter, - buttonLabels, new ExclusionInclusionLabelProvider(descriptor)); + ListDialogField patternList = new ListDialogField(adapter, buttonLabels, new ExclusionInclusionLabelProvider(descriptor)); patternList.setDialogFieldListener(adapter); patternList.setLabelText(label); patternList.enableButton(IDX_EDIT, false); @@ -178,10 +161,8 @@ public class FileScopePreferencePage extends PreferencePage { } private void updateStatus() { - fCurrElement.setAttribute(FileScopeProblemPreference.INCLUSION, - getInclusionPattern()); - fCurrElement.setAttribute(FileScopeProblemPreference.EXCLUSION, - getExclusionPattern()); + fCurrElement.setAttribute(FileScopeProblemPreference.INCLUSION, getInclusionPattern()); + fCurrElement.setAttribute(FileScopeProblemPreference.EXCLUSION, getExclusionPattern()); } protected void doDoubleClicked(ListDialogField field) { @@ -205,8 +186,8 @@ public class FileScopePreferencePage extends PreferencePage { } List existing = field.getElements(); String entry = (String) selElements.get(0); - ExclusionInclusionEntryDialog dialog = new ExclusionInclusionEntryDialog( - getShell(), isExclusion(field), entry, existing, fCurrElement); + ExclusionInclusionEntryDialog dialog = new ExclusionInclusionEntryDialog(getShell(), isExclusion(field), entry, existing, + fCurrElement); if (dialog.open() == Window.OK) { field.replaceElement(entry, dialog.getExclusionPattern()); } @@ -218,16 +199,15 @@ public class FileScopePreferencePage extends PreferencePage { private void addEntry(ListDialogField field) { List existing = field.getElements(); - ExclusionInclusionEntryDialog dialog = new ExclusionInclusionEntryDialog( - getShell(), isExclusion(field), null, existing, fCurrElement); + ExclusionInclusionEntryDialog dialog = new ExclusionInclusionEntryDialog(getShell(), isExclusion(field), null, existing, + fCurrElement); if (dialog.open() == Window.OK) { field.addElement(dialog.getExclusionPattern()); } } // -------- ExclusionPatternAdapter -------- - private class ExclusionPatternAdapter implements IListAdapter, - IDialogFieldListener { + private class ExclusionPatternAdapter implements IListAdapter, IDialogFieldListener { /** * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#customButtonPressed(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField, * int) @@ -296,8 +276,7 @@ public class FileScopePreferencePage extends PreferencePage { title = CodanUIMessages.ExclusionInclusionDialog_ChooseInclusionPattern_title; message = CodanUIMessages.ExclusionInclusionDialog_ChooseInclusionPattern_description; } - IPath[] res = ExclusionInclusionEntryDialog.chooseExclusionPattern( - getShell(), fCurrSourceFolder, title, message, null, true); + IPath[] res = ExclusionInclusionEntryDialog.chooseExclusionPattern(getShell(), fCurrSourceFolder, title, message, null, true); if (res != null) { for (int i = 0; i < res.length; i++) { field.addElement(res[i].toString()); diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/LaunchModesPropertyPage.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/LaunchModesPropertyPage.java index 0c8df203ae7..63afe51cf60 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/LaunchModesPropertyPage.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/LaunchModesPropertyPage.java @@ -60,15 +60,9 @@ public class LaunchModesPropertyPage extends FieldEditorPreferencePage { @Override protected void createFieldEditors() { createSelectionGroup(getFieldEditorParent()); - addField(new BooleanFieldEditor( - CheckerLaunchMode.RUN_ON_FULL_BUILD.name(), - "Run on full build", useLocalGroup)); - addField(new BooleanFieldEditor( - CheckerLaunchMode.RUN_ON_INC_BUILD.name(), - "Run on incremental build", useLocalGroup)); - addField(new BooleanFieldEditor( - CheckerLaunchMode.RUN_AS_YOU_TYPE.name(), - "Run as you type", useLocalGroup)); + addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_FULL_BUILD.name(), "Run on full build", useLocalGroup)); + addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_INC_BUILD.name(), "Run on incremental build", useLocalGroup)); + addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_AS_YOU_TYPE.name(), "Run as you type", useLocalGroup)); updateFieldEditors(); } @@ -102,8 +96,7 @@ public class LaunchModesPropertyPage extends FieldEditorPreferencePage { Composite radioGroup = new Composite(comp, SWT.NONE); radioGroup.setLayout(new GridLayout(2, false)); radioGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - useParentSettingsButton = createRadioButton(radioGroup, - CodanUIMessages.OverlayPage_Use_Project_Settings); + useParentSettingsButton = createRadioButton(radioGroup, CodanUIMessages.OverlayPage_Use_Project_Settings); configureButton = new Button(radioGroup, SWT.PUSH); configureButton.setText("Configure..."); configureButton.addSelectionListener(new SelectionAdapter() { @@ -112,15 +105,13 @@ public class LaunchModesPropertyPage extends FieldEditorPreferencePage { configureProjectSettings(); } }); - useLocalSettingsButton = createRadioButton(radioGroup, - "Use checker specific settings"); + useLocalSettingsButton = createRadioButton(radioGroup, "Use checker specific settings"); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; useLocalSettingsButton.setLayoutData(gd); // Set workspace/project radio buttons try { - Boolean useParent = getPreferenceStore().getBoolean( - CheckerLaunchMode.USE_PARENT.name()); + Boolean useParent = getPreferenceStore().getBoolean(CheckerLaunchMode.USE_PARENT.name()); if (useParent) { useParentSettingsButton.setSelection(true); } else { @@ -162,9 +153,7 @@ public class LaunchModesPropertyPage extends FieldEditorPreferencePage { public void widgetSelected(SelectionEvent e) { boolean useParent = button == useParentSettingsButton; configureButton.setEnabled(useParent); - getPreferenceStore().setValue( - CheckerLaunchMode.USE_PARENT - .name(), useParent); + getPreferenceStore().setValue(CheckerLaunchMode.USE_PARENT.name(), useParent); updateFieldEditors(); } }); diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/PreferenceInitializer.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/PreferenceInitializer.java index 645a89260fa..a51029397d3 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/PreferenceInitializer.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/PreferenceInitializer.java @@ -26,8 +26,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer { * initializeDefaultPreferences() */ public void initializeDefaultPreferences() { - IPreferenceStore store = CodanUIActivator.getDefault() - .getPreferenceStore(); + IPreferenceStore store = CodanUIActivator.getDefault().getPreferenceStore(); store.setDefault(PreferenceConstants.P_RUN_ON_BUILD, false); store.setDefault(PreferenceConstants.P_RUN_IN_EDITOR, true); } diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java index 4547028cb37..895fe9d637d 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/ProblemsTreeEditor.java @@ -103,8 +103,7 @@ public class ProblemsTreeEditor extends CheckedTreeEditor { } } - class ProblemsContentProvider implements IContentProvider, - ITreeContentProvider { + class ProblemsContentProvider implements IContentProvider, ITreeContentProvider { public void dispose() { // TODO Auto-generated method stub } @@ -120,8 +119,7 @@ public class ProblemsTreeEditor extends CheckedTreeEditor { return ((IProblemCategory) parentElement).getChildren(); } if (parentElement instanceof IProblemProfile) { - return ((IProblemProfile) parentElement).getRoot() - .getChildren(); + return ((IProblemProfile) parentElement).getRoot().getChildren(); } return new Object[0]; } @@ -149,27 +147,23 @@ public class ProblemsTreeEditor extends CheckedTreeEditor { IProblemElement[] children = cat.getChildren(); for (int i = 0; i < children.length; i++) { IProblemElement pe = children[i]; - checkStateChanged(new CheckStateChangedEvent(getTreeViewer(), - pe, event.getChecked())); + checkStateChanged(new CheckStateChangedEvent(getTreeViewer(), pe, event.getChecked())); } } getTreeViewer().refresh(); } public ProblemsTreeEditor(Composite parent, IProblemProfile profile) { - super(PreferenceConstants.P_PROBLEMS, - CodanUIMessages.ProblemsTreeEditor_Problems, parent); + super(PreferenceConstants.P_PROBLEMS, CodanUIMessages.ProblemsTreeEditor_Problems, parent); setEmptySelectionAllowed(true); getTreeViewer().getTree().setHeaderVisible(true); // getTreeViewer().getTree(). getTreeViewer().setContentProvider(new ProblemsContentProvider()); getTreeViewer().setCheckStateProvider(new ProblemsCheckStateProvider()); // column Name - TreeViewerColumn column1 = new TreeViewerColumn(getTreeViewer(), - SWT.NONE); + TreeViewerColumn column1 = new TreeViewerColumn(getTreeViewer(), SWT.NONE); column1.getColumn().setWidth(300); - column1.getColumn().setText( - CodanUIMessages.ProblemsTreeEditor_NameColumn); + column1.getColumn().setText(CodanUIMessages.ProblemsTreeEditor_NameColumn); column1.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { @@ -185,28 +179,22 @@ public class ProblemsTreeEditor extends CheckedTreeEditor { } }); // column Severity - TreeViewerColumn column2 = new TreeViewerColumn(getTreeViewer(), - SWT.NONE); + TreeViewerColumn column2 = new TreeViewerColumn(getTreeViewer(), SWT.NONE); column2.getColumn().setWidth(100); - column2.getColumn().setText( - CodanUIMessages.ProblemsTreeEditor_SeverityColumn); + column2.getColumn().setText(CodanUIMessages.ProblemsTreeEditor_SeverityColumn); column2.setLabelProvider(new ColumnLabelProvider() { @Override public Image getImage(Object element) { - final ISharedImages images = PlatformUI.getWorkbench() - .getSharedImages(); + final ISharedImages images = PlatformUI.getWorkbench().getSharedImages(); if (element instanceof IProblem) { IProblem p = (IProblem) element; switch (p.getSeverity().intValue()) { case IMarker.SEVERITY_INFO: - return images - .getImage(ISharedImages.IMG_OBJS_INFO_TSK); + return images.getImage(ISharedImages.IMG_OBJS_INFO_TSK); case IMarker.SEVERITY_WARNING: - return images - .getImage(ISharedImages.IMG_OBJS_WARN_TSK); + return images.getImage(ISharedImages.IMG_OBJS_WARN_TSK); case IMarker.SEVERITY_ERROR: - return images - .getImage(ISharedImages.IMG_OBJS_ERROR_TSK); + return images.getImage(ISharedImages.IMG_OBJS_ERROR_TSK); } } return null; @@ -229,8 +217,7 @@ public class ProblemsTreeEditor extends CheckedTreeEditor { @Override protected CellEditor getCellEditor(Object element) { - return new ComboBoxCellEditor(getTreeViewer().getTree(), - CodanSeverity.stringValues()); + return new ComboBoxCellEditor(getTreeViewer().getTree(), CodanSeverity.stringValues()); } @Override @@ -297,8 +284,7 @@ public class ProblemsTreeEditor extends CheckedTreeEditor { */ @Override protected void doStore() { - codanPreferencesLoader.setInput((IProblemProfile) getViewer() - .getInput()); + codanPreferencesLoader.setInput((IProblemProfile) getViewer().getInput()); IProblem[] probs = codanPreferencesLoader.getProblems(); for (int i = 0; i < probs.length; i++) { String id = probs[i].getId(); @@ -306,8 +292,7 @@ public class ProblemsTreeEditor extends CheckedTreeEditor { getPreferenceStore().setValue(id, s); String params = codanPreferencesLoader.getPreferencesString(id); if (params != null) - getPreferenceStore().setValue( - codanPreferencesLoader.getPreferencesKey(id), params); + getPreferenceStore().setValue(codanPreferencesLoader.getPreferencesKey(id), params); } } 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 83c5e2d5210..15cfc9f35fa 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 @@ -85,8 +85,7 @@ 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.openFileURL(link, curProvider - .getMarker().getResource()); + CodanEditorUtility.openFileURL(link, curProvider.getMarker().getResource()); } catch (PartInitException e1) { CodanUIActivator.log(e1); } catch (BadLocationException e1) { @@ -106,11 +105,9 @@ 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); } @@ -124,12 +121,10 @@ 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; } @@ -142,8 +137,7 @@ public class ProblemDetails extends ViewPart { private void queryProviders(IMarker marker) { String id = marker.getAttribute(ICodanProblemMarker.ID, "id"); //$NON-NLS-1$ - Collection providers = ProblemDetailsExtensions - .getProviders(id); + Collection providers = ProblemDetailsExtensions.getProviders(id); for (AbstractCodanProblemDetailsProvider provider : providers) { synchronized (provider) { provider.setMarker(marker); @@ -160,12 +154,10 @@ 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) { diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetailsExtensions.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetailsExtensions.java index 689d9d87f86..3158f5bdcd1 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetailsExtensions.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/views/ProblemDetailsExtensions.java @@ -32,7 +32,8 @@ public class ProblemDetailsExtensions { private static HashMap> map = new HashMap>(); private static synchronized void readExtensions() { - if (extensionsLoaded) return; + if (extensionsLoaded) + return; IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(CodanUIActivator.PLUGIN_ID, EXTENSION_POINT_NAME); if (ep == null) return; @@ -80,8 +81,11 @@ public class ProblemDetailsExtensions { /** * Remove provider from the list + * * @param id - codan problem id or ALL - * @param el - details provider (class extending AbstractCodanProblemDetailsProvider) or ElementConfiguration (user internally) + * @param el - details provider (class extending + * AbstractCodanProblemDetailsProvider) or ElementConfiguration (user + * internally) */ @SuppressWarnings("rawtypes") public static void removeExtension(String id, Object el) { @@ -118,7 +122,7 @@ public class ProblemDetailsExtensions { // resolve collection.remove(object); AbstractCodanProblemDetailsProvider provider = resolveClass((IConfigurationElement) object); - if (provider!=null) + if (provider != null) collection.add(provider); } } @@ -127,6 +131,7 @@ public class ProblemDetailsExtensions { /** * Add extension (details provider) using API + * * @param id - codan problem id or ALL * @param provider - class extending AbstractCodanProblemDetailsProvider */ diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/BasicElementLabels.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/BasicElementLabels.java index cc2f966826c..d08c0a7fa80 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/BasicElementLabels.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/BasicElementLabels.java @@ -26,21 +26,18 @@ import org.eclipse.ui.IWorkingSet; */ public class BasicElementLabels { // TextProcessor delimiters - private static final String CODE_DELIMITERS = TextProcessor - .getDefaultDelimiters() + "<>()?,{}+-*!%=^|&;[]~"; //$NON-NLS-1$ - private static final String FILE_PATTERN_DELIMITERS = TextProcessor - .getDefaultDelimiters() + "*.?"; //$NON-NLS-1$ - private static final String URL_DELIMITERS = TextProcessor - .getDefaultDelimiters() + ":@?-"; //$NON-NLS-1$ + private static final String CODE_DELIMITERS = TextProcessor.getDefaultDelimiters() + "<>()?,{}+-*!%=^|&;[]~"; //$NON-NLS-1$ + private static final String FILE_PATTERN_DELIMITERS = TextProcessor.getDefaultDelimiters() + "*.?"; //$NON-NLS-1$ + private static final String URL_DELIMITERS = TextProcessor.getDefaultDelimiters() + ":@?-"; //$NON-NLS-1$ /** * Returns the label of a path. * * @param path - * the path + * the path * @param isOSPath - * if true, the path represents an OS path, if - * false it is a workspace path. + * if true, the path represents an OS path, if + * false it is a workspace path. * @return the label of the path to be used in the UI. */ public static String getPathLabel(IPath path, boolean isOSPath) { @@ -57,7 +54,7 @@ public class BasicElementLabels { * Returns the label of the path of a file. * * @param file - * the file + * the file * @return the label of the file path to be used in the UI. */ public static String getPathLabel(File file) { @@ -68,7 +65,7 @@ public class BasicElementLabels { * Returns the label for a file pattern like '*.java' * * @param name - * the pattern + * the pattern * @return the label of the pattern. */ public static String getFilePattern(String name) { @@ -80,7 +77,7 @@ public class BasicElementLabels { * 'http://www.x.xom/s.html#1' * * @param name - * the URL string + * the URL string * @return the label of the URL. */ public static String getURLPart(String name) { @@ -91,7 +88,7 @@ public class BasicElementLabels { * Returns a label for a resource name. * * @param resource - * the resource + * the resource * @return the label of the resource name. */ public static String getResourceName(IResource resource) { @@ -102,7 +99,7 @@ public class BasicElementLabels { * Returns a label for a resource name. * * @param resourceName - * the resource name + * the resource name * @return the label of the resource name. */ public static String getResourceName(String resourceName) { @@ -114,7 +111,7 @@ public class BasicElementLabels { * test= new Test() { ...}'. * * @param string - * the Java code snippet + * the Java code snippet * @return the label for the Java code snippet */ public static String getJavaCodeString(String string) { @@ -125,7 +122,7 @@ public class BasicElementLabels { * Returns a label for a version name. Example is '1.4.1' * * @param name - * the version string + * the version string * @return the version label */ public static String getVersionName(String name) { @@ -136,7 +133,7 @@ public class BasicElementLabels { * Returns a label for a working set * * @param set - * the working set + * the working set * @return the label of the working set */ public static String getWorkingSetLabel(IWorkingSet set) { diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CustomizeProblemComposite.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CustomizeProblemComposite.java index 0d37d807296..090ec048273 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CustomizeProblemComposite.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/CustomizeProblemComposite.java @@ -39,8 +39,7 @@ public class CustomizeProblemComposite extends Composite { * @param resource * @param style */ - public CustomizeProblemComposite(Composite parent, - IProblem selectedProblem, IResource resource) { + public CustomizeProblemComposite(Composite parent, IProblem selectedProblem, IResource resource) { super(parent, SWT.NONE); this.setLayout(new GridLayout(1, false)); this.problem = selectedProblem; @@ -69,8 +68,7 @@ public class CustomizeProblemComposite extends Composite { tabItem1.setControl(parametersTab); parametersTab.setLayout(new GridLayout()); problemsComposite = new ParametersComposite(parametersTab, problem); - problemsComposite.setLayoutData(new GridData(SWT.BEGINNING, - SWT.BEGINNING, true, false)); + problemsComposite.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false)); } /** @@ -83,8 +81,7 @@ public class CustomizeProblemComposite extends Composite { tabItem1.setControl(comp); comp.setLayout(new GridLayout()); scopeComposite = new FileScopeComposite(comp, problem, resource); - scopeComposite.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, - true, false)); + scopeComposite.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false)); } private void createLaunchingTab(TabFolder tabFolder) { @@ -94,7 +91,6 @@ public class CustomizeProblemComposite extends Composite { tabItem1.setControl(comp); comp.setLayout(new GridLayout()); launchingComposite = new LaunchingTabComposite(comp, problem, resource); - launchingComposite.setLayoutData(new GridData(SWT.BEGINNING, - SWT.BEGINNING, true, false)); + launchingComposite.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false)); } } diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/FileScopeComposite.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/FileScopeComposite.java index 1a8536c8204..40dc2b848e2 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/FileScopeComposite.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/FileScopeComposite.java @@ -41,8 +41,7 @@ public class FileScopeComposite extends Composite { * @param resource * @param style */ - public FileScopeComposite(Composite parent, final IProblem problem, - IResource resource) { + public FileScopeComposite(Composite parent, final IProblem problem, IResource resource) { super(parent, SWT.NONE); if (problem == null) throw new NullPointerException(); @@ -79,8 +78,7 @@ public class FileScopeComposite extends Composite { if (scope == null) return; String key = scope.getQualifiedKey(); - ((MapProblemPreference) problem.getPreference()).setChildValue( - FileScopeProblemPreference.KEY, scope); + ((MapProblemPreference) problem.getPreference()).setChildValue(FileScopeProblemPreference.KEY, scope); prefStore.setValue(key, scope.exportValue()); } diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/LaunchingTabComposite.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/LaunchingTabComposite.java index bfbb9809d60..9c5fa7be311 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/LaunchingTabComposite.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/LaunchingTabComposite.java @@ -43,8 +43,7 @@ public class LaunchingTabComposite extends Composite { * @param resource * @param style */ - public LaunchingTabComposite(Composite parent, final IProblem problem, - IResource resource) { + public LaunchingTabComposite(Composite parent, final IProblem problem, IResource resource) { super(parent, SWT.NONE); if (problem == null) throw new NullPointerException(); @@ -81,8 +80,7 @@ public class LaunchingTabComposite extends Composite { if (launchPref == null) return; saveToPref(launchPref, page.getPreferenceStore()); - MapProblemPreference parentMap = (MapProblemPreference) problem - .getPreference(); + MapProblemPreference parentMap = (MapProblemPreference) problem.getPreference(); parentMap.addChildDescriptor(launchPref); } @@ -90,14 +88,12 @@ public class LaunchingTabComposite extends Composite { * @param launchPref2 * @param preferenceStore */ - private void saveToPref(LaunchTypeProblemPreference launchPref, - IPreferenceStore preferenceStore) { + private void saveToPref(LaunchTypeProblemPreference launchPref, IPreferenceStore preferenceStore) { CheckerLaunchMode[] values = CheckerLaunchMode.values(); for (int i = 0; i < values.length; i++) { CheckerLaunchMode checkerLaunchMode = values[i]; if (!preferenceStore.isDefault(checkerLaunchMode.name())) { - launchPref.setRunningMode(checkerLaunchMode, - preferenceStore.getBoolean(checkerLaunchMode.name())); + launchPref.setRunningMode(checkerLaunchMode, preferenceStore.getBoolean(checkerLaunchMode.name())); } } } @@ -105,13 +101,11 @@ public class LaunchingTabComposite extends Composite { private void initPrefStore() { if (launchPref == null) return; - prefStore.setDefault( - CheckerLaunchMode.USE_PARENT.name(), true); + prefStore.setDefault(CheckerLaunchMode.USE_PARENT.name(), true); CheckerLaunchMode[] values = CheckerLaunchMode.values(); for (int i = 0; i < values.length; i++) { CheckerLaunchMode checkerLaunchMode = values[i]; - prefStore.setValue(checkerLaunchMode.name(), - launchPref.isRunningInMode(checkerLaunchMode)); + prefStore.setValue(checkerLaunchMode.name(), launchPref.isRunningInMode(checkerLaunchMode)); } } diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java index bb254d9a6fb..e831813f6b8 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java @@ -66,23 +66,13 @@ public class ParametersComposite extends Composite { protected void createFieldEditors() { noDefaultAndApplyButton(); ((GridLayout) getFieldEditorParent().getLayout()).numColumns = 2; - addField(new BooleanFieldEditor(PREF_ENABLED, - CodanUIMessages.ParametersComposite_IsEnabled, - getFieldEditorParent())); - String[][] entries = { - { CodanSeverity.Error.toString(), - CodanSeverity.Error.toString() }, // - { CodanSeverity.Warning.toString(), - CodanSeverity.Warning.toString() }, // - { CodanSeverity.Info.toString(), - CodanSeverity.Info.toString() }, // + addField(new BooleanFieldEditor(PREF_ENABLED, CodanUIMessages.ParametersComposite_IsEnabled, getFieldEditorParent())); + String[][] entries = { { CodanSeverity.Error.toString(), CodanSeverity.Error.toString() }, // + { CodanSeverity.Warning.toString(), CodanSeverity.Warning.toString() }, // + { CodanSeverity.Info.toString(), CodanSeverity.Info.toString() }, // }; - addField(new ComboFieldEditor(PREF_SEVERITY, - CodanUIMessages.ParametersComposite_Severity, entries, - getFieldEditorParent())); - addField(new StringFieldEditor(PREF_MESSAGE, - CodanUIMessages.ParametersComposite_MessagePattern, - getFieldEditorParent())); + addField(new ComboFieldEditor(PREF_SEVERITY, CodanUIMessages.ParametersComposite_Severity, entries, getFieldEditorParent())); + addField(new StringFieldEditor(PREF_MESSAGE, CodanUIMessages.ParametersComposite_MessagePattern, getFieldEditorParent())); IProblemPreference pref = problem.getPreference(); createFieldEditorsForParameters(pref); } @@ -95,8 +85,7 @@ public class ParametersComposite extends Composite { /** * @param info */ - private void createFieldEditorsForParameters( - final IProblemPreference info) { + private void createFieldEditorsForParameters(final IProblemPreference info) { if (info == null) return; if (info.getKey() == FileScopeProblemPreference.KEY) @@ -105,27 +94,21 @@ public class ParametersComposite extends Composite { return; // skip the launch switch (info.getType()) { case TYPE_STRING: { - StringFieldEditor fe = new StringFieldEditor( - info.getQualifiedKey(), info.getLabel(), - getFieldEditorParent()); + StringFieldEditor fe = new StringFieldEditor(info.getQualifiedKey(), info.getLabel(), getFieldEditorParent()); addField(fe); break; } case TYPE_BOOLEAN: { - BooleanFieldEditor fe = new BooleanFieldEditor( - info.getQualifiedKey(), info.getLabel(), - getFieldEditorParent()); + BooleanFieldEditor fe = new BooleanFieldEditor(info.getQualifiedKey(), info.getLabel(), getFieldEditorParent()); addField(fe); break; } case TYPE_LIST: - ListEditor le = new ListEditor(info.getQualifiedKey(), - info.getLabel(), getFieldEditorParent()) { + ListEditor le = new ListEditor(info.getQualifiedKey(), info.getLabel(), getFieldEditorParent()) { @Override protected String[] parseString(String stringList) { ListProblemPreference list = (ListProblemPreference) info; - IProblemPreference[] childDescriptors = list - .getChildDescriptors(); + IProblemPreference[] childDescriptors = list.getChildDescriptors(); if (childDescriptors.length == 0) return new String[0]; String res[] = new String[childDescriptors.length]; @@ -139,12 +122,9 @@ public class ParametersComposite extends Composite { @Override protected String getNewInputObject() { ListProblemPreference list = (ListProblemPreference) info; - String label = list.getChildDescriptor() - .getLabel(); - InputDialog dialog = new InputDialog( - getShell(), - CodanUIMessages.ParametersComposite_NewValue, - label, "", null); //$NON-NLS-1$ + String label = list.getChildDescriptor().getLabel(); + InputDialog dialog = new InputDialog(getShell(), CodanUIMessages.ParametersComposite_NewValue, label, + "", null); //$NON-NLS-1$ if (dialog.open() == Window.OK) { return dialog.getValue(); } @@ -153,8 +133,7 @@ public class ParametersComposite extends Composite { @Override protected String createList(String[] items) { - ListProblemPreference list = (ListProblemPreference) info - .clone(); + ListProblemPreference list = (ListProblemPreference) info.clone(); list.clear(); for (int i = 0; i < items.length; i++) { String val = items[i]; @@ -166,30 +145,24 @@ public class ParametersComposite extends Composite { addField(le); break; case TYPE_MAP: - IProblemPreference[] childrenDescriptor = ((IProblemPreferenceCompositeDescriptor) info) - .getChildDescriptors(); + IProblemPreference[] childrenDescriptor = ((IProblemPreferenceCompositeDescriptor) info).getChildDescriptors(); for (int i = 0; i < childrenDescriptor.length; i++) { IProblemPreference desc = childrenDescriptor[i]; createFieldEditorsForParameters(desc); } break; case TYPE_CUSTOM: { - StringFieldEditor fe = new StringFieldEditor( - info.getQualifiedKey(), info.getLabel(), - getFieldEditorParent()); + StringFieldEditor fe = new StringFieldEditor(info.getQualifiedKey(), info.getLabel(), getFieldEditorParent()); addField(fe); break; } case TYPE_FILE: { - FileFieldEditor fe = new FileFieldEditor( - info.getQualifiedKey(), info.getLabel(), - getFieldEditorParent()); + FileFieldEditor fe = new FileFieldEditor(info.getQualifiedKey(), info.getLabel(), getFieldEditorParent()); addField(fe); break; } default: - throw new UnsupportedOperationException(info.getType() - .toString()); + throw new UnsupportedOperationException(info.getType().toString()); } } }; @@ -219,8 +192,7 @@ public class ParametersComposite extends Composite { page.performOk(); savePrefStore(problem.getPreference()); problem.setEnabled(prefStore.getBoolean(PREF_ENABLED)); - problem.setSeverity(CodanSeverity.valueOf(prefStore - .getString(PREF_SEVERITY))); + problem.setSeverity(CodanSeverity.valueOf(prefStore.getString(PREF_SEVERITY))); problem.setMessagePattern(prefStore.getString(PREF_MESSAGE)); } @@ -248,16 +220,14 @@ public class ParametersComposite extends Composite { desc.importValue(prefStore.getString(key)); break; case TYPE_MAP: - IProblemPreference[] childrenDescriptor = ((IProblemPreferenceCompositeDescriptor) desc) - .getChildDescriptors(); + IProblemPreference[] childrenDescriptor = ((IProblemPreferenceCompositeDescriptor) desc).getChildDescriptors(); for (int i = 0; i < childrenDescriptor.length; i++) { IProblemPreference chi = childrenDescriptor[i]; savePrefStore(chi); } break; default: - throw new UnsupportedOperationException(desc.getType() - .toString()); + throw new UnsupportedOperationException(desc.getType().toString()); } } @@ -285,16 +255,14 @@ public class ParametersComposite extends Composite { prefStore.setValue(key, desc.exportValue()); break; case TYPE_MAP: - IProblemPreference[] childrenDescriptor = ((IProblemPreferenceCompositeDescriptor) desc) - .getChildDescriptors(); + IProblemPreference[] childrenDescriptor = ((IProblemPreferenceCompositeDescriptor) desc).getChildDescriptors(); for (int i = 0; i < childrenDescriptor.length; i++) { IProblemPreference chi = childrenDescriptor[i]; initPrefStore(chi); } break; default: - throw new UnsupportedOperationException(desc.getType() - .toString()); + throw new UnsupportedOperationException(desc.getType().toString()); } } diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstarctCodanCMarkerResolution.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstarctCodanCMarkerResolution.java index 0771d36d7a2..599dc81ea50 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstarctCodanCMarkerResolution.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstarctCodanCMarkerResolution.java @@ -15,6 +15,5 @@ package org.eclipse.cdt.codan.ui; * {@link AbstractCodanCMarkerResolution} */ @Deprecated -public abstract class AbstarctCodanCMarkerResolution extends - AbstractCodanCMarkerResolution { +public abstract class AbstarctCodanCMarkerResolution extends AbstractCodanCMarkerResolution { } diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanCMarkerResolution.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanCMarkerResolution.java index d416ab1b9b6..7ad3282673c 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanCMarkerResolution.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanCMarkerResolution.java @@ -43,8 +43,7 @@ import org.eclipse.ui.texteditor.ITextEditor; * * @since 1.1 */ -public abstract class AbstractCodanCMarkerResolution implements - IMarkerResolution { +public abstract class AbstractCodanCMarkerResolution implements IMarkerResolution { private boolean codanProblem; /** @@ -156,8 +155,7 @@ public abstract class AbstractCodanCMarkerResolution implements protected IDocument openDocument(IEditorPart editorPart) { if (editorPart instanceof ITextEditor) { ITextEditor editor = (ITextEditor) editorPart; - IDocument doc = editor.getDocumentProvider().getDocument( - editor.getEditorInput()); + IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput()); return doc; } return null; @@ -171,8 +169,7 @@ public abstract class AbstractCodanCMarkerResolution implements * @return The translation unit */ protected ITranslationUnit getTranslationUnitViaEditor(IMarker marker) { - ITranslationUnit tu = (ITranslationUnit) CDTUITools - .getEditorInputCElement(openEditor(marker).getEditorInput()); + ITranslationUnit tu = (ITranslationUnit) CDTUITools.getEditorInputCElement(openEditor(marker).getEditorInput()); return tu; } @@ -186,8 +183,7 @@ public abstract class AbstractCodanCMarkerResolution implements protected ITranslationUnit getTranslationUnitViaWorkspace(IMarker marker) { IPath path = marker.getResource().getFullPath(); IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); - ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create( - file); + ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create(file); return tu; } @@ -200,11 +196,9 @@ public abstract class AbstractCodanCMarkerResolution implements * The AST to check * @return The enclosing ASTName or null */ - protected IASTName getASTNameFromMarker(IMarker marker, - IASTTranslationUnit ast) { + protected IASTName getASTNameFromMarker(IMarker marker, IASTTranslationUnit ast) { final int charStart = marker.getAttribute(IMarker.CHAR_START, -1); - final int length = marker.getAttribute(IMarker.CHAR_END, -1) - - charStart; + final int length = marker.getAttribute(IMarker.CHAR_END, -1) - charStart; return getASTNameFromPositions(ast, charStart, length); } @@ -214,10 +208,8 @@ public abstract class AbstractCodanCMarkerResolution implements * @param length * @return */ - protected IASTName getASTNameFromPositions(IASTTranslationUnit ast, - final int charStart, final int length) { - IASTName name = ast.getNodeSelector(null).findEnclosingName(charStart, - length); + protected IASTName getASTNameFromPositions(IASTTranslationUnit ast, final int charStart, final int length) { + IASTName name = ast.getNodeSelector(null).findEnclosingName(charStart, length); return name; } @@ -230,8 +222,7 @@ public abstract class AbstractCodanCMarkerResolution implements * @return the received index * @throws CoreException */ - protected IIndex getIndexFromMarker(final IMarker marker) - throws CoreException { + protected IIndex getIndexFromMarker(final IMarker marker) throws CoreException { IProject project = marker.getResource().getProject(); ICProject cProject = CoreModel.getDefault().create(project); IIndex index = CCorePlugin.getIndexManager().getIndex(cProject); 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 b66e3b244e5..5f8b33969ed 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 @@ -143,8 +143,7 @@ public abstract class AbstractCodanProblemDetailsProvider { String id = getProblemId(); if (id == null) return ""; //$NON-NLS-1$ - IProblem problem = CodanRuntime.getInstance().getCheckersRegistry() - .getDefaultProfile().findProblem(id); + IProblem problem = CodanRuntime.getInstance().getCheckersRegistry().getDefaultProfile().findProblem(id); String desc = problem.getDescription(); if (desc == null) return ""; //$NON-NLS-1$ diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanEditorUtility.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanEditorUtility.java index a3b5abf3fe1..f2b427115b2 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanEditorUtility.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanEditorUtility.java @@ -43,8 +43,7 @@ public class CodanEditorUtility { * @throws PartInitException * @throws BadLocationException */ - public static void openFileURL(String fileUrl, IResource markerResource) - throws PartInitException, BadLocationException { + public static void openFileURL(String fileUrl, IResource markerResource) throws PartInitException, BadLocationException { String file = getFileFromURL(fileUrl); IEditorPart part = openInEditor(file, markerResource); int line = getLineFromURL(fileUrl); @@ -73,21 +72,18 @@ public class CodanEditorUtility { return file; } - public static void revealLine(IEditorPart part, int line) - throws BadLocationException { + public static void revealLine(IEditorPart part, int line) throws BadLocationException { if (line > 0) { if (part instanceof ITextEditor) { ITextEditor textEditor = (ITextEditor) part; - IDocument document = textEditor.getDocumentProvider() - .getDocument(part.getEditorInput()); + IDocument document = textEditor.getDocumentProvider().getDocument(part.getEditorInput()); textEditor.selectAndReveal(document.getLineOffset(line - 1), 0); } } } @SuppressWarnings("restriction") - public static IEditorPart openInEditor(String file, IResource markerResource) - throws PartInitException { + public static IEditorPart openInEditor(String file, IResource markerResource) throws PartInitException { IPath pfile = new Path(file); ICElement element = null; if (markerResource != null) @@ -96,8 +92,7 @@ public class CodanEditorUtility { return part; } - public static IEditorPart openInEditor(IMarker marker) - throws PartInitException { + public static IEditorPart openInEditor(IMarker marker) throws PartInitException { String href = getLocationHRef(marker); String file = getFileFromURL(href); return openInEditor(file, marker.getResource()); diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/JFaceTextUtils.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/JFaceTextUtils.java index 79923062218..34dfd34d271 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/JFaceTextUtils.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/JFaceTextUtils.java @@ -37,11 +37,9 @@ public final class JFaceTextUtils { * @param document * the document to use */ - public static void markLocationForInsert(IASTFileLocation location, - ITextViewer viewer) { + public static void markLocationForInsert(IASTFileLocation location, ITextViewer viewer) { IDocument document = viewer.getDocument(); - LinkedPosition pos = new LinkedPosition(document, - location.getNodeOffset(), location.getNodeLength()); + LinkedPosition pos = new LinkedPosition(document, location.getNodeOffset(), location.getNodeLength()); LinkedModeModel model = new LinkedModeModel(); LinkedPositionGroup group = new LinkedPositionGroup(); try { diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/RunCodanCommand.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/RunCodanCommand.java index d0999a86cac..4d4d72855d5 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/RunCodanCommand.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/handlers/RunCodanCommand.java @@ -19,11 +19,11 @@ import org.eclipse.ui.handlers.HandlerUtil; /** * Command to run code analysis on selected resources + * * @see org.eclipse.core.commands.IHandler * @see org.eclipse.core.commands.AbstractHandler */ public class RunCodanCommand extends AbstractHandler { - public RunCodanCommand() { }