1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

added on deman launch profile instead of on inc build

This commit is contained in:
Alena Laskavaia 2011-02-27 02:35:23 +00:00
parent f3bb6aa2dd
commit e01c3cc7c3
5 changed files with 41 additions and 13 deletions

View file

@ -7,7 +7,7 @@ package org.eclipse.cdt.codan.core.model;
* part of a work in progress. There is no guarantee that this API will
* work or that it will remain the same.
* </p>
*
*
* @since 2.0
*/
public enum CheckerLaunchMode {
@ -27,4 +27,8 @@ public enum CheckerLaunchMode {
* checker run in editor as you type
*/
RUN_AS_YOU_TYPE,
/**
* checker run when explicit command is given
*/
RUN_ON_DEMAND,
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2010 Alena Laskavaia
* Copyright (c) 2009, 2010 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
@ -18,16 +18,26 @@ import org.eclipse.core.runtime.IProgressMonitor;
* traverse the resource tree. It will be calling all the checkers (this
* interface allows to call framework without using UI). You can obtain instance
* of this class as CodanRuntime.getInstance().getBuilder()
*
*
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICodanBuilder {
/**
* Run code analysis on given resource
*
* Run code analysis on given resource in {@link CheckerLaunchMode#RUN_ON_FULL_BUILD} mode
*
* @param resource - resource to process
* @param monitor - progress monitor
*/
public void processResource(IResource resource, IProgressMonitor monitor);
/**
* Run code analysis on given resource in a given mode
*
* @param resource - resource to process
* @param monitor - progress monitor
* @param mode - launch mode, @see {@link CheckerLaunchMode}
* @since 2.0
*/
public void processResource(IResource resource, IProgressMonitor monitor, CheckerLaunchMode mode);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2010 Alena Laskavaia
* Copyright (c) 2009, 2010 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
@ -69,7 +69,7 @@ public class CodanBuilder extends IncrementalProjectBuilder implements ICodanBui
/*
* (non-Javadoc)
*
*
* @see org.eclipse.core.internal.events.InternalBuilder#build(int,
* java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
*/
@ -93,8 +93,20 @@ public class CodanBuilder extends IncrementalProjectBuilder implements ICodanBui
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);
/**
* Run code analysis on given resource in a given mode
*
* @param resource - resource to process
* @param monitor - progress monitor
* @param mode - launch mode, @see {@link CheckerLaunchMode}
* @since 2.0
*/
public void processResource(IResource resource, IProgressMonitor monitor, CheckerLaunchMode mode) {
processResource(resource, monitor, null, 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) {
@ -147,7 +159,8 @@ public class CodanBuilder extends IncrementalProjectBuilder implements ICodanBui
CodanCorePlugin.log(e);
}
}
if (resource instanceof IContainer && (checkerLaunchMode == CheckerLaunchMode.RUN_ON_FULL_BUILD)) {
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++) {
@ -185,7 +198,7 @@ public class CodanBuilder extends IncrementalProjectBuilder implements ICodanBui
/**
* 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

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.codan.internal.ui.actions;
import java.util.Iterator;
import org.eclipse.cdt.codan.core.CodanRuntime;
import org.eclipse.cdt.codan.core.model.CheckerLaunchMode;
import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
@ -52,7 +53,7 @@ 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);
CodanRuntime.getInstance().getBuilder().processResource(res, subMon, CheckerLaunchMode.RUN_ON_DEMAND);
if (subMon.isCanceled())
return Status.CANCEL_STATUS;
}

View file

@ -61,7 +61,7 @@ public class LaunchModesPropertyPage extends FieldEditorPreferencePage {
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_ON_DEMAND.name(), "Run on demand", useLocalGroup));
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_AS_YOU_TYPE.name(), "Run as you type", useLocalGroup));
updateFieldEditors();
}