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

Merge remote-tracking branch 'cdt/master' into sd90

This commit is contained in:
Andrew Gvozdev 2012-03-18 07:34:11 -04:00
commit eeee4f767a
15 changed files with 197 additions and 198 deletions

View file

@ -248,7 +248,7 @@
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
class="org.eclipse.cdt.internal.autotools.ui.preferences.AutotoolsPreferencePage"
id="org.eclipse.cdt.autotools.ui.preferences1"
name="%PreferencAutotools.name">
name="%PreferenceAutotools.name">
</page>
<page
category="org.eclipse.cdt.autotools.ui.preferences1"

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Symbian - Initial implementation
* Symbian - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.internal.pdom.tests;
@ -33,7 +33,6 @@ import org.eclipse.core.runtime.NullProgressMonitor;
* See bugzilla
*/
public class FilesOnReindexTests extends PDOMTestBase {
protected ICProject project;
protected IIndex pdom;
@ -72,7 +71,7 @@ public class FilesOnReindexTests extends PDOMTestBase {
void performAssertions(IFile file) throws CoreException {
IIndex index = CCorePlugin.getIndexManager().getIndex(project);
assertNotNull(index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)));
assertTrue(index.getFiles(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file)).length != 0);
IBinding[] bs = index.findBindings(Pattern.compile("C"), true, IndexFilter.ALL, new NullProgressMonitor());
assertEquals(1, bs.length);

View file

@ -108,14 +108,14 @@ Export-Package: org.eclipse.cdt.core,
org.eclipse.cdt.utils.spawner,
org.eclipse.cdt.utils.xcoff,
org.eclipse.cdt.utils.xcoff.parser
Require-Bundle: org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.7.0,4.0.0)",
org.eclipse.core.contenttype;bundle-version="[3.3.0,4.0.0)",
org.eclipse.text;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)",
Require-Bundle: org.eclipse.core.contenttype;bundle-version="[3.3.0,4.0.0)",
org.eclipse.core.filebuffers;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.filesystem;bundle-version="[1.1.0,2.0.0)",
org.eclipse.ltk.core.refactoring;bundle-version="3.4.0"
org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.7.0,4.0.0)",
org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)",
org.eclipse.ltk.core.refactoring;bundle-version="3.4.0",
org.eclipse.text;bundle-version="[3.2.0,4.0.0)",
com.ibm.icu;bundle-version="4.4.2"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.ibm.icu.text

View file

