public void testObjectStyleMacroExpansionSimpleDeclarator() throws Exception { StringBuffer buffer = new StringBuffer("#define ABC D\n"); // $NON-NLS-1$ buffer.append("int ABC;"); // $NON-NLS-1$ String code = buffer.toString(); for (ParserLanguage language : languages) { IASTTranslationUnit tu = parse(code, language); IASTPreprocessorObjectStyleMacroDefinition ABC = (IASTPreprocessorObjectStyleMacroDefinition) tu.getMacroDefinitions()[0]; IASTSimpleDeclaration var = (IASTSimpleDeclaration) tu.getDeclarations()[0]; IASTDeclarator d = var.getDeclarators()[0]; assertEquals(d.getName().toString(), "D"); // $NON-NLS-1$ IASTNodeLocation[] declaratorLocations = d.getNodeLocations(); assertEquals(declaratorLocations.length, 1); IASTMacroExpansionLocation expansion = (IASTMacroExpansionLocation) declaratorLocations[0]; IASTPreprocessorObjectStyleMacroDefinition fromExpansion = (IASTPreprocessorObjectStyleMacroDefinition) expansion.getExpansion().getMacroDefinition(); assertEqualsMacros(fromExpansion, ABC); assertEquals(expansion.getNodeOffset(), 0); assertEquals(expansion.getNodeLength(), 1); IASTNodeLocation[] macroLocation = expansion.getExpansion().getNodeLocations(); assertEquals(macroLocation.length, 1); assertTrue(macroLocation[0] instanceof IASTFileLocation); assertEquals( macroLocation[0].getNodeOffset(), code.indexOf("int ABC;") + "int ".length()); // $NON-NLS-1$ //$NON-NLS-2$ assertEquals(macroLocation[0].getNodeLength(), "ABC".length()); // $NON-NLS-1$ } }