1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Cosmetics.

Change-Id: Ib2caefa5406ea94fe1eec61138193c79fd0f608b
This commit is contained in:
Sergey Prigogin 2015-12-18 17:39:14 -08:00
parent 07488984d9
commit 2356094497
3 changed files with 44 additions and 46 deletions

View file

@ -44,14 +44,14 @@ import org.eclipse.core.runtime.CoreException;
public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding {
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_DEF_OFFSET = PDOMNamedNode.RECORD_SIZE + 4; // size 4
private static final int FIRST_REF_OFFSET = PDOMNamedNode.RECORD_SIZE + 8; // size 4
private static final int LOCAL_TO_FILE = PDOMNamedNode.RECORD_SIZE + 12; // size 4
private static final int FIRST_EXTREF_OFFSET = PDOMNamedNode.RECORD_SIZE + 16; // size 4
private static final int FIRST_DECL_OFFSET = PDOMNamedNode.RECORD_SIZE; // size 4
private static final int FIRST_DEF_OFFSET = FIRST_DECL_OFFSET + Database.PTR_SIZE; // size 4
private static final int FIRST_REF_OFFSET = FIRST_DEF_OFFSET + Database.PTR_SIZE; // size 4
private static final int LOCAL_TO_FILE = FIRST_REF_OFFSET + Database.PTR_SIZE; // size 4
private static final int FIRST_EXTREF_OFFSET = LOCAL_TO_FILE + Database.PTR_SIZE; // size 4
@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;
@ -64,10 +64,10 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Object getAdapter(Class adapter) {
@SuppressWarnings("unchecked")
public <T> T getAdapter(Class<T> adapter) {
if (adapter.isAssignableFrom(PDOMBinding.class))
return this;
return (T) this;
// 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
@ -76,7 +76,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
// PDOMTagIndex.setTags(getPDOM(), pdomBinding.record, Collections.<ITag>emptyList());
// to clear out all tags for the binding.
if (adapter.isAssignableFrom(ITagReader.class))
return new PDOMTaggable(getPDOM(), getRecord());
return (T) new PDOMTaggable(getPDOM(), getRecord());
return null;
}
@ -88,7 +88,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
*
* @param pdom
* @param record
* @return <code>true</code> if the binding is orphaned.
* @return {@code true} if the binding is orphaned.
* @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.
* @param linkage
* @param value
* @return String representation of <code>value</code>.
* @return String representation of {@code value}.
*/
protected static String getConstantNameForValue(PDOMLinkage linkage, int value) {
Class<? extends PDOMLinkage> c= linkage.getClass();
@ -328,9 +328,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
return field.getName();
}
}
} catch (IllegalAccessException e) {
continue;
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException | IllegalArgumentException e) {
continue;
}
}
@ -402,8 +400,8 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
}
} while (cmp == 0 && b1 != null && b0 != null);
return cmp;
} catch (CoreException ce) {
CCorePlugin.log(ce);
} catch (CoreException e) {
CCorePlugin.log(e);
return -1;
}
}

View file

@ -35,17 +35,17 @@ public abstract class PDOMNamedNode extends PDOMNode {
* The size in bytes of a PDOMNamedNode record in the database.
*/
@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;
public PDOMNamedNode(PDOMLinkage linkage, long record) {
super(linkage, record);
}
public PDOMNamedNode(PDOMLinkage linkage, PDOMNode parent, char[] name) throws CoreException {
super(linkage, parent);
fName= name;
final Database db = linkage.getDB();
db.putRecPtr(record + NAME, name != null ? db.newString(name).getRecord() : 0);
@ -59,41 +59,41 @@ public abstract class PDOMNamedNode extends PDOMNode {
fName= name;
db.putRecPtr(record + NAME, name != null ? db.newString(name).getRecord() : 0);
}
@Override
abstract protected int getRecordSize();
public IString getDBName() throws CoreException {
return getDBName(getDB(), record);
}
public static IString getDBName(Database db, long record) throws CoreException {
long namerec = db.getRecPtr(record + NAME);
return db.getString(namerec);
}
public char[] getNameCharArray() throws CoreException {
if (fName != null)
return fName;
return fName= getDBName().getChars();
}
public boolean hasName(char[] name) throws CoreException {
if (fName != null)
return Arrays.equals(fName, name);
return getDBName().equals(name);
}
/**
* Template parameters need to update their name.
* @throws CoreException
* @throws CoreException
*/
protected void updateName(char[] nameCharArray) throws CoreException {
if (fName != null && CharArrayUtils.equals(fName, nameCharArray))
return;
IString name= getDBName();
if (!name.equals(nameCharArray)) {
name.delete();
@ -112,11 +112,11 @@ public abstract class PDOMNamedNode extends PDOMNode {
}
super.delete(linkage);
}
public boolean mayHaveChildren() {
return false;
}
public IIndexFragmentBinding getParentBinding() throws CoreException {
PDOMNode parent= getParentNode();
if (parent instanceof IIndexFragmentBinding) {
@ -124,7 +124,7 @@ public abstract class PDOMNamedNode extends PDOMNode {
}
return null;
}
public IIndexFragmentBinding getOwner() {
try {
return getParentBinding();

View file

@ -27,14 +27,14 @@ import org.eclipse.core.runtime.CoreException;
*/
public abstract class PDOMNode implements IInternalPDOMNode {
private static final int FACTORY_ID = 0;
private static final int NODE_TYPE = 2;
private static final int PARENT = 4;
protected static final int RECORD_SIZE = 8;
private static final int NODE_TYPE = FACTORY_ID + 2;
private static final int PARENT = NODE_TYPE + 2;
protected static final int RECORD_SIZE = PARENT + Database.PTR_SIZE;
private final PDOMLinkage fLinkage;
protected final long record;
private volatile long cachedParentRecord;
/**
@ -81,7 +81,7 @@ public abstract class PDOMNode implements IInternalPDOMNode {
protected PDOMNode(Database db) throws CoreException {
this(db, null, 0);
}
protected PDOMNode(Database db, PDOMLinkage linkage, long parentRec) throws CoreException {
this.fLinkage = linkage;
@ -102,7 +102,7 @@ public abstract class PDOMNode implements IInternalPDOMNode {
public PDOM getPDOM() {
return fLinkage.getPDOM();
}
public PDOMLinkage getLinkage() {
return fLinkage;
}
@ -122,7 +122,7 @@ public abstract class PDOMNode implements IInternalPDOMNode {
public final long getRecord() {
return record;
}
public final long getBindingID() {
return record;
}
@ -148,7 +148,7 @@ public abstract class PDOMNode implements IInternalPDOMNode {
PDOMNode other = (PDOMNode) obj;
return getPDOM() == other.getPDOM() && record == other.record;
}
return super.equals(obj);
}
@ -195,16 +195,16 @@ public abstract class PDOMNode implements IInternalPDOMNode {
}
return cachedParentRecord= getDB().getRecPtr(record + PARENT);
}
public PDOMNode getParentNode() throws CoreException {
long parentrec = getParentNodeRec();
return parentrec != 0 ? load(getPDOM(), parentrec) : null;
}
public void addChild(PDOMNode child) throws CoreException {
// nothing here
}
/**
* Convenience method for fetching a byte from the database.
* @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!
* @param linkage
* @throws CoreException
* @param linkage
* @throws CoreException
*/
@Override
public void delete(PDOMLinkage linkage) throws CoreException {