@ -447,14 +447,14 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
Map<ICElement, CElementInfo> newElements, IResource underlyingResource) throws CModelException {
TranslationUnitInfo unitInfo = (TranslationUnitInfo) info;
// generate structure
// Generate structure
this.parse(newElements, pm);
// /////////////////////////////////////////////////////////////
if (isWorkingCopy()) {
ITranslationUnit original = ((IWorkingCopy)this).getOriginalElement();
// might be IResource.NULL_STAMP if original does not exist
// Might be IResource.NULL_STAMP if original does not exist
IResource r = original.getResource();
if (r != null && r instanceof IFile) {
unitInfo.fTimestamp = ((IFile) r).getModificationStamp();
@ -499,7 +499,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
} else {
workingCopy= new WorkingCopy(getParent(), getLocationURI(), getContentTypeId(), factory);
}
// open the working copy now to ensure contents are that of the current state of this element
// Open the working copy now to ensure contents are that of the current state of this element
workingCopy.open(monitor);
return workingCopy;
}
@ -541,7 +541,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
return null;
}
// create a new info and make it the current info
// Create a new info and make it the current info
// (this will remove the info and its children just before storing the new infos)
CModelManager manager = CModelManager.getDefault();
boolean hadTemporaryCache = manager.hasTemporaryCache();
@ -555,7 +555,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
Map<ICElement, CElementInfo> newElements = manager.getTemporaryCache();
openWhenClosed(info, monitor);
if (newElements.get(this) == null) {
// close any buffer that was opened for the new elements
// Close any buffer that was opened for the new elements
Iterator<ICElement> iterator = newElements.keySet().iterator();
while (iterator.hasNext()) {
ICElement element = iterator.next();
@ -593,13 +593,13 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
@Override
protected IBuffer openBuffer(IProgressMonitor pm) throws CModelException {
// create buffer - translation units only use default buffer factory
// Create buffer - translation units only use default buffer factory
BufferManager bufManager = getBufferManager();
IBuffer buffer = getBufferFactory().createBuffer(this);
if (buffer == null)
return null;
// set the buffer source
// Set the buffer source
if (buffer.getCharacters() == null) {
IResource resource = this.getResource();
if (resource != null && resource.getType() == IResource.FILE) {
@ -620,10 +620,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
}
}
// add buffer to buffer cache
// Add buffer to buffer cache
bufManager.addBuffer(buffer);
// listen to buffer changes
// Listen to buffer changes
buffer.addBufferChangedListener(this);
return buffer;
@ -889,6 +889,7 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
}
private static final int[] CTX_LINKAGES= { ILinkage.CPP_LINKAGE_ID, ILinkage.C_LINKAGE_ID };
public IIndexFile[] getContextToHeader(IIndex index, int style) {
if (index != null && (style & AST_CONFIGURE_USING_SOURCE_CONTEXT) != 0) {
try {

View file

@ -1671,9 +1671,8 @@ public class CPPSemantics {
dtor.accept(visitor);
}
break;
case eEnumeration:
case eClassType:
case eTemplateDeclaration:
default:
break;
}
}
@ -1696,7 +1695,7 @@ public class CPPSemantics {
IASTFunctionDeclarator declarator = functionDef.getDeclarator();
if (!((ICPPASTDeclSpecifier) declSpec).isFriend()) {
// check the function itself
// Check the function itself
IASTName declName = ASTQueries.findInnermostDeclarator(declarator).getName();
ASTInternal.addName(scope, declName);
}
@ -1710,21 +1709,22 @@ public class CPPSemantics {
declSpec.accept(visitor);
declarator.accept(visitor);
break;
case eClassType:
case eTemplateDeclaration:
case eEnumeration:
default:
break;
}
}
}
/**
* Perform lookup in nominated namespaces that appear in the given scope. For unqualified lookups the method assumes
* that transitive directives have been stored in the lookup-data. For qualified lookups the transitive directives
* are considered if the lookup of the original directive returns empty.
* Perform lookup in nominated namespaces that appear in the given scope. For unqualified
* lookups the method assumes that transitive directives have been stored in the lookup-data.
* For qualified lookups the transitive directives are considered if the lookup of the original
* directive returns empty.
* @param fileSet
*/
private static void lookupInNominated(LookupData data, IIndexFileSet fileSet, ICPPNamespaceScope scope) throws DOMException {
private static void lookupInNominated(LookupData data, IIndexFileSet fileSet,
ICPPNamespaceScope scope) throws DOMException {
List<ICPPNamespaceScope> allNominated= data.usingDirectives.remove(scope);
while (allNominated != null) {
for (ICPPNamespaceScope nominated : allNominated) {
@ -1740,9 +1740,9 @@ public class CPPSemantics {
found = true;
}
// in the qualified lookup we have to nominate the transitive directives only when
// the lookup did not succeed. In the qualified case this is done earlier, when the directive
// is encountered.
// In the qualified lookup we have to nominate the transitive directives only when
// the lookup did not succeed. In the qualified case this is done earlier, when
// the directive is encountered.
if (!found && data.qualified() && !data.contentAssist) {
if (data.tu != null) {
data.tu.handleAdditionalDirectives(nominated);
@ -1753,7 +1753,7 @@ public class CPPSemantics {
}
}
}
// retry with transitive directives that may have been nominated in a qualified lookup
// Retry with transitive directives that may have been nominated in a qualified lookup
allNominated= data.usingDirectives.remove(scope);
}
}
@ -1778,11 +1778,11 @@ public class CPPSemantics {
return null;
}
// bug 238180
// Bug 238180
if (candidate instanceof ICPPClassTemplatePartialSpecialization)
return null;
// specialization is selected during instantiation
// Specialization is selected during instantiation
if (candidate instanceof ICPPTemplateInstance)
candidate= ((ICPPTemplateInstance) candidate).getSpecializedBinding();
@ -1829,7 +1829,7 @@ public class CPPSemantics {
int pointOfDecl= -1;
if (obj instanceof ICPPInternalBinding) {
ICPPInternalBinding cpp = (ICPPInternalBinding) obj;
// for bindings in global or namespace scope we don't know whether there is a
// For bindings in global or namespace scope we don't know whether there is a
// previous declaration in one of the skipped header files. For bindings that
// are likely to be redeclared we need to assume that there is a declaration
// in one of the headers.
@ -1865,7 +1865,8 @@ public class CPPSemantics {
if (pointOfDecl < 0 && nd != null) {
ASTNodeProperty prop = nd.getPropertyInParent();
if (prop == IASTDeclarator.DECLARATOR_NAME || nd instanceof IASTDeclarator) {
// point of declaration for a name is immediately after its complete declarator and before its initializer
// Point of declaration for a name is immediately after its complete declarator
// and before its initializer.
IASTDeclarator dtor = (IASTDeclarator)((nd instanceof IASTDeclarator) ? nd : nd.getParent());
while (dtor.getParent() instanceof IASTDeclarator)
dtor = (IASTDeclarator) dtor.getParent();
@ -1875,7 +1876,8 @@ public class CPPSemantics {
else
pointOfDecl = ((ASTNode) dtor).getOffset() + ((ASTNode) dtor).getLength();
} else if (prop == IASTEnumerator.ENUMERATOR_NAME) {
// point of declaration for an enumerator is immediately after it enumerator-definition
// Point of declaration for an enumerator is immediately after it
// enumerator-definition
IASTEnumerator enumtor = (IASTEnumerator) nd.getParent();
if (enumtor.getValue() != null) {
ASTNode exp = (ASTNode) enumtor.getValue();
@ -1906,7 +1908,7 @@ public class CPPSemantics {
} else if (cpp instanceof ICompositeType || cpp instanceof IEnumeration) {
IScope scope= cpp.getScope();
if (!(scope instanceof ICPPBlockScope) && scope instanceof ICPPNamespaceScope) {
// if this is not the definition, it may be found in a header. (bug 229571)
// If this is not the definition, it may be found in a header. (bug 229571)
if (cpp.getDefinition() == null) {
return true;
}
@ -1956,7 +1958,7 @@ public class CPPSemantics {
continue;
}
// select among those bindings that have been created without problems.
// Select among those bindings that have been created without problems.
if (temp instanceof IProblemBinding)
continue;
@ -1984,7 +1986,7 @@ public class CPPSemantics {
fns = new ObjectSet<ICPPFunction>(2);
fns.put((ICPPFunction) temp);
} else if (temp instanceof IType) {
// specializations are selected during instantiation
// Specializations are selected during instantiation
if (temp instanceof ICPPClassTemplatePartialSpecialization)
continue;
if (temp instanceof ICPPTemplateInstance) {
@ -2213,7 +2215,7 @@ public class CPPSemantics {
return -1; // function from ast
}
}
// everything is from the index
// Everything is from the index
if (!isReachableFromAst(data.tu, obj)) {
return -1; // obj not reachable
}

View file

@ -2125,7 +2125,7 @@ public class CPPVisitor extends ASTQueries {
}
IType type = expr.getExpressionType();
if (spec.getType() == IASTSimpleDeclSpecifier.t_decltype) {
switch((expr).getValueCategory()) {
switch (expr.getValueCategory()) {
case XVALUE:
type= new CPPReferenceType(type, true);
break;

View file

@ -102,7 +102,7 @@ public class CIndex implements IIndex {
public IIndexBinding[] findBindings(Pattern[] patterns, boolean isFullyQualified, IndexFilter filter,
IProgressMonitor monitor) throws CoreException {
if (SPECIALCASE_SINGLES && fFragments.length == 1) {
return fFragments[0].findBindings(patterns, isFullyQualified, filter, monitor);
return fFragments[0].findBindings(patterns, isFullyQualified, filter, monitor);
} else {
List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
ILinkage[] linkages = Linkage.getIndexerLinkages();

View file

@ -208,7 +208,7 @@ public class PDOM extends PlatformObject implements IPDOM {
* #114.0# - Partial specializations for class template specializations, bug 332884.
* - Corrected signatures for function templates, bug 335062. <<CDT 8.0>>
*
* CDT 8.1 development (versions not supported on teh 8.0.x branch)
* CDT 8.1 development (versions not supported on the 8.0.x branch)
* 120.0 - Enumerators in global index, bug 356235
* 120.1 - Specializations of using declarations, bug 357293.
* 121.0 - Multiple variants of included header file, bug 197989.
@ -469,6 +469,7 @@ public class PDOM extends PlatformObject implements IPDOM {
public int compare(long record) throws CoreException {
return 0;
}
@Override
public boolean visit(long record) throws CoreException {
PDOMFile file = PDOMFile.recreateFile(PDOM.this, record);

View file

@ -10,19 +10,17 @@
* Andrew Ferguson (Symbian) - Provide B-tree deletion routine
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.db;
import com.ibm.icu.text.MessageFormat;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import com.ibm.icu.text.MessageFormat;
/**
* @author Doug Schaefer
*
*/
public class BTree {
// Constants for internal deletion routine (see deleteImp doc)
@ -53,7 +51,7 @@ public class BTree {
* @param rootPointer offset into database of the pointer to the root node
*/
public BTree(Database db, long rootPointer, int degree, IBTreeComparator cmp) {
if(degree<2)
if (degree < 2)
throw new IllegalArgumentException(Messages.getString("BTree.IllegalDegree")); //$NON-NLS-1$
this.db = db;
@ -113,10 +111,10 @@ public class BTree {
// if this node is full (last record isn't null), split it
if (getRecord(chunk, node, MAX_RECORDS - 1) != 0) {
long median = getRecord(chunk, node, MEDIAN_RECORD);
if (median == record)
if (median == record) {
// found it, never mind
return median;
else {
} else {
// split it
// create the new node and move the larger records over
long newnode = allocateNode();
@ -161,8 +159,8 @@ public class BTree {
// binary search to find the insert point
int lower= 0;
int upper= MAX_RECORDS-1;
while (lower < upper && getRecord(chunk, node, upper-1) == 0) {
int upper= MAX_RECORDS - 1;
while (lower < upper && getRecord(chunk, node, upper - 1) == 0) {
upper--;
}
@ -171,16 +169,13 @@ public class BTree {
long checkRec= getRecord(chunk, node, middle);
if (checkRec == 0) {
upper= middle;
}
else {
} else {
int compare= cmp.compare(checkRec, record);
if (compare > 0) {
upper= middle;
}
else if (compare < 0) {
lower= middle+1;
}
else {
} else if (compare < 0) {
lower= middle + 1;
} else {
// found it, no insert, just return the record
return record;
}
@ -256,16 +251,16 @@ public class BTree {
BTNode(long node) throws CoreException {
this.node = node;
this.chunk = db.getChunk(node);
int i=0;
while(i<MAX_RECORDS && getRecord(chunk, node, i)!=0)
int i= 0;
while (i < MAX_RECORDS && getRecord(chunk, node, i) != 0)
i++;
keyCount = i;
}
private BTNode getChild(int index) throws CoreException {
if(0<=index && index<MAX_CHILDREN) {
if (0 <= index && index < MAX_CHILDREN) {
long child = BTree.this.getChild(chunk, node, index);
if(child!=0)
if (child != 0)
return new BTNode(child);
}
return null;
@ -295,38 +290,38 @@ public class BTree {
// Determine index of key in current node, or -1 if its not in this node
int keyIndexInNode = -1;
if(mode==DELMODE_NORMAL)
for(int i=0; i<node.keyCount; i++)
if(getRecord(node.chunk, node.node, i) == key) {
if (mode == DELMODE_NORMAL)
for (int i= 0; i < node.keyCount; i++)
if (getRecord(node.chunk, node.node, i) == key) {
keyIndexInNode = i;
break;
}
if(getChild(node.chunk, node.node, 0)==0) {
if (getChild(node.chunk, node.node, 0) == 0) {
/* Case 1: leaf node containing the key (by method precondition) */
if(keyIndexInNode!=-1) {
if (keyIndexInNode != -1) {
nodeContentDelete(node, keyIndexInNode, 1);
return key;
} else {
if(mode==DELMODE_DELETE_MINIMUM) {
if (mode == DELMODE_DELETE_MINIMUM) {
long subst = getRecord(node.chunk, node.node, 0);
nodeContentDelete(node, 0, 1);
return subst;
} else if(mode==DELMODE_DELETE_MAXIMUM) {
long subst = getRecord(node.chunk, node.node, node.keyCount-1);
nodeContentDelete(node, node.keyCount-1, 1);
} else if (mode == DELMODE_DELETE_MAXIMUM) {
long subst = getRecord(node.chunk, node.node, node.keyCount - 1);
nodeContentDelete(node, node.keyCount - 1, 1);
return subst;
}
throw new BTreeKeyNotFoundException(
MessageFormat.format(Messages.getString("BTree.DeletionOnAbsentKey"), //$NON-NLS-1$
new Object[]{new Long(key), new Integer(mode)}));
new Object[] { new Long(key), new Integer(mode) }));
}
} else {
if(keyIndexInNode != -1) {
if (keyIndexInNode != -1) {
/* Case 2: non-leaf node which contains the key itself */
BTNode succ = node.getChild(keyIndexInNode+1);
if(succ!=null && succ.keyCount > MIN_RECORDS) {
BTNode succ = node.getChild(keyIndexInNode + 1);
if (succ != null && succ.keyCount > MIN_RECORDS) {
/* Case 2a: Delete key by overwriting it with its successor (which occurs in a leaf node) */
long subst = deleteImp(-1, succ.node, DELMODE_DELETE_MINIMUM);
putRecord(node.chunk, node.node, keyIndexInNode, subst);
@ -334,7 +329,7 @@ public class BTree {
}
BTNode pred = node.getChild(keyIndexInNode);
if(pred!=null && pred.keyCount > MIN_RECORDS) {
if (pred != null && pred.keyCount > MIN_RECORDS) {
/* Case 2b: Delete key by overwriting it with its predecessor (which occurs in a leaf node) */
long subst = deleteImp(-1, pred.node, DELMODE_DELETE_MAXIMUM);
putRecord(node.chunk, node.node, keyIndexInNode, subst);
@ -342,7 +337,7 @@ public class BTree {
}
/* Case 2c: Merge successor and predecessor */
// assert(pred!=null && succ!=null);
// assert(pred != null && succ != null);
if (pred != null) {
mergeNodes(succ, node, keyIndexInNode, pred);
return deleteImp(key, pred.node, mode);
@ -356,8 +351,8 @@ public class BTree {
switch(mode) {
case DELMODE_NORMAL:
subtreeIndex = node.keyCount;
for(int i=0; i<node.keyCount; i++)
if(cmp.compare(getRecord(node.chunk, node.node, i), key)>0) {
for (int i= 0; i < node.keyCount; i++)
if (cmp.compare(getRecord(node.chunk, node.node, i), key)>0) {
subtreeIndex = i;
break;
}
@ -368,15 +363,15 @@ public class BTree {
}
BTNode child = node.getChild(subtreeIndex);
if(child==null) {
if (child == null) {
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.OK, Messages.getString("BTree.IntegrityError"), null)); //$NON-NLS-1$
}
if(child.keyCount > MIN_RECORDS) {
if (child.keyCount > MIN_RECORDS) {
return deleteImp(key, child.node, mode);
} else {
BTNode sibR = node.getChild(subtreeIndex+1);
if(sibR!=null && sibR.keyCount > MIN_RECORDS) {
BTNode sibR = node.getChild(subtreeIndex + 1);
if (sibR != null && sibR.keyCount > MIN_RECORDS) {
/* Case 3a (i): child will underflow upon deletion, take a key from rightSibling */
long rightKey = getRecord(node.chunk, node.node, subtreeIndex);
long leftmostRightSiblingKey = getRecord(sibR.chunk, sibR.node, 0);
@ -386,26 +381,26 @@ public class BTree {
return deleteImp(key, child.node, mode);
}
BTNode sibL = node.getChild(subtreeIndex-1);
if(sibL!=null && sibL.keyCount > MIN_RECORDS) {
BTNode sibL = node.getChild(subtreeIndex - 1);
if (sibL != null && sibL.keyCount > MIN_RECORDS) {
/* Case 3a (ii): child will underflow upon deletion, take a key from leftSibling */
long leftKey = getRecord(node.chunk, node.node, subtreeIndex-1);
long leftKey = getRecord(node.chunk, node.node, subtreeIndex - 1);
prepend(child, leftKey, getChild(sibL.chunk, sibL.node, sibL.keyCount));
long rightmostLeftSiblingKey = getRecord(sibL.chunk, sibL.node, sibL.keyCount-1);
putRecord(sibL.chunk, sibL.node, sibL.keyCount-1, 0);
long rightmostLeftSiblingKey = getRecord(sibL.chunk, sibL.node, sibL.keyCount - 1);
putRecord(sibL.chunk, sibL.node, sibL.keyCount - 1, 0);
putChild(sibL.chunk, sibL.node, sibL.keyCount, 0);
putRecord(node.chunk, node.node, subtreeIndex-1, rightmostLeftSiblingKey);
putRecord(node.chunk, node.node, subtreeIndex - 1, rightmostLeftSiblingKey);
return deleteImp(key, child.node, mode);
}
/* Case 3b (i,ii): leftSibling, child, rightSibling all have minimum number of keys */
if(sibL!=null) { // merge child into leftSibling
mergeNodes(child, node, subtreeIndex-1, sibL);
if (sibL != null) { // merge child into leftSibling
mergeNodes(child, node, subtreeIndex - 1, sibL);
return deleteImp(key, sibL.node, mode);
}
if(sibR!=null) { // merge rightSibling into child
if (sibR != null) { // merge rightSibling into child
mergeNodes(sibR, node, subtreeIndex, child);
return deleteImp(key, child.node, mode);
}
@ -429,21 +424,21 @@ public class BTree {
*/
public void mergeNodes(BTNode src, BTNode keyProvider, int kIndex, BTNode dst)
throws CoreException {
nodeContentCopy(src, 0, dst, dst.keyCount+1, src.keyCount+1);
nodeContentCopy(src, 0, dst, dst.keyCount + 1, src.keyCount + 1);
long midKey = getRecord(keyProvider.chunk, keyProvider.node, kIndex);
putRecord(dst.chunk, dst.node, dst.keyCount, midKey);
long keySucc = kIndex+1 == MAX_RECORDS ? 0 : getRecord(keyProvider.chunk, keyProvider.node, kIndex+1);
db.free(getChild(keyProvider.chunk, keyProvider.node, kIndex+1));
nodeContentDelete(keyProvider, kIndex+1, 1);
long keySucc = kIndex + 1 == MAX_RECORDS ? 0 : getRecord(keyProvider.chunk, keyProvider.node, kIndex + 1);
db.free(getChild(keyProvider.chunk, keyProvider.node, kIndex + 1));
nodeContentDelete(keyProvider, kIndex + 1, 1);
putRecord(keyProvider.chunk, keyProvider.node, kIndex, keySucc);
if(kIndex == 0 && keySucc == 0) {
if (kIndex == 0 && keySucc == 0) {
/*
* The root node is excused from the property that a node must have a least MIN keys
* This means we must special case it at the point when its had all of its keys deleted
* entirely during merge operations (which push one of its keys down as a pivot)
*/
long rootNode = getRoot();
if(rootNode == keyProvider.node) {
if (rootNode == keyProvider.node) {
db.putRecPtr(rootPointer, dst.node);
db.free(rootNode);
}
@ -458,7 +453,7 @@ public class BTree {
* @param child the new leftmost (least) subtree root
*/
private void prepend(BTNode node, long key, long child) {
nodeContentCopy(node, 0, node, 1, node.keyCount+1);
nodeContentCopy(node, 0, node, 1, node.keyCount + 1);
putRecord(node.chunk, node.node, 0, key);
putChild(node.chunk, node.node, 0, child);
}
@ -487,15 +482,15 @@ public class BTree {
* @param length the number of (key,(predecessor)child) nodes to write
*/
private void nodeContentCopy(BTNode src, int srcPos, BTNode dst, int dstPos, int length) {
for(int i=length-1; i>=0; i--) { // this order is important when src==dst!
for (int i=length - 1; i >= 0; i--) { // this order is important when src == dst!
int srcIndex = srcPos + i;
int dstIndex = dstPos + i;
if(srcIndex<src.keyCount+1) {
if (srcIndex < src.keyCount + 1) {
long srcChild = getChild(src.chunk, src.node, srcIndex);
putChild(dst.chunk, dst.node, dstIndex, srcChild);
if(srcIndex<src.keyCount) {
if (srcIndex < src.keyCount) {
long srcKey = getRecord(src.chunk, src.node, srcIndex);
putRecord(dst.chunk, dst.node, dstIndex, srcKey);
}
@ -513,13 +508,13 @@ public class BTree {
* @param length the length of the sequence to delete
*/
private void nodeContentDelete(BTNode node, int i, int length) {
for(int index=i; index<=MAX_RECORDS; index++) {
long newKey = (index+length) < node.keyCount ? getRecord(node.chunk, node.node, index+length) : 0;
long newChild = (index+length) < node.keyCount+1 ? getChild(node.chunk, node.node, index+length) : 0;
if(index<MAX_RECORDS) {
for (int index= i; index <= MAX_RECORDS; index++) {
long newKey = (index + length) < node.keyCount ? getRecord(node.chunk, node.node, index + length) : 0;
long newChild = (index + length) < node.keyCount + 1 ? getChild(node.chunk, node.node, index + length) : 0;
if (index < MAX_RECORDS) {
putRecord(node.chunk, node.node, index, newKey);
}
if(index<MAX_CHILDREN) {
if (index < MAX_CHILDREN) {
putChild(node.chunk, node.node, index, newChild);
}
}
@ -543,8 +538,8 @@ public class BTree {
if (node == 0) {
return true;
}
if(visitor instanceof IBTreeVisitor2) {
((IBTreeVisitor2)visitor).preNode(node);
if (visitor instanceof IBTreeVisitor2) {
((IBTreeVisitor2) visitor).preNode(node);
}
try {
@ -552,23 +547,21 @@ public class BTree {
// binary search to find first record greater or equal
int lower= 0;
int upper= MAX_RECORDS-1;
while (lower < upper && getRecord(chunk, node, upper-1) == 0) {
int upper= MAX_RECORDS - 1;
while (lower < upper && getRecord(chunk, node, upper - 1) == 0) {
upper--;
}
while (lower < upper) {
int middle= (lower+upper)/2;
int middle= (lower + upper) / 2;
long checkRec = getRecord(chunk, node, middle);
if (checkRec == 0) {
upper= middle;
}
else {
} else {
int compare= visitor.compare(checkRec);
if (compare >= 0) {
upper= middle;
}
else {
lower= middle+1;
} else {
lower= middle + 1;
}
}
}
@ -584,8 +577,7 @@ public class BTree {
if (compare > 0) {
// start point is to the left
return accept(getChild(chunk, node, i), visitor);
}
else if (compare == 0) {
} else if (compare == 0) {
if (!accept(getChild(chunk, node, i), visitor))
return false;
if (!visitor.visit(record))
@ -594,8 +586,8 @@ public class BTree {
}
return accept(getChild(chunk, node, i), visitor);
} finally {
if(visitor instanceof IBTreeVisitor2) {
((IBTreeVisitor2)visitor).postNode(node);
if (visitor instanceof IBTreeVisitor2) {
((IBTreeVisitor2) visitor).postNode(node);
}
}
}
@ -648,56 +640,56 @@ public class BTree {
int keyCount = 0;
int indexFirstBlankKey = MAX_RECORDS;
int indexLastNonBlankKey = 0;
for(int i=0; i<MAX_RECORDS; i++) {
if(getRecord(db.getChunk(node), node, i)!=0) {
for (int i= 0; i < MAX_RECORDS; i++) {
if (getRecord(db.getChunk(node), node, i) != 0) {
keyCount++;
indexLastNonBlankKey = i;
} else if(indexFirstBlankKey== MAX_RECORDS){
} else if (indexFirstBlankKey == MAX_RECORDS) {
indexFirstBlankKey = i;
}
}
int childCount = 0;
for(int i=0; i<MAX_CHILDREN; i++) {
if(getChild(db.getChunk(node), node, i)!=0) {
for (int i= 0; i < MAX_CHILDREN; i++) {
if (getChild(db.getChunk(node), node, i) != 0) {
childCount++;
}
}
// check that non-blank keys are contiguous and blank key terminated
if(indexFirstBlankKey != indexLastNonBlankKey+1) {
boolean full = indexFirstBlankKey == MAX_RECORDS && indexLastNonBlankKey == MAX_RECORDS-1;
if (indexFirstBlankKey != indexLastNonBlankKey + 1) {
boolean full = indexFirstBlankKey == MAX_RECORDS && indexLastNonBlankKey == MAX_RECORDS - 1;
boolean empty = indexFirstBlankKey == 0 && indexLastNonBlankKey == 0;
if(!full && !empty){
if (!full && !empty) {
valid = false;
msg += MessageFormat.format(Messages.getString("BTree.IntegrityErrorA"), //$NON-NLS-1$
new Object[]{new Long(node), new Integer(indexFirstBlankKey), new Integer(indexLastNonBlankKey)});
new Object[] { new Long(node), new Integer(indexFirstBlankKey), new Integer(indexLastNonBlankKey) });
}
}
// Check: Key number constrains child numbers
if(childCount!=0 && childCount!=keyCount+1) {
if (childCount != 0 && childCount != keyCount + 1) {
valid = false;
msg += MessageFormat.format(Messages.getString("BTree.IntegrityErrorB"), new Object[]{new Long(node)}); //$NON-NLS-1$
msg += MessageFormat.format(Messages.getString("BTree.IntegrityErrorB"), new Object[] { new Long(node) }); //$NON-NLS-1$
}
// the root node is excused from the remaining node constraints
if(node == db.getRecPtr(rootPointer)) {
if (node == db.getRecPtr(rootPointer)) {
return;
}
// Check: Non-root nodes must have a keyCount within a certain range
if(keyCount < MIN_RECORDS || keyCount > MAX_RECORDS) {
if (keyCount < MIN_RECORDS || keyCount > MAX_RECORDS) {
valid = false;
msg += MessageFormat.format(Messages.getString("BTree.IntegrityErrorC"), new Object[]{new Long(node)}); //$NON-NLS-1$
msg += MessageFormat.format(Messages.getString("BTree.IntegrityErrorC"), new Object[] { new Long(node) }); //$NON-NLS-1$
}
// Check: All leaf nodes are at the same depth
if(childCount==0) {
if(leafDepth==null) {
if (childCount == 0) {
if (leafDepth == null) {
leafDepth = new Integer(depth);
}
if(depth!=leafDepth.intValue()) {
if (depth != leafDepth.intValue()) {
valid = false;
msg += Messages.getString("BTree.IntegrityErrorD"); //$NON-NLS-1$
}

View file

@ -16,6 +16,7 @@ import java.io.OutputStream;
import java.util.Properties;
import org.eclipse.cdt.internal.core.Cygwin;
import org.eclipse.cdt.internal.core.Messages;
import org.eclipse.cdt.internal.core.ProcessClosure;
import org.eclipse.cdt.utils.PathUtil;
import org.eclipse.cdt.utils.spawner.EnvironmentReader;
@ -25,6 +26,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.osgi.util.NLS;
/**
* @noextend This class is not intended to be subclassed by clients.
@ -125,18 +127,20 @@ public class CommandLauncher implements ICommandLauncher {
/**
* Parse array of "ENV=value" pairs to Properties.
*/
private Properties parseEnv(String[] env) {
Properties envProperties = new Properties();
for (String envStr : env) {
// Split "ENV=value" and put in Properties
int pos = envStr.indexOf('=');
if (pos < 0)
pos = envStr.length();
String key = envStr.substring(0, pos);
String value = envStr.substring(pos + 1);
envProperties.put(key, value);
private void parseEnvironment(String[] env) {
fEnvironment = null;
if (env != null) {
fEnvironment = new Properties();
for (String envStr : env) {
// Split "ENV=value" and put in Properties
int pos = envStr.indexOf('=');
if (pos < 0)
pos = envStr.length();
String key = envStr.substring(0, pos);
String value = envStr.substring(pos + 1);
fEnvironment.put(key, value);
}
}
return envProperties;
}
/**
@ -160,27 +164,28 @@ public class CommandLauncher implements ICommandLauncher {
*/
@Override
public Process execute(IPath commandPath, String[] args, String[] env, IPath workingDirectory, IProgressMonitor monitor) throws CoreException {
parseEnvironment(env);
String envPathValue = (String) getEnvironment().get(PATH_ENV);
Boolean isFound = null;
String command = commandPath.toOSString();
String envPathValue = (String) getEnvironment().get(PATH_ENV);
try {
fCommandArgs = constructCommandArray(command, args);
if (Platform.getOS().equals(Platform.OS_WIN32)) {
// Handle cygwin link
IPath location = PathUtil.findProgramLocation(command, envPathValue);
isFound = location != null;
if (location != null) {
try {
fCommandArgs[0] = Cygwin.cygwinToWindowsPath(location.toString(), envPathValue);
} catch (Exception e) {
// if no cygwin nothing to worry about
}
fCommandArgs = constructCommandArray(command, args);
if (Platform.getOS().equals(Platform.OS_WIN32)) {
// Handle cygwin link
IPath location = PathUtil.findProgramLocation(command, envPathValue);
isFound = location != null;
if (location != null) {
try {
fCommandArgs[0] = Cygwin.cygwinToWindowsPath(location.toString(), envPathValue);
} catch (Exception e) {
// if no cygwin nothing to worry about
}
}
}
fEnvironment = parseEnv(env);
File dir = workingDirectory != null ? workingDirectory.toFile() : null;
File dir = workingDirectory != null ? workingDirectory.toFile() : null;
try {
fProcess = ProcessFactory.getFactory().exec(fCommandArgs, env, dir);
fCommandArgs[0] = command; // to print original command on the console
fErrorMessage = ""; //$NON-NLS-1$
@ -201,8 +206,8 @@ public class CommandLauncher implements ICommandLauncher {
envPathValue = System.getenv(PATH_ENV);
}
errorMessage = errorMessage + NEWLINE
+ "Error: Program \"" + command + "\" not found in PATH" + NEWLINE
+ "PATH=[" + envPathValue + "]" + NEWLINE;
+ NLS.bind(Messages.CommandLauncher_ProgramNotFoundInPath, command) + NEWLINE
+ "PATH=[" + envPathValue + "]" + NEWLINE; //$NON-NLS-1$ //$NON-NLS-2$
}
setErrorMessage(errorMessage);
fProcess = null;
@ -258,7 +263,7 @@ public class CommandLauncher implements ICommandLauncher {
if (monitor.isCanceled()) {
closure.terminate();
state = COMMAND_CANCELED;
setErrorMessage(CCorePlugin.getResourceString("CommandLauncher.error.commandCanceled")); //$NON-NLS-1$
setErrorMessage(Messages.CommandLauncher_CommandCancelled);
}
try {

View file

@ -26,8 +26,6 @@ CoreModel.PathEntry.DuplicateEntry= Duplicate path entries found ({0}), path: [{
CoreModel.PathEntry.NestedEntry= Nested path entries
CoreModel.PathEntry.InvalidPathEntry= Invalid path
CommandLauncher.error.commandCanceled=Command canceled
CCProjectNature.exception.noNature=Project must have a cnature
CCorePlugin.exception.noBinaryFormat=No Binary Format

View file

@ -16,6 +16,8 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.messages"; //$NON-NLS-1$
public static String Util_unexpectedError;
public static String Addr_valueOutOfRange;
public static String CommandLauncher_CommandCancelled;
public static String CommandLauncher_ProgramNotFoundInPath;
public static String convention_illegalIdentifier;
public static String convention_invalid;
public static String convention_reservedKeyword;

View file

@ -47,6 +47,8 @@ convention_enum_invalidName= Enum name is invalid
Util_unexpectedError=Unexpected error
Addr_valueOutOfRange=Address is outside valid range.
CommandLauncher_CommandCancelled=Command canceled
CommandLauncher_ProgramNotFoundInPath=Error: Program "{0}" not found in PATH
XmlUtil_InternalErrorLoading=Internal error while trying to load XML document
XmlUtil_InternalErrorSerializing=Internal error while trying to serialize XML Document.

View file

@ -43,7 +43,6 @@ import org.eclipse.ui.WorkbenchException;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexFile;
@ -133,13 +132,11 @@ public class BaseUITestCase extends BaseTestCase {
continue;
index.acquireReadLock();
try {
IIndexFile pfile= index.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
if (pfile != null && pfile.getTimestamp() >= file.getLocalTimeStamp()) {
return;
}
pfile= index.getFile(ILinkage.C_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
if (pfile != null && pfile.getTimestamp() >= file.getLocalTimeStamp()) {
return;
IIndexFile[] indexFiles= index.getFiles(IndexLocationFactory.getWorkspaceIFL(file));
for (IIndexFile indexFile : indexFiles) {
if (indexFile != null && indexFile.getTimestamp() >= file.getLocalTimeStamp()) {
return;
}
}
} finally {
index.releaseReadLock();

View file

@ -96,26 +96,26 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true,
org.eclipse.cdt.ui.wizards,
org.eclipse.cdt.ui.wizards.conversion,
org.eclipse.cdt.utils.ui.controls
Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.3.0,4.0.0)",
org.eclipse.ui.views;bundle-version="[3.2.0,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.4.0,4.0.0)",
org.eclipse.ui.workbench.texteditor;bundle-version="[3.5.0,4.0.0)",
org.eclipse.ui.editors;bundle-version="[3.3.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.3.0,4.0.0)",
org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
org.eclipse.search;bundle-version="[3.2.0,4.0.0)",
Require-Bundle: org.eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)",
org.eclipse.compare;bundle-version="[3.3.0,4.0.0)",
org.eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)",
org.eclipse.ui.console;bundle-version="[3.1.100,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.7.0,4.0.0)",
org.eclipse.help;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.filesystem;bundle-version="[1.1.0,2.0.0)",
org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.7.0,4.0.0)",
org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)",
org.eclipse.help;bundle-version="[3.2.0,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.4.0,4.0.0)",
org.eclipse.ltk.core.refactoring;bundle-version="3.4.0",
org.eclipse.ltk.ui.refactoring;bundle-version="3.4.0",
org.eclipse.ui.navigator.resources;bundle-version="3.3.100"
org.eclipse.search;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.3.0,4.0.0)",
org.eclipse.ui.console;bundle-version="[3.1.100,4.0.0)",
org.eclipse.ui.editors;bundle-version="[3.3.0,4.0.0)",
org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui.ide;bundle-version="[3.3.0,4.0.0)",
org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui.navigator.resources;bundle-version="3.3.100",
org.eclipse.ui.views;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui.workbench.texteditor;bundle-version="[3.5.0,4.0.0)",
com.ibm.icu;bundle-version="4.4.2"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.ibm.icu.text