mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Removes DOMScanner and related classes, cleans up interfaces IScanner and IIndexMacro, (bug 212864).
This commit is contained in:
parent
74659247c5
commit
1e43fc3186
96 changed files with 483 additions and 15543 deletions
|
@ -12,7 +12,6 @@ Export-Package: org.eclipse.cdt.core.cdescriptor.tests,
|
|||
org.eclipse.cdt.core.parser.tests,
|
||||
org.eclipse.cdt.core.parser.tests.ast2,
|
||||
org.eclipse.cdt.core.parser.tests.prefix,
|
||||
org.eclipse.cdt.core.parser.tests.scanner2,
|
||||
org.eclipse.cdt.core.suite,
|
||||
org.eclipse.cdt.core.testplugin,
|
||||
org.eclipse.cdt.core.testplugin.util,
|
||||
|
|
|
@ -23,7 +23,6 @@ import junit.framework.TestSuite;
|
|||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.IInclude;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
|
||||
/**
|
||||
* @author bnicolle
|
||||
|
@ -31,14 +30,11 @@ import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
|||
*/
|
||||
public class IIncludeTests extends IntegratedCModelTest {
|
||||
|
||||
private boolean fUseCPreprocessor;
|
||||
|
||||
/**
|
||||
* @param string
|
||||
*/
|
||||
public IIncludeTests(String string) {
|
||||
super( string );
|
||||
fUseCPreprocessor= !DOMScanner.PROP_VALUE.equals(System.getProperty("scanner"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,9 +90,6 @@ public class IIncludeTests extends IntegratedCModelTest {
|
|||
expectIncludes.put("resync_after_bad_parse_2", Boolean.FALSE);
|
||||
expectIncludes.put("one", Boolean.FALSE); // C-spec does not allow this, gcc warns and includes, so we should include it, also.
|
||||
expectIncludes.put("resync_after_bad_parse_3", Boolean.FALSE);
|
||||
if (!fUseCPreprocessor) {
|
||||
expectIncludes.put("invalid.h", Boolean.FALSE); // C-spec does not allow this, but that's OK for our present purposes
|
||||
}
|
||||
expectIncludes.put("myInclude1.h", Boolean.FALSE);
|
||||
expectIncludes.put("vers2.h", Boolean.FALSE);
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ import org.eclipse.cdt.core.parser.NullLogService;
|
|||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.tests.scanner.FileCodeReaderFactory;
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
|
@ -73,8 +74,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.FileCodeReaderFactory;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
@ -82,7 +81,6 @@ import org.eclipse.cdt.internal.core.parser.scanner2.FileCodeReaderFactory;
|
|||
public class AST2BaseTest extends BaseTestCase {
|
||||
|
||||
private static final IParserLogService NULL_LOG = new NullLogService();
|
||||
protected boolean fUsesCPreprocessor= false;
|
||||
|
||||
public AST2BaseTest() {
|
||||
super();
|
||||
|
@ -112,7 +110,6 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems , boolean parseComments) throws ParserException {
|
||||
IScanner scanner = createScanner(new CodeReader(code.toCharArray()), lang, ParserMode.COMPLETE_PARSE,
|
||||
new ScannerInfo(), parseComments);
|
||||
fUsesCPreprocessor= scanner instanceof CPreprocessor;
|
||||
ISourceCodeParser parser2 = null;
|
||||
if( lang == ParserLanguage.CPP )
|
||||
{
|
||||
|
@ -165,15 +162,8 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
else
|
||||
configuration = new GPPScannerExtensionConfiguration();
|
||||
IScanner scanner;
|
||||
if (!DOMScanner.PROP_VALUE.equals(System.getProperty("scanner"))) {
|
||||
scanner= new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration,
|
||||
FileCodeReaderFactory.getInstance());
|
||||
}
|
||||
else {
|
||||
scanner = new DOMScanner( codeReader, scannerInfo, mode, lang, NULL_LOG, configuration,
|
||||
FileCodeReaderFactory.getInstance() );
|
||||
scanner.setScanComments(parseComments);
|
||||
}
|
||||
scanner= new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration,
|
||||
FileCodeReaderFactory.getInstance());
|
||||
return scanner;
|
||||
}
|
||||
|
||||
|
|
|
@ -3588,7 +3588,7 @@ public class AST2Tests extends AST2BaseTest {
|
|||
assertEquals("1", macroDefinitions[0].getExpansion());
|
||||
assertEquals("1", macroDefinitions[1].getExpansion());
|
||||
// regression test for #64268 and #71733 which also handle comments
|
||||
String expectExpansion= fUsesCPreprocessor ? "1 + 2" : "1 + 2";
|
||||
String expectExpansion= "1 + 2";
|
||||
assertEquals(expectExpansion, macroDefinitions[2].getExpansion());
|
||||
assertEquals("(KDebugNum(x))", macroDefinitions[3].getExpansion());
|
||||
assertEquals("{if((DEBUGNUM(a)))p;}", macroDefinitions[4].getExpansion());
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class DOMLocationMacroTests extends AST2BaseTest {
|
|||
IASTPreprocessorObjectStyleMacroDefinition fromExpansion = (IASTPreprocessorObjectStyleMacroDefinition) expansion.getMacroDefinition();
|
||||
assertEqualsMacros( fromExpansion, ABC );
|
||||
assertEquals( expansion.getNodeOffset(), 0 );
|
||||
assertEquals( fUsesCPreprocessor ? 2 : 3, expansion.getNodeLength() );
|
||||
assertEquals( 2, expansion.getNodeLength() );
|
||||
IASTNodeLocation [] macroLocation = expansion.getExpansionLocations();
|
||||
assertEquals( macroLocation.length, 1 );
|
||||
assertTrue( macroLocation[0] instanceof IASTFileLocation );
|
||||
|
@ -99,7 +99,7 @@ public class DOMLocationMacroTests extends AST2BaseTest {
|
|||
IASTNodeLocation [] nameLocations = n.getNodeLocations();
|
||||
assertEquals( nameLocations.length, 1 );
|
||||
final IASTMacroExpansion nodeLocation = (IASTMacroExpansion) nameLocations[0];
|
||||
assertEquals( nodeLocation.getNodeOffset(), fUsesCPreprocessor ? 1 : 2 );
|
||||
assertEquals( nodeLocation.getNodeOffset(), 1 );
|
||||
assertEquals( nodeLocation.getNodeLength(), 1 );
|
||||
|
||||
assertEquals( nodeLocation.getExpansionLocations()[0].getNodeOffset(), macroLocation[0].getNodeOffset() );
|
||||
|
@ -132,7 +132,7 @@ public class DOMLocationMacroTests extends AST2BaseTest {
|
|||
IASTMacroExpansion expansion = (IASTMacroExpansion) declSpecLocations[0];
|
||||
assertEqualsMacros( defXYZ, expansion.getMacroDefinition() );
|
||||
assertEquals( expansion.getNodeOffset(), 0 );
|
||||
assertEquals( expansion.getNodeLength(), fUsesCPreprocessor ? 1 : "const".length() );
|
||||
assertEquals( expansion.getNodeLength(), 1 );
|
||||
IASTNodeLocation [] expansionLocations = expansion.getExpansionLocations();
|
||||
assertEquals( expansionLocations.length, 1 );
|
||||
assertTrue( expansionLocations[0] instanceof IASTFileLocation );
|
||||
|
@ -169,8 +169,7 @@ public class DOMLocationMacroTests extends AST2BaseTest {
|
|||
final IASTPreprocessorMacroDefinition C_PO2 = mac_loc.getMacroDefinition();
|
||||
assertEqualsMacros( C_PO, C_PO2 );
|
||||
assertEquals( 0, mac_loc.getNodeOffset());
|
||||
assertEquals( fUsesCPreprocessor ? 2 :
|
||||
4+ C_PO.getExpansion().length() + XYZ.getExpansion().length() + PO.getExpansion().length(), mac_loc.getNodeLength() );
|
||||
assertEquals( 2, mac_loc.getNodeLength() );
|
||||
IASTFileLocation end_loc = (IASTFileLocation) locations[2];
|
||||
assertEquals( code.indexOf( " var"), end_loc.getNodeOffset() ); //$NON-NLS-1$
|
||||
assertEquals( " var;".length(), end_loc.getNodeLength() ); //$NON-NLS-1$
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||
|
||||
|
@ -581,7 +581,7 @@ public class DOMLocationTests extends AST2BaseTest {
|
|||
assertEquals( 2, decls.length);
|
||||
assertEquals( 1, statements.length);
|
||||
assertEquals( 1, problems.length);
|
||||
assertSoleLocation(problems[0], code, fUsesCPreprocessor ? "nix(y," : "z");
|
||||
assertSoleLocation(problems[0], code, "nix(y,");
|
||||
assertSoleLocation( decls[1], code, "int x;");
|
||||
}
|
||||
}
|
||||
|
@ -600,7 +600,7 @@ public class DOMLocationTests extends AST2BaseTest {
|
|||
assertEquals( 1, decls.length);
|
||||
assertEquals( 2, problems.length);
|
||||
assertSoleLocation(problems[0], code, "#include \"\"");
|
||||
assertSoleLocation(problems[1], code, fUsesCPreprocessor ? "#else" : "else");
|
||||
assertSoleLocation(problems[1], code, "#else");
|
||||
assertSoleLocation( decls[0], code, "int x;");
|
||||
}
|
||||
}
|
||||
|
@ -721,7 +721,7 @@ public class DOMLocationTests extends AST2BaseTest {
|
|||
assertEquals(IASTProblem.PREPROCESSOR_INVALID_DIRECTIVE, problems[2].getID());
|
||||
assertSoleLocation(problems[0], code, "#import \"include_once.h\"");
|
||||
assertSoleLocation(problems[1], code, "\"deprecated include\"");
|
||||
assertSoleLocation(problems[2], code, fUsesCPreprocessor ? "#invalid" : "invalid");
|
||||
assertSoleLocation(problems[2], code, "#invalid");
|
||||
}
|
||||
|
||||
// int main(void){
|
||||
|
|
|
@ -26,7 +26,6 @@ public class DOMParserTestSuite extends TestCase {
|
|||
|
||||
public static Test suite() {
|
||||
TestSuite suite= new TestSuite(ParserTestSuite.class.getName());
|
||||
suite.addTest(DOMScannerTests.suite());
|
||||
suite.addTest(AST2Tests.suite());
|
||||
suite.addTestSuite( GCCTests.class );
|
||||
suite.addTest( AST2CPPTests.suite() );
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Emanuel Graf - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Emanuel Graf - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||
|
||||
|
@ -26,7 +26,6 @@ import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.LocationMap.FunctionMacroExpansionLocation;
|
||||
|
||||
/**
|
||||
* @author Emanuel Graf
|
||||
|
@ -182,14 +181,6 @@ public class DOMPreprocessorInformationTest extends AST2BaseTest {
|
|||
|
||||
IASTNodeLocation[] nodeLocations = init.getNodeLocations();
|
||||
assertEquals(1, nodeLocations.length);
|
||||
|
||||
if (!fUsesCPreprocessor) {
|
||||
FunctionMacroExpansionLocation location = (FunctionMacroExpansionLocation) nodeLocations[0];
|
||||
char[][] actualParameters = location.getActualParameters();
|
||||
|
||||
assertEquals("foo", new String(actualParameters[0]));
|
||||
assertEquals("bar", new String(actualParameters[1]));
|
||||
}
|
||||
}
|
||||
|
||||
// #ifdef xxx
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -111,7 +111,7 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
|
|||
writer.write( "__signed__ int signedInt;\n"); //$NON-NLS-1$
|
||||
IASTDeclaration[] decls = parseGCC( writer.toString() ).getDeclarations();
|
||||
|
||||
assertEquals(((IASTASMDeclaration)decls[0]).getAssembly(), "CODE"); //$NON-NLS-1$
|
||||
assertEquals(((IASTASMDeclaration)decls[0]).getAssembly(), "\"CODE\""); //$NON-NLS-1$
|
||||
assertTrue( ((IASTFunctionDefinition)decls[1]).getDeclSpecifier().isInline() );
|
||||
assertTrue( ((IASTSimpleDeclaration)decls[2]).getDeclSpecifier().isConst() );
|
||||
assertTrue( ((IASTSimpleDeclaration)decls[3]).getDeclSpecifier().isVolatile() );
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
package org.eclipse.cdt.core.parser.tests.scanner;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
import org.eclipse.cdt.core.dom.IMacroCollector;
|
|
@ -30,7 +30,6 @@ import org.eclipse.cdt.core.parser.ParserMode;
|
|||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.FileCodeReaderFactory;
|
||||
|
||||
public class PreprocessorSpeedTest {
|
||||
|
||||
|
|
|
@ -11,9 +11,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.scanner;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IProblem;
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
|||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.FileCodeReaderFactory;
|
||||
|
||||
public abstract class PreprocessorTestsBase extends BaseTestCase {
|
||||
|
||||
|
@ -84,7 +83,7 @@ public abstract class PreprocessorTestsBase extends BaseTestCase {
|
|||
initializeScanner(input[0].toString());
|
||||
}
|
||||
|
||||
protected int fullyTokenize() throws Exception {
|
||||
protected void fullyTokenize() throws Exception {
|
||||
try {
|
||||
for(;;) {
|
||||
IToken t= fScanner.nextToken();
|
||||
|
@ -92,7 +91,6 @@ public abstract class PreprocessorTestsBase extends BaseTestCase {
|
|||
}
|
||||
catch ( EndOfFileException e){
|
||||
}
|
||||
return fScanner.getCount();
|
||||
}
|
||||
|
||||
protected void validateToken(int tokenType) throws Exception {
|
||||
|
|
|
@ -1,107 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2007 IBM Corporation 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:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.scanner2;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
* TODO To change the template for this generated type comment go to
|
||||
* Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class DOMScannerSpeedTest extends SpeedTest2 {
|
||||
|
||||
private PrintStream stream;
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
PrintStream stream = null;
|
||||
if (args.length > 0)
|
||||
stream = new PrintStream(new FileOutputStream(args[0]));
|
||||
|
||||
new DOMScannerSpeedTest().runTest(stream, 30);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void test() throws Exception {
|
||||
runTest(10);
|
||||
}
|
||||
|
||||
public void runTest(PrintStream stream, int n) throws Exception {
|
||||
this.stream = stream;
|
||||
runTest(n);
|
||||
}
|
||||
|
||||
private void runTest(int n) throws Exception {
|
||||
String code =
|
||||
"#include <windows.h>\n" +
|
||||
"#include <stdio.h>\n" +
|
||||
"#include <iostream>\n";
|
||||
|
||||
CodeReader reader = new CodeReader(code.toCharArray());
|
||||
IScannerInfo info = getScannerInfo(false);
|
||||
long totalTime = 0;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
long time = testScan(reader, false, info, ParserLanguage.CPP);
|
||||
if (i > 0)
|
||||
totalTime += time;
|
||||
}
|
||||
|
||||
if (n > 1) {
|
||||
System.out.println("Average Time: " + (totalTime / (n - 1)) + " millisecs");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param path
|
||||
* @param quick TODO
|
||||
*/
|
||||
protected long testScan(CodeReader reader, boolean quick, IScannerInfo info, ParserLanguage lang) throws Exception {
|
||||
ParserMode mode = quick ? ParserMode.QUICK_PARSE : ParserMode.COMPLETE_PARSE;
|
||||
DOMScanner scanner = createScanner(reader, info, mode, lang, null, Collections.EMPTY_LIST );
|
||||
long startTime = System.currentTimeMillis();
|
||||
int count = 0;
|
||||
try {
|
||||
while (true) {
|
||||
IToken t = scanner.nextToken();
|
||||
|
||||
if (stream != null)
|
||||
stream.println(t.getImage());
|
||||
|
||||
if (t == null)
|
||||
break;
|
||||
++count;
|
||||
|
||||
}
|
||||
} catch (EndOfFileException e2) {
|
||||
}
|
||||
long totalTime = System.currentTimeMillis() - startTime;
|
||||
System.out.println( "Resulting scan took " + totalTime + " millisecs " +
|
||||
count + " tokens");
|
||||
return totalTime;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,170 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2007 IBM Corporation 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:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.scanner2;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.FileCodeReaderFactory;
|
||||
|
||||
// A test that just calculates the speed of the parser
|
||||
// Eventually, we'll peg a max time and fail the test if it exceeds it
|
||||
public class SpeedTest2 extends TestCase {
|
||||
|
||||
public static DOMScanner createScanner( CodeReader code, IScannerInfo config, ParserMode mode, ParserLanguage language, IParserLogService log, List workingCopies )
|
||||
{
|
||||
IParserLogService logService = ( log == null ) ? ParserFactory.createDefaultLogService() : log;
|
||||
ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode );
|
||||
IScannerExtensionConfiguration configuration = null;
|
||||
if( language == ParserLanguage.C )
|
||||
configuration = new GCCScannerExtensionConfiguration();
|
||||
else
|
||||
configuration = new GPPScannerExtensionConfiguration();
|
||||
return new DOMScanner( code, config, ourMode, language, logService, configuration, FileCodeReaderFactory.getInstance() );
|
||||
}
|
||||
|
||||
|
||||
protected IScannerInfo getScannerInfo(boolean quick) {
|
||||
if (quick)
|
||||
return new ScannerInfo();
|
||||
|
||||
String config = System.getProperty("speedTest.config");
|
||||
|
||||
if (config == null)
|
||||
return mingwScannerInfo(false);
|
||||
|
||||
if (config.equals("msvc"))
|
||||
return msvcScannerInfo(false);
|
||||
else if (config.equals("msvc98"))
|
||||
return msvc98ScannerInfo(false);
|
||||
else if (config.equals("ydl"))
|
||||
return ydlScannerInfo(false);
|
||||
else
|
||||
return mingwScannerInfo(false);
|
||||
}
|
||||
|
||||
private IScannerInfo msvcScannerInfo(boolean quick) {
|
||||
if( quick )
|
||||
return new ScannerInfo();
|
||||
Map definitions = new Hashtable();
|
||||
//definitions.put( "__GNUC__", "3" ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
String [] includePaths = new String[] {
|
||||
"C:\\Program Files\\Microsoft SDK\\Include",
|
||||
"C:\\Program Files\\Microsoft Visual C++ Toolkit 2003\\include"
|
||||
|
||||
// "C:\\Program Files\\Microsoft Visual Studio\\VC98\\Include"
|
||||
};
|
||||
return new ScannerInfo( definitions, includePaths );
|
||||
}
|
||||
|
||||
private IScannerInfo msvc98ScannerInfo(boolean quick) {
|
||||
if( quick )
|
||||
return new ScannerInfo();
|
||||
Map definitions = new Hashtable();
|
||||
|
||||
String [] includePaths = new String[] {
|
||||
"C:\\Program Files\\Microsoft Visual Studio\\VC98\\Include"
|
||||
};
|
||||
return new ScannerInfo( definitions, includePaths );
|
||||
}
|
||||
|
||||
private IScannerInfo mingwScannerInfo(boolean quick) {
|
||||
// TODO It would be easier and more flexible if we used discovery for this
|
||||
if( quick )
|
||||
return new ScannerInfo();
|
||||
Map definitions = new Hashtable();
|
||||
definitions.put("__GNUC__", "3");
|
||||
definitions.put("__GNUC_MINOR__", "2");
|
||||
definitions.put("__GNUC_PATCHLEVEL__", "3");
|
||||
definitions.put("__GXX_ABI_VERSION", "102");
|
||||
definitions.put("_WIN32", "");
|
||||
definitions.put("__WIN32", "");
|
||||
definitions.put("__WIN32__", "");
|
||||
definitions.put("WIN32", "");
|
||||
definitions.put("__MINGW32__", "");
|
||||
definitions.put("__MSVCRT__", "");
|
||||
definitions.put("WINNT", "");
|
||||
definitions.put("_X86_", "1");
|
||||
definitions.put("__WINNT", "");
|
||||
definitions.put("_NO_INLINE__", "");
|
||||
definitions.put("__STDC_HOSTED__", "1");
|
||||
definitions.put("i386", "");
|
||||
definitions.put("__i386", "");
|
||||
definitions.put("__i386__", "");
|
||||
definitions.put("__tune_i586__", "");
|
||||
definitions.put("__tune_pentium__", "");
|
||||
definitions.put("__stdcall", "__attribute__((__stdcall__))");
|
||||
definitions.put("__cdecl", "__attribute__((__cdecl__))");
|
||||
definitions.put("__fastcall", "__attribute__((__fastcall__))");
|
||||
definitions.put("_stdcall", "__attribute__((__stdcall__))");
|
||||
definitions.put("_cdecl", "__attribute__((__cdecl__))");
|
||||
definitions.put("_fastcall", "__attribute__((__fastcall__))");
|
||||
definitions.put("__declspec(x)", "__attribute__((x))");
|
||||
definitions.put("__DEPRECATED", "");
|
||||
definitions.put("__EXCEPTIONS", "");
|
||||
|
||||
String [] includePaths = new String[] {
|
||||
"c:/mingw/include/c++/3.2.3",
|
||||
"c:/mingw/include/c++/3.2.3/mingw32",
|
||||
"c:/mingw/include/c++/3.2.3/backward",
|
||||
"c:/mingw/include",
|
||||
"c:/mingw/lib/gcc-lib/mingw32/3.2.3/include"
|
||||
};
|
||||
|
||||
return new ScannerInfo( definitions, includePaths );
|
||||
}
|
||||
|
||||
private IScannerInfo ydlScannerInfo(boolean quick) {
|
||||
// TODO It would be easier and more flexible if we used discovery for this
|
||||
if( quick )
|
||||
return new ScannerInfo();
|
||||
Map definitions = new Hashtable();
|
||||
definitions.put("__GNUC__", "3");
|
||||
definitions.put("__GNUC_MINOR__", "3");
|
||||
definitions.put("__GNUC_PATCHLEVEL__", "3");
|
||||
definitions.put("_GNU_SOURCE", "");
|
||||
definitions.put("__unix__", "");
|
||||
definitions.put("__gnu_linux__", "");
|
||||
definitions.put("__linux__", "");
|
||||
definitions.put("unix", "");
|
||||
definitions.put("__unix", "");
|
||||
definitions.put("linux", "");
|
||||
definitions.put("__linux", "");
|
||||
definitions.put("__GNUG__", "3");
|
||||
|
||||
String [] includePaths = new String[] {
|
||||
"/usr/include/g++",
|
||||
"/usr/include/g++/powerpc-yellowdog-linux",
|
||||
"/usr/include/g++/backward",
|
||||
"/usr/local/include",
|
||||
"/usr/lib/gcc-lib/powerpc-yellowdog-linux/3.3.3/include",
|
||||
"/usr/include"
|
||||
};
|
||||
|
||||
return new ScannerInfo( definitions, includePaths );
|
||||
}
|
||||
|
||||
}
|
|
@ -417,11 +417,11 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
IIndexMacro[] macros= ifile.getMacros();
|
||||
assertEquals(2, macros.length);
|
||||
IIndexMacro m= macros[0];
|
||||
assertEquals("1", new String(m.getExpansion()));
|
||||
assertEquals("1", new String(m.getExpansionImage()));
|
||||
assertEquals("macro164500", new String(m.getName()));
|
||||
|
||||
m= macros[1];
|
||||
assertEquals("2", new String(m.getExpansion()));
|
||||
assertEquals("2", new String(m.getExpansionImage()));
|
||||
assertEquals("macro164500", new String(m.getName()));
|
||||
}
|
||||
finally {
|
||||
|
|
|
@ -98,13 +98,19 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
|||
assertEquals("FUNC", new String(func.getName()));
|
||||
assertEquals("FUNC2", new String(func2.getName()));
|
||||
|
||||
assertEquals("void foo()", new String(obj.getExpansion()));
|
||||
assertEquals("void bar()", new String(func.getExpansion()));
|
||||
assertEquals("void baz()", new String(func2.getExpansion()));
|
||||
assertEquals("void foo()", new String(obj.getExpansionImage()));
|
||||
assertEquals("void bar()", new String(func.getExpansionImage()));
|
||||
assertEquals("void baz()", new String(func2.getExpansionImage()));
|
||||
|
||||
assertEquals("OBJ", new String(obj.getSignature()));
|
||||
assertEquals("FUNC()", new String(func.getSignature()));
|
||||
assertEquals("FUNC2(A)", new String(func2.getSignature()));
|
||||
assertEquals("OBJ", new String(obj.getName()));
|
||||
assertNull(obj.getParameterList());
|
||||
|
||||
assertEquals("FUNC", new String(func.getName()));
|
||||
assertEquals(0, func.getParameterList().length);
|
||||
|
||||
assertEquals("FUNC2", new String(func2.getName()));
|
||||
assertEquals(1, func2.getParameterList().length);
|
||||
assertEquals("A", new String(func2.getParameterList()[0]));
|
||||
|
||||
IIndexBinding[] bindings= index.findBindings(Pattern.compile(".*"), false, IndexFilter.ALL, NPM);
|
||||
assertEquals(3, bindings.length);
|
||||
|
|
|
@ -54,7 +54,6 @@ Export-Package: org.eclipse.cdt.core,
|
|||
org.eclipse.cdt.internal.core.parser;x-internal:=true,
|
||||
org.eclipse.cdt.internal.core.parser.problem;x-internal:=true,
|
||||
org.eclipse.cdt.internal.core.parser.scanner;x-friends:="org.eclipse.cdt.ui",
|
||||
org.eclipse.cdt.internal.core.parser.scanner2;x-internal:=true,
|
||||
org.eclipse.cdt.internal.core.parser.token;x-friends:="org.eclipse.cdt.ui",
|
||||
org.eclipse.cdt.internal.core.parser.util;x-internal:=true,
|
||||
org.eclipse.cdt.internal.core.pdom;x-friends:="org.eclipse.cdt.ui",
|
||||
|
|
|
@ -121,7 +121,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo {
|
|||
* @since 4.0.1
|
||||
*/
|
||||
public static IndexTypeInfo create(IIndex index, IIndexMacro macro) {
|
||||
final char[] name= macro.getName();
|
||||
final char[] name= macro.getNameCharArray();
|
||||
return new IndexTypeInfo(new String[] {new String(name)}, ICElement.C_MACRO, index);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IMacro;
|
||||
import org.eclipse.cdt.core.index.IIndexMacro;
|
||||
|
||||
/**
|
||||
* Allows an ICodeReaderFactory to retrieve macro definitions from the index,
|
||||
|
@ -27,7 +27,8 @@ import org.eclipse.cdt.core.parser.IMacro;
|
|||
* @since 4.0
|
||||
*
|
||||
*/
|
||||
// mstodo get rid of this interface
|
||||
public interface IMacroCollector {
|
||||
|
||||
public void addDefinition(IMacro macro);
|
||||
public void addMacroDefinition(IIndexMacro macro);
|
||||
}
|
||||
|
|
|
@ -724,16 +724,7 @@ public class ASTSignatureUtil {
|
|||
}
|
||||
|
||||
private static String getLiteralExpression( IASTLiteralExpression expression ){
|
||||
StringBuffer result = new StringBuffer();
|
||||
result.append(expression.toString());
|
||||
if (expression.getKind() == IASTLiteralExpression.lk_string_literal) {
|
||||
// mstodo- old scanner, remove
|
||||
if (result.length() == 0 || result.charAt(0) != '"') {
|
||||
result.insert(0, '"');
|
||||
result.append('"');
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
return expression.toString();
|
||||
}
|
||||
|
||||
private static String getIdExpression( IASTIdExpression expression ){
|
||||
|
|
|
@ -172,15 +172,6 @@ public interface IASTTranslationUnit extends IASTNode, IAdaptable {
|
|||
*/
|
||||
public IASTProblem[] getPreprocessorProblems();
|
||||
|
||||
/**
|
||||
* For a given range of locations, return a String that represents what is there underneath the range.
|
||||
*
|
||||
* @param locations A range of node locations
|
||||
* @return A String signature.
|
||||
* @deprecated was never fully implemented.
|
||||
*/
|
||||
public String getUnpreprocessedSignature(IASTNodeLocation[] locations);
|
||||
|
||||
/**
|
||||
* Get the translation unit's full path.
|
||||
* @return String representation of path.
|
||||
|
@ -246,13 +237,6 @@ public interface IASTTranslationUnit extends IASTNode, IAdaptable {
|
|||
*/
|
||||
public void setIndex(IIndex index);
|
||||
|
||||
/**
|
||||
* Set comments to translation unit.
|
||||
*
|
||||
* @param comment
|
||||
*/
|
||||
public void setComments(IASTComment[] comments);
|
||||
|
||||
/**
|
||||
* In case the ast was created in a way that supports comment parsing,
|
||||
* all comments of the translation unit are returned. Otherwise an
|
||||
|
|
|
@ -7,13 +7,12 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.parser;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IMacro;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.FunctionStyleMacro;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectStyleMacro;
|
||||
|
||||
/**
|
||||
* Abstract scanner extension configuration to help model C/C++ dialects.
|
||||
|
@ -28,6 +27,22 @@ import org.eclipse.cdt.internal.core.parser.scanner2.ObjectStyleMacro;
|
|||
* @since 4.0
|
||||
*/
|
||||
public abstract class AbstractScannerExtensionConfiguration implements IScannerExtensionConfiguration {
|
||||
protected static class MacroDefinition implements IMacro {
|
||||
private char[] fSignature;
|
||||
private char[] fExpansion;
|
||||
|
||||
MacroDefinition(char[] signature, char[] expansion) {
|
||||
fSignature= signature;
|
||||
fExpansion= expansion;
|
||||
}
|
||||
|
||||
public char[] getSignature() {
|
||||
return fSignature;
|
||||
}
|
||||
public char[] getExpansion() {
|
||||
return fExpansion;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration#initializeMacroValuesTo1()
|
||||
|
@ -64,10 +79,8 @@ public abstract class AbstractScannerExtensionConfiguration implements IScannerE
|
|||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration#getAdditionalMacros()
|
||||
*/
|
||||
public CharArrayObjectMap getAdditionalMacros() {
|
||||
|
||||
public IMacro[] getAdditionalMacros() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -80,14 +93,11 @@ public abstract class AbstractScannerExtensionConfiguration implements IScannerE
|
|||
|
||||
/**
|
||||
* Helper method to add an object style macro to the given map.
|
||||
*
|
||||
* @param macros the macro map
|
||||
* @param name the macro name
|
||||
* @param signature the signature of the macro, see {@link IMacro#getSignature()}.
|
||||
* @param value the macro value
|
||||
*/
|
||||
protected void addObjectStyleMacro(CharArrayObjectMap macros, String name, String value) {
|
||||
char[] nameChars= name.toCharArray();
|
||||
macros.put(nameChars, new ObjectStyleMacro(nameChars, value.toCharArray()));
|
||||
protected static IMacro createMacro(String signature, String value) {
|
||||
return new MacroDefinition(signature.toCharArray(), value.toCharArray());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,13 +108,19 @@ public abstract class AbstractScannerExtensionConfiguration implements IScannerE
|
|||
* @param value the macro value
|
||||
* @param arguments the macro arguments
|
||||
*/
|
||||
protected void addFunctionStyleMacro(CharArrayObjectMap macros, String name, String value, String[] arguments) {
|
||||
char[] nameChars= name.toCharArray();
|
||||
char[][] argumentsArray= new char[arguments.length][];
|
||||
protected static IMacro createFunctionStyleMacro(String name, String value, String[] arguments) {
|
||||
StringBuffer buf= new StringBuffer();
|
||||
buf.append(name);
|
||||
buf.append('(');
|
||||
for (int i = 0; i < arguments.length; i++) {
|
||||
argumentsArray[i]= arguments[i].toCharArray();
|
||||
if (i>0) {
|
||||
buf.append(',');
|
||||
}
|
||||
buf.append(arguments[i]);
|
||||
}
|
||||
macros.put(nameChars, new FunctionStyleMacro(nameChars, value.toCharArray(), argumentsArray));
|
||||
buf.append(')');
|
||||
char[] signature= new char[buf.length()];
|
||||
buf.getChars(0, signature.length, signature, 0);
|
||||
return new MacroDefinition(signature, value.toCharArray());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,24 +6,47 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* IBM - Initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.parser;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IMacro;
|
||||
import org.eclipse.cdt.core.parser.IPreprocessorDirective;
|
||||
import org.eclipse.cdt.core.parser.Keywords;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.FunctionStyleMacro;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectStyleMacro;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public abstract class GNUScannerExtensionConfiguration extends AbstractScannerExtensionConfiguration {
|
||||
|
||||
protected static final char[] emptyCharArray = "".toCharArray(); //$NON-NLS-1$
|
||||
private static IMacro[] sAdditionalMacros= new IMacro[] {
|
||||
createMacro("__asm__", "asm"), //$NON-NLS-1$//$NON-NLS-2$
|
||||
createMacro("__complex__", "_Complex"), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
createMacro("__const__", "const"), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
createMacro("__const", "const"), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
createMacro("__extension__", ""), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
createMacro("__inline__", "inline"), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
createMacro("__imag__", "(int)"), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
createMacro("__null", "(void *)0"), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
createMacro("__real__", "(int)"), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
createMacro("__restrict__", "restrict"), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
createMacro("__restrict", "restrict"), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
createMacro("__volatile__", "volatile"), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
createMacro("__signed__", "signed"), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
createMacro("__stdcall", ""), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
createMacro("__typeof__", "typeof"), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
createMacro("__builtin_va_arg(ap,type)", "*(type *)ap"), //$NON-NLS-1$//$NON-NLS-2$
|
||||
createMacro("__builtin_constant_p(exp)", "0") //$NON-NLS-1$//$NON-NLS-2$
|
||||
};
|
||||
|
||||
public static IMacro[] getAdditionalGNUMacros() {
|
||||
return sAdditionalMacros;
|
||||
}
|
||||
|
||||
|
||||
public boolean initializeMacroValuesTo1() {
|
||||
return true;
|
||||
|
@ -37,85 +60,8 @@ public abstract class GNUScannerExtensionConfiguration extends AbstractScannerEx
|
|||
return "ij".toCharArray(); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private static final ObjectStyleMacro __asm__ = new ObjectStyleMacro(
|
||||
"__asm__".toCharArray(), "asm".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
|
||||
private static final ObjectStyleMacro __inline__ = new ObjectStyleMacro(
|
||||
"__inline__".toCharArray(), "inline".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
private static final ObjectStyleMacro __extension__ = new ObjectStyleMacro(
|
||||
"__extension__".toCharArray(), emptyCharArray); //$NON-NLS-1$
|
||||
|
||||
|
||||
private static final ObjectStyleMacro __restrict__ = new ObjectStyleMacro(
|
||||
"__restrict__".toCharArray(), "restrict".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
private static final ObjectStyleMacro __restrict = new ObjectStyleMacro(
|
||||
"__restrict".toCharArray(), "restrict".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
private static final ObjectStyleMacro __volatile__ = new ObjectStyleMacro(
|
||||
"__volatile__".toCharArray(), "volatile".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
private static final ObjectStyleMacro __const__ = new ObjectStyleMacro(
|
||||
"__const__".toCharArray(), "const".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
private static final ObjectStyleMacro __const = new ObjectStyleMacro(
|
||||
"__const".toCharArray(), "const".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
private static final ObjectStyleMacro __signed__ = new ObjectStyleMacro(
|
||||
"__signed__".toCharArray(), "signed".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
private static final ObjectStyleMacro __complex__ = new ObjectStyleMacro(
|
||||
"__complex__".toCharArray(), "_Complex".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
private static final ObjectStyleMacro __real__ = new ObjectStyleMacro(
|
||||
"__real__".toCharArray(), "(int)".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
private static final ObjectStyleMacro __imag__ = new ObjectStyleMacro(
|
||||
"__imag__".toCharArray(), "(int)".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
private static final ObjectStyleMacro __null = new ObjectStyleMacro(
|
||||
"__null".toCharArray(), "(void *)0".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
private static final FunctionStyleMacro __builtin_va_arg = new FunctionStyleMacro(
|
||||
"__builtin_va_arg".toCharArray(), //$NON-NLS-1$
|
||||
"*(type *)ap".toCharArray(), //$NON-NLS-1$
|
||||
new char[][] { "ap".toCharArray(), "type".toCharArray() }); //$NON-NLS-1$//$NON-NLS-2$
|
||||
|
||||
private static final FunctionStyleMacro __builtin_constant_p = new FunctionStyleMacro(
|
||||
"__builtin_constant_p".toCharArray(), //$NON-NLS-1$
|
||||
"0".toCharArray(), //$NON-NLS-1$
|
||||
new char[][] { "exp".toCharArray() }); //$NON-NLS-1$
|
||||
|
||||
// Kludge for MSVC support until we get a real extension
|
||||
private static final ObjectStyleMacro __stdcall = new ObjectStyleMacro(
|
||||
"__stdcall".toCharArray(), emptyCharArray); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public CharArrayObjectMap getAdditionalMacros() {
|
||||
CharArrayObjectMap realDefinitions = new CharArrayObjectMap(16);
|
||||
realDefinitions.put(__inline__.name, __inline__);
|
||||
realDefinitions.put(__const__.name, __const__);
|
||||
realDefinitions.put(__const.name, __const);
|
||||
realDefinitions.put(__extension__.name, __extension__);
|
||||
realDefinitions.put(__restrict__.name, __restrict__);
|
||||
realDefinitions.put(__restrict.name, __restrict);
|
||||
realDefinitions.put(__volatile__.name, __volatile__);
|
||||
realDefinitions.put(__signed__.name, __signed__);
|
||||
realDefinitions.put(__complex__.name, __complex__);
|
||||
realDefinitions.put(__imag__.name, __imag__);
|
||||
realDefinitions.put( __null.name, __null );
|
||||
realDefinitions.put(__real__.name, __real__);
|
||||
realDefinitions.put(__builtin_va_arg.name, __builtin_va_arg);
|
||||
realDefinitions.put(__builtin_constant_p.name, __builtin_constant_p);
|
||||
realDefinitions.put( __asm__.name, __asm__ );
|
||||
|
||||
realDefinitions.put(__stdcall.name, __stdcall);
|
||||
|
||||
return realDefinitions;
|
||||
public IMacro[] getAdditionalMacros() {
|
||||
return sAdditionalMacros;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -6,13 +6,15 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* IBM - Initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.parser;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IMacro;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
|
||||
/**
|
||||
* Scanner extension configuration interface.
|
||||
|
@ -69,19 +71,15 @@ public interface IScannerExtensionConfiguration {
|
|||
* Support for additional keywords.
|
||||
*
|
||||
* @return a mapping of keyword name to one of the constants defined in
|
||||
* {@link org.eclipse.cdt.core.parser.IToken IToken} or
|
||||
* <code>null</code> for no additional keywords.
|
||||
* {@link IToken} or <code>null</code> for no additional keywords.
|
||||
*/
|
||||
public CharArrayIntMap getAdditionalKeywords();
|
||||
|
||||
/**
|
||||
* Support for additional macros.
|
||||
*
|
||||
* @return a mapping of macro name to
|
||||
* {@link org.eclipse.cdt.core.parser.IMacro IMacro} or
|
||||
* <code>null</code> for no additional macros.
|
||||
* @return an array of macros or <code>null</code> for no additional macros.
|
||||
*/
|
||||
public CharArrayObjectMap getAdditionalMacros();
|
||||
public IMacro[] getAdditionalMacros();
|
||||
|
||||
/**
|
||||
* Support for additional preprocessor directives.
|
||||
|
|
|
@ -41,7 +41,6 @@ import org.eclipse.cdt.core.parser.ParserMode;
|
|||
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCLinkageFactory;
|
||||
|
@ -152,11 +151,7 @@ public abstract class AbstractCLanguage extends AbstractLanguage implements ICLa
|
|||
* @return an instance of IScanner
|
||||
*/
|
||||
protected IScanner createScanner(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IParserLogService log) {
|
||||
if (!DOMScanner.PROP_VALUE.equals(System.getProperty("scanner"))) { //$NON-NLS-1$
|
||||
return new CPreprocessor(reader, scanInfo, ParserLanguage.C, log, getScannerExtensionConfiguration(), fileCreator);
|
||||
}
|
||||
return new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, ParserLanguage.C,
|
||||
log, getScannerExtensionConfiguration(), fileCreator);
|
||||
return new CPreprocessor(reader, scanInfo, ParserLanguage.C, log, getScannerExtensionConfiguration(), fileCreator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,15 +14,22 @@ package org.eclipse.cdt.core.dom.parser.c;
|
|||
import org.eclipse.cdt.core.dom.parser.GNUScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.GCCKeywords;
|
||||
import org.eclipse.cdt.core.parser.IGCCToken;
|
||||
import org.eclipse.cdt.core.parser.IMacro;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.FunctionStyleMacro;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfiguration {
|
||||
|
||||
private static IMacro[] sAdditionalMacros;
|
||||
static {
|
||||
final IMacro[] macros = GNUScannerExtensionConfiguration.getAdditionalGNUMacros();
|
||||
sAdditionalMacros= new IMacro[macros.length+1];
|
||||
System.arraycopy(macros, 0, sAdditionalMacros, 0, macros.length);
|
||||
sAdditionalMacros[macros.length]= createMacro("_Pragma(arg)", ""); //$NON-NLS-1$//$NON-NLS-2$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerConfiguration#supportMinAndMaxOperators()
|
||||
*/
|
||||
|
@ -30,19 +37,12 @@ public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfigu
|
|||
return false;
|
||||
}
|
||||
|
||||
private static final FunctionStyleMacro _Pragma = new FunctionStyleMacro(
|
||||
"_Pragma".toCharArray(), //$NON-NLS-1$
|
||||
emptyCharArray,
|
||||
new char[][] { "arg".toCharArray() } ); //$NON-NLS-1$
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerConfiguration#getAdditionalMacros()
|
||||
*/
|
||||
public CharArrayObjectMap getAdditionalMacros() {
|
||||
CharArrayObjectMap result = super.getAdditionalMacros();
|
||||
result.put(_Pragma.name, _Pragma );
|
||||
return result;
|
||||
public IMacro[] getAdditionalMacros() {
|
||||
return sAdditionalMacros;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -40,7 +40,6 @@ import org.eclipse.cdt.core.parser.ParserMode;
|
|||
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkageFactory;
|
||||
|
@ -148,11 +147,7 @@ public abstract class AbstractCPPLanguage extends AbstractLanguage implements IC
|
|||
* @return an instance of IScanner
|
||||
*/
|
||||
protected IScanner createScanner(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IParserLogService log) {
|
||||
if (!DOMScanner.PROP_VALUE.equals(System.getProperty("scanner"))) { //$NON-NLS-1$
|
||||
return new CPreprocessor(reader, scanInfo, ParserLanguage.CPP, log, getScannerExtensionConfiguration(), fileCreator);
|
||||
}
|
||||
return new DOMScanner(reader, scanInfo, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP,
|
||||
log, getScannerExtensionConfiguration(), fileCreator);
|
||||
return new CPreprocessor(reader, scanInfo, ParserLanguage.CPP, log, getScannerExtensionConfiguration(), fileCreator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
package org.eclipse.cdt.core.index;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||
import org.eclipse.cdt.core.parser.IMacro;
|
||||
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -29,10 +29,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
// mstodo scanner removal: IIndexMacro should extend IMacroBinding. However, the DOMScanner requires
|
||||
// the delivery of some internal representation of macros. That's what this interface seems to be
|
||||
// trimmed to.
|
||||
public interface IIndexMacro extends IMacro {
|
||||
public interface IIndexMacro extends IMacroBinding {
|
||||
|
||||
IIndexMacro[] EMPTY_INDEX_MACRO_ARRAY = new IIndexMacro[0];
|
||||
|
||||
|
@ -58,10 +55,4 @@ public interface IIndexMacro extends IMacro {
|
|||
* Returns the length of the name.
|
||||
*/
|
||||
public int getNodeLength();
|
||||
|
||||
/**
|
||||
* Returns the parameter names or <code>null</code> if this is not a function style macro
|
||||
* @since 5.0
|
||||
*/
|
||||
char[][] getParameterList();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2007 IBM Corporation 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
|
||||
|
@ -7,20 +7,24 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on Sep 16, 2004
|
||||
*/
|
||||
package org.eclipse.cdt.core.parser;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
* Interface to provide macro definitions in an IScannerExtensionConfiguration.
|
||||
*/
|
||||
public interface IMacro {
|
||||
//For object-like macros these will be the same,
|
||||
//for function-like macros, the signature includes the parameters
|
||||
/**
|
||||
* Return the signature of a macro, which is the name for object style macros and
|
||||
* the name followed by the comma-separated parameters put in parenthesis. For
|
||||
* example: 'funcStyleMacro(par1, par2)'.
|
||||
*/
|
||||
public char[] getSignature();
|
||||
public char[] getName();
|
||||
|
||||
/**
|
||||
* Returns the expansion for this macro.
|
||||
*/
|
||||
public char[] getExpansion();
|
||||
}
|
||||
|
|
|
@ -7,25 +7,25 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IMacroCollector;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver;
|
||||
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.Lexer;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
* Interface between the parser and the preprocessor.
|
||||
* <p>
|
||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
||||
* part of a work in progress. There is no guarantee that this API will
|
||||
* work or that it will remain the same. Please do not use this API without
|
||||
* consulting with the CDT team.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public interface IScanner extends IMacroCollector {
|
||||
|
||||
|
@ -47,21 +47,32 @@ public interface IScanner extends IMacroCollector {
|
|||
*/
|
||||
public void setComputeImageLocations(boolean val);
|
||||
|
||||
public IMacro addDefinition(char[] key, char[] value);
|
||||
public void addDefinition(IMacro macro);
|
||||
|
||||
public Map getDefinitions();
|
||||
public String[] getIncludePaths();
|
||||
/**
|
||||
* Returns a map from {@link String} to {@link IMacroBinding} containing
|
||||
* all the definitions that are defined at the current point in the
|
||||
* process of scanning.
|
||||
*/
|
||||
public Map getDefinitions();
|
||||
|
||||
/**
|
||||
* Returns next token for the parser. String literals are concatenated.
|
||||
* @throws EndOfFileException when the end of the translation unit has been reached.
|
||||
* @throws OffsetLimitReachedException see {@link Lexer}.
|
||||
*/
|
||||
public IToken nextToken() throws EndOfFileException;
|
||||
|
||||
public int getCount();
|
||||
/**
|
||||
* Returns <code>true</code>, whenever we are processing the outermost file of the translation unit.
|
||||
*/
|
||||
public boolean isOnTopContext();
|
||||
public CharArrayObjectMap getRealDefinitions();
|
||||
|
||||
/**
|
||||
* Attempts to cancel the scanner.
|
||||
*/
|
||||
public void cancel();
|
||||
|
||||
/**
|
||||
* Returns the location resolver associated with this scanner.
|
||||
*/
|
||||
public ILocationResolver getLocationResolver();
|
||||
}
|
||||
|
|
|
@ -34,32 +34,11 @@ public class OffsetLimitReachedException extends EndOfFileException {
|
|||
public static final int ORIGIN_INACTIVE_CODE = 3;
|
||||
public static final int ORIGIN_MACRO_EXPANSION = 4;
|
||||
|
||||
private final String prefix;
|
||||
private final IToken finalToken;
|
||||
private final int fOrigin;
|
||||
|
||||
/**
|
||||
* mstodo- scanner removal
|
||||
* @deprecated
|
||||
* @param prefix
|
||||
*/
|
||||
public OffsetLimitReachedException( String prefix )
|
||||
{
|
||||
this.prefix= prefix;
|
||||
finalToken = null;
|
||||
fOrigin= ORIGIN_UNKNOWN;
|
||||
}
|
||||
|
||||
public OffsetLimitReachedException( IToken token )
|
||||
{
|
||||
fOrigin= ORIGIN_UNKNOWN;
|
||||
prefix= token.getImage();
|
||||
finalToken = token;
|
||||
}
|
||||
|
||||
public OffsetLimitReachedException(int origin, IToken lastToken) {
|
||||
fOrigin= origin;
|
||||
prefix= lastToken.getImage();
|
||||
finalToken= lastToken;
|
||||
}
|
||||
|
||||
|
@ -76,13 +55,4 @@ public class OffsetLimitReachedException extends EndOfFileException {
|
|||
public IToken getFinalToken() {
|
||||
return finalToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* mstodo- scanner removal
|
||||
* @return returns the IASTCompletionNode
|
||||
* @deprecated
|
||||
*/
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,96 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2007 IBM Corporation 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:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.ast;
|
||||
|
||||
import org.eclipse.cdt.core.parser.Enum;
|
||||
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IASTCompletionNode {
|
||||
|
||||
public static class CompletionKind extends Enum {
|
||||
|
||||
// class member declaration type reference
|
||||
public static final CompletionKind FIELD_TYPE = new CompletionKind( 2 );
|
||||
|
||||
// stand-alone declaration type reference
|
||||
public static final CompletionKind VARIABLE_TYPE = new CompletionKind( 3 );
|
||||
|
||||
// function/method argument type reference
|
||||
public static final CompletionKind ARGUMENT_TYPE = new CompletionKind( 4 );
|
||||
|
||||
// inside code body - name reference || int X::[ ]
|
||||
public static final CompletionKind SINGLE_NAME_REFERENCE = new CompletionKind( 5 );
|
||||
|
||||
// any place one can expect a type
|
||||
public static final CompletionKind TYPE_REFERENCE = new CompletionKind( 6 );
|
||||
|
||||
// any place where one can expect a class name
|
||||
public static final CompletionKind CLASS_REFERENCE = new CompletionKind( 7 );
|
||||
|
||||
// any place where a namespace name is expected
|
||||
public static final CompletionKind NAMESPACE_REFERENCE = new CompletionKind( 8 );
|
||||
|
||||
// any place where an exception name is expected
|
||||
public static final CompletionKind EXCEPTION_REFERENCE = new CompletionKind( 9 );
|
||||
|
||||
// any place where exclusively a preprocessor macro name would be expected
|
||||
public static final CompletionKind MACRO_REFERENCE = new CompletionKind( 10 );
|
||||
|
||||
// any place where constructor parameters are expected
|
||||
public static final CompletionKind CONSTRUCTOR_REFERENCE = new CompletionKind( 12 );
|
||||
|
||||
// any place where exclusively a preprocessor directive is expected
|
||||
public static final CompletionKind PREPROCESSOR_DIRECTIVE = new CompletionKind( 13 );
|
||||
|
||||
// any place where function parameters are expected
|
||||
public static final CompletionKind FUNCTION_REFERENCE = new CompletionKind( 15 );
|
||||
|
||||
// after a new expression
|
||||
public static final CompletionKind NEW_TYPE_REFERENCE = new CompletionKind( 16 );
|
||||
|
||||
// inside something that does not reach the parser - (#ifdefed out/comment)
|
||||
public static final CompletionKind UNREACHABLE_CODE = new CompletionKind( 17 );
|
||||
|
||||
// structs only
|
||||
public static final CompletionKind STRUCT_REFERENCE = new CompletionKind( 18 );
|
||||
|
||||
// unions only
|
||||
public static final CompletionKind UNION_REFERENCE = new CompletionKind( 19 );
|
||||
|
||||
// enums only
|
||||
public static final CompletionKind ENUM_REFERENCE = new CompletionKind( 20 );
|
||||
|
||||
// error condition -- a place in the grammar where there is nothing to lookup
|
||||
public static final CompletionKind NO_SUCH_KIND = new CompletionKind( 200 );
|
||||
/**
|
||||
* @param enumValue
|
||||
*/
|
||||
protected CompletionKind(int enumValue) {
|
||||
super(enumValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return kind of completion expected
|
||||
*/
|
||||
public CompletionKind getCompletionKind();
|
||||
|
||||
/**
|
||||
* @return the prefix
|
||||
*/
|
||||
public String getCompletionPrefix();
|
||||
}
|
|
@ -84,13 +84,13 @@ public final class CharArrayMap/*<V>*/ {
|
|||
public int hashCode() {
|
||||
int result = 17;
|
||||
for(int i = start; i < start+length; i++) {
|
||||
result = 37 * result + (int)buffer[i];
|
||||
result = 37 * result + buffer[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "'" + new String(buffer, start, length) + "'@(" + start + "," + length + ")";
|
||||
return "'" + new String(buffer, start, length) + "'@(" + start + "," + length + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Institute for Software, HSR Hochschule fuer Technik
|
||||
* Rapperswil, University of applied sciences 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:
|
||||
* Emanuel Graf & Leo Buettiker - initial API and implementation
|
||||
* Guido Zgraggen
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
||||
/**
|
||||
* @author egraf
|
||||
*
|
||||
*/
|
||||
public class ASTComment extends ASTNode implements IASTComment {
|
||||
|
||||
private char[] comment;
|
||||
|
||||
private boolean blockComment;
|
||||
|
||||
public ASTComment(IToken commentTocken){
|
||||
switch(commentTocken.getType()){
|
||||
case IToken.tCOMMENT:
|
||||
blockComment = false;
|
||||
break;
|
||||
case IToken.tBLOCKCOMMENT:
|
||||
blockComment = true;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("No Comment Token"); //$NON-NLS-1$
|
||||
}
|
||||
comment = commentTocken.getImage().toCharArray();
|
||||
setOffsetAndLength(commentTocken.getOffset(), commentTocken.getLength());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.ASTNode#accept(org.eclipse.cdt.core.dom.ast.ASTVisitor)
|
||||
*/
|
||||
public boolean accept(ASTVisitor visitor) {
|
||||
if (visitor.shouldVisitComments) {
|
||||
switch (visitor.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT:
|
||||
return false;
|
||||
case ASTVisitor.PROCESS_SKIP:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the comment
|
||||
*/
|
||||
public char[] getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param comment the comment to set
|
||||
*/
|
||||
public void setComment(char[] comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public boolean isBlockComment() {
|
||||
return blockComment;
|
||||
}
|
||||
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if(! (obj instanceof ASTComment))
|
||||
return false;
|
||||
ASTComment com2 = (ASTComment)obj;
|
||||
if(getOffset() == com2.getOffset() && getLength() == com2.getLength()){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static IASTComment[] addComment(IASTComment[] comments, IASTComment comment) {
|
||||
if(!ArrayUtil.contains(comments, comment)){
|
||||
comments = (IASTComment[]) ArrayUtil.append(IASTComment.class, comments, comment);
|
||||
}
|
||||
|
||||
return comments;
|
||||
}
|
||||
}
|
|
@ -89,7 +89,7 @@ public abstract class ASTNode implements IASTNode {
|
|||
else {
|
||||
final IASTTranslationUnit tu= getTranslationUnit();
|
||||
if (tu != null) {
|
||||
org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver l= (org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver) tu.getAdapter(org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver.class);
|
||||
ILocationResolver l= (ILocationResolver) tu.getAdapter(ILocationResolver.class);
|
||||
if (l != null) {
|
||||
locations= l.getLocations(offset, length);
|
||||
}
|
||||
|
@ -117,10 +117,6 @@ public abstract class ASTNode implements IASTNode {
|
|||
if (lr != null) {
|
||||
return new String(lr.getUnpreprocessedSignature(getFileLocation()));
|
||||
}
|
||||
else {
|
||||
// mstodo- old location resolver, remove
|
||||
return ast.getUnpreprocessedSignature(getNodeLocations());
|
||||
}
|
||||
}
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
||||
|
@ -93,16 +92,12 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
|
||||
protected final boolean supportKnRC;
|
||||
|
||||
protected IASTComment[] comments = new ASTComment[0];
|
||||
|
||||
protected final boolean supportAttributeSpecifiers;
|
||||
|
||||
protected final boolean supportDeclspecSpecifiers;
|
||||
|
||||
protected final IBuiltinBindingsProvider builtinBindingsProvider;
|
||||
|
||||
private IToken lastTokenFromScanner;
|
||||
|
||||
protected AbstractGNUSourceCodeParser(IScanner scanner,
|
||||
IParserLogService logService, ParserMode parserMode,
|
||||
boolean supportStatementsInExpressions,
|
||||
|
@ -254,29 +249,13 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
* thrown when the scanner.nextToken() yields no tokens
|
||||
*/
|
||||
protected IToken fetchToken() throws EndOfFileException {
|
||||
IToken value= null;
|
||||
boolean adjustNextToken= false;
|
||||
try {
|
||||
value= scanner.nextToken();
|
||||
// Put the Comments in the Array for later processing
|
||||
int type = value.getType();
|
||||
while(type == IToken.tCOMMENT || type == IToken.tBLOCKCOMMENT){
|
||||
IASTComment comment = createComment(value);
|
||||
comments = ASTComment.addComment(comments, comment);
|
||||
value = scanner.nextToken();
|
||||
type= value.getType();
|
||||
adjustNextToken= true;
|
||||
}
|
||||
return scanner.nextToken();
|
||||
} catch (OffsetLimitReachedException olre) {
|
||||
handleOffsetLimitException(olre);
|
||||
value= null;
|
||||
// never returns, to make the java-compiler happy:
|
||||
return null;
|
||||
}
|
||||
|
||||
if (lastTokenFromScanner != null && adjustNextToken) {
|
||||
lastTokenFromScanner.setNext(value);
|
||||
}
|
||||
lastTokenFromScanner= value;
|
||||
return value;
|
||||
}
|
||||
|
||||
protected boolean isCancelled = false;
|
||||
|
@ -333,7 +312,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
*/
|
||||
public synchronized void cancel() {
|
||||
isCancelled = true;
|
||||
scanner.cancel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1425,19 +1403,39 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
protected IASTDeclaration asmDeclaration() throws EndOfFileException,
|
||||
BacktrackException {
|
||||
IToken first = consume(); // t_asm
|
||||
IToken next= LA(1);
|
||||
if (next.getType() == IToken.t_volatile) {
|
||||
consume();
|
||||
}
|
||||
|
||||
consume(IToken.tLPAREN);
|
||||
char[] assemblyChars = consume(IToken.tSTRING).getCharImage();
|
||||
String assembly;
|
||||
if (assemblyChars.length > 2 && assemblyChars[0] == '"') {
|
||||
assembly= new String(assemblyChars, 1, assemblyChars.length-2);
|
||||
boolean needspace= false;
|
||||
StringBuffer buffer= new StringBuffer();
|
||||
int open= 1;
|
||||
while (open > 0) {
|
||||
IToken t= consume();
|
||||
switch(t.getType()) {
|
||||
case IToken.tLPAREN:
|
||||
open++;
|
||||
break;
|
||||
case IToken.tRPAREN:
|
||||
open--;
|
||||
break;
|
||||
case IToken.tEOC:
|
||||
throw new EndOfFileException();
|
||||
|
||||
default:
|
||||
if (needspace) {
|
||||
buffer.append(' ');
|
||||
}
|
||||
buffer.append(t.getCharImage());
|
||||
needspace= true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
assembly= new String(assemblyChars);
|
||||
}
|
||||
consume(IToken.tRPAREN);
|
||||
int lastOffset = consume(IToken.tSEMI).getEndOffset();
|
||||
|
||||
return buildASMDirective(first.getOffset(), assembly, lastOffset);
|
||||
return buildASMDirective(first.getOffset(), buffer.toString(), lastOffset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2266,10 +2264,4 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the ast node for a comment.
|
||||
* @since 4.0
|
||||
*/
|
||||
protected abstract IASTComment createComment(IToken commentToken) throws EndOfFileException;
|
||||
}
|
||||
|
|
|
@ -263,19 +263,19 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
|
|||
cpp_const_char_p_r = new GPPPointerType(new CPPQualifierType(cpp_char, true, false), false, false, true);
|
||||
|
||||
cpp_double = new CPPBasicType(IBasicType.t_double, 0);
|
||||
cpp_double_complex = new GPPBasicType(IBasicType.t_double, GPPBasicType.IS_COMPLEX, null);
|
||||
cpp_double_complex = new GPPBasicType(IBasicType.t_double, ICPPBasicType.IS_COMPLEX, null);
|
||||
cpp_float = new CPPBasicType(IBasicType.t_float, 0);
|
||||
cpp_float_complex = new GPPBasicType(IBasicType.t_float, GPPBasicType.IS_COMPLEX, null);
|
||||
cpp_float_complex = new GPPBasicType(IBasicType.t_float, ICPPBasicType.IS_COMPLEX, null);
|
||||
cpp_int = new CPPBasicType(IBasicType.t_int, 0);
|
||||
cpp_long_int = new CPPBasicType(IBasicType.t_int, ICPPBasicType.IS_LONG);
|
||||
cpp_long_double = new CPPBasicType(IBasicType.t_double, ICPPBasicType.IS_LONG);
|
||||
cpp_long_double_complex = new GPPBasicType(IBasicType.t_double, ICPPBasicType.IS_LONG | GPPBasicType.IS_COMPLEX, null);
|
||||
cpp_long_long_int = new CPPBasicType(IBasicType.t_int, GPPBasicType.IS_LONGLONG);
|
||||
cpp_long_double_complex = new GPPBasicType(IBasicType.t_double, ICPPBasicType.IS_LONG | ICPPBasicType.IS_COMPLEX, null);
|
||||
cpp_long_long_int = new CPPBasicType(IBasicType.t_int, ICPPBasicType.IS_LONG_LONG);
|
||||
cpp_signed_long_int = new CPPBasicType(IBasicType.t_int, ICPPBasicType.IS_LONG | ICPPBasicType.IS_SIGNED);
|
||||
|
||||
cpp_unsigned_int = new CPPBasicType(IBasicType.t_int, ICPPBasicType.IS_UNSIGNED);
|
||||
cpp_unsigned_long = new CPPBasicType(IBasicType.t_int, ICPPBasicType.IS_UNSIGNED | ICPPBasicType.IS_LONG);
|
||||
cpp_unsigned_long_long = new GPPBasicType(IBasicType.t_int, ICPPBasicType.IS_UNSIGNED | GPPBasicType.IS_LONGLONG, null);
|
||||
cpp_unsigned_long_long = new GPPBasicType(IBasicType.t_int, ICPPBasicType.IS_UNSIGNED | ICPPBasicType.IS_LONG_LONG, null);
|
||||
|
||||
cpp_size_t = cpp_unsigned_long; // assumed unsigned long int
|
||||
cpp_va_list = new CPPFunctionType( cpp_char_p, new IType[0]); // assumed: char * va_list();
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public interface IRequiresLocationInformation {
|
||||
|
||||
/**
|
||||
* @param locationResolver
|
||||
*/
|
||||
void setLocationResolver(ILocationResolver resolver);
|
||||
|
||||
}
|
|
@ -81,7 +81,7 @@ public abstract class CASTAmbiguity extends CASTNode {
|
|||
}
|
||||
}
|
||||
}
|
||||
catch( Throwable t )
|
||||
catch( Exception t )
|
||||
{
|
||||
++issues[i];
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2007 IBM Corporation 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:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class CASTDeclarator extends CASTNode implements IASTDeclarator {
|
|||
this.name = name;
|
||||
if (name != null) {
|
||||
name.setParent(this);
|
||||
name.setPropertyInParent(DECLARATOR_NAME);;
|
||||
name.setPropertyInParent(DECLARATOR_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,45 +47,29 @@ import org.eclipse.cdt.core.index.IIndex;
|
|||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTComment;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTPreprocessorSelectionResult;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IRequiresLocationInformation;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.InvalidPreprocessorNodeException;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class CASTTranslationUnit extends CASTNode implements
|
||||
IASTTranslationUnit, IRequiresLocationInformation {
|
||||
|
||||
private IASTDeclaration[] decls = null;
|
||||
private int declsPos=-1;
|
||||
|
||||
// Binding
|
||||
private CScope compilationUnit = null;
|
||||
|
||||
private ILocationResolver resolver;
|
||||
|
||||
private IIndex index;
|
||||
public class CASTTranslationUnit extends CASTNode implements IASTTranslationUnit {
|
||||
|
||||
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
|
||||
|
||||
private static final IASTNodeLocation[] EMPTY_PREPROCESSOR_LOCATION_ARRAY = new IASTNodeLocation[0];
|
||||
|
||||
private static final IASTPreprocessorMacroDefinition[] EMPTY_PREPROCESSOR_MACRODEF_ARRAY = new IASTPreprocessorMacroDefinition[0];
|
||||
|
||||
private static final IASTPreprocessorIncludeStatement[] EMPTY_PREPROCESSOR_INCLUSION_ARRAY = new IASTPreprocessorIncludeStatement[0];
|
||||
|
||||
private static final IASTProblem[] EMPTY_PROBLEM_ARRAY = new IASTProblem[0];
|
||||
|
||||
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||
|
||||
private static final IASTName[] EMPTY_NAME_ARRAY = new IASTName[0];
|
||||
|
||||
private IASTComment[] comments = new ASTComment[0];
|
||||
private IASTDeclaration[] decls = null;
|
||||
private int declsPos=-1;
|
||||
|
||||
private CScope compilationUnit = null;
|
||||
private ILocationResolver resolver;
|
||||
private IIndex index;
|
||||
private boolean fIsHeader;
|
||||
|
||||
public IASTTranslationUnit getTranslationUnit() {
|
||||
|
@ -395,47 +379,21 @@ public class CASTTranslationUnit extends CASTNode implements
|
|||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getNodeForLocation(org.eclipse.cdt.core.dom.ast.IASTNodeLocation)
|
||||
*/
|
||||
public IASTNode selectNodeForLocation(String path, int realOffset, int realLength) {
|
||||
if (resolver instanceof org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver) {
|
||||
org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver r2= (org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver) resolver;
|
||||
IASTNode result= null;
|
||||
int start= r2.getSequenceNumberForFileOffset(path, realOffset);
|
||||
IASTNode result= null;
|
||||
if (resolver != null) {
|
||||
int start= resolver.getSequenceNumberForFileOffset(path, realOffset);
|
||||
if (start >= 0) {
|
||||
int length= realLength < 1 ? 0 :
|
||||
r2.getSequenceNumberForFileOffset(path, realOffset+realLength-1) + 1 - start;
|
||||
result= r2.findSurroundingPreprocessorNode(start, length);
|
||||
resolver.getSequenceNumberForFileOffset(path, realOffset+realLength-1) + 1 - start;
|
||||
result= resolver.findSurroundingPreprocessorNode(start, length);
|
||||
if (result == null) {
|
||||
CFindNodeForOffsetAction nodeFinder = new CFindNodeForOffsetAction(start, length);
|
||||
accept(nodeFinder);
|
||||
result = nodeFinder.getNode();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// mstodo- old location resolver remove
|
||||
IASTNode node = null;
|
||||
ASTPreprocessorSelectionResult result = null;
|
||||
int globalOffset = 0;
|
||||
|
||||
try {
|
||||
result = resolver.getPreprocessorNode(path, realOffset, realLength);
|
||||
} catch (InvalidPreprocessorNodeException ipne) {
|
||||
globalOffset = ipne.getGlobalOffset();
|
||||
}
|
||||
|
||||
if (result != null && result.getSelectedNode() != null) {
|
||||
node = result.getSelectedNode();
|
||||
} else {
|
||||
// use the globalOffset to get the node from the AST if it's valid
|
||||
globalOffset = result == null ? globalOffset : result.getGlobalOffset();
|
||||
if (globalOffset >= 0) {
|
||||
CFindNodeForOffsetAction nodeFinder = new CFindNodeForOffsetAction(globalOffset, realLength);
|
||||
accept(nodeFinder);
|
||||
node = nodeFinder.getNode();
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -517,17 +475,6 @@ public class CASTTranslationUnit extends CASTNode implements
|
|||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getUnpreprocessedSignature(org.eclipse.cdt.core.dom.ast.IASTNodeLocation[])
|
||||
*/
|
||||
public String getUnpreprocessedSignature(IASTNodeLocation[] locations) {
|
||||
if (resolver == null)
|
||||
return EMPTY_STRING;
|
||||
return new String(resolver.getUnpreprocessedSignature(locations));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -567,12 +514,6 @@ public class CASTTranslationUnit extends CASTNode implements
|
|||
return resolver.flattenLocations( nodeLocations );
|
||||
}
|
||||
|
||||
public IASTName[] getMacroExpansions() {
|
||||
if( resolver == null )
|
||||
return EMPTY_NAME_ARRAY;
|
||||
return resolver.getMacroExpansions();
|
||||
}
|
||||
|
||||
public IDependencyTree getDependencyTree() {
|
||||
if( resolver == null )
|
||||
return null;
|
||||
|
@ -582,7 +523,7 @@ public class CASTTranslationUnit extends CASTNode implements
|
|||
public String getContainingFilename(int offset) {
|
||||
if( resolver == null )
|
||||
return EMPTY_STRING;
|
||||
return resolver.getContainingFilename( offset );
|
||||
return resolver.getContainingFilePath( offset );
|
||||
}
|
||||
|
||||
public ParserLanguage getParserLanguage() {
|
||||
|
@ -599,16 +540,10 @@ public class CASTTranslationUnit extends CASTNode implements
|
|||
}
|
||||
|
||||
public IASTComment[] getComments() {
|
||||
if (resolver instanceof org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver) {
|
||||
org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver r2= (org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver) resolver;
|
||||
return r2.getComments();
|
||||
if (resolver != null) {
|
||||
return resolver.getComments();
|
||||
}
|
||||
// support for old location resolver
|
||||
return comments;
|
||||
}
|
||||
|
||||
public void setComments(IASTComment[] comments) {
|
||||
this.comments = comments;
|
||||
return new IASTComment[0];
|
||||
}
|
||||
|
||||
public Object getAdapter(Class adapter) {
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
||||
|
@ -103,11 +102,9 @@ import org.eclipse.cdt.core.parser.IGCCToken;
|
|||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ParseError;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTComment;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
|
||||
|
@ -606,18 +603,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
} catch (EndOfFileException e3) {
|
||||
// nothing
|
||||
}
|
||||
} catch (ParseError perr) {
|
||||
throw perr;
|
||||
} catch (Throwable e) {
|
||||
logThrowable("translationUnit", e); //$NON-NLS-1$
|
||||
try {
|
||||
failParseWithErrorHandling();
|
||||
} catch (EndOfFileException e3) {
|
||||
// break;
|
||||
}
|
||||
}
|
||||
}
|
||||
translationUnit.setComments((IASTComment[]) ArrayUtil.trim(IASTComment.class, comments));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -633,6 +620,12 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
*/
|
||||
protected IASTExpression assignmentExpression() throws EndOfFileException,
|
||||
BacktrackException {
|
||||
if (LT(1) == IToken.tLPAREN && LT(2) == IToken.tLBRACE && supportStatementsInExpressions) {
|
||||
IASTExpression resultExpression = compoundStatementExpression();
|
||||
if (resultExpression != null)
|
||||
return resultExpression;
|
||||
}
|
||||
|
||||
IASTExpression conditionalExpression = conditionalExpression();
|
||||
// if the condition not taken, try assignment operators
|
||||
if (conditionalExpression != null
|
||||
|
@ -2672,11 +2665,4 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
}
|
||||
return for_statement;
|
||||
}
|
||||
|
||||
protected IASTComment createComment(IToken commentToken) throws EndOfFileException {
|
||||
ASTComment comment = new ASTComment(commentToken);
|
||||
comment.setParent(translationUnit);
|
||||
return comment;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
//no change for leave()
|
||||
|
@ -68,7 +69,7 @@ public abstract class CPPASTAmbiguity extends CPPASTNode {
|
|||
IBinding b = names[j].resolveBinding();
|
||||
if (b == null || b instanceof IProblemBinding)
|
||||
++issues[i];
|
||||
} catch (Throwable t) {
|
||||
} catch (Exception t) {
|
||||
++issues[i];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,12 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
|
||||
|
@ -48,7 +49,7 @@ public class CPPASTCastExpression extends CPPASTUnaryExpression implements ICPPA
|
|||
// ICPPASTCastExpression.OPERAND
|
||||
if (expression != null) {
|
||||
expression.setParent(this);
|
||||
expression.setPropertyInParent(ICPPASTCastExpression.OPERAND);
|
||||
expression.setPropertyInParent(IASTCastExpression.OPERAND);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
|
@ -99,8 +100,8 @@ public class CPPASTName extends CPPASTNode implements IASTName, IASTCompletionCo
|
|||
ICPPASTElaboratedTypeSpecifier specifier = (ICPPASTElaboratedTypeSpecifier) parent;
|
||||
int kind = specifier.getKind();
|
||||
switch (kind) {
|
||||
case ICPPASTElaboratedTypeSpecifier.k_struct:
|
||||
case ICPPASTElaboratedTypeSpecifier.k_union:
|
||||
case ICompositeType.k_struct:
|
||||
case ICompositeType.k_union:
|
||||
case ICPPASTElaboratedTypeSpecifier.k_class:
|
||||
break;
|
||||
default:
|
||||
|
@ -129,13 +130,13 @@ public class CPPASTName extends CPPASTNode implements IASTName, IASTCompletionCo
|
|||
ICPPClassType type = (ICPPClassType) bindings[i];
|
||||
try {
|
||||
switch (type.getKey()) {
|
||||
case ICPPClassType.k_struct:
|
||||
if (kind != ICPPASTElaboratedTypeSpecifier.k_struct) {
|
||||
case ICompositeType.k_struct:
|
||||
if (kind != ICompositeType.k_struct) {
|
||||
bindings[i] = null;
|
||||
}
|
||||
break;
|
||||
case ICPPClassType.k_union:
|
||||
if (kind != ICPPASTElaboratedTypeSpecifier.k_union) {
|
||||
case ICompositeType.k_union:
|
||||
if (kind != ICompositeType.k_union) {
|
||||
bindings[i] = null;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -58,46 +58,31 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
|||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTComment;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTPreprocessorSelectionResult;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IRequiresLocationInformation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider.CPPBuiltinParameter;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.InvalidPreprocessorNodeException;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class CPPASTTranslationUnit extends CPPASTNode implements
|
||||
ICPPASTTranslationUnit, IRequiresLocationInformation, IASTAmbiguityParent {
|
||||
private IASTDeclaration[] decls = new IASTDeclaration[32];
|
||||
|
||||
private ICPPNamespace binding = null;
|
||||
|
||||
private ICPPScope scope = null;
|
||||
|
||||
private ILocationResolver resolver;
|
||||
|
||||
private IIndex index;
|
||||
public class CPPASTTranslationUnit extends CPPASTNode implements ICPPASTTranslationUnit, IASTAmbiguityParent {
|
||||
|
||||
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
|
||||
|
||||
private static final IASTNodeLocation[] EMPTY_PREPROCESSOR_LOCATION_ARRAY = new IASTNodeLocation[0];
|
||||
|
||||
private static final IASTPreprocessorMacroDefinition[] EMPTY_PREPROCESSOR_MACRODEF_ARRAY = new IASTPreprocessorMacroDefinition[0];
|
||||
|
||||
private static final IASTPreprocessorIncludeStatement[] EMPTY_PREPROCESSOR_INCLUSION_ARRAY = new IASTPreprocessorIncludeStatement[0];
|
||||
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||
private static final IASTProblem[] EMPTY_PROBLEM_ARRAY = new IASTProblem[0];
|
||||
|
||||
private static final IASTName[] EMPTY_NAME_ARRAY = new IASTName[0];
|
||||
|
||||
private IASTComment[] comments = new ASTComment[0];
|
||||
|
||||
private IASTDeclaration[] decls = new IASTDeclaration[32];
|
||||
private ICPPNamespace binding = null;
|
||||
private ICPPScope scope = null;
|
||||
private ILocationResolver resolver;
|
||||
private IIndex index;
|
||||
private boolean fIsHeader;
|
||||
|
||||
public IASTTranslationUnit getTranslationUnit() {
|
||||
|
@ -381,47 +366,21 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
|
|||
|
||||
|
||||
public IASTNode selectNodeForLocation(String path, int realOffset, int realLength) {
|
||||
if (resolver instanceof org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver) {
|
||||
org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver r2= (org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver) resolver;
|
||||
IASTNode result= null;
|
||||
int start= r2.getSequenceNumberForFileOffset(path, realOffset);
|
||||
IASTNode result= null;
|
||||
if (resolver != null) {
|
||||
int start= resolver.getSequenceNumberForFileOffset(path, realOffset);
|
||||
if (start >= 0) {
|
||||
int length= realLength < 1 ? 0 :
|
||||
r2.getSequenceNumberForFileOffset(path, realOffset+realLength-1) + 1 - start;
|
||||
result= r2.findSurroundingPreprocessorNode(start, length);
|
||||
resolver.getSequenceNumberForFileOffset(path, realOffset+realLength-1) + 1 - start;
|
||||
result= resolver.findSurroundingPreprocessorNode(start, length);
|
||||
if (result == null) {
|
||||
CPPFindNodeForOffsetAction nodeFinder = new CPPFindNodeForOffsetAction(start, length);
|
||||
accept(nodeFinder);
|
||||
result = nodeFinder.getNode();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// mstodo- old location resolver, remove
|
||||
IASTNode node = null;
|
||||
ASTPreprocessorSelectionResult result = null;
|
||||
int globalOffset = 0;
|
||||
|
||||
try {
|
||||
result = resolver.getPreprocessorNode(path, realOffset, realLength);
|
||||
} catch (InvalidPreprocessorNodeException ipne) {
|
||||
globalOffset = ipne.getGlobalOffset();
|
||||
}
|
||||
|
||||
if (result != null && result.getSelectedNode() != null) {
|
||||
node = result.getSelectedNode();
|
||||
} else {
|
||||
// use the globalOffset to get the node from the AST if it's valid
|
||||
globalOffset = result == null ? globalOffset : result.getGlobalOffset();
|
||||
if (globalOffset >= 0) {
|
||||
CPPFindNodeForOffsetAction nodeFinder = new CPPFindNodeForOffsetAction(globalOffset, realLength);
|
||||
accept(nodeFinder);
|
||||
node = nodeFinder.getNode();
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -473,12 +432,6 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
|
|||
return result;
|
||||
}
|
||||
|
||||
public String getUnpreprocessedSignature(IASTNodeLocation[] locations) {
|
||||
if( resolver == null ) return EMPTY_STRING;
|
||||
return new String( resolver.getUnpreprocessedSignature(locations) );
|
||||
}
|
||||
|
||||
|
||||
public String getFilePath() {
|
||||
if (resolver == null)
|
||||
return EMPTY_STRING;
|
||||
|
@ -514,12 +467,6 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
|
|||
return resolver.flattenLocations( nodeLocations );
|
||||
}
|
||||
|
||||
public IASTName[] getMacroExpansions() {
|
||||
if( resolver == null )
|
||||
return EMPTY_NAME_ARRAY;
|
||||
return resolver.getMacroExpansions();
|
||||
}
|
||||
|
||||
public IDependencyTree getDependencyTree() {
|
||||
if( resolver == null )
|
||||
return null;
|
||||
|
@ -529,7 +476,7 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
|
|||
public String getContainingFilename(int offset) {
|
||||
if( resolver == null )
|
||||
return EMPTY_STRING;
|
||||
return resolver.getContainingFilename( offset );
|
||||
return resolver.getContainingFilePath( offset );
|
||||
}
|
||||
|
||||
public void replace(IASTNode child, IASTNode other) {
|
||||
|
@ -559,16 +506,10 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
|
|||
}
|
||||
|
||||
public IASTComment[] getComments() {
|
||||
if (resolver instanceof org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver) {
|
||||
org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver r2= (org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver) resolver;
|
||||
return r2.getComments();
|
||||
if (resolver != null) {
|
||||
return resolver.getComments();
|
||||
}
|
||||
// support for old location resolver
|
||||
return comments;
|
||||
}
|
||||
|
||||
public void setComments(IASTComment[] comments) {
|
||||
this.comments = comments;
|
||||
return new IASTComment[0];
|
||||
}
|
||||
|
||||
public Object getAdapter(Class adapter) {
|
||||
|
|
|
@ -95,7 +95,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
|
|||
ICPPTemplateDefinition template = null;
|
||||
|
||||
try {
|
||||
template = CPPTemplates.matchTemplatePartialSpecialization( (ICPPClassTemplate) this, arguments );
|
||||
template = CPPTemplates.matchTemplatePartialSpecialization( this, arguments );
|
||||
} catch (DOMException e) {
|
||||
return e.getProblem();
|
||||
}
|
||||
|
|
|
@ -1645,7 +1645,7 @@ public class CPPVisitor {
|
|||
if( gspec.getTypeofExpression() != null ){
|
||||
type = getExpressionType( gspec.getTypeofExpression() );
|
||||
} else {
|
||||
bits |= ( gspec.isLongLong() ? GPPBasicType.IS_LONGLONG : 0 );
|
||||
bits |= ( gspec.isLongLong() ? ICPPBasicType.IS_LONG_LONG : 0 );
|
||||
type = new GPPBasicType( spec.getType(), bits, getExpressionType(gspec.getTypeofExpression()) );
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
||||
|
@ -138,10 +137,8 @@ import org.eclipse.cdt.core.parser.IParserLogService;
|
|||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||
import org.eclipse.cdt.core.parser.ParseError;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTComment;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
|
||||
|
@ -4340,18 +4337,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
} catch (EndOfFileException e3) {
|
||||
// nothing
|
||||
}
|
||||
} catch (ParseError perr) {
|
||||
throw perr;
|
||||
} catch (Throwable e) {
|
||||
logThrowable("translationUnit", e); //$NON-NLS-1$
|
||||
try {
|
||||
failParseWithErrorHandling();
|
||||
} catch (EndOfFileException e3) {
|
||||
// break;
|
||||
}
|
||||
}
|
||||
}
|
||||
translationUnit.setComments((IASTComment[]) ArrayUtil.trim(IASTComment.class, comments));
|
||||
}
|
||||
|
||||
|
||||
|
@ -4977,10 +4964,4 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
}
|
||||
return for_statement;
|
||||
}
|
||||
|
||||
protected IASTComment createComment(IToken commentToken) throws EndOfFileException {
|
||||
ASTComment comment = new ASTComment(commentToken);
|
||||
comment.setParent(translationUnit);
|
||||
return comment;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2007 IBM Corporation 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
/*
|
||||
* Created on Dec 10, 2004
|
||||
|
@ -22,10 +23,6 @@ import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPBasicType;
|
|||
* @author aniefer
|
||||
*/
|
||||
public class GPPBasicType extends CPPBasicType implements IGPPBasicType {
|
||||
public static final int IS_LONGLONG = LAST << 1;
|
||||
public static final int IS_COMPLEX = LAST << 2;
|
||||
public static final int IS_IMAGINARY = LAST << 3;
|
||||
|
||||
private IType typeOf;
|
||||
|
||||
public GPPBasicType( int type, int bits, IType typeOf ){
|
||||
|
@ -34,7 +31,7 @@ public class GPPBasicType extends CPPBasicType implements IGPPBasicType {
|
|||
if( type == IBasicType.t_unspecified ){
|
||||
if((qualifierBits & ( IS_COMPLEX | IS_IMAGINARY )) != 0 )
|
||||
type = IBasicType.t_float;
|
||||
else if( (qualifierBits & IS_LONGLONG) != 0 )
|
||||
else if( (qualifierBits & IS_LONG_LONG) != 0 )
|
||||
type = IBasicType.t_int;
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +40,7 @@ public class GPPBasicType extends CPPBasicType implements IGPPBasicType {
|
|||
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPBasicType#isLongLong()
|
||||
*/
|
||||
public boolean isLongLong() {
|
||||
return ( qualifierBits & IS_LONGLONG ) != 0;
|
||||
return ( qualifierBits & IS_LONG_LONG ) != 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -30,12 +30,10 @@ import org.eclipse.cdt.core.index.IIndexInclude;
|
|||
import org.eclipse.cdt.core.index.IIndexMacro;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.ICodeReaderCache;
|
||||
import org.eclipse.cdt.core.parser.IMacro;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.IIndexBasedCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.IIndexBasedCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.ASTFilePathResolver;
|
||||
import org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMMacro;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -100,9 +98,9 @@ public final class IndexBasedCodeReaderFactory implements IIndexBasedCodeReaderF
|
|||
for (Iterator iterator = macroMap.entrySet().iterator(); iterator.hasNext();) {
|
||||
Map.Entry entry = (Map.Entry) iterator.next();
|
||||
IIndexFileLocation includedIFL = (IIndexFileLocation) entry.getKey();
|
||||
IMacro[] macros = (IMacro[]) entry.getValue();
|
||||
IIndexMacro[] macros = (IIndexMacro[]) entry.getValue();
|
||||
for (int i = 0; i < macros.length; ++i) {
|
||||
scanner.addDefinition(macros[i]);
|
||||
scanner.addMacroDefinition(macros[i]);
|
||||
}
|
||||
fIncludedFiles.add(includedIFL);
|
||||
}
|
||||
|
@ -132,7 +130,7 @@ public final class IndexBasedCodeReaderFactory implements IIndexBasedCodeReaderF
|
|||
if (macroMap.containsKey(ifl) || (checkIncluded && fIncludedFiles.contains(ifl))) {
|
||||
return;
|
||||
}
|
||||
IMacro[] converted;
|
||||
IIndexMacro[] converted;
|
||||
if (fRelatedIndexerTask != null) {
|
||||
converted= fRelatedIndexerTask.getConvertedMacros(fLinkage, ifl);
|
||||
if (converted == null) {
|
||||
|
@ -140,12 +138,7 @@ public final class IndexBasedCodeReaderFactory implements IIndexBasedCodeReaderF
|
|||
}
|
||||
}
|
||||
else {
|
||||
IIndexMacro[] macros= file.getMacros();
|
||||
converted= new IMacro[macros.length];
|
||||
for (int i = 0; i < macros.length; i++) {
|
||||
IIndexMacro macro = macros[i];
|
||||
converted[i]= ((PDOMMacro)macro).getMacro();
|
||||
}
|
||||
converted= file.getMacros();
|
||||
}
|
||||
macroMap.put(ifl, converted); // prevent recursion
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.index.composite;
|
||||
|
@ -31,7 +31,7 @@ public class CompositeTypeContainer extends CompositeType implements ITypeContai
|
|||
try {
|
||||
return ASTTypeUtil.getType(getType());
|
||||
} catch (DOMException e) {
|
||||
return "";
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class CompositeCPPFunctionSpecialization extends CompositeCPPFunction
|
|||
implements ICPPFunction, ICPPSpecialization {
|
||||
|
||||
public CompositeCPPFunctionSpecialization(ICompositesFactory cf, ICPPFunction ft) {
|
||||
super(cf, (ICPPFunction) ft);
|
||||
super(cf, ft);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class InternalTemplateInstantiatorUtil {
|
|||
public static IBinding instantiate(IType[] arguments, ICompositesFactory cf, IIndexBinding rbinding) {
|
||||
IBinding ins= ((ICPPInternalTemplateInstantiator)rbinding).instantiate(arguments);
|
||||
if (ins instanceof IIndexFragmentBinding) {
|
||||
return (IBinding) cf.getCompositeBinding((IIndexFragmentBinding)ins);
|
||||
return cf.getCompositeBinding((IIndexFragmentBinding)ins);
|
||||
} else {
|
||||
// can result in a non-index binding
|
||||
return ins;
|
||||
|
|
|
@ -137,7 +137,8 @@ class ASTMacroReferenceName extends ASTPreprocessorName {
|
|||
return fImageLocationInfo.createLocation(lr, fImageLocationInfo);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
return super.getImageLocation();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,8 +45,6 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
|||
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator.EvalException;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.Lexer.LexerOptions;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.MacroDefinitionParser.InvalidMacroDefinitionException;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.IIndexBasedCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ScannerUtility;
|
||||
|
||||
/**
|
||||
* C-Preprocessor providing tokens for the parsers. The class should not be used directly, rather than that
|
||||
|
@ -181,7 +179,6 @@ public class CPreprocessor implements ILexerLog, IScanner {
|
|||
|
||||
/** Set of already included files */
|
||||
private final HashSet fAllIncludedFiles= new HashSet();
|
||||
private int fTokenCount;
|
||||
|
||||
private final Lexer fRootLexer;
|
||||
private final ScannerContext fRootContext;
|
||||
|
@ -287,10 +284,10 @@ public class CPreprocessor implements ILexerLog, IScanner {
|
|||
fMacroDictionary.put(__STDC_VERSION__.getNameCharArray(), __STDC_VERSION__);
|
||||
}
|
||||
|
||||
CharArrayObjectMap toAdd = config.getAdditionalMacros();
|
||||
for (int i = 0; i < toAdd.size(); ++i) {
|
||||
addDefinition((IMacro) toAdd.getAt(i));
|
||||
}
|
||||
IMacro[] toAdd = config.getAdditionalMacros();
|
||||
for (int i = 0; i < toAdd.length; i++) {
|
||||
addDefinition(toAdd[i]);
|
||||
}
|
||||
|
||||
// macros provided on command-line (-D)
|
||||
final boolean initEmptyMacros= config.initializeMacroValuesTo1();
|
||||
|
@ -376,10 +373,6 @@ public class CPreprocessor implements ILexerLog, IScanner {
|
|||
}
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return fTokenCount;
|
||||
}
|
||||
|
||||
public Map getDefinitions() {
|
||||
final CharArrayObjectMap objMap= fMacroDictionary;
|
||||
int size = objMap.size();
|
||||
|
@ -391,15 +384,11 @@ public class CPreprocessor implements ILexerLog, IScanner {
|
|||
return hashMap;
|
||||
}
|
||||
|
||||
public String[] getIncludePaths() {
|
||||
return fIncludePaths;
|
||||
}
|
||||
|
||||
public boolean isOnTopContext() {
|
||||
return fCurrentContext == fRootContext;
|
||||
}
|
||||
|
||||
public synchronized void cancel() {
|
||||
public void cancel() {
|
||||
isCancelled= true;
|
||||
}
|
||||
|
||||
|
@ -549,7 +538,6 @@ public class CPreprocessor implements ILexerLog, IScanner {
|
|||
|
||||
Token internalFetchToken(final boolean expandMacros, final boolean stopAtNewline,
|
||||
final boolean checkNumbers, final ScannerContext uptoEndOfCtx) throws OffsetLimitReachedException {
|
||||
++fTokenCount;
|
||||
Token ppToken= fCurrentContext.currentLexerToken();
|
||||
while(true) {
|
||||
switch(ppToken.getType()) {
|
||||
|
@ -814,13 +802,13 @@ public class CPreprocessor implements ILexerLog, IScanner {
|
|||
|
||||
public void addMacroDefinition(IIndexMacro macro) {
|
||||
try {
|
||||
PreprocessorMacro result= fMacroDefinitionParser.parseMacroDefinition(macro.getName(), macro.getParameterList(), macro.getExpansion());
|
||||
PreprocessorMacro result= fMacroDefinitionParser.parseMacroDefinition(macro.getNameCharArray(), macro.getParameterList(), macro.getExpansionImage());
|
||||
final IASTFileLocation loc= macro.getFileLocation();
|
||||
fLocationMap.registerMacroFromIndex(result, loc, -1);
|
||||
fMacroDictionary.put(result.getNameCharArray(), result);
|
||||
}
|
||||
catch (Exception e) {
|
||||
fLog.traceLog("Invalid macro definition: '" + String.valueOf(macro.getName()) + "'"); //$NON-NLS-1$//$NON-NLS-2$
|
||||
fLog.traceLog("Invalid macro definition: '" + macro.getName() + "'"); //$NON-NLS-1$//$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1404,15 +1392,9 @@ public class CPreprocessor implements ILexerLog, IScanner {
|
|||
addMacroDefinition(macro.getSignature(), macro.getExpansion());
|
||||
}
|
||||
}
|
||||
public IMacro addDefinition(char[] key, char[] value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
public void setScanComments(boolean val) {
|
||||
}
|
||||
public IMacro addDefinition(char[] name, char[][] params, char[] expansion) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
public org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver getLocationResolver() {
|
||||
public ILocationResolver getLocationResolver() {
|
||||
return fLocationMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
|
|
@ -30,7 +30,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit.IDependencyTree;
|
|||
* Interface between the ast and the location-resolver for resolving offsets.
|
||||
* @since 5.0
|
||||
*/
|
||||
public interface ILocationResolver extends org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver {
|
||||
public interface ILocationResolver {
|
||||
|
||||
/**
|
||||
* Introduces the ast translation unit to the location resolver. Must be called before any tokens from the
|
||||
|
@ -75,9 +75,8 @@ public interface ILocationResolver extends org.eclipse.cdt.internal.core.parser.
|
|||
|
||||
/**
|
||||
* @see IASTTranslationUnit#getContainingFilename()
|
||||
* mstodo- old location resolver, should be renamed
|
||||
*/
|
||||
String getContainingFilename(int sequenceNumber);
|
||||
String getContainingFilePath(int sequenceNumber);
|
||||
|
||||
/**
|
||||
* @see IASTTranslationUnit#getDependencyTree()
|
||||
|
@ -140,4 +139,9 @@ public interface ILocationResolver extends org.eclipse.cdt.internal.core.parser.
|
|||
* @param offset
|
||||
*/
|
||||
boolean isPartOfTranslationUnitFile(int sequenceNumber);
|
||||
|
||||
/**
|
||||
* Same as {@link #getMappedFileLocation(int, int)} for the given array of consecutive node locations.
|
||||
*/
|
||||
IASTFileLocation flattenLocations(IASTNodeLocation[] nodeLocations);
|
||||
}
|
||||
|
|
|
@ -345,7 +345,7 @@ public class LocationMap implements ILocationResolver {
|
|||
return fCurrentContext.getSequenceNumberForOffset(offset, offset < fLastChildInsertionOffset);
|
||||
}
|
||||
|
||||
public String getContainingFilename(int sequenceNumber) {
|
||||
public String getContainingFilePath(int sequenceNumber) {
|
||||
LocationCtx ctx= fRootContext.findSurroundingContext(sequenceNumber, 1);
|
||||
return new String(ctx.getFilePath());
|
||||
}
|
||||
|
@ -554,13 +554,4 @@ public class LocationMap implements ILocationResolver {
|
|||
public ASTPreprocessorSelectionResult getPreprocessorNode(String path, int offset, int length) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
// mstodo- old location resolver
|
||||
public char[] getUnpreprocessedSignature(IASTNodeLocation[] locations) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
// mstodo- old location resolver
|
||||
public IASTName[] getMacroExpansions() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,12 +17,13 @@ import org.eclipse.cdt.core.parser.IToken;
|
|||
import org.eclipse.cdt.core.parser.Keywords;
|
||||
import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.Lexer.LexerOptions;
|
||||
|
||||
/**
|
||||
* Utility to parse macro definitions and create the macro objects for the preprocessor.
|
||||
* @since 5.0
|
||||
*/
|
||||
class MacroDefinitionParser {
|
||||
public class MacroDefinitionParser {
|
||||
private static final int ORIGIN_PREPROCESSOR_DIRECTIVE = OffsetLimitReachedException.ORIGIN_PREPROCESSOR_DIRECTIVE;
|
||||
|
||||
/**
|
||||
|
@ -59,11 +60,41 @@ class MacroDefinitionParser {
|
|||
}
|
||||
}
|
||||
|
||||
public static char[] getExpansion(char[] expansionImage, int offset, int endOffset) {
|
||||
TokenList tl= new TokenList();
|
||||
Lexer lex= new Lexer(expansionImage, offset, endOffset, new LexerOptions(), ILexerLog.NULL, null);
|
||||
try {
|
||||
new MacroDefinitionParser().parseExpansion(lex, ILexerLog.NULL, null, new char[][]{}, tl);
|
||||
} catch (OffsetLimitReachedException e) {
|
||||
}
|
||||
|
||||
StringBuffer buf= new StringBuffer();
|
||||
Token t= tl.first();
|
||||
if (t == null) {
|
||||
return CharArrayUtils.EMPTY;
|
||||
}
|
||||
endOffset= t.getOffset();
|
||||
for (; t != null; t= (Token) t.getNext()) {
|
||||
if (endOffset < t.getOffset()) {
|
||||
buf.append(' ');
|
||||
}
|
||||
buf.append(t.getCharImage());
|
||||
endOffset= t.getEndOffset();
|
||||
}
|
||||
final int length= buf.length();
|
||||
final char[] expansion= new char[length];
|
||||
buf.getChars(0, length, expansion, 0);
|
||||
return expansion;
|
||||
}
|
||||
|
||||
private int fHasVarArgs;
|
||||
private int fExpansionOffset;
|
||||
private int fExpansionEndOffset;
|
||||
private Token fNameToken;
|
||||
|
||||
MacroDefinitionParser() {
|
||||
}
|
||||
|
||||
/**
|
||||
* In case the name was successfully parsed, the name token is returned.
|
||||
* Otherwise the return value is undefined.
|
||||
|
|
|
@ -15,7 +15,6 @@ import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.parser.Keywords;
|
||||
import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.Lexer.LexerOptions;
|
||||
|
||||
|
@ -145,24 +144,7 @@ class ObjectStyleMacro extends PreprocessorMacro {
|
|||
}
|
||||
|
||||
public char[] getExpansion() {
|
||||
TokenList tl= getTokens(new MacroDefinitionParser(), new LexerOptions());
|
||||
StringBuffer buf= new StringBuffer();
|
||||
Token t= tl.first();
|
||||
if (t == null) {
|
||||
return CharArrayUtils.EMPTY;
|
||||
}
|
||||
int endOffset= t.getOffset();
|
||||
for (; t != null; t= (Token) t.getNext()) {
|
||||
if (endOffset < t.getOffset()) {
|
||||
buf.append(' ');
|
||||
}
|
||||
buf.append(t.getCharImage());
|
||||
endOffset= t.getEndOffset();
|
||||
}
|
||||
final int length= buf.length();
|
||||
final char[] expansion= new char[length];
|
||||
buf.getChars(0, length, expansion, 0);
|
||||
return expansion;
|
||||
return MacroDefinitionParser.getExpansion(fExpansion, fExpansionOffset, fEndOffset);
|
||||
}
|
||||
|
||||
public char[] getExpansionImage() {
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IProblem;
|
||||
import org.eclipse.cdt.internal.core.parser.problem.BaseProblemFactory;
|
|
@ -6,9 +6,9 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||
|
||||
import java.io.File;
|
||||
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,44 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
||||
public class DependencyTree implements IASTTranslationUnit.IDependencyTree, IDependencyNodeHost {
|
||||
|
||||
private final String tu_path;
|
||||
|
||||
public DependencyTree( String path )
|
||||
{
|
||||
tu_path = path;
|
||||
}
|
||||
|
||||
public String getTranslationUnitPath() {
|
||||
return tu_path;
|
||||
}
|
||||
|
||||
private IASTInclusionNode [] incs = new IASTInclusionNode[2];
|
||||
private int incsPos=-1;
|
||||
|
||||
public IASTInclusionNode[] getInclusions() {
|
||||
incs = (IASTInclusionNode[]) ArrayUtil.removeNullsAfter( IASTInclusionNode.class, incs, incsPos );
|
||||
return incs;
|
||||
}
|
||||
|
||||
public void addInclusionNode(IASTInclusionNode node) {
|
||||
if (node != null) {
|
||||
incs = (IASTInclusionNode[]) ArrayUtil.append( IASTInclusionNode.class, incs, ++incsPos, node );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation 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:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on Oct 5, 2004
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
abstract public class DynamicFunctionStyleMacro extends FunctionStyleMacro {
|
||||
|
||||
public DynamicFunctionStyleMacro( char[] name, char[][] arglist ) {
|
||||
super( name, "".toCharArray(), arglist ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public abstract char [] execute( CharArrayObjectMap argmap );
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2006 IBM Corporation 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:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IMacro;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog.IMacroDefinition;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public abstract class DynamicStyleMacro implements IMacro{
|
||||
|
||||
public abstract char [] execute();
|
||||
|
||||
public DynamicStyleMacro( char [] n )
|
||||
{
|
||||
name = n;
|
||||
}
|
||||
public final char [] name;
|
||||
public IMacroDefinition attachment;
|
||||
|
||||
public char[] getSignature()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
public char[] getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
public char[] getExpansion() {
|
||||
return execute();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,144 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2007 IBM Corporation 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:
|
||||
* IBM Corporation - initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Ferguson (Symbian)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public class FunctionStyleMacro extends ObjectStyleMacro {
|
||||
|
||||
private static final char[] VA_ARGS_CHARARRAY = "__VA_ARGS__".toCharArray(); //$NON-NLS-1$
|
||||
private static final char[] ELLIPSIS_CHARARRAY = "...".toString().toCharArray(); //$NON-NLS-1$
|
||||
public char[][] arglist;
|
||||
private char[] sig = null;
|
||||
private boolean hasVarArgs = false;
|
||||
private boolean hasGCCVarArgs = false;
|
||||
private int varArgsPosition = -1;
|
||||
|
||||
public FunctionStyleMacro(char[] name, char[] expansion, char[][] arglist) {
|
||||
super(name, expansion);
|
||||
this.arglist = arglist;
|
||||
|
||||
// determine if there's an argument with "..."
|
||||
if (arglist != null && arglist.length > 0 && arglist[0]!= null) {
|
||||
int last = -1;
|
||||
|
||||
// if the last element in the list is null then binary search for the last non-null element
|
||||
if (arglist[arglist.length-1] == null) {
|
||||
int largest = arglist.length - 1;
|
||||
int smallest = 0;
|
||||
for (int j=arglist.length/2; last == -1; ) {
|
||||
if (arglist[j] == null) {
|
||||
largest = j;
|
||||
j=smallest + (largest-smallest)/2;
|
||||
} else {
|
||||
smallest = j;
|
||||
j=smallest + (largest - smallest)/2;
|
||||
if ((j+1 == arglist.length && arglist[j] != null) || (arglist[j] != null && arglist[j+1] == null))
|
||||
last = j;
|
||||
}
|
||||
}
|
||||
} else
|
||||
last = arglist.length-1;
|
||||
|
||||
if (arglist[last] != null && CharArrayUtils.equals(arglist[last], ELLIPSIS_CHARARRAY)) {
|
||||
this.hasVarArgs = true;
|
||||
varArgsPosition = last;
|
||||
// change the arg to __VA_ARGS__ so this will be replaced properly later on...
|
||||
arglist[last] = VA_ARGS_CHARARRAY;
|
||||
} else if (arglist[last] != null && CharArrayUtils.equals(arglist[last], arglist[last].length - ELLIPSIS_CHARARRAY.length, ELLIPSIS_CHARARRAY.length, ELLIPSIS_CHARARRAY)) { // if the last 3 are '...'
|
||||
this.hasGCCVarArgs = true;
|
||||
varArgsPosition = last;
|
||||
// change the arg to "argname" instead of "argname..." so argname will be replaced properly later on...
|
||||
char[] swap = new char[arglist[last].length - ELLIPSIS_CHARARRAY.length];
|
||||
System.arraycopy(arglist[last], 0, swap, 0, swap.length);
|
||||
arglist[last] = swap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public char[][] getOriginalParameters() {
|
||||
if (varArgsPosition == -1) {
|
||||
return arglist;
|
||||
}
|
||||
ArrayList result= new ArrayList(arglist.length);
|
||||
for (int i = 0; i < arglist.length; i++) {
|
||||
final char[] var= arglist[i];
|
||||
if (var != null) {
|
||||
if (i != varArgsPosition) {
|
||||
result.add(var);
|
||||
}
|
||||
else {
|
||||
if (CharArrayUtils.equals(var, VA_ARGS_CHARARRAY)) {
|
||||
result.add(ELLIPSIS_CHARARRAY);
|
||||
}
|
||||
else {
|
||||
char[] varell= new char[var.length+ELLIPSIS_CHARARRAY.length];
|
||||
System.arraycopy(var, 0, varell, 0, var.length);
|
||||
System.arraycopy(ELLIPSIS_CHARARRAY, 0, varell, var.length, ELLIPSIS_CHARARRAY.length);
|
||||
result.add(varell);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (char[][]) result.toArray(new char[result.size()][]);
|
||||
}
|
||||
|
||||
public char[] getSignature(){
|
||||
if( sig != null )
|
||||
return sig;
|
||||
|
||||
int len = name.length + 2 /*()*/;
|
||||
final char[][] params = getOriginalParameters();
|
||||
for( int i = 0; i < params.length && params[i] != null; i++ ){
|
||||
if( i + 1 < params.length && params[i+1] != null)
|
||||
len += 1; /*,*/
|
||||
len += params[i].length;
|
||||
}
|
||||
sig = new char[len];
|
||||
System.arraycopy( name, 0, sig, 0, name.length );
|
||||
sig[name.length] = '(';
|
||||
int idx = name.length + 1;
|
||||
for( int i = 0; i < params.length && params[i] != null; i++ ){
|
||||
System.arraycopy( params[i], 0, sig, idx, params[i].length );
|
||||
idx += params[i].length;
|
||||
if( i + 1 < params.length && params[i+1] != null )
|
||||
sig[idx++] = ',';
|
||||
}
|
||||
sig[idx] = ')';
|
||||
return sig;
|
||||
}
|
||||
public class Expansion {
|
||||
|
||||
public final CharArrayObjectMap definitions
|
||||
= new CharArrayObjectMap(FunctionStyleMacro.this.arglist.length);
|
||||
|
||||
}
|
||||
|
||||
public boolean hasVarArgs() {
|
||||
return hasVarArgs;
|
||||
}
|
||||
|
||||
public boolean hasGCCVarArgs() {
|
||||
return hasGCCVarArgs;
|
||||
}
|
||||
|
||||
public int getVarArgsPosition() {
|
||||
return varArgsPosition;
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2007 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
|
||||
/**
|
||||
* The main purpose of this class is to provide a subclass of GCCScannerExtensionConfiguration
|
||||
* for exclusive use in the old parser (ParserFactory.createScanner()) so that as old
|
||||
* hacks are removed when fixed in the new parser, they can still apply to the old parser. This
|
||||
* way the old parser will not have to be maintained as it's no longer being tested.
|
||||
*
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class GCCOldScannerExtensionConfiguration extends
|
||||
GCCScannerExtensionConfiguration {
|
||||
|
||||
private static final ObjectStyleMacro __cdecl = new ObjectStyleMacro(
|
||||
"__cdecl".toCharArray(), emptyCharArray); //$NON-NLS-1$
|
||||
|
||||
private static final FunctionStyleMacro __attribute__ = new FunctionStyleMacro(
|
||||
"__attribute__".toCharArray(), //$NON-NLS-1$
|
||||
emptyCharArray, new char[][] { "arg".toCharArray() }); //$NON-NLS-1$
|
||||
|
||||
private static final FunctionStyleMacro __declspec = new FunctionStyleMacro(
|
||||
"__declspec".toCharArray(), //$NON-NLS-1$
|
||||
emptyCharArray, new char[][] { "arg".toCharArray() }); //$NON-NLS-1$
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerConfiguration#getAdditionalMacros()
|
||||
*/
|
||||
public CharArrayObjectMap getAdditionalMacros() {
|
||||
CharArrayObjectMap result = super.getAdditionalMacros();
|
||||
|
||||
result.put(__cdecl.name, __cdecl);
|
||||
result.put(__attribute__.name, __attribute__);
|
||||
result.put(__declspec.name, __declspec);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2007 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import org.eclipse.cdt.core.dom.parser.cpp.GPPScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
|
||||
/**
|
||||
* The main purpose of this class is to provide a subclass of GPPScannerExtensionConfiguration
|
||||
* for exclusive use in the old parser (ParserFactory.createScanner()) so that as old
|
||||
* hacks are removed when fixed in the new parser, they can still apply to the old parser. This
|
||||
* way the old parser will not have to be maintained as it's no longer being tested.
|
||||
*
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class GPPOldScannerExtensionConfiguration extends
|
||||
GPPScannerExtensionConfiguration {
|
||||
|
||||
private static final ObjectStyleMacro __cdecl = new ObjectStyleMacro(
|
||||
"__cdecl".toCharArray(), emptyCharArray); //$NON-NLS-1$
|
||||
|
||||
private static final FunctionStyleMacro __attribute__ = new FunctionStyleMacro(
|
||||
"__attribute__".toCharArray(), //$NON-NLS-1$
|
||||
emptyCharArray, new char[][] { "arg".toCharArray() }); //$NON-NLS-1$
|
||||
|
||||
private static final FunctionStyleMacro __declspec = new FunctionStyleMacro(
|
||||
"__declspec".toCharArray(), //$NON-NLS-1$
|
||||
emptyCharArray, new char[][] { "arg".toCharArray() }); //$NON-NLS-1$
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerConfiguration#getAdditionalMacros()
|
||||
*/
|
||||
public CharArrayObjectMap getAdditionalMacros() {
|
||||
CharArrayObjectMap result = super.getAdditionalMacros();
|
||||
|
||||
result.put(__cdecl.name, __cdecl);
|
||||
result.put(__attribute__.name, __attribute__);
|
||||
result.put(__declspec.name, __declspec);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit.IDependencyTree.IASTInclusionNode;
|
||||
|
||||
public interface IDependencyNodeHost {
|
||||
|
||||
public void addInclusionNode( IASTInclusionNode node );
|
||||
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2007 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit.IDependencyTree;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTPreprocessorSelectionResult;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public interface ILocationResolver {
|
||||
|
||||
public IASTPreprocessorMacroDefinition [] getMacroDefinitions();
|
||||
public IASTPreprocessorMacroDefinition [] getBuiltinMacroDefinitions();
|
||||
public IASTPreprocessorIncludeStatement [] getIncludeDirectives();
|
||||
public IASTPreprocessorStatement [] getAllPreprocessorStatements();
|
||||
|
||||
public IASTNodeLocation [] getLocations( int offset, int length );
|
||||
|
||||
public char [] getUnpreprocessedSignature( IASTNodeLocation [] locations );
|
||||
|
||||
public IASTProblem[] getScannerProblems();
|
||||
|
||||
public String getTranslationUnitPath();
|
||||
|
||||
public void cleanup();
|
||||
|
||||
public ASTPreprocessorSelectionResult getPreprocessorNode( String path, int offset, int length ) throws InvalidPreprocessorNodeException;
|
||||
|
||||
public void setRootNode(IASTTranslationUnit root );
|
||||
public IASTFileLocation flattenLocations(IASTNodeLocation[] nodeLocations);
|
||||
public IASTName[] getReferences(IMacroBinding binding);
|
||||
public IASTName[] getDeclarations(IMacroBinding binding);
|
||||
public IASTName[] getMacroExpansions();
|
||||
public IDependencyTree getDependencyTree();
|
||||
public String getContainingFilename(int offset);
|
||||
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2007 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
* Emanuel Graf (IFS)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public interface IScannerPreprocessorLog {
|
||||
|
||||
public void startTranslationUnit(CodeReader tu_reader);
|
||||
|
||||
public void endTranslationUnit(int offset);
|
||||
|
||||
public void startInclusion(CodeReader reader, int offset, int endOffset, int nameOffset, int nameEndoffset, char[] name, boolean systemInclude);
|
||||
|
||||
public void endInclusion(CodeReader reader, int offset);
|
||||
|
||||
public void startObjectStyleMacroExpansion(IMacroDefinition macro,
|
||||
int startOffset, int endOffset);
|
||||
|
||||
public void endObjectStyleMacroExpansion(IMacroDefinition macro, int offset);
|
||||
|
||||
|
||||
public void startFunctionStyleExpansion(IMacroDefinition macro,
|
||||
char[][] parameters, int startOffset, int endOffset, char[][] actualArguments);
|
||||
|
||||
public void endFunctionStyleExpansion(IMacroDefinition macro, int offset);
|
||||
|
||||
public interface IMacroDefinition {
|
||||
public char[] getName();
|
||||
public char[] getExpansion();
|
||||
|
||||
public IMacroBinding getBinding();
|
||||
public void setBinding( IMacroBinding b );
|
||||
}
|
||||
|
||||
public IMacroDefinition defineObjectStyleMacro(ObjectStyleMacro m,
|
||||
int startOffset, int nameOffset, int nameEndOffset, int endOffset);
|
||||
|
||||
public IMacroDefinition defineFunctionStyleMacro(FunctionStyleMacro m,
|
||||
int startOffset, int nameOffset, int nameEndOffset, int endOffset);
|
||||
|
||||
public void encounterPoundIf(int startOffset, int endOffset, boolean taken, char[] condition);
|
||||
|
||||
public void encounterPoundIfdef(int startOffset, int endOffset,
|
||||
boolean taken, char[] condition);
|
||||
|
||||
public void encounterPoundIfndef(int startOffset, int endOffset,
|
||||
boolean taken, char[] condition);
|
||||
|
||||
public void encounterPoundElse(int startOffset, int endOffset, boolean taken);
|
||||
|
||||
public void encounterPoundElif(int startOffset, int endOffset, boolean taken, char[] condition);
|
||||
|
||||
public void encounterPoundEndIf(int startOffset, int endOffset);
|
||||
|
||||
public void encounterPoundPragma(int startOffset, int endOffset, char[] msg);
|
||||
|
||||
public void encounterPoundError(int startOffset, int endOffset, char[] msg);
|
||||
|
||||
public void encounterPoundWarning(int startOffset, int endOffset, char[] msg);
|
||||
|
||||
public void encounterPoundUndef(int startOffset, int endOffset,
|
||||
char[] symbol, int nameOffset, IMacroDefinition macroDefinition);
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #encounterPoundInclude(int, int, int, int, char[], char[], boolean, boolean)}.
|
||||
*/
|
||||
public void encounterPoundInclude(int startOffset, int nameOffset, int nameEndOffset, int endOffset, char[] name, boolean systemInclude, boolean active);
|
||||
|
||||
/**
|
||||
* Report an include that is not actually processed ({@link #startInclusion(CodeReader, int, int, int, int, char[], boolean)}
|
||||
* To report hidden dependencies (bug 167100) you can use the path parameter.
|
||||
* @param startOffset
|
||||
* @param nameOffset
|
||||
* @param nameEndOffset
|
||||
* @param endOffset
|
||||
* @param name the name of the include as found in the source
|
||||
* @param hiddenDependency a file-path in case the include is a hidden dependency, or <code>null</code>.
|
||||
* @param systemInclude
|
||||
* @param active
|
||||
*/
|
||||
public void encounterPoundInclude(int startOffset, int nameOffset, int nameEndOffset, int endOffset, char[] name, char[] hiddenDependency, boolean systemInclude, boolean active);
|
||||
|
||||
public void encounterProblem(IASTProblem problem);
|
||||
|
||||
public IMacroDefinition registerBuiltinObjectStyleMacro(ObjectStyleMacro macro);
|
||||
|
||||
public IMacroDefinition registerBuiltinFunctionStyleMacro(FunctionStyleMacro macro);
|
||||
|
||||
public IMacroDefinition registerBuiltinDynamicFunctionStyleMacro(DynamicFunctionStyleMacro macro);
|
||||
|
||||
public IMacroDefinition registerBuiltinDynamicStyleMacro(DynamicStyleMacro macro);
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit.IDependencyTree.IASTInclusionNode;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
||||
public class InclusionNode implements IASTInclusionNode, IDependencyNodeHost {
|
||||
|
||||
private final IASTPreprocessorIncludeStatement stmt;
|
||||
|
||||
public InclusionNode(IASTPreprocessorIncludeStatement stmt) {
|
||||
this.stmt = stmt;
|
||||
}
|
||||
|
||||
public IASTPreprocessorIncludeStatement getIncludeDirective() {
|
||||
return stmt;
|
||||
}
|
||||
|
||||
private IASTInclusionNode [] incs = new IASTInclusionNode[2];
|
||||
private int incsPos=-1;
|
||||
|
||||
public IASTInclusionNode[] getNestedInclusions() {
|
||||
incs = (IASTInclusionNode[]) ArrayUtil.removeNullsAfter( IASTInclusionNode.class, incs, incsPos );
|
||||
return incs;
|
||||
}
|
||||
|
||||
public void addInclusionNode(IASTInclusionNode node) {
|
||||
if (node != null) {
|
||||
incs = (IASTInclusionNode[]) ArrayUtil.append( IASTInclusionNode.class, incs, ++incsPos, node );
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return stmt.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
/**
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class InvalidPreprocessorNodeException extends Exception {
|
||||
|
||||
public InvalidPreprocessorNodeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public InvalidPreprocessorNodeException(String message, int offset) {
|
||||
super(message);
|
||||
globalOffset = offset;
|
||||
}
|
||||
|
||||
private int globalOffset = -1;
|
||||
|
||||
public int getGlobalOffset() {
|
||||
return globalOffset;
|
||||
}
|
||||
|
||||
public void setGlobalOffset(int offset) {
|
||||
globalOffset = offset;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,80 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
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.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.LocationMap._FunctionMacroDefinition;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
public class MacroBinding extends PlatformObject implements IMacroBinding {
|
||||
|
||||
private final char[] name;
|
||||
private final IScope scope;
|
||||
private final IScannerPreprocessorLog.IMacroDefinition definition;
|
||||
|
||||
public MacroBinding( char [] name, IScope scope, IScannerPreprocessorLog.IMacroDefinition definition )
|
||||
{
|
||||
this.name = name;
|
||||
this.scope = scope;
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return new String( name );
|
||||
}
|
||||
|
||||
public char[] getNameCharArray() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public IScope getScope() throws DOMException {
|
||||
return scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the definition.
|
||||
*/
|
||||
public IScannerPreprocessorLog.IMacroDefinition getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
public ILinkage getLinkage() {
|
||||
return Linkage.NO_LINKAGE;
|
||||
}
|
||||
|
||||
public char[] getExpansion() {
|
||||
return definition.getExpansion();
|
||||
}
|
||||
|
||||
public boolean isFunctionStyle() {
|
||||
return definition instanceof _FunctionMacroDefinition;
|
||||
}
|
||||
|
||||
public char[][] getParameterList() {
|
||||
if (isFunctionStyle()) {
|
||||
return ((_FunctionMacroDefinition) definition).getParms();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public char[] getExpansionImage() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public char[][] getParameterPlaceholderList() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation 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:
|
||||
* IBM Corporation - initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public class MacroExpansionToken implements IToken {
|
||||
|
||||
public MacroExpansionToken() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#getType()
|
||||
*/
|
||||
public int getType() {
|
||||
return IToken.tMACROEXP;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#getImage()
|
||||
*/
|
||||
public String getImage() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#getOffset()
|
||||
*/
|
||||
public int getOffset() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#getLength()
|
||||
*/
|
||||
public int getLength() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#getEndOffset()
|
||||
*/
|
||||
public int getEndOffset() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#getLineNumber()
|
||||
*/
|
||||
public int getLineNumber() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#getNext()
|
||||
*/
|
||||
public IToken getNext() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#setImage(java.lang.String)
|
||||
*/
|
||||
public void setImage(String i) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#setNext(org.eclipse.cdt.core.parser.IToken)
|
||||
*/
|
||||
public void setNext(IToken t) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#setType(int)
|
||||
*/
|
||||
public void setType(int i) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#looksLikeExpression()
|
||||
*/
|
||||
public boolean looksLikeExpression() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#isPointer()
|
||||
*/
|
||||
public boolean isPointer() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#isOperator()
|
||||
*/
|
||||
public boolean isOperator() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#canBeAPrefix()
|
||||
*/
|
||||
public boolean canBeAPrefix() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#getCharImage()
|
||||
*/
|
||||
public char[] getCharImage() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#setImage(char[])
|
||||
*/
|
||||
public void setImage(char[] i) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#getFilename()
|
||||
*/
|
||||
public char[] getFilename() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation 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:
|
||||
* IBM Corporation - initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IMacro;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog.IMacroDefinition;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public class ObjectStyleMacro implements IMacro {
|
||||
|
||||
public char[] name;
|
||||
protected char[] expansion;
|
||||
public IMacroDefinition attachment;
|
||||
|
||||
public ObjectStyleMacro(char[] name, char[] expansion) {
|
||||
this.name = name;
|
||||
this.expansion = expansion;
|
||||
}
|
||||
|
||||
public char[] getSignature() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public char[] getName(){
|
||||
return name;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new String( name );
|
||||
}
|
||||
|
||||
public char[] getExpansion() {
|
||||
return expansion;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,240 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2007 IBM Corporation 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:
|
||||
* IBM - Initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserMessages;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class ScannerASTProblem extends ASTNode implements IASTProblem {
|
||||
|
||||
private final char[] arg;
|
||||
|
||||
private final int id;
|
||||
|
||||
private final boolean isError;
|
||||
|
||||
private final boolean isWarning;
|
||||
|
||||
private String message = null;
|
||||
|
||||
public ScannerASTProblem(int id, char[] arg, boolean warn, boolean error) {
|
||||
this.id = id;
|
||||
this.arg = arg;
|
||||
this.isWarning = warn;
|
||||
this.isError = error;
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public boolean isError() {
|
||||
return isError;
|
||||
}
|
||||
|
||||
public boolean isWarning() {
|
||||
return isWarning;
|
||||
}
|
||||
|
||||
protected static final Map errorMessages;
|
||||
static {
|
||||
errorMessages = new HashMap();
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.PREPROCESSOR_POUND_ERROR),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.error")); //$NON-NLS-1$
|
||||
errorMessages.put(new Integer(IASTProblem.PREPROCESSOR_POUND_WARNING), ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.warning")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.PREPROCESSOR_INCLUSION_NOT_FOUND),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.inclusionNotFound")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.PREPROCESSOR_DEFINITION_NOT_FOUND),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.definitionNotFound")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.PREPROCESSOR_INVALID_MACRO_DEFN),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.invalidMacroDefn")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.PREPROCESSOR_INVALID_MACRO_REDEFN),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.invalidMacroRedefn")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.PREPROCESSOR_UNBALANCE_CONDITION),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.unbalancedConditional")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IASTProblem.PREPROCESSOR_CONDITIONAL_EVAL_ERROR),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.conditionalEval")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.PREPROCESSOR_MACRO_USAGE_ERROR),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.macroUsage")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.PREPROCESSOR_CIRCULAR_INCLUSION),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.circularInclusion")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.PREPROCESSOR_INVALID_DIRECTIVE),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.invalidDirective")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.PREPROCESSOR_MACRO_PASTING_ERROR),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.macroPasting")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IASTProblem.PREPROCESSOR_MISSING_RPAREN_PARMLIST),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.missingRParen")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.PREPROCESSOR_INVALID_VA_ARGS),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.preproc.invalidVaArgs")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SCANNER_INVALID_ESCAPECHAR),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.scanner.invalidEscapeChar")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SCANNER_UNBOUNDED_STRING),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.scanner.unboundedString")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SCANNER_BAD_FLOATING_POINT),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.scanner.badFloatingPoint")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SCANNER_BAD_HEX_FORMAT),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.scanner.badHexFormat")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SCANNER_BAD_OCTAL_FORMAT),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.scanner.badOctalFormat")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SCANNER_BAD_DECIMAL_FORMAT),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.scanner.badDecimalFormat")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SCANNER_ASSIGNMENT_NOT_ALLOWED),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.scanner.assignmentNotAllowed")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SCANNER_DIVIDE_BY_ZERO),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.scanner.divideByZero")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SCANNER_MISSING_R_PAREN),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.scanner.missingRParen")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SCANNER_EXPRESSION_SYNTAX_ERROR),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.scanner.expressionSyntaxError")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SCANNER_ILLEGAL_IDENTIFIER),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.scanner.illegalIdentifier")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SCANNER_BAD_CONDITIONAL_EXPRESSION),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.scanner.badConditionalExpression")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SCANNER_UNEXPECTED_EOF),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.scanner.unexpectedEOF")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SCANNER_BAD_CHARACTER),
|
||||
ParserMessages
|
||||
.getString("ScannerProblemFactory.error.scanner.badCharacter")); //$NON-NLS-1$
|
||||
errorMessages.put(new Integer(IASTProblem.SYNTAX_ERROR), ParserMessages
|
||||
.getString("ParserProblemFactory.error.syntax.syntaxError")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
protected final static String PROBLEM_PATTERN = "BaseProblemFactory.problemPattern"; //$NON-NLS-1$
|
||||
|
||||
public String getMessage() {
|
||||
if (message != null)
|
||||
return message;
|
||||
|
||||
String msg = (String) errorMessages.get(new Integer(id));
|
||||
if (msg == null)
|
||||
msg = ""; //$NON-NLS-1$
|
||||
|
||||
if (arg != null) {
|
||||
msg = MessageFormat.format(msg, new Object[] { new String(arg) });
|
||||
}
|
||||
|
||||
IASTFileLocation f = getFileLocation();
|
||||
String file = null;
|
||||
int line = 0;
|
||||
if( f == null )
|
||||
{
|
||||
file = ""; //$NON-NLS-1$
|
||||
} else {
|
||||
file = f.getFileName();
|
||||
line = f.getStartingLineNumber();
|
||||
}
|
||||
Object[] args = new Object[] { msg, file, new Integer(line) };
|
||||
message = ParserMessages.getFormattedString(PROBLEM_PATTERN, args);
|
||||
return message;
|
||||
}
|
||||
|
||||
public boolean checkCategory(int bitmask) {
|
||||
return ((id & bitmask) != 0);
|
||||
}
|
||||
|
||||
public String getArguments() {
|
||||
return arg != null ? String.valueOf(arg) : ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
|
@ -1,331 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2007 IBM Corporation 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:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.token;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
|
||||
|
||||
/**
|
||||
* @author johnc
|
||||
*/
|
||||
public abstract class AbstractToken implements IToken, ITokenDuple {
|
||||
|
||||
private final char[] filename;
|
||||
|
||||
public AbstractToken( int type, int lineNumber, char [] filename )
|
||||
{
|
||||
setType( type );
|
||||
this.lineNumber = lineNumber;
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public AbstractToken( int type, char [] filename, int lineNumber )
|
||||
{
|
||||
setType( type );
|
||||
this.filename = filename;
|
||||
this.lineNumber = lineNumber;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getImage();
|
||||
}
|
||||
|
||||
public abstract String getImage();
|
||||
public abstract int getOffset();
|
||||
public abstract int getLength();
|
||||
|
||||
public int getType() { return type; }
|
||||
|
||||
public void setType(int i) {
|
||||
type = i;
|
||||
}
|
||||
|
||||
public int getLineNumber() {
|
||||
return lineNumber;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#getFilename()
|
||||
*/
|
||||
public char[] getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
public int getEndOffset() { return getOffset() + getLength(); }
|
||||
|
||||
protected int type;
|
||||
protected int lineNumber = 1;
|
||||
protected IToken next = null;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals(Object other) {
|
||||
if( other == null ) return false;
|
||||
if( !( other instanceof IToken ) )
|
||||
return false;
|
||||
if( ((IToken)other).getType() != getType() )
|
||||
return false;
|
||||
if( !CharArrayUtils.equals( ((IToken)other).getCharImage(), getCharImage() ) )
|
||||
return false;
|
||||
if( getOffset() != ((IToken)other).getOffset() )
|
||||
return false;
|
||||
if( getEndOffset() != ((IToken)other).getEndOffset() )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#isKeyword()
|
||||
*/
|
||||
public boolean canBeAPrefix() {
|
||||
switch( getType() )
|
||||
{
|
||||
case tIDENTIFIER:
|
||||
case tCOMPL:
|
||||
return true;
|
||||
default:
|
||||
if( getType() >= t_and && getType() <= t_xor_eq ) return true;
|
||||
if( getType() >= t__Bool && getType() <= t_restrict ) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean looksLikeExpression()
|
||||
{
|
||||
switch( getType() )
|
||||
{
|
||||
case IToken.tINTEGER:
|
||||
case IToken.t_false:
|
||||
case IToken.t_true:
|
||||
case IToken.tSTRING:
|
||||
case IToken.tLSTRING:
|
||||
case IToken.tFLOATINGPT:
|
||||
case IToken.tCHAR:
|
||||
case IToken.tAMPER:
|
||||
case IToken.tDOT:
|
||||
case IToken.tLPAREN:
|
||||
case IToken.tMINUS:
|
||||
case IToken.tSTAR:
|
||||
case IToken.tPLUS:
|
||||
case IToken.tNOT:
|
||||
case IToken.tCOMPL:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isOperator()
|
||||
{
|
||||
switch( getType() )
|
||||
{
|
||||
case IToken.t_new:
|
||||
case IToken.t_delete:
|
||||
case IToken.tPLUS:
|
||||
case IToken.tMINUS:
|
||||
case IToken.tSTAR:
|
||||
case IToken.tDIV:
|
||||
case IToken.tXOR:
|
||||
case IToken.tMOD:
|
||||
case IToken.tAMPER:
|
||||
case IToken.tBITOR:
|
||||
case IToken.tCOMPL:
|
||||
case IToken.tNOT:
|
||||
case IToken.tASSIGN:
|
||||
case IToken.tLT:
|
||||
case IToken.tGT:
|
||||
case IToken.tPLUSASSIGN:
|
||||
case IToken.tMINUSASSIGN:
|
||||
case IToken.tSTARASSIGN:
|
||||
case IToken.tDIVASSIGN:
|
||||
case IToken.tMODASSIGN:
|
||||
case IToken.tBITORASSIGN:
|
||||
case IToken.tAMPERASSIGN:
|
||||
case IToken.tXORASSIGN:
|
||||
case IToken.tSHIFTL:
|
||||
case IToken.tSHIFTR:
|
||||
case IToken.tSHIFTLASSIGN:
|
||||
case IToken.tSHIFTRASSIGN:
|
||||
case IToken.tEQUAL:
|
||||
case IToken.tNOTEQUAL:
|
||||
case IToken.tLTEQUAL:
|
||||
case IToken.tGTEQUAL:
|
||||
case IToken.tAND:
|
||||
case IToken.tOR:
|
||||
case IToken.tINCR:
|
||||
case IToken.tDECR:
|
||||
case IToken.tCOMMA:
|
||||
case IToken.tARROW:
|
||||
case IToken.tARROWSTAR:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPointer()
|
||||
{
|
||||
return (getType() == IToken.tAMPER || getType() == IToken.tSTAR);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public final IToken getNext() { return next; }
|
||||
public void setNext(IToken t) { next = t; }
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#contains(org.eclipse.cdt.core.parser.ITokenDuple)
|
||||
*/
|
||||
public boolean contains(ITokenDuple duple) {
|
||||
return ( duple.getFirstToken() == duple.getLastToken() ) && ( duple.getFirstToken() == this );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#extractNameFromTemplateId()
|
||||
*/
|
||||
public char[] extractNameFromTemplateId(){
|
||||
return getCharImage();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#findLastTokenType(int)
|
||||
*/
|
||||
public int findLastTokenType(int t) {
|
||||
if( getType() == t ) return 0;
|
||||
return -1;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getFirstToken()
|
||||
*/
|
||||
public IToken getFirstToken() {
|
||||
return this;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getLastSegment()
|
||||
*/
|
||||
public ITokenDuple getLastSegment() {
|
||||
return this;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getLastToken()
|
||||
*/
|
||||
public IToken getLastToken() {
|
||||
return this;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getLeadingSegments()
|
||||
*/
|
||||
public ITokenDuple getLeadingSegments() {
|
||||
return null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getSegmentCount()
|
||||
*/
|
||||
public int getSegmentCount() {
|
||||
return 1;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getStartOffset()
|
||||
*/
|
||||
public int getStartOffset() {
|
||||
return getOffset();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getSubrange(int, int)
|
||||
*/
|
||||
public ITokenDuple getSubrange(int startIndex, int endIndex) {
|
||||
if( startIndex == 0 && endIndex == 0 ) return this;
|
||||
return null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getTemplateIdArgLists()
|
||||
*/
|
||||
public List[] getTemplateIdArgLists() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getToken(int)
|
||||
*/
|
||||
public IToken getToken(int index) {
|
||||
if( index == 0 ) return this;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private class SingleIterator implements Iterator
|
||||
{
|
||||
boolean hasNext = true;
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Iterator#remove()
|
||||
*/
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Iterator#hasNext()
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
return hasNext;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Iterator#next()
|
||||
*/
|
||||
public Object next() {
|
||||
hasNext = false;
|
||||
return AbstractToken.this;
|
||||
}
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#iterator()
|
||||
*/
|
||||
public Iterator iterator() {
|
||||
return new SingleIterator();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#length()
|
||||
*/
|
||||
public int length() {
|
||||
return 1;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#syntaxOfName()
|
||||
*/
|
||||
public boolean syntaxOfName() {
|
||||
return ( getType() == IToken.tIDENTIFIER );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#toQualifiedName()
|
||||
*/
|
||||
public String[] toQualifiedName() {
|
||||
String [] qualifiedName = new String[1];
|
||||
qualifiedName[0] = getImage();
|
||||
return qualifiedName;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getSegmentIterator()
|
||||
*/
|
||||
public ITokenDuple[] getSegments() {
|
||||
ITokenDuple [] r = new ITokenDuple[0];
|
||||
r[0] = this;
|
||||
return r;
|
||||
}
|
||||
}
|
|
@ -1,485 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2001, 2007 IBM Corporation 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:
|
||||
* Rational Software - initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.token;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.Keywords;
|
||||
|
||||
public class SimpleToken extends AbstractToken implements IToken {
|
||||
|
||||
public SimpleToken( int t, int endOffset, char [] filename, int line )
|
||||
{
|
||||
super( t, filename, line );
|
||||
setOffsetAndLength( endOffset );
|
||||
}
|
||||
|
||||
protected int offset;
|
||||
|
||||
// All the tokens generated by the macro expansion
|
||||
// will have dimensions (offset and length) equal to the expanding symbol.
|
||||
public int getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return getCharImage().length;
|
||||
}
|
||||
|
||||
protected void setOffsetAndLength( int endOffset )
|
||||
{
|
||||
this.offset = endOffset - getLength();
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
switch ( getType() ) {
|
||||
case IToken.tCOLONCOLON :
|
||||
return "::" ; //$NON-NLS-1$
|
||||
case IToken.tCOLON :
|
||||
return ":" ; //$NON-NLS-1$
|
||||
case IToken.tSEMI :
|
||||
return ";" ; //$NON-NLS-1$
|
||||
case IToken.tCOMMA :
|
||||
return "," ; //$NON-NLS-1$
|
||||
case IToken.tQUESTION :
|
||||
return "?" ; //$NON-NLS-1$
|
||||
case IToken.tLPAREN :
|
||||
return "(" ; //$NON-NLS-1$
|
||||
case IToken.tRPAREN :
|
||||
return ")" ; //$NON-NLS-1$
|
||||
case IToken.tLBRACKET :
|
||||
return "[" ; //$NON-NLS-1$
|
||||
case IToken.tRBRACKET :
|
||||
return "]" ; //$NON-NLS-1$
|
||||
case IToken.tLBRACE :
|
||||
return "{" ; //$NON-NLS-1$
|
||||
case IToken.tRBRACE :
|
||||
return "}"; //$NON-NLS-1$
|
||||
case IToken.tPLUSASSIGN :
|
||||
return "+="; //$NON-NLS-1$
|
||||
case IToken.tINCR :
|
||||
return "++" ; //$NON-NLS-1$
|
||||
case IToken.tPLUS :
|
||||
return "+"; //$NON-NLS-1$
|
||||
case IToken.tMINUSASSIGN :
|
||||
return "-=" ; //$NON-NLS-1$
|
||||
case IToken.tDECR :
|
||||
return "--" ; //$NON-NLS-1$
|
||||
case IToken.tARROWSTAR :
|
||||
return "->*" ; //$NON-NLS-1$
|
||||
case IToken.tARROW :
|
||||
return "->" ; //$NON-NLS-1$
|
||||
case IToken.tMINUS :
|
||||
return "-" ; //$NON-NLS-1$
|
||||
case IToken.tSTARASSIGN :
|
||||
return "*=" ; //$NON-NLS-1$
|
||||
case IToken.tSTAR :
|
||||
return "*" ; //$NON-NLS-1$
|
||||
case IToken.tMODASSIGN :
|
||||
return "%=" ; //$NON-NLS-1$
|
||||
case IToken.tMOD :
|
||||
return "%" ; //$NON-NLS-1$
|
||||
case IToken.tXORASSIGN :
|
||||
return "^=" ; //$NON-NLS-1$
|
||||
case IToken.tXOR :
|
||||
return "^" ; //$NON-NLS-1$
|
||||
case IToken.tAMPERASSIGN :
|
||||
return "&=" ; //$NON-NLS-1$
|
||||
case IToken.tAND :
|
||||
return "&&" ; //$NON-NLS-1$
|
||||
case IToken.tAMPER :
|
||||
return "&" ; //$NON-NLS-1$
|
||||
case IToken.tBITORASSIGN :
|
||||
return "|=" ; //$NON-NLS-1$
|
||||
case IToken.tOR :
|
||||
return "||" ; //$NON-NLS-1$
|
||||
case IToken.tBITOR :
|
||||
return "|" ; //$NON-NLS-1$
|
||||
case IToken.tCOMPL :
|
||||
return "~" ; //$NON-NLS-1$
|
||||
case IToken.tNOTEQUAL :
|
||||
return "!=" ; //$NON-NLS-1$
|
||||
case IToken.tNOT :
|
||||
return "!" ; //$NON-NLS-1$
|
||||
case IToken.tEQUAL :
|
||||
return "==" ; //$NON-NLS-1$
|
||||
case IToken.tASSIGN :
|
||||
return "=" ; //$NON-NLS-1$
|
||||
case IToken.tSHIFTL :
|
||||
return "<<" ; //$NON-NLS-1$
|
||||
case IToken.tLTEQUAL :
|
||||
return "<=" ; //$NON-NLS-1$
|
||||
case IToken.tLT :
|
||||
return "<"; //$NON-NLS-1$
|
||||
case IToken.tSHIFTRASSIGN :
|
||||
return ">>=" ; //$NON-NLS-1$
|
||||
case IToken.tSHIFTR :
|
||||
return ">>" ; //$NON-NLS-1$
|
||||
case IToken.tGTEQUAL :
|
||||
return ">=" ; //$NON-NLS-1$
|
||||
case IToken.tGT :
|
||||
return ">" ; //$NON-NLS-1$
|
||||
case IToken.tSHIFTLASSIGN :
|
||||
return "<<=" ; //$NON-NLS-1$
|
||||
case IToken.tELLIPSIS :
|
||||
return "..." ; //$NON-NLS-1$
|
||||
case IToken.tDOTSTAR :
|
||||
return ".*" ; //$NON-NLS-1$
|
||||
case IToken.tDOT :
|
||||
return "." ; //$NON-NLS-1$
|
||||
case IToken.tDIVASSIGN :
|
||||
return "/=" ; //$NON-NLS-1$
|
||||
case IToken.tDIV :
|
||||
return "/" ; //$NON-NLS-1$
|
||||
case IToken.t_and :
|
||||
return Keywords.AND;
|
||||
case IToken.t_and_eq :
|
||||
return Keywords.AND_EQ ;
|
||||
case IToken.t_asm :
|
||||
return Keywords.ASM ;
|
||||
case IToken.t_auto :
|
||||
return Keywords.AUTO ;
|
||||
case IToken.t_bitand :
|
||||
return Keywords.BITAND ;
|
||||
case IToken.t_bitor :
|
||||
return Keywords.BITOR ;
|
||||
case IToken.t_bool :
|
||||
return Keywords.BOOL ;
|
||||
case IToken.t_break :
|
||||
return Keywords.BREAK ;
|
||||
case IToken.t_case :
|
||||
return Keywords.CASE ;
|
||||
case IToken.t_catch :
|
||||
return Keywords.CATCH ;
|
||||
case IToken.t_char :
|
||||
return Keywords.CHAR ;
|
||||
case IToken.t_class :
|
||||
return Keywords.CLASS ;
|
||||
case IToken.t_compl :
|
||||
return Keywords.COMPL ;
|
||||
case IToken.t_const :
|
||||
return Keywords.CONST ;
|
||||
case IToken.t_const_cast :
|
||||
return Keywords.CONST_CAST ;
|
||||
case IToken.t_continue :
|
||||
return Keywords.CONTINUE ;
|
||||
case IToken.t_default :
|
||||
return Keywords.DEFAULT ;
|
||||
case IToken.t_delete :
|
||||
return Keywords.DELETE ;
|
||||
case IToken.t_do :
|
||||
return Keywords.DO;
|
||||
case IToken.t_double :
|
||||
return Keywords.DOUBLE ;
|
||||
case IToken.t_dynamic_cast :
|
||||
return Keywords.DYNAMIC_CAST ;
|
||||
case IToken.t_else :
|
||||
return Keywords.ELSE;
|
||||
case IToken.t_enum :
|
||||
return Keywords.ENUM ;
|
||||
case IToken.t_explicit :
|
||||
return Keywords.EXPLICIT ;
|
||||
case IToken.t_export :
|
||||
return Keywords.EXPORT ;
|
||||
case IToken.t_extern :
|
||||
return Keywords.EXTERN;
|
||||
case IToken.t_false :
|
||||
return Keywords.FALSE;
|
||||
case IToken.t_float :
|
||||
return Keywords.FLOAT;
|
||||
case IToken.t_for :
|
||||
return Keywords.FOR;
|
||||
case IToken.t_friend :
|
||||
return Keywords.FRIEND;
|
||||
case IToken.t_goto :
|
||||
return Keywords.GOTO;
|
||||
case IToken.t_if :
|
||||
return Keywords.IF ;
|
||||
case IToken.t_inline :
|
||||
return Keywords.INLINE ;
|
||||
case IToken.t_int :
|
||||
return Keywords.INT ;
|
||||
case IToken.t_long :
|
||||
return Keywords.LONG ;
|
||||
case IToken.t_mutable :
|
||||
return Keywords.MUTABLE ;
|
||||
case IToken.t_namespace :
|
||||
return Keywords.NAMESPACE ;
|
||||
case IToken.t_new :
|
||||
return Keywords.NEW ;
|
||||
case IToken.t_not :
|
||||
return Keywords.NOT ;
|
||||
case IToken.t_not_eq :
|
||||
return Keywords.NOT_EQ;
|
||||
case IToken.t_operator :
|
||||
return Keywords.OPERATOR ;
|
||||
case IToken.t_or :
|
||||
return Keywords.OR ;
|
||||
case IToken.t_or_eq :
|
||||
return Keywords.OR_EQ;
|
||||
case IToken.t_private :
|
||||
return Keywords.PRIVATE ;
|
||||
case IToken.t_protected :
|
||||
return Keywords.PROTECTED ;
|
||||
case IToken.t_public :
|
||||
return Keywords.PUBLIC ;
|
||||
case IToken.t_register :
|
||||
return Keywords.REGISTER ;
|
||||
case IToken.t_reinterpret_cast :
|
||||
return Keywords.REINTERPRET_CAST ;
|
||||
case IToken.t_return :
|
||||
return Keywords.RETURN ;
|
||||
case IToken.t_short :
|
||||
return Keywords.SHORT ;
|
||||
case IToken.t_sizeof :
|
||||
return Keywords.SIZEOF ;
|
||||
case IToken.t_static :
|
||||
return Keywords.STATIC ;
|
||||
case IToken.t_static_cast :
|
||||
return Keywords.STATIC_CAST ;
|
||||
case IToken.t_signed :
|
||||
return Keywords.SIGNED ;
|
||||
case IToken.t_struct :
|
||||
return Keywords.STRUCT ;
|
||||
case IToken.t_switch :
|
||||
return Keywords.SWITCH ;
|
||||
case IToken.t_template :
|
||||
return Keywords.TEMPLATE ;
|
||||
case IToken.t_this :
|
||||
return Keywords.THIS ;
|
||||
case IToken.t_throw :
|
||||
return Keywords.THROW ;
|
||||
case IToken.t_true :
|
||||
return Keywords.TRUE ;
|
||||
case IToken.t_try :
|
||||
return Keywords.TRY ;
|
||||
case IToken.t_typedef :
|
||||
return Keywords.TYPEDEF ;
|
||||
case IToken.t_typeid :
|
||||
return Keywords.TYPEID ;
|
||||
case IToken.t_typename :
|
||||
return Keywords.TYPENAME ;
|
||||
case IToken.t_union :
|
||||
return Keywords.UNION ;
|
||||
case IToken.t_unsigned :
|
||||
return Keywords.UNSIGNED ;
|
||||
case IToken.t_using :
|
||||
return Keywords.USING ;
|
||||
case IToken.t_virtual :
|
||||
return Keywords.VIRTUAL ;
|
||||
case IToken.t_void :
|
||||
return Keywords.VOID ;
|
||||
case IToken.t_volatile :
|
||||
return Keywords.VOLATILE;
|
||||
case IToken.t_wchar_t :
|
||||
return Keywords.WCHAR_T ;
|
||||
case IToken.t_while :
|
||||
return Keywords.WHILE ;
|
||||
case IToken.t_xor :
|
||||
return Keywords.XOR ;
|
||||
case IToken.t_xor_eq :
|
||||
return Keywords.XOR_EQ ;
|
||||
case IToken.t__Bool :
|
||||
return Keywords._BOOL ;
|
||||
case IToken.t__Complex :
|
||||
return Keywords._COMPLEX ;
|
||||
case IToken.t__Imaginary :
|
||||
return Keywords._IMAGINARY ;
|
||||
case IToken.t_restrict :
|
||||
return Keywords.RESTRICT ;
|
||||
case IToken.tPOUND:
|
||||
return "#"; //$NON-NLS-1$
|
||||
case IToken.tPOUNDPOUND:
|
||||
return "##"; //$NON-NLS-1$
|
||||
case IToken.tEOC:
|
||||
return "EOC"; //$NON-NLS-1$
|
||||
default :
|
||||
// we should never get here!
|
||||
// assert false : getType();
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#setImage()
|
||||
*/
|
||||
public void setImage( String i ) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
public char[] getCharImage() {
|
||||
return getCharImage( getType() );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#getCharImage()
|
||||
*/
|
||||
static public char[] getCharImage( int type ){
|
||||
switch ( type ) {
|
||||
case IToken.tCOLONCOLON : return Keywords.cpCOLONCOLON;
|
||||
case IToken.tCOLON : return Keywords.cpCOLON;
|
||||
case IToken.tSEMI : return Keywords.cpSEMI;
|
||||
case IToken.tCOMMA : return Keywords.cpCOMMA;
|
||||
case IToken.tQUESTION : return Keywords.cpQUESTION;
|
||||
case IToken.tLPAREN : return Keywords.cpLPAREN;
|
||||
case IToken.tRPAREN : return Keywords.cpRPAREN;
|
||||
case IToken.tLBRACKET : return Keywords.cpLBRACKET;
|
||||
case IToken.tRBRACKET : return Keywords.cpRBRACKET;
|
||||
case IToken.tLBRACE : return Keywords.cpLBRACE;
|
||||
case IToken.tRBRACE : return Keywords.cpRBRACE;
|
||||
case IToken.tPLUSASSIGN : return Keywords.cpPLUSASSIGN;
|
||||
case IToken.tINCR : return Keywords.cpINCR;
|
||||
case IToken.tPLUS : return Keywords.cpPLUS;
|
||||
case IToken.tMINUSASSIGN : return Keywords.cpMINUSASSIGN;
|
||||
case IToken.tDECR : return Keywords.cpDECR;
|
||||
case IToken.tARROWSTAR : return Keywords.cpARROWSTAR;
|
||||
case IToken.tARROW : return Keywords.cpARROW;
|
||||
case IToken.tMINUS : return Keywords.cpMINUS;
|
||||
case IToken.tSTARASSIGN : return Keywords.cpSTARASSIGN;
|
||||
case IToken.tSTAR : return Keywords.cpSTAR;
|
||||
case IToken.tMODASSIGN : return Keywords.cpMODASSIGN;
|
||||
case IToken.tMOD : return Keywords.cpMOD;
|
||||
case IToken.tXORASSIGN : return Keywords.cpXORASSIGN;
|
||||
case IToken.tXOR : return Keywords.cpXOR;
|
||||
case IToken.tAMPERASSIGN : return Keywords.cpAMPERASSIGN;
|
||||
case IToken.tAND : return Keywords.cpAND;
|
||||
case IToken.tAMPER : return Keywords.cpAMPER;
|
||||
case IToken.tBITORASSIGN : return Keywords.cpBITORASSIGN;
|
||||
case IToken.tOR : return Keywords.cpOR;
|
||||
case IToken.tBITOR : return Keywords.cpBITOR;
|
||||
case IToken.tCOMPL : return Keywords.cpCOMPL;
|
||||
case IToken.tNOTEQUAL : return Keywords.cpNOTEQUAL;
|
||||
case IToken.tNOT : return Keywords.cpNOT;
|
||||
case IToken.tEQUAL : return Keywords.cpEQUAL;
|
||||
case IToken.tASSIGN : return Keywords.cpASSIGN;
|
||||
case IToken.tSHIFTL : return Keywords.cpSHIFTL;
|
||||
case IToken.tLTEQUAL : return Keywords.cpLTEQUAL;
|
||||
case IToken.tLT : return Keywords.cpLT;
|
||||
case IToken.tSHIFTRASSIGN : return Keywords.cpSHIFTRASSIGN;
|
||||
case IToken.tSHIFTR : return Keywords.cpSHIFTR;
|
||||
case IToken.tGTEQUAL : return Keywords.cpGTEQUAL;
|
||||
case IToken.tGT : return Keywords.cpGT;
|
||||
case IToken.tSHIFTLASSIGN : return Keywords.cpSHIFTLASSIGN;
|
||||
case IToken.tELLIPSIS : return Keywords.cpELLIPSIS;
|
||||
case IToken.tDOTSTAR : return Keywords.cpDOTSTAR;
|
||||
case IToken.tDOT : return Keywords.cpDOT;
|
||||
case IToken.tDIVASSIGN : return Keywords.cpDIVASSIGN;
|
||||
case IToken.tDIV : return Keywords.cpDIV;
|
||||
case IToken.t_and : return Keywords.cAND;
|
||||
case IToken.t_and_eq : return Keywords.cAND_EQ ;
|
||||
case IToken.t_asm : return Keywords.cASM ;
|
||||
case IToken.t_auto : return Keywords.cAUTO ;
|
||||
case IToken.t_bitand : return Keywords.cBITAND ;
|
||||
case IToken.t_bitor : return Keywords.cBITOR ;
|
||||
case IToken.t_bool : return Keywords.cBOOL ;
|
||||
case IToken.t_break : return Keywords.cBREAK ;
|
||||
case IToken.t_case : return Keywords.cCASE ;
|
||||
case IToken.t_catch : return Keywords.cCATCH ;
|
||||
case IToken.t_char : return Keywords.cCHAR ;
|
||||
case IToken.t_class : return Keywords.cCLASS ;
|
||||
case IToken.t_compl : return Keywords.cCOMPL ;
|
||||
case IToken.t_const : return Keywords.cCONST ;
|
||||
case IToken.t_const_cast : return Keywords.cCONST_CAST ;
|
||||
case IToken.t_continue : return Keywords.cCONTINUE ;
|
||||
case IToken.t_default : return Keywords.cDEFAULT ;
|
||||
case IToken.t_delete : return Keywords.cDELETE ;
|
||||
case IToken.t_do : return Keywords.cDO;
|
||||
case IToken.t_double : return Keywords.cDOUBLE ;
|
||||
case IToken.t_dynamic_cast: return Keywords.cDYNAMIC_CAST ;
|
||||
case IToken.t_else : return Keywords.cELSE;
|
||||
case IToken.t_enum : return Keywords.cENUM ;
|
||||
case IToken.t_explicit : return Keywords.cEXPLICIT ;
|
||||
case IToken.t_export : return Keywords.cEXPORT ;
|
||||
case IToken.t_extern : return Keywords.cEXTERN;
|
||||
case IToken.t_false : return Keywords.cFALSE;
|
||||
case IToken.t_float : return Keywords.cFLOAT;
|
||||
case IToken.t_for : return Keywords.cFOR;
|
||||
case IToken.t_friend : return Keywords.cFRIEND;
|
||||
case IToken.t_goto : return Keywords.cGOTO;
|
||||
case IToken.t_if : return Keywords.cIF ;
|
||||
case IToken.t_inline : return Keywords.cINLINE ;
|
||||
case IToken.t_int : return Keywords.cINT ;
|
||||
case IToken.t_long : return Keywords.cLONG ;
|
||||
case IToken.t_mutable : return Keywords.cMUTABLE ;
|
||||
case IToken.t_namespace : return Keywords.cNAMESPACE ;
|
||||
case IToken.t_new : return Keywords.cNEW ;
|
||||
case IToken.t_not : return Keywords.cNOT ;
|
||||
case IToken.t_not_eq : return Keywords.cNOT_EQ;
|
||||
case IToken.t_operator : return Keywords.cOPERATOR ;
|
||||
case IToken.t_or : return Keywords.cOR ;
|
||||
case IToken.t_or_eq : return Keywords.cOR_EQ;
|
||||
case IToken.t_private : return Keywords.cPRIVATE ;
|
||||
case IToken.t_protected : return Keywords.cPROTECTED ;
|
||||
case IToken.t_public : return Keywords.cPUBLIC ;
|
||||
case IToken.t_register : return Keywords.cREGISTER ;
|
||||
case IToken.t_reinterpret_cast : return Keywords.cREINTERPRET_CAST ;
|
||||
case IToken.t_return : return Keywords.cRETURN ;
|
||||
case IToken.t_short : return Keywords.cSHORT ;
|
||||
case IToken.t_sizeof : return Keywords.cSIZEOF ;
|
||||
case IToken.t_static : return Keywords.cSTATIC ;
|
||||
case IToken.t_static_cast : return Keywords.cSTATIC_CAST ;
|
||||
case IToken.t_signed : return Keywords.cSIGNED ;
|
||||
case IToken.t_struct : return Keywords.cSTRUCT ;
|
||||
case IToken.t_switch : return Keywords.cSWITCH ;
|
||||
case IToken.t_template : return Keywords.cTEMPLATE ;
|
||||
case IToken.t_this : return Keywords.cTHIS ;
|
||||
case IToken.t_throw : return Keywords.cTHROW ;
|
||||
case IToken.t_true : return Keywords.cTRUE ;
|
||||
case IToken.t_try : return Keywords.cTRY ;
|
||||
case IToken.t_typedef : return Keywords.cTYPEDEF ;
|
||||
case IToken.t_typeid : return Keywords.cTYPEID ;
|
||||
case IToken.t_typename : return Keywords.cTYPENAME ;
|
||||
case IToken.t_union : return Keywords.cUNION ;
|
||||
case IToken.t_unsigned : return Keywords.cUNSIGNED ;
|
||||
case IToken.t_using : return Keywords.cUSING ;
|
||||
case IToken.t_virtual : return Keywords.cVIRTUAL ;
|
||||
case IToken.t_void : return Keywords.cVOID ;
|
||||
case IToken.t_volatile : return Keywords.cVOLATILE;
|
||||
case IToken.t_wchar_t : return Keywords.cWCHAR_T ;
|
||||
case IToken.t_while : return Keywords.cWHILE ;
|
||||
case IToken.t_xor : return Keywords.cXOR ;
|
||||
case IToken.t_xor_eq : return Keywords.cXOR_EQ ;
|
||||
case IToken.t__Bool : return Keywords.c_BOOL ;
|
||||
case IToken.t__Complex : return Keywords.c_COMPLEX ;
|
||||
case IToken.t__Imaginary : return Keywords.c_IMAGINARY ;
|
||||
case IToken.t_restrict : return Keywords.cRESTRICT ;
|
||||
case IToken.tPOUND: return Keywords.cpPOUND;
|
||||
case IToken.tPOUNDPOUND: return Keywords.cpPOUNDPOUND;
|
||||
|
||||
default :
|
||||
// we should never get here!
|
||||
// assert false : getType();
|
||||
return "".toCharArray(); //$NON-NLS-1$
|
||||
}
|
||||
//return getImage().toCharArray(); //TODO - fix me!
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IToken#setImage(char[])
|
||||
*/
|
||||
public void setImage(char[] i) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#toCharArray()
|
||||
*/
|
||||
public char[] toCharArray() {
|
||||
return getCharImage();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#isConversion()
|
||||
*/
|
||||
public boolean isConversion() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -38,14 +38,12 @@ import org.eclipse.cdt.core.index.IndexLocationFactory;
|
|||
import org.eclipse.cdt.core.model.AbstractLanguage;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IMacro;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMMacro;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
@ -82,7 +80,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
boolean fRequestUpdate= false;
|
||||
boolean fRequestIsCounted= true;
|
||||
boolean fIsUpdated= false;
|
||||
public IMacro[] fMacros;
|
||||
public IIndexMacro[] fMacros;
|
||||
}
|
||||
|
||||
private int fUpdateFlags= IIndexManager.UPDATE_ALL;
|
||||
|
@ -456,10 +454,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (OutOfMemoryError e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
catch (Exception e) {
|
||||
swallowError(path, e);
|
||||
}
|
||||
}
|
||||
|
@ -760,7 +755,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
return result*31 + key.hashCode();
|
||||
}
|
||||
|
||||
public final IMacro[] getConvertedMacros(int linkageID, IIndexFileLocation ifl) throws CoreException {
|
||||
public final IIndexMacro[] getConvertedMacros(int linkageID, IIndexFileLocation ifl) throws CoreException {
|
||||
if (!needToUpdateHeader(linkageID, ifl)) {
|
||||
FileInfo info= getFileInfo(linkageID, ifl);
|
||||
assert info != null;
|
||||
|
@ -771,14 +766,9 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
IMacro[] result= info.fMacros;
|
||||
IIndexMacro[] result= info.fMacros;
|
||||
if (result == null) {
|
||||
IIndexMacro[] macros= info.fIndexFile.getMacros();
|
||||
result= new IMacro[macros.length];
|
||||
for (int i = 0; i < macros.length; i++) {
|
||||
IIndexMacro macro = macros[i];
|
||||
result[i]= ((PDOMMacro)macro).getMacro();
|
||||
}
|
||||
result= info.fIndexFile.getMacros();
|
||||
info.fMacros= result;
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Ferguson (Symbian)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
@ -18,16 +18,20 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionStyleMacroParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorFunctionStyleMacroDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.index.IIndexFile;
|
||||
import org.eclipse.cdt.core.index.IIndexMacro;
|
||||
import org.eclipse.cdt.core.parser.IMacro;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.FunctionStyleMacro;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.ObjectStyleMacro;
|
||||
import org.eclipse.cdt.core.parser.Keywords;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.MacroDefinitionParser;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IString;
|
||||
|
@ -40,11 +44,6 @@ import org.eclipse.core.runtime.CoreException;
|
|||
*/
|
||||
public class PDOMMacro implements IIndexMacro, IASTFileLocation {
|
||||
|
||||
private final PDOM pdom;
|
||||
private final int record;
|
||||
private IIndexMacro macro;
|
||||
|
||||
private static final byte MACROSTYLE_UNKNOWN = 0; // for reading versions of PDOM <39
|
||||
private static final byte MACROSTYLE_OBJECT = 1;
|
||||
private static final byte MACROSTYLE_FUNCTION= 2;
|
||||
|
||||
|
@ -58,6 +57,14 @@ public class PDOMMacro implements IIndexMacro, IASTFileLocation {
|
|||
private static final int MACRO_STYLE = 26; // byte
|
||||
|
||||
private static final int RECORD_SIZE = 27;
|
||||
private static final char[][] UNINITIALIZED= {};
|
||||
|
||||
private final PDOM pdom;
|
||||
private final int record;
|
||||
|
||||
private char[][] fParameterList= UNINITIALIZED;
|
||||
private char[] fName;
|
||||
private char[] fExpansion;
|
||||
|
||||
public PDOMMacro(PDOM pdom, int record) {
|
||||
this.pdom = pdom;
|
||||
|
@ -139,141 +146,53 @@ public class PDOMMacro implements IIndexMacro, IASTFileLocation {
|
|||
return rec != 0 ? new PDOMMacroParameter(pdom, rec) : null;
|
||||
}
|
||||
|
||||
private class ObjectStylePDOMMacro extends ObjectStyleMacro implements IIndexMacro {
|
||||
public ObjectStylePDOMMacro(char[] name) {
|
||||
super(name, null);
|
||||
}
|
||||
public char[] getExpansion() {
|
||||
if (expansion == null) {
|
||||
expansion= getMacroExpansion();
|
||||
}
|
||||
return expansion;
|
||||
}
|
||||
public IASTFileLocation getFileLocation() {
|
||||
return PDOMMacro.this;
|
||||
}
|
||||
public IIndexFile getFile() throws CoreException {
|
||||
return PDOMMacro.this.getFile();
|
||||
}
|
||||
public int getNodeOffset() {
|
||||
return PDOMMacro.this.getNodeOffset();
|
||||
}
|
||||
public int getNodeLength() {
|
||||
return PDOMMacro.this.getNodeLength();
|
||||
}
|
||||
public char[][] getParameterList() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class FunctionStylePDOMMacro extends FunctionStyleMacro implements IIndexMacro {
|
||||
public FunctionStylePDOMMacro(char[] name, char[][] arglist) {
|
||||
super(name, null, arglist);
|
||||
}
|
||||
public char[] getExpansion() {
|
||||
if (expansion == null) {
|
||||
expansion= getMacroExpansion();
|
||||
}
|
||||
return expansion;
|
||||
}
|
||||
public IASTFileLocation getFileLocation() {
|
||||
return PDOMMacro.this;
|
||||
}
|
||||
public IIndexFile getFile() throws CoreException {
|
||||
return PDOMMacro.this.getFile();
|
||||
}
|
||||
public int getNodeOffset() {
|
||||
return PDOMMacro.this.getNodeOffset();
|
||||
}
|
||||
public int getNodeLength() {
|
||||
return PDOMMacro.this.getNodeLength();
|
||||
}
|
||||
public char[][] getParameterList() {
|
||||
return getOriginalParameters();
|
||||
}
|
||||
}
|
||||
|
||||
private char[] getMacroExpansion() {
|
||||
try {
|
||||
return PDOMMacro.this.getExpansionInDB().getChars();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return new char[] { ' ' };
|
||||
}
|
||||
}
|
||||
|
||||
public IMacro getMacro() throws CoreException {
|
||||
rebuildMacro();
|
||||
return macro;
|
||||
}
|
||||
|
||||
private void rebuildMacro() throws CoreException {
|
||||
if (macro == null) {
|
||||
char[] name = getNameInDB(pdom, record).getChars();
|
||||
PDOMMacroParameter param= getFirstParameter();
|
||||
|
||||
byte style= pdom.getDB().getByte(record + MACRO_STYLE);
|
||||
if(style == MACROSTYLE_UNKNOWN) {
|
||||
/* PDOM formats < 39 do not store MACRO_STYLE (208558) */
|
||||
style= param != null ? MACROSTYLE_FUNCTION : MACROSTYLE_OBJECT;
|
||||
}
|
||||
|
||||
switch(style) {
|
||||
case MACROSTYLE_OBJECT:
|
||||
macro= new ObjectStylePDOMMacro(name);
|
||||
break;
|
||||
case MACROSTYLE_FUNCTION:
|
||||
List paramList = new ArrayList();
|
||||
while (param != null) {
|
||||
paramList.add(param.getName().getChars());
|
||||
param = param.getNextParameter();
|
||||
}
|
||||
char[][] params = (char[][])paramList.toArray(new char[paramList.size()][]);
|
||||
macro= new FunctionStylePDOMMacro(name, params);
|
||||
break;
|
||||
default:
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public char[][] getParameterList() {
|
||||
try {
|
||||
rebuildMacro();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return new char[][]{};
|
||||
if (fParameterList == UNINITIALIZED) {
|
||||
fParameterList= null;
|
||||
try {
|
||||
byte style= pdom.getDB().getByte(record + MACRO_STYLE);
|
||||
if (style == MACROSTYLE_FUNCTION) {
|
||||
List paramList = new ArrayList();
|
||||
PDOMMacroParameter param= getFirstParameter();
|
||||
while (param != null) {
|
||||
paramList.add(param.getName().getChars());
|
||||
param = param.getNextParameter();
|
||||
}
|
||||
fParameterList= (char[][])paramList.toArray(new char[paramList.size()][]);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
return macro.getParameterList();
|
||||
return fParameterList;
|
||||
}
|
||||
|
||||
public char[] getSignature() {
|
||||
try {
|
||||
rebuildMacro();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return new char[] { ' ' };
|
||||
public char[] getExpansionImage() {
|
||||
if (fExpansion == null) {
|
||||
try {
|
||||
fExpansion= getExpansionInDB().getChars();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
fExpansion= new char[] { ' ' };
|
||||
}
|
||||
}
|
||||
return macro.getSignature();
|
||||
return fExpansion;
|
||||
}
|
||||
|
||||
public char[] getExpansion() {
|
||||
try {
|
||||
rebuildMacro();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return new char[] { ' ' };
|
||||
public char[] getNameCharArray() {
|
||||
if (fName == null) {
|
||||
try {
|
||||
fName= getNameInDB(pdom, record).getChars();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
fName= new char[] { ' ' };
|
||||
}
|
||||
}
|
||||
return macro.getExpansion();
|
||||
return fName;
|
||||
}
|
||||
|
||||
public char[] getName() {
|
||||
try {
|
||||
return getNameInDB(pdom, record).getChars();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return new char[] { ' ' };
|
||||
}
|
||||
public String getName() {
|
||||
return new String(getNameCharArray());
|
||||
}
|
||||
|
||||
public IIndexFile getFile() throws CoreException {
|
||||
|
@ -334,4 +253,39 @@ public class PDOMMacro implements IIndexMacro, IASTFileLocation {
|
|||
}
|
||||
}
|
||||
|
||||
public char[] getExpansion() {
|
||||
char[] expansionImage= getExpansionImage();
|
||||
return MacroDefinitionParser.getExpansion(expansionImage, 0, expansionImage.length);
|
||||
}
|
||||
|
||||
public char[][] getParameterPlaceholderList() {
|
||||
char[][] params= getParameterList();
|
||||
if (params != null && params.length > 0) {
|
||||
char[] lastParam= params[params.length-1];
|
||||
if (CharArrayUtils.equals(lastParam, 0, Keywords.cpELLIPSIS.length, Keywords.cpELLIPSIS)) {
|
||||
char[][] result= new char[params.length][];
|
||||
System.arraycopy(params, 0, result, 0, params.length-1);
|
||||
result[params.length-1]= lastParam.length == Keywords.cpELLIPSIS.length ? Keywords.cVA_ARGS :
|
||||
CharArrayUtils.extract(lastParam, Keywords.cpELLIPSIS.length, lastParam.length-Keywords.cpELLIPSIS.length);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
public boolean isFunctionStyle() {
|
||||
return getParameterList() != null;
|
||||
}
|
||||
|
||||
public ILinkage getLinkage() throws CoreException {
|
||||
return Linkage.NO_LINKAGE;
|
||||
}
|
||||
|
||||
public IScope getScope() throws DOMException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object getAdapter(Class adapter) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,8 +57,10 @@ public class TodoTaskParser {
|
|||
for (int i = 0; i < comments.length; i++) {
|
||||
IASTComment comment = comments[i];
|
||||
IASTFileLocation location = comment.getFileLocation();
|
||||
parse(comment.getComment(), location.getFileName(), location.getNodeOffset(),
|
||||
location.getStartingLineNumber(), tasks);
|
||||
if (location != null) { // be defensive, bug 213307
|
||||
parse(comment.getComment(), location.getFileName(), location.getNodeOffset(),
|
||||
location.getStartingLineNumber(), tasks);
|
||||
}
|
||||
}
|
||||
if (tasks.isEmpty()) {
|
||||
return EMPTY_TASK_ARRAY;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* IBM - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom;
|
||||
|
||||
|
@ -39,7 +39,6 @@ import org.eclipse.cdt.core.parser.ScannerInfo;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -231,10 +230,7 @@ public class InternalASTServiceProvider implements IASTServiceProvider {
|
|||
private IScanner createScanner(CodeReader reader, IScannerInfo scanInfo,
|
||||
ParserMode mode, ParserLanguage lang, IParserLogService log,
|
||||
IScannerExtensionConfiguration scanConfig, ICodeReaderFactory fileCreator) {
|
||||
if (!DOMScanner.PROP_VALUE.equals(System.getProperty("scanner"))) { //$NON-NLS-1$
|
||||
return new CPreprocessor(reader, scanInfo, lang, log, scanConfig, fileCreator);
|
||||
}
|
||||
return new DOMScanner(reader, scanInfo, mode, lang, log, scanConfig, fileCreator);
|
||||
return new CPreprocessor(reader, scanInfo, lang, log, scanConfig, fileCreator);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser;
|
||||
|
||||
|
@ -59,10 +59,7 @@ public class ParserLogService extends AbstractParserLogService
|
|||
}
|
||||
|
||||
public boolean isTracing(){
|
||||
if( CCorePlugin.getDefault() == null )
|
||||
return false;
|
||||
|
||||
return ( CCorePlugin.getDefault().isDebugging() && Util.isActive( topic ) );
|
||||
return fIsTracing;
|
||||
}
|
||||
|
||||
public boolean isTracingExceptions() {
|
||||
|
|
|
@ -42,7 +42,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBas
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.LocationMap.ASTInclusionStatement;
|
||||
|
||||
/**
|
||||
* @author dsteffle
|
||||
|
@ -360,23 +359,19 @@ public class CPPPopulateASTViewAction extends CPPASTVisitor implements IPopulate
|
|||
public void groupIncludes(DOMASTNodeLeaf[] treeIncludes) {
|
||||
// loop through the includes and make sure that all of the nodes
|
||||
// that are children of the TU are in the proper include (based on offset)
|
||||
DOMASTNodeLeaf child = null;
|
||||
for (int i=treeIncludes.length - 1; i >= 0; i-- ) {
|
||||
if (treeIncludes[i] == null) continue;
|
||||
final DOMASTNodeLeaf nodeLeaf = treeIncludes[i];
|
||||
if (nodeLeaf == null || !(nodeLeaf.getNode() instanceof IASTPreprocessorIncludeStatement)) continue;
|
||||
|
||||
IASTNode node = null;
|
||||
for(int j=0; j < root.getChildren(false).length; j++) {
|
||||
final String path= ((IASTPreprocessorIncludeStatement) nodeLeaf.getNode()).getPath();
|
||||
final DOMASTNodeLeaf[] children = root.getChildren(false);
|
||||
for(int j=0; j < children.length; j++) {
|
||||
// if (monitor != null && monitor.isCanceled()) return; // this causes a deadlock when checked here
|
||||
child = root.getChildren(false)[j];
|
||||
|
||||
node = treeIncludes[i].getNode();
|
||||
if (child != null && treeIncludes[i] != child &&
|
||||
node instanceof ASTInclusionStatement &&
|
||||
((ASTNode)child.getNode()).getOffset() >= ((ASTInclusionStatement)node).startOffset &&
|
||||
((ASTNode)child.getNode()).getOffset() <= ((ASTInclusionStatement)node).endOffset)
|
||||
{
|
||||
final DOMASTNodeLeaf child = children[j];
|
||||
if (child != null && child != nodeLeaf &&
|
||||
child.getNode().getContainingFilename().equals(path)) {
|
||||
root.removeChild(child);
|
||||
((DOMASTNodeParent)treeIncludes[i]).addChild(child);
|
||||
((DOMASTNodeParent)nodeLeaf).addChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2007 IBM Corporation 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:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.tests.DOMAST;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||
|
@ -33,9 +35,8 @@ import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
|||
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.LocationMap.ASTInclusionStatement;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
/**
|
||||
* @author dsteffle
|
||||
|
@ -324,23 +325,19 @@ public class CPopulateASTViewAction extends CASTVisitor implements IPopulateDOMA
|
|||
public void groupIncludes(DOMASTNodeLeaf[] treeIncludes) {
|
||||
// loop through the includes and make sure that all of the nodes
|
||||
// that are children of the TU are in the proper include (based on offset)
|
||||
DOMASTNodeLeaf child = null;
|
||||
for (int i=treeIncludes.length-1; i>=0; i--) {
|
||||
if (treeIncludes[i] == null) continue;
|
||||
for (int i=treeIncludes.length - 1; i >= 0; i-- ) {
|
||||
final DOMASTNodeLeaf nodeLeaf = treeIncludes[i];
|
||||
if (nodeLeaf == null || !(nodeLeaf.getNode() instanceof IASTPreprocessorIncludeStatement)) continue;
|
||||
|
||||
IASTNode node = null;
|
||||
for(int j=0; j < root.getChildren(false).length; j++) {
|
||||
final String path= ((IASTPreprocessorIncludeStatement) nodeLeaf.getNode()).getPath();
|
||||
final DOMASTNodeLeaf[] children = root.getChildren(false);
|
||||
for(int j=0; j < children.length; j++) {
|
||||
// if (monitor != null && monitor.isCanceled()) return; // this causes a deadlock when checked here
|
||||
child = root.getChildren(false)[j];
|
||||
|
||||
node = treeIncludes[i].getNode();
|
||||
if (child != null &&
|
||||
treeIncludes[i] != child &&
|
||||
node instanceof ASTInclusionStatement &&
|
||||
((ASTNode)child.getNode()).getOffset() >= ((ASTInclusionStatement)node).startOffset &&
|
||||
((ASTNode)child.getNode()).getOffset() <= ((ASTInclusionStatement)node).endOffset) {
|
||||
final DOMASTNodeLeaf child = children[j];
|
||||
if (child != null && child != nodeLeaf &&
|
||||
child.getNode().getContainingFilename().equals(path)) {
|
||||
root.removeChild(child);
|
||||
((DOMASTNodeParent)treeIncludes[i]).addChild(child);
|
||||
((DOMASTNodeParent)nodeLeaf).addChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,8 @@ public class CompletionTest_MacroRef_NoPrefix extends CompletionProposalsBaseTe
|
|||
"__restrict__",
|
||||
"__signed__",
|
||||
"__stdcall",
|
||||
"__volatile__"
|
||||
"__volatile__",
|
||||
"__typeof__"
|
||||
};
|
||||
|
||||
public CompletionTest_MacroRef_NoPrefix(String name) {
|
||||
|
|
|
@ -106,8 +106,7 @@ public class CElementHyperlinkDetector implements IHyperlinkDetector {
|
|||
linkRegion = new Region(selection.getOffset(), selection.getLength());
|
||||
}
|
||||
}
|
||||
else { // check if we are in an include statement
|
||||
// mstodo- support for old scanner
|
||||
else {
|
||||
linkRegion = matchIncludeStatement(ast, selection);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.text.contentassist;
|
||||
|
@ -52,7 +52,7 @@ public abstract class ParsingBasedProposalComputer implements ICompletionProposa
|
|||
|
||||
return computeCompletionProposals(cContext, completionNode, prefix);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch (Exception e) {
|
||||
fErrorMessage = e.toString();
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue