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

Fix warnings.

This commit is contained in:
Markus Schorn 2008-04-24 16:09:35 +00:00
parent 6875e287df
commit 8085a45d44
79 changed files with 728 additions and 893 deletions

View file

@ -59,10 +59,6 @@ public abstract class APathEntry extends PathEntry {
return basePath;
}
/**
*
* @return
*/
public IPath getBaseReference() {
return baseRef;
}

View file

@ -45,7 +45,7 @@ public class ASTCache {
/**
* Do something with an AST.
*
* @see #runOnAST(IASTTranslationUnit)
* @see #runOnAST(ILanguage, IASTTranslationUnit)
*/
public static interface ASTRunnable {
/**
@ -180,7 +180,7 @@ public class ASTCache {
}
/**
* Executes {@link ASTRunnable#runOnAST(IASTTranslationUnit)} with the AST
* Executes {@link ASTRunnable#runOnAST(ILanguage, IASTTranslationUnit)} with the AST
* provided by this cache for the given translation unit. Handles acquiring
* and releasing the index read-lock for the client.
*

View file

@ -67,7 +67,7 @@ public class Archive extends Openable implements IArchive {
}
@Override
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource)
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map<ICElement, CElementInfo> newElements, IResource underlyingResource)
throws CModelException {
return computeChildren(info, underlyingResource);
}
@ -76,8 +76,7 @@ public class Archive extends Openable implements IArchive {
IBinaryArchive ar = getBinaryArchive();
if (ar != null) {
IBinaryObject[] objects = ar.getObjects();
for (int i = 0; i < objects.length; i++) {
final IBinaryObject obj = objects[i];
for (final IBinaryObject obj : objects) {
Binary binary = new Binary(this, ar.getPath().append(obj.getName()), obj);
info.addChild(binary);
}
@ -90,6 +89,7 @@ public class Archive extends Openable implements IArchive {
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
@SuppressWarnings("unchecked")
@Override
public Object getAdapter(Class adapter) {
if (IBinaryArchive.class.equals(adapter)) {

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.model;
import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.IArchive;
@ -46,7 +47,7 @@ public class ArchiveContainer extends Openable implements IArchiveContainer {
* @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)
*/
@Override
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource)
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map<ICElement, CElementInfo> newElements, IResource underlyingResource)
throws CModelException {
// this will bootstrap/start the runner for the project.
CModelManager.getDefault().getBinaryRunner(getCProject());

View file

@ -198,6 +198,7 @@ public class Binary extends Openable implements IBinary {
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
@SuppressWarnings("unchecked")
@Override
public Object getAdapter(Class adapter) {
if (IBinaryObject.class.equals(adapter)) {
@ -257,7 +258,7 @@ public class Binary extends Openable implements IBinary {
* @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)
*/
@Override
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource)
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map<ICElement, CElementInfo> newElements, IResource underlyingResource)
throws CModelException {
return computeChildren(info, underlyingResource);
}
@ -265,7 +266,7 @@ public class Binary extends Openable implements IBinary {
boolean computeChildren(OpenableInfo info, IResource res) throws CModelException {
boolean ok = false;
if (isObject() || isExecutable() || isSharedLib()) {
Map hash = new HashMap();
Map<IPath, BinaryModule> hash = new HashMap<IPath, BinaryModule>();
IBinaryObject obj = getBinaryObject();
if (obj != null) {
// First check if we can get the list of source
@ -276,14 +277,14 @@ public class Binary extends Openable implements IBinary {
!addSourceFiles(info, obj, hash))
{
ISymbol[] symbols = obj.getSymbols();
for (int i = 0; i < symbols.length; i++) {
switch (symbols[i].getType()) {
for (ISymbol symbol : symbols) {
switch (symbol.getType()) {
case ISymbol.FUNCTION :
addFunction(info, symbols[i], hash);
addFunction(info, symbol, hash);
break;
case ISymbol.VARIABLE :
addVariable(info, symbols[i], hash);
addVariable(info, symbol, hash);
break;
}
}
@ -295,7 +296,7 @@ public class Binary extends Openable implements IBinary {
}
private boolean addSourceFiles(OpenableInfo info, IBinaryObject obj,
Map hash) throws CModelException {
Map<IPath, BinaryModule> hash) throws CModelException {
// Try to get the list of source files used to build the binary from the
// symbol information.
@ -305,18 +306,7 @@ public class Binary extends Openable implements IBinary {
String[] sourceFiles = symbolreader.getSourceFiles();
if (sourceFiles != null && sourceFiles.length > 0) {
for (int i = 0; i < sourceFiles.length; i++) {
String filename = sourceFiles[i];
// Sometimes the path in the symbolics will have a different
// case than the actual file system path. Even if the file
// system is not case sensitive this will confuse the Path
// class.
// So make sure the path is canonical, otherwise breakpoints
// won't be resolved, etc..
// Also check for relative path names and attempt to resolve
// them relative to the executable.
for (String filename : sourceFiles) {
if (filename.startsWith(".")) { //$NON-NLS-1$
filename = obj.getPath().removeLastSegments(1).append(filename).toOSString();
}
@ -341,9 +331,9 @@ public class Binary extends Openable implements IBinary {
.getWorkspace().getRoot()
.findFilesForLocation(new Path(filename));
for (int j = 0; j < filesInWP.length; j++) {
if (filesInWP[j].isAccessible()) {
wkspFile = filesInWP[j];
for (IFile element : filesInWP) {
if (element.isAccessible()) {
wkspFile = element;
break;
}
}
@ -362,14 +352,14 @@ public class Binary extends Openable implements IBinary {
return false;
}
private void addFunction(OpenableInfo info, ISymbol symbol, Map hash) throws CModelException {
private void addFunction(OpenableInfo info, ISymbol symbol, Map<IPath, BinaryModule> hash) throws CModelException {
IPath filename= symbol.getFilename();
BinaryFunction function = null;
if (filename != null && !filename.isEmpty()) {
BinaryModule module = null;
if (hash.containsKey(filename)) {
module = (BinaryModule)hash.get(filename);
module = hash.get(filename);
} else {
// A special container we do not want the file to be parse.
module = new BinaryModule(this, filename);
@ -392,13 +382,13 @@ public class Binary extends Openable implements IBinary {
// }
}
private void addVariable(OpenableInfo info, ISymbol symbol, Map hash) throws CModelException {
private void addVariable(OpenableInfo info, ISymbol symbol, Map<IPath, BinaryModule> hash) throws CModelException {
IPath filename= symbol.getFilename();
BinaryVariable variable = null;
if (filename != null && !filename.isEmpty()) {
BinaryModule module = null;
if (hash.containsKey(filename)) {
module = (BinaryModule)hash.get(filename);
module = hash.get(filename);
} else {
module = new BinaryModule(this, filename);
hash.put(filename, module);

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.model;
import java.util.ArrayList;
import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.IBinary;
@ -40,10 +41,10 @@ public class BinaryContainer extends Openable implements IBinaryContainer {
public IBinary[] getBinaries() throws CModelException {
sync();
ICElement[] e = getChildren();
ArrayList list = new ArrayList(e.length);
for (int i = 0; i < e.length; i++) {
if (e[i] instanceof IBinary) {
IBinary bin = (IBinary)e[i];
ArrayList<IBinary> list = new ArrayList<IBinary>(e.length);
for (ICElement element : e) {
if (element instanceof IBinary) {
IBinary bin = (IBinary)element;
if (bin.showInBinaryContainer()) {
list.add(bin);
}
@ -63,7 +64,7 @@ public class BinaryContainer extends Openable implements IBinaryContainer {
* @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)
*/
@Override
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource)
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map<ICElement, CElementInfo> newElements, IResource underlyingResource)
throws CModelException {
// this will bootstrap/start the runner for the project.
CModelManager.getDefault().getBinaryRunner(getCProject());

View file

@ -175,58 +175,34 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
return addr;
}
/**
* TODO: This should be in the info
* @param line
*/
public void setLines(int startline, int endLine) {
fStartLine = startline;
fEndLine = endLine;
}
/**
* TODO: This should be in the info
* @param line
*/
public int getStartLine() {
return fStartLine;
}
/**
* TODO: This should be in the info
* @param line
*/
public int getEndLine() {
return fEndLine;
}
/**
* @return
*/
private int getLength() {
// TODO Auto-generated method stub
return 0;
}
/**
* @return
*/
public int getStartPos() {
// TODO Auto-generated method stub
return 0;
}
/**
* @return
*/
private int getIdLength() {
// TODO Auto-generated method stub
return 0;
}
/**
* @return
*/
public int getIdStartPos() {
// TODO Auto-generated method stub
return 0;
@ -250,7 +226,7 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
* @see org.eclipse.cdt.internal.core.model.CElement#generateInfos(java.lang.Object, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
protected void generateInfos(Object info, Map newElements, IProgressMonitor monitor) throws CModelException {
protected void generateInfos(CElementInfo info, Map<ICElement, CElementInfo> newElements, IProgressMonitor monitor) throws CModelException {
}
@Override

View file

@ -103,7 +103,7 @@ public class BinaryModule extends Parent implements IBinaryModule {
* @see org.eclipse.cdt.internal.core.model.CElement#generateInfos(java.lang.Object, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
protected void generateInfos(Object info, Map newElements, IProgressMonitor monitor) throws CModelException {
protected void generateInfos(CElementInfo info, Map<ICElement, CElementInfo> newElements, IProgressMonitor monitor) throws CModelException {
newElements.put(this, info);
}

View file

@ -73,8 +73,8 @@ public class BinaryRunner {
ICElement[] children = container.getChildren();
if (children.length > 0) {
cdelta.added((ICElement)container);
for (int i = 0; i < children.length; i++) {
cdelta.added(children[i]);
for (ICElement element : children) {
cdelta.added(element);
}
}
}
@ -200,7 +200,7 @@ public class BinaryRunner {
String name = proxy.getName();
IContentType contentType = CCorePlugin.getContentType(project, name);
if (contentType != null && textContentType != null) {
if (contentType != null && contentType.isKindOf(textContentType)) {
if (contentType.isKindOf(textContentType)) {
return true;
} else if (textContentType.isAssociatedWith(name)) {
return true;
@ -219,7 +219,7 @@ public class BinaryRunner {
CModelManager factory = CModelManager.getDefault();
IBinaryFile bin = factory.createBinaryFile(file);
if (bin != null) {
// Create the file will add it to the {Archive,Binary}Containery.
// Create the file will add it to the {Archive,Binary}Container.
factory.create(file, bin, cproject);
}
return true;

View file

@ -37,7 +37,7 @@ public class Buffer implements IBuffer {
protected IFile file;
protected int flags;
protected char[] contents;
protected ArrayList changeListeners;
protected ArrayList<IBufferChangedListener> changeListeners;
protected IOpenable owner;
protected int gapStart= -1;
protected int gapEnd= -1;
@ -63,14 +63,14 @@ public class Buffer implements IBuffer {
*/
public void addBufferChangedListener(IBufferChangedListener listener) {
if (this.changeListeners == null) {
this.changeListeners = new ArrayList(5);
this.changeListeners = new ArrayList<IBufferChangedListener>(5);
}
if (!this.changeListeners.contains(listener)) {
this.changeListeners.add(listener);
}
}
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#append(char)
* @see org.eclipse.cdt.core.model.IBuffer#append(char[])
*/
public void append(char[] text) {
if (!isReadOnly()) {
@ -87,7 +87,7 @@ public class Buffer implements IBuffer {
}
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#append(java.lang.String)
* @see org.eclipse.cdt.core.model.IBuffer#append(java.lang.String)
*/
public void append(String text) {
if (text == null) {
@ -97,7 +97,7 @@ public class Buffer implements IBuffer {
}
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#close()
* @see org.eclipse.cdt.core.model.IBuffer#close()
*/
public void close() {
BufferChangedEvent event = null;
@ -113,7 +113,7 @@ public class Buffer implements IBuffer {
}
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#getChar(int)
* @see org.eclipse.cdt.core.model.IBuffer#getChar(int)
*/
public char getChar(int position) {
synchronized (this.lock) {
@ -126,7 +126,7 @@ public class Buffer implements IBuffer {
}
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#getCharacters()
* @see org.eclipse.cdt.core.model.IBuffer#getCharacters()
*/
public char[] getCharacters() {
if (this.contents == null) return null;
@ -143,7 +143,7 @@ public class Buffer implements IBuffer {
}
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#getContents()
* @see org.eclipse.cdt.core.model.IBuffer#getContents()
*/
public String getContents() {
if (this.contents == null) return null;
@ -151,7 +151,7 @@ public class Buffer implements IBuffer {
}
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#getLength()
* @see org.eclipse.cdt.core.model.IBuffer#getLength()
*/
public int getLength() {
synchronized (this.lock) {
@ -161,14 +161,14 @@ public class Buffer implements IBuffer {
}
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#getOwner()
* @see org.eclipse.cdt.core.model.IBuffer#getOwner()
*/
public IOpenable getOwner() {
return this.owner;
}
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#getText(int, int)
* @see org.eclipse.cdt.core.model.IBuffer#getText(int, int)
*/
public String getText(int offset, int length) {
if (this.contents == null)
@ -188,28 +188,28 @@ public class Buffer implements IBuffer {
}
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#getUnderlyingResource()
* @see org.eclipse.cdt.core.model.IBuffer#getUnderlyingResource()
*/
public IResource getUnderlyingResource() {
return this.file;
}
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#hasUnsavedChanges()
* @see org.eclipse.cdt.core.model.IBuffer#hasUnsavedChanges()
*/
public boolean hasUnsavedChanges() {
return (this.flags & F_HAS_UNSAVED_CHANGES) != 0;
}
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#isClosed()
* @see org.eclipse.cdt.core.model.IBuffer#isClosed()
*/
public boolean isClosed() {
return (this.flags & F_IS_CLOSED) != 0;
}
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#isReadOnly()
* @see org.eclipse.cdt.core.model.IBuffer#isReadOnly()
*/
public boolean isReadOnly() {
if (this.file == null) {
@ -225,7 +225,7 @@ public class Buffer implements IBuffer {
protected void notifyChanged(final BufferChangedEvent event) {
if (this.changeListeners != null) {
for (int i = 0, size = this.changeListeners.size(); i < size; ++i) {
final IBufferChangedListener listener = (IBufferChangedListener) this.changeListeners.get(i);
final IBufferChangedListener listener = this.changeListeners.get(i);
SafeRunner.run(new ISafeRunnable() {
public void handleException(Throwable exception) {
Util.log(exception, "Exception occurred in listener of buffer change notification", ICLogConstants.CDT); //$NON-NLS-1$
@ -249,7 +249,7 @@ public class Buffer implements IBuffer {
}
}
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#replace(int, int, char)
* @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, char[])
*/
public void replace(int position, int length, char[] text) {
if (!isReadOnly()) {
@ -282,14 +282,14 @@ public class Buffer implements IBuffer {
}
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#replace(int, int, java.lang.String)
* @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, java.lang.String)
*/
public void replace(int position, int length, String text) {
this.replace(position, length, text == null ? null : text.toCharArray());
}
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#save(org.eclipse.core.runtime.IProgressMonitor, boolean)
* @see org.eclipse.cdt.core.model.IBuffer#save(org.eclipse.core.runtime.IProgressMonitor, boolean)
*/
public void save(IProgressMonitor progress, boolean force)
throws CModelException {
@ -338,7 +338,7 @@ public class Buffer implements IBuffer {
}
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#setContents(char)
* @see org.eclipse.cdt.core.model.IBuffer#setContents(char[])
*/
public void setContents(char[] newContents) {
// allow special case for first initialization
@ -366,7 +366,7 @@ public class Buffer implements IBuffer {
}
/**
* @see org.eclipse.cdt.internal.core.model.IBuffer#setContents(java.lang.String)
* @see org.eclipse.cdt.core.model.IBuffer#setContents(java.lang.String)
*/
public void setContents(String newContents) {
this.setContents(newContents.toCharArray());

View file

@ -16,7 +16,6 @@ import java.util.Enumeration;
import org.eclipse.cdt.core.model.IBuffer;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IOpenable;
import org.eclipse.cdt.internal.core.util.LRUCache;
import org.eclipse.cdt.internal.core.util.OverflowingLRUCache;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
@ -32,7 +31,7 @@ public class BufferManager implements IBufferFactory {
/**
* An LRU cache of <code>IBuffers</code>.
*/
public class BufferCache extends OverflowingLRUCache {
public class BufferCache<K> extends OverflowingLRUCache<K,IBuffer> {
/**
* Constructs a new buffer cache of the given size.
*/
@ -53,8 +52,8 @@ public class BufferManager implements IBufferFactory {
* by closing the buffer.
*/
@Override
protected boolean close(LRUCacheEntry entry) {
IBuffer buffer= (IBuffer) entry._fValue;
protected boolean close(LRUCacheEntry<K,IBuffer> entry) {
IBuffer buffer= entry._fValue;
if (buffer.hasUnsavedChanges()) {
return false;
}
@ -65,8 +64,8 @@ public class BufferManager implements IBufferFactory {
* Returns a new instance of the reciever.
*/
@Override
protected LRUCache newInstance(int size, int overflow) {
return new BufferCache(size, overflow);
protected OverflowingLRUCache<K, IBuffer> newInstance(int size, int overflow) {
return new BufferCache<K>(size, overflow);
}
}
@ -76,7 +75,7 @@ public class BufferManager implements IBufferFactory {
* LRU cache of buffers. The key and value for an entry
* in the table is the identical buffer.
*/
protected OverflowingLRUCache openBuffers = new BufferCache(60);
protected OverflowingLRUCache<IOpenable, IBuffer> openBuffers = new BufferCache<IOpenable>(60);
/**
* Creates a new buffer manager.
@ -135,7 +134,7 @@ public class BufferManager implements IBufferFactory {
* @see OverflowingLRUCache
* @return Enumeration of IBuffer
*/
public Enumeration getOpenBuffers() {
public Enumeration<IBuffer> getOpenBuffers() {
synchronized (openBuffers) {
openBuffers.shrink();
return openBuffers.elements();

View file

@ -54,7 +54,7 @@ public class CContainer extends Openable implements ICContainer {
* @see ICContainer#getBinaries()
*/
public IBinary[] getBinaries() throws CModelException {
List list = getChildrenOfType(C_BINARY);
List<?> list = getChildrenOfType(C_BINARY);
IBinary[] array = new IBinary[list.size()];
list.toArray(array);
return array;
@ -82,7 +82,7 @@ public class CContainer extends Openable implements ICContainer {
* @see ICContainer#getArchives()
*/
public IArchive[] getArchives() throws CModelException {
List list = getChildrenOfType(C_ARCHIVE);
List<?> list = getChildrenOfType(C_ARCHIVE);
IArchive[] array = new IArchive[list.size()];
list.toArray(array);
return array;
@ -108,7 +108,7 @@ public class CContainer extends Openable implements ICContainer {
* @see ICContainer#getTranslationUnits()
*/
public ITranslationUnit[] getTranslationUnits() throws CModelException {
List list = getChildrenOfType(C_UNIT);
List<?> list = getChildrenOfType(C_UNIT);
ITranslationUnit[] array = new ITranslationUnit[list.size()];
list.toArray(array);
return array;
@ -135,7 +135,7 @@ public class CContainer extends Openable implements ICContainer {
* @see org.eclipse.cdt.core.model.ICContainer#getCContainers()
*/
public ICContainer[] getCContainers() throws CModelException {
List list = getChildrenOfType(C_CCONTAINER);
List<?> list = getChildrenOfType(C_CCONTAINER);
ICContainer[] array = new ICContainer[list.size()];
list.toArray(array);
return array;
@ -174,7 +174,7 @@ public class CContainer extends Openable implements ICContainer {
* @see Openable
*/
@Override
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource)
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map<ICElement, CElementInfo> newElements, IResource underlyingResource)
throws CModelException {
boolean validInfo = false;
try {
@ -203,7 +203,7 @@ public class CContainer extends Openable implements ICContainer {
}
protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException {
ArrayList vChildren = new ArrayList();
ArrayList<ICElement> vChildren = new ArrayList<ICElement>();
try {
IResource[] resources = null;
if (res instanceof IContainer) {
@ -212,8 +212,8 @@ public class CContainer extends Openable implements ICContainer {
}
if (resources != null) {
ICProject cproject = getCProject();
for (int i = 0; i < resources.length; i++) {
ICElement celement = computeChild(resources[i], cproject);
for (IResource resource2 : resources) {
ICElement celement = computeChild(resource2, cproject);
if (celement != null) {
vChildren.add(celement);
}

View file

@ -39,15 +39,11 @@ public class CContainerInfo extends OpenableInfo {
super(element);
}
/**
* @param container
* @return
*/
public Object[] getNonCResources(IResource res) {
if (nonCResources != null)
return nonCResources;
ArrayList notChildren = new ArrayList();
ArrayList<IResource> notChildren = new ArrayList<IResource>();
ICElement celement = getElement();
ICProject cproject = celement.getCProject();
// move back to the sourceroot.
@ -76,8 +72,7 @@ public class CContainerInfo extends OpenableInfo {
}
if (resources != null) {
for (int i = 0; i < resources.length; i++) {
IResource member = resources[i];
for (IResource member : resources) {
switch(member.getType()) {
case IResource.FOLDER: {
// Check if the folder is not itself a sourceEntry.
@ -113,10 +108,6 @@ public class CContainerInfo extends OpenableInfo {
return nonCResources;
}
/**
* @param container
* @return
*/
public void setNonCResources(Object[] resources) {
nonCResources = resources;
}
@ -125,9 +116,8 @@ public class CContainerInfo extends OpenableInfo {
if(entries == null)
return false;
for (int k = 0; k < entries.length; k++) {
ICSourceEntry entry = entries[k];
// if (entry.getEntryKind() == IPathEntry.CDT_SOURCE) {
for (ICSourceEntry entry : entries) {
// if (entry.getEntryKind() == IPathEntry.CDT_SOURCE) {
IPath sourcePath = entry.getFullPath();
if (resourcePath.equals(sourcePath)) {
return true;

View file

@ -16,7 +16,6 @@ package org.eclipse.cdt.internal.core.model;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@ -73,6 +72,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
/* (non-Javadoc)
* @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
*/
@SuppressWarnings("unchecked")
@Override
public Object getAdapter(Class adapter) {
// handle all kinds of resources
@ -153,10 +153,9 @@ public abstract class CElement extends PlatformObject implements ICElement {
protected ICElement getSourceElementAtOffset(int offset) throws CModelException {
if (this instanceof ISourceReference && this instanceof Parent) {
ICElement[] children = ((Parent)this).getChildren();
for (int i = 0; i < children.length; i++) {
ICElement aChild = children[i];
for (ICElement aChild : children) {
if (aChild instanceof ISourceReference) {
ISourceReference child = (ISourceReference) children[i];
ISourceReference child = (ISourceReference) aChild;
ISourceRange range = child.getSourceRange();
int startPos = range.getStartPos();
int endPos = startPos + range.getLength();
@ -184,12 +183,11 @@ public abstract class CElement extends PlatformObject implements ICElement {
*/
protected ICElement[] getSourceElementsAtOffset(int offset) throws CModelException {
if (this instanceof ISourceReference && this instanceof Parent) {
ArrayList list = new ArrayList();
ArrayList<Object> list = new ArrayList<Object>();
ICElement[] children = ((Parent)this).getChildren();
for (int i = 0; i < children.length; i++) {
ICElement aChild = children[i];
for (ICElement aChild : children) {
if (aChild instanceof ISourceReference) {
ISourceReference child = (ISourceReference) children[i];
ISourceReference child = (ISourceReference) aChild;
ISourceRange range = child.getSourceRange();
int startPos = range.getStartPos();
int endPos = startPos + range.getLength();
@ -412,7 +410,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
* if successful, or false if an error is encountered while determining
* the structure of this element.
*/
protected abstract void generateInfos(Object info, Map newElements, IProgressMonitor monitor) throws CModelException;
protected abstract void generateInfos(CElementInfo info, Map<ICElement, CElementInfo> newElements, IProgressMonitor monitor) throws CModelException;
/**
* Open a <code>IOpenable</code> that is known to be closed (no check for
@ -422,16 +420,16 @@ public abstract class CElement extends PlatformObject implements ICElement {
CModelManager manager = CModelManager.getDefault();
boolean hadTemporaryCache = manager.hasTemporaryCache();
try {
HashMap newElements = manager.getTemporaryCache();
Map<ICElement, CElementInfo> newElements = manager.getTemporaryCache();
generateInfos(info, newElements, pm);
if (info == null) {
info = (CElementInfo)newElements.get(this);
info = newElements.get(this);
}
if (info == null) { // a source ref element could not be opened
// close any buffer that was opened for the openable parent
Iterator iterator = newElements.keySet().iterator();
Iterator<ICElement> iterator = newElements.keySet().iterator();
while (iterator.hasNext()) {
ICElement element = (ICElement)iterator.next();
ICElement element = iterator.next();
if (element instanceof Openable) {
((Openable)element).closeBuffer();
}

View file

@ -39,12 +39,12 @@ public class CElementDelta implements ICElementDelta {
private int fChangeFlags = 0;
/**
* @see #getMovedFromHandle()
* @see #getMovedFromElement()
*/
protected ICElement fMovedFromHandle = null;
/**
* @see #getMovedToHandle()
* @see #getMovedToElement()
*/
protected ICElement fMovedToHandle = null;
@ -171,8 +171,8 @@ public class CElementDelta implements ICElementDelta {
// child was changed then changed -> it is changed
case CHANGED:
ICElementDelta[] children = child.getAffectedChildren();
for (int i = 0; i < children.length; i++) {
CElementDelta childsChild = (CElementDelta) children[i];
for (ICElementDelta element : children) {
CElementDelta childsChild = (CElementDelta) element;
((CElementDelta) existingChild).addAffectedChild(childsChild);
}
// add the non-c resource deltas if needed
@ -276,7 +276,7 @@ public class CElementDelta implements ICElementDelta {
*/
protected CElementDelta createDeltaTree(ICElement element, CElementDelta delta) {
CElementDelta childDelta = delta;
ArrayList ancestors= getAncestors(element);
ArrayList<ICElement> ancestors= getAncestors(element);
if (ancestors == null) {
if (equalsAndSameParent(delta.getElement(), getElement())) {
// handle case of two jars that can be equals but not in the
@ -292,7 +292,7 @@ public class CElementDelta implements ICElementDelta {
}
} else {
for (int i = 0, size = ancestors.size(); i < size; i++) {
ICElement ancestor = (ICElement) ancestors.get(i);
ICElement ancestor = ancestors.get(i);
CElementDelta ancestorDelta = new CElementDelta(ancestor);
ancestorDelta.addAffectedChild(childDelta);
childDelta = ancestorDelta;
@ -309,8 +309,8 @@ public class CElementDelta implements ICElementDelta {
if (equalsAndSameParent(fChangedElement, e)) { // handle case of two jars that can be equals but not in the same project
return this;
}
for (int i = 0; i < fAffectedChildren.length; i++) {
CElementDelta delta = ((CElementDelta)fAffectedChildren[i]).find(e);
for (ICElementDelta element : fAffectedChildren) {
CElementDelta delta = ((CElementDelta)element).find(e);
if (delta != null) {
return delta;
}
@ -345,12 +345,12 @@ public class CElementDelta implements ICElementDelta {
* element is not a descendant of the root of this tree, <code>null</code>
* is returned.
*/
private ArrayList getAncestors(ICElement element) {
private ArrayList<ICElement> getAncestors(ICElement element) {
ICElement parent = element.getParent();
if (parent == null) {
return null;
}
ArrayList parents = new ArrayList();
ArrayList<ICElement> parents = new ArrayList<ICElement>();
while (!parent.equals(fChangedElement)) {
parents.add(parent);
parent = parent.getParent();
@ -377,7 +377,7 @@ public class CElementDelta implements ICElementDelta {
if (length == 0) {
return new ICElementDelta[] {};
}
ArrayList children= new ArrayList(length);
ArrayList<ICElementDelta> children= new ArrayList<ICElementDelta>(length);
for (int i = 0; i < length; i++) {
if (fAffectedChildren[i].getKind() == type) {
children.add(fAffectedChildren[i]);
@ -619,7 +619,7 @@ public class CElementDelta implements ICElementDelta {
* Returns a string representation of this delta's
* structure suitable for debug purposes.
*
* @see toString
* @see #toString()
*/
public String toDebugString(int depth) {
StringBuffer buffer = new StringBuffer();

View file

@ -47,17 +47,17 @@ public class CElementDeltaBuilder {
/**
* The old handle to info relationships
*/
Map infos;
Map<ICElement, CElementInfo> infos;
/**
* The old position info
*/
Map oldPositions;
Map<ICElement, ListItem> oldPositions;
/**
* The new position info
*/
Map newPositions;
Map<ICElement, ListItem> newPositions;
/**
* Change delta
@ -67,12 +67,12 @@ public class CElementDeltaBuilder {
/**
* List of added elements
*/
ArrayList added;
ArrayList<ICElement> added;
/**
* List of removed elements
*/
ArrayList removed;
ArrayList<ICElement> removed;
/**
* Doubly linked list item
@ -213,26 +213,26 @@ private void findContentChange(CElementInfo oldInfo, CElementInfo newInfo, ICEle
* Adds removed deltas for any handles left in the table
*/
private void findDeletions() {
Iterator iter = this.infos.keySet().iterator();
Iterator<ICElement> iter = this.infos.keySet().iterator();
while(iter.hasNext()) {
ICElement element = (ICElement)iter.next();
ICElement element = iter.next();
this.delta.removed(element);
this.removed(element);
}
}
private CElementInfo getElementInfo(ICElement element) {
return (CElementInfo)this.infos.get(element);
return this.infos.get(element);
}
private ListItem getNewPosition(ICElement element) {
return (ListItem)this.newPositions.get(element);
return this.newPositions.get(element);
}
private ListItem getOldPosition(ICElement element) {
return (ListItem)this.oldPositions.get(element);
return this.oldPositions.get(element);
}
private void initialize() {
this.infos = new HashMap(20);
this.oldPositions = new HashMap(20);
this.newPositions = new HashMap(20);
this.infos = new HashMap<ICElement, CElementInfo>(20);
this.oldPositions = new HashMap<ICElement, ListItem>(20);
this.newPositions = new HashMap<ICElement, ListItem>(20);
this.putOldPosition(this.cElement, new ListItem(null, null));
this.putNewPosition(this.cElement, new ListItem(null, null));
this.delta = new CElementDelta(cElement);
@ -243,8 +243,8 @@ private void initialize() {
this.delta.fineGrained();
}
this.added = new ArrayList(5);
this.removed = new ArrayList(5);
this.added = new ArrayList<ICElement>(5);
this.removed = new ArrayList<ICElement>(5);
}
/**
* Inserts position information for the elements into the new or old positions table

View file

@ -36,11 +36,11 @@ class CElementInfo {
* object. This is an empty array if this element has
* no children.
*/
private List fChildren;
private List<ICElement> fChildren;
/**
* Is the structure of this element known
* @see ICElement.isStructureKnown()
* @see ICElement#isStructureKnown()
*/
protected boolean fIsStructureKnown = false;
@ -49,7 +49,7 @@ class CElementInfo {
protected CElementInfo(CElement element) {
this.element = element;
// Array list starts with size = 0
fChildren = new Vector(0);
fChildren = new Vector<ICElement>(0);
}
protected CElement getElement() {
@ -65,11 +65,11 @@ class CElementInfo {
protected ICElement[] getChildren() {
synchronized (fChildren) {
ICElement[] array= new ICElement[fChildren.size()];
return (ICElement[]) fChildren.toArray( array );
return fChildren.toArray( array );
}
}
List internalGetChildren() {
List<ICElement> internalGetChildren() {
return fChildren;
}
@ -84,7 +84,7 @@ class CElementInfo {
}
/**
* @see ICElement.isStructureKnown()
* @see ICElement#isStructureKnown()
*/
protected boolean isStructureKnown() {
return fIsStructureKnown;
@ -98,7 +98,7 @@ class CElementInfo {
fChildren.clear();
}
protected void setChildren(List children) {
protected void setChildren(List<? extends ICElement> children) {
fChildren.addAll(children);
}
@ -138,7 +138,7 @@ class CElementInfo {
/**
* Sets whether the structure of this element known
* @see ICElement.isStructureKnown()
* @see ICElement#isStructureKnown()
*/
protected void setIsStructureKnown(boolean newIsStructureKnown) {
fIsStructureKnown = newIsStructureKnown;

View file

@ -50,7 +50,7 @@ public class CModel extends Openable implements ICModel {
}
public ICProject[] getCProjects() throws CModelException {
List list = getChildrenOfType(C_PROJECT);
List<?> list = getChildrenOfType(C_PROJECT);
ICProject[] array= new ICProject[list.size()];
list.toArray(array);
return array;
@ -92,10 +92,9 @@ public class CModel extends Openable implements ICModel {
public ICProject findCProject(IProject project) {
try {
ICProject[] projects = getOldCProjectsList();
for (int i = 0, length = projects.length; i < length; i++) {
ICProject javaProject = projects[i];
if (project.equals(javaProject.getProject())) {
return javaProject;
for (ICProject cProject : projects) {
if (project.equals(cProject.getProject())) {
return cProject;
}
}
} catch (CModelException e) {
@ -188,7 +187,7 @@ public class CModel extends Openable implements ICModel {
* @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)
*/
@Override
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws CModelException {
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map<ICElement, CElementInfo> newElements, IResource underlyingResource) throws CModelException {
boolean validInfo = false;
try {
IResource res = getResource();
@ -214,8 +213,7 @@ public class CModel extends Openable implements ICModel {
// determine my children
IWorkspaceRoot root = (IWorkspaceRoot)getResource();
IProject[] projects = root.getProjects();
for (int i = 0, max = projects.length; i < max; i++) {
IProject project = projects[i];
for (IProject project : projects) {
if (CoreModel.hasCNature(project) || CoreModel.hasCCNature(project)) {
ICProject cproject = new CProject(this, project);
info.addChild(cproject);

View file

@ -198,37 +198,33 @@ public class CModelBuilder2 implements IContributedModelBuilder {
// includes
final IASTPreprocessorIncludeStatement[] includeDirectives= ast.getIncludeDirectives();
Set<Include> allIncludes= new HashSet<Include>();
for (int i= 0; i < includeDirectives.length; i++) {
IASTPreprocessorIncludeStatement includeDirective= includeDirectives[i];
for (IASTPreprocessorIncludeStatement includeDirective : includeDirectives) {
if (isLocalToFile(includeDirective)) {
createInclusion(fTranslationUnit, includeDirective, allIncludes);
}
}
// macros
final IASTPreprocessorMacroDefinition[] macroDefinitions= ast.getMacroDefinitions();
for (int i= 0; i < macroDefinitions.length; i++) {
IASTPreprocessorMacroDefinition macroDefinition= macroDefinitions[i];
for (IASTPreprocessorMacroDefinition macroDefinition : macroDefinitions) {
if (isLocalToFile(macroDefinition)) {
createMacro(fTranslationUnit, macroDefinition);
}
}
// declarations
final IASTDeclaration[] declarations= ast.getDeclarations();
for (int i= 0; i < declarations.length; i++) {
IASTDeclaration declaration= declarations[i];
for (IASTDeclaration declaration : declarations) {
if (isLocalToFile(declaration)) {
createDeclaration(fTranslationUnit, declaration);
}
}
// sort by offset
@SuppressWarnings("unchecked")
final List<SourceManipulation> children= fTranslationUnit.getElementInfo().internalGetChildren();
Collections.sort(children, new Comparator<SourceManipulation>() {
public int compare(SourceManipulation o1, SourceManipulation o2) {
final List<ICElement> children= fTranslationUnit.getElementInfo().internalGetChildren();
Collections.sort(children, new Comparator<ICElement>() {
public int compare(ICElement o1, ICElement o2) {
try {
final SourceManipulationInfo info1= o1.getSourceManipulationInfo();
final SourceManipulationInfo info2= o2.getSourceManipulationInfo();
final SourceManipulationInfo info1= ((SourceManipulation) o1).getSourceManipulationInfo();
final SourceManipulationInfo info2= ((SourceManipulation) o2).getSourceManipulationInfo();
int delta= info1.getStartPos() - info2.getStartPos();
if (delta == 0) {
delta= info1.getIdStartPos() - info2.getIdStartPos();
@ -249,15 +245,13 @@ public class CModelBuilder2 implements IContributedModelBuilder {
problemRequestor.beginReporting();
final IASTProblem[] ppProblems= ast.getPreprocessorProblems();
IASTProblem[] problems= ppProblems;
for (int i= 0; i < problems.length; i++) {
IASTProblem problem= problems[i];
for (IASTProblem problem : problems) {
if (isLocalToFile(problem)) {
problemRequestor.acceptProblem(problem);
}
}
problems= CPPVisitor.getProblems(ast);
for (int i= 0; i < problems.length; i++) {
IASTProblem problem= problems[i];
for (IASTProblem problem : problems) {
if (isLocalToFile(problem)) {
problemRequestor.acceptProblem(problem);
}
@ -358,8 +352,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
} else if (declaration instanceof IASTSimpleDeclaration) {
CElement[] elements= createSimpleDeclarations(parent, (IASTSimpleDeclaration)declaration, true);
String[] parameterTypes= ASTStringUtil.getTemplateParameterArray(templateDeclaration.getTemplateParameters());
for (int i= 0; i < elements.length; i++) {
CElement element= elements[i];
for (CElement element : elements) {
// set the template parameters
if (element instanceof StructureTemplate) {
StructureTemplate classTemplate= (StructureTemplate) element;
@ -408,8 +401,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
*/
private void createLinkageSpecification(Parent parent, ICPPASTLinkageSpecification linkageDeclaration) throws CModelException, DOMException {
IASTDeclaration[] declarations= linkageDeclaration.getDeclarations();
for (int i= 0; i < declarations.length; i++) {
IASTDeclaration declaration= declarations[i];
for (IASTDeclaration declaration : declarations) {
if (linkageDeclaration.getFileLocation() != null || isLocalToFile(declaration)) {
createDeclaration(parent, declaration);
}
@ -524,8 +516,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
final Set<Namespace> savedNamespaces= fAllNamespaces;
fAllNamespaces= new HashSet<Namespace>();
IASTDeclaration[] nsDeclarations= declaration.getDeclarations();
for (int i= 0; i < nsDeclarations.length; i++) {
IASTDeclaration nsDeclaration= nsDeclarations[i];
for (IASTDeclaration nsDeclaration : nsDeclarations) {
if (declaration.getFileLocation() != null || isLocalToFile(nsDeclaration)) {
createDeclaration(element, nsDeclaration);
}
@ -597,8 +588,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
// add to parent
parent.addChild(element);
final IASTEnumerator[] enumerators= enumSpecifier.getEnumerators();
for (int i= 0; i < enumerators.length; i++) {
final IASTEnumerator enumerator= enumerators[i];
for (final IASTEnumerator enumerator : enumerators) {
createEnumerator(element, enumerator);
}
// set enumeration position
@ -672,8 +662,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
// store super classes names
final ICPPASTCompositeTypeSpecifier cppCompositeTypeSpecifier= (ICPPASTCompositeTypeSpecifier)compositeTypeSpecifier;
ICPPASTBaseSpecifier[] baseSpecifiers= cppCompositeTypeSpecifier.getBaseSpecifiers();
for (int i= 0; i < baseSpecifiers.length; i++) {
final ICPPASTBaseSpecifier baseSpecifier= baseSpecifiers[i];
for (final ICPPASTBaseSpecifier baseSpecifier : baseSpecifiers) {
final IASTName baseName= baseSpecifier.getName();
final ASTAccessVisibility visibility;
switch(baseSpecifier.getVisibility()) {
@ -713,8 +702,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
pushDefaultVisibility(defaultVisibility);
try {
final IASTDeclaration[] memberDeclarations= compositeTypeSpecifier.getMembers();
for (int i= 0; i < memberDeclarations.length; i++) {
IASTDeclaration member= memberDeclarations[i];
for (IASTDeclaration member : memberDeclarations) {
if (compositeTypeSpecifier.getFileLocation() != null || isLocalToFile(member)) {
createDeclaration(element, member);
}
@ -862,8 +850,8 @@ public class CModelBuilder2 implements IContributedModelBuilder {
if (!isMethod && name instanceof ICPPASTQualifiedName) {
final IASTName[] names= ((ICPPASTQualifiedName)name).getNames();
if (isTemplate) {
for (int i= 0; i < names.length; i++) {
if (names[i] instanceof ICPPASTTemplateId) {
for (IASTName name2 : names) {
if (name2 instanceof ICPPASTTemplateId) {
isMethod= true;
break;
}

View file

@ -16,6 +16,7 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IOpenable;
import org.eclipse.cdt.internal.core.util.OverflowingLRUCache;
@ -33,28 +34,28 @@ public class CModelCache {
/**
* Cache of open projects and roots.
*/
protected Map projectAndRootCache;
protected Map<ICElement, Object> projectAndRootCache;
/**
* Cache of open containers
*/
protected Map folderCache;
protected Map<ICElement, Object> folderCache;
/**
* Cache of open translation unit files
*/
protected OverflowingLRUCache fileCache;
protected OverflowingLRUCache<IOpenable, Object> fileCache;
/**
* Cache of children of C elements
*/
protected Map childrenCache;
protected Map<ICElement, Object> childrenCache;
public CModelCache() {
this.projectAndRootCache = new HashMap(PROJ_CACHE_SIZE);
this.folderCache = new HashMap(FOLDER_CACHE_SIZE);
this.fileCache = new ElementCache(FILE_CACHE_SIZE);
this.childrenCache = new HashMap(CHILDREN_CACHE_SIZE); // average 20 children per openable
this.projectAndRootCache = new HashMap<ICElement, Object>(PROJ_CACHE_SIZE);
this.folderCache = new HashMap<ICElement, Object>(FOLDER_CACHE_SIZE);
this.fileCache = new ElementCache<Object>(FILE_CACHE_SIZE);
this.childrenCache = new HashMap<ICElement, Object>(CHILDREN_CACHE_SIZE); // average 20 children per openable
}
public double openableFillingRatio() {
@ -94,7 +95,7 @@ protected Object peekAtInfo(ICElement element) {
case ICElement.C_ARCHIVE:
case ICElement.C_BINARY:
case ICElement.C_UNIT:
return this.fileCache.peek(element);
return this.fileCache.peek((IOpenable) element);
default:
return this.childrenCache.get(element);
}
@ -115,7 +116,7 @@ protected void putInfo(ICElement element, Object info) {
case ICElement.C_ARCHIVE:
case ICElement.C_BINARY:
case ICElement.C_UNIT:
this.fileCache.put(element, info);
this.fileCache.put((IOpenable)element, info);
break;
default:
this.childrenCache.put(element, info);
@ -136,7 +137,7 @@ protected void removeInfo(ICElement element) {
case ICElement.C_ARCHIVE:
case ICElement.C_BINARY:
case ICElement.C_UNIT:
this.fileCache.remove(element);
this.fileCache.remove((IOpenable)element);
break;
default:
this.childrenCache.remove(element);

View file

@ -12,6 +12,7 @@
package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICModel;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
@ -65,9 +66,6 @@ public class CModelInfo extends OpenableInfo {
return nonCResources;
}
/**
* @return
*/
public void setNonCResources(Object[] resources) {
nonCResources = resources;
}

View file

@ -122,16 +122,16 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
/**
* A map from ITranslationUnit to IWorkingCopy of the shared working copies.
*/
public Map<ITranslationUnit, IWorkingCopy> sharedWorkingCopies = new HashMap<ITranslationUnit, IWorkingCopy>();
public Map<IBufferFactory, Map<ITranslationUnit, WorkingCopy>> sharedWorkingCopies = new HashMap<IBufferFactory, Map<ITranslationUnit, WorkingCopy>>();
/**
* Set of elements which are out of sync with their buffers.
*/
protected Map elementsOutOfSynchWithBuffers = new HashMap(11);
protected Map<ICElement,ICElement> elementsOutOfSynchWithBuffers = new HashMap<ICElement, ICElement>(11);
/*
* Temporary cache of newly opened elements
*/
private ThreadLocal<Map<ICElement, Object>> temporaryCache = new ThreadLocal<Map<ICElement, Object>>();
private ThreadLocal<Map<ICElement, CElementInfo>> temporaryCache = new ThreadLocal<Map<ICElement, CElementInfo>>();
/**
* Infos cache.
@ -319,8 +319,8 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
path = path.removeLastSegments(1);
String[] segments = path.segments();
ICContainer cfolder = root;
for (int j = 0; j < segments.length; j++) {
cfolder = cfolder.getCContainer(segments[j]);
for (String segment : segments) {
cfolder = cfolder.getCContainer(segment);
}
if (CoreModel.isValidTranslationUnitName(cproject.getProject(), fileName)) {
celement = cfolder.getTranslationUnit(fileName);
@ -393,15 +393,15 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
try {
IIncludeReference[] includeReferences = cproject.getIncludeReferences();
for (int i = 0; i < includeReferences.length; i++) {
if (includeReferences[i].isOnIncludeEntry(path)) {
for (IIncludeReference includeReference : includeReferences) {
if (includeReference.isOnIncludeEntry(path)) {
String headerContentTypeId= contentTypeId;
if (headerContentTypeId == null) {
headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
}
// TODO: use URI
return new ExternalTranslationUnit(includeReferences[i], URIUtil.toURI(path), headerContentTypeId);
return new ExternalTranslationUnit(includeReference, URIUtil.toURI(path), headerContentTypeId);
}
}
} catch (CModelException e) {
@ -417,8 +417,8 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
// !path.isAbsolute()
try {
IIncludeReference[] includeReferences = cproject.getIncludeReferences();
for (int i = 0; i < includeReferences.length; i++) {
IPath includePath = includeReferences[i].getPath().append(path);
for (IIncludeReference includeReference : includeReferences) {
IPath includePath = includeReference.getPath().append(path);
if (Util.isNonZeroLengthFile(includePath)) {
String headerContentTypeId= contentTypeId;
if (headerContentTypeId == null) {
@ -426,7 +426,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
}
// TODO: use URI
return new ExternalTranslationUnit(includeReferences[i], URIUtil.toURI(includePath), headerContentTypeId);
return new ExternalTranslationUnit(includeReference, URIUtil.toURI(includePath), headerContentTypeId);
}
}
} catch (CModelException e) {
@ -470,18 +470,18 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
try {
IIncludeReference[] includeReferences = cproject.getIncludeReferences();
for (int i = 0; i < includeReferences.length; i++) {
for (IIncludeReference includeReference : includeReferences) {
// crecoskie
// TODO FIXME: include entries don't handle URIs yet
if (includeReferences[i].isOnIncludeEntry(URIUtil.toPath(locationURI))) {
if (includeReference.isOnIncludeEntry(URIUtil.toPath(locationURI))) {
String headerContentTypeId= contentTypeId;
if (headerContentTypeId == null) {
headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
}
return new ExternalTranslationUnit(includeReferences[i], locationURI, headerContentTypeId);
return new ExternalTranslationUnit(includeReference, locationURI, headerContentTypeId);
}
}
} catch (CModelException e) {
@ -511,8 +511,8 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
CElementInfo info = (CElementInfo)peekAtInfo(celement);
if (info != null) {
ICElement[] children = info.getChildren();
for (int i = 0; i < children.length; i++) {
releaseCElement(children[i]);
for (ICElement element : children) {
releaseCElement(element);
}
}
@ -536,10 +536,10 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
if (peekAtInfo(pinfo.vBin) != null) {
try {
ICElement[] bins = pinfo.vBin.getChildren();
for (int i = 0; i < bins.length; i++) {
if (celement.getPath().isPrefixOf(bins[i].getPath())) {
for (ICElement bin : bins) {
if (celement.getPath().isPrefixOf(bin.getPath())) {
//pinfo.vBin.removeChild(bins[i]);
list.add(bins[i]);
list.add(bin);
}
}
} catch (CModelException e) {
@ -551,10 +551,10 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
if (peekAtInfo(pinfo.vLib) != null) {
try {
ICElement[] ars = pinfo.vLib.getChildren();
for (int i = 0; i < ars.length; i++) {
if (celement.getPath().isPrefixOf(ars[i].getPath())) {
for (ICElement ar : ars) {
if (celement.getPath().isPrefixOf(ar.getPath())) {
//pinfo.vLib.removeChild(ars[i]);
list.add(ars[i]);
list.add(ar);
}
}
} catch (CModelException e) {
@ -564,7 +564,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
}
// release any binary/archive that was in the path
for (int i = 0; i < list.size(); i++) {
ICElement b = (ICElement)list.get(i);
ICElement b = list.get(i);
releaseCElement(b);
}
}
@ -580,7 +580,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
}
public BinaryParserConfig[] getBinaryParser(IProject project) {
BinaryParserConfig[] parsers = (BinaryParserConfig[])binaryParsersMap.get(project);
BinaryParserConfig[] parsers = binaryParsersMap.get(project);
if (parsers == null) {
try {
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project, false);
@ -588,8 +588,8 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
ICExtensionReference[] cextensions = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID, true);
if (cextensions.length > 0) {
ArrayList<BinaryParserConfig> list = new ArrayList<BinaryParserConfig>(cextensions.length);
for (int i = 0; i < cextensions.length; i++) {
BinaryParserConfig config = new BinaryParserConfig(cextensions[i]);
for (ICExtensionReference cextension : cextensions) {
BinaryParserConfig config = new BinaryParserConfig(cextension);
list.add(config);
}
parsers = new BinaryParserConfig[list.size()];
@ -661,10 +661,10 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
int hints = 0;
for (int i = 0; i < parsers.length; i++) {
for (BinaryParserConfig parser2 : parsers) {
IBinaryParser parser = null;
try {
parser = parsers[i].getBinaryParser();
parser = parser2.getBinaryParser();
if (parser.getHintBufferSize() > hints) {
hints = Math.max(hints, parser.getHintBufferSize());
}
@ -706,9 +706,9 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
IPath location = file.getLocation();
for (int i = 0; i < parsers.length; i++) {
for (BinaryParserConfig parser2 : parsers) {
try {
IBinaryParser parser = parsers[i].getBinaryParser();
IBinaryParser parser = parser2.getBinaryParser();
if (parser.isBinary(bytes, location)) {
IBinaryFile binFile = parser.getBinary(bytes, location);
if (binFile != null) {
@ -749,7 +749,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
BinaryRunner runner = null;
synchronized (binaryRunners) {
IProject project = cproject.getProject();
runner = (BinaryRunner)binaryRunners.get(project);
runner = binaryRunners.get(project);
if (runner == null) {
runner = new BinaryRunner(project);
binaryRunners.put(project, runner);
@ -764,7 +764,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
}
public void removeBinaryRunner(IProject project) {
BinaryRunner runner = (BinaryRunner)binaryRunners.remove(project);
BinaryRunner runner = binaryRunners.remove(project);
if (runner != null) {
runner.stop();
}
@ -773,7 +773,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
public SourceMapper getSourceMapper(ICProject cProject) {
SourceMapper mapper = null;
synchronized (sourceMappers) {
mapper = (SourceMapper)sourceMappers.get(cProject);
mapper = sourceMappers.get(cProject);
if (mapper == null) {
mapper = new SourceMapper(cProject);
sourceMappers.put(cProject, mapper);
@ -855,8 +855,8 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
checkForProjectRename(delta);
ICElementDelta[] translatedDeltas = fDeltaProcessor.processResourceDelta(delta);
if (translatedDeltas.length > 0) {
for (int i = 0; i < translatedDeltas.length; i++) {
registerCModelDelta(translatedDeltas[i]);
for (ICElementDelta translatedDelta : translatedDeltas) {
registerCModelDelta(translatedDelta);
}
}
fire(ElementChangedEvent.POST_CHANGE);
@ -923,6 +923,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
* Fire C Model deltas, flushing them after the fact.
* If the firing mode has been turned off, this has no effect.
*/
@SuppressWarnings("deprecation")
void fire(ICElementDelta customDeltas, int eventType) {
if (fFire) {
ICElementDelta deltaToNotify;
@ -966,6 +967,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
}
}
@SuppressWarnings("deprecation")
private void firePreAutoBuildDelta(ICElementDelta deltaToNotify,
IElementChangedListener[] listeners, int[] listenerMask, int listenerCount) {
@ -1078,8 +1080,8 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
}
IResourceDelta[] resourceDeltas = delta.getResourceDeltas();
if (resourceDeltas != null) {
for (int i = 0, length = resourceDeltas.length; i < length; i++) {
rootDelta.addResourceDelta(resourceDeltas[i]);
for (IResourceDelta resourceDelta : resourceDeltas) {
rootDelta.addResourceDelta(resourceDelta);
insertedTree = true;
}
}
@ -1098,7 +1100,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
/**
* Returns the set of elements which are out of synch with their buffers.
*/
protected Map getElementsOutOfSynchWithBuffers() {
protected Map<ICElement,ICElement> getElementsOutOfSynchWithBuffers() {
return this.elementsOutOfSynchWithBuffers;
}
@ -1106,7 +1108,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
* Returns the info for the element.
*/
public synchronized Object getInfo(ICElement element) {
HashMap<ICElement, Object> tempCache = (HashMap<ICElement, Object>)this.temporaryCache.get();
Map<ICElement, CElementInfo> tempCache = this.temporaryCache.get();
if (tempCache != null) {
Object result = tempCache.get(element);
if (result != null)
@ -1120,7 +1122,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
* disturbing the cache ordering.
*/
protected synchronized Object peekAtInfo(ICElement element) {
HashMap<ICElement, Object> tempCache = (HashMap<ICElement, Object>)this.temporaryCache.get();
Map<ICElement, CElementInfo> tempCache = this.temporaryCache.get();
if (tempCache != null) {
Object result = tempCache.get(element);
if (result != null) {
@ -1137,7 +1139,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
* added to the cache. If it is the case, another thread has opened the element (or one of
* its ancestors). So returns without updating the cache.
*/
protected synchronized void putInfos(ICElement openedElement, Map<ICElement, Object> newElements) {
protected synchronized void putInfos(ICElement openedElement, Map<ICElement, CElementInfo> newElements) {
// remove children
Object existingInfo = this.cache.peekAtInfo(openedElement);
if (openedElement instanceof IParent && existingInfo instanceof CElementInfo) {
@ -1187,10 +1189,10 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
* Returns the temporary cache for newly opened elements for the current thread.
* Creates it if not already created.
*/
public HashMap<ICElement, Object> getTemporaryCache() {
HashMap<ICElement, Object> result = (HashMap<ICElement, Object>)this.temporaryCache.get();
public Map<ICElement, CElementInfo> getTemporaryCache() {
Map<ICElement, CElementInfo> result = this.temporaryCache.get();
if (result == null) {
result = new HashMap<ICElement, Object>();
result = new HashMap<ICElement, CElementInfo>();
this.temporaryCache.set(result);
}
return result;
@ -1229,16 +1231,16 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
// Do any shutdown of services.
ResourcesPlugin.getWorkspace().removeResourceChangeListener(factory);
BinaryRunner[] runners = (BinaryRunner[])binaryRunners.values().toArray(new BinaryRunner[0]);
for (int i = 0; i < runners.length; i++) {
runners[i].stop();
BinaryRunner[] runners = binaryRunners.values().toArray(new BinaryRunner[0]);
for (BinaryRunner runner : runners) {
runner.stop();
}
}
private void checkForProjectRename(IResourceDelta delta) {
IResourceDelta[] rem= delta.getAffectedChildren(IResourceDelta.REMOVED);
for (int i = 0; i < rem.length; i++) {
delta = rem[i];
for (IResourceDelta element : rem) {
delta = element;
IResource res= delta.getResource();
if (res.getType() == IResource.PROJECT) {
IPath movedTo= null;

View file

@ -106,7 +106,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
/*
* A per thread stack of java model operations (PerThreadObject of ArrayList).
*/
protected static ThreadLocal operationStacks = new ThreadLocal();
protected static ThreadLocal<ArrayList<CModelOperation>> operationStacks = new ThreadLocal<ArrayList<CModelOperation>>();
protected CModelOperation() {
}
@ -178,12 +178,12 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
* Registers the given reconcile delta with the C Model Manager.
*/
protected void addReconcileDelta(IWorkingCopy workingCopy, ICElementDelta delta) {
HashMap reconcileDeltas = CModelManager.getDefault().reconcileDeltas;
HashMap<IWorkingCopy, ICElementDelta> reconcileDeltas = CModelManager.getDefault().reconcileDeltas;
CElementDelta previousDelta = (CElementDelta)reconcileDeltas.get(workingCopy);
if (previousDelta != null) {
ICElementDelta[] children = delta.getAffectedChildren();
for (int i = 0, length = children.length; i < length; i++) {
CElementDelta child = (CElementDelta)children[i];
for (ICElementDelta element : children) {
CElementDelta child = (CElementDelta)element;
previousDelta.insertDeltaTree(child.getElement(), child);
}
} else {
@ -229,8 +229,8 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
if (fElementsToProcess == null || fElementsToProcess.length == 0) {
return new CModelStatus(ICModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
}
for (int i = 0; i < fElementsToProcess.length; i++) {
if (fElementsToProcess[i] == null) {
for (ICElement elementsToProces : fElementsToProcess) {
if (elementsToProces == null) {
return new CModelStatus(ICModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
}
}
@ -359,8 +359,8 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
}
//accumulate the nested operation deltas
if (operation.fDeltas != null) {
for (int i = 0; i < operation.fDeltas.length; i++) {
addDelta(operation.fDeltas[i]);
for (ICElementDelta delta : operation.fDeltas) {
addDelta(delta);
}
}
} catch (CoreException ce) {
@ -538,8 +538,8 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
// hook to ensure working copies remain consistent
//makeWorkingCopiesConsistent(fDeltas);
CModelManager manager= CModelManager.getDefault();
for (int i= 0; i < fDeltas.length; i++) {
manager.registerCModelDelta(fDeltas[i]);
for (ICElementDelta delta : fDeltas) {
manager.registerCModelDelta(delta);
}
}
}
@ -548,10 +548,10 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
* Returns the stack of operations running in the current thread.
* Returns an empty stack if no operations are currently running in this thread.
*/
protected ArrayList getCurrentOperationStack() {
ArrayList stack = (ArrayList)operationStacks.get();
protected ArrayList<CModelOperation> getCurrentOperationStack() {
ArrayList<CModelOperation> stack = operationStacks.get();
if (stack == null) {
stack = new ArrayList();
stack = new ArrayList<CModelOperation>();
operationStacks.set(stack);
}
return stack;
@ -562,13 +562,13 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
* Returns the poped operation or null if the stack was empty.
*/
protected CModelOperation popOperation() {
ArrayList stack = getCurrentOperationStack();
ArrayList<CModelOperation> stack = getCurrentOperationStack();
int size = stack.size();
if (size > 0) {
if (size == 1) { // top level operation
operationStacks.set(null); // release reference (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=33927)
}
return (CModelOperation)stack.remove(size-1);
return stack.remove(size-1);
} else {
return null;
}
@ -585,7 +585,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
* Returns whether this operation is the first operation to run in the current thread.
*/
protected boolean isTopLevelOperation() {
ArrayList stack;
ArrayList<CModelOperation> stack;
return
(stack = this.getCurrentOperationStack()).size() > 0
&& stack.get(0) == this;
@ -663,7 +663,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
/**
* Sets whether this operation is nested or not.
* @see CreateElementInCUOperation#checkCanceled
* @see CreateElementInTUOperation#checkCanceled
*/
protected void setNested(boolean nested) {
fNested = nested;

View file

@ -303,9 +303,6 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
return exception.toString();
}
/**
* @see IOperationStatus
*/
public IPath getPath() {
if (fPath == null) {
return Path.EMPTY;
@ -321,8 +318,8 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
if (fChildren == fgEmptyChildren)
return super.getSeverity();
int severity = -1;
for (int i = 0, max = fChildren.length; i < max; i++) {
int childrenSeverity = fChildren[i].getSeverity();
for (IStatus element : fChildren) {
int childrenSeverity = element.getSeverity();
if (childrenSeverity > severity) {
severity = childrenSeverity;
}
@ -378,8 +375,8 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
if (!isMultiStatus()) {
return matches(this, mask);
}
for (int i = 0, max = fChildren.length; i < max; i++) {
if (matches((CModelStatus)fChildren[i], mask))
for (IStatus element : fChildren) {
if (matches((CModelStatus)element, mask))
return true;
}
return false;
@ -399,7 +396,7 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
* Creates and returns a new <code>ICModelStatus</code> that is a a
* multi-status status.
*
* @see IStatus#.isMultiStatus()
* @see IStatus#isMultiStatus()
*/
public static ICModelStatus newMultiStatus(ICModelStatus[] children) {
CModelStatus jms = new CModelStatus();
@ -410,8 +407,6 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
/**
* Creates and returns a new <code>ICModelStatus</code> that is a a
* multi-status status.
*
* @see IStatus#.isMultiStatus()
*/
public static ICModelStatus newMultiStatus(int code, ICModelStatus[] children) {
CModelStatus jms = new CModelStatus(code);

View file

@ -165,9 +165,9 @@ public class CProject extends Openable implements ICProject {
if (incRefs == null) {
IPathEntry[] entries = getResolvedPathEntries();
ArrayList<IncludeReference> list = new ArrayList<IncludeReference>(entries.length);
for (int i = 0; i < entries.length; i++) {
if (entries[i].getEntryKind() == IPathEntry.CDT_INCLUDE) {
IIncludeEntry entry = (IIncludeEntry) entries[i];
for (IPathEntry entrie : entries) {
if (entrie.getEntryKind() == IPathEntry.CDT_INCLUDE) {
IIncludeEntry entry = (IIncludeEntry) entrie;
list.add(new IncludeReference(this, entry));
}
}
@ -190,9 +190,9 @@ public class CProject extends Openable implements ICProject {
BinaryParserConfig[] binConfigs = CModelManager.getDefault().getBinaryParser(getProject());
IPathEntry[] entries = getResolvedPathEntries();
ArrayList<ILibraryReference> list = new ArrayList<ILibraryReference>(entries.length);
for (int i = 0; i < entries.length; i++) {
if (entries[i].getEntryKind() == IPathEntry.CDT_LIBRARY) {
ILibraryEntry entry = (ILibraryEntry) entries[i];
for (IPathEntry entrie : entries) {
if (entrie.getEntryKind() == IPathEntry.CDT_LIBRARY) {
ILibraryEntry entry = (ILibraryEntry) entrie;
ILibraryReference lib = getLibraryReference(this, binConfigs, entry);
if (lib != null) {
list.add(lib);
@ -213,10 +213,10 @@ public class CProject extends Openable implements ICProject {
}
ILibraryReference lib = null;
if (binConfigs != null) {
for (int i = 0; i < binConfigs.length; i++) {
for (BinaryParserConfig binConfig : binConfigs) {
IBinaryFile bin;
try {
IBinaryParser parser = binConfigs[i].getBinaryParser();
IBinaryParser parser = binConfig.getBinaryParser();
bin = parser.getBinary(entry.getFullLibraryPath());
if (bin != null) {
if (bin.getType() == IBinaryFile.ARCHIVE) {
@ -281,8 +281,7 @@ public class CProject extends Openable implements ICProject {
// create project options
try {
String[] propertyNames= preferences.keys();
for (int i= 0; i < propertyNames.length; i++){
String propertyName= propertyNames[i];
for (String propertyName : propertyNames) {
String value= preferences.get(propertyName, null);
if (value != null && optionNames.contains(propertyName)){
options.put(propertyName, value.trim());
@ -450,9 +449,9 @@ public class CProject extends Openable implements ICProject {
public ISourceRoot findSourceRoot(IResource res) {
try {
ISourceRoot[] roots = getAllSourceRoots();
for (int i = 0; i < roots.length; i++) {
if (roots[i].isOnSourceEntry(res)) {
return roots[i];
for (ISourceRoot root : roots) {
if (root.isOnSourceEntry(res)) {
return root;
}
}
} catch (CModelException e) {
@ -466,9 +465,9 @@ public class CProject extends Openable implements ICProject {
public ISourceRoot findSourceRoot(IPath path) {
try {
ISourceRoot[] roots = getAllSourceRoots();
for (int i = 0; i < roots.length; i++) {
if (roots[i].getPath().equals(path)) {
return roots[i];
for (ISourceRoot root : roots) {
if (root.getPath().equals(path)) {
return root;
}
}
} catch (CModelException e) {
@ -482,9 +481,9 @@ public class CProject extends Openable implements ICProject {
public ISourceRoot[] getSourceRoots() throws CModelException {
Object[] children = getChildren();
ArrayList<ISourceRoot> result = new ArrayList<ISourceRoot>(children.length);
for (int i = 0; i < children.length; i++) {
if (children[i] instanceof ISourceRoot) {
result.add((ISourceRoot) children[i]);
for (Object element : children) {
if (element instanceof ISourceRoot) {
result.add((ISourceRoot) element);
}
}
return result.toArray(new ISourceRoot[result.size()]);
@ -535,9 +534,9 @@ public class CProject extends Openable implements ICProject {
*/
public IOutputEntry[] getOutputEntries(IPathEntry[] entries) throws CModelException {
ArrayList<IPathEntry> list = new ArrayList<IPathEntry>(entries.length);
for (int i = 0; i < entries.length; i++) {
if (entries[i].getEntryKind() == IPathEntry .CDT_OUTPUT) {
list.add(entries[i]);
for (IPathEntry entrie : entries) {
if (entrie.getEntryKind() == IPathEntry .CDT_OUTPUT) {
list.add(entrie);
}
}
IOutputEntry[] outputs = new IOutputEntry[list.size()];
@ -558,8 +557,8 @@ public class CProject extends Openable implements ICProject {
try {
IOutputEntry[] entries = getOutputEntries();
for (int i = 0; i < entries.length; i++) {
boolean on = isOnOutputEntry(entries[i], path);
for (IOutputEntry entrie : entries) {
boolean on = isOnOutputEntry(entrie, path);
if (on) {
return on;
}
@ -582,7 +581,7 @@ public class CProject extends Openable implements ICProject {
*/
@Override
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm,
Map newElements, IResource underlyingResource)
Map<ICElement, CElementInfo> newElements, IResource underlyingResource)
throws CModelException {
boolean validInfo = false;
try {
@ -612,9 +611,8 @@ public class CProject extends Openable implements ICProject {
if(entries != null){
ArrayList<ISourceRoot> list = new ArrayList<ISourceRoot>(entries.length);
for (int i = 0; i < entries.length; i++) {
ICSourceEntry sourceEntry = entries[i];
ISourceRoot root = getSourceRoot(sourceEntry);
for (ICSourceEntry sourceEntry : entries) {
ISourceRoot root = getSourceRoot(sourceEntry);
if (root != null) {
list.add(root);
}
@ -630,8 +628,8 @@ public class CProject extends Openable implements ICProject {
children.addAll(sourceRoots);
boolean projectIsSourceRoot = false;
for (Iterator<ISourceRoot> i = sourceRoots.iterator(); i.hasNext();)
if (i.next().getResource().equals(getProject())) {
for (ISourceRoot sourceRoot : sourceRoots)
if (sourceRoot.getResource().equals(getProject())) {
projectIsSourceRoot = true;
break;
}
@ -639,12 +637,10 @@ public class CProject extends Openable implements ICProject {
// Now look for output folders
try {
IResource[] resources = getProject().members();
for (int i = 0; i < resources.length; i++) {
IResource child = resources[i];
for (IResource child : resources) {
if (child.getType() == IResource.FOLDER) {
boolean found = false;
for (Iterator<ISourceRoot> iter = sourceRoots.iterator(); iter.hasNext();) {
ISourceRoot sourceRoot = iter.next();
for (ISourceRoot sourceRoot : sourceRoots) {
if (sourceRoot.isOnSourceEntry(child)) {
found = true;
break;
@ -677,8 +673,8 @@ public class CProject extends Openable implements ICProject {
public boolean isOnSourceRoot(ICElement element) {
try {
ISourceRoot[] roots = getSourceRoots();
for (int i = 0; i < roots.length; i++) {
if (roots[i].isOnSourceEntry(element)) {
for (ISourceRoot root : roots) {
if (root.isOnSourceEntry(element)) {
return true;
}
}
@ -694,8 +690,8 @@ public class CProject extends Openable implements ICProject {
public boolean isOnSourceRoot(IResource resource) {
try {
ISourceRoot[] roots = getSourceRoots();
for (int i = 0; i < roots.length; i++) {
if (roots[i].isOnSourceEntry(resource)) {
for (ISourceRoot root : roots) {
if (root.isOnSourceEntry(resource)) {
return true;
}
}

View file

@ -65,14 +65,11 @@ class CProjectInfo extends OpenableInfo {
return vLib;
}
/**
* @return
*/
public Object[] getNonCResources(IResource res) {
if (nonCResources != null)
return nonCResources;
List notChildren = new ArrayList();
List<IResource> notChildren = new ArrayList<IResource>();
try {
if (res instanceof IContainer) {
ICProject cproject = getElement().getCProject();
@ -128,10 +125,6 @@ class CProjectInfo extends OpenableInfo {
return nonCResources;
}
/**
* @param container
* @return
*/
public void setNonCResources(Object[] resources) {
nonCResources = resources;
}
@ -141,18 +134,18 @@ class CProjectInfo extends OpenableInfo {
*/
public void resetCaches() {
if (libReferences != null) {
for (int i = 0; i < libReferences.length; i++) {
for (ILibraryReference libReference : libReferences) {
try {
((CElement)libReferences[i]).close();
((CElement)libReference).close();
} catch (CModelException e) {
//
}
}
}
if (incReferences != null) {
for (int i = 0; i < incReferences.length; i++) {
for (IIncludeReference incReference : incReferences) {
try {
((CElement)incReferences[i]).close();
((CElement)incReference).close();
} catch (CModelException e) {
//
}

View file

@ -147,14 +147,12 @@ public class CommitWorkingCopyOperation extends CModelOperation {
worked(1);
if (deltaBuilder != null) {
// build the deltas
deltaBuilder.buildDeltas();
// build the deltas
deltaBuilder.buildDeltas();
// add the deltas to the list of deltas created during this operation
if (deltaBuilder.delta != null) {
addDelta(deltaBuilder.delta);
}
// add the deltas to the list of deltas created during this operation
if (deltaBuilder.delta != null) {
addDelta(deltaBuilder.delta);
}
worked(1);
} finally {

View file

@ -328,11 +328,11 @@ public class ContentTypeProcessor extends CModelOperation {
}
}
// Assume a workspace resolver
List list = new ArrayList(cprojects.length);
List<ICProject> list = new ArrayList<ICProject>(cprojects.length);
for (int i = 0; i < cprojects.length; ++i) {
list.add(cprojects[i]);
}
return (ICProject[]) list.toArray(new ICProject[list.size()]);
return list.toArray(new ICProject[list.size()]);
} catch (CModelException e) {
//
}

View file

@ -170,7 +170,7 @@ public class CopyElementsOperation extends MultiOperation {
if (isInTUOperation) {
CreateElementInTUOperation inTUop = (CreateElementInTUOperation)op;
ICElement sibling = (ICElement) fInsertBeforeElements.get(element);
ICElement sibling = fInsertBeforeElements.get(element);
if (sibling != null) {
(inTUop).setRelativePosition(sibling, CreateElementInTUOperation.INSERT_BEFORE);
} else if (isRename()) {
@ -200,8 +200,7 @@ public class CopyElementsOperation extends MultiOperation {
private ICElement resolveRenameAnchor(ICElement element) throws CModelException {
IParent parent = (IParent) element.getParent();
ICElement[] children = parent.getChildren();
for (int i = 0; i < children.length; i++) {
ICElement child = children[i];
for (ICElement child : children) {
if (child.equals(element)) {
return child;
}
@ -256,18 +255,19 @@ public class CopyElementsOperation extends MultiOperation {
protected void verify(ICElement element) throws CModelException {
if (element == null || !element.exists())
error(ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST, element);
else {
if (element.getElementType() < ICElement.C_UNIT)
error(ICModelStatusConstants.INVALID_ELEMENT_TYPES, element);
if (element.getElementType() < ICElement.C_UNIT)
error(ICModelStatusConstants.INVALID_ELEMENT_TYPES, element);
if (element.isReadOnly())
error(ICModelStatusConstants.READ_ONLY, element);
if (element.isReadOnly())
error(ICModelStatusConstants.READ_ONLY, element);
ICElement dest = getDestinationParent(element);
verifyDestination(element, dest);
verifySibling(element, dest);
if (fRenamingsList != null) {
verifyRenaming(element);
ICElement dest = getDestinationParent(element);
verifyDestination(element, dest);
verifySibling(element, dest);
if (fRenamingsList != null) {
verifyRenaming(element);
}
}
}
}

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.CConventions;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.IBuffer;
import org.eclipse.cdt.core.model.ICElement;
@ -21,7 +22,7 @@ import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.core.model.ITranslationUnit;
/**
* <p>This abstract class implements behavior common to <code>CreateElementInCUOperations</code>.
* <p>This abstract class implements behavior common to <code>CreateElementInTUOperations</code>.
* To create a compilation unit, or an element contained in a compilation unit, the
* source code for the entire compilation unit is updated and saved.
*
@ -174,8 +175,8 @@ public abstract class CreateElementInTUOperation extends CModelOperation {
fResultElements = generateResultHandles();
if (!isWorkingCopy) { // if unit is working copy, then save will have already fired the delta
if (unit.getParent().exists()) {
for (int i = 0; i < fResultElements.length; i++) {
delta.added(fResultElements[i]);
for (ICElement resultElement : fResultElements) {
delta.added(resultElement);
}
addDelta(delta);
} // else unit is created outside classpath
@ -211,7 +212,7 @@ public abstract class CreateElementInTUOperation extends CModelOperation {
/**
* Returns the amount of work for the main task of this operation for
* progress reporting.
* @see executeOperation()
* @see #executeOperation()
*/
protected int getMainAmountOfWork(){
return 2;
@ -220,7 +221,7 @@ public abstract class CreateElementInTUOperation extends CModelOperation {
/**
* Returns the name of the main task of this operation for
* progress reporting.
* @see executeOperation()
* @see #executeOperation()
*/
protected abstract String getMainTaskName();
@ -246,8 +247,8 @@ public abstract class CreateElementInTUOperation extends CModelOperation {
* Inserts the given child into the given JDOM,
* based on the position settings of this operation.
*
* @see createAfter(IJavaElement)
* @see createBefore(IJavaElement);
* @see #createAfter(ICElement)
* @see #createBefore(ICElement)
*/
protected void insertElement() throws CModelException {
if (fInsertionPolicy != INSERT_LAST) {
@ -307,7 +308,7 @@ public abstract class CreateElementInTUOperation extends CModelOperation {
* <li>INVALID_SIBLING - the sibling provided for positioning is not valid.
* </ul>
* @see ICModelStatus
* @see CNamingConventions
* @see CConventions
*/
@Override
public ICModelStatus verify() {

View file

@ -13,8 +13,8 @@ package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.core.model.ICModelStatus;
import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.core.model.ITranslationUnit;
/**
* <p>This operation creates a field declaration in a type.
@ -45,7 +45,7 @@ public class CreateFieldOperation extends CreateMemberOperation {
}
/**
* @see CreateElementInCUOperation#getMainTaskName
* @see CreateElementInTUOperation#getMainTaskName
*/
@Override
public String getMainTaskName(){
@ -75,7 +75,7 @@ public class CreateFieldOperation extends CreateMemberOperation {
}
/**
* @see CreateElementInCUOperation#generateResultHandle
* @see CreateElementInTUOperation#generateResultHandle
*/
@Override
protected ICElement generateResultHandle() {
@ -83,7 +83,7 @@ public class CreateFieldOperation extends CreateMemberOperation {
}
/**
* @see CreateTypeMemberOperation#verifyNameCollision
* @see CreateMemberOperation#verifyNameCollision
*/
@Override
protected ICModelStatus verifyNameCollision() {

View file

@ -13,12 +13,12 @@ package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.CConventions;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICModelStatus;
import org.eclipse.cdt.core.model.ICModelStatusConstants;
import org.eclipse.cdt.core.model.IInclude;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.ICModelStatus;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IStatus;
@ -56,7 +56,7 @@ public class CreateIncludeOperation extends CreateElementInTUOperation {
}
/**
* @see CreateElementInCUOperation#generateResultHandle
* @see CreateElementInTUOperation#generateResultHandle
*/
@Override
protected ICElement generateResultHandle() {
@ -64,7 +64,7 @@ public class CreateIncludeOperation extends CreateElementInTUOperation {
}
/**
* @see CreateElementInCUOperation#getMainTaskName
* @see CreateElementInTUOperation#getMainTaskName
*/
@Override
public String getMainTaskName(){
@ -97,7 +97,7 @@ public class CreateIncludeOperation extends CreateElementInTUOperation {
* <li>INVALID_NAME - not a valid include declaration name.
* </ul>
* @see ICModelStatus
* @see CNamingConventions
* @see CConventions
*/
@Override
public ICModelStatus verify() {

View file

@ -13,9 +13,9 @@ package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICModelStatus;
import org.eclipse.cdt.core.model.ICModelStatusConstants;
import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.core.model.ICModelStatus;
import org.eclipse.cdt.core.model.ITranslationUnit;
/**
@ -50,7 +50,7 @@ public class CreateMethodOperation extends CreateMemberOperation {
}
/**
* @see CreateElementInCUOperation#generateResultHandle
* @see CreateElementInTUOperation#generateResultHandle
*/
@Override
protected ICElement generateResultHandle() {
@ -59,7 +59,7 @@ public class CreateMethodOperation extends CreateMemberOperation {
}
/**
* @see CreateElementInCUOperation#getMainTaskName
* @see CreateElementInTUOperation#getMainTaskName
*/
@Override
public String getMainTaskName(){
@ -67,7 +67,7 @@ public class CreateMethodOperation extends CreateMemberOperation {
}
/**
* @see CreateTypeMemberOperation#verifyNameCollision
* @see CreateMemberOperation#verifyNameCollision
*/
@Override
protected ICModelStatus verifyNameCollision() {

View file

@ -39,7 +39,7 @@ public class CreateNamespaceOperation extends CreateElementInTUOperation {
}
/**
* @see CreateElementInCUOperation#generateResultHandle
* @see CreateElementInTUOperation#generateResultHandle
*/
@Override
protected ICElement generateResultHandle() {
@ -47,7 +47,7 @@ public class CreateNamespaceOperation extends CreateElementInTUOperation {
}
/**
* @see CreateElementInCUOperation#getMainTaskName
* @see CreateElementInTUOperation#getMainTaskName
*/
@Override
public String getMainTaskName(){

View file

@ -46,7 +46,7 @@ public class CreateUsingOperation extends CreateElementInTUOperation {
}
/**
* @see CreateElementInCUOperation#generateResultHandle
* @see CreateElementInTUOperation#generateResultHandle
*/
@Override
protected ICElement generateResultHandle() {
@ -54,7 +54,7 @@ public class CreateUsingOperation extends CreateElementInTUOperation {
}
/**
* @see CreateElementInCUOperation#getMainTaskName
* @see CreateElementInTUOperation#getMainTaskName
*/
@Override
public String getMainTaskName(){

View file

@ -25,7 +25,7 @@ import org.eclipse.core.resources.IFile;
*/
public class CreateWorkingCopyOperation extends CModelOperation {
Map perFactoryWorkingCopies;
Map<ITranslationUnit, WorkingCopy> perFactoryWorkingCopies;
IBufferFactory factory;
IProblemRequestor problemRequestor;
@ -33,7 +33,7 @@ public class CreateWorkingCopyOperation extends CModelOperation {
* Creates a working copy from the given original tu and the given buffer factory.
* perFactoryWorkingCopies map is not null if the working copy is a shared working copy.
*/
public CreateWorkingCopyOperation(ITranslationUnit originalElement, Map perFactoryWorkingCopies, IBufferFactory factory, IProblemRequestor problemRequestor) {
public CreateWorkingCopyOperation(ITranslationUnit originalElement, Map<ITranslationUnit, WorkingCopy> perFactoryWorkingCopies, IBufferFactory factory, IProblemRequestor problemRequestor) {
super(new ICElement[] {originalElement});
this.perFactoryWorkingCopies = perFactoryWorkingCopies;
this.factory = factory;
@ -78,7 +78,7 @@ public class CreateWorkingCopyOperation extends CModelOperation {
}
/**
* @see JavaModelOperation#isReadOnly
* @see CModelOperation#isReadOnly
*/
@Override
public boolean isReadOnly() {

View file

@ -71,7 +71,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
static final IPathEntry[] NO_PATHENTRIES = new IPathEntry[0];
List listeners;
List<IPathEntryStoreListener> listeners;
IProject fProject;
/**
@ -79,7 +79,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
*/
public DefaultPathEntryStore(IProject project) {
fProject = project;
listeners = Collections.synchronizedList(new ArrayList());
listeners = Collections.synchronizedList(new ArrayList<IPathEntryStoreListener>());
// Register the Core Model on the Descriptor
// Manager, it needs to know about changes.
CCorePlugin.getDefault().getCDescriptorManager().addDescriptorListener(this);
@ -88,7 +88,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
public IPathEntry[] getRawPathEntries() throws CoreException {
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(fProject, false);
if (cdesc != null) {
ArrayList pathEntries = new ArrayList();
ArrayList<IPathEntry> pathEntries = new ArrayList<IPathEntry>();
Element element = cdesc.getProjectData(PATH_ENTRY_ID);
NodeList list = element.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
@ -185,7 +185,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
IPath sourceAttachmentPrefixMapping = element.hasAttribute(ATTRIBUTE_PREFIXMAPPING) ? new Path(
element.getAttribute(ATTRIBUTE_PREFIXMAPPING)) : null;
if (baseRef != null && !baseRef.isEmpty()) {
if (!baseRef.isEmpty()) {
return CoreModel.newLibraryRefEntry(path, baseRef, libraryPath);
}
return CoreModel.newLibraryEntry(path, basePath, libraryPath, sourceAttachmentPath, sourceAttachmentRootPath,
@ -212,7 +212,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
if (element.hasAttribute(ATTRIBUTE_SYSTEM)) {
isSystemInclude = element.getAttribute(ATTRIBUTE_SYSTEM).equals(VALUE_TRUE);
}
if (baseRef != null && !baseRef.isEmpty()) {
if (!baseRef.isEmpty()) {
return CoreModel.newIncludeRefEntry(path, baseRef, includePath);
}
return CoreModel.newIncludeEntry(path, basePath, includePath, isSystemInclude, exclusionPatterns, isExported);
@ -225,7 +225,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
case IPathEntry.CDT_MACRO : {
String macroName = element.getAttribute(ATTRIBUTE_NAME);
String macroValue = element.getAttribute(ATTRIBUTE_VALUE);
if (baseRef != null && !baseRef.isEmpty()) {
if (!baseRef.isEmpty()) {
return CoreModel.newMacroRefEntry(path, baseRef, macroName);
}
return CoreModel.newMacroEntry(path, macroName, macroValue, exclusionPatterns, isExported);
@ -247,16 +247,16 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
static void encodePathEntries(IPath projectPath, Document doc, Element configRootElement, IPathEntry[] entries) {
Element element;
for (int i = 0; i < entries.length; i++) {
for (IPathEntry entrie : entries) {
element = doc.createElement(PATH_ENTRY);
configRootElement.appendChild(element);
int kind = entries[i].getEntryKind();
int kind = entrie.getEntryKind();
// Set the kind
element.setAttribute(ATTRIBUTE_KIND, PathEntry.kindToString(kind));
// translate the project prefix.
IPath xmlPath = entries[i].getPath();
IPath xmlPath = entrie.getPath();
if (xmlPath == null) {
xmlPath = new Path(""); //$NON-NLS-1$
}
@ -285,7 +285,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
case IPathEntry.CDT_CONTAINER:
break;
case IPathEntry.CDT_LIBRARY: {
ILibraryEntry lib = (ILibraryEntry) entries[i];
ILibraryEntry lib = (ILibraryEntry) entrie;
IPath libraryPath = lib.getLibraryPath();
element.setAttribute(ATTRIBUTE_LIBRARY, libraryPath.toString());
IPath sourcePath = lib.getSourceAttachmentPath();
@ -308,7 +308,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
break;
}
case IPathEntry.CDT_INCLUDE: {
IIncludeEntry include = (IIncludeEntry) entries[i];
IIncludeEntry include = (IIncludeEntry) entrie;
IPath includePath = include.getIncludePath();
element.setAttribute(ATTRIBUTE_INCLUDE, includePath.toString());
if (include.isSystemInclude()) {
@ -317,26 +317,26 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
break;
}
case IPathEntry.CDT_INCLUDE_FILE: {
IIncludeFileEntry include = (IIncludeFileEntry) entries[i];
IIncludeFileEntry include = (IIncludeFileEntry) entrie;
IPath includeFilePath = include.getIncludeFilePath();
element.setAttribute(ATTRIBUTE_INCLUDE_FILE, includeFilePath.toString());
break;
}
case IPathEntry.CDT_MACRO: {
IMacroEntry macro = (IMacroEntry) entries[i];
IMacroEntry macro = (IMacroEntry) entrie;
element.setAttribute(ATTRIBUTE_NAME, macro.getMacroName());
element.setAttribute(ATTRIBUTE_VALUE, macro.getMacroValue());
break;
}
case IPathEntry.CDT_MACRO_FILE: {
IMacroFileEntry macro = (IMacroFileEntry) entries[i];
IMacroFileEntry macro = (IMacroFileEntry) entrie;
element.setAttribute(ATTRIBUTE_MACRO_FILE, macro.getMacroFilePath().toString());
break;
}
}
if (entries[i] instanceof APathEntry) {
APathEntry entry = (APathEntry) entries[i];
if (entrie instanceof APathEntry) {
APathEntry entry = (APathEntry) entrie;
// save the basePath or the baseRef
IPath basePath = entry.getBasePath();
@ -362,7 +362,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
}
// Save the export attribute
if (entries[i].isExported()) {
if (entrie.isExported()) {
element.setAttribute(ATTRIBUTE_EXPORTED, VALUE_TRUE);
}
}
@ -402,8 +402,8 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, project, PathEntryStoreChangedEvent.CONTENT_CHANGED);
IPathEntryStoreListener[] observers = new IPathEntryStoreListener[listeners.size()];
listeners.toArray(observers);
for (int i = 0; i < observers.length; i++) {
observers[i].pathEntryStoreChanged(evt);
for (IPathEntryStoreListener observer : observers) {
observer.pathEntryStoreChanged(evt);
}
}
@ -414,8 +414,8 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, fProject, PathEntryStoreChangedEvent.STORE_CLOSED);
IPathEntryStoreListener[] observers = new IPathEntryStoreListener[listeners.size()];
listeners.toArray(observers);
for (int i = 0; i < observers.length; i++) {
observers[i].pathEntryStoreChanged(evt);
for (IPathEntryStoreListener observer : observers) {
observer.pathEntryStoreChanged(evt);
}
CCorePlugin.getDefault().getCDescriptorManager().removeDescriptorListener(this);
}

View file

@ -32,11 +32,11 @@ import org.eclipse.cdt.internal.core.CharOperation;
public class DeleteElementsOperation extends MultiOperation {
/**
* The elements this operation processes grouped by compilation unit
* @see processElements(). Keys are compilation units,
* @see #processElements() Keys are compilation units,
* values are <code>IRegion</code>s of elements to be processed in each
* compilation unit.
*/
protected Map fChildrenToRemove;
protected Map<ITranslationUnit, IRegion> fChildrenToRemove;
/**
* When executed, this operation will delete the given elements. The elements
@ -62,15 +62,14 @@ public class DeleteElementsOperation extends MultiOperation {
* duplicates specified in elements to be processed.
*/
protected void groupElements() throws CModelException {
fChildrenToRemove = new HashMap(1);
fChildrenToRemove = new HashMap<ITranslationUnit, IRegion>(1);
int uniqueTUs = 0;
for (int i = 0, length = fElementsToProcess.length; i < length; i++) {
ICElement e = fElementsToProcess[i];
for (ICElement e : fElementsToProcess) {
ITranslationUnit tu = getTranslationUnitFor(e);
if (tu == null) {
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, e));
}
IRegion region = (IRegion) fChildrenToRemove.get(tu);
IRegion region = fChildrenToRemove.get(tu);
if (region == null) {
region = new Region();
fChildrenToRemove.put(tu, region);
@ -79,10 +78,10 @@ public class DeleteElementsOperation extends MultiOperation {
region.add(e);
}
fElementsToProcess = new ICElement[uniqueTUs];
Iterator iter = fChildrenToRemove.keySet().iterator();
Iterator<ITranslationUnit> iter = fChildrenToRemove.keySet().iterator();
int i = 0;
while (iter.hasNext()) {
fElementsToProcess[i++] = (ICElement) iter.next();
fElementsToProcess[i++] = iter.next();
}
}
/**
@ -96,9 +95,8 @@ public class DeleteElementsOperation extends MultiOperation {
IBuffer buffer = tu.getBuffer();
if (buffer == null) return;
CElementDelta delta = new CElementDelta(tu);
ICElement[] cuElements = ((IRegion) fChildrenToRemove.get(tu)).getElements();
for (int i = 0, length = cuElements.length; i < length; i++) {
ICElement e = cuElements[i];
ICElement[] cuElements = fChildrenToRemove.get(tu).getElements();
for (ICElement e : cuElements) {
if (e.exists()) {
char[] contents = buffer.getCharacters();
if (contents == null) continue;
@ -165,9 +163,8 @@ public class DeleteElementsOperation extends MultiOperation {
*/
@Override
protected void verify(ICElement element) throws CModelException {
ICElement[] children = ((IRegion) fChildrenToRemove.get(element)).getElements();
for (int i = 0; i < children.length; i++) {
ICElement child = children[i];
ICElement[] children = fChildrenToRemove.get(element).getElements();
for (ICElement child : children) {
if (child.getResource() != null)
error(ICModelStatusConstants.INVALID_ELEMENT_TYPES, child);
if (child.isReadOnly())

View file

@ -39,7 +39,7 @@ public class DeleteResourceElementsOperation extends MultiOperation {
}
/**
* @see MultiOperation. This method delegate to <code>deleteResource</code> or
* @see MultiOperation This method delegate to <code>deleteResource</code> or
* <code>deletePackageFragment</code> depending on the type of <code>element</code>.
*/
@Override

View file

@ -12,8 +12,9 @@ package org.eclipse.cdt.internal.core.model;
import java.util.Map;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ITranslationUnit;
/**
* Destroys a working copy (remove it from its cache if it is shared)
@ -47,9 +48,9 @@ public class DestroyWorkingCopyOperation extends CModelOperation {
// In order to be shared, working copies have to denote the same compilation unit
// AND use the same buffer factory.
// Assuming there is a little set of buffer factories, then use a 2 level Map cache.
Map sharedWorkingCopies = manager.sharedWorkingCopies;
Map<IBufferFactory, Map<ITranslationUnit, WorkingCopy>> sharedWorkingCopies = manager.sharedWorkingCopies;
Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(workingCopy.bufferFactory);
Map<ITranslationUnit, WorkingCopy> perFactoryWorkingCopies = sharedWorkingCopies.get(workingCopy.bufferFactory);
if (perFactoryWorkingCopies != null) {
if (perFactoryWorkingCopies.remove(originalElement) != null) {
//System.out.println("Destroying shared working copy " + workingCopy.toStringWithAncestors());//$NON-NLS-1$

View file

@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.IOpenable;
import org.eclipse.cdt.internal.core.util.LRUCache;
import org.eclipse.cdt.internal.core.util.OverflowingLRUCache;
/**
@ -21,7 +20,7 @@ import org.eclipse.cdt.internal.core.util.OverflowingLRUCache;
*
* This class is similar to the JDT ElementCache class.
*/
public class ElementCache extends OverflowingLRUCache {
public class ElementCache<T> extends OverflowingLRUCache<IOpenable, T> {
/**
* Constructs a new element cache of the given size.
@ -43,8 +42,8 @@ public class ElementCache extends OverflowingLRUCache {
* by closing the element.
*/
@Override
protected boolean close(LRUCacheEntry entry) {
IOpenable element = (IOpenable) entry._fKey;
protected boolean close(LRUCacheEntry<IOpenable, T> entry) {
IOpenable element = entry._fKey;
try {
if (element.hasUnsavedChanges()) {
return false;
@ -56,10 +55,10 @@ public class ElementCache extends OverflowingLRUCache {
}
}
/**
* Returns a new instance of the reciever.
* Returns a new instance of the receiver.
*/
@Override
protected LRUCache newInstance(int size, int overflow) {
return new ElementCache(size, overflow);
protected OverflowingLRUCache<IOpenable, T> newInstance(int size, int overflow) {
return new ElementCache<T>(size, overflow);
}
}

View file

@ -27,7 +27,7 @@ public class Enumerator extends SourceManipulation implements IEnumerator{
}
/**
* @see org.eclipse.cdt.core.model.IEnumerator#getConstantExptrssion()
* @see org.eclipse.cdt.core.model.IEnumerator#getConstantExpression()
*/
public String getConstantExpression() {
return constantExpression;

View file

@ -22,10 +22,6 @@ import org.eclipse.cdt.core.model.ICElement;
*/
public class ExternalTranslationUnit extends TranslationUnit {
/**
* @param parent
* @param path
*/
public ExternalTranslationUnit(ICElement parent, URI uri, String contentTypeID) {
super(parent, uri, contentTypeID);
}

View file

@ -82,9 +82,6 @@ public class FieldInfo extends SourceManipulationInfo {
this.visibility = visibility;
}
/**
* @see org.eclipse.cdt.internal.core.model.SourceManipulationInfo#hasSameContentsAs(SourceManipulationInfo)
*/
@Override
public boolean hasSameContentsAs( SourceManipulationInfo info){

View file

@ -54,9 +54,6 @@ class FunctionInfo extends SourceManipulationInfo {
this.isVolatile = isVolatile;
}
/**
* @see org.eclipse.cdt.internal.core.model.SourceManipulationInfo#hasSameContentsAs(org.eclipse.cdt.internal.core.model.SourceManipulationInfo)
*/
@Override
public boolean hasSameContentsAs(SourceManipulationInfo otherInfo) {
return (super.hasSameContentsAs(otherInfo)

View file

@ -26,7 +26,7 @@ public class FunctionTemplate extends Function implements IFunctionTemplate {
/**
* Returns the parameterTypes.
* @see org.eclipse.cdt.core.model.ITemplate#getParameters()
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes()
* @return String[]
*/
public String[] getTemplateParameterTypes() {
@ -34,8 +34,7 @@ public class FunctionTemplate extends Function implements IFunctionTemplate {
}
/**
* Sets the fParameterTypes.
* @param fParameterTypes The fParameterTypes to set
* Sets the template parameter types.
*/
public void setTemplateParameterTypes(String[] templateParameterTypes) {
fTemplate.setTemplateParameterTypes(templateParameterTypes);

View file

@ -49,8 +49,7 @@ public class FunctionTemplateDeclaration extends FunctionDeclaration implements
}
/**
* Sets the fParameterTypes.
* @param fParameterTypes The fParameterTypes to set
* Sets the template parameter types.
*/
public void setTemplateParameterTypes(String[] templateParameterTypes) {
fTemplate.setTemplateParameterTypes(templateParameterTypes);

View file

@ -41,11 +41,6 @@ public class IncludeReference extends Openable implements IIncludeReference {
IIncludeEntry fIncludeEntry;
IPath fPath;
/**
* @param parent
* @param name
* @param type
*/
public IncludeReference(ICProject cproject, IIncludeEntry entry) {
this(cproject, entry, entry.getFullIncludePath());
}
@ -83,7 +78,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
* @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)
*/
@Override
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws CModelException {
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map<ICElement, CElementInfo> newElements, IResource underlyingResource) throws CModelException {
return computeChildren(info, underlyingResource);
}
@ -108,24 +103,24 @@ public class IncludeReference extends Openable implements IIncludeReference {
String[] names = null;
if (file != null && file.isDirectory()) {
names = file.list();
}
if (names != null) {
IPath path = new Path(file.getAbsolutePath());
for (int i = 0; i < names.length; i++) {
File child = new File(file, names[i]);
ICElement celement = null;
if (child.isDirectory()) {
celement = new IncludeReference(this, fIncludeEntry, new Path(child.getAbsolutePath()));
} else if (child.isFile()){
String id = CoreModel.getRegistedContentTypeId(getCProject().getProject(), names[i]);
if (id != null) {
// TODO: should use URI
celement = new ExternalTranslationUnit(this, URIUtil.toURI(path.append(names[i])), id);
if (names != null) {
IPath path = new Path(file.getAbsolutePath());
for (String name : names) {
File child = new File(file, name);
ICElement celement = null;
if (child.isDirectory()) {
celement = new IncludeReference(this, fIncludeEntry, new Path(child.getAbsolutePath()));
} else if (child.isFile()){
String id = CoreModel.getRegistedContentTypeId(getCProject().getProject(), name);
if (id != null) {
// TODO: should use URI
celement = new ExternalTranslationUnit(this, URIUtil.toURI(path.append(name)), id);
}
}
if (celement != null) {
vChildren.add(celement);
}
}
if (celement != null) {
vChildren.add(celement);
}
}
}

View file

@ -70,7 +70,7 @@ public class LibraryReference extends Parent implements ILibraryReference {
* @see org.eclipse.cdt.internal.core.model.CElement#generateInfos(java.lang.Object, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
protected void generateInfos(Object info, Map newElements, IProgressMonitor monitor) throws CModelException {
protected void generateInfos(CElementInfo info, Map<ICElement, CElementInfo> newElements, IProgressMonitor monitor) throws CModelException {
}
@Override

View file

@ -74,9 +74,6 @@ public class MethodInfo extends FunctionInfo {
this.visibility = visibility;
}
/**
* @see org.eclipse.cdt.internal.core.model.SourceManipulationInfo#hasSameContentsAs(org.eclipse.cdt.internal.core.model.SourceManipulationInfo)
*/
@Override
public boolean hasSameContentsAs(SourceManipulationInfo otherInfo) {
return (super.hasSameContentsAs(otherInfo)

View file

@ -26,7 +26,7 @@ public class MethodTemplate extends Method implements IMethodTemplate {
/**
* Returns the parameterTypes.
* @see org.eclipse.cdt.core.model.ITemplate#getParameters()
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes()
* @return String[]
*/
public String[] getTemplateParameterTypes() {
@ -35,7 +35,7 @@ public class MethodTemplate extends Method implements IMethodTemplate {
/**
* Sets the fParameterTypes.
* @param fParameterTypes The fParameterTypes to set
* @param templateParameterTypes The template parameter types to set
*/
public void setTemplateParameterTypes(String[] templateParameterTypes) {
fTemplate.setTemplateParameterTypes(templateParameterTypes);

View file

@ -51,7 +51,7 @@ public class MethodTemplateDeclaration extends MethodDeclaration implements IMet
/**
* Sets the fParameterTypes.
* @param fParameterTypes The fParameterTypes to set
* @param templateParameterTypes The template parameter types to set
*/
public void setTemplateParameterTypes(String[] templateParameterTypes) {
fTemplate.setTemplateParameterTypes(templateParameterTypes);

View file

@ -78,7 +78,7 @@ public abstract class Openable extends Parent implements IOpenable, IBufferChang
* if successful, or false if an error is encountered while determining
* the structure of this element.
*/
protected abstract boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws CModelException;
protected abstract boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map<ICElement, CElementInfo> newElements, IResource underlyingResource) throws CModelException;
/**
* Close the buffer associated with this element, if any.
@ -157,9 +157,9 @@ public abstract class Openable extends Parent implements IOpenable, IBufferChang
// to see if they have an child with unsaved changes
if (fType == C_MODEL ||
fType == C_PROJECT) {
Enumeration openBuffers= getBufferManager().getOpenBuffers();
Enumeration<IBuffer> openBuffers= getBufferManager().getOpenBuffers();
while (openBuffers.hasMoreElements()) {
IBuffer buffer= (IBuffer)openBuffers.nextElement();
IBuffer buffer= openBuffers.nextElement();
if (buffer.hasUnsavedChanges()) {
ICElement owner= (ICElement)buffer.getOwner();
if (isAncestorOf(owner)) {
@ -228,7 +228,7 @@ public abstract class Openable extends Parent implements IOpenable, IBufferChang
/**
* Open the parent element if necessary.
*/
protected void openParent(Object childInfo, Map newElements, IProgressMonitor pm) throws CModelException {
protected void openParent(CElementInfo childInfo, Map<ICElement, CElementInfo> newElements, IProgressMonitor pm) throws CModelException {
Openable openableParent = (Openable)getOpenableParent();
if (openableParent != null && !openableParent.isOpen()){
@ -243,7 +243,7 @@ public abstract class Openable extends Parent implements IOpenable, IBufferChang
* @see org.eclipse.cdt.internal.core.model.CElement#generateInfos(java.lang.Object, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
protected void generateInfos(Object info, Map newElements, IProgressMonitor monitor) throws CModelException {
protected void generateInfos(CElementInfo info, Map<ICElement, CElementInfo> newElements, IProgressMonitor monitor) throws CModelException {
if (CModelManager.VERBOSE){
System.out.println("OPENING Element ("+ Thread.currentThread()+"): " + this); //$NON-NLS-1$//$NON-NLS-2$

View file

@ -17,12 +17,7 @@ import org.eclipse.core.runtime.IPath;
* OutputEntry
*/
public class OutputEntry extends APathEntry implements IOutputEntry {
/**
* @param kind
* @param path
* @param exclusionPatterns
* @param isExported
*/
public OutputEntry(IPath path, IPath[] exclusionPatterns, boolean isExported) {
super(CDT_OUTPUT, null, null, path, exclusionPatterns, isExported);
}

View file

@ -63,10 +63,10 @@ public abstract class Parent extends CElement {
* @param type
* @return ArrayList
*/
public List getChildrenOfType(int type) throws CModelException {
public List<ICElement> getChildrenOfType(int type) throws CModelException {
ICElement[] children = getChildren();
int size = children.length;
ArrayList list = new ArrayList(size);
ArrayList<ICElement> list = new ArrayList<ICElement>(size);
for (int i = 0; i < size; ++i) {
CElement elt = (CElement)children[i];
if (elt.getElementType() == type) {

View file

@ -45,7 +45,7 @@ public class PathEntryContainerUpdatesOperation extends CModelOperation {
@Override
protected void executeOperation() throws CModelException {
PathEntryManager pathEntryManager = PathEntryManager.getDefault();
ArrayList list = new ArrayList(events.length);
ArrayList<CElementDelta> list = new ArrayList<CElementDelta>(events.length);
for (int i = 0; i < events.length; ++i) {
PathEntryContainerChanged event = events[i];
ICElement celement = CoreModel.getDefault().create(event.getPath());

View file

@ -27,12 +27,12 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPathEntryStore, IPathEntryStoreListener {
private List fListeners;
private List<IPathEntryStoreListener> fListeners;
private IPathEntryStore fStore;
public PathEntryStoreProxy(IProject project){
super(project, PathEntryManager.PATHENTRY_STORE_UNIQ_ID);
fListeners = Collections.synchronizedList(new ArrayList());
fListeners = Collections.synchronizedList(new ArrayList<IPathEntryStoreListener>());
}
public IPathEntryStore getStore(){

View file

@ -28,7 +28,7 @@ public class Region implements IRegion {
/**
* A collection of the top level elements that have been added to the region
*/
protected ArrayList fRootElements;
protected ArrayList<ICElement> fRootElements;
/**
* Creates an empty region.
@ -36,7 +36,7 @@ public class Region implements IRegion {
* @see IRegion
*/
public Region() {
fRootElements = new ArrayList(1);
fRootElements = new ArrayList<ICElement>(1);
}
/**
@ -57,10 +57,10 @@ public class Region implements IRegion {
public boolean contains(ICElement element) {
int size = fRootElements.size();
ArrayList parents = getAncestors(element);
ArrayList<ICElement> parents = getAncestors(element);
for (int i = 0; i < size; i++) {
ICElement aTop = (ICElement) fRootElements.get(i);
ICElement aTop = fRootElements.get(i);
if (aTop.equals(element)) {
return true;
}
@ -79,8 +79,8 @@ public class Region implements IRegion {
* order.
*
*/
private ArrayList getAncestors(ICElement element) {
ArrayList parents = new ArrayList();
private ArrayList<ICElement> getAncestors(ICElement element) {
ArrayList<ICElement> parents = new ArrayList<ICElement>();
ICElement parent = element.getParent();
while (parent != null) {
parents.add(parent);
@ -97,7 +97,7 @@ public class Region implements IRegion {
int size = fRootElements.size();
ICElement[] roots = new ICElement[size];
for (int i = 0; i < size; i++) {
roots[i] = (ICElement) fRootElements.get(i);
roots[i] = fRootElements.get(i);
}
return roots;
@ -121,9 +121,9 @@ public class Region implements IRegion {
*/
private void removeAllChildren(ICElement element) {
if (element instanceof IParent) {
ArrayList newRootElements = new ArrayList();
ArrayList<ICElement> newRootElements = new ArrayList<ICElement>();
for (int i = 0, size = fRootElements.size(); i < size; i++) {
ICElement currentRoot = (ICElement) fRootElements.get(i);
ICElement currentRoot = fRootElements.get(i);
// walk the current root hierarchy
ICElement parent = currentRoot.getParent();
boolean isChild = false;

View file

@ -63,27 +63,28 @@ public class RenameElementsOperation extends MoveElementsOperation {
*/
@Override
protected void verify(ICElement element) throws CModelException {
int elementType = element.getElementType();
if (element == null || !element.exists())
error(ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST, element);
if (element.isReadOnly())
error(ICModelStatusConstants.READ_ONLY, element);
if (!(element instanceof ISourceReference))
error(ICModelStatusConstants.INVALID_ELEMENT_TYPES, element);
if (elementType < ICElement.C_UNIT /*|| elementType == ICElement.INITIALIZER*/)
error(ICModelStatusConstants.INVALID_ELEMENT_TYPES, element);
// Member localContext;
// if (element instanceof Member && (localContext = ((Member)element).getOuterMostLocalContext()) != null && localContext != element) {
// // JDOM doesn't support source manipulation in local/anonymous types
// error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element);
// }
else {
int elementType = element.getElementType();
if (element.isReadOnly())
error(ICModelStatusConstants.READ_ONLY, element);
verifyRenaming(element);
if (!(element instanceof ISourceReference))
error(ICModelStatusConstants.INVALID_ELEMENT_TYPES, element);
if (elementType < ICElement.C_UNIT /*|| elementType == ICElement.INITIALIZER*/)
error(ICModelStatusConstants.INVALID_ELEMENT_TYPES, element);
// Member localContext;
// if (element instanceof Member && (localContext = ((Member)element).getOuterMostLocalContext()) != null && localContext != element) {
// // JDOM doesn't support source manipulation in local/anonymous types
// error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element);
// }
verifyRenaming(element);
}
}
}

View file

@ -67,23 +67,22 @@ public class SetPathEntriesOperation extends CModelOperation {
IProject[] projectReferences = description.getReferencedProjects();
HashSet oldReferences = new HashSet(projectReferences.length);
for (int i = 0; i < projectReferences.length; i++) {
String projectName = projectReferences[i].getName();
HashSet<String> oldReferences = new HashSet<String>(projectReferences.length);
for (IProject projectReference : projectReferences) {
String projectName = projectReference.getName();
oldReferences.add(projectName);
}
HashSet newReferences = (HashSet) oldReferences.clone();
@SuppressWarnings("unchecked")
HashSet<String> newReferences = (HashSet<String>) oldReferences.clone();
for (int i = 0; i < oldRequired.length; i++) {
String projectName = oldRequired[i];
for (String projectName : oldRequired) {
newReferences.remove(projectName);
}
for (int i = 0; i < newRequired.length; i++) {
String projectName = newRequired[i];
for (String projectName : newRequired) {
newReferences.add(projectName);
}
Iterator iter;
Iterator<String> iter;
int newSize = newReferences.size();
checkIdentity : {
@ -101,7 +100,7 @@ public class SetPathEntriesOperation extends CModelOperation {
int index = 0;
iter = newReferences.iterator();
while (iter.hasNext()) {
requiredProjectNames[index++] = (String) iter.next();
requiredProjectNames[index++] = iter.next();
}
Arrays.sort(requiredProjectNames); // ensure that if changed, the order is consistent

View file

@ -16,11 +16,6 @@ import org.eclipse.core.runtime.IPath;
public class SourceEntry extends APathEntry implements ISourceEntry {
/**
*
* @param path
* @param exclusionPatterns
*/
public SourceEntry(IPath sourcePath, IPath[] exclusionPatterns) {
super(IPathEntry.CDT_SOURCE, null, null, sourcePath, exclusionPatterns, false);
}

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IFunctionDeclaration;
import org.eclipse.cdt.core.model.IMember;
import org.eclipse.cdt.core.model.IOpenable;
import org.eclipse.cdt.core.model.ISourceManipulation;
import org.eclipse.cdt.core.model.ISourceRange;
@ -191,7 +192,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
* @see CElement#generateInfos
*/
@Override
protected void generateInfos(Object info, Map newElements, IProgressMonitor pm) throws CModelException {
protected void generateInfos(CElementInfo info, Map<ICElement, CElementInfo> newElements, IProgressMonitor pm) throws CModelException {
Openable openableParent = (Openable)getOpenableParent();
if (openableParent == null) {
return;
@ -288,41 +289,41 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
case ICElement.C_TEMPLATE_METHOD:
case ICElement.C_TEMPLATE_METHOD_DECLARATION:
for (int i = 0; i < children.length; i++) {
if (elementType == children[i].getElementType()
&& elementName.equals(children[i].getElementName())) {
assert children[i] instanceof IFunctionDeclaration;
String[] functionParams= ((IFunctionDeclaration)children[i]).getParameterTypes();
if (Arrays.equals(functionParams, mementoParams)) {
element= (CElement) children[i];
break;
for (ICElement element2 : children) {
if (elementType == element2.getElementType()
&& elementName.equals(element2.getElementName())) {
assert element2 instanceof IFunctionDeclaration;
String[] functionParams= ((IFunctionDeclaration)element2).getParameterTypes();
if (Arrays.equals(functionParams, mementoParams)) {
element= (CElement) element2;
break;
}
}
}
}
break;
case ICElement.C_TEMPLATE_CLASS:
case ICElement.C_TEMPLATE_STRUCT:
case ICElement.C_TEMPLATE_UNION:
for (int i = 0; i < children.length; i++) {
if (elementType == children[i].getElementType()
&& elementName.equals(children[i].getElementName())) {
assert children[i] instanceof ITemplate;
String[] templateParams= ((ITemplate)children[i]).getTemplateParameterTypes();
if (Arrays.equals(templateParams, mementoParams)) {
element= (CElement) children[i];
for (ICElement element2 : children) {
if (elementType == element2.getElementType()
&& elementName.equals(element2.getElementName())) {
assert element2 instanceof ITemplate;
String[] templateParams= ((ITemplate)element2).getTemplateParameterTypes();
if (Arrays.equals(templateParams, mementoParams)) {
element= (CElement) element2;
break;
}
}
}
break;
default:
for (ICElement element2 : children) {
if (elementType == element2.getElementType()
&& elementName.equals(element2.getElementName())) {
element= (CElement) element2;
break;
}
}
}
break;
default:
for (int i = 0; i < children.length; i++) {
if (elementType == children[i].getElementType()
&& elementName.equals(children[i].getElementName())) {
element= (CElement) children[i];
break;
}
}
break;
}
if (element != null) {

View file

@ -14,7 +14,10 @@ package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.IBuffer;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IMember;
import org.eclipse.cdt.core.model.ISourceManipulation;
import org.eclipse.cdt.core.model.ISourceRange;
import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.core.runtime.IProgressMonitor;

View file

@ -34,7 +34,7 @@ public class SourceMapper {
public ITranslationUnit findTranslationUnit(IParent container, String filename) {
try {
List list = container.getChildrenOfType(ICElement.C_UNIT);
List<?> list = container.getChildrenOfType(ICElement.C_UNIT);
for (int i = 0; i < list.size(); i++) {
Object o = list.get(i);
if (o instanceof ITranslationUnit) {

View file

@ -25,23 +25,22 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
public class Structure extends StructureDeclaration implements IStructure {
Map superClassesNames = new TreeMap();
Map<String, ASTAccessVisibility> superClassesNames = new TreeMap<String, ASTAccessVisibility>();
public Structure(ICElement parent, int kind, String name) {
super(parent, name, kind);
}
public IField[] getFields() throws CModelException {
List fields = new ArrayList();
List<ICElement> fields = new ArrayList<ICElement>();
fields.addAll(getChildrenOfType(ICElement.C_FIELD));
return (IField[]) fields.toArray(new IField[fields.size()]);
return fields.toArray(new IField[fields.size()]);
}
public IField getField(String name) {
try {
IField[] fields = getFields();
for (int i = 0; i<fields.length; i++){
IField field = fields[i];
for (IField field : fields) {
if(field.getElementName().equals(name)){
return field;
}
@ -52,17 +51,16 @@ public class Structure extends StructureDeclaration implements IStructure {
}
public IMethodDeclaration[] getMethods() throws CModelException {
List methods = new ArrayList();
List<ICElement> methods = new ArrayList<ICElement>();
methods.addAll(getChildrenOfType(ICElement.C_METHOD_DECLARATION));
methods.addAll(getChildrenOfType(ICElement.C_METHOD));
return (IMethodDeclaration[])methods.toArray(new IMethodDeclaration[methods.size()]);
return methods.toArray(new IMethodDeclaration[methods.size()]);
}
public IMethodDeclaration getMethod(String name) {
try {
IMethodDeclaration[] methods = getMethods();
for (int i = 0; i<methods.length; i++){
IMethodDeclaration method = methods[i];
for (IMethodDeclaration method : methods) {
if(method.getElementName().equals(name)){
return method;
}
@ -74,8 +72,7 @@ public class Structure extends StructureDeclaration implements IStructure {
public boolean isAbstract() throws CModelException {
IMethodDeclaration[] methods = getMethods();
for(int i=0; i<methods.length; i++){
IMethodDeclaration method = methods[i];
for (IMethodDeclaration method : methods) {
if(method.isPureVirtual())
return true;
}
@ -83,11 +80,11 @@ public class Structure extends StructureDeclaration implements IStructure {
}
public String[] getSuperClassesNames(){
return (String[])superClassesNames.keySet().toArray(new String[superClassesNames.keySet().size()]);
return superClassesNames.keySet().toArray(new String[superClassesNames.keySet().size()]);
}
public ASTAccessVisibility getSuperClassAccess(String name){
return (ASTAccessVisibility)superClassesNames.get(name);
return superClassesNames.get(name);
}
public void addSuperClass(String name) {

View file

@ -20,11 +20,6 @@ import org.eclipse.cdt.core.model.IStructureDeclaration;
*/
public class StructureDeclaration extends SourceManipulation implements IStructureDeclaration {
/**
* @param parent
* @param name
* @param type
*/
public StructureDeclaration(ICElement parent, String name, int kind) {
super(parent, name, kind);
}

View file

@ -24,7 +24,7 @@ public class StructureTemplate extends Structure implements IStructureTemplate {
}
/**
* Returns the parameterTypes.
* @see org.eclipse.cdt.core.model.ITemplate#getParameters()
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes()
* @return String[]
*/
public String[] getTemplateParameterTypes() {
@ -33,7 +33,7 @@ public class StructureTemplate extends Structure implements IStructureTemplate {
/**
* Sets the fParameterTypes.
* @param fParameterTypes The fParameterTypes to set
* @param templateParameterTypes The template parameter types to set
*/
public void setTemplateParameterTypes(String[] templateParameterTypes) {
fTemplate.setTemplateParameterTypes(templateParameterTypes);
@ -58,9 +58,9 @@ public class StructureTemplate extends Structure implements IStructureTemplate {
super.getHandleMemento(buff);
if (fTemplate.getNumberOfTemplateParameters() > 0) {
final String[] parameterTypes= fTemplate.getTemplateParameterTypes();
for (int i = 0; i < parameterTypes.length; i++) {
for (String parameterType : parameterTypes) {
buff.append(CEM_PARAMETER);
escapeMementoName(buff, parameterTypes[i]);
escapeMementoName(buff, parameterType);
}
}
}

View file

@ -25,7 +25,7 @@ public class Template implements ITemplate {
}
/**
* Returns the parameterTypes.
* @see org.eclipse.cdt.core.model.ITemplate#getParameters()
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes()
* @return String[]
*/
public String[] getTemplateParameterTypes() {
@ -34,7 +34,7 @@ public class Template implements ITemplate {
/**
* Sets the fParameterTypes.
* @param fParameterTypes The fParameterTypes to set
* @param templateParameterTypes The template parameter types to set
*/
public void setTemplateParameterTypes(String[] templateParameterTypes) {
this.templateParameterTypes = templateParameterTypes;

View file

@ -147,12 +147,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
public ICElement getElementAtLine(int line) throws CModelException {
ICElement[] celements = getChildren();
for (int i = 0; i < celements.length; i++) {
ISourceRange range = ((ISourceReference)celements[i]).getSourceRange();
for (ICElement celement : celements) {
ISourceRange range = ((ISourceReference)celement).getSourceRange();
int startLine = range.getStartLine();
int endLine = range.getEndLine();
if (line >= startLine && line <= endLine) {
return celements[i];
return celement;
}
}
return null;
@ -180,9 +180,9 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
}
try {
ICElement[] celements = getChildren();
for (int i = 0; i < celements.length; i++) {
if (name.equals(celements[i].getElementName())) {
return celements[i];
for (ICElement celement : celements) {
if (name.equals(celement.getElementName())) {
return celement;
}
}
} catch (CModelException e) {
@ -196,9 +196,9 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
try {
ICElement[] celements = ((IParent) current).getChildren();
current = null;
for (int i = 0; i < celements.length; i++) {
if (names[j].equals(celements[i].getElementName())) {
current = celements[i];
for (ICElement celement : celements) {
if (names[j].equals(celement.getElementName())) {
current = celement;
break;
}
}
@ -215,10 +215,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
public IInclude getInclude(String name) {
try {
ICElement[] celements = getChildren();
for (int i = 0; i < celements.length; i++) {
if (celements[i].getElementType() == ICElement.C_INCLUDE) {
if (name.equals(celements[i].getElementName())) {
return (IInclude) celements[i];
for (ICElement celement : celements) {
if (celement.getElementType() == ICElement.C_INCLUDE) {
if (name.equals(celement.getElementName())) {
return (IInclude) celement;
}
}
}
@ -230,9 +230,9 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
public IInclude[] getIncludes() throws CModelException {
ICElement[] celements = getChildren();
ArrayList<ICElement> aList = new ArrayList<ICElement>();
for (int i = 0; i < celements.length; i++) {
if (celements[i].getElementType() == ICElement.C_INCLUDE) {
aList.add(celements[i]);
for (ICElement celement : celements) {
if (celement.getElementType() == ICElement.C_INCLUDE) {
aList.add(celement);
}
}
return aList.toArray(new IInclude[0]);
@ -241,10 +241,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
public IUsing getUsing(String name) {
try {
ICElement[] celements = getChildren();
for (int i = 0; i < celements.length; i++) {
if (celements[i].getElementType() == ICElement.C_USING) {
if (name.equals(celements[i].getElementName())) {
return (IUsing) celements[i];
for (ICElement celement : celements) {
if (celement.getElementType() == ICElement.C_USING) {
if (name.equals(celement.getElementName())) {
return (IUsing) celement;
}
}
}
@ -256,9 +256,9 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
public IUsing[] getUsings() throws CModelException {
ICElement[] celements = getChildren();
ArrayList<ICElement> aList = new ArrayList<ICElement>();
for (int i = 0; i < celements.length; i++) {
if (celements[i].getElementType() == ICElement.C_USING) {
aList.add(celements[i]);
for (ICElement celement : celements) {
if (celement.getElementType() == ICElement.C_USING) {
aList.add(celement);
}
}
return aList.toArray(new IUsing[0]);
@ -272,10 +272,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
if (current instanceof IParent) {
ICElement[] celements = ((IParent) current).getChildren();
current = null;
for (int i = 0; i < celements.length; i++) {
if (celements[i].getElementType() == ICElement.C_NAMESPACE) {
if (name.equals(celements[i].getElementName())) {
current = celements[i];
for (ICElement celement : celements) {
if (celement.getElementType() == ICElement.C_NAMESPACE) {
if (name.equals(celement.getElementName())) {
current = celement;
break;
}
}
@ -295,9 +295,9 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
public INamespace[] getNamespaces() throws CModelException {
ICElement[] celements = getChildren();
ArrayList<ICElement> aList = new ArrayList<ICElement>();
for (int i = 0; i < celements.length; i++) {
if (celements[i].getElementType() == ICElement.C_NAMESPACE) {
aList.add(celements[i]);
for (ICElement celement : celements) {
if (celement.getElementType() == ICElement.C_NAMESPACE) {
aList.add(celement);
}
}
return aList.toArray(new INamespace[0]);
@ -405,11 +405,11 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
// In order to be shared, working copies have to denote the same translation unit
// AND use the same buffer factory.
// Assuming there is a little set of buffer factories, then use a 2 level Map cache.
Map sharedWorkingCopies = CModelManager.getDefault().sharedWorkingCopies;
Map<IBufferFactory, Map<ITranslationUnit, WorkingCopy>> sharedWorkingCopies = CModelManager.getDefault().sharedWorkingCopies;
Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
Map<ITranslationUnit, WorkingCopy> perFactoryWorkingCopies = sharedWorkingCopies.get(factory);
if (perFactoryWorkingCopies == null) return null;
return (WorkingCopy) perFactoryWorkingCopies.get(this);
return perFactoryWorkingCopies.get(this);
}
@Override
@ -418,7 +418,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
}
@Override
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws CModelException {
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map<ICElement, CElementInfo> newElements, IResource underlyingResource) throws CModelException {
TranslationUnitInfo unitInfo = (TranslationUnitInfo) info;
// We reuse the general info cache in the CModelBuilder, We should not do this
@ -468,14 +468,14 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
// In order to be shared, working copies have to denote the same translation unit
// AND use the same buffer factory.
// Assuming there is a little set of buffer factories, then use a 2 level Map cache.
Map sharedWorkingCopies = manager.sharedWorkingCopies;
Map<IBufferFactory, Map<ITranslationUnit, WorkingCopy>> sharedWorkingCopies = manager.sharedWorkingCopies;
Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
Map<ITranslationUnit, WorkingCopy> perFactoryWorkingCopies = sharedWorkingCopies.get(factory);
if (perFactoryWorkingCopies == null) {
perFactoryWorkingCopies = new HashMap();
perFactoryWorkingCopies = new HashMap<ITranslationUnit, WorkingCopy>();
sharedWorkingCopies.put(factory, perFactoryWorkingCopies);
}
WorkingCopy workingCopy = (WorkingCopy)perFactoryWorkingCopies.get(this);
WorkingCopy workingCopy = perFactoryWorkingCopies.get(this);
if (workingCopy != null) {
workingCopy.useCount++;
return workingCopy;
@ -511,7 +511,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
}
@Override
protected void openParent(Object childInfo, Map newElements, IProgressMonitor pm) throws CModelException {
protected void openParent(CElementInfo childInfo, Map<ICElement, CElementInfo> newElements, IProgressMonitor pm) throws CModelException {
try {
super.openParent(childInfo, newElements, pm);
} catch (CModelException e) {
@ -548,13 +548,13 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
info= createElementInfo();
}
try {
HashMap newElements = manager.getTemporaryCache();
Map<ICElement, CElementInfo> newElements = manager.getTemporaryCache();
openWhenClosed(info, monitor);
if (newElements.get(this) == null) {
// close any buffer that was opened for the new elements
Iterator iterator = newElements.keySet().iterator();
Iterator<ICElement> iterator = newElements.keySet().iterator();
while (iterator.hasNext()) {
ICElement element = (ICElement)iterator.next();
ICElement element = iterator.next();
if (element instanceof Openable) {
((Openable)element).closeBuffer();
}
@ -625,14 +625,14 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return buffer;
}
public Map parse() {
public Map<?, ?> parse() {
throw new UnsupportedOperationException("Deprecated method"); //$NON-NLS-1$
}
/**
* Parse the buffer contents of this element.
*/
private void parse(Map newElements, IProgressMonitor monitor) {
private void parse(Map<ICElement, CElementInfo> newElements, IProgressMonitor monitor) {
boolean quickParseMode = ! (CCorePlugin.getDefault().useStructuralParseMode());
IContributedModelBuilder mb = LanguageManager.getInstance().getContributedModelBuilderFor(this);
if (mb == null) {
@ -646,7 +646,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
* Parse the buffer contents of this element.
* @param monitor
*/
private void parseUsingCModelBuilder(Map newElements, boolean quickParseMode, IProgressMonitor monitor) {
private void parseUsingCModelBuilder(Map<ICElement, CElementInfo> newElements, boolean quickParseMode, IProgressMonitor monitor) {
try {
new CModelBuilder2(this, monitor).parse(quickParseMode);
} catch (OperationCanceledException oce) {
@ -854,11 +854,11 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
if (index != null && (style & AST_CONFIGURE_USING_SOURCE_CONTEXT) != 0) {
try {
fLanguageOfContext= null;
for (int i = 0; i < CTX_LINKAGES.length; i++) {
for (int element : CTX_LINKAGES) {
IIndexFile context= null;
final IIndexFileLocation ifl = IndexLocationFactory.getIFL(this);
if (ifl != null) {
IIndexFile indexFile= index.getFile(CTX_LINKAGES[i], ifl);
IIndexFile indexFile= index.getFile(element, ifl);
if (indexFile != null) {
// bug 199412, when a source-file includes itself the context may recurse.
HashSet<IIndexFile> visited= new HashSet<IIndexFile>();
@ -1032,43 +1032,43 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
case ICElement.C_TEMPLATE_METHOD:
case ICElement.C_TEMPLATE_METHOD_DECLARATION:
// search for matching function
for (int i = 0; i < children.length; i++) {
if (elementType == children[i].getElementType()
&& elementName.equals(children[i].getElementName())) {
assert children[i] instanceof IFunctionDeclaration;
String[] functionParams= ((IFunctionDeclaration)children[i]).getParameterTypes();
if (Arrays.equals(functionParams, mementoParams)) {
element= (CElement) children[i];
break;
for (ICElement element2 : children) {
if (elementType == element2.getElementType()
&& elementName.equals(element2.getElementName())) {
assert element2 instanceof IFunctionDeclaration;
String[] functionParams= ((IFunctionDeclaration)element2).getParameterTypes();
if (Arrays.equals(functionParams, mementoParams)) {
element= (CElement) element2;
break;
}
}
}
}
break;
case ICElement.C_TEMPLATE_CLASS:
case ICElement.C_TEMPLATE_STRUCT:
case ICElement.C_TEMPLATE_UNION:
// search for matching template type
for (int i = 0; i < children.length; i++) {
if (elementType == children[i].getElementType()
&& elementName.equals(children[i].getElementName())) {
assert children[i] instanceof ITemplate;
String[] templateParams= ((ITemplate)children[i]).getTemplateParameterTypes();
if (Arrays.equals(templateParams, mementoParams)) {
element= (CElement) children[i];
break;
for (ICElement element2 : children) {
if (elementType == element2.getElementType()
&& elementName.equals(element2.getElementName())) {
assert element2 instanceof ITemplate;
String[] templateParams= ((ITemplate)element2).getTemplateParameterTypes();
if (Arrays.equals(templateParams, mementoParams)) {
element= (CElement) element2;
break;
}
}
}
}
break;
default:
// search for matching element
for (int i = 0; i < children.length; i++) {
if (elementType == children[i].getElementType()
&& elementName.equals(children[i].getElementName())) {
element= (CElement) children[i];
break;
for (ICElement element2 : children) {
if (elementType == element2.getElementType()
&& elementName.equals(element2.getElementName())) {
element= (CElement) element2;
break;
}
}
}
break;
}
if (element != null) {

View file

@ -60,8 +60,7 @@ public class Util implements ICLogConstants {
return new StringBuffer(b.length).append(b);
} finally {
try {
if (stream != null)
stream.close();
stream.close();
} catch (IOException e) {
}
}
@ -234,10 +233,6 @@ public class Util implements ICLogConstants {
}
}
/**
* @param client
* @return
*/
public static boolean isActive(DebugLogConstants client) {
if (client.equals(DebugLogConstants.PARSER)) {
return VERBOSE_PARSER;
@ -436,8 +431,6 @@ public class Util implements ICLogConstants {
/**
* Return true if the file is not a directory and has length > 0
* @param path
* @return
*/
public static boolean isNonZeroLengthFile(IPath path) {
return isNonZeroLengthFile(URIUtil.toURI(path));
@ -445,8 +438,6 @@ public class Util implements ICLogConstants {
/**
* Return true if the file referred to by the URI is not a directory and has length > 0
* @param uri
* @return
*/
public static boolean isNonZeroLengthFile(URI uri) {
try {

View file

@ -57,9 +57,6 @@ class VariableInfo extends SourceManipulationInfo {
this.isStatic = isStatic;
}
/**
* @see org.eclipse.cdt.internal.core.model.SourceManipulationInfo#hasSameContentsAs(org.eclipse.cdt.internal.core.model.SourceManipulationInfo)
*/
@Override
public boolean hasSameContentsAs(SourceManipulationInfo otherInfo) {
return

View file

@ -190,14 +190,14 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
// look for it.
ICElement element = workingCopyElement;
ArrayList children = new ArrayList();
ArrayList<ICElement> children = new ArrayList<ICElement>();
while (element != null && element.getElementType() != ICElement.C_UNIT) {
children.add(element);
element = element.getParent();
}
ICElement current = tu;
for (int i = children.size()-1; i >= 0; i--) {
ICElement child = (ICElement)children.get(i);
ICElement child = children.get(i);
if (current instanceof IParent) {
try {
ICElement[] celems = ((IParent)current).getChildren();
@ -282,7 +282,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
}
/**
* @see ICFile
* @see ITranslationUnit
* @see IWorkingCopy
*
* @exception CModelException attempting to open a read only element for
@ -331,7 +331,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
if (originalBuffer != null) {
char[] originalContents = originalBuffer.getCharacters();
if (originalContents != null) {
buffer.setContents((char[])originalContents.clone());
buffer.setContents(originalContents.clone());
}
} else {
// initialize buffer
@ -379,7 +379,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
}
/**
* @see org.eclipse.cdt.core.model.ICFile#save(IProgressMonitor, boolean)
* @see ITranslationUnit#save(IProgressMonitor, boolean)
*/
@Override
public void save(IProgressMonitor pm, boolean force) throws CModelException {

View file

@ -12,7 +12,7 @@ package org.eclipse.cdt.internal.core.model;
/**
* The Element Info of a Working Copy.
* @deprecated Use {@link TranslationUnitInfo} directly
* @deprecated Use the extended class directly
*/
@Deprecated
public class WorkingCopyInfo extends TranslationUnitInfo {

View file

@ -32,7 +32,7 @@ import java.util.Hashtable;
*
* This class is similar to the JDT LRUCache class.
*/
public class LRUCache implements Cloneable {
public class LRUCache<K,T> implements Cloneable {
/**
* This type is used internally by the LRUCache to represent entries
@ -42,17 +42,17 @@ public class LRUCache implements Cloneable {
*
* @see LRUCache
*/
protected static class LRUCacheEntry {
protected static class LRUCacheEntry<K,T> {
/**
* Hash table key
*/
public Object _fKey;
public K _fKey;
/**
* Hash table value (an LRUCacheEntry object)
*/
public Object _fValue;
public T _fValue;
/**
* Time value for queue sorting
@ -67,18 +67,18 @@ public class LRUCache implements Cloneable {
/**
* Previous entry in queue
*/
public LRUCacheEntry _fPrevious;
public LRUCacheEntry<K,T> _fPrevious;
/**
* Next entry in queue
*/
public LRUCacheEntry _fNext;
public LRUCacheEntry<K,T> _fNext;
/**
* Creates a new instance of the receiver with the provided values
* for key, value, and space.
*/
public LRUCacheEntry (Object key, Object value, int space) {
public LRUCacheEntry (K key, T value, int space) {
_fKey = key;
_fValue = value;
_fSpace = space;
@ -112,17 +112,17 @@ public class LRUCache implements Cloneable {
/**
* Hash table for fast random access to cache entries
*/
protected Hashtable fEntryTable;
protected Hashtable<K,LRUCacheEntry<K,T>> fEntryTable;
/**
* Start of queue (most recently used entry)
*/
protected LRUCacheEntry fEntryQueue;
protected LRUCacheEntry<K,T> fEntryQueue;
/**
* End of queue (least recently used entry)
*/
protected LRUCacheEntry fEntryQueueTail;
protected LRUCacheEntry<K,T> fEntryQueueTail;
/**
* Default amount of space in the cache
@ -144,7 +144,7 @@ public class LRUCache implements Cloneable {
fTimestampCounter = fCurrentSpace = 0;
fEntryQueue = fEntryQueueTail = null;
fEntryTable = new Hashtable(size);
fEntryTable = new Hashtable<K,LRUCacheEntry<K,T>>(size);
fSpaceLimit = size;
}
/**
@ -155,8 +155,8 @@ public class LRUCache implements Cloneable {
@Override
public Object clone() {
LRUCache newCache = newInstance(fSpaceLimit);
LRUCacheEntry qEntry;
LRUCache<K,T> newCache = newInstance(fSpaceLimit);
LRUCacheEntry<K,T> qEntry;
/* Preserve order of entries by copying from oldest to newest */
qEntry = this.fEntryQueueTail;
@ -172,8 +172,8 @@ public class LRUCache implements Cloneable {
public void flush() {
fCurrentSpace = 0;
LRUCacheEntry entry = fEntryQueueTail; // Remember last entry
fEntryTable = new Hashtable(); // Clear it out
LRUCacheEntry<K,T> entry = fEntryQueueTail; // Remember last entry
fEntryTable = new Hashtable<K,LRUCacheEntry<K,T>>(); // Clear it out
fEntryQueue = fEntryQueueTail = null;
while (entry != null) { // send deletion notifications in LRU order
privateNotifyDeletionFromCache(entry);
@ -188,9 +188,9 @@ public class LRUCache implements Cloneable {
*/
public void flush (Object key) {
LRUCacheEntry entry;
LRUCacheEntry<K,T> entry;
entry = (LRUCacheEntry) fEntryTable.get(key);
entry = fEntryTable.get(key);
/* If entry does not exist, return */
if (entry == null) return;
@ -206,7 +206,7 @@ public class LRUCache implements Cloneable {
*/
public Object get(Object key) {
LRUCacheEntry entry = (LRUCacheEntry) fEntryTable.get(key);
LRUCacheEntry<K,T> entry = fEntryTable.get(key);
if (entry == null) {
return null;
}
@ -229,7 +229,7 @@ public class LRUCache implements Cloneable {
/**
* Returns an Enumeration of the keys currently in the cache.
*/
public Enumeration keys() {
public Enumeration<K> keys() {
return fEntryTable.keys();
}
@ -246,19 +246,19 @@ public class LRUCache implements Cloneable {
public ICacheEnumeration keysAndValues() {
return new ICacheEnumeration() {
Enumeration fValues = fEntryTable.elements();
LRUCacheEntry fEntry;
Enumeration<LRUCacheEntry<K,T>> fValues = fEntryTable.elements();
LRUCacheEntry<K,T> fEntry;
public boolean hasMoreElements() {
return fValues.hasMoreElements();
}
public Object nextElement() {
fEntry = (LRUCacheEntry) fValues.nextElement();
public K nextElement() {
fEntry = fValues.nextElement();
return fEntry._fKey;
}
public Object getValue() {
public T getValue() {
if (fEntry == null) {
throw new java.util.NoSuchElementException();
}
@ -298,17 +298,17 @@ public class LRUCache implements Cloneable {
/**
* Returns a new LRUCache instance
*/
protected LRUCache newInstance(int size) {
return new LRUCache(size);
protected LRUCache<K,T> newInstance(int size) {
return new LRUCache<K,T>(size);
}
/**
* Adds an entry for the given key/value/space.
*/
protected void privateAdd (Object key, Object value, int space) {
protected void privateAdd (K key, T value, int space) {
LRUCacheEntry entry;
LRUCacheEntry<K,T> entry;
entry = new LRUCacheEntry(key, value, space);
entry = new LRUCacheEntry<K,T>(key, value, space);
this.privateAddEntry (entry, false);
}
/**
@ -316,7 +316,7 @@ public class LRUCache implements Cloneable {
* @param shuffle Indicates whether we are just shuffling the queue
* (i.e., the entry table is left alone).
*/
protected void privateAddEntry (LRUCacheEntry entry, boolean shuffle) {
protected void privateAddEntry (LRUCacheEntry<K,T> entry, boolean shuffle) {
if (!shuffle) {
fEntryTable.put (entry._fKey, entry);
@ -341,7 +341,7 @@ public class LRUCache implements Cloneable {
* fallen off the bottom of the LRU queue.
* Subclasses could over-ride this to implement a persistent cache below the LRU cache.
*/
protected void privateNotifyDeletionFromCache(LRUCacheEntry entry) {
protected void privateNotifyDeletionFromCache(LRUCacheEntry<K,T> entry) {
// Default is NOP.
}
/**
@ -349,9 +349,9 @@ public class LRUCache implements Cloneable {
* @param shuffle indicates whether we are just shuffling the queue
* (i.e., the entry table is left alone).
*/
protected void privateRemoveEntry (LRUCacheEntry entry, boolean shuffle) {
protected void privateRemoveEntry (LRUCacheEntry<K,T> entry, boolean shuffle) {
LRUCacheEntry previous, next;
LRUCacheEntry<K,T> previous, next;
previous = entry._fPrevious;
next = entry._fNext;
@ -383,14 +383,14 @@ public class LRUCache implements Cloneable {
* @param value Value of object to add.
* @return added value.
*/
public Object put(Object key, Object value) {
public T put(K key, T value) {
int newSpace, oldSpace, newTotal;
LRUCacheEntry entry;
LRUCacheEntry<K,T> entry;
/* Check whether there's an entry in the cache */
newSpace = spaceFor (key, value);
entry = (LRUCacheEntry) fEntryTable.get (key);
entry = fEntryTable.get (key);
if (entry != null) {
@ -422,13 +422,13 @@ public class LRUCache implements Cloneable {
* @param key Key of object to remove from cache.
* @return Value removed from cache.
*/
public Object removeKey (Object key) {
public T removeKey (K key) {
LRUCacheEntry entry = (LRUCacheEntry) fEntryTable.get(key);
LRUCacheEntry<K,T> entry = fEntryTable.get(key);
if (entry == null) {
return null;
}
Object value = entry._fValue;
T value = entry._fValue;
this.privateRemoveEntry (entry, false);
return value;
}
@ -472,7 +472,7 @@ protected String toStringContents() {
int length = fEntryTable.size();
Object[] unsortedKeys = new Object[length];
String[] unsortedToStrings = new String[length];
Enumeration e = this.keys();
Enumeration<K> e = this.keys();
for (int i = 0; i < length; i++) {
Object key = e.nextElement();
unsortedKeys[i] = key;
@ -497,7 +497,7 @@ protected String toStringContents() {
* Updates the timestamp for the given entry, ensuring that the queue is
* kept in correct order. The entry must exist
*/
protected void updateTimestamp (LRUCacheEntry entry) {
protected void updateTimestamp (LRUCacheEntry<K,T> entry) {
entry._fTimestamp = fTimestampCounter++;
if (fEntryQueue != entry) {

View file

@ -24,34 +24,34 @@ import java.util.Enumeration;
*
* This class is similar to the JDT LRUCacheEnumerator class.
*/
public class LRUCacheEnumerator implements Enumeration {
public class LRUCacheEnumerator<T> implements Enumeration<T> {
/**
* Current element;
*/
protected LRUEnumeratorElement fElementQueue;
protected LRUEnumeratorElement<T> fElementQueue;
public static class LRUEnumeratorElement {
public static class LRUEnumeratorElement<T> {
/**
* Value returned by <code>nextElement()</code>;
*/
public Object fValue;
public T fValue;
/**
* Next element
*/
public LRUEnumeratorElement fNext;
public LRUEnumeratorElement<T> fNext;
/**
* Constructor
*/
public LRUEnumeratorElement(Object value) {
public LRUEnumeratorElement(T value) {
fValue = value;
}
}
/**
* Creates a CacheEnumerator on the list of <code>LRUEnumeratorElements</code>.
*/
public LRUCacheEnumerator(LRUEnumeratorElement firstElement) {
public LRUCacheEnumerator(LRUEnumeratorElement<T> firstElement) {
fElementQueue = firstElement;
}
/**
@ -63,8 +63,8 @@ public class LRUCacheEnumerator implements Enumeration {
/**
* Returns the next element.
*/
public Object nextElement() {
Object temp = fElementQueue.fValue;
public T nextElement() {
T temp = fElementQueue.fValue;
fElementQueue = fElementQueue.fNext;
return temp;
}

View file

@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.util;
import java.util.Enumeration;
import java.util.Iterator;
/**
* The <code>OverflowingLRUCache</code> is an LRUCache which attempts
@ -48,7 +47,7 @@ import java.util.Iterator;
*
* This class is similar to the JDT OverflowingLRUCache class.
*/
public abstract class OverflowingLRUCache extends LRUCache {
public abstract class OverflowingLRUCache<K,T> extends LRUCache<K,T> {
/**
* Indicates if the cache has been over filled and by how much.
*/
@ -96,8 +95,8 @@ public abstract class OverflowingLRUCache extends LRUCache {
@Override
public Object clone() {
OverflowingLRUCache newCache = (OverflowingLRUCache)newInstance(fSpaceLimit, fOverflow);
LRUCacheEntry qEntry;
OverflowingLRUCache<K,T> newCache = newInstance(fSpaceLimit, fOverflow);
LRUCacheEntry<K,T> qEntry;
/* Preserve order of entries by copying from oldest to newest */
qEntry = this.fEntryQueueTail;
@ -115,25 +114,25 @@ public abstract class OverflowingLRUCache extends LRUCache {
* by closing the obejct.
*
*/
protected abstract boolean close(LRUCacheEntry entry);
protected abstract boolean close(LRUCacheEntry<K,T> entry);
/**
* Returns an enumerator of the values in the cache with the most
* recently used first.
*/
public Enumeration elements() {
public Enumeration<T> elements() {
if (fEntryQueue == null)
return new LRUCacheEnumerator(null);
LRUCacheEnumerator.LRUEnumeratorElement head =
new LRUCacheEnumerator.LRUEnumeratorElement(fEntryQueue._fValue);
LRUCacheEntry currentEntry = fEntryQueue._fNext;
LRUCacheEnumerator.LRUEnumeratorElement currentElement = head;
return new LRUCacheEnumerator<T>(null);
LRUCacheEnumerator.LRUEnumeratorElement<T> head =
new LRUCacheEnumerator.LRUEnumeratorElement<T>(fEntryQueue._fValue);
LRUCacheEntry<K,T> currentEntry = fEntryQueue._fNext;
LRUCacheEnumerator.LRUEnumeratorElement<T> currentElement = head;
while(currentEntry != null) {
currentElement.fNext = new LRUCacheEnumerator.LRUEnumeratorElement(currentEntry._fValue);
currentElement.fNext = new LRUCacheEnumerator.LRUEnumeratorElement<T>(currentEntry._fValue);
currentElement = currentElement.fNext;
currentEntry = currentEntry._fNext;
}
return new LRUCacheEnumerator(head);
return new LRUCacheEnumerator<T>(head);
}
public double fillingRatio() {
return (fCurrentSpace + fOverflow) * 100.0 / fSpaceLimit;
@ -144,7 +143,7 @@ public abstract class OverflowingLRUCache extends LRUCache {
*
* @return Hashtable of entries
*/
public java.util.Hashtable getEntryTable() {
public java.util.Hashtable<K,LRUCacheEntry<K,T>> getEntryTable() {
return fEntryTable;
}
/**
@ -183,7 +182,7 @@ public abstract class OverflowingLRUCache extends LRUCache {
/* Free up space by removing oldest entries */
int spaceNeeded = (int)((1 - fLoadFactor) * fSpaceLimit);
spaceNeeded = (spaceNeeded > space) ? spaceNeeded : space;
LRUCacheEntry entry = fEntryQueueTail;
LRUCacheEntry<K,T> entry = fEntryQueueTail;
while (fCurrentSpace + spaceNeeded > limit && entry != null) {
this.privateRemoveEntry(entry, false, false);
@ -203,16 +202,16 @@ public abstract class OverflowingLRUCache extends LRUCache {
/**
* Returns a new instance of the reciever.
*/
protected abstract LRUCache newInstance(int size, int overflow);
protected abstract OverflowingLRUCache<K,T> newInstance(int size, int overflow);
/**
* Answers the value in the cache at the given key.
* If the value is not in the cache, returns null
*
* This function does not modify timestamps.
*/
public Object peek(Object key) {
public T peek(K key) {
LRUCacheEntry entry = (LRUCacheEntry) fEntryTable.get(key);
LRUCacheEntry<K,T> entry = fEntryTable.get(key);
if (entry == null) {
return null;
}
@ -223,7 +222,7 @@ public abstract class OverflowingLRUCache extends LRUCache {
*/
public void printStats() {
int forwardListLength = 0;
LRUCacheEntry entry = fEntryQueue;
LRUCacheEntry<K,T> entry = fEntryQueue;
while(entry != null) {
forwardListLength++;
entry = entry._fNext;
@ -238,11 +237,11 @@ public abstract class OverflowingLRUCache extends LRUCache {
}
System.out.println("Backward length: " + backwardListLength); //$NON-NLS-1$
Enumeration keys = fEntryTable.keys();
Enumeration<K> keys = fEntryTable.keys();
class Temp {
public Class fClass;
public Class<?> fClass;
public int fCount;
public Temp(Class aClass) {
public Temp(Class<?> aClass) {
fClass = aClass;
fCount = 1;
}
@ -251,11 +250,11 @@ public abstract class OverflowingLRUCache extends LRUCache {
return "Class: " + fClass + " has " + fCount + " entries."; //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$
}
}
java.util.HashMap h = new java.util.HashMap();
java.util.HashMap<Class<?>, Temp> h = new java.util.HashMap<Class<?>, Temp>();
while(keys.hasMoreElements()) {
entry = (LRUCacheEntry)fEntryTable.get(keys.nextElement());
Class key = entry._fValue.getClass();
Temp t = (Temp)h.get(key);
entry = fEntryTable.get(keys.nextElement());
Class<?> key = entry._fValue.getClass();
Temp t = h.get(key);
if (t == null) {
h.put(key, new Temp(key));
} else {
@ -263,8 +262,8 @@ public abstract class OverflowingLRUCache extends LRUCache {
}
}
for (Iterator iter = h.keySet().iterator(); iter.hasNext();){
System.out.println(h.get(iter.next()));
for (Object element : h.keySet()) {
System.out.println(h.get(element));
}
}
/**
@ -275,7 +274,7 @@ public abstract class OverflowingLRUCache extends LRUCache {
* (i.e., the entry table is left alone).
*/
@Override
protected void privateRemoveEntry (LRUCacheEntry entry, boolean shuffle) {
protected void privateRemoveEntry (LRUCacheEntry<K,T> entry, boolean shuffle) {
privateRemoveEntry(entry, shuffle, true);
}
/**
@ -289,7 +288,7 @@ public abstract class OverflowingLRUCache extends LRUCache {
* @param shuffle indicates whether we are just shuffling the queue
* (i.e., the entry table is left alone).
*/
protected void privateRemoveEntry(LRUCacheEntry entry, boolean shuffle, boolean external) {
protected void privateRemoveEntry(LRUCacheEntry<K, T> entry, boolean shuffle, boolean external) {
if (!shuffle) {
if (external) {
@ -309,8 +308,8 @@ public abstract class OverflowingLRUCache extends LRUCache {
privateNotifyDeletionFromCache(entry);
}
}
LRUCacheEntry previous = entry._fPrevious;
LRUCacheEntry next = entry._fNext;
LRUCacheEntry<K, T> previous = entry._fPrevious;
LRUCacheEntry<K, T> next = entry._fNext;
/* if this was the first entry */
if (previous == null) {
@ -333,14 +332,14 @@ public abstract class OverflowingLRUCache extends LRUCache {
* @return added value.
*/
@Override
public Object put(Object key, Object value) {
public T put(K key, T value) {
/* attempt to rid ourselves of the overflow, if there is any */
if (fOverflow > 0)
shrink();
/* Check whether there's an entry in the cache */
int newSpace = spaceFor (key, value);
LRUCacheEntry entry = (LRUCacheEntry) fEntryTable.get (key);
LRUCacheEntry<K, T> entry = fEntryTable.get (key);
if (entry != null) {
@ -378,7 +377,7 @@ public abstract class OverflowingLRUCache extends LRUCache {
* @param key Key of object to remove from cache.
* @return Value removed from cache.
*/
public Object remove(Object key) {
public Object remove(K key) {
return removeKey(key);
}
/**
@ -431,7 +430,7 @@ public abstract class OverflowingLRUCache extends LRUCache {
* <p>This method will do nothing if timestamps have been disabled.
*/
@Override
protected void updateTimestamp(LRUCacheEntry entry) {
protected void updateTimestamp(LRUCacheEntry<K, T> entry) {
if (fTimestampsOn) {
entry._fTimestamp = fTimestampCounter++;
if (fEntryQueue != entry) {

View file

@ -54,6 +54,7 @@ import org.eclipse.cdt.internal.core.model.BufferManager;
import org.eclipse.cdt.internal.core.model.CModelManager;
import org.eclipse.cdt.internal.core.model.IBufferFactory;
import org.eclipse.cdt.internal.core.model.Util;
import org.eclipse.cdt.internal.core.model.WorkingCopy;
import org.eclipse.cdt.internal.core.pdom.PDOMManager;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IProject;
@ -211,11 +212,11 @@ public class CCorePlugin extends Plugin {
// if factory is null, default factory must be used
if (factory == null) factory = BufferManager.getDefaultBufferManager().getDefaultBufferFactory();
Map<ITranslationUnit, IWorkingCopy> sharedWorkingCopies = CModelManager.getDefault().sharedWorkingCopies;
Map<IBufferFactory, Map<ITranslationUnit, WorkingCopy>> sharedWorkingCopies = CModelManager.getDefault().sharedWorkingCopies;
Map<ITranslationUnit, IWorkingCopy> perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(factory);
Map<ITranslationUnit, WorkingCopy> perFactoryWorkingCopies = sharedWorkingCopies.get(factory);
if (perFactoryWorkingCopies == null) return CModelManager.NoWorkingCopy;
Collection<IWorkingCopy> copies = perFactoryWorkingCopies.values();
Collection<WorkingCopy> copies = perFactoryWorkingCopies.values();
IWorkingCopy[] result = new IWorkingCopy[copies.size()];
copies.toArray(result);
return result;
@ -494,7 +495,7 @@ public class CCorePlugin extends Plugin {
for (String key : newOptions.keySet()){
if (!CModelManager.OptionNames.contains(key)) continue; // unrecognized option
if (key.equals(CORE_ENCODING)) continue; // skipped, contributed by resource prefs
String value = (String)newOptions.get(key);
String value = newOptions.get(key);
preferences.setValue(key, value);
}
@ -508,12 +509,12 @@ public class CCorePlugin extends Plugin {
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, "CBuildConsole"); //$NON-NLS-1$
if (extension != null) {
IExtension[] extensions = extension.getExtensions();
for (int i = 0; i < extensions.length; i++) {
IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
for (int j = 0; j < configElements.length; j++) {
String consoleID = configElements[j].getAttribute("id"); //$NON-NLS-1$
for (IExtension extension2 : extensions) {
IConfigurationElement[] configElements = extension2.getConfigurationElements();
for (IConfigurationElement configElement : configElements) {
String consoleID = configElement.getAttribute("id"); //$NON-NLS-1$
if ((id == null && consoleID == null) || (id != null && id.equals(consoleID))) {
return (IConsole) configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
return (IConsole) configElement.createExecutableExtension("class"); //$NON-NLS-1$
}
}
}
@ -570,9 +571,6 @@ public class CCorePlugin extends Plugin {
}
/**
* @param project
* @return
* @throws CoreException
* @deprecated - use getBinaryParserExtensions(IProject project)
*/
@Deprecated
@ -621,9 +619,9 @@ public class CCorePlugin extends Plugin {
IExtension extension = extensionPoint.getExtension(id);
if (extension != null) {
IConfigurationElement element[] = extension.getConfigurationElements();
for (int i = 0; i < element.length; i++) {
if (element[i].getName().equalsIgnoreCase("cextension")) { //$NON-NLS-1$
parser = (IBinaryParser) element[i].createExecutableExtension("run"); //$NON-NLS-1$
for (IConfigurationElement element2 : element) {
if (element2.getName().equalsIgnoreCase("cextension")) { //$NON-NLS-1$
parser = (IBinaryParser) element2.createExecutableExtension("run"); //$NON-NLS-1$
break;
}
}
@ -655,9 +653,6 @@ public class CCorePlugin extends Plugin {
}
/**
* @param project
* @return
* @throws CoreException
* @deprecated use getCProjetDescription(IProject project, boolean create)
*/
@Deprecated
@ -779,9 +774,9 @@ public class CCorePlugin extends Plugin {
ICProjectDescription projDes = createProjectDescription(projectHandle, true);
ICConfigurationDescription cfgs[] = projDes.getConfigurations();
ICConfigurationDescription cfg = null;
for(int i = 0; i < cfgs.length; i++){
if(bsId.equals(cfgs[i].getBuildSystemId())){
cfg = cfgs[i];
for (ICConfigurationDescription cfg2 : cfgs) {
if(bsId.equals(cfg2.getBuildSystemId())){
cfg = cfg2;
break;
}
}
@ -830,14 +825,7 @@ public class CCorePlugin extends Plugin {
* All checks should have been done externally
* (as in the Conversion Wizards).
* This method blindly does the conversion.
*
* @param project
* @param String targetNature
* @param monitor
* @param projectID
* @exception CoreException
*/
public void convertProjectToC(IProject projectHandle, IProgressMonitor monitor, String projectID)
throws CoreException {
if ((projectHandle == null) || (monitor == null) || (projectID == null)) {
@ -862,14 +850,7 @@ public class CCorePlugin extends Plugin {
/**
* Method to convert a project to a C++ nature
*
* @param project
* @param String targetNature
* @param monitor
* @param projectID
* @exception CoreException
*/
public void convertProjectToCC(IProject projectHandle, IProgressMonitor monitor, String projectID)
throws CoreException {
if ((projectHandle == null) || (monitor == null) || (projectID == null)) {
@ -899,14 +880,14 @@ public class CCorePlugin extends Plugin {
if (extension != null) {
IExtension[] extensions = extension.getExtensions();
IConfigurationElement defaultContributor = null;
for (int i = 0; i < extensions.length; i++) {
IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
for (int j = 0; j < configElements.length; j++) {
if (configElements[j].getName().equals("processList")) { //$NON-NLS-1$
String platform = configElements[j].getAttribute("platform"); //$NON-NLS-1$
for (IExtension extension2 : extensions) {
IConfigurationElement[] configElements = extension2.getConfigurationElements();
for (IConfigurationElement configElement : configElements) {
if (configElement.getName().equals("processList")) { //$NON-NLS-1$
String platform = configElement.getAttribute("platform"); //$NON-NLS-1$
if (platform == null ) { // first contrbutor found with not platform will be default.
if (defaultContributor == null) {
defaultContributor = configElements[j];
defaultContributor = configElement;
}
} else if (platform.equals(Platform.getOS())) {
// found explicit contributor for this platform.
@ -925,7 +906,6 @@ public class CCorePlugin extends Plugin {
/**
* Array of error parsers ids.
* @return
*/
public String[] getAllErrorParsersIDs() {
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, ERROR_PARSER_SIMPLE_ID);
@ -1072,7 +1052,7 @@ public class CCorePlugin extends Plugin {
}
/**
* this method is a full equivalent to {@link #createProjectDescription(IProject, boolean, false)}
* this method is a full equivalent to <code>createProjectDescription(IProject, boolean, false)</code>.
*
* @see #createProjectDescription(IProject, boolean, boolean)
*/
@ -1126,7 +1106,7 @@ public class CCorePlugin extends Plugin {
* @param des
* @throws CoreException
*
* @see {@link #getProjectDescription(IProject, boolean)}
* @see #getProjectDescription(IProject, boolean)
* @see #createProjectDescription(IProject, boolean)
*/
public void setProjectDescription(IProject project, ICProjectDescription des) throws CoreException {
@ -1183,8 +1163,6 @@ public class CCorePlugin extends Plugin {
/**
* Answers whether the given project is a new-style project, i.e. CConfigurationDataProvider-driven
* @param project
* @return
*/
public boolean isNewStyleProject(IProject project){
return fNewCProjectDescriptionManager.isNewStyleProject(project);
@ -1192,8 +1170,6 @@ public class CCorePlugin extends Plugin {
/**
* Answers whether the given project is a new-style project, i.e. CConfigurationDataProvider-driven
* @param des
* @return
*/
public boolean isNewStyleProject(ICProjectDescription des){
return fNewCProjectDescriptionManager.isNewStyleProject(des);

View file

@ -19,7 +19,6 @@ import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.internal.core.util.ILRUCacheable;
import org.eclipse.cdt.internal.core.util.LRUCache;
import org.eclipse.cdt.internal.core.util.OverflowingLRUCache;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
@ -77,9 +76,6 @@ public class CodeReaderCache implements ICodeReaderCache {
/**
* Create a RemoveCacheJob used to run as a separate thread to remove a CodeReader from the cache.
* @param cache
* @param event
* @param mutex
*/
public RemoveCacheJob(ICodeReaderCache cache, IResourceChangeEvent event) {
super(REMOVE_CACHE);
@ -97,11 +93,11 @@ public class CodeReaderCache implements ICodeReaderCache {
}
private void removeKeys(IResourceDelta[] deltas) {
for(int j=0; j<deltas.length; j++) {
if (deltas[j].getResource().getType() == IResource.PROJECT || deltas[j].getResource().getType() == IResource.FOLDER) {
removeKeys(deltas[j].getAffectedChildren());
} else if (deltas[j].getResource() instanceof IFile && ((IFile)deltas[j].getResource()).getLocation() != null) {
removeKey(((IFile)deltas[j].getResource()).getLocation().toOSString());
for (IResourceDelta delta : deltas) {
if (delta.getResource().getType() == IResource.PROJECT || delta.getResource().getType() == IResource.FOLDER) {
removeKeys(delta.getAffectedChildren());
} else if (delta.getResource() instanceof IFile && ((IFile)delta.getResource()).getLocation() != null) {
removeKey(((IFile)delta.getResource()).getLocation().toOSString());
}
}
}
@ -142,7 +138,6 @@ public class CodeReaderCache implements ICodeReaderCache {
/**
* Get a CodeReader from the cache. The key is the char[] filename of the CodeReader to retrieve.
* @param key the path of the CodeReader to retrieve
* @return
*/
public synchronized CodeReader get(String key) {
CodeReader ret = null;
@ -189,6 +184,37 @@ public class CodeReaderCache implements ICodeReaderCache {
cache.setSpaceLimit(size * MB_TO_KB_FACTOR);
}
/**
* This is a wrapper for entries to put into the OverflowingLRUCache (required to determine the
* size of entries relative to the CodeReader's file size).
*
* Although the size of the CodeReaderCache is specified in terms of MB, the actual granularity of
* the cache is KB.
*
* @author dsteffle
*
*/
private class CodeReaderCacheEntry implements ILRUCacheable {
private static final double CHAR_TO_KB_FACTOR = 1024;
CodeReader reader = null;
int size = 0; // used to specify the size of the CodeReader in terms of KB
public CodeReaderCacheEntry(CodeReader value) {
this.reader = value;
size = (int)Math.ceil(reader.buffer.length / CHAR_TO_KB_FACTOR); // get the size of the file in terms of KB
}
public int getCacheFootprint() {
return size;
}
public CodeReader getCodeReader() {
return reader;
}
}
/**
* This class is a wrapper/implementor class for OverflowingLRUCache.
*
@ -198,37 +224,8 @@ public class CodeReaderCache implements ICodeReaderCache {
* @author dsteffle
*
*/
private class CodeReaderLRUCache extends OverflowingLRUCache {
private class CodeReaderLRUCache extends OverflowingLRUCache<String, CodeReaderCacheEntry> {
/**
* This is a wrapper for entries to put into the OverflowingLRUCache (required to determine the
* size of entries relative to the CodeReader's file size).
*
* Although the size of the CodeReaderCache is specified in terms of MB, the actual granularity of
* the cache is KB.
*
* @author dsteffle
*
*/
private class CodeReaderCacheEntry implements ILRUCacheable {
private static final double CHAR_TO_KB_FACTOR = 1024;
CodeReader reader = null;
int size = 0; // used to specify the size of the CodeReader in terms of KB
public CodeReaderCacheEntry(CodeReader value) {
this.reader = value;
size = (int)Math.ceil(reader.buffer.length / CHAR_TO_KB_FACTOR); // get the size of the file in terms of KB
}
public int getCacheFootprint() {
return size;
}
public CodeReader getCodeReader() {
return reader;
}
}
/**
* Creates a new CodeReaderLRUCache with a specified initial maximum size.
@ -241,7 +238,7 @@ public class CodeReaderCache implements ICodeReaderCache {
// must be overloaded, required to remove entries from the cache
@Override
protected boolean close(LRUCacheEntry entry) {
protected boolean close(LRUCacheEntry<String,CodeReaderCacheEntry> entry) {
Object obj = remove(entry._fKey);
if (obj != null)
@ -251,16 +248,15 @@ public class CodeReaderCache implements ICodeReaderCache {
}
@Override
protected LRUCache newInstance(int size, int overflow) {
protected OverflowingLRUCache<String,CodeReaderCacheEntry> newInstance(int size, int overflow) {
return null;
}
/**
* Removes an entry from the cache and returns the entry that was removed if found.
* Otherwise null is returned.
* @param key
* @return
*/
@Override
public CodeReader remove(String key) {
Object removed = removeKey(key);
@ -274,30 +270,23 @@ public class CodeReaderCache implements ICodeReaderCache {
* Puts a CodeReader into the cache by wrapping it with a CodeReaderCacheEntry first.
* This way the proper size of the element in the cache can be determined
* via the CodeReaderCacheEntry.
* @param key
* @param value
* @return
*/
public CodeReader put(Object key, CodeReader value) {
Object entry = new CodeReaderCacheEntry(value);
Object ret = put(key, entry);
if (ret instanceof CodeReaderCacheEntry)
return ((CodeReaderCacheEntry)ret).getCodeReader();
public CodeReader put(String key, CodeReader value) {
CodeReaderCacheEntry entry = new CodeReaderCacheEntry(value);
CodeReaderCacheEntry ret = put(key, entry);
if (ret != null)
return ret.getCodeReader();
return null;
}
/**
* Retrieves a CodeReader from the cache corresponding to the path specified by the key.
* @param key
* @return
*/
public CodeReader get(String key) {
Object obj = peek(key);
if (obj instanceof CodeReaderCacheEntry)
return ((CodeReaderCacheEntry)obj).getCodeReader();
CodeReaderCacheEntry obj = peek(key);
if (obj != null)
return obj.getCodeReader();
return null;
}
@ -320,7 +309,6 @@ public class CodeReaderCache implements ICodeReaderCache {
/**
* Returns the current size of the cache. For the CodeReaderCache this is in MB.
* @return
*/
public int getCurrentSpace() {
return cache.getCurrentSpace();

View file

@ -72,7 +72,7 @@ public class ScalabilityPreferencePage extends PreferencePage implements
public ScalabilityPreferencePage() {
setPreferenceStore(PreferenceConstants.getPreferenceStore());
setDescription(PreferencesMessages.ScalabilityPreferencePage_description);
setDescription(PreferencesMessages.ScalabilityPreferencePage_description);
}
/**
@ -104,7 +104,7 @@ public class ScalabilityPreferencePage extends PreferencePage implements
SelectionListener listener= (SelectionListener)iter.next();
listener.widgetSelected(null);
}
fLinesToTrigger.setStringValue(Integer.toString(prefs.getInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES)));
fLinesToTrigger.setStringValue(Integer.toString(prefs.getInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES)));
}
/*
@ -114,7 +114,7 @@ public class ScalabilityPreferencePage extends PreferencePage implements
public void createControl(Composite parent) {
super.createControl(parent);
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.SCALABILITY_PREFERENCE_PAGE);
}
}
/*
* @see PreferencePage#createContents(Composite)
@ -138,14 +138,14 @@ public class ScalabilityPreferencePage extends PreferencePage implements
createDetectionSettings(composite);
new Separator().doFillIntoGrid(composite, nColumns);
new Separator().doFillIntoGrid(composite, nColumns);
createScalabilityModeSettings(composite);
new Separator().doFillIntoGrid(composite, nColumns);
new Separator().doFillIntoGrid(composite, nColumns);
String noteTitle= PreferencesMessages.ScalabilityPreferencePage_note;
String noteMessage= PreferencesMessages.ScalabilityPreferencePage_preferenceOnlyForNewViews;
String noteMessage= PreferencesMessages.ScalabilityPreferencePage_preferenceOnlyForNewViews;
Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), composite, noteTitle, noteMessage);
GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan= 2;
@ -196,7 +196,7 @@ public class ScalabilityPreferencePage extends PreferencePage implements
fLinesToTrigger.setValidRange( 1, Integer.MAX_VALUE );
String minValue = Integer.toString( 1 );
String maxValue = Integer.toString( Integer.MAX_VALUE );
fLinesToTrigger.setErrorMessage( MessageFormat.format(PreferencesMessages.ScalabilityPreferencePage_error, new Object[]{ minValue, maxValue } ) );
fLinesToTrigger.setErrorMessage( MessageFormat.format(PreferencesMessages.ScalabilityPreferencePage_error, minValue, maxValue) );
fLinesToTrigger.load();
fLinesToTrigger.setPropertyChangeListener( new IPropertyChangeListener() {
@ -222,7 +222,7 @@ public class ScalabilityPreferencePage extends PreferencePage implements
private static void indent(Control control) {
GridData gridData= new GridData();
gridData.horizontalIndent= 20;
control.setLayoutData(gridData);
control.setLayoutData(gridData);
}
private void createDependency(final Button master, String masterKey, final Control slave) {
@ -269,7 +269,7 @@ public class ScalabilityPreferencePage extends PreferencePage implements
prefs.setValue(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES, fLinesToTrigger.getIntValue());
CUIPlugin.getDefault().savePluginPreferences();
return super.performOk();
}
}
/*
* @see PreferencePage#performDefaults()
@ -291,6 +291,6 @@ public class ScalabilityPreferencePage extends PreferencePage implements
SelectionListener listener= (SelectionListener)iter.next();
listener.widgetSelected(null);
}
fLinesToTrigger.setStringValue(Integer.toString(prefs.getDefaultInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES)));
fLinesToTrigger.setStringValue(Integer.toString(prefs.getDefaultInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES)));
}
}