mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Test cases and fixes for the location map
This commit is contained in:
parent
bad4dcae70
commit
ac3d4db76b
8 changed files with 101 additions and 60 deletions
|
@ -38,21 +38,30 @@ import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit.IDependencyTree;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit.IDependencyTree.IASTInclusionNode;
|
||||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner.ILocationCtx;
|
import org.eclipse.cdt.internal.core.parser.scanner.ILocationCtx;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner.IPreprocessorMacro;
|
import org.eclipse.cdt.internal.core.parser.scanner.ImageLocationInfo;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner.LocationMap;
|
import org.eclipse.cdt.internal.core.parser.scanner.LocationMap;
|
||||||
|
|
||||||
public class LocationMapTests extends BaseTestCase {
|
public class LocationMapTests extends BaseTestCase {
|
||||||
private static final String FN = "filename";
|
private static final String FN = "filename";
|
||||||
private static final int ROLE_DEFINITION = IASTNameOwner.r_definition;
|
private static final int ROLE_DEFINITION = IASTNameOwner.r_definition;
|
||||||
private static final int ROLE_UNCLEAR = IASTNameOwner.r_unclear;
|
private static final int ROLE_UNCLEAR = IASTNameOwner.r_unclear;
|
||||||
|
private static final int ROLE_REFERENCE = IASTNameOwner.r_reference;
|
||||||
private static final ASTNodeProperty PROP_PST = IASTTranslationUnit.PREPROCESSOR_STATEMENT;
|
private static final ASTNodeProperty PROP_PST = IASTTranslationUnit.PREPROCESSOR_STATEMENT;
|
||||||
final static char[] DIGITS= "0123456789abcdef".toCharArray();
|
final static char[] DIGITS= "0123456789abcdef".toCharArray();
|
||||||
|
final static char[] LONGDIGITS= new char[1024];
|
||||||
|
static {
|
||||||
|
for (int i = 0; i < LONGDIGITS.length; i++) {
|
||||||
|
LONGDIGITS[i]= (char) i;
|
||||||
|
}
|
||||||
|
}
|
||||||
private LocationMap fLocationMap;
|
private LocationMap fLocationMap;
|
||||||
private CPPASTTranslationUnit fTu;
|
private CPPASTTranslationUnit fTu;
|
||||||
|
|
||||||
|
@ -227,7 +236,7 @@ public class LocationMapTests extends BaseTestCase {
|
||||||
checkASTNode(st, fTu, PROP_PST, filename, offset, length, line, line, directive);
|
checkASTNode(st, fTu, PROP_PST, filename, offset, length, line, line, directive);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkMacroDefinition(IASTPreprocessorMacroDefinition macro, IBinding binding, String image, String name,
|
private void checkMacroDefinition(IASTPreprocessorMacroDefinition macro, IMacroBinding binding, String image, String name,
|
||||||
String nameImage, String expansion, String[] parameters,
|
String nameImage, String expansion, String[] parameters,
|
||||||
String filename, int offset, int length, int line, int nameOffset, int nameLength) {
|
String filename, int offset, int length, int line, int nameOffset, int nameLength) {
|
||||||
assertEquals(expansion, macro.getExpansion());
|
assertEquals(expansion, macro.getExpansion());
|
||||||
|
@ -243,6 +252,12 @@ public class LocationMapTests extends BaseTestCase {
|
||||||
checkASTNode(mp, fd, IASTPreprocessorFunctionStyleMacroDefinition.PARAMETER, filename, -1, 0, -1, 0, null);
|
checkASTNode(mp, fd, IASTPreprocessorFunctionStyleMacroDefinition.PARAMETER, filename, -1, 0, -1, 0, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int expectCount= offset >= 0 ? 1 : 0;
|
||||||
|
IASTName[] decls= fLocationMap.getDeclarations(binding);
|
||||||
|
assertEquals(expectCount, decls.length);
|
||||||
|
if (expectCount > 0) {
|
||||||
|
assertSame(macro.getName(), decls[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkMacroUndef(IASTPreprocessorStatement s, IBinding binding, String image, String name, String nameImage,
|
private void checkMacroUndef(IASTPreprocessorStatement s, IBinding binding, String image, String name, String nameImage,
|
||||||
|
@ -394,9 +409,9 @@ public class LocationMapTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIndexDefine() {
|
public void testIndexDefine() {
|
||||||
IPreprocessorMacro macro1= new TestMacro("n1", "exp1", null);
|
IMacroBinding macro1= new TestMacro("n1", "exp1", null);
|
||||||
final String[] params = new String[]{"p1", "p2"};
|
final String[] params = new String[]{"p1", "p2"};
|
||||||
IPreprocessorMacro macro2= new TestMacro("n2", "exp2", params);
|
IMacroBinding macro2= new TestMacro("n2", "exp2", params);
|
||||||
init(DIGITS);
|
init(DIGITS);
|
||||||
fLocationMap.registerMacroFromIndex(macro1, "fidx1", 0, 0, 0);
|
fLocationMap.registerMacroFromIndex(macro1, "fidx1", 0, 0, 0);
|
||||||
fLocationMap.registerMacroFromIndex(macro2, "fidx2", 1, 4, 8);
|
fLocationMap.registerMacroFromIndex(macro2, "fidx2", 1, 4, 8);
|
||||||
|
@ -407,7 +422,7 @@ public class LocationMapTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUndefine() {
|
public void testUndefine() {
|
||||||
IPreprocessorMacro macro1= new TestMacro("n1", "exp1", null);
|
IMacroBinding macro1= new TestMacro("n1", "exp1", null);
|
||||||
|
|
||||||
init(DIGITS);
|
init(DIGITS);
|
||||||
fLocationMap.encounterPoundUndef(null, 0, 0, 0, 0, "n1".toCharArray());
|
fLocationMap.encounterPoundUndef(null, 0, 0, 0, 0, "n1".toCharArray());
|
||||||
|
@ -418,6 +433,36 @@ public class LocationMapTests extends BaseTestCase {
|
||||||
checkMacroUndef(prep[1], macro1, new String(DIGITS), "n2", "3456", FN, 0, 16, 1, 3, 4);
|
checkMacroUndef(prep[1], macro1, new String(DIGITS), "n2", "3456", FN, 0, 16, 1, 3, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testMacroExpansion() {
|
||||||
|
ImageLocationInfo ili= new ImageLocationInfo();
|
||||||
|
IMacroBinding macro1= new TestMacro("n1", "exp1", null);
|
||||||
|
IMacroBinding macro2= new TestMacro("n2", "exp2", null);
|
||||||
|
IMacroBinding macro3= new TestMacro("n3", "exp3", null);
|
||||||
|
init(LONGDIGITS);
|
||||||
|
assertEquals(1, fLocationMap.getCurrentLineNumber('\n'));
|
||||||
|
assertEquals(2, fLocationMap.getCurrentLineNumber('\n'+1));
|
||||||
|
fLocationMap.registerPredefinedMacro(macro1);
|
||||||
|
fLocationMap.registerMacroFromIndex(macro2, "ifile", 2, 12, 32);
|
||||||
|
fLocationMap.encounterPoundDefine(3, 13, 33, 63, 103, macro3);
|
||||||
|
IASTName name1= fLocationMap.encounterImplicitMacroExpansion(macro1, ili);
|
||||||
|
IASTName name2= fLocationMap.encounterImplicitMacroExpansion(macro2, ili);
|
||||||
|
fLocationMap.pushMacroExpansion(110, 115, 125, 30, macro3, new IASTName[]{name1, name2}, new ImageLocationInfo[0]);
|
||||||
|
fLocationMap.encounteredComment(12, 23, false);
|
||||||
|
checkComment(fLocationMap.getComments()[0], new String(LONGDIGITS, 110, 15), false, FN, 110, 15, 2, 2);
|
||||||
|
|
||||||
|
IASTName[] refs= fLocationMap.getReferences(macro1);
|
||||||
|
assertEquals(1, refs.length);
|
||||||
|
checkName(refs[0], macro1, "n1", fTu, IASTTranslationUnit.EXPANSION_NAME, ROLE_REFERENCE, FN, 110, 15, 2, 2, new String(LONGDIGITS, 110, 15));
|
||||||
|
|
||||||
|
refs= fLocationMap.getReferences(macro2);
|
||||||
|
assertEquals(1, refs.length);
|
||||||
|
checkName(refs[0], macro2, "n2", fTu, IASTTranslationUnit.EXPANSION_NAME, ROLE_REFERENCE, FN, 110, 15, 2, 2, new String(LONGDIGITS, 110, 15));
|
||||||
|
|
||||||
|
refs= fLocationMap.getReferences(macro3);
|
||||||
|
assertEquals(1, refs.length);
|
||||||
|
checkName(refs[0], macro3, "n3", fTu, IASTTranslationUnit.EXPANSION_NAME, ROLE_REFERENCE, FN, 110, 5, 2, 2, new String(LONGDIGITS, 110, 5));
|
||||||
|
}
|
||||||
|
|
||||||
public void testContexts() {
|
public void testContexts() {
|
||||||
init(DIGITS);
|
init(DIGITS);
|
||||||
assertEquals(FN, fLocationMap.getTranslationUnitPath());
|
assertEquals(FN, fLocationMap.getTranslationUnitPath());
|
||||||
|
@ -485,5 +530,28 @@ public class LocationMapTests extends BaseTestCase {
|
||||||
checkLocation(fLocationMap.getMappedFileLocation(36, 0), "pre2", 0, 0, 1, 1);
|
checkLocation(fLocationMap.getMappedFileLocation(36, 0), "pre2", 0, 0, 1, 1);
|
||||||
checkLocation(fLocationMap.getMappedFileLocation(45, 0), "pre2", 9, 0, 1, 1);
|
checkLocation(fLocationMap.getMappedFileLocation(45, 0), "pre2", 9, 0, 1, 1);
|
||||||
checkLocation(fLocationMap.getMappedFileLocation(46, 0), FN, 0, 0, 1, 1);
|
checkLocation(fLocationMap.getMappedFileLocation(46, 0), FN, 0, 0, 1, 1);
|
||||||
|
|
||||||
|
checkLocation(fLocationMap.getMappedFileLocation(0, 7), FN, 0, 0, 1, 1);
|
||||||
|
checkLocation(fLocationMap.getMappedFileLocation(6, 10), "pre1", 0, 9, 1, 1);
|
||||||
|
checkLocation(fLocationMap.getMappedFileLocation(6, 20), "pre1", 0, 10, 1, 1);
|
||||||
|
checkLocation(fLocationMap.getMappedFileLocation(15, 11), "pre1", 6, 4, 1, 1);
|
||||||
|
checkLocation(fLocationMap.getMappedFileLocation(25, 2), FN, 0, 0, 1, 1);
|
||||||
|
checkLocation(fLocationMap.getMappedFileLocation(26, 5), FN, 0, 0, 1, 1);
|
||||||
|
checkLocation(fLocationMap.getMappedFileLocation(30, 7), FN, 0, 0, 1, 1);
|
||||||
|
checkLocation(fLocationMap.getMappedFileLocation(36, 11), FN, 0, 0, 1, 1);
|
||||||
|
checkLocation(fLocationMap.getMappedFileLocation(46, 5), FN, 0, 1, 1, 1);
|
||||||
|
|
||||||
|
IDependencyTree tree= fLocationMap.getDependencyTree();
|
||||||
|
assertEquals(FN, tree.getTranslationUnitPath());
|
||||||
|
IASTInclusionNode[] inclusions= tree.getInclusions();
|
||||||
|
assertEquals(2, inclusions.length);
|
||||||
|
checkInclude(inclusions[0].getIncludeDirective(), "", "", "pre1", "pre1", false, true, FN, 0, 0, 1, 0, 0);
|
||||||
|
checkInclude(inclusions[1].getIncludeDirective(), "", "", "pre2", "pre2", false, true, FN, 0, 0, 1, 0, 0);
|
||||||
|
assertEquals(0, inclusions[1].getNestedInclusions().length);
|
||||||
|
|
||||||
|
inclusions= inclusions[0].getNestedInclusions();
|
||||||
|
assertEquals(1, inclusions.length);
|
||||||
|
checkInclude(inclusions[0].getIncludeDirective(), "b4b", "4", "pre11", "pre11", false, true, "pre1", 6, 3, 1, 7, 1);
|
||||||
|
assertEquals(0, inclusions[0].getNestedInclusions().length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,11 @@ package org.eclipse.cdt.core.parser.tests.scanner;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ILinkage;
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner.IPreprocessorMacro;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
final class TestMacro implements IPreprocessorMacro {
|
final class TestMacro implements IMacroBinding {
|
||||||
private String fName;
|
private String fName;
|
||||||
private String fExpansion;
|
private String fExpansion;
|
||||||
private String[] fParams;
|
private String[] fParams;
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,16 +128,8 @@ class ASTBuiltinName extends ASTPreprocessorDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ASTMacroReferenceName extends ASTPreprocessorName {
|
class ASTMacroReferenceName extends ASTPreprocessorName {
|
||||||
public ASTMacroReferenceName(IASTNode parent, IPreprocessorMacro macro, ImageLocationInfo imgLocationInfo) {
|
public ASTMacroReferenceName(IASTNode parent, int offset, int endOffset, IMacroBinding macro, ImageLocationInfo imgLocationInfo) {
|
||||||
super(parent, IASTTranslationUnit.EXPANSION_NAME, 0, 0, macro.getNameCharArray(), macro);
|
super(parent, IASTTranslationUnit.EXPANSION_NAME, offset, endOffset, macro.getNameCharArray(), macro);
|
||||||
}
|
|
||||||
|
|
||||||
public String getContainingFilename() {
|
|
||||||
return getTranslationUnit().getContainingFilename();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRawSignature() {
|
|
||||||
return toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReference() {
|
public boolean isReference() {
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* Markus Schorn - initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface for the location map when using the macros from the preprocessor.
|
|
||||||
* @since 5.0
|
|
||||||
*/
|
|
||||||
public interface IPreprocessorMacro extends ILocationCtx, IMacroBinding {
|
|
||||||
|
|
||||||
}
|
|
|
@ -16,6 +16,6 @@ package org.eclipse.cdt.internal.core.parser.scanner;
|
||||||
*
|
*
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
class ImageLocationInfo {
|
public class ImageLocationInfo {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,13 +203,15 @@ class ContainerLocationCtx extends LocationCtx {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getInclusions(ArrayList result) {
|
public void getInclusions(ArrayList result) {
|
||||||
for (Iterator iterator = fChildren.iterator(); iterator.hasNext();) {
|
if (fChildren != null) {
|
||||||
LocationCtx ctx= (LocationCtx) iterator.next();
|
for (Iterator iterator = fChildren.iterator(); iterator.hasNext();) {
|
||||||
if (ctx.getInclusionStatement() != null) {
|
LocationCtx ctx= (LocationCtx) iterator.next();
|
||||||
result.add(new ASTInclusionNode(ctx));
|
if (ctx.getInclusionStatement() != null) {
|
||||||
}
|
result.add(new ASTInclusionNode(ctx));
|
||||||
else {
|
}
|
||||||
ctx.getInclusions(result);
|
else {
|
||||||
|
ctx.getInclusions(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class LocationMap implements ILocationResolver {
|
||||||
registerPredefinedMacro(macro, null, -1, -1, -1);
|
registerPredefinedMacro(macro, null, -1, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerMacroFromIndex(IPreprocessorMacro macro, String filename, int nameOffset, int nameEndOffset, int expansionOffset) {
|
public void registerMacroFromIndex(IMacroBinding macro, String filename, int nameOffset, int nameEndOffset, int expansionOffset) {
|
||||||
registerPredefinedMacro(macro, filename, nameOffset, nameEndOffset, expansionOffset);
|
registerPredefinedMacro(macro, filename, nameOffset, nameEndOffset, expansionOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,13 +131,12 @@ public class LocationMap implements ILocationResolver {
|
||||||
* @param macro the macro that has been expanded
|
* @param macro the macro that has been expanded
|
||||||
* @param imageLocationInfo the image-location for the name of the macro.
|
* @param imageLocationInfo the image-location for the name of the macro.
|
||||||
*/
|
*/
|
||||||
public IASTName encounterImplicitMacroExpansion(IPreprocessorMacro macro, ImageLocationInfo imageLocationInfo) {
|
public IASTName encounterImplicitMacroExpansion(IMacroBinding macro, ImageLocationInfo imageLocationInfo) {
|
||||||
return new ASTMacroReferenceName(fTranslationUnit, macro, imageLocationInfo);
|
return new ASTMacroReferenceName(fTranslationUnit, 0, 0, macro, imageLocationInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new context for the result of a (recursive) macro-expansion.
|
* Creates a new context for the result of a (recursive) macro-expansion.
|
||||||
* @param startOffset offset within the current context where macro-expansion starts.
|
|
||||||
* @param nameOffset offset within the current context where the name for the macro-expansion starts.
|
* @param nameOffset offset within the current context where the name for the macro-expansion starts.
|
||||||
* @param nameEndOffset offset within the current context where the name for the macro-expansion ends.
|
* @param nameEndOffset offset within the current context where the name for the macro-expansion ends.
|
||||||
* @param endOffset offset within the current context where the entire macro-expansion ends.
|
* @param endOffset offset within the current context where the entire macro-expansion ends.
|
||||||
|
@ -145,31 +144,30 @@ public class LocationMap implements ILocationResolver {
|
||||||
* @param implicitMacroReferences an array of implicit macro-expansions.
|
* @param implicitMacroReferences an array of implicit macro-expansions.
|
||||||
* @param imageLocations an array of image-locations for the new context.
|
* @param imageLocations an array of image-locations for the new context.
|
||||||
*/
|
*/
|
||||||
public ILocationCtx pushMacroExpansion(int startOffset, int nameOffset, int nameEndOffset, int endOffset, int contextLength,
|
public ILocationCtx pushMacroExpansion(int nameOffset, int nameEndOffset, int endOffset, int contextLength,
|
||||||
IPreprocessorMacro macro, IASTName[] implicitMacroReferences, ImageLocationInfo[] imageLocations) {
|
IMacroBinding macro, IASTName[] implicitMacroReferences, ImageLocationInfo[] imageLocations) {
|
||||||
assert fCurrentContext instanceof ContainerLocationCtx;
|
assert fCurrentContext instanceof ContainerLocationCtx;
|
||||||
|
|
||||||
int startNumber= getSequenceNumberForOffset(startOffset);
|
|
||||||
int nameNumber= getSequenceNumberForOffset(nameOffset);
|
int nameNumber= getSequenceNumberForOffset(nameOffset);
|
||||||
int nameEndNumber= getSequenceNumberForOffset(nameEndOffset);
|
int nameEndNumber= getSequenceNumberForOffset(nameEndOffset);
|
||||||
int endNumber= getSequenceNumberForOffset(endOffset);
|
int endNumber= getSequenceNumberForOffset(endOffset);
|
||||||
|
final int length= endNumber-nameNumber;
|
||||||
|
|
||||||
for (int i = 0; i < implicitMacroReferences.length; i++) {
|
for (int i = 0; i < implicitMacroReferences.length; i++) {
|
||||||
ASTMacroReferenceName name = (ASTMacroReferenceName) implicitMacroReferences[i];
|
ASTMacroReferenceName name = (ASTMacroReferenceName) implicitMacroReferences[i];
|
||||||
name.setOffsetAndLength(startNumber, endNumber);
|
name.setOffsetAndLength(nameNumber, length);
|
||||||
addExpansion((IPreprocessorMacro) name.getBinding(), name);
|
addExpansion((IMacroBinding) name.getBinding(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASTPreprocessorName expansion= new ASTPreprocessorName(fTranslationUnit, IASTTranslationUnit.EXPANSION_NAME,
|
ASTMacroReferenceName expansion= new ASTMacroReferenceName(fTranslationUnit, nameNumber, nameEndNumber, macro, null);
|
||||||
nameNumber, nameEndNumber, macro.getNameCharArray(), macro);
|
|
||||||
addExpansion(macro, expansion);
|
addExpansion(macro, expansion);
|
||||||
|
|
||||||
fCurrentContext= new MacroExpansionCtx((ContainerLocationCtx) fCurrentContext, startOffset, endOffset, endNumber, contextLength, imageLocations, expansion);
|
fCurrentContext= new MacroExpansionCtx((ContainerLocationCtx) fCurrentContext, nameOffset, endOffset, endNumber, contextLength, imageLocations, expansion);
|
||||||
fLastChildInsertionOffset= 0;
|
fLastChildInsertionOffset= 0;
|
||||||
return fCurrentContext;
|
return fCurrentContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addExpansion(IPreprocessorMacro macro, ASTPreprocessorName name) {
|
private void addExpansion(IMacroBinding macro, ASTPreprocessorName name) {
|
||||||
List list= (List) fMacroExpansions.get(macro);
|
List list= (List) fMacroExpansions.get(macro);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list= new ArrayList();
|
list= new ArrayList();
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ILinkage;
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.parser.Keywords;
|
import org.eclipse.cdt.core.parser.Keywords;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
|
@ -20,7 +21,7 @@ import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||||
* Models macros used by the preprocessor
|
* Models macros used by the preprocessor
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
abstract class PreprocessorMacro implements IPreprocessorMacro {
|
abstract class PreprocessorMacro implements IMacroBinding {
|
||||||
final private char[] fName;
|
final private char[] fName;
|
||||||
|
|
||||||
public PreprocessorMacro(char[] name) {
|
public PreprocessorMacro(char[] name) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue