1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2011-10-06 17:27:49 -07:00
parent 5c8b7da9f4
commit 085f428acb

View file

@ -11,7 +11,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -60,7 +59,7 @@ public class CModel extends Openable implements ICModel {
* ICModel#getCProject(String) * ICModel#getCProject(String)
*/ */
public ICProject getCProject(String name) { public ICProject getCProject(String name) {
IProject project = ((IWorkspaceRoot)getResource()).getProject(name); IProject project = ((IWorkspaceRoot) getResource()).getProject(name);
return CModelManager.getDefault().create(project); return CModelManager.getDefault().create(project);
} }
@ -73,13 +72,13 @@ public class CModel extends Openable implements ICModel {
* is not one of an IProject, IFolder, or IFile. * is not one of an IProject, IFolder, or IFile.
*/ */
public ICProject getCProject(IResource resource) { public ICProject getCProject(IResource resource) {
switch(resource.getType()){ switch (resource.getType()) {
case IResource.FOLDER: case IResource.FOLDER:
return new CProject(this, ((IFolder)resource).getProject()); return new CProject(this, ((IFolder) resource).getProject());
case IResource.FILE: case IResource.FILE:
return new CProject(this, ((IFile)resource).getProject()); return new CProject(this, ((IFile) resource).getProject());
case IResource.PROJECT: case IResource.PROJECT:
return new CProject(this, (IProject)resource); return new CProject(this, (IProject) resource);
default: default:
throw new IllegalArgumentException("element.invalidResourceForProject"); //$NON-NLS-1$ 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, public void copy(ICElement[] elements, ICElement[] containers, ICElement[] siblings,
String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException { String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException {
if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT ) { 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 { } 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, public void move(ICElement[] elements, ICElement[] containers, ICElement[] siblings,
String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException { String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException {
if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT) { 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 { } 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 <code>MultiOperation</code>. * Configures and runs the <code>MultiOperation</code>.
*/ */
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); op.setRenamings(renamings);
if (siblings != null) { if (siblings != null) {
for (int i = 0; i < elements.length; i++) { for (int i = 0; i < elements.length; i++) {
@ -184,10 +188,11 @@ public class CModel extends Openable implements ICModel {
} }
/* (non-Javadoc) /* (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 @Override
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map<ICElement, CElementInfo> newElements, IResource underlyingResource) throws CModelException { protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map<ICElement,
CElementInfo> newElements, IResource underlyingResource) throws CModelException {
boolean validInfo = false; boolean validInfo = false;
try { try {
IResource res = getResource(); IResource res = getResource();
@ -206,12 +211,12 @@ public class CModel extends Openable implements ICModel {
* @see org.eclipse.cdt.core.model.ICModel#getNonCResources() * @see org.eclipse.cdt.core.model.ICModel#getNonCResources()
*/ */
public Object[] getNonCResources() throws CModelException { public Object[] getNonCResources() throws CModelException {
return ((CModelInfo)getElementInfo()).getNonCResources(); return ((CModelInfo) getElementInfo()).getNonCResources();
} }
protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException { protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException {
// determine my children // determine my children
IWorkspaceRoot root = (IWorkspaceRoot)getResource(); IWorkspaceRoot root = (IWorkspaceRoot) getResource();
IProject[] projects = root.getProjects(); IProject[] projects = root.getProjects();
for (IProject project : projects) { for (IProject project : projects) {
if (CoreModel.hasCNature(project) || CoreModel.hasCCNature(project)) { if (CoreModel.hasCNature(project) || CoreModel.hasCCNature(project)) {
@ -219,7 +224,7 @@ public class CModel extends Openable implements ICModel {
info.addChild(cproject); info.addChild(cproject);
} }
} }
((CModelInfo)getElementInfo()).setNonCResources(null); ((CModelInfo) getElementInfo()).setNonCResources(null);
return true; return true;
} }
@ -229,7 +234,7 @@ public class CModel extends Openable implements ICModel {
case CEM_CPROJECT: case CEM_CPROJECT:
if (!memento.hasMoreTokens()) return this; if (!memento.hasMoreTokens()) return this;
String projectName = memento.nextToken(); String projectName = memento.nextToken();
CElement project = (CElement)getCProject(projectName); CElement project = (CElement) getCProject(projectName);
if (project != null) { if (project != null) {
return project.getHandleFromMemento(memento); return project.getHandleFromMemento(memento);
} }
@ -243,9 +248,8 @@ public class CModel extends Openable implements ICModel {
} }
@Override @Override
protected char getHandleMementoDelimiter(){ protected char getHandleMementoDelimiter() {
Assert.isTrue(false, "Should not be called"); //$NON-NLS-1$ Assert.isTrue(false, "Should not be called"); //$NON-NLS-1$
return 0; return 0;
} }
} }