mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
Cosmetics.
This commit is contained in:
parent
fa989bde50
commit
0f25dd18d3
1 changed files with 12 additions and 14 deletions
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*******************************************************************************
|
||||||
* Copyright (c) 2013 QNX Software Systems and others.
|
* Copyright (c) 2013 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
@ -7,11 +7,10 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Eidsness - Initial implementation
|
* Andrew Eidsness - Initial implementation
|
||||||
*/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.tag;
|
package org.eclipse.cdt.internal.core.pdom.tag;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -30,8 +29,8 @@ public class PDOMTagSynchronizer implements IBTreeVisitor {
|
||||||
private final Long searchRecord;
|
private final Long searchRecord;
|
||||||
private final Map<String, ITag> newTags;
|
private final Map<String, ITag> newTags;
|
||||||
|
|
||||||
private final List<Long> toRemove = new LinkedList<Long>();
|
private final List<Long> toRemove = new ArrayList<>();
|
||||||
private final List<Long> toInsert = new LinkedList<Long>();
|
private final List<Long> toInsert = new ArrayList<>();
|
||||||
|
|
||||||
public PDOMTagSynchronizer(Database db, Long searchRecord, Map<String, ITag> newTags) {
|
public PDOMTagSynchronizer(Database db, Long searchRecord, Map<String, ITag> newTags) {
|
||||||
this.db = db;
|
this.db = db;
|
||||||
|
@ -44,7 +43,7 @@ public class PDOMTagSynchronizer implements IBTreeVisitor {
|
||||||
* and false otherwise.
|
* and false otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean synchronize(BTree tree) {
|
public boolean synchronize(BTree tree) {
|
||||||
for (Long rm : toRemove)
|
for (Long rm : toRemove) {
|
||||||
try {
|
try {
|
||||||
long record = rm.longValue();
|
long record = rm.longValue();
|
||||||
tree.delete(record);
|
tree.delete(record);
|
||||||
|
@ -52,9 +51,10 @@ public class PDOMTagSynchronizer implements IBTreeVisitor {
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
toRemove.clear();
|
toRemove.clear();
|
||||||
|
|
||||||
for (Long insert : toInsert)
|
for (Long insert : toInsert) {
|
||||||
try {
|
try {
|
||||||
tree.insert(insert.longValue());
|
tree.insert(insert.longValue());
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -65,6 +65,7 @@ public class PDOMTagSynchronizer implements IBTreeVisitor {
|
||||||
CCorePlugin.log(e1);
|
CCorePlugin.log(e1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
toInsert.clear();
|
toInsert.clear();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -73,7 +74,6 @@ public class PDOMTagSynchronizer implements IBTreeVisitor {
|
||||||
@Override
|
@Override
|
||||||
public int compare(long test_record) throws CoreException {
|
public int compare(long test_record) throws CoreException {
|
||||||
// TODO this is the same as BTreeIterable.Descriptor.compare
|
// TODO this is the same as BTreeIterable.Descriptor.compare
|
||||||
|
|
||||||
long test_node = new PDOMTag(db, test_record).getNode();
|
long test_node = new PDOMTag(db, test_record).getNode();
|
||||||
|
|
||||||
// -1 if record < key, 0 if record == key, 1 if record > key
|
// -1 if record < key, 0 if record == key, 1 if record > key
|
||||||
|
@ -90,15 +90,13 @@ public class PDOMTagSynchronizer implements IBTreeVisitor {
|
||||||
toRemove.add(Long.valueOf(existing_record));
|
toRemove.add(Long.valueOf(existing_record));
|
||||||
} else if (newTag.getDataLen() > existingTag.getDataLen()) {
|
} else if (newTag.getDataLen() > existingTag.getDataLen()) {
|
||||||
toRemove.add(Long.valueOf(existing_record));
|
toRemove.add(Long.valueOf(existing_record));
|
||||||
|
|
||||||
PDOMTag pdomTag = existingTag.cloneWith(newTag.getBytes(0, -1));
|
PDOMTag pdomTag = existingTag.cloneWith(newTag.getBytes(0, -1));
|
||||||
if (pdomTag != null)
|
if (pdomTag != null)
|
||||||
toInsert.add(Long.valueOf(pdomTag.getRecord()));
|
toInsert.add(Long.valueOf(pdomTag.getRecord()));
|
||||||
} else if (!existingTag.putBytes(0, newTag.getBytes(0, -1), -1))
|
} else if (!existingTag.putBytes(0, newTag.getBytes(0, -1), -1))
|
||||||
CCorePlugin
|
CCorePlugin.log("Unable to modify data of tag record " + existing_record //$NON-NLS-1$
|
||||||
.log("Unable to modify data of tag record " + existing_record + " from taggerId " + taggerId); //$NON-NLS-1$ //$NON-NLS-2$
|
+ " from taggerId " + taggerId); //$NON-NLS-1$
|
||||||
|
// Try to visit the full tree.
|
||||||
// try to visit the full tree
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue