mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
Moved execution of checkers from CodanBuilder to CodanRunner.
This commit is contained in:
parent
d40474476a
commit
4c3a5dd669
18 changed files with 289 additions and 176 deletions
|
@ -1,17 +1,17 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2010 Alena Laskavaia
|
||||
* Copyright (c) 2009, 2012 Alena Laskavaia
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.cxx.internal.model;
|
||||
|
||||
import org.eclipse.cdt.codan.core.CodanRuntime;
|
||||
import org.eclipse.cdt.codan.internal.core.CodanBuilder;
|
||||
import org.eclipse.cdt.codan.internal.core.CodanRunner;
|
||||
import org.eclipse.cdt.core.CCProjectNature;
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
|
@ -22,10 +22,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
|
||||
/**
|
||||
* @author Alena
|
||||
*
|
||||
*/
|
||||
public class CxxCodanReconciler {
|
||||
private CodanBuilder builder = (CodanBuilder) CodanRuntime.getInstance().getBuilder();
|
||||
|
||||
public void reconciledAst(IASTTranslationUnit ast, IResource resource, IProgressMonitor monitor) {
|
||||
if (ast == null)
|
||||
|
@ -35,7 +33,7 @@ public class CxxCodanReconciler {
|
|||
return;
|
||||
try {
|
||||
if (project.hasNature(CProjectNature.C_NATURE_ID) || project.hasNature(CCProjectNature.CC_NATURE_ID)) {
|
||||
builder.runInEditor(ast, resource, monitor);
|
||||
CodanRunner.runInEditor(ast, resource, monitor);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
// ignore
|
||||
|
|
11
codan/org.eclipse.cdt.codan.core/.settings/.api_filters
Normal file
11
codan/org.eclipse.cdt.codan.core/.settings/.api_filters
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<component id="org.eclipse.cdt.codan.core" version="2">
|
||||
<resource path="META-INF/MANIFEST.MF" type="org.eclipse.cdt.codan.core.Messages">
|
||||
<filter id="305324134">
|
||||
<message_arguments>
|
||||
<message_argument value="org.eclipse.cdt.codan.core.Messages"/>
|
||||
<message_argument value="org.eclipse.cdt.codan.core_2.1.0"/>
|
||||
</message_arguments>
|
||||
</filter>
|
||||
</resource>
|
||||
</component>
|
|
@ -10,7 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core;
|
||||
|
||||
import org.eclipse.cdt.codan.internal.core.CodeAnlysisNature;
|
||||
import org.eclipse.cdt.codan.internal.core.CodeAnalysisNature;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
|
@ -28,7 +28,7 @@ public class CodanCorePlugin extends Plugin {
|
|||
* The nature used to run Codan builder.
|
||||
* @noreference This constant is not intended to be referenced by clients.
|
||||
*/
|
||||
public static final String NATURE_ID = CodeAnlysisNature.NATURE_ID;
|
||||
public static final String NATURE_ID = CodeAnalysisNature.NATURE_ID;
|
||||
// The shared instance
|
||||
private static CodanCorePlugin plugin;
|
||||
|
||||
|
|
|
@ -11,11 +11,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.model;
|
||||
|
||||
import org.eclipse.cdt.codan.core.Messages;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
|
||||
/**
|
||||
*
|
||||
* Represents Severity of the codan problem. It is directly mapped to markers
|
||||
* severity.
|
||||
*
|
||||
|
@ -33,6 +31,7 @@ public enum CodanSeverity {
|
|||
* Error severity
|
||||
*/
|
||||
Error(IMarker.SEVERITY_ERROR);
|
||||
|
||||
private int value;
|
||||
|
||||
private CodanSeverity(int value) {
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2012 Alena Laskavaia and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
* IBM Corporation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.model;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
/**
|
||||
* Core Messages
|
||||
*/
|
||||
class Messages extends NLS {
|
||||
public static String CodanSeverity_Error;
|
||||
public static String CodanSeverity_Info;
|
||||
public static String CodanSeverity_Warning;
|
||||
|
||||
static {
|
||||
NLS.initializeMessages(Messages.class.getName(), Messages.class);
|
||||
}
|
||||
|
||||
// Do not instantiate
|
||||
private Messages() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2010, 2012 Alena Laskavaia and others.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# Alena Laskavaia - initial API and implementation
|
||||
# IBM Corporation
|
||||
###############################################################################
|
||||
CodanSeverity_Error=Error
|
||||
CodanSeverity_Info=Info
|
||||
CodanSeverity_Warning=Warning
|
|
@ -1,16 +1,21 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009,2010 QNX Software Systems
|
||||
* Copyright (c) 2009, 2010 QNX Software Systems
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems (Alena Laskavaia) - initial API and implementation
|
||||
* QNX Software Systems (Alena Laskavaia) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.param;
|
||||
|
||||
import org.eclipse.cdt.codan.core.Messages;
|
||||
import java.io.IOException;
|
||||
import java.io.StreamTokenizer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.codan.internal.core.CharOperation;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -20,12 +25,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
|||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StreamTokenizer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Custom preference for resource scope
|
||||
*
|
||||
|
@ -45,6 +44,7 @@ public class FileScopeProblemPreference extends AbstractProblemPreference {
|
|||
* Inclusion attribute
|
||||
*/
|
||||
public static final String INCLUSION = "inclusion"; //$NON-NLS-1$
|
||||
|
||||
private IResource resource;
|
||||
private IPath[] inclusion = new IPath[0];
|
||||
private IPath[] exclusion = new IPath[0];
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2012 Alena Laskavaia and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
* IBM Corporation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.param;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
/**
|
||||
* Core Messages
|
||||
*/
|
||||
class Messages extends NLS {
|
||||
public static String FileScopeProblemPreference_Label;
|
||||
|
||||
static {
|
||||
NLS.initializeMessages(Messages.class.getName(), Messages.class);
|
||||
}
|
||||
|
||||
// Do not instantiate
|
||||
private Messages() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2010, 2012 Alena Laskavaia and others.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# Alena Laskavaia - initial API and implementation
|
||||
# IBM Corporation
|
||||
###############################################################################
|
||||
FileScopeProblemPreference_Label=Exclusion and Inclusion
|
|
@ -14,7 +14,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
|
||||
import org.eclipse.cdt.codan.core.CodanRuntime;
|
||||
import org.eclipse.cdt.codan.core.Messages;
|
||||
import org.eclipse.cdt.codan.core.model.AbstractProblemReporter;
|
||||
import org.eclipse.cdt.codan.core.model.ICodanProblemMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -28,14 +27,14 @@ import org.eclipse.osgi.util.NLS;
|
|||
|
||||
/**
|
||||
* Application to support headless build
|
||||
*
|
||||
*
|
||||
* @noextend This class is not intended to be extended by clients.
|
||||
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||
*/
|
||||
public class CodanApplication implements IApplication {
|
||||
private Collection<String> projects = new ArrayList<String>();
|
||||
private boolean verbose = false;
|
||||
private boolean all = false;
|
||||
private boolean verbose;
|
||||
private boolean all;
|
||||
|
||||
@Override
|
||||
public Object start(IApplicationContext context) throws Exception {
|
||||
|
@ -99,7 +98,7 @@ public class CodanApplication implements IApplication {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private void help() {
|
||||
System.out.println(Messages.CodanApplication_Usage);
|
||||
|
|
|
@ -13,14 +13,8 @@ package org.eclipse.cdt.codan.internal.core;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
||||
import org.eclipse.cdt.codan.core.Messages;
|
||||
import org.eclipse.cdt.codan.core.model.CheckerLaunchMode;
|
||||
import org.eclipse.cdt.codan.core.model.IChecker;
|
||||
import org.eclipse.cdt.codan.core.model.ICheckerInvocationContext;
|
||||
import org.eclipse.cdt.codan.core.model.ICodanBuilder;
|
||||
import org.eclipse.cdt.codan.core.model.IRunnableInEditorChecker;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceDelta;
|
||||
|
@ -28,8 +22,6 @@ import org.eclipse.core.resources.IResourceDeltaVisitor;
|
|||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ICodanBuilder}
|
||||
|
@ -86,7 +78,7 @@ public class CodanBuilder extends IncrementalProjectBuilder implements ICodanBui
|
|||
|
||||
@Override
|
||||
public void processResource(IResource resource, IProgressMonitor monitor) {
|
||||
processResource(resource, monitor, null, CheckerLaunchMode.RUN_ON_FULL_BUILD);
|
||||
CodanRunner.processResource(resource, monitor, CheckerLaunchMode.RUN_ON_FULL_BUILD);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,84 +91,13 @@ public class CodanBuilder extends IncrementalProjectBuilder implements ICodanBui
|
|||
*/
|
||||
@Override
|
||||
public void processResource(IResource resource, IProgressMonitor monitor, CheckerLaunchMode mode) {
|
||||
processResource(resource, monitor, null, mode);
|
||||
CodanRunner.processResource(resource, monitor, mode);
|
||||
}
|
||||
|
||||
private void processResourceDelta(IResource resource, IProgressMonitor monitor) {
|
||||
processResource(resource, monitor, CheckerLaunchMode.RUN_ON_INC_BUILD);
|
||||
}
|
||||
|
||||
protected void processResource(IResource resource, IProgressMonitor monitor, Object model,
|
||||
CheckerLaunchMode checkerLaunchMode) {
|
||||
CheckersRegistry chegistry = CheckersRegistry.getInstance();
|
||||
int checkers = chegistry.getCheckersSize();
|
||||
int memsize = 0;
|
||||
if (resource instanceof IContainer) {
|
||||
try {
|
||||
IResource[] members = ((IContainer) resource).members();
|
||||
memsize = members.length;
|
||||
} catch (CoreException e) {
|
||||
CodanCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
int tick = 1000;
|
||||
// System.err.println("processing " + resource);
|
||||
monitor.beginTask(Messages.CodanBuilder_Code_Analysis_On + resource, checkers + memsize * tick);
|
||||
try {
|
||||
CheckersTimeStats.getInstance().checkerStart(CheckersTimeStats.ALL);
|
||||
ICheckerInvocationContext context = new CheckerInvocationContext(resource);
|
||||
try {
|
||||
for (IChecker checker : chegistry) {
|
||||
try {
|
||||
if (monitor.isCanceled())
|
||||
return;
|
||||
if (chegistry.isCheckerEnabled(checker, resource, checkerLaunchMode)) {
|
||||
synchronized (checker) {
|
||||
try {
|
||||
checker.before(resource);
|
||||
CheckersTimeStats.getInstance().checkerStart(checker.getClass().getName());
|
||||
if (checkerLaunchMode == CheckerLaunchMode.RUN_AS_YOU_TYPE) {
|
||||
((IRunnableInEditorChecker) checker).processModel(model, context);
|
||||
} else {
|
||||
checker.processResource(resource, context);
|
||||
}
|
||||
} finally {
|
||||
CheckersTimeStats.getInstance().checkerStop(checker.getClass().getName());
|
||||
checker.after(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
monitor.worked(1);
|
||||
} catch (OperationCanceledException e) {
|
||||
return;
|
||||
} catch (Throwable e) {
|
||||
CodanCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
context.dispose();
|
||||
CheckersTimeStats.getInstance().checkerStop(CheckersTimeStats.ALL);
|
||||
//CheckersTimeStats.getInstance().printStats();
|
||||
}
|
||||
if (resource instanceof IContainer
|
||||
&& (checkerLaunchMode == CheckerLaunchMode.RUN_ON_FULL_BUILD || checkerLaunchMode == CheckerLaunchMode.RUN_ON_DEMAND)) {
|
||||
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));
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CodanCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
monitor.done();
|
||||
}
|
||||
}
|
||||
|
||||
protected void fullBuild(final IProgressMonitor monitor) throws CoreException {
|
||||
processResource(getProject(), monitor);
|
||||
}
|
||||
|
@ -185,17 +106,4 @@ public class CodanBuilder extends IncrementalProjectBuilder implements ICodanBui
|
|||
// The visitor does the work.
|
||||
delta.accept(new CodanDeltaVisitor(monitor));
|
||||
}
|
||||
|
||||
/**
|
||||
* Run all checkers that support "check as you type" mode
|
||||
*
|
||||
* @param model - model of given resource such as ast
|
||||
* @param resource - resource to process
|
||||
* @param monitor - progress monitor
|
||||
*/
|
||||
public void runInEditor(Object model, IResource resource, IProgressMonitor monitor) {
|
||||
if (model == null)
|
||||
return;
|
||||
processResource(resource, monitor, model, CheckerLaunchMode.RUN_AS_YOU_TYPE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2012 Alena Laskavaia
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.internal.core;
|
||||
|
||||
import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
||||
import org.eclipse.cdt.codan.core.model.CheckerLaunchMode;
|
||||
import org.eclipse.cdt.codan.core.model.IChecker;
|
||||
import org.eclipse.cdt.codan.core.model.ICheckerInvocationContext;
|
||||
import org.eclipse.cdt.codan.core.model.IRunnableInEditorChecker;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
/**
|
||||
* Collection of methods for running checkers.
|
||||
*/
|
||||
public class CodanRunner {
|
||||
/** Do not instantiate. All methods are static */
|
||||
private CodanRunner() {}
|
||||
|
||||
|
||||
/**
|
||||
* Runs all checkers that support "run as you type" mode.
|
||||
*
|
||||
* @param model - the model of given resource such as AST
|
||||
* @param resource - the resource to process
|
||||
* @param monitor - the progress monitor
|
||||
*/
|
||||
public static void runInEditor(Object model, IResource resource, IProgressMonitor monitor) {
|
||||
CodanRunner.processResource(resource, monitor, model, CheckerLaunchMode.RUN_AS_YOU_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs all checkers on a given resource.
|
||||
*
|
||||
* @param resource - the resource to run the checkers on, either IFile or IContainer
|
||||
* @param monitor - the progress monitor
|
||||
* @param checkerLaunchMode - the checker launch mode.
|
||||
*/
|
||||
public static void processResource(IResource resource, IProgressMonitor monitor,
|
||||
CheckerLaunchMode checkerLaunchMode) {
|
||||
processResource(resource, monitor, null, checkerLaunchMode);
|
||||
}
|
||||
|
||||
private static void processResource(IResource resource, IProgressMonitor monitor, Object model,
|
||||
CheckerLaunchMode checkerLaunchMode) {
|
||||
CheckersRegistry chegistry = CheckersRegistry.getInstance();
|
||||
int checkers = chegistry.getCheckersSize();
|
||||
int memsize = 0;
|
||||
if (resource instanceof IContainer) {
|
||||
try {
|
||||
IResource[] members = ((IContainer) resource).members();
|
||||
memsize = members.length;
|
||||
} catch (CoreException e) {
|
||||
CodanCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
int tick = 1000;
|
||||
// System.err.println("processing " + resource);
|
||||
monitor.beginTask(NLS.bind(Messages.CodanRunner_Code_Analysis_On, resource.getFullPath().toString()),
|
||||
checkers + memsize * tick);
|
||||
try {
|
||||
CheckersTimeStats.getInstance().checkerStart(CheckersTimeStats.ALL);
|
||||
ICheckerInvocationContext context = new CheckerInvocationContext(resource);
|
||||
try {
|
||||
for (IChecker checker : chegistry) {
|
||||
try {
|
||||
if (monitor.isCanceled())
|
||||
return;
|
||||
if (chegistry.isCheckerEnabled(checker, resource, checkerLaunchMode)) {
|
||||
synchronized (checker) {
|
||||
try {
|
||||
checker.before(resource);
|
||||
CheckersTimeStats.getInstance().checkerStart(checker.getClass().getName());
|
||||
if (checkerLaunchMode == CheckerLaunchMode.RUN_AS_YOU_TYPE) {
|
||||
((IRunnableInEditorChecker) checker).processModel(model, context);
|
||||
} else {
|
||||
checker.processResource(resource, context);
|
||||
}
|
||||
} finally {
|
||||
CheckersTimeStats.getInstance().checkerStop(checker.getClass().getName());
|
||||
checker.after(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
monitor.worked(1);
|
||||
} catch (OperationCanceledException e) {
|
||||
return;
|
||||
} catch (Throwable e) {
|
||||
CodanCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
context.dispose();
|
||||
CheckersTimeStats.getInstance().checkerStop(CheckersTimeStats.ALL);
|
||||
//CheckersTimeStats.getInstance().printStats();
|
||||
}
|
||||
|
||||
if (resource instanceof IContainer
|
||||
&& (checkerLaunchMode == CheckerLaunchMode.RUN_ON_FULL_BUILD || checkerLaunchMode == CheckerLaunchMode.RUN_ON_DEMAND)) {
|
||||
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), null, checkerLaunchMode);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CodanCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
monitor.done();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2011 Alena Laskavaia and others.
|
||||
* Copyright (c) 2009, 2012 Alena Laskavaia and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -8,15 +8,16 @@
|
|||
* Contributors:
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
* IBM Corporation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core;
|
||||
package org.eclipse.cdt.codan.internal.core;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
/**
|
||||
* Core Messages
|
||||
*/
|
||||
public class Messages extends NLS {
|
||||
class Messages extends NLS {
|
||||
public static String CodanApplication_all_option;
|
||||
public static String CodanApplication_Error_ProjectDoesNotExists;
|
||||
public static String CodanApplication_LogRunProject;
|
||||
|
@ -24,20 +25,7 @@ public class Messages extends NLS {
|
|||
public static String CodanApplication_Options;
|
||||
public static String CodanApplication_Usage;
|
||||
public static String CodanApplication_verbose_option;
|
||||
public static String CodanBuilder_Code_Analysis_On;
|
||||
/**
|
||||
* @since 2.0
|
||||
*/
|
||||
public static String CodanSeverity_Error;
|
||||
/**
|
||||
* @since 2.0
|
||||
*/
|
||||
public static String CodanSeverity_Info;
|
||||
/**
|
||||
* @since 2.0
|
||||
*/
|
||||
public static String CodanSeverity_Warning;
|
||||
public static String FileScopeProblemPreference_Label;
|
||||
public static String CodanRunner_Code_Analysis_On;
|
||||
|
||||
static {
|
||||
NLS.initializeMessages(Messages.class.getName(), Messages.class);
|
|
@ -8,6 +8,7 @@
|
|||
# Contributors:
|
||||
# Alena Laskavaia - initial API and implementation
|
||||
# IBM Corporation
|
||||
# Sergey Prigogin (Google)
|
||||
###############################################################################
|
||||
CodanApplication_Error_ProjectDoesNotExists=Error: project {0} does not exist
|
||||
CodanApplication_LogRunProject=Running code analysis on project
|
||||
|
@ -16,8 +17,4 @@ CodanApplication_Usage=Usage: [options] <project1> <project2> ...
|
|||
CodanApplication_Options=Options:
|
||||
CodanApplication_all_option= -all - run on all projects in workspace
|
||||
CodanApplication_verbose_option= -verbose - print verbose build information
|
||||
CodanBuilder_Code_Analysis_On=Code analysis on
|
||||
CodanSeverity_Error=Error
|
||||
CodanSeverity_Info=Info
|
||||
CodanSeverity_Warning=Warning
|
||||
FileScopeProblemPreference_Label=Exclusion and Inclusion
|
||||
CodanRunner_Code_Analysis_On=Code analysis on {0}
|
|
@ -10,6 +10,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.internal.core.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.eclipse.cdt.codan.core.model.IProblem;
|
||||
import org.eclipse.cdt.codan.core.model.IProblemCategory;
|
||||
import org.eclipse.cdt.codan.core.model.IProblemProfile;
|
||||
|
@ -19,15 +22,13 @@ import org.eclipse.core.runtime.ISafeRunnable;
|
|||
import org.eclipse.core.runtime.ListenerList;
|
||||
import org.eclipse.core.runtime.SafeRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author Alena
|
||||
*/
|
||||
public class ProblemProfile implements IProblemProfile, Cloneable {
|
||||
private CodanProblemCategory rootCategory;
|
||||
private Object resource;
|
||||
private ListenerList preferenceChangeListeners;
|
||||
|
||||
/**
|
||||
* @param resource
|
||||
|
@ -106,7 +107,6 @@ public class ProblemProfile implements IProblemProfile, Cloneable {
|
|||
public IProblemCategory getParentCategory() {
|
||||
return getRoot();
|
||||
}
|
||||
private ListenerList preferenceChangeListeners;
|
||||
|
||||
@Override
|
||||
public void addProfileChangeListener(IProblemProfileChangeListener listener) {
|
||||
|
@ -120,7 +120,7 @@ public class ProblemProfile implements IProblemProfile, Cloneable {
|
|||
if (preferenceChangeListeners == null)
|
||||
return;
|
||||
preferenceChangeListeners.remove(listener);
|
||||
if (preferenceChangeListeners.size() == 0)
|
||||
if (preferenceChangeListeners.isEmpty())
|
||||
preferenceChangeListeners = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,15 +12,13 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.internal.ui.cxx;
|
||||
|
||||
import org.eclipse.cdt.codan.core.CodanRuntime;
|
||||
import org.eclipse.cdt.codan.core.model.CheckerLaunchMode;
|
||||
import org.eclipse.cdt.codan.internal.core.CodanBuilder;
|
||||
import org.eclipse.cdt.codan.internal.core.CodanRunner;
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
import org.eclipse.cdt.ui.ICEditor;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
@ -38,8 +36,6 @@ import org.eclipse.ui.PlatformUI;
|
|||
* @author Alena Laskavaia
|
||||
*/
|
||||
public class Startup implements IStartup {
|
||||
private static final IProgressMonitor NULL_PROGRESS_MONITOR = new NullProgressMonitor();
|
||||
|
||||
@Override
|
||||
public void earlyStartup() {
|
||||
registerListeners();
|
||||
|
@ -86,13 +82,12 @@ public class Startup implements IStartup {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void processResource(final IResource resource) {
|
||||
Job job = new Job(NLS.bind(Messages.Startup_AnalyzingFile, resource.getName())) {
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
CodanBuilder builder = (CodanBuilder) CodanRuntime.getInstance().getBuilder();
|
||||
builder.processResource(resource, NULL_PROGRESS_MONITOR, CheckerLaunchMode.RUN_ON_FILE_OPEN);
|
||||
CodanRunner.processResource(resource, monitor, CheckerLaunchMode.RUN_ON_FILE_OPEN);
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.internal.ui.preferences;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
||||
import org.eclipse.cdt.codan.core.CodanRuntime;
|
||||
import org.eclipse.cdt.codan.core.model.ICheckersRegistry;
|
||||
|
@ -41,17 +44,15 @@ import org.eclipse.ui.IWorkbench;
|
|||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
import org.eclipse.ui.preferences.ScopedPreferenceStore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* This class represents a preference page that is contributed to the Preferences dialog. By
|
||||
* subclassing {@code FieldEditorPreferencePage}, we can use built-in field support in JFace to
|
||||
* create a page that is both small and knows how to save, restore and apply its values.
|
||||
* This class represents a preference page that is contributed to the Preferences dialog.
|
||||
* By subclassing {@code FieldEditorPreferencePage}, we can use built-in field support in
|
||||
* JFace to create a page that is both small and knows how to save, restore and apply its
|
||||
* values.
|
||||
* <p>
|
||||
* This page is used to modify preferences only. They are stored in the preference store that
|
||||
* belongs to the main plug-in class. That way, preferences can be accessed directly via the
|
||||
* preference store.
|
||||
* This page is used to modify preferences only. They are stored in the preference store that
|
||||
* belongs to the main plug-in class. That way, preferences can be accessed directly via
|
||||
* the preference store.
|
||||
* </p>
|
||||
*/
|
||||
public class CodanPreferencePage extends FieldEditorOverlayPage implements IWorkbenchPreferencePage {
|
||||
|
@ -89,8 +90,10 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements IWork
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates the field editors. Field editors are abstractions of the common GUI blocks needed to
|
||||
* manipulate various types of preferences. Each field editor knows how to save and restore
|
||||
* Creates the field editors. Field editors are abstractions of the common
|
||||
* GUI blocks needed to
|
||||
* manipulate various types of preferences. Each field editor knows how to
|
||||
* save and restore
|
||||
* its own value.
|
||||
*/
|
||||
@Override
|
||||
|
@ -156,13 +159,13 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements IWork
|
|||
}
|
||||
|
||||
private void saveWidgetValues() {
|
||||
String id = (!hasSelectedProblems()) ? EMPTY_STRING : selectedProblems.get(0).getId();
|
||||
String id = !hasSelectedProblems() ? EMPTY_STRING : selectedProblems.get(0).getId();
|
||||
getDialogSettings().put(getWidgetId(), id);
|
||||
}
|
||||
|
||||
private void restoreWidgetValues() {
|
||||
String id = getDialogSettings().get(getWidgetId());
|
||||
if (id != null && id.length() > 0 && checkedTreeEditor != null) {
|
||||
if (id != null && !id.isEmpty() && checkedTreeEditor != null) {
|
||||
IProblem problem = profile.findProblem(id);
|
||||
if (problem != null) {
|
||||
checkedTreeEditor.getTreeViewer().setSelection(new StructuredSelection(problem), true);
|
||||
|
@ -194,12 +197,11 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements IWork
|
|||
return;
|
||||
}
|
||||
IProblem[] selected = selectedProblems.toArray(new IProblem[selectedProblems.size()]);
|
||||
CustomizeProblemDialog dialog =
|
||||
new CustomizeProblemDialog(getShell(), selected, (IResource) getElement());
|
||||
CustomizeProblemDialog dialog = new CustomizeProblemDialog(getShell(), selected, (IResource) getElement());
|
||||
dialog.open();
|
||||
checkedTreeEditor.getTreeViewer().refresh(true);
|
||||
}
|
||||
|
||||
|
||||
private boolean hasSelectedProblems() {
|
||||
return selectedProblems != null && !selectedProblems.isEmpty();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.internal.ui.preferences;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
||||
import org.eclipse.cdt.codan.core.PreferenceConstants;
|
||||
import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
|
||||
|
@ -40,9 +43,6 @@ import org.eclipse.swt.widgets.Control;
|
|||
import org.eclipse.ui.IWorkbenchPropertyPage;
|
||||
import org.eclipse.ui.preferences.ScopedPreferenceStore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Berthold Daum
|
||||
*/
|
||||
|
@ -269,7 +269,7 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage i
|
|||
return super.getPreferenceStore();
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Enables or disables the field editors and buttons of this page
|
||||
*/
|
||||
private void updateFieldEditors() {
|
||||
|
@ -293,8 +293,8 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage i
|
|||
}
|
||||
|
||||
/**
|
||||
* We override the performOk method. In case of property pages we copy the
|
||||
* values in the overlay store into the property values of the selected
|
||||
* We override the performOk method. In case of property pages we copy
|
||||
* the values in the overlay store into the property values of the selected
|
||||
* project. We also save the state of the radio buttons.
|
||||
*
|
||||
* @see org.eclipse.jface.preference.IPreferencePage#performOk()
|
||||
|
|
Loading…
Add table
Reference in a new issue