mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
Fix warnings.
This commit is contained in:
parent
6875e287df
commit
8085a45d44
79 changed files with 728 additions and 893 deletions
|
@ -59,10 +59,6 @@ public abstract class APathEntry extends PathEntry {
|
||||||
return basePath;
|
return basePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public IPath getBaseReference() {
|
public IPath getBaseReference() {
|
||||||
return baseRef;
|
return baseRef;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class ASTCache {
|
||||||
/**
|
/**
|
||||||
* Do something with an AST.
|
* Do something with an AST.
|
||||||
*
|
*
|
||||||
* @see #runOnAST(IASTTranslationUnit)
|
* @see #runOnAST(ILanguage, IASTTranslationUnit)
|
||||||
*/
|
*/
|
||||||
public static interface ASTRunnable {
|
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
|
* provided by this cache for the given translation unit. Handles acquiring
|
||||||
* and releasing the index read-lock for the client.
|
* and releasing the index read-lock for the client.
|
||||||
*
|
*
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class Archive extends Openable implements IArchive {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 {
|
throws CModelException {
|
||||||
return computeChildren(info, underlyingResource);
|
return computeChildren(info, underlyingResource);
|
||||||
}
|
}
|
||||||
|
@ -76,8 +76,7 @@ public class Archive extends Openable implements IArchive {
|
||||||
IBinaryArchive ar = getBinaryArchive();
|
IBinaryArchive ar = getBinaryArchive();
|
||||||
if (ar != null) {
|
if (ar != null) {
|
||||||
IBinaryObject[] objects = ar.getObjects();
|
IBinaryObject[] objects = ar.getObjects();
|
||||||
for (int i = 0; i < objects.length; i++) {
|
for (final IBinaryObject obj : objects) {
|
||||||
final IBinaryObject obj = objects[i];
|
|
||||||
Binary binary = new Binary(this, ar.getPath().append(obj.getName()), obj);
|
Binary binary = new Binary(this, ar.getPath().append(obj.getName()), obj);
|
||||||
info.addChild(binary);
|
info.addChild(binary);
|
||||||
}
|
}
|
||||||
|
@ -90,6 +89,7 @@ public class Archive extends Openable implements IArchive {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public Object getAdapter(Class adapter) {
|
public Object getAdapter(Class adapter) {
|
||||||
if (IBinaryArchive.class.equals(adapter)) {
|
if (IBinaryArchive.class.equals(adapter)) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.IArchive;
|
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)
|
* @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
|
@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 {
|
throws CModelException {
|
||||||
// this will bootstrap/start the runner for the project.
|
// this will bootstrap/start the runner for the project.
|
||||||
CModelManager.getDefault().getBinaryRunner(getCProject());
|
CModelManager.getDefault().getBinaryRunner(getCProject());
|
||||||
|
|
|
@ -198,6 +198,7 @@ public class Binary extends Openable implements IBinary {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public Object getAdapter(Class adapter) {
|
public Object getAdapter(Class adapter) {
|
||||||
if (IBinaryObject.class.equals(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)
|
* @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
|
@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 {
|
throws CModelException {
|
||||||
return computeChildren(info, underlyingResource);
|
return computeChildren(info, underlyingResource);
|
||||||
}
|
}
|
||||||
|
@ -265,7 +266,7 @@ public class Binary extends Openable implements IBinary {
|
||||||
boolean computeChildren(OpenableInfo info, IResource res) throws CModelException {
|
boolean computeChildren(OpenableInfo info, IResource res) throws CModelException {
|
||||||
boolean ok = false;
|
boolean ok = false;
|
||||||
if (isObject() || isExecutable() || isSharedLib()) {
|
if (isObject() || isExecutable() || isSharedLib()) {
|
||||||
Map hash = new HashMap();
|
Map<IPath, BinaryModule> hash = new HashMap<IPath, BinaryModule>();
|
||||||
IBinaryObject obj = getBinaryObject();
|
IBinaryObject obj = getBinaryObject();
|
||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
// First check if we can get the list of source
|
// 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))
|
!addSourceFiles(info, obj, hash))
|
||||||
{
|
{
|
||||||
ISymbol[] symbols = obj.getSymbols();
|
ISymbol[] symbols = obj.getSymbols();
|
||||||
for (int i = 0; i < symbols.length; i++) {
|
for (ISymbol symbol : symbols) {
|
||||||
switch (symbols[i].getType()) {
|
switch (symbol.getType()) {
|
||||||
case ISymbol.FUNCTION :
|
case ISymbol.FUNCTION :
|
||||||
addFunction(info, symbols[i], hash);
|
addFunction(info, symbol, hash);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ISymbol.VARIABLE :
|
case ISymbol.VARIABLE :
|
||||||
addVariable(info, symbols[i], hash);
|
addVariable(info, symbol, hash);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,7 +296,7 @@ public class Binary extends Openable implements IBinary {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean addSourceFiles(OpenableInfo info, IBinaryObject obj,
|
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
|
// Try to get the list of source files used to build the binary from the
|
||||||
// symbol information.
|
// symbol information.
|
||||||
|
|
||||||
|
@ -305,18 +306,7 @@ public class Binary extends Openable implements IBinary {
|
||||||
|
|
||||||
String[] sourceFiles = symbolreader.getSourceFiles();
|
String[] sourceFiles = symbolreader.getSourceFiles();
|
||||||
if (sourceFiles != null && sourceFiles.length > 0) {
|
if (sourceFiles != null && sourceFiles.length > 0) {
|
||||||
for (int i = 0; i < sourceFiles.length; i++) {
|
for (String filename : sourceFiles) {
|
||||||
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.
|
|
||||||
|
|
||||||
if (filename.startsWith(".")) { //$NON-NLS-1$
|
if (filename.startsWith(".")) { //$NON-NLS-1$
|
||||||
filename = obj.getPath().removeLastSegments(1).append(filename).toOSString();
|
filename = obj.getPath().removeLastSegments(1).append(filename).toOSString();
|
||||||
}
|
}
|
||||||
|
@ -341,9 +331,9 @@ public class Binary extends Openable implements IBinary {
|
||||||
.getWorkspace().getRoot()
|
.getWorkspace().getRoot()
|
||||||
.findFilesForLocation(new Path(filename));
|
.findFilesForLocation(new Path(filename));
|
||||||
|
|
||||||
for (int j = 0; j < filesInWP.length; j++) {
|
for (IFile element : filesInWP) {
|
||||||
if (filesInWP[j].isAccessible()) {
|
if (element.isAccessible()) {
|
||||||
wkspFile = filesInWP[j];
|
wkspFile = element;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,14 +352,14 @@ public class Binary extends Openable implements IBinary {
|
||||||
return false;
|
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();
|
IPath filename= symbol.getFilename();
|
||||||
BinaryFunction function = null;
|
BinaryFunction function = null;
|
||||||
|
|
||||||
if (filename != null && !filename.isEmpty()) {
|
if (filename != null && !filename.isEmpty()) {
|
||||||
BinaryModule module = null;
|
BinaryModule module = null;
|
||||||
if (hash.containsKey(filename)) {
|
if (hash.containsKey(filename)) {
|
||||||
module = (BinaryModule)hash.get(filename);
|
module = hash.get(filename);
|
||||||
} else {
|
} else {
|
||||||
// A special container we do not want the file to be parse.
|
// A special container we do not want the file to be parse.
|
||||||
module = new BinaryModule(this, filename);
|
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();
|
IPath filename= symbol.getFilename();
|
||||||
BinaryVariable variable = null;
|
BinaryVariable variable = null;
|
||||||
if (filename != null && !filename.isEmpty()) {
|
if (filename != null && !filename.isEmpty()) {
|
||||||
BinaryModule module = null;
|
BinaryModule module = null;
|
||||||
if (hash.containsKey(filename)) {
|
if (hash.containsKey(filename)) {
|
||||||
module = (BinaryModule)hash.get(filename);
|
module = hash.get(filename);
|
||||||
} else {
|
} else {
|
||||||
module = new BinaryModule(this, filename);
|
module = new BinaryModule(this, filename);
|
||||||
hash.put(filename, module);
|
hash.put(filename, module);
|
||||||
|
|
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
|
@ -40,10 +41,10 @@ public class BinaryContainer extends Openable implements IBinaryContainer {
|
||||||
public IBinary[] getBinaries() throws CModelException {
|
public IBinary[] getBinaries() throws CModelException {
|
||||||
sync();
|
sync();
|
||||||
ICElement[] e = getChildren();
|
ICElement[] e = getChildren();
|
||||||
ArrayList list = new ArrayList(e.length);
|
ArrayList<IBinary> list = new ArrayList<IBinary>(e.length);
|
||||||
for (int i = 0; i < e.length; i++) {
|
for (ICElement element : e) {
|
||||||
if (e[i] instanceof IBinary) {
|
if (element instanceof IBinary) {
|
||||||
IBinary bin = (IBinary)e[i];
|
IBinary bin = (IBinary)element;
|
||||||
if (bin.showInBinaryContainer()) {
|
if (bin.showInBinaryContainer()) {
|
||||||
list.add(bin);
|
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)
|
* @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
|
@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 {
|
throws CModelException {
|
||||||
// this will bootstrap/start the runner for the project.
|
// this will bootstrap/start the runner for the project.
|
||||||
CModelManager.getDefault().getBinaryRunner(getCProject());
|
CModelManager.getDefault().getBinaryRunner(getCProject());
|
||||||
|
|
|
@ -175,58 +175,34 @@ public class BinaryElement extends CElement implements IBinaryElement, ISourceMa
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: This should be in the info
|
|
||||||
* @param line
|
|
||||||
*/
|
|
||||||
public void setLines(int startline, int endLine) {
|
public void setLines(int startline, int endLine) {
|
||||||
fStartLine = startline;
|
fStartLine = startline;
|
||||||
fEndLine = endLine;
|
fEndLine = endLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: This should be in the info
|
|
||||||
* @param line
|
|
||||||
*/
|
|
||||||
public int getStartLine() {
|
public int getStartLine() {
|
||||||
return fStartLine;
|
return fStartLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: This should be in the info
|
|
||||||
* @param line
|
|
||||||
*/
|
|
||||||
public int getEndLine() {
|
public int getEndLine() {
|
||||||
return fEndLine;
|
return fEndLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private int getLength() {
|
private int getLength() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getStartPos() {
|
public int getStartPos() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private int getIdLength() {
|
private int getIdLength() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public int getIdStartPos() {
|
public int getIdStartPos() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return 0;
|
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)
|
* @see org.eclipse.cdt.internal.core.model.CElement#generateInfos(java.lang.Object, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
@Override
|
@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
|
@Override
|
||||||
|
|
|
@ -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)
|
* @see org.eclipse.cdt.internal.core.model.CElement#generateInfos(java.lang.Object, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
@Override
|
@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);
|
newElements.put(this, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,8 +73,8 @@ public class BinaryRunner {
|
||||||
ICElement[] children = container.getChildren();
|
ICElement[] children = container.getChildren();
|
||||||
if (children.length > 0) {
|
if (children.length > 0) {
|
||||||
cdelta.added((ICElement)container);
|
cdelta.added((ICElement)container);
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (ICElement element : children) {
|
||||||
cdelta.added(children[i]);
|
cdelta.added(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ public class BinaryRunner {
|
||||||
String name = proxy.getName();
|
String name = proxy.getName();
|
||||||
IContentType contentType = CCorePlugin.getContentType(project, name);
|
IContentType contentType = CCorePlugin.getContentType(project, name);
|
||||||
if (contentType != null && textContentType != null) {
|
if (contentType != null && textContentType != null) {
|
||||||
if (contentType != null && contentType.isKindOf(textContentType)) {
|
if (contentType.isKindOf(textContentType)) {
|
||||||
return true;
|
return true;
|
||||||
} else if (textContentType.isAssociatedWith(name)) {
|
} else if (textContentType.isAssociatedWith(name)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -219,7 +219,7 @@ public class BinaryRunner {
|
||||||
CModelManager factory = CModelManager.getDefault();
|
CModelManager factory = CModelManager.getDefault();
|
||||||
IBinaryFile bin = factory.createBinaryFile(file);
|
IBinaryFile bin = factory.createBinaryFile(file);
|
||||||
if (bin != null) {
|
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);
|
factory.create(file, bin, cproject);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class Buffer implements IBuffer {
|
||||||
protected IFile file;
|
protected IFile file;
|
||||||
protected int flags;
|
protected int flags;
|
||||||
protected char[] contents;
|
protected char[] contents;
|
||||||
protected ArrayList changeListeners;
|
protected ArrayList<IBufferChangedListener> changeListeners;
|
||||||
protected IOpenable owner;
|
protected IOpenable owner;
|
||||||
protected int gapStart= -1;
|
protected int gapStart= -1;
|
||||||
protected int gapEnd= -1;
|
protected int gapEnd= -1;
|
||||||
|
@ -63,14 +63,14 @@ public class Buffer implements IBuffer {
|
||||||
*/
|
*/
|
||||||
public void addBufferChangedListener(IBufferChangedListener listener) {
|
public void addBufferChangedListener(IBufferChangedListener listener) {
|
||||||
if (this.changeListeners == null) {
|
if (this.changeListeners == null) {
|
||||||
this.changeListeners = new ArrayList(5);
|
this.changeListeners = new ArrayList<IBufferChangedListener>(5);
|
||||||
}
|
}
|
||||||
if (!this.changeListeners.contains(listener)) {
|
if (!this.changeListeners.contains(listener)) {
|
||||||
this.changeListeners.add(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) {
|
public void append(char[] text) {
|
||||||
if (!isReadOnly()) {
|
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) {
|
public void append(String text) {
|
||||||
if (text == null) {
|
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() {
|
public void close() {
|
||||||
BufferChangedEvent event = null;
|
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) {
|
public char getChar(int position) {
|
||||||
synchronized (this.lock) {
|
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() {
|
public char[] getCharacters() {
|
||||||
if (this.contents == null) return null;
|
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() {
|
public String getContents() {
|
||||||
if (this.contents == null) return null;
|
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() {
|
public int getLength() {
|
||||||
synchronized (this.lock) {
|
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() {
|
public IOpenable getOwner() {
|
||||||
return this.owner;
|
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) {
|
public String getText(int offset, int length) {
|
||||||
if (this.contents == null)
|
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() {
|
public IResource getUnderlyingResource() {
|
||||||
return this.file;
|
return this.file;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.model.IBuffer#hasUnsavedChanges()
|
* @see org.eclipse.cdt.core.model.IBuffer#hasUnsavedChanges()
|
||||||
*/
|
*/
|
||||||
public boolean hasUnsavedChanges() {
|
public boolean hasUnsavedChanges() {
|
||||||
return (this.flags & F_HAS_UNSAVED_CHANGES) != 0;
|
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() {
|
public boolean isClosed() {
|
||||||
return (this.flags & F_IS_CLOSED) != 0;
|
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() {
|
public boolean isReadOnly() {
|
||||||
if (this.file == null) {
|
if (this.file == null) {
|
||||||
|
@ -225,7 +225,7 @@ public class Buffer implements IBuffer {
|
||||||
protected void notifyChanged(final BufferChangedEvent event) {
|
protected void notifyChanged(final BufferChangedEvent event) {
|
||||||
if (this.changeListeners != null) {
|
if (this.changeListeners != null) {
|
||||||
for (int i = 0, size = this.changeListeners.size(); i < size; ++i) {
|
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() {
|
SafeRunner.run(new ISafeRunnable() {
|
||||||
public void handleException(Throwable exception) {
|
public void handleException(Throwable exception) {
|
||||||
Util.log(exception, "Exception occurred in listener of buffer change notification", ICLogConstants.CDT); //$NON-NLS-1$
|
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) {
|
public void replace(int position, int length, char[] text) {
|
||||||
if (!isReadOnly()) {
|
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) {
|
public void replace(int position, int length, String text) {
|
||||||
this.replace(position, length, text == null ? null : text.toCharArray());
|
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)
|
public void save(IProgressMonitor progress, boolean force)
|
||||||
throws CModelException {
|
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) {
|
public void setContents(char[] newContents) {
|
||||||
// allow special case for first initialization
|
// 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) {
|
public void setContents(String newContents) {
|
||||||
this.setContents(newContents.toCharArray());
|
this.setContents(newContents.toCharArray());
|
||||||
|
|
|
@ -16,7 +16,6 @@ import java.util.Enumeration;
|
||||||
import org.eclipse.cdt.core.model.IBuffer;
|
import org.eclipse.cdt.core.model.IBuffer;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IOpenable;
|
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.cdt.internal.core.util.OverflowingLRUCache;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
@ -32,7 +31,7 @@ public class BufferManager implements IBufferFactory {
|
||||||
/**
|
/**
|
||||||
* An LRU cache of <code>IBuffers</code>.
|
* 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.
|
* Constructs a new buffer cache of the given size.
|
||||||
*/
|
*/
|
||||||
|
@ -53,8 +52,8 @@ public class BufferManager implements IBufferFactory {
|
||||||
* by closing the buffer.
|
* by closing the buffer.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected boolean close(LRUCacheEntry entry) {
|
protected boolean close(LRUCacheEntry<K,IBuffer> entry) {
|
||||||
IBuffer buffer= (IBuffer) entry._fValue;
|
IBuffer buffer= entry._fValue;
|
||||||
if (buffer.hasUnsavedChanges()) {
|
if (buffer.hasUnsavedChanges()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -65,8 +64,8 @@ public class BufferManager implements IBufferFactory {
|
||||||
* Returns a new instance of the reciever.
|
* Returns a new instance of the reciever.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected LRUCache newInstance(int size, int overflow) {
|
protected OverflowingLRUCache<K, IBuffer> newInstance(int size, int overflow) {
|
||||||
return new BufferCache(size, 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
|
* LRU cache of buffers. The key and value for an entry
|
||||||
* in the table is the identical buffer.
|
* 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.
|
* Creates a new buffer manager.
|
||||||
|
@ -135,7 +134,7 @@ public class BufferManager implements IBufferFactory {
|
||||||
* @see OverflowingLRUCache
|
* @see OverflowingLRUCache
|
||||||
* @return Enumeration of IBuffer
|
* @return Enumeration of IBuffer
|
||||||
*/
|
*/
|
||||||
public Enumeration getOpenBuffers() {
|
public Enumeration<IBuffer> getOpenBuffers() {
|
||||||
synchronized (openBuffers) {
|
synchronized (openBuffers) {
|
||||||
openBuffers.shrink();
|
openBuffers.shrink();
|
||||||
return openBuffers.elements();
|
return openBuffers.elements();
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class CContainer extends Openable implements ICContainer {
|
||||||
* @see ICContainer#getBinaries()
|
* @see ICContainer#getBinaries()
|
||||||
*/
|
*/
|
||||||
public IBinary[] getBinaries() throws CModelException {
|
public IBinary[] getBinaries() throws CModelException {
|
||||||
List list = getChildrenOfType(C_BINARY);
|
List<?> list = getChildrenOfType(C_BINARY);
|
||||||
IBinary[] array = new IBinary[list.size()];
|
IBinary[] array = new IBinary[list.size()];
|
||||||
list.toArray(array);
|
list.toArray(array);
|
||||||
return array;
|
return array;
|
||||||
|
@ -82,7 +82,7 @@ public class CContainer extends Openable implements ICContainer {
|
||||||
* @see ICContainer#getArchives()
|
* @see ICContainer#getArchives()
|
||||||
*/
|
*/
|
||||||
public IArchive[] getArchives() throws CModelException {
|
public IArchive[] getArchives() throws CModelException {
|
||||||
List list = getChildrenOfType(C_ARCHIVE);
|
List<?> list = getChildrenOfType(C_ARCHIVE);
|
||||||
IArchive[] array = new IArchive[list.size()];
|
IArchive[] array = new IArchive[list.size()];
|
||||||
list.toArray(array);
|
list.toArray(array);
|
||||||
return array;
|
return array;
|
||||||
|
@ -108,7 +108,7 @@ public class CContainer extends Openable implements ICContainer {
|
||||||
* @see ICContainer#getTranslationUnits()
|
* @see ICContainer#getTranslationUnits()
|
||||||
*/
|
*/
|
||||||
public ITranslationUnit[] getTranslationUnits() throws CModelException {
|
public ITranslationUnit[] getTranslationUnits() throws CModelException {
|
||||||
List list = getChildrenOfType(C_UNIT);
|
List<?> list = getChildrenOfType(C_UNIT);
|
||||||
ITranslationUnit[] array = new ITranslationUnit[list.size()];
|
ITranslationUnit[] array = new ITranslationUnit[list.size()];
|
||||||
list.toArray(array);
|
list.toArray(array);
|
||||||
return array;
|
return array;
|
||||||
|
@ -135,7 +135,7 @@ public class CContainer extends Openable implements ICContainer {
|
||||||
* @see org.eclipse.cdt.core.model.ICContainer#getCContainers()
|
* @see org.eclipse.cdt.core.model.ICContainer#getCContainers()
|
||||||
*/
|
*/
|
||||||
public ICContainer[] getCContainers() throws CModelException {
|
public ICContainer[] getCContainers() throws CModelException {
|
||||||
List list = getChildrenOfType(C_CCONTAINER);
|
List<?> list = getChildrenOfType(C_CCONTAINER);
|
||||||
ICContainer[] array = new ICContainer[list.size()];
|
ICContainer[] array = new ICContainer[list.size()];
|
||||||
list.toArray(array);
|
list.toArray(array);
|
||||||
return array;
|
return array;
|
||||||
|
@ -174,7 +174,7 @@ public class CContainer extends Openable implements ICContainer {
|
||||||
* @see Openable
|
* @see Openable
|
||||||
*/
|
*/
|
||||||
@Override
|
@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 {
|
throws CModelException {
|
||||||
boolean validInfo = false;
|
boolean validInfo = false;
|
||||||
try {
|
try {
|
||||||
|
@ -203,7 +203,7 @@ public class CContainer extends Openable implements ICContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException {
|
protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException {
|
||||||
ArrayList vChildren = new ArrayList();
|
ArrayList<ICElement> vChildren = new ArrayList<ICElement>();
|
||||||
try {
|
try {
|
||||||
IResource[] resources = null;
|
IResource[] resources = null;
|
||||||
if (res instanceof IContainer) {
|
if (res instanceof IContainer) {
|
||||||
|
@ -212,8 +212,8 @@ public class CContainer extends Openable implements ICContainer {
|
||||||
}
|
}
|
||||||
if (resources != null) {
|
if (resources != null) {
|
||||||
ICProject cproject = getCProject();
|
ICProject cproject = getCProject();
|
||||||
for (int i = 0; i < resources.length; i++) {
|
for (IResource resource2 : resources) {
|
||||||
ICElement celement = computeChild(resources[i], cproject);
|
ICElement celement = computeChild(resource2, cproject);
|
||||||
if (celement != null) {
|
if (celement != null) {
|
||||||
vChildren.add(celement);
|
vChildren.add(celement);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,15 +39,11 @@ public class CContainerInfo extends OpenableInfo {
|
||||||
super(element);
|
super(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param container
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Object[] getNonCResources(IResource res) {
|
public Object[] getNonCResources(IResource res) {
|
||||||
if (nonCResources != null)
|
if (nonCResources != null)
|
||||||
return nonCResources;
|
return nonCResources;
|
||||||
|
|
||||||
ArrayList notChildren = new ArrayList();
|
ArrayList<IResource> notChildren = new ArrayList<IResource>();
|
||||||
ICElement celement = getElement();
|
ICElement celement = getElement();
|
||||||
ICProject cproject = celement.getCProject();
|
ICProject cproject = celement.getCProject();
|
||||||
// move back to the sourceroot.
|
// move back to the sourceroot.
|
||||||
|
@ -76,8 +72,7 @@ public class CContainerInfo extends OpenableInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resources != null) {
|
if (resources != null) {
|
||||||
for (int i = 0; i < resources.length; i++) {
|
for (IResource member : resources) {
|
||||||
IResource member = resources[i];
|
|
||||||
switch(member.getType()) {
|
switch(member.getType()) {
|
||||||
case IResource.FOLDER: {
|
case IResource.FOLDER: {
|
||||||
// Check if the folder is not itself a sourceEntry.
|
// Check if the folder is not itself a sourceEntry.
|
||||||
|
@ -113,10 +108,6 @@ public class CContainerInfo extends OpenableInfo {
|
||||||
return nonCResources;
|
return nonCResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param container
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void setNonCResources(Object[] resources) {
|
public void setNonCResources(Object[] resources) {
|
||||||
nonCResources = resources;
|
nonCResources = resources;
|
||||||
}
|
}
|
||||||
|
@ -125,9 +116,8 @@ public class CContainerInfo extends OpenableInfo {
|
||||||
if(entries == null)
|
if(entries == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int k = 0; k < entries.length; k++) {
|
for (ICSourceEntry entry : entries) {
|
||||||
ICSourceEntry entry = entries[k];
|
// if (entry.getEntryKind() == IPathEntry.CDT_SOURCE) {
|
||||||
// if (entry.getEntryKind() == IPathEntry.CDT_SOURCE) {
|
|
||||||
IPath sourcePath = entry.getFullPath();
|
IPath sourcePath = entry.getFullPath();
|
||||||
if (resourcePath.equals(sourcePath)) {
|
if (resourcePath.equals(sourcePath)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -16,7 +16,6 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -73,6 +72,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
|
* @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public Object getAdapter(Class adapter) {
|
public Object getAdapter(Class adapter) {
|
||||||
// handle all kinds of resources
|
// handle all kinds of resources
|
||||||
|
@ -153,10 +153,9 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
||||||
protected ICElement getSourceElementAtOffset(int offset) throws CModelException {
|
protected ICElement getSourceElementAtOffset(int offset) throws CModelException {
|
||||||
if (this instanceof ISourceReference && this instanceof Parent) {
|
if (this instanceof ISourceReference && this instanceof Parent) {
|
||||||
ICElement[] children = ((Parent)this).getChildren();
|
ICElement[] children = ((Parent)this).getChildren();
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (ICElement aChild : children) {
|
||||||
ICElement aChild = children[i];
|
|
||||||
if (aChild instanceof ISourceReference) {
|
if (aChild instanceof ISourceReference) {
|
||||||
ISourceReference child = (ISourceReference) children[i];
|
ISourceReference child = (ISourceReference) aChild;
|
||||||
ISourceRange range = child.getSourceRange();
|
ISourceRange range = child.getSourceRange();
|
||||||
int startPos = range.getStartPos();
|
int startPos = range.getStartPos();
|
||||||
int endPos = startPos + range.getLength();
|
int endPos = startPos + range.getLength();
|
||||||
|
@ -184,12 +183,11 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
||||||
*/
|
*/
|
||||||
protected ICElement[] getSourceElementsAtOffset(int offset) throws CModelException {
|
protected ICElement[] getSourceElementsAtOffset(int offset) throws CModelException {
|
||||||
if (this instanceof ISourceReference && this instanceof Parent) {
|
if (this instanceof ISourceReference && this instanceof Parent) {
|
||||||
ArrayList list = new ArrayList();
|
ArrayList<Object> list = new ArrayList<Object>();
|
||||||
ICElement[] children = ((Parent)this).getChildren();
|
ICElement[] children = ((Parent)this).getChildren();
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (ICElement aChild : children) {
|
||||||
ICElement aChild = children[i];
|
|
||||||
if (aChild instanceof ISourceReference) {
|
if (aChild instanceof ISourceReference) {
|
||||||
ISourceReference child = (ISourceReference) children[i];
|
ISourceReference child = (ISourceReference) aChild;
|
||||||
ISourceRange range = child.getSourceRange();
|
ISourceRange range = child.getSourceRange();
|
||||||
int startPos = range.getStartPos();
|
int startPos = range.getStartPos();
|
||||||
int endPos = startPos + range.getLength();
|
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
|
* if successful, or false if an error is encountered while determining
|
||||||
* the structure of this element.
|
* 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
|
* 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();
|
CModelManager manager = CModelManager.getDefault();
|
||||||
boolean hadTemporaryCache = manager.hasTemporaryCache();
|
boolean hadTemporaryCache = manager.hasTemporaryCache();
|
||||||
try {
|
try {
|
||||||
HashMap newElements = manager.getTemporaryCache();
|
Map<ICElement, CElementInfo> newElements = manager.getTemporaryCache();
|
||||||
generateInfos(info, newElements, pm);
|
generateInfos(info, newElements, pm);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
info = (CElementInfo)newElements.get(this);
|
info = newElements.get(this);
|
||||||
}
|
}
|
||||||
if (info == null) { // a source ref element could not be opened
|
if (info == null) { // a source ref element could not be opened
|
||||||
// close any buffer that was opened for the openable parent
|
// close any buffer that was opened for the openable parent
|
||||||
Iterator iterator = newElements.keySet().iterator();
|
Iterator<ICElement> iterator = newElements.keySet().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
ICElement element = (ICElement)iterator.next();
|
ICElement element = iterator.next();
|
||||||
if (element instanceof Openable) {
|
if (element instanceof Openable) {
|
||||||
((Openable)element).closeBuffer();
|
((Openable)element).closeBuffer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,12 +39,12 @@ public class CElementDelta implements ICElementDelta {
|
||||||
private int fChangeFlags = 0;
|
private int fChangeFlags = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #getMovedFromHandle()
|
* @see #getMovedFromElement()
|
||||||
*/
|
*/
|
||||||
protected ICElement fMovedFromHandle = null;
|
protected ICElement fMovedFromHandle = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #getMovedToHandle()
|
* @see #getMovedToElement()
|
||||||
*/
|
*/
|
||||||
protected ICElement fMovedToHandle = null;
|
protected ICElement fMovedToHandle = null;
|
||||||
|
|
||||||
|
@ -171,8 +171,8 @@ public class CElementDelta implements ICElementDelta {
|
||||||
// child was changed then changed -> it is changed
|
// child was changed then changed -> it is changed
|
||||||
case CHANGED:
|
case CHANGED:
|
||||||
ICElementDelta[] children = child.getAffectedChildren();
|
ICElementDelta[] children = child.getAffectedChildren();
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (ICElementDelta element : children) {
|
||||||
CElementDelta childsChild = (CElementDelta) children[i];
|
CElementDelta childsChild = (CElementDelta) element;
|
||||||
((CElementDelta) existingChild).addAffectedChild(childsChild);
|
((CElementDelta) existingChild).addAffectedChild(childsChild);
|
||||||
}
|
}
|
||||||
// add the non-c resource deltas if needed
|
// add the non-c resource deltas if needed
|
||||||
|
@ -276,7 +276,7 @@ public class CElementDelta implements ICElementDelta {
|
||||||
*/
|
*/
|
||||||
protected CElementDelta createDeltaTree(ICElement element, CElementDelta delta) {
|
protected CElementDelta createDeltaTree(ICElement element, CElementDelta delta) {
|
||||||
CElementDelta childDelta = delta;
|
CElementDelta childDelta = delta;
|
||||||
ArrayList ancestors= getAncestors(element);
|
ArrayList<ICElement> ancestors= getAncestors(element);
|
||||||
if (ancestors == null) {
|
if (ancestors == null) {
|
||||||
if (equalsAndSameParent(delta.getElement(), getElement())) {
|
if (equalsAndSameParent(delta.getElement(), getElement())) {
|
||||||
// handle case of two jars that can be equals but not in the
|
// handle case of two jars that can be equals but not in the
|
||||||
|
@ -292,7 +292,7 @@ public class CElementDelta implements ICElementDelta {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0, size = ancestors.size(); i < size; i++) {
|
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);
|
CElementDelta ancestorDelta = new CElementDelta(ancestor);
|
||||||
ancestorDelta.addAffectedChild(childDelta);
|
ancestorDelta.addAffectedChild(childDelta);
|
||||||
childDelta = ancestorDelta;
|
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
|
if (equalsAndSameParent(fChangedElement, e)) { // handle case of two jars that can be equals but not in the same project
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < fAffectedChildren.length; i++) {
|
for (ICElementDelta element : fAffectedChildren) {
|
||||||
CElementDelta delta = ((CElementDelta)fAffectedChildren[i]).find(e);
|
CElementDelta delta = ((CElementDelta)element).find(e);
|
||||||
if (delta != null) {
|
if (delta != null) {
|
||||||
return delta;
|
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>
|
* element is not a descendant of the root of this tree, <code>null</code>
|
||||||
* is returned.
|
* is returned.
|
||||||
*/
|
*/
|
||||||
private ArrayList getAncestors(ICElement element) {
|
private ArrayList<ICElement> getAncestors(ICElement element) {
|
||||||
ICElement parent = element.getParent();
|
ICElement parent = element.getParent();
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ArrayList parents = new ArrayList();
|
ArrayList<ICElement> parents = new ArrayList<ICElement>();
|
||||||
while (!parent.equals(fChangedElement)) {
|
while (!parent.equals(fChangedElement)) {
|
||||||
parents.add(parent);
|
parents.add(parent);
|
||||||
parent = parent.getParent();
|
parent = parent.getParent();
|
||||||
|
@ -377,7 +377,7 @@ public class CElementDelta implements ICElementDelta {
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
return new ICElementDelta[] {};
|
return new ICElementDelta[] {};
|
||||||
}
|
}
|
||||||
ArrayList children= new ArrayList(length);
|
ArrayList<ICElementDelta> children= new ArrayList<ICElementDelta>(length);
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
if (fAffectedChildren[i].getKind() == type) {
|
if (fAffectedChildren[i].getKind() == type) {
|
||||||
children.add(fAffectedChildren[i]);
|
children.add(fAffectedChildren[i]);
|
||||||
|
@ -619,7 +619,7 @@ public class CElementDelta implements ICElementDelta {
|
||||||
* Returns a string representation of this delta's
|
* Returns a string representation of this delta's
|
||||||
* structure suitable for debug purposes.
|
* structure suitable for debug purposes.
|
||||||
*
|
*
|
||||||
* @see toString
|
* @see #toString()
|
||||||
*/
|
*/
|
||||||
public String toDebugString(int depth) {
|
public String toDebugString(int depth) {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
|
|
@ -47,17 +47,17 @@ public class CElementDeltaBuilder {
|
||||||
/**
|
/**
|
||||||
* The old handle to info relationships
|
* The old handle to info relationships
|
||||||
*/
|
*/
|
||||||
Map infos;
|
Map<ICElement, CElementInfo> infos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The old position info
|
* The old position info
|
||||||
*/
|
*/
|
||||||
Map oldPositions;
|
Map<ICElement, ListItem> oldPositions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The new position info
|
* The new position info
|
||||||
*/
|
*/
|
||||||
Map newPositions;
|
Map<ICElement, ListItem> newPositions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change delta
|
* Change delta
|
||||||
|
@ -67,12 +67,12 @@ public class CElementDeltaBuilder {
|
||||||
/**
|
/**
|
||||||
* List of added elements
|
* List of added elements
|
||||||
*/
|
*/
|
||||||
ArrayList added;
|
ArrayList<ICElement> added;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of removed elements
|
* List of removed elements
|
||||||
*/
|
*/
|
||||||
ArrayList removed;
|
ArrayList<ICElement> removed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Doubly linked list item
|
* 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
|
* Adds removed deltas for any handles left in the table
|
||||||
*/
|
*/
|
||||||
private void findDeletions() {
|
private void findDeletions() {
|
||||||
Iterator iter = this.infos.keySet().iterator();
|
Iterator<ICElement> iter = this.infos.keySet().iterator();
|
||||||
while(iter.hasNext()) {
|
while(iter.hasNext()) {
|
||||||
ICElement element = (ICElement)iter.next();
|
ICElement element = iter.next();
|
||||||
this.delta.removed(element);
|
this.delta.removed(element);
|
||||||
this.removed(element);
|
this.removed(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private CElementInfo getElementInfo(ICElement element) {
|
private CElementInfo getElementInfo(ICElement element) {
|
||||||
return (CElementInfo)this.infos.get(element);
|
return this.infos.get(element);
|
||||||
}
|
}
|
||||||
private ListItem getNewPosition(ICElement element) {
|
private ListItem getNewPosition(ICElement element) {
|
||||||
return (ListItem)this.newPositions.get(element);
|
return this.newPositions.get(element);
|
||||||
}
|
}
|
||||||
private ListItem getOldPosition(ICElement element) {
|
private ListItem getOldPosition(ICElement element) {
|
||||||
return (ListItem)this.oldPositions.get(element);
|
return this.oldPositions.get(element);
|
||||||
}
|
}
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
this.infos = new HashMap(20);
|
this.infos = new HashMap<ICElement, CElementInfo>(20);
|
||||||
this.oldPositions = new HashMap(20);
|
this.oldPositions = new HashMap<ICElement, ListItem>(20);
|
||||||
this.newPositions = new HashMap(20);
|
this.newPositions = new HashMap<ICElement, ListItem>(20);
|
||||||
this.putOldPosition(this.cElement, new ListItem(null, null));
|
this.putOldPosition(this.cElement, new ListItem(null, null));
|
||||||
this.putNewPosition(this.cElement, new ListItem(null, null));
|
this.putNewPosition(this.cElement, new ListItem(null, null));
|
||||||
this.delta = new CElementDelta(cElement);
|
this.delta = new CElementDelta(cElement);
|
||||||
|
@ -243,8 +243,8 @@ private void initialize() {
|
||||||
this.delta.fineGrained();
|
this.delta.fineGrained();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.added = new ArrayList(5);
|
this.added = new ArrayList<ICElement>(5);
|
||||||
this.removed = new ArrayList(5);
|
this.removed = new ArrayList<ICElement>(5);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Inserts position information for the elements into the new or old positions table
|
* Inserts position information for the elements into the new or old positions table
|
||||||
|
|
|
@ -36,11 +36,11 @@ class CElementInfo {
|
||||||
* object. This is an empty array if this element has
|
* object. This is an empty array if this element has
|
||||||
* no children.
|
* no children.
|
||||||
*/
|
*/
|
||||||
private List fChildren;
|
private List<ICElement> fChildren;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the structure of this element known
|
* Is the structure of this element known
|
||||||
* @see ICElement.isStructureKnown()
|
* @see ICElement#isStructureKnown()
|
||||||
*/
|
*/
|
||||||
protected boolean fIsStructureKnown = false;
|
protected boolean fIsStructureKnown = false;
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ class CElementInfo {
|
||||||
protected CElementInfo(CElement element) {
|
protected CElementInfo(CElement element) {
|
||||||
this.element = element;
|
this.element = element;
|
||||||
// Array list starts with size = 0
|
// Array list starts with size = 0
|
||||||
fChildren = new Vector(0);
|
fChildren = new Vector<ICElement>(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CElement getElement() {
|
protected CElement getElement() {
|
||||||
|
@ -65,11 +65,11 @@ class CElementInfo {
|
||||||
protected ICElement[] getChildren() {
|
protected ICElement[] getChildren() {
|
||||||
synchronized (fChildren) {
|
synchronized (fChildren) {
|
||||||
ICElement[] array= new ICElement[fChildren.size()];
|
ICElement[] array= new ICElement[fChildren.size()];
|
||||||
return (ICElement[]) fChildren.toArray( array );
|
return fChildren.toArray( array );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List internalGetChildren() {
|
List<ICElement> internalGetChildren() {
|
||||||
return fChildren;
|
return fChildren;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class CElementInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ICElement.isStructureKnown()
|
* @see ICElement#isStructureKnown()
|
||||||
*/
|
*/
|
||||||
protected boolean isStructureKnown() {
|
protected boolean isStructureKnown() {
|
||||||
return fIsStructureKnown;
|
return fIsStructureKnown;
|
||||||
|
@ -98,7 +98,7 @@ class CElementInfo {
|
||||||
fChildren.clear();
|
fChildren.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setChildren(List children) {
|
protected void setChildren(List<? extends ICElement> children) {
|
||||||
fChildren.addAll(children);
|
fChildren.addAll(children);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ class CElementInfo {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether the structure of this element known
|
* Sets whether the structure of this element known
|
||||||
* @see ICElement.isStructureKnown()
|
* @see ICElement#isStructureKnown()
|
||||||
*/
|
*/
|
||||||
protected void setIsStructureKnown(boolean newIsStructureKnown) {
|
protected void setIsStructureKnown(boolean newIsStructureKnown) {
|
||||||
fIsStructureKnown = newIsStructureKnown;
|
fIsStructureKnown = newIsStructureKnown;
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class CModel extends Openable implements ICModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICProject[] getCProjects() throws CModelException {
|
public ICProject[] getCProjects() throws CModelException {
|
||||||
List list = getChildrenOfType(C_PROJECT);
|
List<?> list = getChildrenOfType(C_PROJECT);
|
||||||
ICProject[] array= new ICProject[list.size()];
|
ICProject[] array= new ICProject[list.size()];
|
||||||
list.toArray(array);
|
list.toArray(array);
|
||||||
return array;
|
return array;
|
||||||
|
@ -92,10 +92,9 @@ public class CModel extends Openable implements ICModel {
|
||||||
public ICProject findCProject(IProject project) {
|
public ICProject findCProject(IProject project) {
|
||||||
try {
|
try {
|
||||||
ICProject[] projects = getOldCProjectsList();
|
ICProject[] projects = getOldCProjectsList();
|
||||||
for (int i = 0, length = projects.length; i < length; i++) {
|
for (ICProject cProject : projects) {
|
||||||
ICProject javaProject = projects[i];
|
if (project.equals(cProject.getProject())) {
|
||||||
if (project.equals(javaProject.getProject())) {
|
return cProject;
|
||||||
return javaProject;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CModelException e) {
|
} 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)
|
* @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
|
@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;
|
boolean validInfo = false;
|
||||||
try {
|
try {
|
||||||
IResource res = getResource();
|
IResource res = getResource();
|
||||||
|
@ -214,8 +213,7 @@ public class CModel extends Openable implements ICModel {
|
||||||
// determine my children
|
// determine my children
|
||||||
IWorkspaceRoot root = (IWorkspaceRoot)getResource();
|
IWorkspaceRoot root = (IWorkspaceRoot)getResource();
|
||||||
IProject[] projects = root.getProjects();
|
IProject[] projects = root.getProjects();
|
||||||
for (int i = 0, max = projects.length; i < max; i++) {
|
for (IProject project : projects) {
|
||||||
IProject project = projects[i];
|
|
||||||
if (CoreModel.hasCNature(project) || CoreModel.hasCCNature(project)) {
|
if (CoreModel.hasCNature(project) || CoreModel.hasCCNature(project)) {
|
||||||
ICProject cproject = new CProject(this, project);
|
ICProject cproject = new CProject(this, project);
|
||||||
info.addChild(cproject);
|
info.addChild(cproject);
|
||||||
|
|
|
@ -198,37 +198,33 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
||||||
// includes
|
// includes
|
||||||
final IASTPreprocessorIncludeStatement[] includeDirectives= ast.getIncludeDirectives();
|
final IASTPreprocessorIncludeStatement[] includeDirectives= ast.getIncludeDirectives();
|
||||||
Set<Include> allIncludes= new HashSet<Include>();
|
Set<Include> allIncludes= new HashSet<Include>();
|
||||||
for (int i= 0; i < includeDirectives.length; i++) {
|
for (IASTPreprocessorIncludeStatement includeDirective : includeDirectives) {
|
||||||
IASTPreprocessorIncludeStatement includeDirective= includeDirectives[i];
|
|
||||||
if (isLocalToFile(includeDirective)) {
|
if (isLocalToFile(includeDirective)) {
|
||||||
createInclusion(fTranslationUnit, includeDirective, allIncludes);
|
createInclusion(fTranslationUnit, includeDirective, allIncludes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// macros
|
// macros
|
||||||
final IASTPreprocessorMacroDefinition[] macroDefinitions= ast.getMacroDefinitions();
|
final IASTPreprocessorMacroDefinition[] macroDefinitions= ast.getMacroDefinitions();
|
||||||
for (int i= 0; i < macroDefinitions.length; i++) {
|
for (IASTPreprocessorMacroDefinition macroDefinition : macroDefinitions) {
|
||||||
IASTPreprocessorMacroDefinition macroDefinition= macroDefinitions[i];
|
|
||||||
if (isLocalToFile(macroDefinition)) {
|
if (isLocalToFile(macroDefinition)) {
|
||||||
createMacro(fTranslationUnit, macroDefinition);
|
createMacro(fTranslationUnit, macroDefinition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// declarations
|
// declarations
|
||||||
final IASTDeclaration[] declarations= ast.getDeclarations();
|
final IASTDeclaration[] declarations= ast.getDeclarations();
|
||||||
for (int i= 0; i < declarations.length; i++) {
|
for (IASTDeclaration declaration : declarations) {
|
||||||
IASTDeclaration declaration= declarations[i];
|
|
||||||
if (isLocalToFile(declaration)) {
|
if (isLocalToFile(declaration)) {
|
||||||
createDeclaration(fTranslationUnit, declaration);
|
createDeclaration(fTranslationUnit, declaration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort by offset
|
// sort by offset
|
||||||
@SuppressWarnings("unchecked")
|
final List<ICElement> children= fTranslationUnit.getElementInfo().internalGetChildren();
|
||||||
final List<SourceManipulation> children= fTranslationUnit.getElementInfo().internalGetChildren();
|
Collections.sort(children, new Comparator<ICElement>() {
|
||||||
Collections.sort(children, new Comparator<SourceManipulation>() {
|
public int compare(ICElement o1, ICElement o2) {
|
||||||
public int compare(SourceManipulation o1, SourceManipulation o2) {
|
|
||||||
try {
|
try {
|
||||||
final SourceManipulationInfo info1= o1.getSourceManipulationInfo();
|
final SourceManipulationInfo info1= ((SourceManipulation) o1).getSourceManipulationInfo();
|
||||||
final SourceManipulationInfo info2= o2.getSourceManipulationInfo();
|
final SourceManipulationInfo info2= ((SourceManipulation) o2).getSourceManipulationInfo();
|
||||||
int delta= info1.getStartPos() - info2.getStartPos();
|
int delta= info1.getStartPos() - info2.getStartPos();
|
||||||
if (delta == 0) {
|
if (delta == 0) {
|
||||||
delta= info1.getIdStartPos() - info2.getIdStartPos();
|
delta= info1.getIdStartPos() - info2.getIdStartPos();
|
||||||
|
@ -249,15 +245,13 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
||||||
problemRequestor.beginReporting();
|
problemRequestor.beginReporting();
|
||||||
final IASTProblem[] ppProblems= ast.getPreprocessorProblems();
|
final IASTProblem[] ppProblems= ast.getPreprocessorProblems();
|
||||||
IASTProblem[] problems= ppProblems;
|
IASTProblem[] problems= ppProblems;
|
||||||
for (int i= 0; i < problems.length; i++) {
|
for (IASTProblem problem : problems) {
|
||||||
IASTProblem problem= problems[i];
|
|
||||||
if (isLocalToFile(problem)) {
|
if (isLocalToFile(problem)) {
|
||||||
problemRequestor.acceptProblem(problem);
|
problemRequestor.acceptProblem(problem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
problems= CPPVisitor.getProblems(ast);
|
problems= CPPVisitor.getProblems(ast);
|
||||||
for (int i= 0; i < problems.length; i++) {
|
for (IASTProblem problem : problems) {
|
||||||
IASTProblem problem= problems[i];
|
|
||||||
if (isLocalToFile(problem)) {
|
if (isLocalToFile(problem)) {
|
||||||
problemRequestor.acceptProblem(problem);
|
problemRequestor.acceptProblem(problem);
|
||||||
}
|
}
|
||||||
|
@ -358,8 +352,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
||||||
} else if (declaration instanceof IASTSimpleDeclaration) {
|
} else if (declaration instanceof IASTSimpleDeclaration) {
|
||||||
CElement[] elements= createSimpleDeclarations(parent, (IASTSimpleDeclaration)declaration, true);
|
CElement[] elements= createSimpleDeclarations(parent, (IASTSimpleDeclaration)declaration, true);
|
||||||
String[] parameterTypes= ASTStringUtil.getTemplateParameterArray(templateDeclaration.getTemplateParameters());
|
String[] parameterTypes= ASTStringUtil.getTemplateParameterArray(templateDeclaration.getTemplateParameters());
|
||||||
for (int i= 0; i < elements.length; i++) {
|
for (CElement element : elements) {
|
||||||
CElement element= elements[i];
|
|
||||||
// set the template parameters
|
// set the template parameters
|
||||||
if (element instanceof StructureTemplate) {
|
if (element instanceof StructureTemplate) {
|
||||||
StructureTemplate classTemplate= (StructureTemplate) element;
|
StructureTemplate classTemplate= (StructureTemplate) element;
|
||||||
|
@ -408,8 +401,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
||||||
*/
|
*/
|
||||||
private void createLinkageSpecification(Parent parent, ICPPASTLinkageSpecification linkageDeclaration) throws CModelException, DOMException {
|
private void createLinkageSpecification(Parent parent, ICPPASTLinkageSpecification linkageDeclaration) throws CModelException, DOMException {
|
||||||
IASTDeclaration[] declarations= linkageDeclaration.getDeclarations();
|
IASTDeclaration[] declarations= linkageDeclaration.getDeclarations();
|
||||||
for (int i= 0; i < declarations.length; i++) {
|
for (IASTDeclaration declaration : declarations) {
|
||||||
IASTDeclaration declaration= declarations[i];
|
|
||||||
if (linkageDeclaration.getFileLocation() != null || isLocalToFile(declaration)) {
|
if (linkageDeclaration.getFileLocation() != null || isLocalToFile(declaration)) {
|
||||||
createDeclaration(parent, declaration);
|
createDeclaration(parent, declaration);
|
||||||
}
|
}
|
||||||
|
@ -524,8 +516,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
||||||
final Set<Namespace> savedNamespaces= fAllNamespaces;
|
final Set<Namespace> savedNamespaces= fAllNamespaces;
|
||||||
fAllNamespaces= new HashSet<Namespace>();
|
fAllNamespaces= new HashSet<Namespace>();
|
||||||
IASTDeclaration[] nsDeclarations= declaration.getDeclarations();
|
IASTDeclaration[] nsDeclarations= declaration.getDeclarations();
|
||||||
for (int i= 0; i < nsDeclarations.length; i++) {
|
for (IASTDeclaration nsDeclaration : nsDeclarations) {
|
||||||
IASTDeclaration nsDeclaration= nsDeclarations[i];
|
|
||||||
if (declaration.getFileLocation() != null || isLocalToFile(nsDeclaration)) {
|
if (declaration.getFileLocation() != null || isLocalToFile(nsDeclaration)) {
|
||||||
createDeclaration(element, nsDeclaration);
|
createDeclaration(element, nsDeclaration);
|
||||||
}
|
}
|
||||||
|
@ -597,8 +588,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
||||||
// add to parent
|
// add to parent
|
||||||
parent.addChild(element);
|
parent.addChild(element);
|
||||||
final IASTEnumerator[] enumerators= enumSpecifier.getEnumerators();
|
final IASTEnumerator[] enumerators= enumSpecifier.getEnumerators();
|
||||||
for (int i= 0; i < enumerators.length; i++) {
|
for (final IASTEnumerator enumerator : enumerators) {
|
||||||
final IASTEnumerator enumerator= enumerators[i];
|
|
||||||
createEnumerator(element, enumerator);
|
createEnumerator(element, enumerator);
|
||||||
}
|
}
|
||||||
// set enumeration position
|
// set enumeration position
|
||||||
|
@ -672,8 +662,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
||||||
// store super classes names
|
// store super classes names
|
||||||
final ICPPASTCompositeTypeSpecifier cppCompositeTypeSpecifier= (ICPPASTCompositeTypeSpecifier)compositeTypeSpecifier;
|
final ICPPASTCompositeTypeSpecifier cppCompositeTypeSpecifier= (ICPPASTCompositeTypeSpecifier)compositeTypeSpecifier;
|
||||||
ICPPASTBaseSpecifier[] baseSpecifiers= cppCompositeTypeSpecifier.getBaseSpecifiers();
|
ICPPASTBaseSpecifier[] baseSpecifiers= cppCompositeTypeSpecifier.getBaseSpecifiers();
|
||||||
for (int i= 0; i < baseSpecifiers.length; i++) {
|
for (final ICPPASTBaseSpecifier baseSpecifier : baseSpecifiers) {
|
||||||
final ICPPASTBaseSpecifier baseSpecifier= baseSpecifiers[i];
|
|
||||||
final IASTName baseName= baseSpecifier.getName();
|
final IASTName baseName= baseSpecifier.getName();
|
||||||
final ASTAccessVisibility visibility;
|
final ASTAccessVisibility visibility;
|
||||||
switch(baseSpecifier.getVisibility()) {
|
switch(baseSpecifier.getVisibility()) {
|
||||||
|
@ -713,8 +702,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
||||||
pushDefaultVisibility(defaultVisibility);
|
pushDefaultVisibility(defaultVisibility);
|
||||||
try {
|
try {
|
||||||
final IASTDeclaration[] memberDeclarations= compositeTypeSpecifier.getMembers();
|
final IASTDeclaration[] memberDeclarations= compositeTypeSpecifier.getMembers();
|
||||||
for (int i= 0; i < memberDeclarations.length; i++) {
|
for (IASTDeclaration member : memberDeclarations) {
|
||||||
IASTDeclaration member= memberDeclarations[i];
|
|
||||||
if (compositeTypeSpecifier.getFileLocation() != null || isLocalToFile(member)) {
|
if (compositeTypeSpecifier.getFileLocation() != null || isLocalToFile(member)) {
|
||||||
createDeclaration(element, member);
|
createDeclaration(element, member);
|
||||||
}
|
}
|
||||||
|
@ -862,8 +850,8 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
||||||
if (!isMethod && name instanceof ICPPASTQualifiedName) {
|
if (!isMethod && name instanceof ICPPASTQualifiedName) {
|
||||||
final IASTName[] names= ((ICPPASTQualifiedName)name).getNames();
|
final IASTName[] names= ((ICPPASTQualifiedName)name).getNames();
|
||||||
if (isTemplate) {
|
if (isTemplate) {
|
||||||
for (int i= 0; i < names.length; i++) {
|
for (IASTName name2 : names) {
|
||||||
if (names[i] instanceof ICPPASTTemplateId) {
|
if (name2 instanceof ICPPASTTemplateId) {
|
||||||
isMethod= true;
|
isMethod= true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.IOpenable;
|
||||||
import org.eclipse.cdt.internal.core.util.OverflowingLRUCache;
|
import org.eclipse.cdt.internal.core.util.OverflowingLRUCache;
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,28 +34,28 @@ public class CModelCache {
|
||||||
/**
|
/**
|
||||||
* Cache of open projects and roots.
|
* Cache of open projects and roots.
|
||||||
*/
|
*/
|
||||||
protected Map projectAndRootCache;
|
protected Map<ICElement, Object> projectAndRootCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache of open containers
|
* Cache of open containers
|
||||||
*/
|
*/
|
||||||
protected Map folderCache;
|
protected Map<ICElement, Object> folderCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache of open translation unit files
|
* Cache of open translation unit files
|
||||||
*/
|
*/
|
||||||
protected OverflowingLRUCache fileCache;
|
protected OverflowingLRUCache<IOpenable, Object> fileCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache of children of C elements
|
* Cache of children of C elements
|
||||||
*/
|
*/
|
||||||
protected Map childrenCache;
|
protected Map<ICElement, Object> childrenCache;
|
||||||
|
|
||||||
public CModelCache() {
|
public CModelCache() {
|
||||||
this.projectAndRootCache = new HashMap(PROJ_CACHE_SIZE);
|
this.projectAndRootCache = new HashMap<ICElement, Object>(PROJ_CACHE_SIZE);
|
||||||
this.folderCache = new HashMap(FOLDER_CACHE_SIZE);
|
this.folderCache = new HashMap<ICElement, Object>(FOLDER_CACHE_SIZE);
|
||||||
this.fileCache = new ElementCache(FILE_CACHE_SIZE);
|
this.fileCache = new ElementCache<Object>(FILE_CACHE_SIZE);
|
||||||
this.childrenCache = new HashMap(CHILDREN_CACHE_SIZE); // average 20 children per openable
|
this.childrenCache = new HashMap<ICElement, Object>(CHILDREN_CACHE_SIZE); // average 20 children per openable
|
||||||
}
|
}
|
||||||
|
|
||||||
public double openableFillingRatio() {
|
public double openableFillingRatio() {
|
||||||
|
@ -94,7 +95,7 @@ protected Object peekAtInfo(ICElement element) {
|
||||||
case ICElement.C_ARCHIVE:
|
case ICElement.C_ARCHIVE:
|
||||||
case ICElement.C_BINARY:
|
case ICElement.C_BINARY:
|
||||||
case ICElement.C_UNIT:
|
case ICElement.C_UNIT:
|
||||||
return this.fileCache.peek(element);
|
return this.fileCache.peek((IOpenable) element);
|
||||||
default:
|
default:
|
||||||
return this.childrenCache.get(element);
|
return this.childrenCache.get(element);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +116,7 @@ protected void putInfo(ICElement element, Object info) {
|
||||||
case ICElement.C_ARCHIVE:
|
case ICElement.C_ARCHIVE:
|
||||||
case ICElement.C_BINARY:
|
case ICElement.C_BINARY:
|
||||||
case ICElement.C_UNIT:
|
case ICElement.C_UNIT:
|
||||||
this.fileCache.put(element, info);
|
this.fileCache.put((IOpenable)element, info);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this.childrenCache.put(element, info);
|
this.childrenCache.put(element, info);
|
||||||
|
@ -136,7 +137,7 @@ protected void removeInfo(ICElement element) {
|
||||||
case ICElement.C_ARCHIVE:
|
case ICElement.C_ARCHIVE:
|
||||||
case ICElement.C_BINARY:
|
case ICElement.C_BINARY:
|
||||||
case ICElement.C_UNIT:
|
case ICElement.C_UNIT:
|
||||||
this.fileCache.remove(element);
|
this.fileCache.remove((IOpenable)element);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this.childrenCache.remove(element);
|
this.childrenCache.remove(element);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
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.IProject;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
|
||||||
|
@ -65,9 +66,6 @@ public class CModelInfo extends OpenableInfo {
|
||||||
return nonCResources;
|
return nonCResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void setNonCResources(Object[] resources) {
|
public void setNonCResources(Object[] resources) {
|
||||||
nonCResources = resources;
|
nonCResources = resources;
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,16 +122,16 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
/**
|
/**
|
||||||
* A map from ITranslationUnit to IWorkingCopy of the shared working copies.
|
* 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.
|
* 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
|
* 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.
|
* Infos cache.
|
||||||
|
@ -319,8 +319,8 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
path = path.removeLastSegments(1);
|
path = path.removeLastSegments(1);
|
||||||
String[] segments = path.segments();
|
String[] segments = path.segments();
|
||||||
ICContainer cfolder = root;
|
ICContainer cfolder = root;
|
||||||
for (int j = 0; j < segments.length; j++) {
|
for (String segment : segments) {
|
||||||
cfolder = cfolder.getCContainer(segments[j]);
|
cfolder = cfolder.getCContainer(segment);
|
||||||
}
|
}
|
||||||
if (CoreModel.isValidTranslationUnitName(cproject.getProject(), fileName)) {
|
if (CoreModel.isValidTranslationUnitName(cproject.getProject(), fileName)) {
|
||||||
celement = cfolder.getTranslationUnit(fileName);
|
celement = cfolder.getTranslationUnit(fileName);
|
||||||
|
@ -393,15 +393,15 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IIncludeReference[] includeReferences = cproject.getIncludeReferences();
|
IIncludeReference[] includeReferences = cproject.getIncludeReferences();
|
||||||
for (int i = 0; i < includeReferences.length; i++) {
|
for (IIncludeReference includeReference : includeReferences) {
|
||||||
if (includeReferences[i].isOnIncludeEntry(path)) {
|
if (includeReference.isOnIncludeEntry(path)) {
|
||||||
String headerContentTypeId= contentTypeId;
|
String headerContentTypeId= contentTypeId;
|
||||||
if (headerContentTypeId == null) {
|
if (headerContentTypeId == null) {
|
||||||
headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
|
headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use URI
|
// TODO: use URI
|
||||||
return new ExternalTranslationUnit(includeReferences[i], URIUtil.toURI(path), headerContentTypeId);
|
return new ExternalTranslationUnit(includeReference, URIUtil.toURI(path), headerContentTypeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
|
@ -417,8 +417,8 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
// !path.isAbsolute()
|
// !path.isAbsolute()
|
||||||
try {
|
try {
|
||||||
IIncludeReference[] includeReferences = cproject.getIncludeReferences();
|
IIncludeReference[] includeReferences = cproject.getIncludeReferences();
|
||||||
for (int i = 0; i < includeReferences.length; i++) {
|
for (IIncludeReference includeReference : includeReferences) {
|
||||||
IPath includePath = includeReferences[i].getPath().append(path);
|
IPath includePath = includeReference.getPath().append(path);
|
||||||
if (Util.isNonZeroLengthFile(includePath)) {
|
if (Util.isNonZeroLengthFile(includePath)) {
|
||||||
String headerContentTypeId= contentTypeId;
|
String headerContentTypeId= contentTypeId;
|
||||||
if (headerContentTypeId == null) {
|
if (headerContentTypeId == null) {
|
||||||
|
@ -426,7 +426,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use URI
|
// TODO: use URI
|
||||||
return new ExternalTranslationUnit(includeReferences[i], URIUtil.toURI(includePath), headerContentTypeId);
|
return new ExternalTranslationUnit(includeReference, URIUtil.toURI(includePath), headerContentTypeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
|
@ -470,18 +470,18 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IIncludeReference[] includeReferences = cproject.getIncludeReferences();
|
IIncludeReference[] includeReferences = cproject.getIncludeReferences();
|
||||||
for (int i = 0; i < includeReferences.length; i++) {
|
for (IIncludeReference includeReference : includeReferences) {
|
||||||
|
|
||||||
|
|
||||||
// crecoskie
|
// crecoskie
|
||||||
// TODO FIXME: include entries don't handle URIs yet
|
// 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;
|
String headerContentTypeId= contentTypeId;
|
||||||
if (headerContentTypeId == null) {
|
if (headerContentTypeId == null) {
|
||||||
headerContentTypeId= CoreModel.hasCCNature(project) ? CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
|
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) {
|
} catch (CModelException e) {
|
||||||
|
@ -511,8 +511,8 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
CElementInfo info = (CElementInfo)peekAtInfo(celement);
|
CElementInfo info = (CElementInfo)peekAtInfo(celement);
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
ICElement[] children = info.getChildren();
|
ICElement[] children = info.getChildren();
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (ICElement element : children) {
|
||||||
releaseCElement(children[i]);
|
releaseCElement(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,10 +536,10 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
if (peekAtInfo(pinfo.vBin) != null) {
|
if (peekAtInfo(pinfo.vBin) != null) {
|
||||||
try {
|
try {
|
||||||
ICElement[] bins = pinfo.vBin.getChildren();
|
ICElement[] bins = pinfo.vBin.getChildren();
|
||||||
for (int i = 0; i < bins.length; i++) {
|
for (ICElement bin : bins) {
|
||||||
if (celement.getPath().isPrefixOf(bins[i].getPath())) {
|
if (celement.getPath().isPrefixOf(bin.getPath())) {
|
||||||
//pinfo.vBin.removeChild(bins[i]);
|
//pinfo.vBin.removeChild(bins[i]);
|
||||||
list.add(bins[i]);
|
list.add(bin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
|
@ -551,10 +551,10 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
if (peekAtInfo(pinfo.vLib) != null) {
|
if (peekAtInfo(pinfo.vLib) != null) {
|
||||||
try {
|
try {
|
||||||
ICElement[] ars = pinfo.vLib.getChildren();
|
ICElement[] ars = pinfo.vLib.getChildren();
|
||||||
for (int i = 0; i < ars.length; i++) {
|
for (ICElement ar : ars) {
|
||||||
if (celement.getPath().isPrefixOf(ars[i].getPath())) {
|
if (celement.getPath().isPrefixOf(ar.getPath())) {
|
||||||
//pinfo.vLib.removeChild(ars[i]);
|
//pinfo.vLib.removeChild(ars[i]);
|
||||||
list.add(ars[i]);
|
list.add(ar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
|
@ -564,7 +564,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
}
|
}
|
||||||
// release any binary/archive that was in the path
|
// release any binary/archive that was in the path
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
ICElement b = (ICElement)list.get(i);
|
ICElement b = list.get(i);
|
||||||
releaseCElement(b);
|
releaseCElement(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -580,7 +580,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
}
|
}
|
||||||
|
|
||||||
public BinaryParserConfig[] getBinaryParser(IProject project) {
|
public BinaryParserConfig[] getBinaryParser(IProject project) {
|
||||||
BinaryParserConfig[] parsers = (BinaryParserConfig[])binaryParsersMap.get(project);
|
BinaryParserConfig[] parsers = binaryParsersMap.get(project);
|
||||||
if (parsers == null) {
|
if (parsers == null) {
|
||||||
try {
|
try {
|
||||||
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project, false);
|
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);
|
ICExtensionReference[] cextensions = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID, true);
|
||||||
if (cextensions.length > 0) {
|
if (cextensions.length > 0) {
|
||||||
ArrayList<BinaryParserConfig> list = new ArrayList<BinaryParserConfig>(cextensions.length);
|
ArrayList<BinaryParserConfig> list = new ArrayList<BinaryParserConfig>(cextensions.length);
|
||||||
for (int i = 0; i < cextensions.length; i++) {
|
for (ICExtensionReference cextension : cextensions) {
|
||||||
BinaryParserConfig config = new BinaryParserConfig(cextensions[i]);
|
BinaryParserConfig config = new BinaryParserConfig(cextension);
|
||||||
list.add(config);
|
list.add(config);
|
||||||
}
|
}
|
||||||
parsers = new BinaryParserConfig[list.size()];
|
parsers = new BinaryParserConfig[list.size()];
|
||||||
|
@ -661,10 +661,10 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
|
|
||||||
int hints = 0;
|
int hints = 0;
|
||||||
|
|
||||||
for (int i = 0; i < parsers.length; i++) {
|
for (BinaryParserConfig parser2 : parsers) {
|
||||||
IBinaryParser parser = null;
|
IBinaryParser parser = null;
|
||||||
try {
|
try {
|
||||||
parser = parsers[i].getBinaryParser();
|
parser = parser2.getBinaryParser();
|
||||||
if (parser.getHintBufferSize() > hints) {
|
if (parser.getHintBufferSize() > hints) {
|
||||||
hints = Math.max(hints, parser.getHintBufferSize());
|
hints = Math.max(hints, parser.getHintBufferSize());
|
||||||
}
|
}
|
||||||
|
@ -706,9 +706,9 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
|
|
||||||
IPath location = file.getLocation();
|
IPath location = file.getLocation();
|
||||||
|
|
||||||
for (int i = 0; i < parsers.length; i++) {
|
for (BinaryParserConfig parser2 : parsers) {
|
||||||
try {
|
try {
|
||||||
IBinaryParser parser = parsers[i].getBinaryParser();
|
IBinaryParser parser = parser2.getBinaryParser();
|
||||||
if (parser.isBinary(bytes, location)) {
|
if (parser.isBinary(bytes, location)) {
|
||||||
IBinaryFile binFile = parser.getBinary(bytes, location);
|
IBinaryFile binFile = parser.getBinary(bytes, location);
|
||||||
if (binFile != null) {
|
if (binFile != null) {
|
||||||
|
@ -749,7 +749,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
BinaryRunner runner = null;
|
BinaryRunner runner = null;
|
||||||
synchronized (binaryRunners) {
|
synchronized (binaryRunners) {
|
||||||
IProject project = cproject.getProject();
|
IProject project = cproject.getProject();
|
||||||
runner = (BinaryRunner)binaryRunners.get(project);
|
runner = binaryRunners.get(project);
|
||||||
if (runner == null) {
|
if (runner == null) {
|
||||||
runner = new BinaryRunner(project);
|
runner = new BinaryRunner(project);
|
||||||
binaryRunners.put(project, runner);
|
binaryRunners.put(project, runner);
|
||||||
|
@ -764,7 +764,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeBinaryRunner(IProject project) {
|
public void removeBinaryRunner(IProject project) {
|
||||||
BinaryRunner runner = (BinaryRunner)binaryRunners.remove(project);
|
BinaryRunner runner = binaryRunners.remove(project);
|
||||||
if (runner != null) {
|
if (runner != null) {
|
||||||
runner.stop();
|
runner.stop();
|
||||||
}
|
}
|
||||||
|
@ -773,7 +773,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
public SourceMapper getSourceMapper(ICProject cProject) {
|
public SourceMapper getSourceMapper(ICProject cProject) {
|
||||||
SourceMapper mapper = null;
|
SourceMapper mapper = null;
|
||||||
synchronized (sourceMappers) {
|
synchronized (sourceMappers) {
|
||||||
mapper = (SourceMapper)sourceMappers.get(cProject);
|
mapper = sourceMappers.get(cProject);
|
||||||
if (mapper == null) {
|
if (mapper == null) {
|
||||||
mapper = new SourceMapper(cProject);
|
mapper = new SourceMapper(cProject);
|
||||||
sourceMappers.put(cProject, mapper);
|
sourceMappers.put(cProject, mapper);
|
||||||
|
@ -855,8 +855,8 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
checkForProjectRename(delta);
|
checkForProjectRename(delta);
|
||||||
ICElementDelta[] translatedDeltas = fDeltaProcessor.processResourceDelta(delta);
|
ICElementDelta[] translatedDeltas = fDeltaProcessor.processResourceDelta(delta);
|
||||||
if (translatedDeltas.length > 0) {
|
if (translatedDeltas.length > 0) {
|
||||||
for (int i = 0; i < translatedDeltas.length; i++) {
|
for (ICElementDelta translatedDelta : translatedDeltas) {
|
||||||
registerCModelDelta(translatedDeltas[i]);
|
registerCModelDelta(translatedDelta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fire(ElementChangedEvent.POST_CHANGE);
|
fire(ElementChangedEvent.POST_CHANGE);
|
||||||
|
@ -923,6 +923,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
* Fire C Model deltas, flushing them after the fact.
|
* Fire C Model deltas, flushing them after the fact.
|
||||||
* If the firing mode has been turned off, this has no effect.
|
* If the firing mode has been turned off, this has no effect.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
void fire(ICElementDelta customDeltas, int eventType) {
|
void fire(ICElementDelta customDeltas, int eventType) {
|
||||||
if (fFire) {
|
if (fFire) {
|
||||||
ICElementDelta deltaToNotify;
|
ICElementDelta deltaToNotify;
|
||||||
|
@ -966,6 +967,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
private void firePreAutoBuildDelta(ICElementDelta deltaToNotify,
|
private void firePreAutoBuildDelta(ICElementDelta deltaToNotify,
|
||||||
IElementChangedListener[] listeners, int[] listenerMask, int listenerCount) {
|
IElementChangedListener[] listeners, int[] listenerMask, int listenerCount) {
|
||||||
|
|
||||||
|
@ -1078,8 +1080,8 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
}
|
}
|
||||||
IResourceDelta[] resourceDeltas = delta.getResourceDeltas();
|
IResourceDelta[] resourceDeltas = delta.getResourceDeltas();
|
||||||
if (resourceDeltas != null) {
|
if (resourceDeltas != null) {
|
||||||
for (int i = 0, length = resourceDeltas.length; i < length; i++) {
|
for (IResourceDelta resourceDelta : resourceDeltas) {
|
||||||
rootDelta.addResourceDelta(resourceDeltas[i]);
|
rootDelta.addResourceDelta(resourceDelta);
|
||||||
insertedTree = true;
|
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.
|
* Returns the set of elements which are out of synch with their buffers.
|
||||||
*/
|
*/
|
||||||
protected Map getElementsOutOfSynchWithBuffers() {
|
protected Map<ICElement,ICElement> getElementsOutOfSynchWithBuffers() {
|
||||||
return this.elementsOutOfSynchWithBuffers;
|
return this.elementsOutOfSynchWithBuffers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1106,7 +1108,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
* Returns the info for the element.
|
* Returns the info for the element.
|
||||||
*/
|
*/
|
||||||
public synchronized Object getInfo(ICElement 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) {
|
if (tempCache != null) {
|
||||||
Object result = tempCache.get(element);
|
Object result = tempCache.get(element);
|
||||||
if (result != null)
|
if (result != null)
|
||||||
|
@ -1120,7 +1122,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
* disturbing the cache ordering.
|
* disturbing the cache ordering.
|
||||||
*/
|
*/
|
||||||
protected synchronized Object peekAtInfo(ICElement element) {
|
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) {
|
if (tempCache != null) {
|
||||||
Object result = tempCache.get(element);
|
Object result = tempCache.get(element);
|
||||||
if (result != null) {
|
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
|
* 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.
|
* 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
|
// remove children
|
||||||
Object existingInfo = this.cache.peekAtInfo(openedElement);
|
Object existingInfo = this.cache.peekAtInfo(openedElement);
|
||||||
if (openedElement instanceof IParent && existingInfo instanceof CElementInfo) {
|
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.
|
* Returns the temporary cache for newly opened elements for the current thread.
|
||||||
* Creates it if not already created.
|
* Creates it if not already created.
|
||||||
*/
|
*/
|
||||||
public HashMap<ICElement, Object> getTemporaryCache() {
|
public Map<ICElement, CElementInfo> getTemporaryCache() {
|
||||||
HashMap<ICElement, Object> result = (HashMap<ICElement, Object>)this.temporaryCache.get();
|
Map<ICElement, CElementInfo> result = this.temporaryCache.get();
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
result = new HashMap<ICElement, Object>();
|
result = new HashMap<ICElement, CElementInfo>();
|
||||||
this.temporaryCache.set(result);
|
this.temporaryCache.set(result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -1229,16 +1231,16 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
||||||
// Do any shutdown of services.
|
// Do any shutdown of services.
|
||||||
ResourcesPlugin.getWorkspace().removeResourceChangeListener(factory);
|
ResourcesPlugin.getWorkspace().removeResourceChangeListener(factory);
|
||||||
|
|
||||||
BinaryRunner[] runners = (BinaryRunner[])binaryRunners.values().toArray(new BinaryRunner[0]);
|
BinaryRunner[] runners = binaryRunners.values().toArray(new BinaryRunner[0]);
|
||||||
for (int i = 0; i < runners.length; i++) {
|
for (BinaryRunner runner : runners) {
|
||||||
runners[i].stop();
|
runner.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForProjectRename(IResourceDelta delta) {
|
private void checkForProjectRename(IResourceDelta delta) {
|
||||||
IResourceDelta[] rem= delta.getAffectedChildren(IResourceDelta.REMOVED);
|
IResourceDelta[] rem= delta.getAffectedChildren(IResourceDelta.REMOVED);
|
||||||
for (int i = 0; i < rem.length; i++) {
|
for (IResourceDelta element : rem) {
|
||||||
delta = rem[i];
|
delta = element;
|
||||||
IResource res= delta.getResource();
|
IResource res= delta.getResource();
|
||||||
if (res.getType() == IResource.PROJECT) {
|
if (res.getType() == IResource.PROJECT) {
|
||||||
IPath movedTo= null;
|
IPath movedTo= null;
|
||||||
|
|
|
@ -106,7 +106,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
|
||||||
/*
|
/*
|
||||||
* A per thread stack of java model operations (PerThreadObject of ArrayList).
|
* 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() {
|
protected CModelOperation() {
|
||||||
}
|
}
|
||||||
|
@ -178,12 +178,12 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
|
||||||
* Registers the given reconcile delta with the C Model Manager.
|
* Registers the given reconcile delta with the C Model Manager.
|
||||||
*/
|
*/
|
||||||
protected void addReconcileDelta(IWorkingCopy workingCopy, ICElementDelta delta) {
|
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);
|
CElementDelta previousDelta = (CElementDelta)reconcileDeltas.get(workingCopy);
|
||||||
if (previousDelta != null) {
|
if (previousDelta != null) {
|
||||||
ICElementDelta[] children = delta.getAffectedChildren();
|
ICElementDelta[] children = delta.getAffectedChildren();
|
||||||
for (int i = 0, length = children.length; i < length; i++) {
|
for (ICElementDelta element : children) {
|
||||||
CElementDelta child = (CElementDelta)children[i];
|
CElementDelta child = (CElementDelta)element;
|
||||||
previousDelta.insertDeltaTree(child.getElement(), child);
|
previousDelta.insertDeltaTree(child.getElement(), child);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -229,8 +229,8 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
|
||||||
if (fElementsToProcess == null || fElementsToProcess.length == 0) {
|
if (fElementsToProcess == null || fElementsToProcess.length == 0) {
|
||||||
return new CModelStatus(ICModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
|
return new CModelStatus(ICModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < fElementsToProcess.length; i++) {
|
for (ICElement elementsToProces : fElementsToProcess) {
|
||||||
if (fElementsToProcess[i] == null) {
|
if (elementsToProces == null) {
|
||||||
return new CModelStatus(ICModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
|
return new CModelStatus(ICModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,8 +359,8 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
|
||||||
}
|
}
|
||||||
//accumulate the nested operation deltas
|
//accumulate the nested operation deltas
|
||||||
if (operation.fDeltas != null) {
|
if (operation.fDeltas != null) {
|
||||||
for (int i = 0; i < operation.fDeltas.length; i++) {
|
for (ICElementDelta delta : operation.fDeltas) {
|
||||||
addDelta(operation.fDeltas[i]);
|
addDelta(delta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CoreException ce) {
|
} catch (CoreException ce) {
|
||||||
|
@ -538,8 +538,8 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
|
||||||
// hook to ensure working copies remain consistent
|
// hook to ensure working copies remain consistent
|
||||||
//makeWorkingCopiesConsistent(fDeltas);
|
//makeWorkingCopiesConsistent(fDeltas);
|
||||||
CModelManager manager= CModelManager.getDefault();
|
CModelManager manager= CModelManager.getDefault();
|
||||||
for (int i= 0; i < fDeltas.length; i++) {
|
for (ICElementDelta delta : fDeltas) {
|
||||||
manager.registerCModelDelta(fDeltas[i]);
|
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 the stack of operations running in the current thread.
|
||||||
* Returns an empty stack if no operations are currently running in this thread.
|
* Returns an empty stack if no operations are currently running in this thread.
|
||||||
*/
|
*/
|
||||||
protected ArrayList getCurrentOperationStack() {
|
protected ArrayList<CModelOperation> getCurrentOperationStack() {
|
||||||
ArrayList stack = (ArrayList)operationStacks.get();
|
ArrayList<CModelOperation> stack = operationStacks.get();
|
||||||
if (stack == null) {
|
if (stack == null) {
|
||||||
stack = new ArrayList();
|
stack = new ArrayList<CModelOperation>();
|
||||||
operationStacks.set(stack);
|
operationStacks.set(stack);
|
||||||
}
|
}
|
||||||
return 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.
|
* Returns the poped operation or null if the stack was empty.
|
||||||
*/
|
*/
|
||||||
protected CModelOperation popOperation() {
|
protected CModelOperation popOperation() {
|
||||||
ArrayList stack = getCurrentOperationStack();
|
ArrayList<CModelOperation> stack = getCurrentOperationStack();
|
||||||
int size = stack.size();
|
int size = stack.size();
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
if (size == 1) { // top level operation
|
if (size == 1) { // top level operation
|
||||||
operationStacks.set(null); // release reference (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=33927)
|
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 {
|
} else {
|
||||||
return null;
|
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.
|
* Returns whether this operation is the first operation to run in the current thread.
|
||||||
*/
|
*/
|
||||||
protected boolean isTopLevelOperation() {
|
protected boolean isTopLevelOperation() {
|
||||||
ArrayList stack;
|
ArrayList<CModelOperation> stack;
|
||||||
return
|
return
|
||||||
(stack = this.getCurrentOperationStack()).size() > 0
|
(stack = this.getCurrentOperationStack()).size() > 0
|
||||||
&& stack.get(0) == this;
|
&& stack.get(0) == this;
|
||||||
|
@ -663,7 +663,7 @@ public abstract class CModelOperation implements IWorkspaceRunnable, IProgressMo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether this operation is nested or not.
|
* Sets whether this operation is nested or not.
|
||||||
* @see CreateElementInCUOperation#checkCanceled
|
* @see CreateElementInTUOperation#checkCanceled
|
||||||
*/
|
*/
|
||||||
protected void setNested(boolean nested) {
|
protected void setNested(boolean nested) {
|
||||||
fNested = nested;
|
fNested = nested;
|
||||||
|
|
|
@ -303,9 +303,6 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
return exception.toString();
|
return exception.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see IOperationStatus
|
|
||||||
*/
|
|
||||||
public IPath getPath() {
|
public IPath getPath() {
|
||||||
if (fPath == null) {
|
if (fPath == null) {
|
||||||
return Path.EMPTY;
|
return Path.EMPTY;
|
||||||
|
@ -321,8 +318,8 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
if (fChildren == fgEmptyChildren)
|
if (fChildren == fgEmptyChildren)
|
||||||
return super.getSeverity();
|
return super.getSeverity();
|
||||||
int severity = -1;
|
int severity = -1;
|
||||||
for (int i = 0, max = fChildren.length; i < max; i++) {
|
for (IStatus element : fChildren) {
|
||||||
int childrenSeverity = fChildren[i].getSeverity();
|
int childrenSeverity = element.getSeverity();
|
||||||
if (childrenSeverity > severity) {
|
if (childrenSeverity > severity) {
|
||||||
severity = childrenSeverity;
|
severity = childrenSeverity;
|
||||||
}
|
}
|
||||||
|
@ -378,8 +375,8 @@ public class CModelStatus extends Status implements ICModelStatus, ICModelStatus
|
||||||
if (!isMultiStatus()) {
|
if (!isMultiStatus()) {
|
||||||
return matches(this, mask);
|
return matches(this, mask);
|
||||||
}
|
}
|
||||||
for (int i = 0, max = fChildren.length; i < max; i++) {
|
for (IStatus element : fChildren) {
|
||||||
if (matches((CModelStatus)fChildren[i], mask))
|
if (matches((CModelStatus)element, mask))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
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
|
* Creates and returns a new <code>ICModelStatus</code> that is a a
|
||||||
* multi-status status.
|
* multi-status status.
|
||||||
*
|
*
|
||||||
* @see IStatus#.isMultiStatus()
|
* @see IStatus#isMultiStatus()
|
||||||
*/
|
*/
|
||||||
public static ICModelStatus newMultiStatus(ICModelStatus[] children) {
|
public static ICModelStatus newMultiStatus(ICModelStatus[] children) {
|
||||||
CModelStatus jms = new CModelStatus();
|
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
|
* Creates and returns a new <code>ICModelStatus</code> that is a a
|
||||||
* multi-status status.
|
* multi-status status.
|
||||||
*
|
|
||||||
* @see IStatus#.isMultiStatus()
|
|
||||||
*/
|
*/
|
||||||
public static ICModelStatus newMultiStatus(int code, ICModelStatus[] children) {
|
public static ICModelStatus newMultiStatus(int code, ICModelStatus[] children) {
|
||||||
CModelStatus jms = new CModelStatus(code);
|
CModelStatus jms = new CModelStatus(code);
|
||||||
|
|
|
@ -165,9 +165,9 @@ public class CProject extends Openable implements ICProject {
|
||||||
if (incRefs == null) {
|
if (incRefs == null) {
|
||||||
IPathEntry[] entries = getResolvedPathEntries();
|
IPathEntry[] entries = getResolvedPathEntries();
|
||||||
ArrayList<IncludeReference> list = new ArrayList<IncludeReference>(entries.length);
|
ArrayList<IncludeReference> list = new ArrayList<IncludeReference>(entries.length);
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (IPathEntry entrie : entries) {
|
||||||
if (entries[i].getEntryKind() == IPathEntry.CDT_INCLUDE) {
|
if (entrie.getEntryKind() == IPathEntry.CDT_INCLUDE) {
|
||||||
IIncludeEntry entry = (IIncludeEntry) entries[i];
|
IIncludeEntry entry = (IIncludeEntry) entrie;
|
||||||
list.add(new IncludeReference(this, entry));
|
list.add(new IncludeReference(this, entry));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,9 +190,9 @@ public class CProject extends Openable implements ICProject {
|
||||||
BinaryParserConfig[] binConfigs = CModelManager.getDefault().getBinaryParser(getProject());
|
BinaryParserConfig[] binConfigs = CModelManager.getDefault().getBinaryParser(getProject());
|
||||||
IPathEntry[] entries = getResolvedPathEntries();
|
IPathEntry[] entries = getResolvedPathEntries();
|
||||||
ArrayList<ILibraryReference> list = new ArrayList<ILibraryReference>(entries.length);
|
ArrayList<ILibraryReference> list = new ArrayList<ILibraryReference>(entries.length);
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (IPathEntry entrie : entries) {
|
||||||
if (entries[i].getEntryKind() == IPathEntry.CDT_LIBRARY) {
|
if (entrie.getEntryKind() == IPathEntry.CDT_LIBRARY) {
|
||||||
ILibraryEntry entry = (ILibraryEntry) entries[i];
|
ILibraryEntry entry = (ILibraryEntry) entrie;
|
||||||
ILibraryReference lib = getLibraryReference(this, binConfigs, entry);
|
ILibraryReference lib = getLibraryReference(this, binConfigs, entry);
|
||||||
if (lib != null) {
|
if (lib != null) {
|
||||||
list.add(lib);
|
list.add(lib);
|
||||||
|
@ -213,10 +213,10 @@ public class CProject extends Openable implements ICProject {
|
||||||
}
|
}
|
||||||
ILibraryReference lib = null;
|
ILibraryReference lib = null;
|
||||||
if (binConfigs != null) {
|
if (binConfigs != null) {
|
||||||
for (int i = 0; i < binConfigs.length; i++) {
|
for (BinaryParserConfig binConfig : binConfigs) {
|
||||||
IBinaryFile bin;
|
IBinaryFile bin;
|
||||||
try {
|
try {
|
||||||
IBinaryParser parser = binConfigs[i].getBinaryParser();
|
IBinaryParser parser = binConfig.getBinaryParser();
|
||||||
bin = parser.getBinary(entry.getFullLibraryPath());
|
bin = parser.getBinary(entry.getFullLibraryPath());
|
||||||
if (bin != null) {
|
if (bin != null) {
|
||||||
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
||||||
|
@ -281,8 +281,7 @@ public class CProject extends Openable implements ICProject {
|
||||||
// create project options
|
// create project options
|
||||||
try {
|
try {
|
||||||
String[] propertyNames= preferences.keys();
|
String[] propertyNames= preferences.keys();
|
||||||
for (int i= 0; i < propertyNames.length; i++){
|
for (String propertyName : propertyNames) {
|
||||||
String propertyName= propertyNames[i];
|
|
||||||
String value= preferences.get(propertyName, null);
|
String value= preferences.get(propertyName, null);
|
||||||
if (value != null && optionNames.contains(propertyName)){
|
if (value != null && optionNames.contains(propertyName)){
|
||||||
options.put(propertyName, value.trim());
|
options.put(propertyName, value.trim());
|
||||||
|
@ -450,9 +449,9 @@ public class CProject extends Openable implements ICProject {
|
||||||
public ISourceRoot findSourceRoot(IResource res) {
|
public ISourceRoot findSourceRoot(IResource res) {
|
||||||
try {
|
try {
|
||||||
ISourceRoot[] roots = getAllSourceRoots();
|
ISourceRoot[] roots = getAllSourceRoots();
|
||||||
for (int i = 0; i < roots.length; i++) {
|
for (ISourceRoot root : roots) {
|
||||||
if (roots[i].isOnSourceEntry(res)) {
|
if (root.isOnSourceEntry(res)) {
|
||||||
return roots[i];
|
return root;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
|
@ -466,9 +465,9 @@ public class CProject extends Openable implements ICProject {
|
||||||
public ISourceRoot findSourceRoot(IPath path) {
|
public ISourceRoot findSourceRoot(IPath path) {
|
||||||
try {
|
try {
|
||||||
ISourceRoot[] roots = getAllSourceRoots();
|
ISourceRoot[] roots = getAllSourceRoots();
|
||||||
for (int i = 0; i < roots.length; i++) {
|
for (ISourceRoot root : roots) {
|
||||||
if (roots[i].getPath().equals(path)) {
|
if (root.getPath().equals(path)) {
|
||||||
return roots[i];
|
return root;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
|
@ -482,9 +481,9 @@ public class CProject extends Openable implements ICProject {
|
||||||
public ISourceRoot[] getSourceRoots() throws CModelException {
|
public ISourceRoot[] getSourceRoots() throws CModelException {
|
||||||
Object[] children = getChildren();
|
Object[] children = getChildren();
|
||||||
ArrayList<ISourceRoot> result = new ArrayList<ISourceRoot>(children.length);
|
ArrayList<ISourceRoot> result = new ArrayList<ISourceRoot>(children.length);
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (Object element : children) {
|
||||||
if (children[i] instanceof ISourceRoot) {
|
if (element instanceof ISourceRoot) {
|
||||||
result.add((ISourceRoot) children[i]);
|
result.add((ISourceRoot) element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result.toArray(new ISourceRoot[result.size()]);
|
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 {
|
public IOutputEntry[] getOutputEntries(IPathEntry[] entries) throws CModelException {
|
||||||
ArrayList<IPathEntry> list = new ArrayList<IPathEntry>(entries.length);
|
ArrayList<IPathEntry> list = new ArrayList<IPathEntry>(entries.length);
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (IPathEntry entrie : entries) {
|
||||||
if (entries[i].getEntryKind() == IPathEntry .CDT_OUTPUT) {
|
if (entrie.getEntryKind() == IPathEntry .CDT_OUTPUT) {
|
||||||
list.add(entries[i]);
|
list.add(entrie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IOutputEntry[] outputs = new IOutputEntry[list.size()];
|
IOutputEntry[] outputs = new IOutputEntry[list.size()];
|
||||||
|
@ -558,8 +557,8 @@ public class CProject extends Openable implements ICProject {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IOutputEntry[] entries = getOutputEntries();
|
IOutputEntry[] entries = getOutputEntries();
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (IOutputEntry entrie : entries) {
|
||||||
boolean on = isOnOutputEntry(entries[i], path);
|
boolean on = isOnOutputEntry(entrie, path);
|
||||||
if (on) {
|
if (on) {
|
||||||
return on;
|
return on;
|
||||||
}
|
}
|
||||||
|
@ -582,7 +581,7 @@ public class CProject extends Openable implements ICProject {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm,
|
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm,
|
||||||
Map newElements, IResource underlyingResource)
|
Map<ICElement, CElementInfo> newElements, IResource underlyingResource)
|
||||||
throws CModelException {
|
throws CModelException {
|
||||||
boolean validInfo = false;
|
boolean validInfo = false;
|
||||||
try {
|
try {
|
||||||
|
@ -612,9 +611,8 @@ public class CProject extends Openable implements ICProject {
|
||||||
|
|
||||||
if(entries != null){
|
if(entries != null){
|
||||||
ArrayList<ISourceRoot> list = new ArrayList<ISourceRoot>(entries.length);
|
ArrayList<ISourceRoot> list = new ArrayList<ISourceRoot>(entries.length);
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (ICSourceEntry sourceEntry : entries) {
|
||||||
ICSourceEntry sourceEntry = entries[i];
|
ISourceRoot root = getSourceRoot(sourceEntry);
|
||||||
ISourceRoot root = getSourceRoot(sourceEntry);
|
|
||||||
if (root != null) {
|
if (root != null) {
|
||||||
list.add(root);
|
list.add(root);
|
||||||
}
|
}
|
||||||
|
@ -630,8 +628,8 @@ public class CProject extends Openable implements ICProject {
|
||||||
children.addAll(sourceRoots);
|
children.addAll(sourceRoots);
|
||||||
|
|
||||||
boolean projectIsSourceRoot = false;
|
boolean projectIsSourceRoot = false;
|
||||||
for (Iterator<ISourceRoot> i = sourceRoots.iterator(); i.hasNext();)
|
for (ISourceRoot sourceRoot : sourceRoots)
|
||||||
if (i.next().getResource().equals(getProject())) {
|
if (sourceRoot.getResource().equals(getProject())) {
|
||||||
projectIsSourceRoot = true;
|
projectIsSourceRoot = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -639,12 +637,10 @@ public class CProject extends Openable implements ICProject {
|
||||||
// Now look for output folders
|
// Now look for output folders
|
||||||
try {
|
try {
|
||||||
IResource[] resources = getProject().members();
|
IResource[] resources = getProject().members();
|
||||||
for (int i = 0; i < resources.length; i++) {
|
for (IResource child : resources) {
|
||||||
IResource child = resources[i];
|
|
||||||
if (child.getType() == IResource.FOLDER) {
|
if (child.getType() == IResource.FOLDER) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (Iterator<ISourceRoot> iter = sourceRoots.iterator(); iter.hasNext();) {
|
for (ISourceRoot sourceRoot : sourceRoots) {
|
||||||
ISourceRoot sourceRoot = iter.next();
|
|
||||||
if (sourceRoot.isOnSourceEntry(child)) {
|
if (sourceRoot.isOnSourceEntry(child)) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
@ -677,8 +673,8 @@ public class CProject extends Openable implements ICProject {
|
||||||
public boolean isOnSourceRoot(ICElement element) {
|
public boolean isOnSourceRoot(ICElement element) {
|
||||||
try {
|
try {
|
||||||
ISourceRoot[] roots = getSourceRoots();
|
ISourceRoot[] roots = getSourceRoots();
|
||||||
for (int i = 0; i < roots.length; i++) {
|
for (ISourceRoot root : roots) {
|
||||||
if (roots[i].isOnSourceEntry(element)) {
|
if (root.isOnSourceEntry(element)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -694,8 +690,8 @@ public class CProject extends Openable implements ICProject {
|
||||||
public boolean isOnSourceRoot(IResource resource) {
|
public boolean isOnSourceRoot(IResource resource) {
|
||||||
try {
|
try {
|
||||||
ISourceRoot[] roots = getSourceRoots();
|
ISourceRoot[] roots = getSourceRoots();
|
||||||
for (int i = 0; i < roots.length; i++) {
|
for (ISourceRoot root : roots) {
|
||||||
if (roots[i].isOnSourceEntry(resource)) {
|
if (root.isOnSourceEntry(resource)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,14 +65,11 @@ class CProjectInfo extends OpenableInfo {
|
||||||
return vLib;
|
return vLib;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Object[] getNonCResources(IResource res) {
|
public Object[] getNonCResources(IResource res) {
|
||||||
if (nonCResources != null)
|
if (nonCResources != null)
|
||||||
return nonCResources;
|
return nonCResources;
|
||||||
|
|
||||||
List notChildren = new ArrayList();
|
List<IResource> notChildren = new ArrayList<IResource>();
|
||||||
try {
|
try {
|
||||||
if (res instanceof IContainer) {
|
if (res instanceof IContainer) {
|
||||||
ICProject cproject = getElement().getCProject();
|
ICProject cproject = getElement().getCProject();
|
||||||
|
@ -128,10 +125,6 @@ class CProjectInfo extends OpenableInfo {
|
||||||
return nonCResources;
|
return nonCResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param container
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public void setNonCResources(Object[] resources) {
|
public void setNonCResources(Object[] resources) {
|
||||||
nonCResources = resources;
|
nonCResources = resources;
|
||||||
}
|
}
|
||||||
|
@ -141,18 +134,18 @@ class CProjectInfo extends OpenableInfo {
|
||||||
*/
|
*/
|
||||||
public void resetCaches() {
|
public void resetCaches() {
|
||||||
if (libReferences != null) {
|
if (libReferences != null) {
|
||||||
for (int i = 0; i < libReferences.length; i++) {
|
for (ILibraryReference libReference : libReferences) {
|
||||||
try {
|
try {
|
||||||
((CElement)libReferences[i]).close();
|
((CElement)libReference).close();
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (incReferences != null) {
|
if (incReferences != null) {
|
||||||
for (int i = 0; i < incReferences.length; i++) {
|
for (IIncludeReference incReference : incReferences) {
|
||||||
try {
|
try {
|
||||||
((CElement)incReferences[i]).close();
|
((CElement)incReference).close();
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,14 +147,12 @@ public class CommitWorkingCopyOperation extends CModelOperation {
|
||||||
|
|
||||||
worked(1);
|
worked(1);
|
||||||
|
|
||||||
if (deltaBuilder != null) {
|
// build the deltas
|
||||||
// build the deltas
|
deltaBuilder.buildDeltas();
|
||||||
deltaBuilder.buildDeltas();
|
|
||||||
|
|
||||||
// add the deltas to the list of deltas created during this operation
|
// add the deltas to the list of deltas created during this operation
|
||||||
if (deltaBuilder.delta != null) {
|
if (deltaBuilder.delta != null) {
|
||||||
addDelta(deltaBuilder.delta);
|
addDelta(deltaBuilder.delta);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
worked(1);
|
worked(1);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -328,11 +328,11 @@ public class ContentTypeProcessor extends CModelOperation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Assume a workspace resolver
|
// 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) {
|
for (int i = 0; i < cprojects.length; ++i) {
|
||||||
list.add(cprojects[i]);
|
list.add(cprojects[i]);
|
||||||
}
|
}
|
||||||
return (ICProject[]) list.toArray(new ICProject[list.size()]);
|
return list.toArray(new ICProject[list.size()]);
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,7 +170,7 @@ public class CopyElementsOperation extends MultiOperation {
|
||||||
|
|
||||||
if (isInTUOperation) {
|
if (isInTUOperation) {
|
||||||
CreateElementInTUOperation inTUop = (CreateElementInTUOperation)op;
|
CreateElementInTUOperation inTUop = (CreateElementInTUOperation)op;
|
||||||
ICElement sibling = (ICElement) fInsertBeforeElements.get(element);
|
ICElement sibling = fInsertBeforeElements.get(element);
|
||||||
if (sibling != null) {
|
if (sibling != null) {
|
||||||
(inTUop).setRelativePosition(sibling, CreateElementInTUOperation.INSERT_BEFORE);
|
(inTUop).setRelativePosition(sibling, CreateElementInTUOperation.INSERT_BEFORE);
|
||||||
} else if (isRename()) {
|
} else if (isRename()) {
|
||||||
|
@ -200,8 +200,7 @@ public class CopyElementsOperation extends MultiOperation {
|
||||||
private ICElement resolveRenameAnchor(ICElement element) throws CModelException {
|
private ICElement resolveRenameAnchor(ICElement element) throws CModelException {
|
||||||
IParent parent = (IParent) element.getParent();
|
IParent parent = (IParent) element.getParent();
|
||||||
ICElement[] children = parent.getChildren();
|
ICElement[] children = parent.getChildren();
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (ICElement child : children) {
|
||||||
ICElement child = children[i];
|
|
||||||
if (child.equals(element)) {
|
if (child.equals(element)) {
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
@ -256,18 +255,19 @@ public class CopyElementsOperation extends MultiOperation {
|
||||||
protected void verify(ICElement element) throws CModelException {
|
protected void verify(ICElement element) throws CModelException {
|
||||||
if (element == null || !element.exists())
|
if (element == null || !element.exists())
|
||||||
error(ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST, element);
|
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)
|
if (element.isReadOnly())
|
||||||
error(ICModelStatusConstants.INVALID_ELEMENT_TYPES, element);
|
error(ICModelStatusConstants.READ_ONLY, element);
|
||||||
|
|
||||||
if (element.isReadOnly())
|
ICElement dest = getDestinationParent(element);
|
||||||
error(ICModelStatusConstants.READ_ONLY, element);
|
verifyDestination(element, dest);
|
||||||
|
verifySibling(element, dest);
|
||||||
ICElement dest = getDestinationParent(element);
|
if (fRenamingsList != null) {
|
||||||
verifyDestination(element, dest);
|
verifyRenaming(element);
|
||||||
verifySibling(element, dest);
|
}
|
||||||
if (fRenamingsList != null) {
|
|
||||||
verifyRenaming(element);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.model;
|
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.CModelException;
|
||||||
import org.eclipse.cdt.core.model.IBuffer;
|
import org.eclipse.cdt.core.model.IBuffer;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
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;
|
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
|
* 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.
|
* source code for the entire compilation unit is updated and saved.
|
||||||
*
|
*
|
||||||
|
@ -174,8 +175,8 @@ public abstract class CreateElementInTUOperation extends CModelOperation {
|
||||||
fResultElements = generateResultHandles();
|
fResultElements = generateResultHandles();
|
||||||
if (!isWorkingCopy) { // if unit is working copy, then save will have already fired the delta
|
if (!isWorkingCopy) { // if unit is working copy, then save will have already fired the delta
|
||||||
if (unit.getParent().exists()) {
|
if (unit.getParent().exists()) {
|
||||||
for (int i = 0; i < fResultElements.length; i++) {
|
for (ICElement resultElement : fResultElements) {
|
||||||
delta.added(fResultElements[i]);
|
delta.added(resultElement);
|
||||||
}
|
}
|
||||||
addDelta(delta);
|
addDelta(delta);
|
||||||
} // else unit is created outside classpath
|
} // 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
|
* Returns the amount of work for the main task of this operation for
|
||||||
* progress reporting.
|
* progress reporting.
|
||||||
* @see executeOperation()
|
* @see #executeOperation()
|
||||||
*/
|
*/
|
||||||
protected int getMainAmountOfWork(){
|
protected int getMainAmountOfWork(){
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -220,7 +221,7 @@ public abstract class CreateElementInTUOperation extends CModelOperation {
|
||||||
/**
|
/**
|
||||||
* Returns the name of the main task of this operation for
|
* Returns the name of the main task of this operation for
|
||||||
* progress reporting.
|
* progress reporting.
|
||||||
* @see executeOperation()
|
* @see #executeOperation()
|
||||||
*/
|
*/
|
||||||
protected abstract String getMainTaskName();
|
protected abstract String getMainTaskName();
|
||||||
|
|
||||||
|
@ -246,8 +247,8 @@ public abstract class CreateElementInTUOperation extends CModelOperation {
|
||||||
* Inserts the given child into the given JDOM,
|
* Inserts the given child into the given JDOM,
|
||||||
* based on the position settings of this operation.
|
* based on the position settings of this operation.
|
||||||
*
|
*
|
||||||
* @see createAfter(IJavaElement)
|
* @see #createAfter(ICElement)
|
||||||
* @see createBefore(IJavaElement);
|
* @see #createBefore(ICElement)
|
||||||
*/
|
*/
|
||||||
protected void insertElement() throws CModelException {
|
protected void insertElement() throws CModelException {
|
||||||
if (fInsertionPolicy != INSERT_LAST) {
|
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.
|
* <li>INVALID_SIBLING - the sibling provided for positioning is not valid.
|
||||||
* </ul>
|
* </ul>
|
||||||
* @see ICModelStatus
|
* @see ICModelStatus
|
||||||
* @see CNamingConventions
|
* @see CConventions
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ICModelStatus verify() {
|
public ICModelStatus verify() {
|
||||||
|
|
|
@ -13,8 +13,8 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
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.ICModelStatus;
|
||||||
|
import org.eclipse.cdt.core.model.IStructure;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
/**
|
/**
|
||||||
* <p>This operation creates a field declaration in a type.
|
* <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
|
@Override
|
||||||
public String getMainTaskName(){
|
public String getMainTaskName(){
|
||||||
|
@ -75,7 +75,7 @@ public class CreateFieldOperation extends CreateMemberOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CreateElementInCUOperation#generateResultHandle
|
* @see CreateElementInTUOperation#generateResultHandle
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected ICElement generateResultHandle() {
|
protected ICElement generateResultHandle() {
|
||||||
|
@ -83,7 +83,7 @@ public class CreateFieldOperation extends CreateMemberOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CreateTypeMemberOperation#verifyNameCollision
|
* @see CreateMemberOperation#verifyNameCollision
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected ICModelStatus verifyNameCollision() {
|
protected ICModelStatus verifyNameCollision() {
|
||||||
|
|
|
@ -13,12 +13,12 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CConventions;
|
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.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.ICModelStatus;
|
||||||
import org.eclipse.cdt.core.model.ICModelStatusConstants;
|
import org.eclipse.cdt.core.model.ICModelStatusConstants;
|
||||||
import org.eclipse.cdt.core.model.IInclude;
|
import org.eclipse.cdt.core.model.IInclude;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
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.resources.IProject;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public class CreateIncludeOperation extends CreateElementInTUOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CreateElementInCUOperation#generateResultHandle
|
* @see CreateElementInTUOperation#generateResultHandle
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected ICElement generateResultHandle() {
|
protected ICElement generateResultHandle() {
|
||||||
|
@ -64,7 +64,7 @@ public class CreateIncludeOperation extends CreateElementInTUOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CreateElementInCUOperation#getMainTaskName
|
* @see CreateElementInTUOperation#getMainTaskName
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getMainTaskName(){
|
public String getMainTaskName(){
|
||||||
|
@ -97,7 +97,7 @@ public class CreateIncludeOperation extends CreateElementInTUOperation {
|
||||||
* <li>INVALID_NAME - not a valid include declaration name.
|
* <li>INVALID_NAME - not a valid include declaration name.
|
||||||
* </ul>
|
* </ul>
|
||||||
* @see ICModelStatus
|
* @see ICModelStatus
|
||||||
* @see CNamingConventions
|
* @see CConventions
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ICModelStatus verify() {
|
public ICModelStatus verify() {
|
||||||
|
|
|
@ -13,9 +13,9 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
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.ICModelStatusConstants;
|
||||||
import org.eclipse.cdt.core.model.IStructure;
|
import org.eclipse.cdt.core.model.IStructure;
|
||||||
import org.eclipse.cdt.core.model.ICModelStatus;
|
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,7 +50,7 @@ public class CreateMethodOperation extends CreateMemberOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CreateElementInCUOperation#generateResultHandle
|
* @see CreateElementInTUOperation#generateResultHandle
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected ICElement generateResultHandle() {
|
protected ICElement generateResultHandle() {
|
||||||
|
@ -59,7 +59,7 @@ public class CreateMethodOperation extends CreateMemberOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CreateElementInCUOperation#getMainTaskName
|
* @see CreateElementInTUOperation#getMainTaskName
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getMainTaskName(){
|
public String getMainTaskName(){
|
||||||
|
@ -67,7 +67,7 @@ public class CreateMethodOperation extends CreateMemberOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CreateTypeMemberOperation#verifyNameCollision
|
* @see CreateMemberOperation#verifyNameCollision
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected ICModelStatus verifyNameCollision() {
|
protected ICModelStatus verifyNameCollision() {
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class CreateNamespaceOperation extends CreateElementInTUOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CreateElementInCUOperation#generateResultHandle
|
* @see CreateElementInTUOperation#generateResultHandle
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected ICElement generateResultHandle() {
|
protected ICElement generateResultHandle() {
|
||||||
|
@ -47,7 +47,7 @@ public class CreateNamespaceOperation extends CreateElementInTUOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CreateElementInCUOperation#getMainTaskName
|
* @see CreateElementInTUOperation#getMainTaskName
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getMainTaskName(){
|
public String getMainTaskName(){
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class CreateUsingOperation extends CreateElementInTUOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CreateElementInCUOperation#generateResultHandle
|
* @see CreateElementInTUOperation#generateResultHandle
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected ICElement generateResultHandle() {
|
protected ICElement generateResultHandle() {
|
||||||
|
@ -54,7 +54,7 @@ public class CreateUsingOperation extends CreateElementInTUOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CreateElementInCUOperation#getMainTaskName
|
* @see CreateElementInTUOperation#getMainTaskName
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getMainTaskName(){
|
public String getMainTaskName(){
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.core.resources.IFile;
|
||||||
*/
|
*/
|
||||||
public class CreateWorkingCopyOperation extends CModelOperation {
|
public class CreateWorkingCopyOperation extends CModelOperation {
|
||||||
|
|
||||||
Map perFactoryWorkingCopies;
|
Map<ITranslationUnit, WorkingCopy> perFactoryWorkingCopies;
|
||||||
IBufferFactory factory;
|
IBufferFactory factory;
|
||||||
IProblemRequestor problemRequestor;
|
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.
|
* 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.
|
* 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});
|
super(new ICElement[] {originalElement});
|
||||||
this.perFactoryWorkingCopies = perFactoryWorkingCopies;
|
this.perFactoryWorkingCopies = perFactoryWorkingCopies;
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
|
@ -78,7 +78,7 @@ public class CreateWorkingCopyOperation extends CModelOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see JavaModelOperation#isReadOnly
|
* @see CModelOperation#isReadOnly
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isReadOnly() {
|
public boolean isReadOnly() {
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
||||||
|
|
||||||
static final IPathEntry[] NO_PATHENTRIES = new IPathEntry[0];
|
static final IPathEntry[] NO_PATHENTRIES = new IPathEntry[0];
|
||||||
|
|
||||||
List listeners;
|
List<IPathEntryStoreListener> listeners;
|
||||||
IProject fProject;
|
IProject fProject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,7 +79,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
||||||
*/
|
*/
|
||||||
public DefaultPathEntryStore(IProject project) {
|
public DefaultPathEntryStore(IProject project) {
|
||||||
fProject = project;
|
fProject = project;
|
||||||
listeners = Collections.synchronizedList(new ArrayList());
|
listeners = Collections.synchronizedList(new ArrayList<IPathEntryStoreListener>());
|
||||||
// Register the Core Model on the Descriptor
|
// Register the Core Model on the Descriptor
|
||||||
// Manager, it needs to know about changes.
|
// Manager, it needs to know about changes.
|
||||||
CCorePlugin.getDefault().getCDescriptorManager().addDescriptorListener(this);
|
CCorePlugin.getDefault().getCDescriptorManager().addDescriptorListener(this);
|
||||||
|
@ -88,7 +88,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
||||||
public IPathEntry[] getRawPathEntries() throws CoreException {
|
public IPathEntry[] getRawPathEntries() throws CoreException {
|
||||||
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(fProject, false);
|
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(fProject, false);
|
||||||
if (cdesc != null) {
|
if (cdesc != null) {
|
||||||
ArrayList pathEntries = new ArrayList();
|
ArrayList<IPathEntry> pathEntries = new ArrayList<IPathEntry>();
|
||||||
Element element = cdesc.getProjectData(PATH_ENTRY_ID);
|
Element element = cdesc.getProjectData(PATH_ENTRY_ID);
|
||||||
NodeList list = element.getChildNodes();
|
NodeList list = element.getChildNodes();
|
||||||
for (int i = 0; i < list.getLength(); i++) {
|
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(
|
IPath sourceAttachmentPrefixMapping = element.hasAttribute(ATTRIBUTE_PREFIXMAPPING) ? new Path(
|
||||||
element.getAttribute(ATTRIBUTE_PREFIXMAPPING)) : null;
|
element.getAttribute(ATTRIBUTE_PREFIXMAPPING)) : null;
|
||||||
|
|
||||||
if (baseRef != null && !baseRef.isEmpty()) {
|
if (!baseRef.isEmpty()) {
|
||||||
return CoreModel.newLibraryRefEntry(path, baseRef, libraryPath);
|
return CoreModel.newLibraryRefEntry(path, baseRef, libraryPath);
|
||||||
}
|
}
|
||||||
return CoreModel.newLibraryEntry(path, basePath, libraryPath, sourceAttachmentPath, sourceAttachmentRootPath,
|
return CoreModel.newLibraryEntry(path, basePath, libraryPath, sourceAttachmentPath, sourceAttachmentRootPath,
|
||||||
|
@ -212,7 +212,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
||||||
if (element.hasAttribute(ATTRIBUTE_SYSTEM)) {
|
if (element.hasAttribute(ATTRIBUTE_SYSTEM)) {
|
||||||
isSystemInclude = element.getAttribute(ATTRIBUTE_SYSTEM).equals(VALUE_TRUE);
|
isSystemInclude = element.getAttribute(ATTRIBUTE_SYSTEM).equals(VALUE_TRUE);
|
||||||
}
|
}
|
||||||
if (baseRef != null && !baseRef.isEmpty()) {
|
if (!baseRef.isEmpty()) {
|
||||||
return CoreModel.newIncludeRefEntry(path, baseRef, includePath);
|
return CoreModel.newIncludeRefEntry(path, baseRef, includePath);
|
||||||
}
|
}
|
||||||
return CoreModel.newIncludeEntry(path, basePath, includePath, isSystemInclude, exclusionPatterns, isExported);
|
return CoreModel.newIncludeEntry(path, basePath, includePath, isSystemInclude, exclusionPatterns, isExported);
|
||||||
|
@ -225,7 +225,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
||||||
case IPathEntry.CDT_MACRO : {
|
case IPathEntry.CDT_MACRO : {
|
||||||
String macroName = element.getAttribute(ATTRIBUTE_NAME);
|
String macroName = element.getAttribute(ATTRIBUTE_NAME);
|
||||||
String macroValue = element.getAttribute(ATTRIBUTE_VALUE);
|
String macroValue = element.getAttribute(ATTRIBUTE_VALUE);
|
||||||
if (baseRef != null && !baseRef.isEmpty()) {
|
if (!baseRef.isEmpty()) {
|
||||||
return CoreModel.newMacroRefEntry(path, baseRef, macroName);
|
return CoreModel.newMacroRefEntry(path, baseRef, macroName);
|
||||||
}
|
}
|
||||||
return CoreModel.newMacroEntry(path, macroName, macroValue, exclusionPatterns, isExported);
|
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) {
|
static void encodePathEntries(IPath projectPath, Document doc, Element configRootElement, IPathEntry[] entries) {
|
||||||
Element element;
|
Element element;
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (IPathEntry entrie : entries) {
|
||||||
element = doc.createElement(PATH_ENTRY);
|
element = doc.createElement(PATH_ENTRY);
|
||||||
|
|
||||||
configRootElement.appendChild(element);
|
configRootElement.appendChild(element);
|
||||||
int kind = entries[i].getEntryKind();
|
int kind = entrie.getEntryKind();
|
||||||
// Set the kind
|
// Set the kind
|
||||||
element.setAttribute(ATTRIBUTE_KIND, PathEntry.kindToString(kind));
|
element.setAttribute(ATTRIBUTE_KIND, PathEntry.kindToString(kind));
|
||||||
|
|
||||||
// translate the project prefix.
|
// translate the project prefix.
|
||||||
IPath xmlPath = entries[i].getPath();
|
IPath xmlPath = entrie.getPath();
|
||||||
if (xmlPath == null) {
|
if (xmlPath == null) {
|
||||||
xmlPath = new Path(""); //$NON-NLS-1$
|
xmlPath = new Path(""); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
||||||
case IPathEntry.CDT_CONTAINER:
|
case IPathEntry.CDT_CONTAINER:
|
||||||
break;
|
break;
|
||||||
case IPathEntry.CDT_LIBRARY: {
|
case IPathEntry.CDT_LIBRARY: {
|
||||||
ILibraryEntry lib = (ILibraryEntry) entries[i];
|
ILibraryEntry lib = (ILibraryEntry) entrie;
|
||||||
IPath libraryPath = lib.getLibraryPath();
|
IPath libraryPath = lib.getLibraryPath();
|
||||||
element.setAttribute(ATTRIBUTE_LIBRARY, libraryPath.toString());
|
element.setAttribute(ATTRIBUTE_LIBRARY, libraryPath.toString());
|
||||||
IPath sourcePath = lib.getSourceAttachmentPath();
|
IPath sourcePath = lib.getSourceAttachmentPath();
|
||||||
|
@ -308,7 +308,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_INCLUDE: {
|
case IPathEntry.CDT_INCLUDE: {
|
||||||
IIncludeEntry include = (IIncludeEntry) entries[i];
|
IIncludeEntry include = (IIncludeEntry) entrie;
|
||||||
IPath includePath = include.getIncludePath();
|
IPath includePath = include.getIncludePath();
|
||||||
element.setAttribute(ATTRIBUTE_INCLUDE, includePath.toString());
|
element.setAttribute(ATTRIBUTE_INCLUDE, includePath.toString());
|
||||||
if (include.isSystemInclude()) {
|
if (include.isSystemInclude()) {
|
||||||
|
@ -317,26 +317,26 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_INCLUDE_FILE: {
|
case IPathEntry.CDT_INCLUDE_FILE: {
|
||||||
IIncludeFileEntry include = (IIncludeFileEntry) entries[i];
|
IIncludeFileEntry include = (IIncludeFileEntry) entrie;
|
||||||
IPath includeFilePath = include.getIncludeFilePath();
|
IPath includeFilePath = include.getIncludeFilePath();
|
||||||
element.setAttribute(ATTRIBUTE_INCLUDE_FILE, includeFilePath.toString());
|
element.setAttribute(ATTRIBUTE_INCLUDE_FILE, includeFilePath.toString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_MACRO: {
|
case IPathEntry.CDT_MACRO: {
|
||||||
IMacroEntry macro = (IMacroEntry) entries[i];
|
IMacroEntry macro = (IMacroEntry) entrie;
|
||||||
element.setAttribute(ATTRIBUTE_NAME, macro.getMacroName());
|
element.setAttribute(ATTRIBUTE_NAME, macro.getMacroName());
|
||||||
element.setAttribute(ATTRIBUTE_VALUE, macro.getMacroValue());
|
element.setAttribute(ATTRIBUTE_VALUE, macro.getMacroValue());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IPathEntry.CDT_MACRO_FILE: {
|
case IPathEntry.CDT_MACRO_FILE: {
|
||||||
IMacroFileEntry macro = (IMacroFileEntry) entries[i];
|
IMacroFileEntry macro = (IMacroFileEntry) entrie;
|
||||||
element.setAttribute(ATTRIBUTE_MACRO_FILE, macro.getMacroFilePath().toString());
|
element.setAttribute(ATTRIBUTE_MACRO_FILE, macro.getMacroFilePath().toString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entries[i] instanceof APathEntry) {
|
if (entrie instanceof APathEntry) {
|
||||||
APathEntry entry = (APathEntry) entries[i];
|
APathEntry entry = (APathEntry) entrie;
|
||||||
|
|
||||||
// save the basePath or the baseRef
|
// save the basePath or the baseRef
|
||||||
IPath basePath = entry.getBasePath();
|
IPath basePath = entry.getBasePath();
|
||||||
|
@ -362,7 +362,7 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the export attribute
|
// Save the export attribute
|
||||||
if (entries[i].isExported()) {
|
if (entrie.isExported()) {
|
||||||
element.setAttribute(ATTRIBUTE_EXPORTED, VALUE_TRUE);
|
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);
|
PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, project, PathEntryStoreChangedEvent.CONTENT_CHANGED);
|
||||||
IPathEntryStoreListener[] observers = new IPathEntryStoreListener[listeners.size()];
|
IPathEntryStoreListener[] observers = new IPathEntryStoreListener[listeners.size()];
|
||||||
listeners.toArray(observers);
|
listeners.toArray(observers);
|
||||||
for (int i = 0; i < observers.length; i++) {
|
for (IPathEntryStoreListener observer : observers) {
|
||||||
observers[i].pathEntryStoreChanged(evt);
|
observer.pathEntryStoreChanged(evt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,8 +414,8 @@ public class DefaultPathEntryStore implements IPathEntryStore, ICDescriptorListe
|
||||||
PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, fProject, PathEntryStoreChangedEvent.STORE_CLOSED);
|
PathEntryStoreChangedEvent evt = new PathEntryStoreChangedEvent(this, fProject, PathEntryStoreChangedEvent.STORE_CLOSED);
|
||||||
IPathEntryStoreListener[] observers = new IPathEntryStoreListener[listeners.size()];
|
IPathEntryStoreListener[] observers = new IPathEntryStoreListener[listeners.size()];
|
||||||
listeners.toArray(observers);
|
listeners.toArray(observers);
|
||||||
for (int i = 0; i < observers.length; i++) {
|
for (IPathEntryStoreListener observer : observers) {
|
||||||
observers[i].pathEntryStoreChanged(evt);
|
observer.pathEntryStoreChanged(evt);
|
||||||
}
|
}
|
||||||
CCorePlugin.getDefault().getCDescriptorManager().removeDescriptorListener(this);
|
CCorePlugin.getDefault().getCDescriptorManager().removeDescriptorListener(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,11 +32,11 @@ import org.eclipse.cdt.internal.core.CharOperation;
|
||||||
public class DeleteElementsOperation extends MultiOperation {
|
public class DeleteElementsOperation extends MultiOperation {
|
||||||
/**
|
/**
|
||||||
* The elements this operation processes grouped by compilation unit
|
* 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
|
* values are <code>IRegion</code>s of elements to be processed in each
|
||||||
* compilation unit.
|
* compilation unit.
|
||||||
*/
|
*/
|
||||||
protected Map fChildrenToRemove;
|
protected Map<ITranslationUnit, IRegion> fChildrenToRemove;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When executed, this operation will delete the given elements. The elements
|
* 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.
|
* duplicates specified in elements to be processed.
|
||||||
*/
|
*/
|
||||||
protected void groupElements() throws CModelException {
|
protected void groupElements() throws CModelException {
|
||||||
fChildrenToRemove = new HashMap(1);
|
fChildrenToRemove = new HashMap<ITranslationUnit, IRegion>(1);
|
||||||
int uniqueTUs = 0;
|
int uniqueTUs = 0;
|
||||||
for (int i = 0, length = fElementsToProcess.length; i < length; i++) {
|
for (ICElement e : fElementsToProcess) {
|
||||||
ICElement e = fElementsToProcess[i];
|
|
||||||
ITranslationUnit tu = getTranslationUnitFor(e);
|
ITranslationUnit tu = getTranslationUnitFor(e);
|
||||||
if (tu == null) {
|
if (tu == null) {
|
||||||
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, e));
|
throw new CModelException(new CModelStatus(ICModelStatusConstants.READ_ONLY, e));
|
||||||
}
|
}
|
||||||
IRegion region = (IRegion) fChildrenToRemove.get(tu);
|
IRegion region = fChildrenToRemove.get(tu);
|
||||||
if (region == null) {
|
if (region == null) {
|
||||||
region = new Region();
|
region = new Region();
|
||||||
fChildrenToRemove.put(tu, region);
|
fChildrenToRemove.put(tu, region);
|
||||||
|
@ -79,10 +78,10 @@ public class DeleteElementsOperation extends MultiOperation {
|
||||||
region.add(e);
|
region.add(e);
|
||||||
}
|
}
|
||||||
fElementsToProcess = new ICElement[uniqueTUs];
|
fElementsToProcess = new ICElement[uniqueTUs];
|
||||||
Iterator iter = fChildrenToRemove.keySet().iterator();
|
Iterator<ITranslationUnit> iter = fChildrenToRemove.keySet().iterator();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (iter.hasNext()) {
|
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();
|
IBuffer buffer = tu.getBuffer();
|
||||||
if (buffer == null) return;
|
if (buffer == null) return;
|
||||||
CElementDelta delta = new CElementDelta(tu);
|
CElementDelta delta = new CElementDelta(tu);
|
||||||
ICElement[] cuElements = ((IRegion) fChildrenToRemove.get(tu)).getElements();
|
ICElement[] cuElements = fChildrenToRemove.get(tu).getElements();
|
||||||
for (int i = 0, length = cuElements.length; i < length; i++) {
|
for (ICElement e : cuElements) {
|
||||||
ICElement e = cuElements[i];
|
|
||||||
if (e.exists()) {
|
if (e.exists()) {
|
||||||
char[] contents = buffer.getCharacters();
|
char[] contents = buffer.getCharacters();
|
||||||
if (contents == null) continue;
|
if (contents == null) continue;
|
||||||
|
@ -165,9 +163,8 @@ public class DeleteElementsOperation extends MultiOperation {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void verify(ICElement element) throws CModelException {
|
protected void verify(ICElement element) throws CModelException {
|
||||||
ICElement[] children = ((IRegion) fChildrenToRemove.get(element)).getElements();
|
ICElement[] children = fChildrenToRemove.get(element).getElements();
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (ICElement child : children) {
|
||||||
ICElement child = children[i];
|
|
||||||
if (child.getResource() != null)
|
if (child.getResource() != null)
|
||||||
error(ICModelStatusConstants.INVALID_ELEMENT_TYPES, child);
|
error(ICModelStatusConstants.INVALID_ELEMENT_TYPES, child);
|
||||||
if (child.isReadOnly())
|
if (child.isReadOnly())
|
||||||
|
|
|
@ -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>.
|
* <code>deletePackageFragment</code> depending on the type of <code>element</code>.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -12,8 +12,9 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
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)
|
* 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
|
// In order to be shared, working copies have to denote the same compilation unit
|
||||||
// AND use the same buffer factory.
|
// AND use the same buffer factory.
|
||||||
// Assuming there is a little set of buffer factories, then use a 2 level Map cache.
|
// 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 != null) {
|
||||||
if (perFactoryWorkingCopies.remove(originalElement) != null) {
|
if (perFactoryWorkingCopies.remove(originalElement) != null) {
|
||||||
//System.out.println("Destroying shared working copy " + workingCopy.toStringWithAncestors());//$NON-NLS-1$
|
//System.out.println("Destroying shared working copy " + workingCopy.toStringWithAncestors());//$NON-NLS-1$
|
||||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.IOpenable;
|
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.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.
|
* 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.
|
* Constructs a new element cache of the given size.
|
||||||
|
@ -43,8 +42,8 @@ public class ElementCache extends OverflowingLRUCache {
|
||||||
* by closing the element.
|
* by closing the element.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected boolean close(LRUCacheEntry entry) {
|
protected boolean close(LRUCacheEntry<IOpenable, T> entry) {
|
||||||
IOpenable element = (IOpenable) entry._fKey;
|
IOpenable element = entry._fKey;
|
||||||
try {
|
try {
|
||||||
if (element.hasUnsavedChanges()) {
|
if (element.hasUnsavedChanges()) {
|
||||||
return false;
|
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
|
@Override
|
||||||
protected LRUCache newInstance(int size, int overflow) {
|
protected OverflowingLRUCache<IOpenable, T> newInstance(int size, int overflow) {
|
||||||
return new ElementCache(size, overflow);
|
return new ElementCache<T>(size, overflow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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() {
|
public String getConstantExpression() {
|
||||||
return constantExpression;
|
return constantExpression;
|
||||||
|
|
|
@ -22,10 +22,6 @@ import org.eclipse.cdt.core.model.ICElement;
|
||||||
*/
|
*/
|
||||||
public class ExternalTranslationUnit extends TranslationUnit {
|
public class ExternalTranslationUnit extends TranslationUnit {
|
||||||
|
|
||||||
/**
|
|
||||||
* @param parent
|
|
||||||
* @param path
|
|
||||||
*/
|
|
||||||
public ExternalTranslationUnit(ICElement parent, URI uri, String contentTypeID) {
|
public ExternalTranslationUnit(ICElement parent, URI uri, String contentTypeID) {
|
||||||
super(parent, uri, contentTypeID);
|
super(parent, uri, contentTypeID);
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,9 +82,6 @@ public class FieldInfo extends SourceManipulationInfo {
|
||||||
this.visibility = visibility;
|
this.visibility = visibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.internal.core.model.SourceManipulationInfo#hasSameContentsAs(SourceManipulationInfo)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasSameContentsAs( SourceManipulationInfo info){
|
public boolean hasSameContentsAs( SourceManipulationInfo info){
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,6 @@ class FunctionInfo extends SourceManipulationInfo {
|
||||||
this.isVolatile = isVolatile;
|
this.isVolatile = isVolatile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.internal.core.model.SourceManipulationInfo#hasSameContentsAs(org.eclipse.cdt.internal.core.model.SourceManipulationInfo)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasSameContentsAs(SourceManipulationInfo otherInfo) {
|
public boolean hasSameContentsAs(SourceManipulationInfo otherInfo) {
|
||||||
return (super.hasSameContentsAs(otherInfo)
|
return (super.hasSameContentsAs(otherInfo)
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class FunctionTemplate extends Function implements IFunctionTemplate {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the parameterTypes.
|
* Returns the parameterTypes.
|
||||||
* @see org.eclipse.cdt.core.model.ITemplate#getParameters()
|
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes()
|
||||||
* @return String[]
|
* @return String[]
|
||||||
*/
|
*/
|
||||||
public String[] getTemplateParameterTypes() {
|
public String[] getTemplateParameterTypes() {
|
||||||
|
@ -34,8 +34,7 @@ public class FunctionTemplate extends Function implements IFunctionTemplate {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the fParameterTypes.
|
* Sets the template parameter types.
|
||||||
* @param fParameterTypes The fParameterTypes to set
|
|
||||||
*/
|
*/
|
||||||
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
||||||
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
||||||
|
|
|
@ -49,8 +49,7 @@ public class FunctionTemplateDeclaration extends FunctionDeclaration implements
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the fParameterTypes.
|
* Sets the template parameter types.
|
||||||
* @param fParameterTypes The fParameterTypes to set
|
|
||||||
*/
|
*/
|
||||||
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
||||||
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
||||||
|
|
|
@ -41,11 +41,6 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
||||||
IIncludeEntry fIncludeEntry;
|
IIncludeEntry fIncludeEntry;
|
||||||
IPath fPath;
|
IPath fPath;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param parent
|
|
||||||
* @param name
|
|
||||||
* @param type
|
|
||||||
*/
|
|
||||||
public IncludeReference(ICProject cproject, IIncludeEntry entry) {
|
public IncludeReference(ICProject cproject, IIncludeEntry entry) {
|
||||||
this(cproject, entry, entry.getFullIncludePath());
|
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)
|
* @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
|
@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);
|
return computeChildren(info, underlyingResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,24 +103,24 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
||||||
String[] names = null;
|
String[] names = null;
|
||||||
if (file != null && file.isDirectory()) {
|
if (file != null && file.isDirectory()) {
|
||||||
names = file.list();
|
names = file.list();
|
||||||
}
|
|
||||||
|
if (names != null) {
|
||||||
if (names != null) {
|
IPath path = new Path(file.getAbsolutePath());
|
||||||
IPath path = new Path(file.getAbsolutePath());
|
for (String name : names) {
|
||||||
for (int i = 0; i < names.length; i++) {
|
File child = new File(file, name);
|
||||||
File child = new File(file, names[i]);
|
ICElement celement = null;
|
||||||
ICElement celement = null;
|
if (child.isDirectory()) {
|
||||||
if (child.isDirectory()) {
|
celement = new IncludeReference(this, fIncludeEntry, new Path(child.getAbsolutePath()));
|
||||||
celement = new IncludeReference(this, fIncludeEntry, new Path(child.getAbsolutePath()));
|
} else if (child.isFile()){
|
||||||
} else if (child.isFile()){
|
String id = CoreModel.getRegistedContentTypeId(getCProject().getProject(), name);
|
||||||
String id = CoreModel.getRegistedContentTypeId(getCProject().getProject(), names[i]);
|
if (id != null) {
|
||||||
if (id != null) {
|
// TODO: should use URI
|
||||||
// TODO: should use URI
|
celement = new ExternalTranslationUnit(this, URIUtil.toURI(path.append(name)), id);
|
||||||
celement = new ExternalTranslationUnit(this, URIUtil.toURI(path.append(names[i])), id);
|
}
|
||||||
|
}
|
||||||
|
if (celement != null) {
|
||||||
|
vChildren.add(celement);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (celement != null) {
|
|
||||||
vChildren.add(celement);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
* @see org.eclipse.cdt.internal.core.model.CElement#generateInfos(java.lang.Object, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
@Override
|
@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
|
@Override
|
||||||
|
|
|
@ -74,9 +74,6 @@ public class MethodInfo extends FunctionInfo {
|
||||||
this.visibility = visibility;
|
this.visibility = visibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.internal.core.model.SourceManipulationInfo#hasSameContentsAs(org.eclipse.cdt.internal.core.model.SourceManipulationInfo)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasSameContentsAs(SourceManipulationInfo otherInfo) {
|
public boolean hasSameContentsAs(SourceManipulationInfo otherInfo) {
|
||||||
return (super.hasSameContentsAs(otherInfo)
|
return (super.hasSameContentsAs(otherInfo)
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class MethodTemplate extends Method implements IMethodTemplate {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the parameterTypes.
|
* Returns the parameterTypes.
|
||||||
* @see org.eclipse.cdt.core.model.ITemplate#getParameters()
|
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes()
|
||||||
* @return String[]
|
* @return String[]
|
||||||
*/
|
*/
|
||||||
public String[] getTemplateParameterTypes() {
|
public String[] getTemplateParameterTypes() {
|
||||||
|
@ -35,7 +35,7 @@ public class MethodTemplate extends Method implements IMethodTemplate {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the fParameterTypes.
|
* Sets the fParameterTypes.
|
||||||
* @param fParameterTypes The fParameterTypes to set
|
* @param templateParameterTypes The template parameter types to set
|
||||||
*/
|
*/
|
||||||
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
||||||
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class MethodTemplateDeclaration extends MethodDeclaration implements IMet
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the fParameterTypes.
|
* Sets the fParameterTypes.
|
||||||
* @param fParameterTypes The fParameterTypes to set
|
* @param templateParameterTypes The template parameter types to set
|
||||||
*/
|
*/
|
||||||
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
||||||
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
||||||
|
|
|
@ -78,7 +78,7 @@ public abstract class Openable extends Parent implements IOpenable, IBufferChang
|
||||||
* if successful, or false if an error is encountered while determining
|
* if successful, or false if an error is encountered while determining
|
||||||
* the structure of this element.
|
* 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.
|
* 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
|
// to see if they have an child with unsaved changes
|
||||||
if (fType == C_MODEL ||
|
if (fType == C_MODEL ||
|
||||||
fType == C_PROJECT) {
|
fType == C_PROJECT) {
|
||||||
Enumeration openBuffers= getBufferManager().getOpenBuffers();
|
Enumeration<IBuffer> openBuffers= getBufferManager().getOpenBuffers();
|
||||||
while (openBuffers.hasMoreElements()) {
|
while (openBuffers.hasMoreElements()) {
|
||||||
IBuffer buffer= (IBuffer)openBuffers.nextElement();
|
IBuffer buffer= openBuffers.nextElement();
|
||||||
if (buffer.hasUnsavedChanges()) {
|
if (buffer.hasUnsavedChanges()) {
|
||||||
ICElement owner= (ICElement)buffer.getOwner();
|
ICElement owner= (ICElement)buffer.getOwner();
|
||||||
if (isAncestorOf(owner)) {
|
if (isAncestorOf(owner)) {
|
||||||
|
@ -228,7 +228,7 @@ public abstract class Openable extends Parent implements IOpenable, IBufferChang
|
||||||
/**
|
/**
|
||||||
* Open the parent element if necessary.
|
* 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();
|
Openable openableParent = (Openable)getOpenableParent();
|
||||||
if (openableParent != null && !openableParent.isOpen()){
|
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)
|
* @see org.eclipse.cdt.internal.core.model.CElement#generateInfos(java.lang.Object, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
@Override
|
@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){
|
if (CModelManager.VERBOSE){
|
||||||
System.out.println("OPENING Element ("+ Thread.currentThread()+"): " + this); //$NON-NLS-1$//$NON-NLS-2$
|
System.out.println("OPENING Element ("+ Thread.currentThread()+"): " + this); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
|
|
|
@ -17,12 +17,7 @@ import org.eclipse.core.runtime.IPath;
|
||||||
* OutputEntry
|
* OutputEntry
|
||||||
*/
|
*/
|
||||||
public class OutputEntry extends APathEntry implements IOutputEntry {
|
public class OutputEntry extends APathEntry implements IOutputEntry {
|
||||||
/**
|
|
||||||
* @param kind
|
|
||||||
* @param path
|
|
||||||
* @param exclusionPatterns
|
|
||||||
* @param isExported
|
|
||||||
*/
|
|
||||||
public OutputEntry(IPath path, IPath[] exclusionPatterns, boolean isExported) {
|
public OutputEntry(IPath path, IPath[] exclusionPatterns, boolean isExported) {
|
||||||
super(CDT_OUTPUT, null, null, path, exclusionPatterns, isExported);
|
super(CDT_OUTPUT, null, null, path, exclusionPatterns, isExported);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,10 +63,10 @@ public abstract class Parent extends CElement {
|
||||||
* @param type
|
* @param type
|
||||||
* @return ArrayList
|
* @return ArrayList
|
||||||
*/
|
*/
|
||||||
public List getChildrenOfType(int type) throws CModelException {
|
public List<ICElement> getChildrenOfType(int type) throws CModelException {
|
||||||
ICElement[] children = getChildren();
|
ICElement[] children = getChildren();
|
||||||
int size = children.length;
|
int size = children.length;
|
||||||
ArrayList list = new ArrayList(size);
|
ArrayList<ICElement> list = new ArrayList<ICElement>(size);
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
CElement elt = (CElement)children[i];
|
CElement elt = (CElement)children[i];
|
||||||
if (elt.getElementType() == type) {
|
if (elt.getElementType() == type) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class PathEntryContainerUpdatesOperation extends CModelOperation {
|
||||||
@Override
|
@Override
|
||||||
protected void executeOperation() throws CModelException {
|
protected void executeOperation() throws CModelException {
|
||||||
PathEntryManager pathEntryManager = PathEntryManager.getDefault();
|
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) {
|
for (int i = 0; i < events.length; ++i) {
|
||||||
PathEntryContainerChanged event = events[i];
|
PathEntryContainerChanged event = events[i];
|
||||||
ICElement celement = CoreModel.getDefault().create(event.getPath());
|
ICElement celement = CoreModel.getDefault().create(event.getPath());
|
||||||
|
|
|
@ -27,12 +27,12 @@ import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPathEntryStore, IPathEntryStoreListener {
|
public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPathEntryStore, IPathEntryStoreListener {
|
||||||
private List fListeners;
|
private List<IPathEntryStoreListener> fListeners;
|
||||||
private IPathEntryStore fStore;
|
private IPathEntryStore fStore;
|
||||||
|
|
||||||
public PathEntryStoreProxy(IProject project){
|
public PathEntryStoreProxy(IProject project){
|
||||||
super(project, PathEntryManager.PATHENTRY_STORE_UNIQ_ID);
|
super(project, PathEntryManager.PATHENTRY_STORE_UNIQ_ID);
|
||||||
fListeners = Collections.synchronizedList(new ArrayList());
|
fListeners = Collections.synchronizedList(new ArrayList<IPathEntryStoreListener>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPathEntryStore getStore(){
|
public IPathEntryStore getStore(){
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class Region implements IRegion {
|
||||||
/**
|
/**
|
||||||
* A collection of the top level elements that have been added to the region
|
* 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.
|
* Creates an empty region.
|
||||||
|
@ -36,7 +36,7 @@ public class Region implements IRegion {
|
||||||
* @see IRegion
|
* @see IRegion
|
||||||
*/
|
*/
|
||||||
public Region() {
|
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) {
|
public boolean contains(ICElement element) {
|
||||||
|
|
||||||
int size = fRootElements.size();
|
int size = fRootElements.size();
|
||||||
ArrayList parents = getAncestors(element);
|
ArrayList<ICElement> parents = getAncestors(element);
|
||||||
|
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
ICElement aTop = (ICElement) fRootElements.get(i);
|
ICElement aTop = fRootElements.get(i);
|
||||||
if (aTop.equals(element)) {
|
if (aTop.equals(element)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -79,8 +79,8 @@ public class Region implements IRegion {
|
||||||
* order.
|
* order.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private ArrayList getAncestors(ICElement element) {
|
private ArrayList<ICElement> getAncestors(ICElement element) {
|
||||||
ArrayList parents = new ArrayList();
|
ArrayList<ICElement> parents = new ArrayList<ICElement>();
|
||||||
ICElement parent = element.getParent();
|
ICElement parent = element.getParent();
|
||||||
while (parent != null) {
|
while (parent != null) {
|
||||||
parents.add(parent);
|
parents.add(parent);
|
||||||
|
@ -97,7 +97,7 @@ public class Region implements IRegion {
|
||||||
int size = fRootElements.size();
|
int size = fRootElements.size();
|
||||||
ICElement[] roots = new ICElement[size];
|
ICElement[] roots = new ICElement[size];
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
roots[i] = (ICElement) fRootElements.get(i);
|
roots[i] = fRootElements.get(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return roots;
|
return roots;
|
||||||
|
@ -121,9 +121,9 @@ public class Region implements IRegion {
|
||||||
*/
|
*/
|
||||||
private void removeAllChildren(ICElement element) {
|
private void removeAllChildren(ICElement element) {
|
||||||
if (element instanceof IParent) {
|
if (element instanceof IParent) {
|
||||||
ArrayList newRootElements = new ArrayList();
|
ArrayList<ICElement> newRootElements = new ArrayList<ICElement>();
|
||||||
for (int i = 0, size = fRootElements.size(); i < size; i++) {
|
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
|
// walk the current root hierarchy
|
||||||
ICElement parent = currentRoot.getParent();
|
ICElement parent = currentRoot.getParent();
|
||||||
boolean isChild = false;
|
boolean isChild = false;
|
||||||
|
|
|
@ -63,27 +63,28 @@ public class RenameElementsOperation extends MoveElementsOperation {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void verify(ICElement element) throws CModelException {
|
protected void verify(ICElement element) throws CModelException {
|
||||||
int elementType = element.getElementType();
|
|
||||||
|
|
||||||
if (element == null || !element.exists())
|
if (element == null || !element.exists())
|
||||||
error(ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST, element);
|
error(ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST, element);
|
||||||
|
else {
|
||||||
if (element.isReadOnly())
|
int elementType = element.getElementType();
|
||||||
error(ICModelStatusConstants.READ_ONLY, 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);
|
|
||||||
// }
|
|
||||||
|
|
||||||
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,23 +67,22 @@ public class SetPathEntriesOperation extends CModelOperation {
|
||||||
|
|
||||||
IProject[] projectReferences = description.getReferencedProjects();
|
IProject[] projectReferences = description.getReferencedProjects();
|
||||||
|
|
||||||
HashSet oldReferences = new HashSet(projectReferences.length);
|
HashSet<String> oldReferences = new HashSet<String>(projectReferences.length);
|
||||||
for (int i = 0; i < projectReferences.length; i++) {
|
for (IProject projectReference : projectReferences) {
|
||||||
String projectName = projectReferences[i].getName();
|
String projectName = projectReference.getName();
|
||||||
oldReferences.add(projectName);
|
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++) {
|
for (String projectName : oldRequired) {
|
||||||
String projectName = oldRequired[i];
|
|
||||||
newReferences.remove(projectName);
|
newReferences.remove(projectName);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < newRequired.length; i++) {
|
for (String projectName : newRequired) {
|
||||||
String projectName = newRequired[i];
|
|
||||||
newReferences.add(projectName);
|
newReferences.add(projectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator iter;
|
Iterator<String> iter;
|
||||||
int newSize = newReferences.size();
|
int newSize = newReferences.size();
|
||||||
|
|
||||||
checkIdentity : {
|
checkIdentity : {
|
||||||
|
@ -101,7 +100,7 @@ public class SetPathEntriesOperation extends CModelOperation {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
iter = newReferences.iterator();
|
iter = newReferences.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
requiredProjectNames[index++] = (String) iter.next();
|
requiredProjectNames[index++] = iter.next();
|
||||||
}
|
}
|
||||||
Arrays.sort(requiredProjectNames); // ensure that if changed, the order is consistent
|
Arrays.sort(requiredProjectNames); // ensure that if changed, the order is consistent
|
||||||
|
|
||||||
|
|
|
@ -16,11 +16,6 @@ import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public class SourceEntry extends APathEntry implements ISourceEntry {
|
public class SourceEntry extends APathEntry implements ISourceEntry {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param path
|
|
||||||
* @param exclusionPatterns
|
|
||||||
*/
|
|
||||||
public SourceEntry(IPath sourcePath, IPath[] exclusionPatterns) {
|
public SourceEntry(IPath sourcePath, IPath[] exclusionPatterns) {
|
||||||
super(IPathEntry.CDT_SOURCE, null, null, sourcePath, exclusionPatterns, false);
|
super(IPathEntry.CDT_SOURCE, null, null, sourcePath, exclusionPatterns, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IFunctionDeclaration;
|
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.IOpenable;
|
||||||
import org.eclipse.cdt.core.model.ISourceManipulation;
|
import org.eclipse.cdt.core.model.ISourceManipulation;
|
||||||
import org.eclipse.cdt.core.model.ISourceRange;
|
import org.eclipse.cdt.core.model.ISourceRange;
|
||||||
|
@ -191,7 +192,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
|
||||||
* @see CElement#generateInfos
|
* @see CElement#generateInfos
|
||||||
*/
|
*/
|
||||||
@Override
|
@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();
|
Openable openableParent = (Openable)getOpenableParent();
|
||||||
if (openableParent == null) {
|
if (openableParent == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -288,41 +289,41 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
|
||||||
case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
|
case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
|
||||||
case ICElement.C_TEMPLATE_METHOD:
|
case ICElement.C_TEMPLATE_METHOD:
|
||||||
case ICElement.C_TEMPLATE_METHOD_DECLARATION:
|
case ICElement.C_TEMPLATE_METHOD_DECLARATION:
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (ICElement element2 : children) {
|
||||||
if (elementType == children[i].getElementType()
|
if (elementType == element2.getElementType()
|
||||||
&& elementName.equals(children[i].getElementName())) {
|
&& elementName.equals(element2.getElementName())) {
|
||||||
assert children[i] instanceof IFunctionDeclaration;
|
assert element2 instanceof IFunctionDeclaration;
|
||||||
String[] functionParams= ((IFunctionDeclaration)children[i]).getParameterTypes();
|
String[] functionParams= ((IFunctionDeclaration)element2).getParameterTypes();
|
||||||
if (Arrays.equals(functionParams, mementoParams)) {
|
if (Arrays.equals(functionParams, mementoParams)) {
|
||||||
element= (CElement) children[i];
|
element= (CElement) element2;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case ICElement.C_TEMPLATE_CLASS:
|
case ICElement.C_TEMPLATE_CLASS:
|
||||||
case ICElement.C_TEMPLATE_STRUCT:
|
case ICElement.C_TEMPLATE_STRUCT:
|
||||||
case ICElement.C_TEMPLATE_UNION:
|
case ICElement.C_TEMPLATE_UNION:
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (ICElement element2 : children) {
|
||||||
if (elementType == children[i].getElementType()
|
if (elementType == element2.getElementType()
|
||||||
&& elementName.equals(children[i].getElementName())) {
|
&& elementName.equals(element2.getElementName())) {
|
||||||
assert children[i] instanceof ITemplate;
|
assert element2 instanceof ITemplate;
|
||||||
String[] templateParams= ((ITemplate)children[i]).getTemplateParameterTypes();
|
String[] templateParams= ((ITemplate)element2).getTemplateParameterTypes();
|
||||||
if (Arrays.equals(templateParams, mementoParams)) {
|
if (Arrays.equals(templateParams, mementoParams)) {
|
||||||
element= (CElement) children[i];
|
element= (CElement) element2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
for (ICElement element2 : children) {
|
||||||
|
if (elementType == element2.getElementType()
|
||||||
|
&& elementName.equals(element2.getElementName())) {
|
||||||
|
element= (CElement) element2;
|
||||||
break;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
|
|
|
@ -14,7 +14,10 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.IBuffer;
|
import org.eclipse.cdt.core.model.IBuffer;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
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.ISourceRange;
|
||||||
|
import org.eclipse.cdt.core.model.ISourceReference;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class SourceMapper {
|
||||||
|
|
||||||
public ITranslationUnit findTranslationUnit(IParent container, String filename) {
|
public ITranslationUnit findTranslationUnit(IParent container, String filename) {
|
||||||
try {
|
try {
|
||||||
List list = container.getChildrenOfType(ICElement.C_UNIT);
|
List<?> list = container.getChildrenOfType(ICElement.C_UNIT);
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
Object o = list.get(i);
|
Object o = list.get(i);
|
||||||
if (o instanceof ITranslationUnit) {
|
if (o instanceof ITranslationUnit) {
|
||||||
|
|
|
@ -25,23 +25,22 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||||
|
|
||||||
public class Structure extends StructureDeclaration implements IStructure {
|
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) {
|
public Structure(ICElement parent, int kind, String name) {
|
||||||
super(parent, name, kind);
|
super(parent, name, kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IField[] getFields() throws CModelException {
|
public IField[] getFields() throws CModelException {
|
||||||
List fields = new ArrayList();
|
List<ICElement> fields = new ArrayList<ICElement>();
|
||||||
fields.addAll(getChildrenOfType(ICElement.C_FIELD));
|
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) {
|
public IField getField(String name) {
|
||||||
try {
|
try {
|
||||||
IField[] fields = getFields();
|
IField[] fields = getFields();
|
||||||
for (int i = 0; i<fields.length; i++){
|
for (IField field : fields) {
|
||||||
IField field = fields[i];
|
|
||||||
if(field.getElementName().equals(name)){
|
if(field.getElementName().equals(name)){
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
@ -52,17 +51,16 @@ public class Structure extends StructureDeclaration implements IStructure {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMethodDeclaration[] getMethods() throws CModelException {
|
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_DECLARATION));
|
||||||
methods.addAll(getChildrenOfType(ICElement.C_METHOD));
|
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) {
|
public IMethodDeclaration getMethod(String name) {
|
||||||
try {
|
try {
|
||||||
IMethodDeclaration[] methods = getMethods();
|
IMethodDeclaration[] methods = getMethods();
|
||||||
for (int i = 0; i<methods.length; i++){
|
for (IMethodDeclaration method : methods) {
|
||||||
IMethodDeclaration method = methods[i];
|
|
||||||
if(method.getElementName().equals(name)){
|
if(method.getElementName().equals(name)){
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
@ -74,8 +72,7 @@ public class Structure extends StructureDeclaration implements IStructure {
|
||||||
|
|
||||||
public boolean isAbstract() throws CModelException {
|
public boolean isAbstract() throws CModelException {
|
||||||
IMethodDeclaration[] methods = getMethods();
|
IMethodDeclaration[] methods = getMethods();
|
||||||
for(int i=0; i<methods.length; i++){
|
for (IMethodDeclaration method : methods) {
|
||||||
IMethodDeclaration method = methods[i];
|
|
||||||
if(method.isPureVirtual())
|
if(method.isPureVirtual())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -83,11 +80,11 @@ public class Structure extends StructureDeclaration implements IStructure {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getSuperClassesNames(){
|
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){
|
public ASTAccessVisibility getSuperClassAccess(String name){
|
||||||
return (ASTAccessVisibility)superClassesNames.get(name);
|
return superClassesNames.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSuperClass(String name) {
|
public void addSuperClass(String name) {
|
||||||
|
|
|
@ -20,11 +20,6 @@ import org.eclipse.cdt.core.model.IStructureDeclaration;
|
||||||
*/
|
*/
|
||||||
public class StructureDeclaration extends SourceManipulation implements IStructureDeclaration {
|
public class StructureDeclaration extends SourceManipulation implements IStructureDeclaration {
|
||||||
|
|
||||||
/**
|
|
||||||
* @param parent
|
|
||||||
* @param name
|
|
||||||
* @param type
|
|
||||||
*/
|
|
||||||
public StructureDeclaration(ICElement parent, String name, int kind) {
|
public StructureDeclaration(ICElement parent, String name, int kind) {
|
||||||
super(parent, name, kind);
|
super(parent, name, kind);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class StructureTemplate extends Structure implements IStructureTemplate {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the parameterTypes.
|
* Returns the parameterTypes.
|
||||||
* @see org.eclipse.cdt.core.model.ITemplate#getParameters()
|
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes()
|
||||||
* @return String[]
|
* @return String[]
|
||||||
*/
|
*/
|
||||||
public String[] getTemplateParameterTypes() {
|
public String[] getTemplateParameterTypes() {
|
||||||
|
@ -33,7 +33,7 @@ public class StructureTemplate extends Structure implements IStructureTemplate {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the fParameterTypes.
|
* Sets the fParameterTypes.
|
||||||
* @param fParameterTypes The fParameterTypes to set
|
* @param templateParameterTypes The template parameter types to set
|
||||||
*/
|
*/
|
||||||
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
||||||
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
||||||
|
@ -58,9 +58,9 @@ public class StructureTemplate extends Structure implements IStructureTemplate {
|
||||||
super.getHandleMemento(buff);
|
super.getHandleMemento(buff);
|
||||||
if (fTemplate.getNumberOfTemplateParameters() > 0) {
|
if (fTemplate.getNumberOfTemplateParameters() > 0) {
|
||||||
final String[] parameterTypes= fTemplate.getTemplateParameterTypes();
|
final String[] parameterTypes= fTemplate.getTemplateParameterTypes();
|
||||||
for (int i = 0; i < parameterTypes.length; i++) {
|
for (String parameterType : parameterTypes) {
|
||||||
buff.append(CEM_PARAMETER);
|
buff.append(CEM_PARAMETER);
|
||||||
escapeMementoName(buff, parameterTypes[i]);
|
escapeMementoName(buff, parameterType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class Template implements ITemplate {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the parameterTypes.
|
* Returns the parameterTypes.
|
||||||
* @see org.eclipse.cdt.core.model.ITemplate#getParameters()
|
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateParameterTypes()
|
||||||
* @return String[]
|
* @return String[]
|
||||||
*/
|
*/
|
||||||
public String[] getTemplateParameterTypes() {
|
public String[] getTemplateParameterTypes() {
|
||||||
|
@ -34,7 +34,7 @@ public class Template implements ITemplate {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the fParameterTypes.
|
* Sets the fParameterTypes.
|
||||||
* @param fParameterTypes The fParameterTypes to set
|
* @param templateParameterTypes The template parameter types to set
|
||||||
*/
|
*/
|
||||||
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
||||||
this.templateParameterTypes = templateParameterTypes;
|
this.templateParameterTypes = templateParameterTypes;
|
||||||
|
|
|
@ -147,12 +147,12 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
|
|
||||||
public ICElement getElementAtLine(int line) throws CModelException {
|
public ICElement getElementAtLine(int line) throws CModelException {
|
||||||
ICElement[] celements = getChildren();
|
ICElement[] celements = getChildren();
|
||||||
for (int i = 0; i < celements.length; i++) {
|
for (ICElement celement : celements) {
|
||||||
ISourceRange range = ((ISourceReference)celements[i]).getSourceRange();
|
ISourceRange range = ((ISourceReference)celement).getSourceRange();
|
||||||
int startLine = range.getStartLine();
|
int startLine = range.getStartLine();
|
||||||
int endLine = range.getEndLine();
|
int endLine = range.getEndLine();
|
||||||
if (line >= startLine && line <= endLine) {
|
if (line >= startLine && line <= endLine) {
|
||||||
return celements[i];
|
return celement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -180,9 +180,9 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ICElement[] celements = getChildren();
|
ICElement[] celements = getChildren();
|
||||||
for (int i = 0; i < celements.length; i++) {
|
for (ICElement celement : celements) {
|
||||||
if (name.equals(celements[i].getElementName())) {
|
if (name.equals(celement.getElementName())) {
|
||||||
return celements[i];
|
return celement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
|
@ -196,9 +196,9 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
try {
|
try {
|
||||||
ICElement[] celements = ((IParent) current).getChildren();
|
ICElement[] celements = ((IParent) current).getChildren();
|
||||||
current = null;
|
current = null;
|
||||||
for (int i = 0; i < celements.length; i++) {
|
for (ICElement celement : celements) {
|
||||||
if (names[j].equals(celements[i].getElementName())) {
|
if (names[j].equals(celement.getElementName())) {
|
||||||
current = celements[i];
|
current = celement;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,10 +215,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
public IInclude getInclude(String name) {
|
public IInclude getInclude(String name) {
|
||||||
try {
|
try {
|
||||||
ICElement[] celements = getChildren();
|
ICElement[] celements = getChildren();
|
||||||
for (int i = 0; i < celements.length; i++) {
|
for (ICElement celement : celements) {
|
||||||
if (celements[i].getElementType() == ICElement.C_INCLUDE) {
|
if (celement.getElementType() == ICElement.C_INCLUDE) {
|
||||||
if (name.equals(celements[i].getElementName())) {
|
if (name.equals(celement.getElementName())) {
|
||||||
return (IInclude) celements[i];
|
return (IInclude) celement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,9 +230,9 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
public IInclude[] getIncludes() throws CModelException {
|
public IInclude[] getIncludes() throws CModelException {
|
||||||
ICElement[] celements = getChildren();
|
ICElement[] celements = getChildren();
|
||||||
ArrayList<ICElement> aList = new ArrayList<ICElement>();
|
ArrayList<ICElement> aList = new ArrayList<ICElement>();
|
||||||
for (int i = 0; i < celements.length; i++) {
|
for (ICElement celement : celements) {
|
||||||
if (celements[i].getElementType() == ICElement.C_INCLUDE) {
|
if (celement.getElementType() == ICElement.C_INCLUDE) {
|
||||||
aList.add(celements[i]);
|
aList.add(celement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return aList.toArray(new IInclude[0]);
|
return aList.toArray(new IInclude[0]);
|
||||||
|
@ -241,10 +241,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
public IUsing getUsing(String name) {
|
public IUsing getUsing(String name) {
|
||||||
try {
|
try {
|
||||||
ICElement[] celements = getChildren();
|
ICElement[] celements = getChildren();
|
||||||
for (int i = 0; i < celements.length; i++) {
|
for (ICElement celement : celements) {
|
||||||
if (celements[i].getElementType() == ICElement.C_USING) {
|
if (celement.getElementType() == ICElement.C_USING) {
|
||||||
if (name.equals(celements[i].getElementName())) {
|
if (name.equals(celement.getElementName())) {
|
||||||
return (IUsing) celements[i];
|
return (IUsing) celement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,9 +256,9 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
public IUsing[] getUsings() throws CModelException {
|
public IUsing[] getUsings() throws CModelException {
|
||||||
ICElement[] celements = getChildren();
|
ICElement[] celements = getChildren();
|
||||||
ArrayList<ICElement> aList = new ArrayList<ICElement>();
|
ArrayList<ICElement> aList = new ArrayList<ICElement>();
|
||||||
for (int i = 0; i < celements.length; i++) {
|
for (ICElement celement : celements) {
|
||||||
if (celements[i].getElementType() == ICElement.C_USING) {
|
if (celement.getElementType() == ICElement.C_USING) {
|
||||||
aList.add(celements[i]);
|
aList.add(celement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return aList.toArray(new IUsing[0]);
|
return aList.toArray(new IUsing[0]);
|
||||||
|
@ -272,10 +272,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
if (current instanceof IParent) {
|
if (current instanceof IParent) {
|
||||||
ICElement[] celements = ((IParent) current).getChildren();
|
ICElement[] celements = ((IParent) current).getChildren();
|
||||||
current = null;
|
current = null;
|
||||||
for (int i = 0; i < celements.length; i++) {
|
for (ICElement celement : celements) {
|
||||||
if (celements[i].getElementType() == ICElement.C_NAMESPACE) {
|
if (celement.getElementType() == ICElement.C_NAMESPACE) {
|
||||||
if (name.equals(celements[i].getElementName())) {
|
if (name.equals(celement.getElementName())) {
|
||||||
current = celements[i];
|
current = celement;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,9 +295,9 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
public INamespace[] getNamespaces() throws CModelException {
|
public INamespace[] getNamespaces() throws CModelException {
|
||||||
ICElement[] celements = getChildren();
|
ICElement[] celements = getChildren();
|
||||||
ArrayList<ICElement> aList = new ArrayList<ICElement>();
|
ArrayList<ICElement> aList = new ArrayList<ICElement>();
|
||||||
for (int i = 0; i < celements.length; i++) {
|
for (ICElement celement : celements) {
|
||||||
if (celements[i].getElementType() == ICElement.C_NAMESPACE) {
|
if (celement.getElementType() == ICElement.C_NAMESPACE) {
|
||||||
aList.add(celements[i]);
|
aList.add(celement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return aList.toArray(new INamespace[0]);
|
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
|
// In order to be shared, working copies have to denote the same translation unit
|
||||||
// AND use the same buffer factory.
|
// AND use the same buffer factory.
|
||||||
// Assuming there is a little set of buffer factories, then use a 2 level Map cache.
|
// 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;
|
if (perFactoryWorkingCopies == null) return null;
|
||||||
return (WorkingCopy) perFactoryWorkingCopies.get(this);
|
return perFactoryWorkingCopies.get(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -418,7 +418,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
TranslationUnitInfo unitInfo = (TranslationUnitInfo) info;
|
||||||
|
|
||||||
// We reuse the general info cache in the CModelBuilder, We should not do this
|
// 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
|
// In order to be shared, working copies have to denote the same translation unit
|
||||||
// AND use the same buffer factory.
|
// AND use the same buffer factory.
|
||||||
// Assuming there is a little set of buffer factories, then use a 2 level Map cache.
|
// 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) {
|
if (perFactoryWorkingCopies == null) {
|
||||||
perFactoryWorkingCopies = new HashMap();
|
perFactoryWorkingCopies = new HashMap<ITranslationUnit, WorkingCopy>();
|
||||||
sharedWorkingCopies.put(factory, perFactoryWorkingCopies);
|
sharedWorkingCopies.put(factory, perFactoryWorkingCopies);
|
||||||
}
|
}
|
||||||
WorkingCopy workingCopy = (WorkingCopy)perFactoryWorkingCopies.get(this);
|
WorkingCopy workingCopy = perFactoryWorkingCopies.get(this);
|
||||||
if (workingCopy != null) {
|
if (workingCopy != null) {
|
||||||
workingCopy.useCount++;
|
workingCopy.useCount++;
|
||||||
return workingCopy;
|
return workingCopy;
|
||||||
|
@ -511,7 +511,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 {
|
try {
|
||||||
super.openParent(childInfo, newElements, pm);
|
super.openParent(childInfo, newElements, pm);
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
|
@ -548,13 +548,13 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
info= createElementInfo();
|
info= createElementInfo();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
HashMap newElements = manager.getTemporaryCache();
|
Map<ICElement, CElementInfo> newElements = manager.getTemporaryCache();
|
||||||
openWhenClosed(info, monitor);
|
openWhenClosed(info, monitor);
|
||||||
if (newElements.get(this) == null) {
|
if (newElements.get(this) == null) {
|
||||||
// close any buffer that was opened for the new elements
|
// close any buffer that was opened for the new elements
|
||||||
Iterator iterator = newElements.keySet().iterator();
|
Iterator<ICElement> iterator = newElements.keySet().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
ICElement element = (ICElement)iterator.next();
|
ICElement element = iterator.next();
|
||||||
if (element instanceof Openable) {
|
if (element instanceof Openable) {
|
||||||
((Openable)element).closeBuffer();
|
((Openable)element).closeBuffer();
|
||||||
}
|
}
|
||||||
|
@ -625,14 +625,14 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map parse() {
|
public Map<?, ?> parse() {
|
||||||
throw new UnsupportedOperationException("Deprecated method"); //$NON-NLS-1$
|
throw new UnsupportedOperationException("Deprecated method"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the buffer contents of this element.
|
* 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());
|
boolean quickParseMode = ! (CCorePlugin.getDefault().useStructuralParseMode());
|
||||||
IContributedModelBuilder mb = LanguageManager.getInstance().getContributedModelBuilderFor(this);
|
IContributedModelBuilder mb = LanguageManager.getInstance().getContributedModelBuilderFor(this);
|
||||||
if (mb == null) {
|
if (mb == null) {
|
||||||
|
@ -646,7 +646,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
* Parse the buffer contents of this element.
|
* Parse the buffer contents of this element.
|
||||||
* @param monitor
|
* @param monitor
|
||||||
*/
|
*/
|
||||||
private void parseUsingCModelBuilder(Map newElements, boolean quickParseMode, IProgressMonitor monitor) {
|
private void parseUsingCModelBuilder(Map<ICElement, CElementInfo> newElements, boolean quickParseMode, IProgressMonitor monitor) {
|
||||||
try {
|
try {
|
||||||
new CModelBuilder2(this, monitor).parse(quickParseMode);
|
new CModelBuilder2(this, monitor).parse(quickParseMode);
|
||||||
} catch (OperationCanceledException oce) {
|
} catch (OperationCanceledException oce) {
|
||||||
|
@ -854,11 +854,11 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
if (index != null && (style & AST_CONFIGURE_USING_SOURCE_CONTEXT) != 0) {
|
if (index != null && (style & AST_CONFIGURE_USING_SOURCE_CONTEXT) != 0) {
|
||||||
try {
|
try {
|
||||||
fLanguageOfContext= null;
|
fLanguageOfContext= null;
|
||||||
for (int i = 0; i < CTX_LINKAGES.length; i++) {
|
for (int element : CTX_LINKAGES) {
|
||||||
IIndexFile context= null;
|
IIndexFile context= null;
|
||||||
final IIndexFileLocation ifl = IndexLocationFactory.getIFL(this);
|
final IIndexFileLocation ifl = IndexLocationFactory.getIFL(this);
|
||||||
if (ifl != null) {
|
if (ifl != null) {
|
||||||
IIndexFile indexFile= index.getFile(CTX_LINKAGES[i], ifl);
|
IIndexFile indexFile= index.getFile(element, ifl);
|
||||||
if (indexFile != null) {
|
if (indexFile != null) {
|
||||||
// bug 199412, when a source-file includes itself the context may recurse.
|
// bug 199412, when a source-file includes itself the context may recurse.
|
||||||
HashSet<IIndexFile> visited= new HashSet<IIndexFile>();
|
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:
|
||||||
case ICElement.C_TEMPLATE_METHOD_DECLARATION:
|
case ICElement.C_TEMPLATE_METHOD_DECLARATION:
|
||||||
// search for matching function
|
// search for matching function
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (ICElement element2 : children) {
|
||||||
if (elementType == children[i].getElementType()
|
if (elementType == element2.getElementType()
|
||||||
&& elementName.equals(children[i].getElementName())) {
|
&& elementName.equals(element2.getElementName())) {
|
||||||
assert children[i] instanceof IFunctionDeclaration;
|
assert element2 instanceof IFunctionDeclaration;
|
||||||
String[] functionParams= ((IFunctionDeclaration)children[i]).getParameterTypes();
|
String[] functionParams= ((IFunctionDeclaration)element2).getParameterTypes();
|
||||||
if (Arrays.equals(functionParams, mementoParams)) {
|
if (Arrays.equals(functionParams, mementoParams)) {
|
||||||
element= (CElement) children[i];
|
element= (CElement) element2;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case ICElement.C_TEMPLATE_CLASS:
|
case ICElement.C_TEMPLATE_CLASS:
|
||||||
case ICElement.C_TEMPLATE_STRUCT:
|
case ICElement.C_TEMPLATE_STRUCT:
|
||||||
case ICElement.C_TEMPLATE_UNION:
|
case ICElement.C_TEMPLATE_UNION:
|
||||||
// search for matching template type
|
// search for matching template type
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (ICElement element2 : children) {
|
||||||
if (elementType == children[i].getElementType()
|
if (elementType == element2.getElementType()
|
||||||
&& elementName.equals(children[i].getElementName())) {
|
&& elementName.equals(element2.getElementName())) {
|
||||||
assert children[i] instanceof ITemplate;
|
assert element2 instanceof ITemplate;
|
||||||
String[] templateParams= ((ITemplate)children[i]).getTemplateParameterTypes();
|
String[] templateParams= ((ITemplate)element2).getTemplateParameterTypes();
|
||||||
if (Arrays.equals(templateParams, mementoParams)) {
|
if (Arrays.equals(templateParams, mementoParams)) {
|
||||||
element= (CElement) children[i];
|
element= (CElement) element2;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// search for matching element
|
// search for matching element
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (ICElement element2 : children) {
|
||||||
if (elementType == children[i].getElementType()
|
if (elementType == element2.getElementType()
|
||||||
&& elementName.equals(children[i].getElementName())) {
|
&& elementName.equals(element2.getElementName())) {
|
||||||
element= (CElement) children[i];
|
element= (CElement) element2;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
|
|
|
@ -60,8 +60,7 @@ public class Util implements ICLogConstants {
|
||||||
return new StringBuffer(b.length).append(b);
|
return new StringBuffer(b.length).append(b);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (stream != null)
|
stream.close();
|
||||||
stream.close();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,10 +233,6 @@ public class Util implements ICLogConstants {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param client
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static boolean isActive(DebugLogConstants client) {
|
public static boolean isActive(DebugLogConstants client) {
|
||||||
if (client.equals(DebugLogConstants.PARSER)) {
|
if (client.equals(DebugLogConstants.PARSER)) {
|
||||||
return VERBOSE_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
|
* Return true if the file is not a directory and has length > 0
|
||||||
* @param path
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static boolean isNonZeroLengthFile(IPath path) {
|
public static boolean isNonZeroLengthFile(IPath path) {
|
||||||
return isNonZeroLengthFile(URIUtil.toURI(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
|
* 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) {
|
public static boolean isNonZeroLengthFile(URI uri) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -57,9 +57,6 @@ class VariableInfo extends SourceManipulationInfo {
|
||||||
this.isStatic = isStatic;
|
this.isStatic = isStatic;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.internal.core.model.SourceManipulationInfo#hasSameContentsAs(org.eclipse.cdt.internal.core.model.SourceManipulationInfo)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasSameContentsAs(SourceManipulationInfo otherInfo) {
|
public boolean hasSameContentsAs(SourceManipulationInfo otherInfo) {
|
||||||
return
|
return
|
||||||
|
|
|
@ -190,14 +190,14 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
|
|
||||||
// look for it.
|
// look for it.
|
||||||
ICElement element = workingCopyElement;
|
ICElement element = workingCopyElement;
|
||||||
ArrayList children = new ArrayList();
|
ArrayList<ICElement> children = new ArrayList<ICElement>();
|
||||||
while (element != null && element.getElementType() != ICElement.C_UNIT) {
|
while (element != null && element.getElementType() != ICElement.C_UNIT) {
|
||||||
children.add(element);
|
children.add(element);
|
||||||
element = element.getParent();
|
element = element.getParent();
|
||||||
}
|
}
|
||||||
ICElement current = tu;
|
ICElement current = tu;
|
||||||
for (int i = children.size()-1; i >= 0; i--) {
|
for (int i = children.size()-1; i >= 0; i--) {
|
||||||
ICElement child = (ICElement)children.get(i);
|
ICElement child = children.get(i);
|
||||||
if (current instanceof IParent) {
|
if (current instanceof IParent) {
|
||||||
try {
|
try {
|
||||||
ICElement[] celems = ((IParent)current).getChildren();
|
ICElement[] celems = ((IParent)current).getChildren();
|
||||||
|
@ -282,7 +282,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ICFile
|
* @see ITranslationUnit
|
||||||
* @see IWorkingCopy
|
* @see IWorkingCopy
|
||||||
*
|
*
|
||||||
* @exception CModelException attempting to open a read only element for
|
* @exception CModelException attempting to open a read only element for
|
||||||
|
@ -331,7 +331,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
||||||
if (originalBuffer != null) {
|
if (originalBuffer != null) {
|
||||||
char[] originalContents = originalBuffer.getCharacters();
|
char[] originalContents = originalBuffer.getCharacters();
|
||||||
if (originalContents != null) {
|
if (originalContents != null) {
|
||||||
buffer.setContents((char[])originalContents.clone());
|
buffer.setContents(originalContents.clone());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// initialize buffer
|
// 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
|
@Override
|
||||||
public void save(IProgressMonitor pm, boolean force) throws CModelException {
|
public void save(IProgressMonitor pm, boolean force) throws CModelException {
|
||||||
|
|
|
@ -12,7 +12,7 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Element Info of a Working Copy.
|
* The Element Info of a Working Copy.
|
||||||
* @deprecated Use {@link TranslationUnitInfo} directly
|
* @deprecated Use the extended class directly
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class WorkingCopyInfo extends TranslationUnitInfo {
|
public class WorkingCopyInfo extends TranslationUnitInfo {
|
||||||
|
|
|
@ -32,7 +32,7 @@ import java.util.Hashtable;
|
||||||
*
|
*
|
||||||
* This class is similar to the JDT LRUCache class.
|
* 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
|
* This type is used internally by the LRUCache to represent entries
|
||||||
|
@ -42,17 +42,17 @@ public class LRUCache implements Cloneable {
|
||||||
*
|
*
|
||||||
* @see LRUCache
|
* @see LRUCache
|
||||||
*/
|
*/
|
||||||
protected static class LRUCacheEntry {
|
protected static class LRUCacheEntry<K,T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hash table key
|
* Hash table key
|
||||||
*/
|
*/
|
||||||
public Object _fKey;
|
public K _fKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hash table value (an LRUCacheEntry object)
|
* Hash table value (an LRUCacheEntry object)
|
||||||
*/
|
*/
|
||||||
public Object _fValue;
|
public T _fValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Time value for queue sorting
|
* Time value for queue sorting
|
||||||
|
@ -67,18 +67,18 @@ public class LRUCache implements Cloneable {
|
||||||
/**
|
/**
|
||||||
* Previous entry in queue
|
* Previous entry in queue
|
||||||
*/
|
*/
|
||||||
public LRUCacheEntry _fPrevious;
|
public LRUCacheEntry<K,T> _fPrevious;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Next entry in queue
|
* Next entry in queue
|
||||||
*/
|
*/
|
||||||
public LRUCacheEntry _fNext;
|
public LRUCacheEntry<K,T> _fNext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of the receiver with the provided values
|
* Creates a new instance of the receiver with the provided values
|
||||||
* for key, value, and space.
|
* for key, value, and space.
|
||||||
*/
|
*/
|
||||||
public LRUCacheEntry (Object key, Object value, int space) {
|
public LRUCacheEntry (K key, T value, int space) {
|
||||||
_fKey = key;
|
_fKey = key;
|
||||||
_fValue = value;
|
_fValue = value;
|
||||||
_fSpace = space;
|
_fSpace = space;
|
||||||
|
@ -112,17 +112,17 @@ public class LRUCache implements Cloneable {
|
||||||
/**
|
/**
|
||||||
* Hash table for fast random access to cache entries
|
* 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)
|
* Start of queue (most recently used entry)
|
||||||
*/
|
*/
|
||||||
protected LRUCacheEntry fEntryQueue;
|
protected LRUCacheEntry<K,T> fEntryQueue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* End of queue (least recently used entry)
|
* End of queue (least recently used entry)
|
||||||
*/
|
*/
|
||||||
protected LRUCacheEntry fEntryQueueTail;
|
protected LRUCacheEntry<K,T> fEntryQueueTail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default amount of space in the cache
|
* Default amount of space in the cache
|
||||||
|
@ -144,7 +144,7 @@ public class LRUCache implements Cloneable {
|
||||||
|
|
||||||
fTimestampCounter = fCurrentSpace = 0;
|
fTimestampCounter = fCurrentSpace = 0;
|
||||||
fEntryQueue = fEntryQueueTail = null;
|
fEntryQueue = fEntryQueueTail = null;
|
||||||
fEntryTable = new Hashtable(size);
|
fEntryTable = new Hashtable<K,LRUCacheEntry<K,T>>(size);
|
||||||
fSpaceLimit = size;
|
fSpaceLimit = size;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -155,8 +155,8 @@ public class LRUCache implements Cloneable {
|
||||||
@Override
|
@Override
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
|
|
||||||
LRUCache newCache = newInstance(fSpaceLimit);
|
LRUCache<K,T> newCache = newInstance(fSpaceLimit);
|
||||||
LRUCacheEntry qEntry;
|
LRUCacheEntry<K,T> qEntry;
|
||||||
|
|
||||||
/* Preserve order of entries by copying from oldest to newest */
|
/* Preserve order of entries by copying from oldest to newest */
|
||||||
qEntry = this.fEntryQueueTail;
|
qEntry = this.fEntryQueueTail;
|
||||||
|
@ -172,8 +172,8 @@ public class LRUCache implements Cloneable {
|
||||||
public void flush() {
|
public void flush() {
|
||||||
|
|
||||||
fCurrentSpace = 0;
|
fCurrentSpace = 0;
|
||||||
LRUCacheEntry entry = fEntryQueueTail; // Remember last entry
|
LRUCacheEntry<K,T> entry = fEntryQueueTail; // Remember last entry
|
||||||
fEntryTable = new Hashtable(); // Clear it out
|
fEntryTable = new Hashtable<K,LRUCacheEntry<K,T>>(); // Clear it out
|
||||||
fEntryQueue = fEntryQueueTail = null;
|
fEntryQueue = fEntryQueueTail = null;
|
||||||
while (entry != null) { // send deletion notifications in LRU order
|
while (entry != null) { // send deletion notifications in LRU order
|
||||||
privateNotifyDeletionFromCache(entry);
|
privateNotifyDeletionFromCache(entry);
|
||||||
|
@ -188,9 +188,9 @@ public class LRUCache implements Cloneable {
|
||||||
*/
|
*/
|
||||||
public void flush (Object key) {
|
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 does not exist, return */
|
||||||
if (entry == null) return;
|
if (entry == null) return;
|
||||||
|
@ -206,7 +206,7 @@ public class LRUCache implements Cloneable {
|
||||||
*/
|
*/
|
||||||
public Object get(Object key) {
|
public Object get(Object key) {
|
||||||
|
|
||||||
LRUCacheEntry entry = (LRUCacheEntry) fEntryTable.get(key);
|
LRUCacheEntry<K,T> entry = fEntryTable.get(key);
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,7 @@ public class LRUCache implements Cloneable {
|
||||||
/**
|
/**
|
||||||
* Returns an Enumeration of the keys currently in the cache.
|
* Returns an Enumeration of the keys currently in the cache.
|
||||||
*/
|
*/
|
||||||
public Enumeration keys() {
|
public Enumeration<K> keys() {
|
||||||
|
|
||||||
return fEntryTable.keys();
|
return fEntryTable.keys();
|
||||||
}
|
}
|
||||||
|
@ -246,19 +246,19 @@ public class LRUCache implements Cloneable {
|
||||||
public ICacheEnumeration keysAndValues() {
|
public ICacheEnumeration keysAndValues() {
|
||||||
return new ICacheEnumeration() {
|
return new ICacheEnumeration() {
|
||||||
|
|
||||||
Enumeration fValues = fEntryTable.elements();
|
Enumeration<LRUCacheEntry<K,T>> fValues = fEntryTable.elements();
|
||||||
LRUCacheEntry fEntry;
|
LRUCacheEntry<K,T> fEntry;
|
||||||
|
|
||||||
public boolean hasMoreElements() {
|
public boolean hasMoreElements() {
|
||||||
return fValues.hasMoreElements();
|
return fValues.hasMoreElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object nextElement() {
|
public K nextElement() {
|
||||||
fEntry = (LRUCacheEntry) fValues.nextElement();
|
fEntry = fValues.nextElement();
|
||||||
return fEntry._fKey;
|
return fEntry._fKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getValue() {
|
public T getValue() {
|
||||||
if (fEntry == null) {
|
if (fEntry == null) {
|
||||||
throw new java.util.NoSuchElementException();
|
throw new java.util.NoSuchElementException();
|
||||||
}
|
}
|
||||||
|
@ -298,17 +298,17 @@ public class LRUCache implements Cloneable {
|
||||||
/**
|
/**
|
||||||
* Returns a new LRUCache instance
|
* Returns a new LRUCache instance
|
||||||
*/
|
*/
|
||||||
protected LRUCache newInstance(int size) {
|
protected LRUCache<K,T> newInstance(int size) {
|
||||||
return new LRUCache(size);
|
return new LRUCache<K,T>(size);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Adds an entry for the given key/value/space.
|
* 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);
|
this.privateAddEntry (entry, false);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -316,7 +316,7 @@ public class LRUCache implements Cloneable {
|
||||||
* @param shuffle Indicates whether we are just shuffling the queue
|
* @param shuffle Indicates whether we are just shuffling the queue
|
||||||
* (i.e., the entry table is left alone).
|
* (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) {
|
if (!shuffle) {
|
||||||
fEntryTable.put (entry._fKey, entry);
|
fEntryTable.put (entry._fKey, entry);
|
||||||
|
@ -341,7 +341,7 @@ public class LRUCache implements Cloneable {
|
||||||
* fallen off the bottom of the LRU queue.
|
* fallen off the bottom of the LRU queue.
|
||||||
* Subclasses could over-ride this to implement a persistent cache below the LRU cache.
|
* 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.
|
// Default is NOP.
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -349,9 +349,9 @@ public class LRUCache implements Cloneable {
|
||||||
* @param shuffle indicates whether we are just shuffling the queue
|
* @param shuffle indicates whether we are just shuffling the queue
|
||||||
* (i.e., the entry table is left alone).
|
* (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;
|
previous = entry._fPrevious;
|
||||||
next = entry._fNext;
|
next = entry._fNext;
|
||||||
|
@ -383,14 +383,14 @@ public class LRUCache implements Cloneable {
|
||||||
* @param value Value of object to add.
|
* @param value Value of object to add.
|
||||||
* @return added value.
|
* @return added value.
|
||||||
*/
|
*/
|
||||||
public Object put(Object key, Object value) {
|
public T put(K key, T value) {
|
||||||
|
|
||||||
int newSpace, oldSpace, newTotal;
|
int newSpace, oldSpace, newTotal;
|
||||||
LRUCacheEntry entry;
|
LRUCacheEntry<K,T> entry;
|
||||||
|
|
||||||
/* Check whether there's an entry in the cache */
|
/* Check whether there's an entry in the cache */
|
||||||
newSpace = spaceFor (key, value);
|
newSpace = spaceFor (key, value);
|
||||||
entry = (LRUCacheEntry) fEntryTable.get (key);
|
entry = fEntryTable.get (key);
|
||||||
|
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
|
|
||||||
|
@ -422,13 +422,13 @@ public class LRUCache implements Cloneable {
|
||||||
* @param key Key of object to remove from cache.
|
* @param key Key of object to remove from cache.
|
||||||
* @return Value removed 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) {
|
if (entry == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Object value = entry._fValue;
|
T value = entry._fValue;
|
||||||
this.privateRemoveEntry (entry, false);
|
this.privateRemoveEntry (entry, false);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -472,7 +472,7 @@ protected String toStringContents() {
|
||||||
int length = fEntryTable.size();
|
int length = fEntryTable.size();
|
||||||
Object[] unsortedKeys = new Object[length];
|
Object[] unsortedKeys = new Object[length];
|
||||||
String[] unsortedToStrings = new String[length];
|
String[] unsortedToStrings = new String[length];
|
||||||
Enumeration e = this.keys();
|
Enumeration<K> e = this.keys();
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
Object key = e.nextElement();
|
Object key = e.nextElement();
|
||||||
unsortedKeys[i] = key;
|
unsortedKeys[i] = key;
|
||||||
|
@ -497,7 +497,7 @@ protected String toStringContents() {
|
||||||
* Updates the timestamp for the given entry, ensuring that the queue is
|
* Updates the timestamp for the given entry, ensuring that the queue is
|
||||||
* kept in correct order. The entry must exist
|
* kept in correct order. The entry must exist
|
||||||
*/
|
*/
|
||||||
protected void updateTimestamp (LRUCacheEntry entry) {
|
protected void updateTimestamp (LRUCacheEntry<K,T> entry) {
|
||||||
|
|
||||||
entry._fTimestamp = fTimestampCounter++;
|
entry._fTimestamp = fTimestampCounter++;
|
||||||
if (fEntryQueue != entry) {
|
if (fEntryQueue != entry) {
|
||||||
|
|
|
@ -24,34 +24,34 @@ import java.util.Enumeration;
|
||||||
*
|
*
|
||||||
* This class is similar to the JDT LRUCacheEnumerator class.
|
* This class is similar to the JDT LRUCacheEnumerator class.
|
||||||
*/
|
*/
|
||||||
public class LRUCacheEnumerator implements Enumeration {
|
public class LRUCacheEnumerator<T> implements Enumeration<T> {
|
||||||
/**
|
/**
|
||||||
* Current element;
|
* Current element;
|
||||||
*/
|
*/
|
||||||
protected LRUEnumeratorElement fElementQueue;
|
protected LRUEnumeratorElement<T> fElementQueue;
|
||||||
|
|
||||||
public static class LRUEnumeratorElement {
|
public static class LRUEnumeratorElement<T> {
|
||||||
/**
|
/**
|
||||||
* Value returned by <code>nextElement()</code>;
|
* Value returned by <code>nextElement()</code>;
|
||||||
*/
|
*/
|
||||||
public Object fValue;
|
public T fValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Next element
|
* Next element
|
||||||
*/
|
*/
|
||||||
public LRUEnumeratorElement fNext;
|
public LRUEnumeratorElement<T> fNext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public LRUEnumeratorElement(Object value) {
|
public LRUEnumeratorElement(T value) {
|
||||||
fValue = value;
|
fValue = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Creates a CacheEnumerator on the list of <code>LRUEnumeratorElements</code>.
|
* Creates a CacheEnumerator on the list of <code>LRUEnumeratorElements</code>.
|
||||||
*/
|
*/
|
||||||
public LRUCacheEnumerator(LRUEnumeratorElement firstElement) {
|
public LRUCacheEnumerator(LRUEnumeratorElement<T> firstElement) {
|
||||||
fElementQueue = firstElement;
|
fElementQueue = firstElement;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -63,8 +63,8 @@ public class LRUCacheEnumerator implements Enumeration {
|
||||||
/**
|
/**
|
||||||
* Returns the next element.
|
* Returns the next element.
|
||||||
*/
|
*/
|
||||||
public Object nextElement() {
|
public T nextElement() {
|
||||||
Object temp = fElementQueue.fValue;
|
T temp = fElementQueue.fValue;
|
||||||
fElementQueue = fElementQueue.fNext;
|
fElementQueue = fElementQueue.fNext;
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.util;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The <code>OverflowingLRUCache</code> is an LRUCache which attempts
|
* 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.
|
* 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.
|
* Indicates if the cache has been over filled and by how much.
|
||||||
*/
|
*/
|
||||||
|
@ -96,8 +95,8 @@ public abstract class OverflowingLRUCache extends LRUCache {
|
||||||
@Override
|
@Override
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
|
|
||||||
OverflowingLRUCache newCache = (OverflowingLRUCache)newInstance(fSpaceLimit, fOverflow);
|
OverflowingLRUCache<K,T> newCache = newInstance(fSpaceLimit, fOverflow);
|
||||||
LRUCacheEntry qEntry;
|
LRUCacheEntry<K,T> qEntry;
|
||||||
|
|
||||||
/* Preserve order of entries by copying from oldest to newest */
|
/* Preserve order of entries by copying from oldest to newest */
|
||||||
qEntry = this.fEntryQueueTail;
|
qEntry = this.fEntryQueueTail;
|
||||||
|
@ -115,25 +114,25 @@ public abstract class OverflowingLRUCache extends LRUCache {
|
||||||
* by closing the obejct.
|
* 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
|
* Returns an enumerator of the values in the cache with the most
|
||||||
* recently used first.
|
* recently used first.
|
||||||
*/
|
*/
|
||||||
public Enumeration elements() {
|
public Enumeration<T> elements() {
|
||||||
if (fEntryQueue == null)
|
if (fEntryQueue == null)
|
||||||
return new LRUCacheEnumerator(null);
|
return new LRUCacheEnumerator<T>(null);
|
||||||
LRUCacheEnumerator.LRUEnumeratorElement head =
|
LRUCacheEnumerator.LRUEnumeratorElement<T> head =
|
||||||
new LRUCacheEnumerator.LRUEnumeratorElement(fEntryQueue._fValue);
|
new LRUCacheEnumerator.LRUEnumeratorElement<T>(fEntryQueue._fValue);
|
||||||
LRUCacheEntry currentEntry = fEntryQueue._fNext;
|
LRUCacheEntry<K,T> currentEntry = fEntryQueue._fNext;
|
||||||
LRUCacheEnumerator.LRUEnumeratorElement currentElement = head;
|
LRUCacheEnumerator.LRUEnumeratorElement<T> currentElement = head;
|
||||||
while(currentEntry != null) {
|
while(currentEntry != null) {
|
||||||
currentElement.fNext = new LRUCacheEnumerator.LRUEnumeratorElement(currentEntry._fValue);
|
currentElement.fNext = new LRUCacheEnumerator.LRUEnumeratorElement<T>(currentEntry._fValue);
|
||||||
currentElement = currentElement.fNext;
|
currentElement = currentElement.fNext;
|
||||||
|
|
||||||
currentEntry = currentEntry._fNext;
|
currentEntry = currentEntry._fNext;
|
||||||
}
|
}
|
||||||
return new LRUCacheEnumerator(head);
|
return new LRUCacheEnumerator<T>(head);
|
||||||
}
|
}
|
||||||
public double fillingRatio() {
|
public double fillingRatio() {
|
||||||
return (fCurrentSpace + fOverflow) * 100.0 / fSpaceLimit;
|
return (fCurrentSpace + fOverflow) * 100.0 / fSpaceLimit;
|
||||||
|
@ -144,7 +143,7 @@ public abstract class OverflowingLRUCache extends LRUCache {
|
||||||
*
|
*
|
||||||
* @return Hashtable of entries
|
* @return Hashtable of entries
|
||||||
*/
|
*/
|
||||||
public java.util.Hashtable getEntryTable() {
|
public java.util.Hashtable<K,LRUCacheEntry<K,T>> getEntryTable() {
|
||||||
return fEntryTable;
|
return fEntryTable;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -183,7 +182,7 @@ public abstract class OverflowingLRUCache extends LRUCache {
|
||||||
/* Free up space by removing oldest entries */
|
/* Free up space by removing oldest entries */
|
||||||
int spaceNeeded = (int)((1 - fLoadFactor) * fSpaceLimit);
|
int spaceNeeded = (int)((1 - fLoadFactor) * fSpaceLimit);
|
||||||
spaceNeeded = (spaceNeeded > space) ? spaceNeeded : space;
|
spaceNeeded = (spaceNeeded > space) ? spaceNeeded : space;
|
||||||
LRUCacheEntry entry = fEntryQueueTail;
|
LRUCacheEntry<K,T> entry = fEntryQueueTail;
|
||||||
|
|
||||||
while (fCurrentSpace + spaceNeeded > limit && entry != null) {
|
while (fCurrentSpace + spaceNeeded > limit && entry != null) {
|
||||||
this.privateRemoveEntry(entry, false, false);
|
this.privateRemoveEntry(entry, false, false);
|
||||||
|
@ -203,16 +202,16 @@ public abstract class OverflowingLRUCache extends LRUCache {
|
||||||
/**
|
/**
|
||||||
* Returns a new instance of the reciever.
|
* 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.
|
* Answers the value in the cache at the given key.
|
||||||
* If the value is not in the cache, returns null
|
* If the value is not in the cache, returns null
|
||||||
*
|
*
|
||||||
* This function does not modify timestamps.
|
* 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) {
|
if (entry == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -223,7 +222,7 @@ public abstract class OverflowingLRUCache extends LRUCache {
|
||||||
*/
|
*/
|
||||||
public void printStats() {
|
public void printStats() {
|
||||||
int forwardListLength = 0;
|
int forwardListLength = 0;
|
||||||
LRUCacheEntry entry = fEntryQueue;
|
LRUCacheEntry<K,T> entry = fEntryQueue;
|
||||||
while(entry != null) {
|
while(entry != null) {
|
||||||
forwardListLength++;
|
forwardListLength++;
|
||||||
entry = entry._fNext;
|
entry = entry._fNext;
|
||||||
|
@ -238,11 +237,11 @@ public abstract class OverflowingLRUCache extends LRUCache {
|
||||||
}
|
}
|
||||||
System.out.println("Backward length: " + backwardListLength); //$NON-NLS-1$
|
System.out.println("Backward length: " + backwardListLength); //$NON-NLS-1$
|
||||||
|
|
||||||
Enumeration keys = fEntryTable.keys();
|
Enumeration<K> keys = fEntryTable.keys();
|
||||||
class Temp {
|
class Temp {
|
||||||
public Class fClass;
|
public Class<?> fClass;
|
||||||
public int fCount;
|
public int fCount;
|
||||||
public Temp(Class aClass) {
|
public Temp(Class<?> aClass) {
|
||||||
fClass = aClass;
|
fClass = aClass;
|
||||||
fCount = 1;
|
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$
|
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()) {
|
while(keys.hasMoreElements()) {
|
||||||
entry = (LRUCacheEntry)fEntryTable.get(keys.nextElement());
|
entry = fEntryTable.get(keys.nextElement());
|
||||||
Class key = entry._fValue.getClass();
|
Class<?> key = entry._fValue.getClass();
|
||||||
Temp t = (Temp)h.get(key);
|
Temp t = h.get(key);
|
||||||
if (t == null) {
|
if (t == null) {
|
||||||
h.put(key, new Temp(key));
|
h.put(key, new Temp(key));
|
||||||
} else {
|
} else {
|
||||||
|
@ -263,8 +262,8 @@ public abstract class OverflowingLRUCache extends LRUCache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Iterator iter = h.keySet().iterator(); iter.hasNext();){
|
for (Object element : h.keySet()) {
|
||||||
System.out.println(h.get(iter.next()));
|
System.out.println(h.get(element));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -275,7 +274,7 @@ public abstract class OverflowingLRUCache extends LRUCache {
|
||||||
* (i.e., the entry table is left alone).
|
* (i.e., the entry table is left alone).
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void privateRemoveEntry (LRUCacheEntry entry, boolean shuffle) {
|
protected void privateRemoveEntry (LRUCacheEntry<K,T> entry, boolean shuffle) {
|
||||||
privateRemoveEntry(entry, shuffle, true);
|
privateRemoveEntry(entry, shuffle, true);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -289,7 +288,7 @@ public abstract class OverflowingLRUCache extends LRUCache {
|
||||||
* @param shuffle indicates whether we are just shuffling the queue
|
* @param shuffle indicates whether we are just shuffling the queue
|
||||||
* (i.e., the entry table is left alone).
|
* (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 (!shuffle) {
|
||||||
if (external) {
|
if (external) {
|
||||||
|
@ -309,8 +308,8 @@ public abstract class OverflowingLRUCache extends LRUCache {
|
||||||
privateNotifyDeletionFromCache(entry);
|
privateNotifyDeletionFromCache(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LRUCacheEntry previous = entry._fPrevious;
|
LRUCacheEntry<K, T> previous = entry._fPrevious;
|
||||||
LRUCacheEntry next = entry._fNext;
|
LRUCacheEntry<K, T> next = entry._fNext;
|
||||||
|
|
||||||
/* if this was the first entry */
|
/* if this was the first entry */
|
||||||
if (previous == null) {
|
if (previous == null) {
|
||||||
|
@ -333,14 +332,14 @@ public abstract class OverflowingLRUCache extends LRUCache {
|
||||||
* @return added value.
|
* @return added value.
|
||||||
*/
|
*/
|
||||||
@Override
|
@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 */
|
/* attempt to rid ourselves of the overflow, if there is any */
|
||||||
if (fOverflow > 0)
|
if (fOverflow > 0)
|
||||||
shrink();
|
shrink();
|
||||||
|
|
||||||
/* Check whether there's an entry in the cache */
|
/* Check whether there's an entry in the cache */
|
||||||
int newSpace = spaceFor (key, value);
|
int newSpace = spaceFor (key, value);
|
||||||
LRUCacheEntry entry = (LRUCacheEntry) fEntryTable.get (key);
|
LRUCacheEntry<K, T> entry = fEntryTable.get (key);
|
||||||
|
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
|
|
||||||
|
@ -378,7 +377,7 @@ public abstract class OverflowingLRUCache extends LRUCache {
|
||||||
* @param key Key of object to remove from cache.
|
* @param key Key of object to remove from cache.
|
||||||
* @return Value removed from cache.
|
* @return Value removed from cache.
|
||||||
*/
|
*/
|
||||||
public Object remove(Object key) {
|
public Object remove(K key) {
|
||||||
return removeKey(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.
|
* <p>This method will do nothing if timestamps have been disabled.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void updateTimestamp(LRUCacheEntry entry) {
|
protected void updateTimestamp(LRUCacheEntry<K, T> entry) {
|
||||||
if (fTimestampsOn) {
|
if (fTimestampsOn) {
|
||||||
entry._fTimestamp = fTimestampCounter++;
|
entry._fTimestamp = fTimestampCounter++;
|
||||||
if (fEntryQueue != entry) {
|
if (fEntryQueue != entry) {
|
||||||
|
|
|
@ -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.CModelManager;
|
||||||
import org.eclipse.cdt.internal.core.model.IBufferFactory;
|
import org.eclipse.cdt.internal.core.model.IBufferFactory;
|
||||||
import org.eclipse.cdt.internal.core.model.Util;
|
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.pdom.PDOMManager;
|
||||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
||||||
import org.eclipse.core.resources.IProject;
|
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 is null, default factory must be used
|
||||||
if (factory == null) factory = BufferManager.getDefaultBufferManager().getDefaultBufferFactory();
|
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;
|
if (perFactoryWorkingCopies == null) return CModelManager.NoWorkingCopy;
|
||||||
Collection<IWorkingCopy> copies = perFactoryWorkingCopies.values();
|
Collection<WorkingCopy> copies = perFactoryWorkingCopies.values();
|
||||||
IWorkingCopy[] result = new IWorkingCopy[copies.size()];
|
IWorkingCopy[] result = new IWorkingCopy[copies.size()];
|
||||||
copies.toArray(result);
|
copies.toArray(result);
|
||||||
return result;
|
return result;
|
||||||
|
@ -494,7 +495,7 @@ public class CCorePlugin extends Plugin {
|
||||||
for (String key : newOptions.keySet()){
|
for (String key : newOptions.keySet()){
|
||||||
if (!CModelManager.OptionNames.contains(key)) continue; // unrecognized option
|
if (!CModelManager.OptionNames.contains(key)) continue; // unrecognized option
|
||||||
if (key.equals(CORE_ENCODING)) continue; // skipped, contributed by resource prefs
|
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);
|
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$
|
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, "CBuildConsole"); //$NON-NLS-1$
|
||||||
if (extension != null) {
|
if (extension != null) {
|
||||||
IExtension[] extensions = extension.getExtensions();
|
IExtension[] extensions = extension.getExtensions();
|
||||||
for (int i = 0; i < extensions.length; i++) {
|
for (IExtension extension2 : extensions) {
|
||||||
IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
|
IConfigurationElement[] configElements = extension2.getConfigurationElements();
|
||||||
for (int j = 0; j < configElements.length; j++) {
|
for (IConfigurationElement configElement : configElements) {
|
||||||
String consoleID = configElements[j].getAttribute("id"); //$NON-NLS-1$
|
String consoleID = configElement.getAttribute("id"); //$NON-NLS-1$
|
||||||
if ((id == null && consoleID == null) || (id != null && id.equals(consoleID))) {
|
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 - use getBinaryParserExtensions(IProject project)
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -621,9 +619,9 @@ public class CCorePlugin extends Plugin {
|
||||||
IExtension extension = extensionPoint.getExtension(id);
|
IExtension extension = extensionPoint.getExtension(id);
|
||||||
if (extension != null) {
|
if (extension != null) {
|
||||||
IConfigurationElement element[] = extension.getConfigurationElements();
|
IConfigurationElement element[] = extension.getConfigurationElements();
|
||||||
for (int i = 0; i < element.length; i++) {
|
for (IConfigurationElement element2 : element) {
|
||||||
if (element[i].getName().equalsIgnoreCase("cextension")) { //$NON-NLS-1$
|
if (element2.getName().equalsIgnoreCase("cextension")) { //$NON-NLS-1$
|
||||||
parser = (IBinaryParser) element[i].createExecutableExtension("run"); //$NON-NLS-1$
|
parser = (IBinaryParser) element2.createExecutableExtension("run"); //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -655,9 +653,6 @@ public class CCorePlugin extends Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param project
|
|
||||||
* @return
|
|
||||||
* @throws CoreException
|
|
||||||
* @deprecated use getCProjetDescription(IProject project, boolean create)
|
* @deprecated use getCProjetDescription(IProject project, boolean create)
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -779,9 +774,9 @@ public class CCorePlugin extends Plugin {
|
||||||
ICProjectDescription projDes = createProjectDescription(projectHandle, true);
|
ICProjectDescription projDes = createProjectDescription(projectHandle, true);
|
||||||
ICConfigurationDescription cfgs[] = projDes.getConfigurations();
|
ICConfigurationDescription cfgs[] = projDes.getConfigurations();
|
||||||
ICConfigurationDescription cfg = null;
|
ICConfigurationDescription cfg = null;
|
||||||
for(int i = 0; i < cfgs.length; i++){
|
for (ICConfigurationDescription cfg2 : cfgs) {
|
||||||
if(bsId.equals(cfgs[i].getBuildSystemId())){
|
if(bsId.equals(cfg2.getBuildSystemId())){
|
||||||
cfg = cfgs[i];
|
cfg = cfg2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -830,14 +825,7 @@ public class CCorePlugin extends Plugin {
|
||||||
* All checks should have been done externally
|
* All checks should have been done externally
|
||||||
* (as in the Conversion Wizards).
|
* (as in the Conversion Wizards).
|
||||||
* This method blindly does the conversion.
|
* 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)
|
public void convertProjectToC(IProject projectHandle, IProgressMonitor monitor, String projectID)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
if ((projectHandle == null) || (monitor == null) || (projectID == null)) {
|
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
|
* 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)
|
public void convertProjectToCC(IProject projectHandle, IProgressMonitor monitor, String projectID)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
if ((projectHandle == null) || (monitor == null) || (projectID == null)) {
|
if ((projectHandle == null) || (monitor == null) || (projectID == null)) {
|
||||||
|
@ -899,14 +880,14 @@ public class CCorePlugin extends Plugin {
|
||||||
if (extension != null) {
|
if (extension != null) {
|
||||||
IExtension[] extensions = extension.getExtensions();
|
IExtension[] extensions = extension.getExtensions();
|
||||||
IConfigurationElement defaultContributor = null;
|
IConfigurationElement defaultContributor = null;
|
||||||
for (int i = 0; i < extensions.length; i++) {
|
for (IExtension extension2 : extensions) {
|
||||||
IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
|
IConfigurationElement[] configElements = extension2.getConfigurationElements();
|
||||||
for (int j = 0; j < configElements.length; j++) {
|
for (IConfigurationElement configElement : configElements) {
|
||||||
if (configElements[j].getName().equals("processList")) { //$NON-NLS-1$
|
if (configElement.getName().equals("processList")) { //$NON-NLS-1$
|
||||||
String platform = configElements[j].getAttribute("platform"); //$NON-NLS-1$
|
String platform = configElement.getAttribute("platform"); //$NON-NLS-1$
|
||||||
if (platform == null ) { // first contrbutor found with not platform will be default.
|
if (platform == null ) { // first contrbutor found with not platform will be default.
|
||||||
if (defaultContributor == null) {
|
if (defaultContributor == null) {
|
||||||
defaultContributor = configElements[j];
|
defaultContributor = configElement;
|
||||||
}
|
}
|
||||||
} else if (platform.equals(Platform.getOS())) {
|
} else if (platform.equals(Platform.getOS())) {
|
||||||
// found explicit contributor for this platform.
|
// found explicit contributor for this platform.
|
||||||
|
@ -925,7 +906,6 @@ public class CCorePlugin extends Plugin {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of error parsers ids.
|
* Array of error parsers ids.
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public String[] getAllErrorParsersIDs() {
|
public String[] getAllErrorParsersIDs() {
|
||||||
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, ERROR_PARSER_SIMPLE_ID);
|
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)
|
* @see #createProjectDescription(IProject, boolean, boolean)
|
||||||
*/
|
*/
|
||||||
|
@ -1126,7 +1106,7 @@ public class CCorePlugin extends Plugin {
|
||||||
* @param des
|
* @param des
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*
|
*
|
||||||
* @see {@link #getProjectDescription(IProject, boolean)}
|
* @see #getProjectDescription(IProject, boolean)
|
||||||
* @see #createProjectDescription(IProject, boolean)
|
* @see #createProjectDescription(IProject, boolean)
|
||||||
*/
|
*/
|
||||||
public void setProjectDescription(IProject project, ICProjectDescription des) throws CoreException {
|
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
|
* Answers whether the given project is a new-style project, i.e. CConfigurationDataProvider-driven
|
||||||
* @param project
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public boolean isNewStyleProject(IProject project){
|
public boolean isNewStyleProject(IProject project){
|
||||||
return fNewCProjectDescriptionManager.isNewStyleProject(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
|
* Answers whether the given project is a new-style project, i.e. CConfigurationDataProvider-driven
|
||||||
* @param des
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public boolean isNewStyleProject(ICProjectDescription des){
|
public boolean isNewStyleProject(ICProjectDescription des){
|
||||||
return fNewCProjectDescriptionManager.isNewStyleProject(des);
|
return fNewCProjectDescriptionManager.isNewStyleProject(des);
|
||||||
|
|
|
@ -19,7 +19,6 @@ import java.util.List;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.internal.core.util.ILRUCacheable;
|
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.cdt.internal.core.util.OverflowingLRUCache;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IResource;
|
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.
|
* 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) {
|
public RemoveCacheJob(ICodeReaderCache cache, IResourceChangeEvent event) {
|
||||||
super(REMOVE_CACHE);
|
super(REMOVE_CACHE);
|
||||||
|
@ -97,11 +93,11 @@ public class CodeReaderCache implements ICodeReaderCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeKeys(IResourceDelta[] deltas) {
|
private void removeKeys(IResourceDelta[] deltas) {
|
||||||
for(int j=0; j<deltas.length; j++) {
|
for (IResourceDelta delta : deltas) {
|
||||||
if (deltas[j].getResource().getType() == IResource.PROJECT || deltas[j].getResource().getType() == IResource.FOLDER) {
|
if (delta.getResource().getType() == IResource.PROJECT || delta.getResource().getType() == IResource.FOLDER) {
|
||||||
removeKeys(deltas[j].getAffectedChildren());
|
removeKeys(delta.getAffectedChildren());
|
||||||
} else if (deltas[j].getResource() instanceof IFile && ((IFile)deltas[j].getResource()).getLocation() != null) {
|
} else if (delta.getResource() instanceof IFile && ((IFile)delta.getResource()).getLocation() != null) {
|
||||||
removeKey(((IFile)deltas[j].getResource()).getLocation().toOSString());
|
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.
|
* 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
|
* @param key the path of the CodeReader to retrieve
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public synchronized CodeReader get(String key) {
|
public synchronized CodeReader get(String key) {
|
||||||
CodeReader ret = null;
|
CodeReader ret = null;
|
||||||
|
@ -189,6 +184,37 @@ public class CodeReaderCache implements ICodeReaderCache {
|
||||||
cache.setSpaceLimit(size * MB_TO_KB_FACTOR);
|
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.
|
* This class is a wrapper/implementor class for OverflowingLRUCache.
|
||||||
*
|
*
|
||||||
|
@ -198,37 +224,8 @@ public class CodeReaderCache implements ICodeReaderCache {
|
||||||
* @author dsteffle
|
* @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.
|
* 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
|
// must be overloaded, required to remove entries from the cache
|
||||||
@Override
|
@Override
|
||||||
protected boolean close(LRUCacheEntry entry) {
|
protected boolean close(LRUCacheEntry<String,CodeReaderCacheEntry> entry) {
|
||||||
Object obj = remove(entry._fKey);
|
Object obj = remove(entry._fKey);
|
||||||
|
|
||||||
if (obj != null)
|
if (obj != null)
|
||||||
|
@ -251,16 +248,15 @@ public class CodeReaderCache implements ICodeReaderCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LRUCache newInstance(int size, int overflow) {
|
protected OverflowingLRUCache<String,CodeReaderCacheEntry> newInstance(int size, int overflow) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an entry from the cache and returns the entry that was removed if found.
|
* Removes an entry from the cache and returns the entry that was removed if found.
|
||||||
* Otherwise null is returned.
|
* Otherwise null is returned.
|
||||||
* @param key
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public CodeReader remove(String key) {
|
public CodeReader remove(String key) {
|
||||||
Object removed = removeKey(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.
|
* 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
|
* This way the proper size of the element in the cache can be determined
|
||||||
* via the CodeReaderCacheEntry.
|
* via the CodeReaderCacheEntry.
|
||||||
* @param key
|
|
||||||
* @param value
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public CodeReader put(Object key, CodeReader value) {
|
public CodeReader put(String key, CodeReader value) {
|
||||||
Object entry = new CodeReaderCacheEntry(value);
|
CodeReaderCacheEntry entry = new CodeReaderCacheEntry(value);
|
||||||
|
CodeReaderCacheEntry ret = put(key, entry);
|
||||||
Object ret = put(key, entry);
|
if (ret != null)
|
||||||
|
return ret.getCodeReader();
|
||||||
if (ret instanceof CodeReaderCacheEntry)
|
|
||||||
return ((CodeReaderCacheEntry)ret).getCodeReader();
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a CodeReader from the cache corresponding to the path specified by the key.
|
* Retrieves a CodeReader from the cache corresponding to the path specified by the key.
|
||||||
* @param key
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public CodeReader get(String key) {
|
public CodeReader get(String key) {
|
||||||
Object obj = peek(key);
|
CodeReaderCacheEntry obj = peek(key);
|
||||||
if (obj instanceof CodeReaderCacheEntry)
|
if (obj != null)
|
||||||
return ((CodeReaderCacheEntry)obj).getCodeReader();
|
return obj.getCodeReader();
|
||||||
|
|
||||||
return null;
|
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.
|
* Returns the current size of the cache. For the CodeReaderCache this is in MB.
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public int getCurrentSpace() {
|
public int getCurrentSpace() {
|
||||||
return cache.getCurrentSpace();
|
return cache.getCurrentSpace();
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class ScalabilityPreferencePage extends PreferencePage implements
|
||||||
|
|
||||||
public ScalabilityPreferencePage() {
|
public ScalabilityPreferencePage() {
|
||||||
setPreferenceStore(PreferenceConstants.getPreferenceStore());
|
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();
|
SelectionListener listener= (SelectionListener)iter.next();
|
||||||
listener.widgetSelected(null);
|
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) {
|
public void createControl(Composite parent) {
|
||||||
super.createControl(parent);
|
super.createControl(parent);
|
||||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.SCALABILITY_PREFERENCE_PAGE);
|
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.SCALABILITY_PREFERENCE_PAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see PreferencePage#createContents(Composite)
|
* @see PreferencePage#createContents(Composite)
|
||||||
|
@ -138,14 +138,14 @@ public class ScalabilityPreferencePage extends PreferencePage implements
|
||||||
|
|
||||||
createDetectionSettings(composite);
|
createDetectionSettings(composite);
|
||||||
|
|
||||||
new Separator().doFillIntoGrid(composite, nColumns);
|
new Separator().doFillIntoGrid(composite, nColumns);
|
||||||
|
|
||||||
createScalabilityModeSettings(composite);
|
createScalabilityModeSettings(composite);
|
||||||
|
|
||||||
new Separator().doFillIntoGrid(composite, nColumns);
|
new Separator().doFillIntoGrid(composite, nColumns);
|
||||||
|
|
||||||
String noteTitle= PreferencesMessages.ScalabilityPreferencePage_note;
|
String noteTitle= PreferencesMessages.ScalabilityPreferencePage_note;
|
||||||
String noteMessage= PreferencesMessages.ScalabilityPreferencePage_preferenceOnlyForNewViews;
|
String noteMessage= PreferencesMessages.ScalabilityPreferencePage_preferenceOnlyForNewViews;
|
||||||
Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), composite, noteTitle, noteMessage);
|
Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), composite, noteTitle, noteMessage);
|
||||||
GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
|
GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
|
||||||
gd.horizontalSpan= 2;
|
gd.horizontalSpan= 2;
|
||||||
|
@ -196,7 +196,7 @@ public class ScalabilityPreferencePage extends PreferencePage implements
|
||||||
fLinesToTrigger.setValidRange( 1, Integer.MAX_VALUE );
|
fLinesToTrigger.setValidRange( 1, Integer.MAX_VALUE );
|
||||||
String minValue = Integer.toString( 1 );
|
String minValue = Integer.toString( 1 );
|
||||||
String maxValue = Integer.toString( Integer.MAX_VALUE );
|
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.load();
|
||||||
fLinesToTrigger.setPropertyChangeListener( new IPropertyChangeListener() {
|
fLinesToTrigger.setPropertyChangeListener( new IPropertyChangeListener() {
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ public class ScalabilityPreferencePage extends PreferencePage implements
|
||||||
private static void indent(Control control) {
|
private static void indent(Control control) {
|
||||||
GridData gridData= new GridData();
|
GridData gridData= new GridData();
|
||||||
gridData.horizontalIndent= 20;
|
gridData.horizontalIndent= 20;
|
||||||
control.setLayoutData(gridData);
|
control.setLayoutData(gridData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createDependency(final Button master, String masterKey, final Control slave) {
|
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());
|
prefs.setValue(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES, fLinesToTrigger.getIntValue());
|
||||||
CUIPlugin.getDefault().savePluginPreferences();
|
CUIPlugin.getDefault().savePluginPreferences();
|
||||||
return super.performOk();
|
return super.performOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see PreferencePage#performDefaults()
|
* @see PreferencePage#performDefaults()
|
||||||
|
@ -291,6 +291,6 @@ public class ScalabilityPreferencePage extends PreferencePage implements
|
||||||
SelectionListener listener= (SelectionListener)iter.next();
|
SelectionListener listener= (SelectionListener)iter.next();
|
||||||
listener.widgetSelected(null);
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue