mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Compiler warnings.
This commit is contained in:
parent
645efee68a
commit
4698f4d97f
2 changed files with 33 additions and 44 deletions
|
@ -27,14 +27,16 @@ import org.eclipse.core.runtime.OperationCanceledException;
|
||||||
public class FindBinding {
|
public class FindBinding {
|
||||||
public static class DefaultBindingBTreeComparator implements IBTreeComparator {
|
public static class DefaultBindingBTreeComparator implements IBTreeComparator {
|
||||||
protected PDOM pdom;
|
protected PDOM pdom;
|
||||||
|
|
||||||
public DefaultBindingBTreeComparator(PDOM pdom) {
|
public DefaultBindingBTreeComparator(PDOM pdom) {
|
||||||
this.pdom = pdom;
|
this.pdom = pdom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compare(int record1, int record2) throws CoreException {
|
public int compare(int record1, int record2) throws CoreException {
|
||||||
IString nm1 = PDOMNamedNode.getDBName(pdom, record1);
|
IString nm1 = PDOMNamedNode.getDBName(pdom, record1);
|
||||||
IString nm2 = PDOMNamedNode.getDBName(pdom, record2);
|
IString nm2 = PDOMNamedNode.getDBName(pdom, record2);
|
||||||
int cmp= nm1.compareCompatibleWithIgnoreCase(nm2);
|
int cmp= nm1.compareCompatibleWithIgnoreCase(nm2);
|
||||||
if(cmp == 0) {
|
if (cmp == 0) {
|
||||||
int t1= PDOMBinding.getLocalToFileRec(pdom, record1);
|
int t1= PDOMBinding.getLocalToFileRec(pdom, record1);
|
||||||
int t2= PDOMBinding.getLocalToFileRec(pdom, record2);
|
int t2= PDOMBinding.getLocalToFileRec(pdom, record2);
|
||||||
if (t1 == t2) {
|
if (t1 == t2) {
|
||||||
|
@ -60,11 +62,12 @@ public class FindBinding {
|
||||||
fConstants = constants;
|
fConstants = constants;
|
||||||
fLocalToFile= localToFile;
|
fLocalToFile= localToFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
// IBTreeVisitor
|
// IBTreeVisitor
|
||||||
public int compare(int record) throws CoreException {
|
public int compare(int record) throws CoreException {
|
||||||
IString nm1 = PDOMNamedNode.getDBName(fPdom, record);
|
IString nm1 = PDOMNamedNode.getDBName(fPdom, record);
|
||||||
int cmp= nm1.compareCompatibleWithIgnoreCase(fName);
|
int cmp= nm1.compareCompatibleWithIgnoreCase(fName);
|
||||||
if(cmp == 0) {
|
if (cmp == 0) {
|
||||||
int t1= PDOMBinding.getLocalToFileRec(fPdom, record);
|
int t1= PDOMBinding.getLocalToFileRec(fPdom, record);
|
||||||
int t2= fLocalToFile;
|
int t2= fLocalToFile;
|
||||||
cmp= t1 < t2 ? -1 : (t1 > t2 ? 1 : 0);
|
cmp= t1 < t2 ? -1 : (t1 > t2 ? 1 : 0);
|
||||||
|
@ -88,8 +91,8 @@ public class FindBinding {
|
||||||
protected boolean matches(PDOMBinding nnode) throws CoreException {
|
protected boolean matches(PDOMBinding nnode) throws CoreException {
|
||||||
if (nnode.hasName(fName)) {
|
if (nnode.hasName(fName)) {
|
||||||
int constant = nnode.getNodeType();
|
int constant = nnode.getNodeType();
|
||||||
for(int i=0; i<fConstants.length; i++) {
|
for (int i=0; i<fConstants.length; i++) {
|
||||||
if(constant==fConstants[i]) {
|
if (constant == fConstants[i]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,21 +119,21 @@ public class FindBinding {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class NestedBindingsBTreeComparator extends DefaultBindingBTreeComparator implements IBTreeComparator {
|
public static class NestedBindingsBTreeComparator extends DefaultBindingBTreeComparator {
|
||||||
protected PDOMLinkage linkage;
|
protected PDOMLinkage linkage;
|
||||||
|
|
||||||
public NestedBindingsBTreeComparator(PDOMLinkage linkage) {
|
public NestedBindingsBTreeComparator(PDOMLinkage linkage) {
|
||||||
super(linkage.pdom);
|
super(linkage.pdom);
|
||||||
this.linkage= linkage;
|
this.linkage= linkage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(int record1, int record2) throws CoreException {
|
public int compare(int record1, int record2) throws CoreException {
|
||||||
int cmp= super.compare(record1, record2); // compare names
|
int cmp= super.compare(record1, record2); // compare names
|
||||||
if (cmp==0) { // any order will do.
|
if (cmp == 0) { // any order will do.
|
||||||
if (record1 < record2) {
|
if (record1 < record2) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
} else if (record1 > record2) {
|
||||||
else if (record1 > record2) {
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,7 +155,7 @@ public class FindBinding {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PDOMBinding findBinding(BTree btree, final PDOM pdom, final char[]name, final int[] constants,
|
public static PDOMBinding findBinding(BTree btree, final PDOM pdom, final char[] name, final int[] constants,
|
||||||
final int localToFileRec) throws CoreException {
|
final int localToFileRec) throws CoreException {
|
||||||
final DefaultFindBindingVisitor visitor = new DefaultFindBindingVisitor(pdom, name, constants, localToFileRec);
|
final DefaultFindBindingVisitor visitor = new DefaultFindBindingVisitor(pdom, name, constants, localToFileRec);
|
||||||
btree.accept(visitor);
|
btree.accept(visitor);
|
||||||
|
@ -160,7 +163,7 @@ public class FindBinding {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static PDOMBinding findBinding(IPDOMNode node, final PDOM pdom, final char[]name, final int[] constants,
|
public static PDOMBinding findBinding(IPDOMNode node, final PDOM pdom, final char[] name, final int[] constants,
|
||||||
int localToFileRec) throws CoreException {
|
int localToFileRec) throws CoreException {
|
||||||
final DefaultFindBindingVisitor visitor = new DefaultFindBindingVisitor(pdom, name, constants, localToFileRec);
|
final DefaultFindBindingVisitor visitor = new DefaultFindBindingVisitor(pdom, name, constants, localToFileRec);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -50,7 +50,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* Represents a file containing names.
|
* Represents a file containing names.
|
||||||
*
|
*
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class PDOMFile implements IIndexFragmentFile {
|
public class PDOMFile implements IIndexFragmentFile {
|
||||||
private final PDOM pdom;
|
private final PDOM pdom;
|
||||||
|
@ -100,7 +99,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
Database db = pdom.getDB();
|
Database db = pdom.getDB();
|
||||||
record = db.malloc(RECORD_SIZE);
|
record = db.malloc(RECORD_SIZE);
|
||||||
String locationString = pdom.getLocationConverter().toInternalFormat(location);
|
String locationString = pdom.getLocationConverter().toInternalFormat(location);
|
||||||
if(locationString==null)
|
if (locationString==null)
|
||||||
throw new CoreException(CCorePlugin.createStatus(Messages.getString("PDOMFile.toInternalProblem")+location.getURI())); //$NON-NLS-1$
|
throw new CoreException(CCorePlugin.createStatus(Messages.getString("PDOMFile.toInternalProblem")+location.getURI())); //$NON-NLS-1$
|
||||||
IString locationDBString = db.newString(locationString);
|
IString locationDBString = db.newString(locationString);
|
||||||
db.putInt(record + LOCATION_REPRESENTATION, locationDBString.getRecord());
|
db.putInt(record + LOCATION_REPRESENTATION, locationDBString.getRecord());
|
||||||
|
@ -136,7 +135,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
* Directly changes this record's internal location string. The format
|
* Directly changes this record's internal location string. The format
|
||||||
* of this string is unspecified in general and is determined by the
|
* of this string is unspecified in general and is determined by the
|
||||||
* associated IIndexLocationConverter
|
* associated IIndexLocationConverter
|
||||||
* @param newName
|
* @param internalLocation
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
public void setInternalLocation(String internalLocation) throws CoreException {
|
public void setInternalLocation(String internalLocation) throws CoreException {
|
||||||
|
@ -237,8 +236,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
PDOMMacro pdomMacro = new PDOMMacro(pdom, container, macro, this);
|
PDOMMacro pdomMacro = new PDOMMacro(pdom, container, macro, this);
|
||||||
if (lastMacro == null) {
|
if (lastMacro == null) {
|
||||||
setFirstMacro(pdomMacro);
|
setFirstMacro(pdomMacro);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
lastMacro.setNextMacro(pdomMacro);
|
lastMacro.setNextMacro(pdomMacro);
|
||||||
}
|
}
|
||||||
lastMacro= pdomMacro;
|
lastMacro= pdomMacro;
|
||||||
|
@ -283,8 +281,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
PDOMMacroReferenceName macroName = (PDOMMacroReferenceName) fname;
|
PDOMMacroReferenceName macroName = (PDOMMacroReferenceName) fname;
|
||||||
if (lastMacroName == null) {
|
if (lastMacroName == null) {
|
||||||
setFirstMacroReference(macroName);
|
setFirstMacroReference(macroName);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
lastMacroName.setNextInFile(macroName);
|
lastMacroName.setNextInFile(macroName);
|
||||||
}
|
}
|
||||||
lastMacroName= macroName;
|
lastMacroName= macroName;
|
||||||
|
@ -302,13 +299,11 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
if (binding instanceof IMacroBinding) {
|
if (binding instanceof IMacroBinding) {
|
||||||
return createPDOMMacroReferenceName(linkage, name);
|
return createPDOMMacroReferenceName(linkage, name);
|
||||||
}
|
}
|
||||||
else {
|
PDOMBinding pdomBinding = linkage.addBinding(name);
|
||||||
PDOMBinding pdomBinding = linkage.addBinding(name);
|
if (pdomBinding != null) {
|
||||||
if (pdomBinding != null) {
|
final PDOMName result= new PDOMName(pdom, name, this, pdomBinding, caller);
|
||||||
final PDOMName result= new PDOMName(pdom, name, this, pdomBinding, caller);
|
linkage.onCreateName(this, name, result);
|
||||||
linkage.onCreateName(this, name, result);
|
return result;
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
|
@ -396,8 +391,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
}
|
}
|
||||||
if (lastInclude == null) {
|
if (lastInclude == null) {
|
||||||
setFirstInclude(pdomInclude);
|
setFirstInclude(pdomInclude);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
lastInclude.setNextInIncludes(pdomInclude);
|
lastInclude.setNextInIncludes(pdomInclude);
|
||||||
}
|
}
|
||||||
lastInclude= pdomInclude;
|
lastInclude= pdomInclude;
|
||||||
|
@ -411,8 +405,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
setFirstIncludedBy(include);
|
setFirstIncludedBy(include);
|
||||||
include.setNextInIncludedBy(firstIncludedBy);
|
include.setNextInIncludedBy(firstIncludedBy);
|
||||||
firstIncludedBy.setPrevInIncludedBy(include);
|
firstIncludedBy.setPrevInIncludedBy(include);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
PDOMInclude secondIncludedBy= firstIncludedBy.getNextInIncludedBy();
|
PDOMInclude secondIncludedBy= firstIncludedBy.getNextInIncludedBy();
|
||||||
if (secondIncludedBy != null) {
|
if (secondIncludedBy != null) {
|
||||||
include.setNextInIncludedBy(secondIncludedBy);
|
include.setNextInIncludedBy(secondIncludedBy);
|
||||||
|
@ -458,8 +451,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
if (nameOffset >= offset) {
|
if (nameOffset >= offset) {
|
||||||
if (nameOffset + name.getNodeLength() <= offset+length) {
|
if (nameOffset + name.getNodeLength() <= offset+length) {
|
||||||
result.add(name);
|
result.add(name);
|
||||||
}
|
} else if (name.isReference()) {
|
||||||
else if (name.isReference()) {
|
|
||||||
// names are ordered, but callers are inserted before
|
// names are ordered, but callers are inserted before
|
||||||
// their references
|
// their references
|
||||||
break;
|
break;
|
||||||
|
@ -472,8 +464,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
if (nameOffset >= offset) {
|
if (nameOffset >= offset) {
|
||||||
if (nameOffset + name.getNodeLength() <= offset+length) {
|
if (nameOffset + name.getNodeLength() <= offset+length) {
|
||||||
result.add(name.getDefinition());
|
result.add(name.getDefinition());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -483,8 +474,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
if (nameOffset >= offset) {
|
if (nameOffset >= offset) {
|
||||||
if (nameOffset + name.getNodeLength() <= offset+length) {
|
if (nameOffset + name.getNodeLength() <= offset+length) {
|
||||||
result.add(name);
|
result.add(name);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -496,7 +486,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
String internalRepresentation= strategy.toInternalFormat(location);
|
String internalRepresentation= strategy.toInternalFormat(location);
|
||||||
int record= 0;
|
int record= 0;
|
||||||
if(internalRepresentation!=null) {
|
if (internalRepresentation != null) {
|
||||||
Finder finder = new Finder(pdom.getDB(), internalRepresentation, linkageID);
|
Finder finder = new Finder(pdom.getDB(), internalRepresentation, linkageID);
|
||||||
btree.accept(finder);
|
btree.accept(finder);
|
||||||
record= finder.getRecord();
|
record= finder.getRecord();
|
||||||
|
@ -507,7 +497,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
public static IIndexFragmentFile[] findFiles(PDOM pdom, BTree btree, IIndexFileLocation location, IIndexLocationConverter strategy)
|
public static IIndexFragmentFile[] findFiles(PDOM pdom, BTree btree, IIndexFileLocation location, IIndexLocationConverter strategy)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
String internalRepresentation= strategy.toInternalFormat(location);
|
String internalRepresentation= strategy.toInternalFormat(location);
|
||||||
if(internalRepresentation!=null) {
|
if (internalRepresentation != null) {
|
||||||
Finder finder = new Finder(pdom.getDB(), internalRepresentation, -1);
|
Finder finder = new Finder(pdom.getDB(), internalRepresentation, -1);
|
||||||
btree.accept(finder);
|
btree.accept(finder);
|
||||||
int[] records= finder.getRecords();
|
int[] records= finder.getRecords();
|
||||||
|
@ -542,12 +532,11 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
if (record == 0) {
|
if (record == 0) {
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
}
|
}
|
||||||
return new int[] {record};
|
return new int[] { record };
|
||||||
}
|
}
|
||||||
return records;
|
return records;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("hiding")
|
|
||||||
public int compare(int record) throws CoreException {
|
public int compare(int record) throws CoreException {
|
||||||
IString name = db.getString(db.getInt(record + PDOMFile.LOCATION_REPRESENTATION));
|
IString name = db.getString(db.getInt(record + PDOMFile.LOCATION_REPRESENTATION));
|
||||||
int cmp= name.compare(rawKey, true);
|
int cmp= name.compare(rawKey, true);
|
||||||
|
@ -557,7 +546,6 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("hiding")
|
|
||||||
public boolean visit(int record) throws CoreException {
|
public boolean visit(int record) throws CoreException {
|
||||||
if (linkageID >= 0) {
|
if (linkageID >= 0) {
|
||||||
this.record = record;
|
this.record = record;
|
||||||
|
@ -565,11 +553,9 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
}
|
}
|
||||||
if (this.record == 0) {
|
if (this.record == 0) {
|
||||||
this.record= record;
|
this.record= record;
|
||||||
}
|
} else if (this.records == null) {
|
||||||
else if (this.records == null) {
|
|
||||||
this.records= new int[] {this.record, record};
|
this.records= new int[] {this.record, record};
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
int[] cpy= new int[this.records.length+1];
|
int[] cpy= new int[this.records.length+1];
|
||||||
System.arraycopy(this.records, 0, cpy, 0, this.records.length);
|
System.arraycopy(this.records, 0, cpy, 0, this.records.length);
|
||||||
cpy[cpy.length-1]= record;
|
cpy[cpy.length-1]= record;
|
||||||
|
@ -588,7 +574,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
Database db = pdom.getDB();
|
Database db = pdom.getDB();
|
||||||
String raw = db.getString(db.getInt(record + LOCATION_REPRESENTATION)).getString();
|
String raw = db.getString(db.getInt(record + LOCATION_REPRESENTATION)).getString();
|
||||||
location= pdom.getLocationConverter().fromInternalFormat(raw);
|
location= pdom.getLocationConverter().fromInternalFormat(raw);
|
||||||
if(location==null)
|
if (location == null)
|
||||||
throw new CoreException(CCorePlugin.createStatus(Messages.getString("PDOMFile.toExternalProblem")+raw)); //$NON-NLS-1$
|
throw new CoreException(CCorePlugin.createStatus(Messages.getString("PDOMFile.toExternalProblem")+raw)); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
return location;
|
return location;
|
||||||
|
|
Loading…
Add table
Reference in a new issue