mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
remove unneccessary imports and format code
This commit is contained in:
parent
efdd319587
commit
2f8833f31d
2 changed files with 98 additions and 112 deletions
|
@ -15,12 +15,9 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
|
||||
|
@ -35,7 +32,6 @@ 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.SubProgressMonitor;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.ui.ISelectionService;
|
||||
|
@ -45,7 +41,8 @@ import org.eclipse.ui.actions.ActionDelegate;
|
|||
* @author crecoskie
|
||||
*
|
||||
*/
|
||||
public class BuildFilesAction extends ActionDelegate implements IWorkbenchWindowActionDelegate {
|
||||
public class BuildFilesAction extends ActionDelegate implements
|
||||
IWorkbenchWindowActionDelegate {
|
||||
|
||||
/**
|
||||
* The workbench window; or <code>null</code> if this action has been
|
||||
|
@ -82,7 +79,6 @@ public class BuildFilesAction extends ActionDelegate implements IWorkbenchWindow
|
|||
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.actions.ActionDelegate#init(org.eclipse.jface.action.IAction)
|
||||
*/
|
||||
|
@ -168,7 +164,9 @@ public class BuildFilesAction extends ActionDelegate implements IWorkbenchWindow
|
|||
IManagedBuildInfo buildInfo = ManagedBuildManager
|
||||
.getBuildInfo(file.getProject());
|
||||
|
||||
if (buildInfo != null && buildInfo.buildsFileType(file.getFileExtension())) {
|
||||
if ((buildInfo != null)
|
||||
&& buildInfo
|
||||
.buildsFileType(file.getFileExtension())) {
|
||||
files.add(file);
|
||||
}
|
||||
}
|
||||
|
@ -182,13 +180,13 @@ public class BuildFilesAction extends ActionDelegate implements IWorkbenchWindow
|
|||
return files;
|
||||
}
|
||||
|
||||
|
||||
private static final class BuildFilesJob extends Job {
|
||||
private final List files;
|
||||
|
||||
BuildFilesJob(List filesToBuild)
|
||||
{
|
||||
super(ManagedMakeMessages.getResourceString("BuildFilesAction.buildingSelectedFiles")); //$NON-NLS-1$
|
||||
BuildFilesJob(List filesToBuild) {
|
||||
super(
|
||||
ManagedMakeMessages
|
||||
.getResourceString("BuildFilesAction.buildingSelectedFiles")); //$NON-NLS-1$
|
||||
|
||||
files = filesToBuild;
|
||||
}
|
||||
|
@ -202,41 +200,40 @@ public class BuildFilesAction extends ActionDelegate implements IWorkbenchWindow
|
|||
|
||||
GeneratedMakefileBuilder builder = new GeneratedMakefileBuilder();
|
||||
|
||||
monitor.beginTask(ManagedMakeMessages.getResourceString("BuildFilesAction.building"), files.size()); //$NON-NLS-1$
|
||||
monitor
|
||||
.beginTask(
|
||||
ManagedMakeMessages
|
||||
.getResourceString("BuildFilesAction.building"), files.size()); //$NON-NLS-1$
|
||||
|
||||
boolean isFirstFile = true;
|
||||
|
||||
while(iterator.hasNext())
|
||||
{
|
||||
while (iterator.hasNext()) {
|
||||
IFile file = (IFile) iterator.next();
|
||||
|
||||
IManagedBuildInfo buildInfo = ManagedBuildManager
|
||||
.getBuildInfo(file.getProject());
|
||||
|
||||
IResource[] resources = {file};
|
||||
IResource[] resources = { file };
|
||||
|
||||
// invoke the internal builder to do the build
|
||||
builder.invokeInternalBuilder(resources, buildInfo
|
||||
.getDefaultConfiguration(), false, false, isFirstFile,
|
||||
!iterator.hasNext(), monitor);
|
||||
|
||||
if(isFirstFile) {
|
||||
if (isFirstFile) {
|
||||
isFirstFile = false;
|
||||
}
|
||||
|
||||
if(monitor.isCanceled())
|
||||
{
|
||||
if (monitor.isCanceled()) {
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
monitor.done();
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.jobs.Job#belongsTo(java.lang.Object)
|
||||
*/
|
||||
|
@ -246,7 +243,6 @@ public class BuildFilesAction extends ActionDelegate implements IWorkbenchWindow
|
|||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -270,47 +266,49 @@ public class BuildFilesAction extends ActionDelegate implements IWorkbenchWindow
|
|||
if (selection instanceof IStructuredSelection) {
|
||||
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
|
||||
|
||||
if(structuredSelection.size() <= 0)
|
||||
if (structuredSelection.size() <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Iterator elements = structuredSelection.iterator(); elements
|
||||
.hasNext();) {
|
||||
IFile file = convertToIFile(elements.next());
|
||||
if (file != null) {
|
||||
// we only add files that we can actually build
|
||||
if(!ManagedBuildManager.manages(file.getProject()))
|
||||
{
|
||||
if (!ManagedBuildManager.manages(file.getProject())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IManagedBuildInfo buildInfo = ManagedBuildManager
|
||||
.getBuildInfo(file.getProject());
|
||||
|
||||
if(buildInfo == null)
|
||||
if (buildInfo == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IManagedBuilderMakefileGenerator buildfileGenerator = ManagedBuildManager
|
||||
.getBuildfileGenerator(buildInfo
|
||||
.getDefaultConfiguration());
|
||||
|
||||
if(buildfileGenerator == null)
|
||||
if (buildfileGenerator == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// make sure build file generator is initialized
|
||||
buildfileGenerator.initialize(file.getProject(), buildInfo, new NullProgressMonitor());
|
||||
buildfileGenerator.initialize(file.getProject(), buildInfo,
|
||||
new NullProgressMonitor());
|
||||
|
||||
// if we have no build info or we can't build the file, then
|
||||
// disable the action
|
||||
if (!buildInfo.buildsFileType(file.getFileExtension())
|
||||
|| buildfileGenerator.isGeneratedResource(file) ) {
|
||||
|| buildfileGenerator.isGeneratedResource(file)) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -327,10 +325,10 @@ public class BuildFilesAction extends ActionDelegate implements IWorkbenchWindow
|
|||
* be enabled.
|
||||
*/
|
||||
private void update() {
|
||||
if(action != null)
|
||||
if (action != null) {
|
||||
action.setEnabled(shouldBeEnabled());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -343,6 +341,4 @@ public class BuildFilesAction extends ActionDelegate implements IWorkbenchWindow
|
|||
update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -15,33 +15,22 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager;
|
||||
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription;
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.GeneratedMakefileBuilder;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.ui.ISelectionService;
|
||||
|
@ -54,7 +43,8 @@ import org.eclipse.ui.actions.ActionDelegate;
|
|||
* @author crecoskie
|
||||
*
|
||||
*/
|
||||
public class CleanFilesAction extends ActionDelegate implements IWorkbenchWindowActionDelegate {
|
||||
public class CleanFilesAction extends ActionDelegate implements
|
||||
IWorkbenchWindowActionDelegate {
|
||||
/**
|
||||
* The workbench window; or <code>null</code> if this action has been
|
||||
* <code>dispose</code>d.
|
||||
|
@ -90,7 +80,6 @@ public class CleanFilesAction extends ActionDelegate implements IWorkbenchWindow
|
|||
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.actions.ActionDelegate#init(org.eclipse.jface.action.IAction)
|
||||
*/
|
||||
|
@ -123,8 +112,9 @@ public class CleanFilesAction extends ActionDelegate implements IWorkbenchWindow
|
|||
*/
|
||||
private IFile convertToIFile(Object object) {
|
||||
|
||||
if (object instanceof IFile)
|
||||
if (object instanceof IFile) {
|
||||
return (IFile) object;
|
||||
}
|
||||
|
||||
if (object instanceof IAdaptable) {
|
||||
IAdaptable adaptable = (IAdaptable) object;
|
||||
|
@ -199,7 +189,6 @@ public class CleanFilesAction extends ActionDelegate implements IWorkbenchWindow
|
|||
files = filesToBuild;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -214,7 +203,7 @@ public class CleanFilesAction extends ActionDelegate implements IWorkbenchWindow
|
|||
ResourcesPlugin.FAMILY_MANUAL_BUILD);
|
||||
for (int i = 0; i < buildJobs.length; i++) {
|
||||
Job curr = buildJobs[i];
|
||||
if (curr != this && curr instanceof CleanFilesJob) {
|
||||
if ((curr != this) && (curr instanceof CleanFilesJob)) {
|
||||
curr.cancel(); // cancel all other build jobs of our
|
||||
// kind
|
||||
|
||||
|
@ -223,7 +212,10 @@ public class CleanFilesAction extends ActionDelegate implements IWorkbenchWindow
|
|||
}
|
||||
try {
|
||||
if (files != null) {
|
||||
monitor.beginTask(ManagedMakeMessages.getResourceString("CleanFilesAction.cleaningFiles"), files.size()); //$NON-NLS-1$
|
||||
monitor
|
||||
.beginTask(
|
||||
ManagedMakeMessages
|
||||
.getResourceString("CleanFilesAction.cleaningFiles"), files.size()); //$NON-NLS-1$
|
||||
|
||||
Iterator iterator = files.iterator();
|
||||
|
||||
|
@ -234,8 +226,7 @@ public class CleanFilesAction extends ActionDelegate implements IWorkbenchWindow
|
|||
GeneratedMakefileBuilder builder = new GeneratedMakefileBuilder();
|
||||
builder.cleanFile(file, monitor);
|
||||
|
||||
if(monitor.isCanceled())
|
||||
{
|
||||
if (monitor.isCanceled()) {
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
}
|
||||
|
@ -265,12 +256,13 @@ public class CleanFilesAction extends ActionDelegate implements IWorkbenchWindow
|
|||
|
||||
List selectedFiles = getSelectedBuildableFiles();
|
||||
|
||||
CleanFilesJob job = new CleanFilesJob(ManagedMakeMessages.getResourceString("CleanFilesAction.cleaningFiles"), selectedFiles); //$NON-NLS-1$
|
||||
CleanFilesJob job = new CleanFilesJob(
|
||||
ManagedMakeMessages
|
||||
.getResourceString("CleanFilesAction.cleaningFiles"), selectedFiles); //$NON-NLS-1$
|
||||
|
||||
job.schedule();
|
||||
}
|
||||
|
||||
|
||||
private boolean shouldBeEnabled() {
|
||||
ISelectionService selectionService = workbenchWindow
|
||||
.getSelectionService();
|
||||
|
@ -279,16 +271,16 @@ public class CleanFilesAction extends ActionDelegate implements IWorkbenchWindow
|
|||
if (selection instanceof IStructuredSelection) {
|
||||
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
|
||||
|
||||
if(structuredSelection.size() <= 0)
|
||||
if (structuredSelection.size() <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Iterator elements = structuredSelection.iterator(); elements
|
||||
.hasNext();) {
|
||||
IFile file = convertToIFile(elements.next());
|
||||
if (file != null) {
|
||||
// we only add files that we can actually build
|
||||
if(!ManagedBuildManager.manages(file.getProject()))
|
||||
{
|
||||
if (!ManagedBuildManager.manages(file.getProject())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -297,14 +289,14 @@ public class CleanFilesAction extends ActionDelegate implements IWorkbenchWindow
|
|||
|
||||
// if we have no build info or we can't build the file, then
|
||||
// disable the action
|
||||
if (buildInfo == null
|
||||
|| !buildInfo.buildsFileType(file.getFileExtension()) ) {
|
||||
if ((buildInfo == null)
|
||||
|| !buildInfo.buildsFileType(file
|
||||
.getFileExtension())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -316,18 +308,16 @@ public class CleanFilesAction extends ActionDelegate implements IWorkbenchWindow
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Updates the enablement state for the action based upon the selection. If
|
||||
* the selection corresponds to files buildable by MBS, then the action will
|
||||
* be enabled.
|
||||
*/
|
||||
private void update() {
|
||||
if(action != null)
|
||||
if (action != null) {
|
||||
action.setEnabled(shouldBeEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
|
Loading…
Add table
Reference in a new issue