From 085f428acbf69d30af1dabe562a83e07ea807419 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Thu, 6 Oct 2011 17:27:49 -0700 Subject: [PATCH] Cosmetics. --- .../cdt/internal/core/model/CModel.java | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModel.java index 499a450118c..1ea7dceea65 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModel.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModel.java @@ -10,7 +10,6 @@ * Anton Leherbauer (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.model; - import java.util.List; import java.util.Map; @@ -60,7 +59,7 @@ public class CModel extends Openable implements ICModel { * ICModel#getCProject(String) */ public ICProject getCProject(String name) { - IProject project = ((IWorkspaceRoot)getResource()).getProject(name); + IProject project = ((IWorkspaceRoot) getResource()).getProject(name); return CModelManager.getDefault().create(project); } @@ -73,15 +72,15 @@ public class CModel extends Openable implements ICModel { * is not one of an IProject, IFolder, or IFile. */ public ICProject getCProject(IResource resource) { - switch(resource.getType()){ - case IResource.FOLDER: - return new CProject(this, ((IFolder)resource).getProject()); - case IResource.FILE: - return new CProject(this, ((IFile)resource).getProject()); - case IResource.PROJECT: - return new CProject(this, (IProject)resource); - default: - throw new IllegalArgumentException("element.invalidResourceForProject"); //$NON-NLS-1$ + switch (resource.getType()) { + case IResource.FOLDER: + return new CProject(this, ((IFolder) resource).getProject()); + case IResource.FILE: + return new CProject(this, ((IFile) resource).getProject()); + case IResource.PROJECT: + return new CProject(this, (IProject) resource); + default: + throw new IllegalArgumentException("element.invalidResourceForProject"); //$NON-NLS-1$ } } @@ -110,9 +109,11 @@ public class CModel extends Openable implements ICModel { public void copy(ICElement[] elements, ICElement[] containers, ICElement[] siblings, String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException { if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT ) { - runOperation(new CopyResourceElementsOperation(elements, containers, replace), elements, siblings, renamings, monitor); + runOperation(new CopyResourceElementsOperation(elements, containers, replace), elements, + siblings, renamings, monitor); } else { - runOperation(new CopyElementsOperation(elements, containers, replace), elements, siblings, renamings, monitor); + runOperation(new CopyElementsOperation(elements, containers, replace), elements, siblings, + renamings, monitor); } } @@ -130,9 +131,11 @@ public class CModel extends Openable implements ICModel { public void move(ICElement[] elements, ICElement[] containers, ICElement[] siblings, String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException { if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT) { - runOperation(new MoveResourceElementsOperation(elements, containers, replace), elements, siblings, renamings, monitor); + runOperation(new MoveResourceElementsOperation(elements, containers, replace), elements, + siblings, renamings, monitor); } else { - runOperation(new MoveElementsOperation(elements, containers, replace), elements, siblings, renamings, monitor); + runOperation(new MoveElementsOperation(elements, containers, replace), elements, siblings, + renamings, monitor); } } @@ -150,7 +153,8 @@ public class CModel extends Openable implements ICModel { /** * Configures and runs the MultiOperation. */ - protected void runOperation(MultiOperation op, ICElement[] elements, ICElement[] siblings, String[] renamings, IProgressMonitor monitor) throws CModelException { + protected void runOperation(MultiOperation op, ICElement[] elements, ICElement[] siblings, + String[] renamings, IProgressMonitor monitor) throws CModelException { op.setRenamings(renamings); if (siblings != null) { for (int i = 0; i < elements.length; i++) { @@ -184,10 +188,11 @@ public class CModel extends Openable implements ICModel { } /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.model.Openable#buildStructure(org.eclipse.cdt.internal.core.model.OpenableInfo, org.eclipse.core.runtime.IProgressMonitor, java.util.Map, org.eclipse.core.resources.IResource) + * @see Openable#buildStructure(OpenableInfo, IProgressMonitor, Map, IResource) */ @Override - protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws CModelException { + protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws CModelException { boolean validInfo = false; try { IResource res = getResource(); @@ -206,12 +211,12 @@ public class CModel extends Openable implements ICModel { * @see org.eclipse.cdt.core.model.ICModel#getNonCResources() */ public Object[] getNonCResources() throws CModelException { - return ((CModelInfo)getElementInfo()).getNonCResources(); + return ((CModelInfo) getElementInfo()).getNonCResources(); } protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException { // determine my children - IWorkspaceRoot root = (IWorkspaceRoot)getResource(); + IWorkspaceRoot root = (IWorkspaceRoot) getResource(); IProject[] projects = root.getProjects(); for (IProject project : projects) { if (CoreModel.hasCNature(project) || CoreModel.hasCCNature(project)) { @@ -219,7 +224,7 @@ public class CModel extends Openable implements ICModel { info.addChild(cproject); } } - ((CModelInfo)getElementInfo()).setNonCResources(null); + ((CModelInfo) getElementInfo()).setNonCResources(null); return true; } @@ -229,7 +234,7 @@ public class CModel extends Openable implements ICModel { case CEM_CPROJECT: if (!memento.hasMoreTokens()) return this; String projectName = memento.nextToken(); - CElement project = (CElement)getCProject(projectName); + CElement project = (CElement) getCProject(projectName); if (project != null) { return project.getHandleFromMemento(memento); } @@ -243,9 +248,8 @@ public class CModel extends Openable implements ICModel { } @Override - protected char getHandleMementoDelimiter(){ + protected char getHandleMementoDelimiter() { Assert.isTrue(false, "Should not be called"); //$NON-NLS-1$ return 0; } - }