From 4570a0f0f150fd8a990419dba0a6912922f483c2 Mon Sep 17 00:00:00 2001 From: John Camelon Date: Thu, 12 Jun 2003 20:48:27 +0000 Subject: Get rest of JUnit tests working, will merge back to HEAD branch. --- .../eclipse/cdt/internal/core/dom/DOMBuilder.java | 32 +- .../cdt/internal/core/dom/UsingDeclaration.java | 6 +- .../eclipse/cdt/internal/core/index/CTagsCmd.java | 2 +- .../cdt/internal/core/index/CTagsEntry.java | 2 +- .../cdt/internal/core/index/CTagsHeader.java | 2 +- .../cdt/internal/core/index/CTagsRunner.java | 3 +- .../cdt/internal/core/index/RequestList.java | 6 +- .../eclipse/cdt/core/model/CModelException.java | 3 +- .../org/eclipse/cdt/core/model/ICElement.java | 2 +- .../eclipse/cdt/internal/core/model/Buffer.java | 4 +- .../cdt/internal/core/model/CElementInfo.java | 5 +- .../cdt/internal/core/model/CModelOperation.java | 25 +- .../core/model/CommitWorkingCopyOperation.java | 2 +- .../core/model/CreateElementInTUOperation.java | 2 +- .../internal/core/model/CreateFieldOperation.java | 2 +- .../model/CreateFunctionDeclarationOperation.java | 4 +- .../core/model/CreateIncludeOperation.java | 4 +- .../internal/core/model/CreateMemberOperation.java | 2 +- .../internal/core/model/CreateMethodOperation.java | 2 +- .../cdt/internal/core/model/IBufferFactory.java | 2 +- .../cdt/internal/core/model/MultiOperation.java | 2 +- .../model/RenameResourceElementsOperation.java | 2 +- .../eclipse/cdt/internal/core/model/Structure.java | 4 +- .../cdt/internal/core/model/WorkingCopy.java | 2 +- .../internal/core/util/OverflowingLRUCache.java | 856 ++++++++++----------- core/org.eclipse.cdt.core/parser/ChangeLog | 3 + .../cdt/core/parser/ast/IASTASMDefinition.java | 2 +- .../eclipse/cdt/core/parser/ast/IASTFactory.java | 6 + .../core/parser/ast/IASTLinkageSpecification.java | 2 +- .../core/parser/ast/IASTNamespaceDefinition.java | 2 +- .../cdt/core/parser/ast/IASTUsingDeclaration.java | 6 +- .../cdt/core/parser/ast/IASTUsingDirective.java | 2 +- .../internal/core/parser/ASTUsingDirective.java | 35 - .../eclipse/cdt/internal/core/parser/Parser.java | 9 +- .../core/parser/ast/full/ASTASMDefinition.java | 7 + .../parser/ast/full/ASTLinkageSpecification.java | 8 + .../parser/ast/full/ASTNamespaceDefinition.java | 8 + .../core/parser/ast/full/ASTUsingDirective.java | 42 + .../core/parser/ast/full/FullParseASTFactory.java | 10 +- .../parser/ast/full/IPSTContainerExtension.java | 3 +- .../core/parser/ast/quick/ASTUsingDeclaration.java | 47 ++ .../parser/ast/quick/QuickParseASTFactory.java | 8 + .../src/org/eclipse/cdt/core/BuildInfoFactory.java | 3 +- .../eclipse/cdt/core/resources/FileStorage.java | 9 +- .../org/eclipse/cdt/core/resources/MakeUtil.java | 1 + .../cdt/internal/parser/generated/CPPParser.java | 4 +- .../parser/generated/CPPParserTokenManager.java | 2 - .../utils/org/eclipse/cdt/utils/elf/Elf.java | 2 +- .../org/eclipse/cdt/utils/pty/PTYInputStream.java | 2 +- .../org/eclipse/cdt/utils/pty/PTYOutputStream.java | 2 +- .../cdt/utils/spawner/EnvironmentReader.java | 2 +- .../cdt/utils/spawner/SpawnerInputStream.java | 2 +- .../cdt/utils/spawner/SpawnerOutputStream.java | 2 +- core/org.eclipse.cdt.ui.tests/ChangeLog | 3 + .../eclipse/cdt/core/parser/tests/DOMTests.java | 6 +- 55 files changed, 665 insertions(+), 553 deletions(-) delete mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ASTUsingDirective.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTUsingDirective.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTUsingDeclaration.java 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 46ddd5d0422..a2d9979945c 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 7e6afb13c10..20a6a914405 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 ada44f6c884..117e338e34e 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 cc4b2a7eb06..306df3e5c97 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 1398f8bf6df..b98baa87579 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 ae1d230b12a..fcb036be7d4 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 f21eed91c3e..21006686445 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 dbe943a1445..a093bf5ce2d 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 69ddb3e375c..09742d4909c 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 1c130746acc..b8bb0fd4e46 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 42d77f538e8..3492ca5928c 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 9295f24f628..8e0ab94f2e7 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 062ae92d507..3dd9f1640ba 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 e70af712749..07cbb95c4d6 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 cae08069224..f699a9b42df 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; /** *
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 d00f25c0167..766f4bb9136 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; /** *
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 e845adc9b92..d7a17d43195 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; /** *
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 ffe3e1538b0..90be8fd9bbb 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 0704e206400..d86880bac5a 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; /** *
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 0265d5428fb..ff4b37c57de 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 IBuffer
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 4ae5aaec649..ae66505e97c 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 ICElement
.
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 6c4da177eff..be0899ad7b9 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 c20fddf8fa4..56e158b63a4 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 b87e7035ed9..ec551d5e80d 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 c479f797d83..bd999902a11 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 OverflowingLRUCache
is an LRUCache which attempts
- * to maintain a size equal or less than its fSpaceLimit
- * by removing the least recently used elements.
- *
- *
The cache will remove elements which successfully close and all - * elements which are explicitly removed. - * - *
If the cache cannot remove enough old elements to add new elements
- * it will grow beyond fSpaceLimit
. Later, it will attempt to
- * shink back to the maximum space limit.
- *
- * The method close
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.
- *
- *
The cache implicitly attempts shrinks on calls to put
and
- * setSpaceLimit
. Explicitly calling the shrink
method
- * will also cause the cache to attempt to shrink.
- *
- *
The cache calculates the used space of all elements which implement
- * ILRUCacheable
. All other elements are assumed to be of size one.
- *
- *
Use the #peek(Object)
and #disableTimestamps()
method to
- * circumvent the timestamp feature of the cache. This feature is intended to be used
- * only when the #close(LRUCacheEntry)
method causes changes to the cache.
- * For example, if a parent closes its children when #close(LRUCacheEntry) is called,
- * it should be careful not to change the LRU linked list. It can be sure it is not causing
- * problems by calling #peek(Object)
instead of #get(Object)
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.
- *
- *
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 privateRemoveEntry
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 external 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 external 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 fSpaceLimit
.
- */
- 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.
- *
- *
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 OverflowingLRUCache
is an LRUCache which attempts
+ * to maintain a size equal or less than its fSpaceLimit
+ * by removing the least recently used elements.
+ *
+ *
The cache will remove elements which successfully close and all + * elements which are explicitly removed. + * + *
If the cache cannot remove enough old elements to add new elements
+ * it will grow beyond fSpaceLimit
. Later, it will attempt to
+ * shink back to the maximum space limit.
+ *
+ * The method close
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.
+ *
+ *
The cache implicitly attempts shrinks on calls to put
and
+ * setSpaceLimit
. Explicitly calling the shrink
method
+ * will also cause the cache to attempt to shrink.
+ *
+ *
The cache calculates the used space of all elements which implement
+ * ILRUCacheable
. All other elements are assumed to be of size one.
+ *
+ *
Use the #peek(Object)
and #disableTimestamps()
method to
+ * circumvent the timestamp feature of the cache. This feature is intended to be used
+ * only when the #close(LRUCacheEntry)
method causes changes to the cache.
+ * For example, if a parent closes its children when #close(LRUCacheEntry) is called,
+ * it should be careful not to change the LRU linked list. It can be sure it is not causing
+ * problems by calling #peek(Object)
instead of #get(Object)
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.
+ *
+ *
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 privateRemoveEntry
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 external 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 external 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 fSpaceLimit
.
+ */
+ 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.
+ *
+ *
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 c4c0e1ac11e..425aa97f237 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog +++ b/core/org.eclipse.cdt.core/parser/ChangeLog @@ -1,3 +1,6 @@ +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. 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 f22adb98e34..14c2a22c90b 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 69766cb12a8..0411c20ed63 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 17d391eee60..72eb090ffa2 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 dc1513c1ad5..953e22d2053 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 25471a9936f..c33146a44ab 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 ba0ca412af9..afe1639e623 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/ASTUsingDirective.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ASTUsingDirective.java deleted file mode 100644 index 0b51b2799f3..00000000000 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ASTUsingDirective.java +++ /dev/null @@ -1,35 +0,0 @@ -/********************************************************************** - * 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; - -import org.eclipse.cdt.core.parser.ast.IASTUsingDirective; - -/** - * @author jcamelon - * - */ -public class ASTUsingDirective implements IASTUsingDirective { - - private final String namespaceName; - - public ASTUsingDirective( String namespace ) - { - namespaceName = namespace; - } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.parser.ast.IASTUsingDirective#getNamespaceName() - */ - public String getNamespaceName() { - // TODO Auto-generated method stub - return namespaceName; - } - -} 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 3960e7bf699..26bde9bf361 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 9229291431d..05aac1cdec9 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 628c7b1e0e5..966c440a3fa 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 eb3c03d9d79..808a32e70f2 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/ast/full/ASTUsingDirective.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTUsingDirective.java new file mode 100644 index 00000000000..d376106c115 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTUsingDirective.java @@ -0,0 +1,42 @@ +/********************************************************************** + * 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.full; + +import org.eclipse.cdt.core.parser.ast.IASTScope; +import org.eclipse.cdt.core.parser.ast.IASTUsingDirective; + +/** + * @author jcamelon + * + */ +public class ASTUsingDirective implements IASTUsingDirective { + + private final String namespaceName; + + public ASTUsingDirective( String namespace ) + { + namespaceName = namespace; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.IASTUsingDirective#getNamespaceName() + */ + public String getNamespaceName() { + 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 e382724d925..041e6536463 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 446eb013ab7..71c5fc202e9 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 00000000000..f08ff71205b --- /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 31407a9955e..da2813bbc7c 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 eb31bceeca9..0697ccf3c93 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 7858b1b309d..dade570ff72 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 fa682d18917..318a9ee6139 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 e9d42f02f6b..7b48d5d85d9 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 f22c7d204de..fa9927759f6 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 31cc77f959c..65502f4c2d7 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 fa6a29a4918..e7c642d88cd 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 31ba3235246..d85473de5a1 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 4606955cc7c..a413f9f8a48 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 102eb9063bc..ea08b24fab0 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 b279df57d8f..f846cb126c5 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 5fec003558b..0355a39c074 100644 --- a/core/org.eclipse.cdt.ui.tests/ChangeLog +++ b/core/org.eclipse.cdt.ui.tests/ChangeLog @@ -1,3 +1,6 @@ +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. 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 1f0fffb4971..f8c5fd6fc2d 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 -- cgit v1.2.3