Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Camelon2003-06-12 16:48:27 -0400
committerJohn Camelon2003-06-12 16:48:27 -0400
commit4570a0f0f150fd8a990419dba0a6912922f483c2 (patch)
treebc6ccce25839acbfc0ed60f066a3b6487ceab2e6
parent7fb1f3201b8c44ec55ef2d4e72f70122b8ee46b7 (diff)
downloadorg.eclipse.cdt-Parser_SymbolTable_branch.tar.gz
org.eclipse.cdt-Parser_SymbolTable_branch.tar.xz
org.eclipse.cdt-Parser_SymbolTable_branch.zip
Get rest of JUnit tests working, will merge back to HEAD branch.Parser_SymbolTable_branch
-rw-r--r--core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java32
-rw-r--r--core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/UsingDeclaration.java6
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsCmd.java2
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsEntry.java2
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsHeader.java2
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsRunner.java3
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/RequestList.java6
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CModelException.java3
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElement.java2
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Buffer.java4
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java5
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelOperation.java25
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CommitWorkingCopyOperation.java2
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateElementInTUOperation.java2
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateFieldOperation.java2
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateFunctionDeclarationOperation.java4
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateIncludeOperation.java4
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateMemberOperation.java2
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateMethodOperation.java2
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IBufferFactory.java2
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MultiOperation.java2
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/RenameResourceElementsOperation.java2
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Structure.java4
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java2
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/util/OverflowingLRUCache.java856
-rw-r--r--core/org.eclipse.cdt.core/parser/ChangeLog3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTASMDefinition.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTLinkageSpecification.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTNamespaceDefinition.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTUsingDeclaration.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTUsingDirective.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTASMDefinition.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTLinkageSpecification.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTNamespaceDefinition.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTUsingDirective.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ASTUsingDirective.java)13
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTContainerExtension.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTUsingDeclaration.java47
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java8
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/BuildInfoFactory.java3
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/FileStorage.java9
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/MakeUtil.java1
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/parser/generated/CPPParser.java4
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/parser/generated/CPPParserTokenManager.java2
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java2
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/pty/PTYInputStream.java2
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/pty/PTYOutputStream.java2
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/EnvironmentReader.java2
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java2
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerOutputStream.java2
-rw-r--r--core/org.eclipse.cdt.ui.tests/ChangeLog3
-rw-r--r--core/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/DOMTests.java6
54 files changed, 633 insertions, 521 deletions
diff --git a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java
index 46ddd5d042..a2d9979945 100644
--- a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java
+++ b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java
@@ -84,6 +84,7 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor
classSpecifier.setClassKeyToken( classKey );
decl.setTypeSpecifier(classSpecifier);
+ domScopes.push( classSpecifier );
return classSpecifier;
}
@@ -100,6 +101,7 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor
public void classSpecifierEnd(Object classSpecifier, Token closingBrace) {
ClassSpecifier c = (ClassSpecifier)classSpecifier;
c.setTotalLength( closingBrace.getOffset() + closingBrace.getLength() - c.getStartingOffset() );
+ domScopes.pop();
}
/**
@@ -216,7 +218,7 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor
*/
public Object simpleDeclarationBegin(Object container, Token firstToken) {
SimpleDeclaration decl = new SimpleDeclaration( getCurrentDOMScope() );
- if( container instanceof IAccessable )
+ if( getCurrentDOMScope() instanceof IAccessable )
decl.setAccessSpecifier(new AccessSpecifier( ((IAccessable)getCurrentDOMScope()).getVisibility() ));
((IOffsetable)decl).setStartingOffset( firstToken.getOffset() );
return decl;
@@ -345,6 +347,7 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor
public void classSpecifierAbort(Object classSpecifier) {
ClassSpecifier cs = (ClassSpecifier)classSpecifier;
cs.getOwner().setTypeSpecifier(null);
+ domScopes.pop();
}
/**
@@ -620,26 +623,27 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDeclarationBegin(java.lang.Object)
*/
public Object usingDeclarationBegin(Object container) {
- IScope scope = (IScope)container;
- UsingDeclaration declaration = new UsingDeclaration( scope );
- return declaration;
+// IScope scope = (IScope)container;
+// UsingDeclaration declaration = new UsingDeclaration( scope );
+// return declaration;
+ return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDeclarationMapping(java.lang.Object)
*/
public void usingDeclarationMapping(Object decl, boolean isTypename) {
- UsingDeclaration declaration = (UsingDeclaration)decl;
- declaration.setMappedName( currName );
- declaration.setTypename( isTypename );
+// UsingDeclaration declaration = (UsingDeclaration)decl;
+// declaration.setMappedName( currName );
+// declaration.setTypename( isTypename );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDeclarationEnd(java.lang.Object)
*/
public void usingDeclarationEnd(Object decl) {
- UsingDeclaration declaration = (UsingDeclaration)decl;
- declaration.getOwnerScope().addDeclaration( declaration );
+// UsingDeclaration declaration = (UsingDeclaration)decl;
+// declaration.getOwnerScope().addDeclaration( declaration );
}
/* (non-Javadoc)
@@ -834,8 +838,8 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationBegin(java.lang.Object, boolean)
*/
public Object templateDeclarationBegin(Object container, Token exported) {
- TemplateDeclaration d = new TemplateDeclaration( (IScope)container, exported );
- if( container instanceof IAccessable )
+ TemplateDeclaration d = new TemplateDeclaration( (IScope)getCurrentDOMScope(), exported );
+ if( getCurrentDOMScope() instanceof IAccessable )
d.setVisibility( ((IAccessable)container).getVisibility() );
d.setStartingOffset( exported.getOffset() );
domScopes.push( d );
@@ -1022,8 +1026,10 @@ public class DOMBuilder implements IParserCallback, ISourceElementRequestor
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsageDeclaration(org.eclipse.cdt.core.parser.ast.IASTUsageDeclaration)
*/
public void acceptUsingDeclaration(IASTUsingDeclaration usageDeclaration) {
- // TODO Auto-generated method stub
-
+ UsingDeclaration declaration = new UsingDeclaration( getCurrentDOMScope() );
+ declaration.setTypename( usageDeclaration.isTypename());
+ declaration.setMappedName(usageDeclaration.usingTypeName());
+ declaration.getOwnerScope().addDeclaration( declaration );
}
/* (non-Javadoc)
diff --git a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/UsingDeclaration.java b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/UsingDeclaration.java
index 7e6afb13c1..20a6a91440 100644
--- a/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/UsingDeclaration.java
+++ b/core/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/UsingDeclaration.java
@@ -21,7 +21,7 @@ import org.eclipse.cdt.internal.core.parser.Name;
*/
public class UsingDeclaration extends Declaration {
- private Name mappedName;
+ private String mappedName;
boolean isTypename = false;
public UsingDeclaration( IScope owner )
@@ -31,7 +31,7 @@ public class UsingDeclaration extends Declaration {
/**
* @return String
*/
- public Name getMappedName() {
+ public String getMappedName() {
return mappedName;
}
@@ -39,7 +39,7 @@ public class UsingDeclaration extends Declaration {
* Sets the mapping.
* @param mapping The mapping to set
*/
- public void setMappedName(Name mapping) {
+ public void setMappedName(String mapping) {
this.mappedName = mapping;
}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsCmd.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsCmd.java
index ada44f6c88..117e338e34 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsCmd.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsCmd.java
@@ -11,9 +11,9 @@ import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;
-import org.eclipse.core.resources.IFile;
import org.eclipse.cdt.core.index.ITagEntry;
import org.eclipse.cdt.utils.spawner.ProcessFactory;
+import org.eclipse.core.resources.IFile;
public class CTagsCmd {
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsEntry.java
index cc4b2a7eb0..306df3e5c9 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsEntry.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsEntry.java
@@ -10,9 +10,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;
-import org.eclipse.core.resources.IFile;
import org.eclipse.cdt.core.index.ITagEntry;
import org.eclipse.cdt.core.index.TagFlags;
+import org.eclipse.core.resources.IFile;
public class CTagsEntry implements ITagEntry {
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsHeader.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsHeader.java
index 1398f8bf6d..b98baa8757 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsHeader.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsHeader.java
@@ -5,8 +5,8 @@ package org.eclipse.cdt.internal.core.index;
* All Rights Reserved.
*/
-import java.io.IOException;
import java.io.BufferedReader;
+import java.io.IOException;
/* This structure contains information about the tag file. */
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsRunner.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsRunner.java
index ae1d230b12..fcb036be7d 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsRunner.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/CTagsRunner.java
@@ -10,13 +10,12 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.cdt.core.index.ITagEntry;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.cdt.core.index.ITagEntry;
-
public class CTagsRunner implements Runnable {
IndexManager manager;
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/RequestList.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/RequestList.java
index f21eed91c3..2100668644 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/RequestList.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/RequestList.java
@@ -5,9 +5,11 @@ package org.eclipse.cdt.internal.core.index;
* All Rights Reserved.
*/
-import java.util.*;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
-import org.eclipse.core.resources.*;
+import org.eclipse.core.resources.IResource;
public class RequestList {
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CModelException.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CModelException.java
index dbe943a144..a093bf5ce2 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CModelException.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CModelException.java
@@ -5,9 +5,8 @@ package org.eclipse.cdt.core.model;
* All Rights Reserved.
*/
-import org.eclipse.core.runtime.CoreException;
-
import org.eclipse.cdt.internal.core.model.CModelStatus;
+import org.eclipse.core.runtime.CoreException;
/**
* A checked exception representing a failure in the C model.
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElement.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElement.java
index 69ddb3e375..09742d4909 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElement.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElement.java
@@ -6,8 +6,8 @@ package org.eclipse.cdt.core.model;
*/
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
/**
* Common protocol for all elements provided by the C model.
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Buffer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Buffer.java
index 1c130746ac..b8bb0fd4e4 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Buffer.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Buffer.java
@@ -14,8 +14,10 @@ package org.eclipse.cdt.internal.core.model;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
-import org.eclipse.cdt.core.model.*;
+import org.eclipse.cdt.core.model.BufferChangedEvent;
import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.IBuffer;
+import org.eclipse.cdt.core.model.IBufferChangedListener;
import org.eclipse.cdt.core.model.IOpenable;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java
index 42d77f538e..3492ca5928 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElementInfo.java
@@ -7,10 +7,9 @@ package org.eclipse.cdt.internal.core.model;
import java.io.File;
-import org.eclipse.core.resources.IResource;
-
-import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.core.resources.IResource;
/**
* Holds cached structure and properties for a C element.
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelOperation.java
index 9295f24f62..8e0ab94f2e 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelOperation.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelOperation.java
@@ -6,28 +6,27 @@ package org.eclipse.cdt.internal.core.model;
*/
import java.io.InputStream;
-import org.eclipse.core.resources.IResource;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICElementDelta;
+import org.eclipse.cdt.core.model.ICModel;
+import org.eclipse.cdt.core.model.ICModelStatus;
+import org.eclipse.cdt.core.model.ICModelStatusConstants;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceStatus;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.ICModel;
-import org.eclipse.cdt.core.model.ICModelStatus;
-import org.eclipse.cdt.core.model.ICModelStatusConstants;
-import org.eclipse.cdt.core.model.ICElementDelta;
-import org.eclipse.cdt.core.model.CModelException;
-
/**
* Defines behavior common to all C Model operations
*/
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CommitWorkingCopyOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CommitWorkingCopyOperation.java
index 062ae92d50..3dd9f1640b 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CommitWorkingCopyOperation.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CommitWorkingCopyOperation.java
@@ -11,8 +11,8 @@ package org.eclipse.cdt.internal.core.model;
* Rational Software - Initial API and implementation
***********************************************************************/
-import org.eclipse.cdt.core.model.*;
import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.IBuffer;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICModelStatus;
import org.eclipse.cdt.core.model.ICModelStatusConstants;
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateElementInTUOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateElementInTUOperation.java
index e70af71274..07cbb95c4d 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateElementInTUOperation.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateElementInTUOperation.java
@@ -11,8 +11,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import org.eclipse.cdt.core.model.*;
import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.IBuffer;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICModelStatus;
import org.eclipse.cdt.core.model.ICModelStatusConstants;
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateFieldOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateFieldOperation.java
index cae0806922..f699a9b42d 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateFieldOperation.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateFieldOperation.java
@@ -6,8 +6,8 @@ package org.eclipse.cdt.internal.core.model;
*/
import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.core.model.ICModelStatus;
+import org.eclipse.cdt.core.model.IStructure;
/**
* <p>This operation creates a field declaration in a type.
*
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateFunctionDeclarationOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateFunctionDeclarationOperation.java
index d00f25c016..766f4bb913 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateFunctionDeclarationOperation.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateFunctionDeclarationOperation.java
@@ -5,11 +5,11 @@ package org.eclipse.cdt.internal.core.model;
* All Rights Reserved.
*/
+import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICModelStatus;
import org.eclipse.cdt.core.model.IInclude;
import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.ICModelStatus;
-import org.eclipse.cdt.core.model.CModelException;
/**
* <p>This operation adds an include declaration to an existing translation unit.
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateIncludeOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateIncludeOperation.java
index e845adc9b9..d7a17d4319 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateIncludeOperation.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateIncludeOperation.java
@@ -5,11 +5,11 @@ package org.eclipse.cdt.internal.core.model;
* All Rights Reserved.
*/
+import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICModelStatus;
import org.eclipse.cdt.core.model.IInclude;
import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.ICModelStatus;
-import org.eclipse.cdt.core.model.CModelException;
/**
* <p>This operation adds an include declaration to an existing translation unit.
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateMemberOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateMemberOperation.java
index ffe3e1538b..90be8fd9bb 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateMemberOperation.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateMemberOperation.java
@@ -6,9 +6,9 @@ package org.eclipse.cdt.internal.core.model;
*/
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.ICModelStatusConstants;
+import org.eclipse.cdt.core.model.IStructure;
/**
* Implements functionality common to
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateMethodOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateMethodOperation.java
index 0704e20640..d86880bac5 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateMethodOperation.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CreateMethodOperation.java
@@ -6,8 +6,8 @@ package org.eclipse.cdt.internal.core.model;
*/
import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.core.model.ICModelStatus;
+import org.eclipse.cdt.core.model.IStructure;
/**
* <p>This operation creates an instance method.
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IBufferFactory.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IBufferFactory.java
index 0265d5428f..ff4b37c57d 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IBufferFactory.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IBufferFactory.java
@@ -11,7 +11,7 @@ package org.eclipse.cdt.internal.core.model;
* Rational Software - Initial API and implementation
***********************************************************************/
-import org.eclipse.cdt.core.model.*;
+import org.eclipse.cdt.core.model.IBuffer;
import org.eclipse.cdt.core.model.IOpenable;
/**
* A factory that creates <code>IBuffer</code>s for CFiles.
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MultiOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MultiOperation.java
index 4ae5aaec64..ae66505e97 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MultiOperation.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MultiOperation.java
@@ -8,11 +8,11 @@ package org.eclipse.cdt.internal.core.model;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICElementDelta;
import org.eclipse.cdt.core.model.ICModelStatus;
import org.eclipse.cdt.core.model.ICModelStatusConstants;
-import org.eclipse.cdt.core.model.CModelException;
/**
* This class is used to perform operations on multiple <code>ICElement</code>.
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/RenameResourceElementsOperation.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/RenameResourceElementsOperation.java
index 6c4da177ef..be0899ad7b 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/RenameResourceElementsOperation.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/RenameResourceElementsOperation.java
@@ -5,8 +5,8 @@ package org.eclipse.cdt.internal.core.model;
* All Rights Reserved.
*/
-import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
/**
* This operation renames resources (Package fragments and compilation units).
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Structure.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Structure.java
index c20fddf8fa..56e158b63a 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Structure.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Structure.java
@@ -7,9 +7,9 @@ package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IStructure;
-import org.eclipse.cdt.core.model.IMethod;
import org.eclipse.cdt.core.model.IField;
+import org.eclipse.cdt.core.model.IMethod;
+import org.eclipse.cdt.core.model.IStructure;
public class Structure extends SourceManipulation implements IStructure {
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java
index b87e7035ed..ec551d5e80 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/WorkingCopy.java
@@ -14,8 +14,8 @@ package org.eclipse.cdt.internal.core.model;
import java.io.ByteArrayInputStream;
import java.util.Map;
-import org.eclipse.cdt.core.model.*;
import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.IBuffer;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICModelStatusConstants;
import org.eclipse.cdt.core.model.ITranslationUnit;
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/util/OverflowingLRUCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/util/OverflowingLRUCache.java
index c479f797d8..bd999902a1 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/util/OverflowingLRUCache.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/util/OverflowingLRUCache.java
@@ -1,429 +1,427 @@
-package org.eclipse.cdt.internal.core.util;
-
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * Rational Software - Initial API and implementation
-***********************************************************************/
-
-import java.util.Enumeration;
-import java.util.Iterator;
-
-import org.eclipse.cdt.internal.core.util.LRUCache;
-
-/**
- * The <code>OverflowingLRUCache</code> is an LRUCache which attempts
- * to maintain a size equal or less than its <code>fSpaceLimit</code>
- * by removing the least recently used elements.
- *
- * <p>The cache will remove elements which successfully close and all
- * elements which are explicitly removed.
- *
- * <p>If the cache cannot remove enough old elements to add new elements
- * it will grow beyond <code>fSpaceLimit</code>. Later, it will attempt to
- * shink back to the maximum space limit.
- *
- * The method <code>close</code> should attempt to close the element. If
- * the element is successfully closed it will return true and the element will
- * be removed from the cache. Otherwise the element will remain in the cache.
- *
- * <p>The cache implicitly attempts shrinks on calls to <code>put</code>and
- * <code>setSpaceLimit</code>. Explicitly calling the <code>shrink</code> method
- * will also cause the cache to attempt to shrink.
- *
- * <p>The cache calculates the used space of all elements which implement
- * <code>ILRUCacheable</code>. All other elements are assumed to be of size one.
- *
- * <p>Use the <code>#peek(Object)</code> and <code>#disableTimestamps()</code> method to
- * circumvent the timestamp feature of the cache. This feature is intended to be used
- * only when the <code>#close(LRUCacheEntry)</code> method causes changes to the cache.
- * For example, if a parent closes its children when </code>#close(LRUCacheEntry)</code> is called,
- * it should be careful not to change the LRU linked list. It can be sure it is not causing
- * problems by calling <code>#peek(Object)</code> instead of <code>#get(Object)</code> method.
- *
- * @see LRUCache
- *
- * This class is similar to the JDT OverflowingLRUCache class.
- */
-public abstract class OverflowingLRUCache extends LRUCache {
- /**
- * Indicates if the cache has been over filled and by how much.
- */
- protected int fOverflow = 0;
- /**
- * Indicates whether or not timestamps should be updated
- */
- protected boolean fTimestampsOn = true;
- /**
- * Indicates how much space should be reclaimed when the cache overflows.
- * Inital load factor of one third.
- */
- protected double fLoadFactor = 0.333;
- /**
- * Creates a OverflowingLRUCache.
- * @param size Size limit of cache.
- */
- public OverflowingLRUCache(int size) {
- this(size, 0);
- }
- /**
- * Creates a OverflowingLRUCache.
- * @param size Size limit of cache.
- * @param overflow Size of the overflow.
- */
- public OverflowingLRUCache(int size, int overflow) {
- super(size);
- fOverflow = overflow;
- }
- /**
- * Returns a new cache containing the same contents.
- *
- * @return New copy of this object.
- */
- public Object clone() {
-
- OverflowingLRUCache newCache = (OverflowingLRUCache)newInstance(fSpaceLimit, fOverflow);
- LRUCacheEntry qEntry;
-
- /* Preserve order of entries by copying from oldest to newest */
- qEntry = this.fEntryQueueTail;
- while (qEntry != null) {
- newCache.privateAdd (qEntry._fKey, qEntry._fValue, qEntry._fSpace);
- qEntry = qEntry._fPrevious;
- }
- return newCache;
- }
- /**
- * Returns true if the element is successfully closed and
- * removed from the cache, otherwise false.
- *
- * <p>NOTE: this triggers an external remove from the cache
- * by closing the obejct.
- *
- */
- protected abstract boolean close(LRUCacheEntry entry);
- /**
- * Returns an enumerator of the values in the cache with the most
- * recently used first.
- */
- public Enumeration elements() {
- if (fEntryQueue == null)
- return new LRUCacheEnumerator(null);
- LRUCacheEnumerator.LRUEnumeratorElement head =
- new LRUCacheEnumerator.LRUEnumeratorElement(fEntryQueue._fValue);
- LRUCacheEntry currentEntry = fEntryQueue._fNext;
- LRUCacheEnumerator.LRUEnumeratorElement currentElement = head;
- while(currentEntry != null) {
- currentElement.fNext = new LRUCacheEnumerator.LRUEnumeratorElement(currentEntry._fValue);
- currentElement = currentElement.fNext;
-
- currentEntry = currentEntry._fNext;
- }
- return new LRUCacheEnumerator(head);
- }
- public double fillingRatio() {
- return (fCurrentSpace + fOverflow) * 100.0 / fSpaceLimit;
- }
- /**
- * For internal testing only.
- * This method exposed only for testing purposes!
- *
- * @return Hashtable of entries
- */
- public java.util.Hashtable getEntryTable() {
- return fEntryTable;
- }
- /**
- * Returns the load factor for the cache. The load factor determines how
- * much space is reclaimed when the cache exceeds its space limit.
- * @return double
- */
- public double getLoadFactor() {
- return fLoadFactor;
- }
- /**
- * @return The space by which the cache has overflown.
- */
- public int getOverflow() {
- return fOverflow;
- }
- /**
- * Ensures there is the specified amount of free space in the receiver,
- * by removing old entries if necessary. Returns true if the requested space was
- * made available, false otherwise. May not be able to free enough space
- * since some elements cannot be removed until they are saved.
- *
- * @param space Amount of space to free up
- */
- protected boolean makeSpace(int space) {
-
- int limit = fSpaceLimit;
- if (fOverflow == 0) {
- /* if space is already available */
- if (fCurrentSpace + space <= limit) {
- return true;
- }
- }
-
- /* Free up space by removing oldest entries */
- int spaceNeeded = (int)((1 - fLoadFactor) * fSpaceLimit);
- spaceNeeded = (spaceNeeded > space) ? spaceNeeded : space;
- LRUCacheEntry entry = fEntryQueueTail;
-
- while (fCurrentSpace + spaceNeeded > limit && entry != null) {
- this.privateRemoveEntry(entry, false, false);
- entry = entry._fPrevious;
- }
-
- /* check again, since we may have aquired enough space */
- if (fCurrentSpace + space <= limit) {
- fOverflow = 0;
- return true;
- }
-
- /* update fOverflow */
- fOverflow = fCurrentSpace + space - limit;
- return false;
- }
- /**
- * Returns a new instance of the reciever.
- */
- protected abstract LRUCache newInstance(int size, int overflow);
- /**
- * Answers the value in the cache at the given key.
- * If the value is not in the cache, returns null
- *
- * This function does not modify timestamps.
- */
- public Object peek(Object key) {
-
- LRUCacheEntry entry = (LRUCacheEntry) fEntryTable.get(key);
- if (entry == null) {
- return null;
- }
- return entry._fValue;
- }
- /**
- * For testing purposes only
- */
- public void printStats() {
- int forwardListLength = 0;
- LRUCacheEntry entry = fEntryQueue;
- while(entry != null) {
- forwardListLength++;
- entry = entry._fNext;
- }
- System.out.println("Forward length: " + forwardListLength); //$NON-NLS-1$
-
- int backwardListLength = 0;
- entry = fEntryQueueTail;
- while(entry != null) {
- backwardListLength++;
- entry = entry._fPrevious;
- }
- System.out.println("Backward length: " + backwardListLength); //$NON-NLS-1$
-
- Enumeration keys = fEntryTable.keys();
- class Temp {
- public Class fClass;
- public int fCount;
- public Temp(Class aClass) {
- fClass = aClass;
- fCount = 1;
- }
- public String toString() {
- return "Class: " + fClass + " has " + fCount + " entries."; //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$
- }
- }
- java.util.HashMap h = new java.util.HashMap();
- while(keys.hasMoreElements()) {
- entry = (LRUCacheEntry)fEntryTable.get(keys.nextElement());
- Class key = entry._fValue.getClass();
- Temp t = (Temp)h.get(key);
- if (t == null) {
- h.put(key, new Temp(key));
- } else {
- t.fCount++;
- }
- }
-
- for (Iterator iter = h.keySet().iterator(); iter.hasNext();){
- System.out.println(h.get(iter.next()));
- }
- }
- /**
- * Removes the entry from the entry queue.
- * Calls <code>privateRemoveEntry</code> with the external functionality enabled.
- *
- * @param shuffle indicates whether we are just shuffling the queue
- * (i.e., the entry table is left alone).
- */
- protected void privateRemoveEntry (LRUCacheEntry entry, boolean shuffle) {
- privateRemoveEntry(entry, shuffle, true);
- }
- /**
- * Removes the entry from the entry queue. If <i>external</i> is true, the entry is removed
- * without checking if it can be removed. It is assumed that the client has already closed
- * the element it is trying to remove (or will close it promptly).
- *
- * If <i>external</i> is false, and the entry could not be closed, it is not removed and the
- * pointers are not changed.
- *
- * @param shuffle indicates whether we are just shuffling the queue
- * (i.e., the entry table is left alone).
- */
- protected void privateRemoveEntry(LRUCacheEntry entry, boolean shuffle, boolean external) {
-
- if (!shuffle) {
- if (external) {
- fEntryTable.remove(entry._fKey);
- fCurrentSpace -= entry._fSpace;
- privateNotifyDeletionFromCache(entry);
- } else {
- if (!close(entry)) return;
- // buffer close will recursively call #privateRemoveEntry with external==true
- // thus entry will already be removed if reaching this point.
- if (fEntryTable.get(entry._fKey) == null){
- return;
- } else {
- // basic removal
- fEntryTable.remove(entry._fKey);
- fCurrentSpace -= entry._fSpace;
- privateNotifyDeletionFromCache(entry);
- }
- }
- }
- LRUCacheEntry previous = entry._fPrevious;
- LRUCacheEntry next = entry._fNext;
-
- /* if this was the first entry */
- if (previous == null) {
- fEntryQueue = next;
- } else {
- previous._fNext = next;
- }
- /* if this was the last entry */
- if (next == null) {
- fEntryQueueTail = previous;
- } else {
- next._fPrevious = previous;
- }
- }
- /**
- * Sets the value in the cache at the given key. Returns the value.
- *
- * @param key Key of object to add.
- * @param value Value of object to add.
- * @return added value.
- */
- public Object put(Object key, Object value) {
- /* attempt to rid ourselves of the overflow, if there is any */
- if (fOverflow > 0)
- shrink();
-
- /* Check whether there's an entry in the cache */
- int newSpace = spaceFor (key, value);
- LRUCacheEntry entry = (LRUCacheEntry) fEntryTable.get (key);
-
- if (entry != null) {
-
- /**
- * Replace the entry in the cache if it would not overflow
- * the cache. Otherwise flush the entry and re-add it so as
- * to keep cache within budget
- */
- int oldSpace = entry._fSpace;
- int newTotal = fCurrentSpace - oldSpace + newSpace;
- if (newTotal <= fSpaceLimit) {
- updateTimestamp (entry);
- entry._fValue = value;
- entry._fSpace = newSpace;
- fCurrentSpace = newTotal;
- fOverflow = 0;
- return value;
- } else {
- privateRemoveEntry (entry, false, false);
- }
- }
-
- // attempt to make new space
- makeSpace(newSpace);
-
- // add without worring about space, it will
- // be handled later in a makeSpace call
- privateAdd (key, value, newSpace);
-
- return value;
- }
- /**
- * Removes and returns the value in the cache for the given key.
- * If the key is not in the cache, returns null.
- *
- * @param key Key of object to remove from cache.
- * @return Value removed from cache.
- */
- public Object remove(Object key) {
- return removeKey(key);
- }
- /**
- * Sets the load factor for the cache. The load factor determines how
- * much space is reclaimed when the cache exceeds its space limit.
- * @param newLoadFactor double
- * @throws IllegalArgumentException when the new load factor is not in (0.0, 1.0]
- */
- public void setLoadFactor(double newLoadFactor) throws IllegalArgumentException {
- if(newLoadFactor <= 1.0 && newLoadFactor > 0.0)
- fLoadFactor = newLoadFactor;
- else
- throw new IllegalArgumentException("cache.invalidLoadFactor"); //$NON-NLS-1$
- }
- /**
- * Sets the maximum amount of space that the cache can store
- *
- * @param limit Number of units of cache space
- */
- public void setSpaceLimit(int limit) {
- if (limit < fSpaceLimit) {
- makeSpace(fSpaceLimit - limit);
- }
- fSpaceLimit = limit;
- }
- /**
- * Attempts to shrink the cache if it has overflown.
- * Returns true if the cache shrinks to less than or equal to <code>fSpaceLimit</code>.
- */
- public boolean shrink() {
- if (fOverflow > 0)
- return makeSpace(0);
- return true;
- }
- /**
- * Returns a String that represents the value of this object. This method
- * is for debugging purposes only.
- */
- public String toString() {
- return
- "OverflowingLRUCache " + this.fillingRatio() + "% full\n" + //$NON-NLS-1$ //$NON-NLS-2$
- this.toStringContents();
- }
- /**
- * Updates the timestamp for the given entry, ensuring that the queue is
- * kept in correct order. The entry must exist.
- *
- * <p>This method will do nothing if timestamps have been disabled.
- */
- protected void updateTimestamp(LRUCacheEntry entry) {
- if (fTimestampsOn) {
- entry._fTimestamp = fTimestampCounter++;
- if (fEntryQueue != entry) {
- this.privateRemoveEntry(entry, true);
- this.privateAddEntry(entry, true);
- }
- }
- }
-}
+package org.eclipse.cdt.internal.core.util;
+
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * Rational Software - Initial API and implementation
+***********************************************************************/
+
+import java.util.Enumeration;
+import java.util.Iterator;
+
+/**
+ * The <code>OverflowingLRUCache</code> is an LRUCache which attempts
+ * to maintain a size equal or less than its <code>fSpaceLimit</code>
+ * by removing the least recently used elements.
+ *
+ * <p>The cache will remove elements which successfully close and all
+ * elements which are explicitly removed.
+ *
+ * <p>If the cache cannot remove enough old elements to add new elements
+ * it will grow beyond <code>fSpaceLimit</code>. Later, it will attempt to
+ * shink back to the maximum space limit.
+ *
+ * The method <code>close</code> should attempt to close the element. If
+ * the element is successfully closed it will return true and the element will
+ * be removed from the cache. Otherwise the element will remain in the cache.
+ *
+ * <p>The cache implicitly attempts shrinks on calls to <code>put</code>and
+ * <code>setSpaceLimit</code>. Explicitly calling the <code>shrink</code> method
+ * will also cause the cache to attempt to shrink.
+ *
+ * <p>The cache calculates the used space of all elements which implement
+ * <code>ILRUCacheable</code>. All other elements are assumed to be of size one.
+ *
+ * <p>Use the <code>#peek(Object)</code> and <code>#disableTimestamps()</code> method to
+ * circumvent the timestamp feature of the cache. This feature is intended to be used
+ * only when the <code>#close(LRUCacheEntry)</code> method causes changes to the cache.
+ * For example, if a parent closes its children when </code>#close(LRUCacheEntry)</code> is called,
+ * it should be careful not to change the LRU linked list. It can be sure it is not causing
+ * problems by calling <code>#peek(Object)</code> instead of <code>#get(Object)</code> method.
+ *
+ * @see LRUCache
+ *
+ * This class is similar to the JDT OverflowingLRUCache class.
+ */
+public abstract class OverflowingLRUCache extends LRUCache {
+ /**
+ * Indicates if the cache has been over filled and by how much.
+ */
+ protected int fOverflow = 0;
+ /**
+ * Indicates whether or not timestamps should be updated
+ */
+ protected boolean fTimestampsOn = true;
+ /**
+ * Indicates how much space should be reclaimed when the cache overflows.
+ * Inital load factor of one third.
+ */
+ protected double fLoadFactor = 0.333;
+ /**
+ * Creates a OverflowingLRUCache.
+ * @param size Size limit of cache.
+ */
+ public OverflowingLRUCache(int size) {
+ this(size, 0);
+ }
+ /**
+ * Creates a OverflowingLRUCache.
+ * @param size Size limit of cache.
+ * @param overflow Size of the overflow.
+ */
+ public OverflowingLRUCache(int size, int overflow) {
+ super(size);
+ fOverflow = overflow;
+ }
+ /**
+ * Returns a new cache containing the same contents.
+ *
+ * @return New copy of this object.
+ */
+ public Object clone() {
+
+ OverflowingLRUCache newCache = (OverflowingLRUCache)newInstance(fSpaceLimit, fOverflow);
+ LRUCacheEntry qEntry;
+
+ /* Preserve order of entries by copying from oldest to newest */
+ qEntry = this.fEntryQueueTail;
+ while (qEntry != null) {
+ newCache.privateAdd (qEntry._fKey, qEntry._fValue, qEntry._fSpace);
+ qEntry = qEntry._fPrevious;
+ }
+ return newCache;
+ }
+ /**
+ * Returns true if the element is successfully closed and
+ * removed from the cache, otherwise false.
+ *
+ * <p>NOTE: this triggers an external remove from the cache
+ * by closing the obejct.
+ *
+ */
+ protected abstract boolean close(LRUCacheEntry entry);
+ /**
+ * Returns an enumerator of the values in the cache with the most
+ * recently used first.
+ */
+ public Enumeration elements() {
+ if (fEntryQueue == null)
+ return new LRUCacheEnumerator(null);
+ LRUCacheEnumerator.LRUEnumeratorElement head =
+ new LRUCacheEnumerator.LRUEnumeratorElement(fEntryQueue._fValue);
+ LRUCacheEntry currentEntry = fEntryQueue._fNext;
+ LRUCacheEnumerator.LRUEnumeratorElement currentElement = head;
+ while(currentEntry != null) {
+ currentElement.fNext = new LRUCacheEnumerator.LRUEnumeratorElement(currentEntry._fValue);
+ currentElement = currentElement.fNext;
+
+ currentEntry = currentEntry._fNext;
+ }
+ return new LRUCacheEnumerator(head);
+ }
+ public double fillingRatio() {
+ return (fCurrentSpace + fOverflow) * 100.0 / fSpaceLimit;
+ }
+ /**
+ * For internal testing only.
+ * This method exposed only for testing purposes!
+ *
+ * @return Hashtable of entries
+ */
+ public java.util.Hashtable getEntryTable() {
+ return fEntryTable;
+ }
+ /**
+ * Returns the load factor for the cache. The load factor determines how
+ * much space is reclaimed when the cache exceeds its space limit.
+ * @return double
+ */
+ public double getLoadFactor() {
+ return fLoadFactor;
+ }
+ /**
+ * @return The space by which the cache has overflown.
+ */
+ public int getOverflow() {
+ return fOverflow;
+ }
+ /**
+ * Ensures there is the specified amount of free space in the receiver,
+ * by removing old entries if necessary. Returns true if the requested space was
+ * made available, false otherwise. May not be able to free enough space
+ * since some elements cannot be removed until they are saved.
+ *
+ * @param space Amount of space to free up
+ */
+ protected boolean makeSpace(int space) {
+
+ int limit = fSpaceLimit;
+ if (fOverflow == 0) {
+ /* if space is already available */
+ if (fCurrentSpace + space <= limit) {
+ return true;
+ }
+ }
+
+ /* Free up space by removing oldest entries */
+ int spaceNeeded = (int)((1 - fLoadFactor) * fSpaceLimit);
+ spaceNeeded = (spaceNeeded > space) ? spaceNeeded : space;
+ LRUCacheEntry entry = fEntryQueueTail;
+
+ while (fCurrentSpace + spaceNeeded > limit && entry != null) {
+ this.privateRemoveEntry(entry, false, false);
+ entry = entry._fPrevious;
+ }
+
+ /* check again, since we may have aquired enough space */
+ if (fCurrentSpace + space <= limit) {
+ fOverflow = 0;
+ return true;
+ }
+
+ /* update fOverflow */
+ fOverflow = fCurrentSpace + space - limit;
+ return false;
+ }
+ /**
+ * Returns a new instance of the reciever.
+ */
+ protected abstract LRUCache newInstance(int size, int overflow);
+ /**
+ * Answers the value in the cache at the given key.
+ * If the value is not in the cache, returns null
+ *
+ * This function does not modify timestamps.
+ */
+ public Object peek(Object key) {
+
+ LRUCacheEntry entry = (LRUCacheEntry) fEntryTable.get(key);
+ if (entry == null) {
+ return null;
+ }
+ return entry._fValue;
+ }
+ /**
+ * For testing purposes only
+ */
+ public void printStats() {
+ int forwardListLength = 0;
+ LRUCacheEntry entry = fEntryQueue;
+ while(entry != null) {
+ forwardListLength++;
+ entry = entry._fNext;
+ }
+ System.out.println("Forward length: " + forwardListLength); //$NON-NLS-1$
+
+ int backwardListLength = 0;
+ entry = fEntryQueueTail;
+ while(entry != null) {
+ backwardListLength++;
+ entry = entry._fPrevious;
+ }
+ System.out.println("Backward length: " + backwardListLength); //$NON-NLS-1$
+
+ Enumeration keys = fEntryTable.keys();
+ class Temp {
+ public Class fClass;
+ public int fCount;
+ public Temp(Class aClass) {
+ fClass = aClass;
+ fCount = 1;
+ }
+ public String toString() {
+ return "Class: " + fClass + " has " + fCount + " entries."; //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$
+ }
+ }
+ java.util.HashMap h = new java.util.HashMap();
+ while(keys.hasMoreElements()) {
+ entry = (LRUCacheEntry)fEntryTable.get(keys.nextElement());
+ Class key = entry._fValue.getClass();
+ Temp t = (Temp)h.get(key);
+ if (t == null) {
+ h.put(key, new Temp(key));
+ } else {
+ t.fCount++;
+ }
+ }
+
+ for (Iterator iter = h.keySet().iterator(); iter.hasNext();){
+ System.out.println(h.get(iter.next()));
+ }
+ }
+ /**
+ * Removes the entry from the entry queue.
+ * Calls <code>privateRemoveEntry</code> with the external functionality enabled.
+ *
+ * @param shuffle indicates whether we are just shuffling the queue
+ * (i.e., the entry table is left alone).
+ */
+ protected void privateRemoveEntry (LRUCacheEntry entry, boolean shuffle) {
+ privateRemoveEntry(entry, shuffle, true);
+ }
+ /**
+ * Removes the entry from the entry queue. If <i>external</i> is true, the entry is removed
+ * without checking if it can be removed. It is assumed that the client has already closed
+ * the element it is trying to remove (or will close it promptly).
+ *
+ * If <i>external</i> is false, and the entry could not be closed, it is not removed and the
+ * pointers are not changed.
+ *
+ * @param shuffle indicates whether we are just shuffling the queue
+ * (i.e., the entry table is left alone).
+ */
+ protected void privateRemoveEntry(LRUCacheEntry entry, boolean shuffle, boolean external) {
+
+ if (!shuffle) {
+ if (external) {
+ fEntryTable.remove(entry._fKey);
+ fCurrentSpace -= entry._fSpace;
+ privateNotifyDeletionFromCache(entry);
+ } else {
+ if (!close(entry)) return;
+ // buffer close will recursively call #privateRemoveEntry with external==true
+ // thus entry will already be removed if reaching this point.
+ if (fEntryTable.get(entry._fKey) == null){
+ return;
+ } else {
+ // basic removal
+ fEntryTable.remove(entry._fKey);
+ fCurrentSpace -= entry._fSpace;
+ privateNotifyDeletionFromCache(entry);
+ }
+ }
+ }
+ LRUCacheEntry previous = entry._fPrevious;
+ LRUCacheEntry next = entry._fNext;
+
+ /* if this was the first entry */
+ if (previous == null) {
+ fEntryQueue = next;
+ } else {
+ previous._fNext = next;
+ }
+ /* if this was the last entry */
+ if (next == null) {
+ fEntryQueueTail = previous;
+ } else {
+ next._fPrevious = previous;
+ }
+ }
+ /**
+ * Sets the value in the cache at the given key. Returns the value.
+ *
+ * @param key Key of object to add.
+ * @param value Value of object to add.
+ * @return added value.
+ */
+ public Object put(Object key, Object value) {
+ /* attempt to rid ourselves of the overflow, if there is any */
+ if (fOverflow > 0)
+ shrink();
+
+ /* Check whether there's an entry in the cache */
+ int newSpace = spaceFor (key, value);
+ LRUCacheEntry entry = (LRUCacheEntry) fEntryTable.get (key);
+
+ if (entry != null) {
+
+ /**
+ * Replace the entry in the cache if it would not overflow
+ * the cache. Otherwise flush the entry and re-add it so as
+ * to keep cache within budget
+ */
+ int oldSpace = entry._fSpace;
+ int newTotal = fCurrentSpace - oldSpace + newSpace;
+ if (newTotal <= fSpaceLimit) {
+ updateTimestamp (entry);
+ entry._fValue = value;
+ entry._fSpace = newSpace;
+ fCurrentSpace = newTotal;
+ fOverflow = 0;
+ return value;
+ } else {
+ privateRemoveEntry (entry, false, false);
+ }
+ }
+
+ // attempt to make new space
+ makeSpace(newSpace);
+
+ // add without worring about space, it will
+ // be handled later in a makeSpace call
+ privateAdd (key, value, newSpace);
+
+ return value;
+ }
+ /**
+ * Removes and returns the value in the cache for the given key.
+ * If the key is not in the cache, returns null.
+ *
+ * @param key Key of object to remove from cache.
+ * @return Value removed from cache.
+ */
+ public Object remove(Object key) {
+ return removeKey(key);
+ }
+ /**
+ * Sets the load factor for the cache. The load factor determines how
+ * much space is reclaimed when the cache exceeds its space limit.
+ * @param newLoadFactor double
+ * @throws IllegalArgumentException when the new load factor is not in (0.0, 1.0]
+ */
+ public void setLoadFactor(double newLoadFactor) throws IllegalArgumentException {
+ if(newLoadFactor <= 1.0 && newLoadFactor > 0.0)
+ fLoadFactor = newLoadFactor;
+ else
+ throw new IllegalArgumentException("cache.invalidLoadFactor"); //$NON-NLS-1$
+ }
+ /**
+ * Sets the maximum amount of space that the cache can store
+ *
+ * @param limit Number of units of cache space
+ */
+ public void setSpaceLimit(int limit) {
+ if (limit < fSpaceLimit) {
+ makeSpace(fSpaceLimit - limit);
+ }
+ fSpaceLimit = limit;
+ }
+ /**
+ * Attempts to shrink the cache if it has overflown.
+ * Returns true if the cache shrinks to less than or equal to <code>fSpaceLimit</code>.
+ */
+ public boolean shrink() {
+ if (fOverflow > 0)
+ return makeSpace(0);
+ return true;
+ }
+ /**
+ * Returns a String that represents the value of this object. This method
+ * is for debugging purposes only.
+ */
+ public String toString() {
+ return
+ "OverflowingLRUCache " + this.fillingRatio() + "% full\n" + //$NON-NLS-1$ //$NON-NLS-2$
+ this.toStringContents();
+ }
+ /**
+ * Updates the timestamp for the given entry, ensuring that the queue is
+ * kept in correct order. The entry must exist.
+ *
+ * <p>This method will do nothing if timestamps have been disabled.
+ */
+ protected void updateTimestamp(LRUCacheEntry entry) {
+ if (fTimestampsOn) {
+ entry._fTimestamp = fTimestampCounter++;
+ if (fEntryQueue != entry) {
+ this.privateRemoveEntry(entry, true);
+ this.privateAddEntry(entry, true);
+ }
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog b/core/org.eclipse.cdt.core/parser/ChangeLog
index c4c0e1ac11..425aa97f23 100644
--- a/core/org.eclipse.cdt.core/parser/ChangeLog
+++ b/core/org.eclipse.cdt.core/parser/ChangeLog
@@ -1,4 +1,7 @@
2003-06-12 John Camelon
+ Get rest of JUnit tests working, will merge back to HEAD branch.
+
+2003-06-12 John Camelon
Introduction of ASTFactory strategy, some restructuring of packages and interfaces.
2003-06-10 John Camelon
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTASMDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTASMDefinition.java
index f22adb98e3..14c2a22c90 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTASMDefinition.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTASMDefinition.java
@@ -14,7 +14,7 @@ package org.eclipse.cdt.core.parser.ast;
* @author jcamelon
*
*/
-public interface IASTASMDefinition extends IASTOffsetableElement {
+public interface IASTASMDefinition extends IASTOffsetableElement, IASTDeclaration {
public String getBody();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java
index 69766cb12a..0411c20ed6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java
@@ -27,6 +27,12 @@ public interface IASTFactory {
TokenDuple duple)
throws Backtrack;
+ public IASTUsingDeclaration createUsingDeclaration(
+ IASTScope scope,
+ boolean isTypeName,
+ TokenDuple name );
+
+
public IASTASMDefinition createASMDefinition(
IASTScope scope,
String assembly,
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTLinkageSpecification.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTLinkageSpecification.java
index 17d391eee6..72eb090ffa 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTLinkageSpecification.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTLinkageSpecification.java
@@ -14,7 +14,7 @@ package org.eclipse.cdt.core.parser.ast;
* @author jcamelon
*
*/
-public interface IASTLinkageSpecification extends IASTScope {
+public interface IASTLinkageSpecification extends IASTScope, IASTDeclaration {
public String getLinkageString();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTNamespaceDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTNamespaceDefinition.java
index dc1513c1ad..953e22d205 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTNamespaceDefinition.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTNamespaceDefinition.java
@@ -14,6 +14,6 @@ package org.eclipse.cdt.core.parser.ast;
* @author jcamelon
*
*/
-public interface IASTNamespaceDefinition extends IASTOffsetableNamedElement, IASTScope {
+public interface IASTNamespaceDefinition extends IASTOffsetableNamedElement, IASTScope, IASTDeclaration {
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTUsingDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTUsingDeclaration.java
index 25471a9936..c33146a44a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTUsingDeclaration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTUsingDeclaration.java
@@ -14,7 +14,9 @@ package org.eclipse.cdt.core.parser.ast;
* @author jcamelon
*
*/
-public interface IASTUsingDeclaration {
+public interface IASTUsingDeclaration extends IASTDeclaration {
-
+ public boolean isTypename();
+ public String usingTypeName();
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTUsingDirective.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTUsingDirective.java
index ba0ca412af..afe1639e62 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTUsingDirective.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTUsingDirective.java
@@ -14,7 +14,7 @@ package org.eclipse.cdt.core.parser.ast;
* @author jcamelon
*
*/
-public interface IASTUsingDirective {
+public interface IASTUsingDirective extends IASTDeclaration {
public String getNamespaceName();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java
index 3960e7bf69..26bde9bf36 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java
@@ -24,9 +24,9 @@ import org.eclipse.cdt.core.parser.ast.IASTFactory;
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTScope;
+import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
import org.eclipse.cdt.internal.core.model.Util;
-import org.eclipse.cdt.internal.core.parser.ast.full.IASTFScope;
/**
* This is our first implementation of the IParser interface, serving as a parser for
@@ -312,10 +312,11 @@ c, quickParse);
consume( Token.t_typename );
}
+ TokenDuple name = null;
if( LT(1) == Token.tIDENTIFIER || LT(1) == Token.tCOLONCOLON )
{
// optional :: and nested classes handled in name
- name();
+ name = name();
try{ callback.usingDeclarationMapping( usingDeclaration, typeName ); } catch( Exception e ) {}
}
else
@@ -327,7 +328,11 @@ c, quickParse);
if( LT(1) == Token.tSEMI )
{
consume( Token.tSEMI );
+
try{ callback.usingDeclarationEnd( usingDeclaration );} catch( Exception e ) {}
+
+ IASTUsingDeclaration declaration = astFactory.createUsingDeclaration( scope, typeName, name );
+ requestor.acceptUsingDeclaration(declaration);
}
else
{
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTASMDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTASMDefinition.java
index 9229291431..05aac1cdec 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTASMDefinition.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTASMDefinition.java
@@ -10,6 +10,7 @@
***********************************************************************/
package org.eclipse.cdt.internal.core.parser.ast.full;
+import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
@@ -68,4 +69,10 @@ public class ASTASMDefinition implements IASTFASMDefinition {
public ISymbol getSymbol() {
return symbol;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTDeclaration#getOwnerScope()
+ */
+ public IASTScope getOwnerScope() {
+ return (IPSTContainerExtension)symbol.getContainingSymbol().getASTNode();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTLinkageSpecification.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTLinkageSpecification.java
index 628c7b1e0e..966c440a3f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTLinkageSpecification.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTLinkageSpecification.java
@@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.parser.ast.full;
import java.util.Iterator;
+import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
@@ -57,4 +58,11 @@ public class ASTLinkageSpecification implements IASTFLinkageSpecification {
return symbol;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTDeclaration#getOwnerScope()
+ */
+ public IASTScope getOwnerScope() {
+ return (IPSTContainerExtension)symbol.getContainingSymbol().getASTNode();
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTNamespaceDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTNamespaceDefinition.java
index eb3c03d9d7..808a32e70f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTNamespaceDefinition.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTNamespaceDefinition.java
@@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.parser.ast.full;
import java.util.Iterator;
+import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
@@ -100,5 +101,12 @@ public class ASTNamespaceDefinition implements IASTFNamespaceDefinition {
*/
public IContainerSymbol getContainerSymbol() {
return symbol;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTDeclaration#getOwnerScope()
+ */
+ public IASTScope getOwnerScope() {
+ return (IPSTContainerExtension)symbol.getContainingSymbol().getASTNode();
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ASTUsingDirective.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTUsingDirective.java
index 0b51b2799f..d376106c11 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ASTUsingDirective.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTUsingDirective.java
@@ -8,8 +8,9 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
***********************************************************************/
-package org.eclipse.cdt.internal.core.parser;
+package org.eclipse.cdt.internal.core.parser.ast.full;
+import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
/**
@@ -18,7 +19,7 @@ import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
*/
public class ASTUsingDirective implements IASTUsingDirective {
- private final String namespaceName;
+ private final String namespaceName;
public ASTUsingDirective( String namespace )
{
@@ -28,8 +29,14 @@ public class ASTUsingDirective implements IASTUsingDirective {
* @see org.eclipse.cdt.core.parser.ast.IASTUsingDirective#getNamespaceName()
*/
public String getNamespaceName() {
- // TODO Auto-generated method stub
return namespaceName;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTDeclaration#getOwnerScope()
+ */
+ public IASTScope getOwnerScope() {
+ return null; //TODO
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java
index e382724d92..041e653646 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java
@@ -18,8 +18,8 @@ import org.eclipse.cdt.core.parser.ast.IASTFactory;
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTScope;
+import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
-import org.eclipse.cdt.internal.core.parser.ASTUsingDirective;
import org.eclipse.cdt.internal.core.parser.Token;
import org.eclipse.cdt.internal.core.parser.TokenDuple;
import org.eclipse.cdt.internal.core.parser.Parser.Backtrack;
@@ -137,4 +137,12 @@ public class FullParseASTFactory extends BaseASTFactory implements IASTFactory {
throw new Backtrack();
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope, boolean, org.eclipse.cdt.internal.core.parser.TokenDuple)
+ */
+ public IASTUsingDeclaration createUsingDeclaration(IASTScope scope, boolean isTypeName, TokenDuple name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTContainerExtension.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTContainerExtension.java
index 446eb013ab..71c5fc202e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTContainerExtension.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTContainerExtension.java
@@ -10,13 +10,14 @@
***********************************************************************/
package org.eclipse.cdt.internal.core.parser.ast.full;
+import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
/**
* @author jcamelon
*
*/
-public interface IPSTContainerExtension extends IPSTSymbolExtension {
+public interface IPSTContainerExtension extends IPSTSymbolExtension, IASTScope {
public IContainerSymbol getContainerSymbol();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTUsingDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTUsingDeclaration.java
new file mode 100644
index 0000000000..f08ff71205
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTUsingDeclaration.java
@@ -0,0 +1,47 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v0.5
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v05.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.quick;
+
+import org.eclipse.cdt.core.parser.ast.IASTScope;
+import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTUsingDeclaration
+ extends ASTDeclaration
+ implements IASTUsingDeclaration {
+
+ private final boolean isTypename;
+ private final String mappingName;
+
+ public ASTUsingDeclaration( IASTScope scope, boolean isTypeName, String mappingName )
+ {
+ super( scope );
+ isTypename = isTypeName;
+ this.mappingName = mappingName;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration#isTypename()
+ */
+ public boolean isTypename() {
+ return isTypename;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration#usingTypeName()
+ */
+ public String usingTypeName() {
+ return mappingName;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java
index 31407a9955..da2813bbc7 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java
@@ -16,6 +16,7 @@ import org.eclipse.cdt.core.parser.ast.IASTFactory;
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTScope;
+import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
import org.eclipse.cdt.internal.core.parser.TokenDuple;
import org.eclipse.cdt.internal.core.parser.Parser.Backtrack;
@@ -68,4 +69,11 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
return new ASTLinkageSpecification( scope, spec );
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope, boolean, org.eclipse.cdt.internal.core.parser.TokenDuple)
+ */
+ public IASTUsingDeclaration createUsingDeclaration(IASTScope scope, boolean isTypeName, TokenDuple name) {
+ return new ASTUsingDeclaration( scope, isTypeName, name.toString() );
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/BuildInfoFactory.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/BuildInfoFactory.java
index eb31bceeca..0697ccf3c9 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/BuildInfoFactory.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/BuildInfoFactory.java
@@ -6,6 +6,7 @@ package org.eclipse.cdt.core;
*/
+import org.eclipse.cdt.core.resources.IBuildInfo;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -16,8 +17,6 @@ import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.cdt.core.resources.IBuildInfo;
-
public class BuildInfoFactory {
public static final String LOCATION = "buildLocation";
public static final String FULL_ARGUMENTS = "buildFullArguments";
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/FileStorage.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/FileStorage.java
index 7858b1b309..dade570ff7 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/FileStorage.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/FileStorage.java
@@ -5,18 +5,17 @@ package org.eclipse.cdt.core.resources;
* All Rights Reserved.
*/
-import java.io.InputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.InputStream;
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.cdt.core.CCorePlugin;
/**
*
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/MakeUtil.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/MakeUtil.java
index fa682d1891..318a9ee613 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/MakeUtil.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/MakeUtil.java
@@ -9,6 +9,7 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
+
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/parser/generated/CPPParser.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/parser/generated/CPPParser.java
index e9d42f02f6..7b48d5d85d 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/parser/generated/CPPParser.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/parser/generated/CPPParser.java
@@ -1,10 +1,8 @@
/* Generated By:JavaCC: Do not edit this line. CPPParser.java */
package org.eclipse.cdt.internal.parser.generated;
-import org.eclipse.cdt.internal.parser.ParserCallback;
-
-// redirect to a fixed class
import org.eclipse.cdt.internal.parser.ASCII_CharStream;
+import org.eclipse.cdt.internal.parser.ParserCallback;
public final class CPPParser implements CPPParserConstants {
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/parser/generated/CPPParserTokenManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/parser/generated/CPPParserTokenManager.java
index f22c7d204d..fa9927759f 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/parser/generated/CPPParserTokenManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/parser/generated/CPPParserTokenManager.java
@@ -1,8 +1,6 @@
/* Generated By:JavaCC: Do not edit this line. CPPParserTokenManager.java */
package org.eclipse.cdt.internal.parser.generated;
-import org.eclipse.cdt.internal.parser.ParserCallback;
-// redirect to a fixed class
import org.eclipse.cdt.internal.parser.ASCII_CharStream;
public class CPPParserTokenManager implements CPPParserConstants
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java
index 31cc77f959..65502f4c2d 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java
@@ -8,8 +8,8 @@ package org.eclipse.cdt.utils.elf;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-
import java.util.Comparator;
+
import org.eclipse.cdt.utils.Addr2line;
import org.eclipse.cdt.utils.CPPFilt;
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/pty/PTYInputStream.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/pty/PTYInputStream.java
index fa6a29a491..e7c642d88c 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/pty/PTYInputStream.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/pty/PTYInputStream.java
@@ -5,8 +5,8 @@ package org.eclipse.cdt.utils.pty;
* All Rights Reserved.
*/
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
class PTYInputStream extends InputStream {
private int fd;
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/pty/PTYOutputStream.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/pty/PTYOutputStream.java
index 31ba323524..d85473de5a 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/pty/PTYOutputStream.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/pty/PTYOutputStream.java
@@ -5,8 +5,8 @@ package org.eclipse.cdt.utils.pty;
* All Rights Reserved.
*/
-import java.io.OutputStream;
import java.io.IOException;
+import java.io.OutputStream;
public class PTYOutputStream extends OutputStream {
private int fd;
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/EnvironmentReader.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/EnvironmentReader.java
index 4606955cc7..a413f9f8a4 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/EnvironmentReader.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/EnvironmentReader.java
@@ -7,8 +7,8 @@ package org.eclipse.cdt.utils.spawner;
import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStreamReader;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.util.Properties;
import java.util.Vector;
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java
index 102eb9063b..ea08b24fab 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java
@@ -5,8 +5,8 @@ package org.eclipse.cdt.utils.spawner;
* All Rights Reserved.
*/
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
class SpawnerInputStream extends InputStream {
private int fd;
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerOutputStream.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerOutputStream.java
index b279df57d8..f846cb126c 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerOutputStream.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerOutputStream.java
@@ -5,8 +5,8 @@ package org.eclipse.cdt.utils.spawner;
* All Rights Reserved.
*/
-import java.io.OutputStream;
import java.io.IOException;
+import java.io.OutputStream;
public class SpawnerOutputStream extends OutputStream {
private int fd;
diff --git a/core/org.eclipse.cdt.ui.tests/ChangeLog b/core/org.eclipse.cdt.ui.tests/ChangeLog
index 5fec003558..0355a39c07 100644
--- a/core/org.eclipse.cdt.ui.tests/ChangeLog
+++ b/core/org.eclipse.cdt.ui.tests/ChangeLog
@@ -1,4 +1,7 @@
2003-06-12 John Camelon
+ Get rest of JUnit tests working, will merge back to HEAD branch.
+
+2003-06-12 John Camelon
Introduction of ASTFactory strategy, some restructuring of packages and interfaces.
2003-06-10 John Camelon
diff --git a/core/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/DOMTests.java b/core/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/DOMTests.java
index 1f0fffb497..f8c5fd6fc2 100644
--- a/core/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/DOMTests.java
+++ b/core/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/DOMTests.java
@@ -222,16 +222,16 @@ public class DOMTests extends BaseDOMTest {
assertEquals( second.getNamespaceName().toString(), "C" );
third = (UsingDeclaration) declarations.get(2);
- assertEquals( third.getMappedName().toString(), "B::f" );
+ assertEquals( third.getMappedName(), "B::f" );
assertFalse( third.isTypename() );
fourth = (UsingDeclaration) declarations.get(3);
- assertEquals( fourth.getMappedName().toString(), "::f" );
+ assertEquals( fourth.getMappedName(), "::f" );
assertFalse( fourth.isTypename() );
fifth = (UsingDeclaration) declarations.get(4);
assertTrue( fifth.isTypename() );
- assertEquals( fifth.getMappedName().toString(), "crap::de::crap" );
+ assertEquals( fifth.getMappedName(), "crap::de::crap" );
}
public void testDeclSpecifier() throws Exception

Back to the top