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

Fix undef-statements in index, bug 234591.

This commit is contained in:
Markus Schorn 2008-05-29 12:38:27 +00:00
parent c33ef0d470
commit ed6c4dc4a0
4 changed files with 17 additions and 13 deletions

View file

@ -104,7 +104,7 @@ public class PDOM extends PlatformObject implements IPDOM {
private static int version(int major, int minor) { private static int version(int major, int minor) {
return major << 16 + minor; return major << 16 + minor;
} }
public static final int MAJOR_VERSION = 60; public static final int MAJOR_VERSION = 61;
public static final int MINOR_VERSION = 0; // minor versions must be compatible public static final int MINOR_VERSION = 0; // minor versions must be compatible
public static final int CURRENT_VERSION= version(MAJOR_VERSION, MINOR_VERSION); public static final int CURRENT_VERSION= version(MAJOR_VERSION, MINOR_VERSION);
@ -174,6 +174,7 @@ public class PDOM extends PlatformObject implements IPDOM {
* 58.0 - non-type parameters (bug 207840) * 58.0 - non-type parameters (bug 207840)
* 59.0 - changed modeling of deferred class instances (bug 229218) * 59.0 - changed modeling of deferred class instances (bug 229218)
* 60.0 - store integral values with basic types (bug 207871) * 60.0 - store integral values with basic types (bug 207871)
* 61.0 - properly insert macro undef statements into macro-containers (bug 234591)
*/ */
public static final int LINKAGES = Database.DATA_AREA; public static final int LINKAGES = Database.DATA_AREA;
@ -800,7 +801,10 @@ public class PDOM extends PlatformObject implements IPDOM {
throws CoreException { throws CoreException {
if ((options & FIND_DEFINITIONS) != 0) { if ((options & FIND_DEFINITIONS) != 0) {
for (PDOMMacro macro= container.getFirstDefinition(); macro != null; macro= macro.getNextInContainer()) { for (PDOMMacro macro= container.getFirstDefinition(); macro != null; macro= macro.getNextInContainer()) {
names.add(macro.getDefinition()); final IIndexFragmentName name = macro.getDefinition();
if (name != null) {
names.add(name);
}
} }
} }
if ((options & FIND_REFERENCES) != 0) { if ((options & FIND_REFERENCES) != 0) {

View file

@ -472,12 +472,13 @@ public class PDOMFile implements IIndexFragmentFile {
} }
} }
for (PDOMMacro name= getFirstMacro(); name != null; name= name.getNextMacro()) { for (PDOMMacro macro= getFirstMacro(); macro != null; macro= macro.getNextMacro()) {
int nameOffset= name.getNodeOffset(); int nameOffset= macro.getNodeOffset();
if (nameOffset >= offset) { if (nameOffset >= offset) {
if (nameOffset + name.getNodeLength() <= offset+length) { if (nameOffset + macro.getNodeLength() <= offset+length) {
if (name.isMacroDefinition()) { IIndexFragmentName name= macro.getDefinition();
result.add(name.getDefinition()); if (name != null) {
result.add(name);
} }
} else { } else {
break; break;

View file

@ -10,7 +10,6 @@
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Andrew Ferguson (Symbian) * Andrew Ferguson (Symbian)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom; package org.eclipse.cdt.internal.core.pdom.dom;
import java.net.URI; import java.net.URI;
@ -90,8 +89,6 @@ public class PDOMMacro implements IIndexMacro, IIndexFragmentBinding, IASTFileLo
} }
db.putInt(fRecord + PARAMETERS, db.newString(buf.toString().toCharArray()).getRecord()); db.putInt(fRecord + PARAMETERS, db.newString(buf.toString().toCharArray()).getRecord());
} }
container.addDefinition(this);
} }
public PDOMMacro(PDOM pdom, PDOMMacroContainer container, IASTPreprocessorUndefStatement undef, PDOMFile file) throws CoreException { public PDOMMacro(PDOM pdom, PDOMMacroContainer container, IASTPreprocessorUndefStatement undef, PDOMFile file) throws CoreException {
@ -109,6 +106,8 @@ public class PDOMMacro implements IIndexMacro, IIndexFragmentBinding, IASTFileLo
db.putInt(fRecord + FILE, file.getRecord()); db.putInt(fRecord + FILE, file.getRecord());
db.putInt(fRecord + NAME_OFFSET, fileloc.getNodeOffset()); db.putInt(fRecord + NAME_OFFSET, fileloc.getNodeOffset());
db.putShort(fRecord + NAME_LENGTH, (short) fileloc.getNodeLength()); db.putShort(fRecord + NAME_LENGTH, (short) fileloc.getNodeLength());
container.addDefinition(this);
} }
public PDOM getPDOM() { public PDOM getPDOM() {

View file

@ -345,9 +345,9 @@ public class IndexUI {
throws CoreException { throws CoreException {
ITranslationUnit tu= getTranslationUnit(preferProject, macro.getFileLocation()); ITranslationUnit tu= getTranslationUnit(preferProject, macro.getFileLocation());
if (tu != null) { if (tu != null) {
IIndexName def= macro.getDefinition(); IIndexName name= macro.getDefinition();
if (def != null) { if (name != null) {
IRegion region= new Region(def.getNodeOffset(), def.getNodeLength()); IRegion region= new Region(name.getNodeOffset(), name.getNodeLength());
long timestamp= macro.getFile().getTimestamp(); long timestamp= macro.getFile().getTimestamp();
return CElementHandleFactory.create(tu, macro, region, timestamp); return CElementHandleFactory.create(tu, macro, region, timestamp);
} }