mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-08 16:55:38 +02:00
Cosmetics.
Change-Id: Ib2caefa5406ea94fe1eec61138193c79fd0f608b
This commit is contained in:
parent
07488984d9
commit
2356094497
3 changed files with 44 additions and 46 deletions
|
@ -44,14 +44,14 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding {
|
public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding {
|
||||||
public static final PDOMBinding[] EMPTY_PDOMBINDING_ARRAY = {};
|
public static final PDOMBinding[] EMPTY_PDOMBINDING_ARRAY = {};
|
||||||
|
|
||||||
private static final int FIRST_DECL_OFFSET = PDOMNamedNode.RECORD_SIZE + 0; // size 4
|
private static final int FIRST_DECL_OFFSET = PDOMNamedNode.RECORD_SIZE; // size 4
|
||||||
private static final int FIRST_DEF_OFFSET = PDOMNamedNode.RECORD_SIZE + 4; // size 4
|
private static final int FIRST_DEF_OFFSET = FIRST_DECL_OFFSET + Database.PTR_SIZE; // size 4
|
||||||
private static final int FIRST_REF_OFFSET = PDOMNamedNode.RECORD_SIZE + 8; // size 4
|
private static final int FIRST_REF_OFFSET = FIRST_DEF_OFFSET + Database.PTR_SIZE; // size 4
|
||||||
private static final int LOCAL_TO_FILE = PDOMNamedNode.RECORD_SIZE + 12; // size 4
|
private static final int LOCAL_TO_FILE = FIRST_REF_OFFSET + Database.PTR_SIZE; // size 4
|
||||||
private static final int FIRST_EXTREF_OFFSET = PDOMNamedNode.RECORD_SIZE + 16; // size 4
|
private static final int FIRST_EXTREF_OFFSET = LOCAL_TO_FILE + Database.PTR_SIZE; // size 4
|
||||||
|
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
protected static final int RECORD_SIZE = PDOMNamedNode.RECORD_SIZE + 20;
|
protected static final int RECORD_SIZE = FIRST_EXTREF_OFFSET + + Database.PTR_SIZE;
|
||||||
|
|
||||||
private byte hasDeclaration= -1;
|
private byte hasDeclaration= -1;
|
||||||
|
|
||||||
|
@ -64,10 +64,10 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings("unchecked")
|
||||||
public Object getAdapter(Class adapter) {
|
public <T> T getAdapter(Class<T> adapter) {
|
||||||
if (adapter.isAssignableFrom(PDOMBinding.class))
|
if (adapter.isAssignableFrom(PDOMBinding.class))
|
||||||
return this;
|
return (T) this;
|
||||||
|
|
||||||
// Any PDOMBinding can have a persistent tag. These tags should be deleted when
|
// Any PDOMBinding can have a persistent tag. These tags should be deleted when
|
||||||
// the PDOMBinding is deleted. However, PDOMBinding's don't get deleted, so there is no way
|
// the PDOMBinding is deleted. However, PDOMBinding's don't get deleted, so there is no way
|
||||||
|
@ -76,7 +76,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
|
||||||
// PDOMTagIndex.setTags(getPDOM(), pdomBinding.record, Collections.<ITag>emptyList());
|
// PDOMTagIndex.setTags(getPDOM(), pdomBinding.record, Collections.<ITag>emptyList());
|
||||||
// to clear out all tags for the binding.
|
// to clear out all tags for the binding.
|
||||||
if (adapter.isAssignableFrom(ITagReader.class))
|
if (adapter.isAssignableFrom(ITagReader.class))
|
||||||
return new PDOMTaggable(getPDOM(), getRecord());
|
return (T) new PDOMTaggable(getPDOM(), getRecord());
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
|
||||||
*
|
*
|
||||||
* @param pdom
|
* @param pdom
|
||||||
* @param record
|
* @param record
|
||||||
* @return <code>true</code> if the binding is orphaned.
|
* @return {@code true} if the binding is orphaned.
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
public static boolean isOrphaned(PDOM pdom, long record) throws CoreException {
|
public static boolean isOrphaned(PDOM pdom, long record) throws CoreException {
|
||||||
|
@ -313,7 +313,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
|
||||||
* For debug purposes only.
|
* For debug purposes only.
|
||||||
* @param linkage
|
* @param linkage
|
||||||
* @param value
|
* @param value
|
||||||
* @return String representation of <code>value</code>.
|
* @return String representation of {@code value}.
|
||||||
*/
|
*/
|
||||||
protected static String getConstantNameForValue(PDOMLinkage linkage, int value) {
|
protected static String getConstantNameForValue(PDOMLinkage linkage, int value) {
|
||||||
Class<? extends PDOMLinkage> c= linkage.getClass();
|
Class<? extends PDOMLinkage> c= linkage.getClass();
|
||||||
|
@ -328,9 +328,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
|
||||||
return field.getName();
|
return field.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException | IllegalArgumentException e) {
|
||||||
continue;
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,8 +400,8 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
|
||||||
}
|
}
|
||||||
} while (cmp == 0 && b1 != null && b0 != null);
|
} while (cmp == 0 && b1 != null && b0 != null);
|
||||||
return cmp;
|
return cmp;
|
||||||
} catch (CoreException ce) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(ce);
|
CCorePlugin.log(e);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,17 +35,17 @@ public abstract class PDOMNamedNode extends PDOMNode {
|
||||||
* The size in bytes of a PDOMNamedNode record in the database.
|
* The size in bytes of a PDOMNamedNode record in the database.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
protected static final int RECORD_SIZE = PDOMNode.RECORD_SIZE + 4;
|
protected static final int RECORD_SIZE = PDOMNode.RECORD_SIZE + Database.PTR_SIZE;
|
||||||
|
|
||||||
private volatile char[] fName;
|
private volatile char[] fName;
|
||||||
|
|
||||||
public PDOMNamedNode(PDOMLinkage linkage, long record) {
|
public PDOMNamedNode(PDOMLinkage linkage, long record) {
|
||||||
super(linkage, record);
|
super(linkage, record);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMNamedNode(PDOMLinkage linkage, PDOMNode parent, char[] name) throws CoreException {
|
public PDOMNamedNode(PDOMLinkage linkage, PDOMNode parent, char[] name) throws CoreException {
|
||||||
super(linkage, parent);
|
super(linkage, parent);
|
||||||
|
|
||||||
fName= name;
|
fName= name;
|
||||||
final Database db = linkage.getDB();
|
final Database db = linkage.getDB();
|
||||||
db.putRecPtr(record + NAME, name != null ? db.newString(name).getRecord() : 0);
|
db.putRecPtr(record + NAME, name != null ? db.newString(name).getRecord() : 0);
|
||||||
|
@ -59,41 +59,41 @@ public abstract class PDOMNamedNode extends PDOMNode {
|
||||||
fName= name;
|
fName= name;
|
||||||
db.putRecPtr(record + NAME, name != null ? db.newString(name).getRecord() : 0);
|
db.putRecPtr(record + NAME, name != null ? db.newString(name).getRecord() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
abstract protected int getRecordSize();
|
abstract protected int getRecordSize();
|
||||||
|
|
||||||
public IString getDBName() throws CoreException {
|
public IString getDBName() throws CoreException {
|
||||||
return getDBName(getDB(), record);
|
return getDBName(getDB(), record);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IString getDBName(Database db, long record) throws CoreException {
|
public static IString getDBName(Database db, long record) throws CoreException {
|
||||||
long namerec = db.getRecPtr(record + NAME);
|
long namerec = db.getRecPtr(record + NAME);
|
||||||
return db.getString(namerec);
|
return db.getString(namerec);
|
||||||
}
|
}
|
||||||
|
|
||||||
public char[] getNameCharArray() throws CoreException {
|
public char[] getNameCharArray() throws CoreException {
|
||||||
if (fName != null)
|
if (fName != null)
|
||||||
return fName;
|
return fName;
|
||||||
|
|
||||||
return fName= getDBName().getChars();
|
return fName= getDBName().getChars();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasName(char[] name) throws CoreException {
|
public boolean hasName(char[] name) throws CoreException {
|
||||||
if (fName != null)
|
if (fName != null)
|
||||||
return Arrays.equals(fName, name);
|
return Arrays.equals(fName, name);
|
||||||
|
|
||||||
return getDBName().equals(name);
|
return getDBName().equals(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Template parameters need to update their name.
|
* Template parameters need to update their name.
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
protected void updateName(char[] nameCharArray) throws CoreException {
|
protected void updateName(char[] nameCharArray) throws CoreException {
|
||||||
if (fName != null && CharArrayUtils.equals(fName, nameCharArray))
|
if (fName != null && CharArrayUtils.equals(fName, nameCharArray))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IString name= getDBName();
|
IString name= getDBName();
|
||||||
if (!name.equals(nameCharArray)) {
|
if (!name.equals(nameCharArray)) {
|
||||||
name.delete();
|
name.delete();
|
||||||
|
@ -112,11 +112,11 @@ public abstract class PDOMNamedNode extends PDOMNode {
|
||||||
}
|
}
|
||||||
super.delete(linkage);
|
super.delete(linkage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean mayHaveChildren() {
|
public boolean mayHaveChildren() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFragmentBinding getParentBinding() throws CoreException {
|
public IIndexFragmentBinding getParentBinding() throws CoreException {
|
||||||
PDOMNode parent= getParentNode();
|
PDOMNode parent= getParentNode();
|
||||||
if (parent instanceof IIndexFragmentBinding) {
|
if (parent instanceof IIndexFragmentBinding) {
|
||||||
|
@ -124,7 +124,7 @@ public abstract class PDOMNamedNode extends PDOMNode {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFragmentBinding getOwner() {
|
public IIndexFragmentBinding getOwner() {
|
||||||
try {
|
try {
|
||||||
return getParentBinding();
|
return getParentBinding();
|
||||||
|
|
|
@ -27,14 +27,14 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
*/
|
*/
|
||||||
public abstract class PDOMNode implements IInternalPDOMNode {
|
public abstract class PDOMNode implements IInternalPDOMNode {
|
||||||
private static final int FACTORY_ID = 0;
|
private static final int FACTORY_ID = 0;
|
||||||
private static final int NODE_TYPE = 2;
|
private static final int NODE_TYPE = FACTORY_ID + 2;
|
||||||
private static final int PARENT = 4;
|
private static final int PARENT = NODE_TYPE + 2;
|
||||||
|
|
||||||
protected static final int RECORD_SIZE = 8;
|
protected static final int RECORD_SIZE = PARENT + Database.PTR_SIZE;
|
||||||
|
|
||||||
private final PDOMLinkage fLinkage;
|
private final PDOMLinkage fLinkage;
|
||||||
protected final long record;
|
protected final long record;
|
||||||
|
|
||||||
private volatile long cachedParentRecord;
|
private volatile long cachedParentRecord;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,7 +81,7 @@ public abstract class PDOMNode implements IInternalPDOMNode {
|
||||||
protected PDOMNode(Database db) throws CoreException {
|
protected PDOMNode(Database db) throws CoreException {
|
||||||
this(db, null, 0);
|
this(db, null, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PDOMNode(Database db, PDOMLinkage linkage, long parentRec) throws CoreException {
|
protected PDOMNode(Database db, PDOMLinkage linkage, long parentRec) throws CoreException {
|
||||||
this.fLinkage = linkage;
|
this.fLinkage = linkage;
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ public abstract class PDOMNode implements IInternalPDOMNode {
|
||||||
public PDOM getPDOM() {
|
public PDOM getPDOM() {
|
||||||
return fLinkage.getPDOM();
|
return fLinkage.getPDOM();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMLinkage getLinkage() {
|
public PDOMLinkage getLinkage() {
|
||||||
return fLinkage;
|
return fLinkage;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ public abstract class PDOMNode implements IInternalPDOMNode {
|
||||||
public final long getRecord() {
|
public final long getRecord() {
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final long getBindingID() {
|
public final long getBindingID() {
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ public abstract class PDOMNode implements IInternalPDOMNode {
|
||||||
PDOMNode other = (PDOMNode) obj;
|
PDOMNode other = (PDOMNode) obj;
|
||||||
return getPDOM() == other.getPDOM() && record == other.record;
|
return getPDOM() == other.getPDOM() && record == other.record;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.equals(obj);
|
return super.equals(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,16 +195,16 @@ public abstract class PDOMNode implements IInternalPDOMNode {
|
||||||
}
|
}
|
||||||
return cachedParentRecord= getDB().getRecPtr(record + PARENT);
|
return cachedParentRecord= getDB().getRecPtr(record + PARENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMNode getParentNode() throws CoreException {
|
public PDOMNode getParentNode() throws CoreException {
|
||||||
long parentrec = getParentNodeRec();
|
long parentrec = getParentNodeRec();
|
||||||
return parentrec != 0 ? load(getPDOM(), parentrec) : null;
|
return parentrec != 0 ? load(getPDOM(), parentrec) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addChild(PDOMNode child) throws CoreException {
|
public void addChild(PDOMNode child) throws CoreException {
|
||||||
// nothing here
|
// nothing here
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method for fetching a byte from the database.
|
* Convenience method for fetching a byte from the database.
|
||||||
* @param offset Location of the byte.
|
* @param offset Location of the byte.
|
||||||
|
@ -232,8 +232,8 @@ public abstract class PDOMNode implements IInternalPDOMNode {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete this PDOMNode, make sure you are actually the owner of this record!
|
* Delete this PDOMNode, make sure you are actually the owner of this record!
|
||||||
* @param linkage
|
* @param linkage
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void delete(PDOMLinkage linkage) throws CoreException {
|
public void delete(PDOMLinkage linkage) throws CoreException {
|
||||||
|
|
Loading…
Add table
Reference in a new issue