mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fixes related to scalability with large array initializer, bug 253690.
This commit is contained in:
parent
e6eda2a51d
commit
bb8d3bd8a4
47 changed files with 604 additions and 408 deletions
|
@ -54,7 +54,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
|
||||||
import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
|
|
||||||
import org.eclipse.cdt.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
import org.eclipse.cdt.core.dom.parser.c.ANSICParserExtensionConfiguration;
|
||||||
import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration;
|
import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration;
|
||||||
import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration;
|
import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration;
|
||||||
|
@ -75,6 +74,7 @@ import org.eclipse.cdt.core.parser.tests.scanner.FileCodeReaderFactory;
|
||||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
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.dom.parser.cpp.GNUCPPSourceParser;
|
||||||
|
@ -116,17 +116,17 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
|
protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
|
||||||
boolean expectNoProblems, boolean parseComments) throws ParserException {
|
boolean expectNoProblems, boolean skipTrivialInitializers) throws ParserException {
|
||||||
IScanner scanner = createScanner(new CodeReader(code.toCharArray()), lang, ParserMode.COMPLETE_PARSE,
|
IScanner scanner = createScanner(new CodeReader(code.toCharArray()), lang, ParserMode.COMPLETE_PARSE,
|
||||||
new ScannerInfo(), parseComments);
|
new ScannerInfo());
|
||||||
ISourceCodeParser parser2 = null;
|
AbstractGNUSourceCodeParser parser = null;
|
||||||
if (lang == ParserLanguage.CPP) {
|
if (lang == ParserLanguage.CPP) {
|
||||||
ICPPParserExtensionConfiguration config = null;
|
ICPPParserExtensionConfiguration config = null;
|
||||||
if (useGNUExtensions)
|
if (useGNUExtensions)
|
||||||
config = new GPPParserExtensionConfiguration();
|
config = new GPPParserExtensionConfiguration();
|
||||||
else
|
else
|
||||||
config = new ANSICPPParserExtensionConfiguration();
|
config = new ANSICPPParserExtensionConfiguration();
|
||||||
parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG,config, null);
|
parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG,config, null);
|
||||||
} else {
|
} else {
|
||||||
ICParserExtensionConfiguration config = null;
|
ICParserExtensionConfiguration config = null;
|
||||||
|
|
||||||
|
@ -135,12 +135,14 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
else
|
else
|
||||||
config = new ANSICParserExtensionConfiguration();
|
config = new ANSICParserExtensionConfiguration();
|
||||||
|
|
||||||
parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
|
parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
|
||||||
}
|
}
|
||||||
|
if (skipTrivialInitializers)
|
||||||
|
parser.setSkipTrivialExpressionsInAggregateInitializers(true);
|
||||||
|
|
||||||
IASTTranslationUnit tu = parser2.parse();
|
IASTTranslationUnit tu = parser.parse();
|
||||||
|
|
||||||
if (parser2.encounteredError() && expectNoProblems)
|
if (parser.encounteredError() && expectNoProblems)
|
||||||
throw new ParserException("FAILURE"); //$NON-NLS-1$
|
throw new ParserException("FAILURE"); //$NON-NLS-1$
|
||||||
|
|
||||||
if (lang == ParserLanguage.C && expectNoProblems) {
|
if (lang == ParserLanguage.C && expectNoProblems) {
|
||||||
|
@ -157,7 +159,7 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IScanner createScanner(CodeReader codeReader, ParserLanguage lang, ParserMode mode,
|
public static IScanner createScanner(CodeReader codeReader, ParserLanguage lang, ParserMode mode,
|
||||||
IScannerInfo scannerInfo, boolean parseComments) {
|
IScannerInfo scannerInfo) {
|
||||||
IScannerExtensionConfiguration configuration = null;
|
IScannerExtensionConfiguration configuration = null;
|
||||||
if (lang == ParserLanguage.C)
|
if (lang == ParserLanguage.C)
|
||||||
configuration= GCCScannerExtensionConfiguration.getInstance();
|
configuration= GCCScannerExtensionConfiguration.getInstance();
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class AST2SelectionParseBaseTest extends FileBasePluginTest {
|
||||||
CodeReader codeReader = new CodeReader(code
|
CodeReader codeReader = new CodeReader(code
|
||||||
.toCharArray());
|
.toCharArray());
|
||||||
ScannerInfo scannerInfo = new ScannerInfo();
|
ScannerInfo scannerInfo = new ScannerInfo();
|
||||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo, false);
|
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||||
|
|
||||||
ISourceCodeParser parser2 = null;
|
ISourceCodeParser parser2 = null;
|
||||||
if( lang == ParserLanguage.CPP )
|
if( lang == ParserLanguage.CPP )
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class AST2SpecBaseTest extends AST2BaseTest {
|
||||||
private IASTTranslationUnit parse(CodeReader codeReader, ParserLanguage lang, boolean useGNUExtensions,
|
private IASTTranslationUnit parse(CodeReader codeReader, ParserLanguage lang, boolean useGNUExtensions,
|
||||||
boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings, String[] problems) throws ParserException {
|
boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings, String[] problems) throws ParserException {
|
||||||
ScannerInfo scannerInfo = new ScannerInfo();
|
ScannerInfo scannerInfo = new ScannerInfo();
|
||||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo, false);
|
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||||
|
|
||||||
ISourceCodeParser parser2 = null;
|
ISourceCodeParser parser2 = null;
|
||||||
if( lang == ParserLanguage.CPP )
|
if( lang == ParserLanguage.CPP )
|
||||||
|
|
|
@ -5500,4 +5500,35 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
parseAndCheckBindings(code, lang);
|
parseAndCheckBindings(code, lang);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// int a[]= {
|
||||||
|
|
||||||
|
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
|
||||||
|
// };
|
||||||
|
public void testScalabilityOfLargeTrivialInitializer_Bug252970() throws Exception {
|
||||||
|
final StringBuffer[] input = getContents(3);
|
||||||
|
StringBuilder buf= new StringBuilder();
|
||||||
|
buf.append(input[0].toString());
|
||||||
|
final String line= input[1].toString();
|
||||||
|
for (int i = 0; i < 25000; i++) { // 250K values
|
||||||
|
buf.append(line);
|
||||||
|
}
|
||||||
|
buf.append(input[2].toString());
|
||||||
|
final String code= buf.toString();
|
||||||
|
long mem= memoryUsed();
|
||||||
|
for (ParserLanguage lang : ParserLanguage.values()) {
|
||||||
|
IASTTranslationUnit tu= parse(code, lang, false, true, true);
|
||||||
|
long diff= memoryUsed()-mem;
|
||||||
|
final int expected = 1024*10 + code.length()*2; // a copy of the buffer + some
|
||||||
|
assertTrue(String.valueOf(diff) + " expected < " + expected, diff < expected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private long memoryUsed() {
|
||||||
|
System.gc();System.gc();System.gc();
|
||||||
|
final Runtime runtime = Runtime.getRuntime();
|
||||||
|
return runtime.totalMemory()-runtime.freeMemory();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class ASTNodeSelectorTest extends AST2BaseTest {
|
||||||
fCode= getContents(1)[0].toString();
|
fCode= getContents(1)[0].toString();
|
||||||
CodeReader codeReader = new CodeReader(fCode.toCharArray());
|
CodeReader codeReader = new CodeReader(fCode.toCharArray());
|
||||||
ScannerInfo scannerInfo = new ScannerInfo();
|
ScannerInfo scannerInfo = new ScannerInfo();
|
||||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, scannerInfo, false);
|
IScanner scanner= AST2BaseTest.createScanner(codeReader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||||
GNUCPPSourceParser parser= new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, new NullLogService(), new GPPParserExtensionConfiguration());
|
GNUCPPSourceParser parser= new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, new NullLogService(), new GPPParserExtensionConfiguration());
|
||||||
fTu= parser.parse();
|
fTu= parser.parse();
|
||||||
fSelector= fTu.getNodeSelector(null);
|
fSelector= fTu.getNodeSelector(null);
|
||||||
|
|
|
@ -180,7 +180,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
||||||
.toCharArray());
|
.toCharArray());
|
||||||
ScannerInfo scannerInfo = new ScannerInfo();
|
ScannerInfo scannerInfo = new ScannerInfo();
|
||||||
ISourceCodeParser parser2 = null;
|
ISourceCodeParser parser2 = null;
|
||||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo, false);
|
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||||
if (lang == ParserLanguage.CPP) {
|
if (lang == ParserLanguage.CPP) {
|
||||||
ICPPParserExtensionConfiguration config = null;
|
ICPPParserExtensionConfiguration config = null;
|
||||||
if (gcc)
|
if (gcc)
|
||||||
|
|
|
@ -1355,7 +1355,7 @@ public class QuickParser2Tests extends TestCase {
|
||||||
|
|
||||||
CodeReader codeReader = new CodeReader( code.toCharArray() );
|
CodeReader codeReader = new CodeReader( code.toCharArray() );
|
||||||
IScannerInfo scannerInfo = new ScannerInfo();
|
IScannerInfo scannerInfo = new ScannerInfo();
|
||||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo, false);
|
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||||
ISourceCodeParser parser2 = null;
|
ISourceCodeParser parser2 = null;
|
||||||
if (lang == ParserLanguage.CPP) {
|
if (lang == ParserLanguage.CPP) {
|
||||||
ICPPParserExtensionConfiguration config = null;
|
ICPPParserExtensionConfiguration config = null;
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class CompletionTestBase extends TestCase {
|
||||||
protected IASTCompletionNode getCompletionNode(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException {
|
protected IASTCompletionNode getCompletionNode(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException {
|
||||||
CodeReader codeReader = new CodeReader(code.toCharArray());
|
CodeReader codeReader = new CodeReader(code.toCharArray());
|
||||||
ScannerInfo scannerInfo = new ScannerInfo();
|
ScannerInfo scannerInfo = new ScannerInfo();
|
||||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo, false);
|
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||||
|
|
||||||
ISourceCodeParser parser = null;
|
ISourceCodeParser parser = null;
|
||||||
if( lang == ParserLanguage.CPP )
|
if( lang == ParserLanguage.CPP )
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class ASTWriterTest extends RewriteBaseTest {
|
||||||
ParserLanguage language = getLanguage(testFile);
|
ParserLanguage language = getLanguage(testFile);
|
||||||
boolean useGNUExtensions = getGNUExtension(testFile);
|
boolean useGNUExtensions = getGNUExtension(testFile);
|
||||||
|
|
||||||
IScanner scanner = AST2BaseTest.createScanner(codeReader, language, ParserMode.COMPLETE_PARSE, scannerInfo, true);
|
IScanner scanner = AST2BaseTest.createScanner(codeReader, language, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||||
|
|
||||||
ISourceCodeParser parser2 = null;
|
ISourceCodeParser parser2 = null;
|
||||||
if( language == ParserLanguage.CPP ) {
|
if( language == ParserLanguage.CPP ) {
|
||||||
|
|
|
@ -1370,7 +1370,8 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "f1/g/h/header.h", "#define ID three\n");
|
TestSourceReader.createFile(fCProject.getProject(), "f1/g/h/header.h", "#define ID three\n");
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "f1/g/source.cpp", contents + "int CONCAT(one, ID);\n");
|
TestSourceReader.createFile(fCProject.getProject(), "f1/g/source.cpp", contents + "int CONCAT(one, ID);\n");
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "f2/g/source.cpp", contents + "int CONCAT(two, ID);\n");
|
TestSourceReader.createFile(fCProject.getProject(), "f2/g/source.cpp", contents + "int CONCAT(two, ID);\n");
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "f1/g/h/source.cpp", contents + "int CONCAT(three, ID);\n");
|
IFile f= TestSourceReader.createFile(fCProject.getProject(), "f1/g/h/source.cpp", contents + "int CONCAT(three, ID);\n");
|
||||||
|
waitUntilFileIsIndexed(f, 4000);
|
||||||
indexManager.reindex(fCProject);
|
indexManager.reindex(fCProject);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* Doug Schaefer (QNX) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
@ -27,7 +27,8 @@ import org.eclipse.core.runtime.IAdaptable;
|
||||||
/**
|
/**
|
||||||
* Models differences between languages. The interface is not supposed to be implemented directly.
|
* Models differences between languages. The interface is not supposed to be implemented directly.
|
||||||
* Rather than that clients may subclass {@link AbstractLanguage}.
|
* Rather than that clients may subclass {@link AbstractLanguage}.
|
||||||
* @author Doug Schaefer
|
*
|
||||||
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface ILanguage extends IAdaptable {
|
public interface ILanguage extends IAdaptable {
|
||||||
|
|
||||||
|
@ -35,27 +36,35 @@ public interface ILanguage extends IAdaptable {
|
||||||
* Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
* Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
||||||
* Instructs the parser to skip function and method bodies.
|
* Instructs the parser to skip function and method bodies.
|
||||||
*/
|
*/
|
||||||
public final static int OPTION_SKIP_FUNCTION_BODIES= 1;
|
public final static int OPTION_SKIP_FUNCTION_BODIES= 0x1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
* Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
||||||
* Instructs the parser to add comment nodes to the ast.
|
* Instructs the parser to add comment nodes to the ast.
|
||||||
*/
|
*/
|
||||||
public final static int OPTION_ADD_COMMENTS= 2;
|
public final static int OPTION_ADD_COMMENTS= 0x2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
* Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
||||||
* Performance optimization, instructs the parser not to create image-locations.
|
* Performance optimization, instructs the parser not to create image-locations.
|
||||||
* When using this option {@link IASTName#getImageLocation()} will always return <code>null</code>.
|
* When using this option {@link IASTName#getImageLocation()} will always return <code>null</code>.
|
||||||
*/
|
*/
|
||||||
public final static int OPTION_NO_IMAGE_LOCATIONS= 4;
|
public final static int OPTION_NO_IMAGE_LOCATIONS= 0x4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
* Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
||||||
* Marks the ast as being based on a source-file rather than a header-file. This makes a difference
|
* Marks the ast as being based on a source-file rather than a header-file. This makes a difference
|
||||||
* when bindings from the AST are used for searching the index, e.g. for static variables.
|
* when bindings from the AST are used for searching the index, e.g. for static variables.
|
||||||
*/
|
*/
|
||||||
public final static int OPTION_IS_SOURCE_UNIT= 8;
|
public final static int OPTION_IS_SOURCE_UNIT= 0x8;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
||||||
|
* Instructs the parser not to create ast nodes for expressions within aggregate initializers
|
||||||
|
* when they do not contain names.
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public final static int OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS= 0x10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the language id for this language.
|
* Return the language id for this language.
|
||||||
|
|
|
@ -30,6 +30,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
* If a <code>.c</code> file cannot be parsed, its structure remains unknown.
|
* If a <code>.c</code> file cannot be parsed, its structure remains unknown.
|
||||||
* Use <code>ICElement.isStructureKnown</code> to determine whether this is
|
* Use <code>ICElement.isStructureKnown</code> to determine whether this is
|
||||||
* the case.
|
* the case.
|
||||||
|
*
|
||||||
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISourceReference, ISourceManipulation {
|
public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISourceReference, ISourceManipulation {
|
||||||
|
|
||||||
|
@ -38,21 +40,21 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
||||||
* Meaning: Skip function and method bodies.
|
* Meaning: Skip function and method bodies.
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static final int AST_SKIP_FUNCTION_BODIES= 1;
|
public static final int AST_SKIP_FUNCTION_BODIES= 0x1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Style constant for {@link #getAST(IIndex, int)}.
|
* Style constant for {@link #getAST(IIndex, int)}.
|
||||||
* Meaning: Skip over headers that are found in the index, parse all others.
|
* Meaning: Skip over headers that are found in the index, parse all others.
|
||||||
* Macro definitions and bindings are taken from index for skipped files.
|
* Macro definitions and bindings are taken from index for skipped files.
|
||||||
*/
|
*/
|
||||||
public static final int AST_SKIP_INDEXED_HEADERS = 2;
|
public static final int AST_SKIP_INDEXED_HEADERS = 0x2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Style constant for {@link #getAST(IIndex, int)}.
|
* Style constant for {@link #getAST(IIndex, int)}.
|
||||||
* Meaning: Skip headers even if they are not found in the index.
|
* Meaning: Skip headers even if they are not found in the index.
|
||||||
* Makes practically only sense in combination with {@link #AST_SKIP_INDEXED_HEADERS}.
|
* Makes practically only sense in combination with {@link #AST_SKIP_INDEXED_HEADERS}.
|
||||||
*/
|
*/
|
||||||
public static final int AST_SKIP_NONINDEXED_HEADERS = 4;
|
public static final int AST_SKIP_NONINDEXED_HEADERS = 0x4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Style constant for {@link #getAST(IIndex, int)}.
|
* Style constant for {@link #getAST(IIndex, int)}.
|
||||||
|
@ -66,14 +68,14 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
||||||
* Style constant for {@link #getAST(IIndex, int)}.
|
* Style constant for {@link #getAST(IIndex, int)}.
|
||||||
* Meaning: Don't parse the file if there is no build information for it.
|
* Meaning: Don't parse the file if there is no build information for it.
|
||||||
*/
|
*/
|
||||||
public static final int AST_SKIP_IF_NO_BUILD_INFO = 8;
|
public static final int AST_SKIP_IF_NO_BUILD_INFO = 0x8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Style constant for {@link #getAST(IIndex, int)}.
|
* Style constant for {@link #getAST(IIndex, int)}.
|
||||||
* Meaning: Add nodes for comments to the ast.
|
* Meaning: Add nodes for comments to the ast.
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static final int AST_CREATE_COMMENT_NODES = 16;
|
public static final int AST_CREATE_COMMENT_NODES = 0x10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Style constant for {@link #getAST(IIndex, int)}.
|
* Style constant for {@link #getAST(IIndex, int)}.
|
||||||
|
@ -82,7 +84,15 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
||||||
* the flag is ignored.
|
* the flag is ignored.
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static final int AST_CONFIGURE_USING_SOURCE_CONTEXT= 32;
|
public static final int AST_CONFIGURE_USING_SOURCE_CONTEXT= 0x20;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Style constant for {@link #getAST(IIndex, int)}.
|
||||||
|
* Instructs the parser not to create ast nodes for expressions within aggregate initializers
|
||||||
|
* when they do not contain names.
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public final static int AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS= 0x40;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns an include declaration in this translation unit
|
* Creates and returns an include declaration in this translation unit
|
||||||
|
|
|
@ -40,7 +40,8 @@ public class ASTCache {
|
||||||
/** Full parse mode (no PDOM) */
|
/** Full parse mode (no PDOM) */
|
||||||
public static int PARSE_MODE_FULL= ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT;
|
public static int PARSE_MODE_FULL= ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT;
|
||||||
/** Fast parse mode (use PDOM) */
|
/** Fast parse mode (use PDOM) */
|
||||||
public static int PARSE_MODE_FAST= ITranslationUnit.AST_SKIP_ALL_HEADERS | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT;
|
public static int PARSE_MODE_FAST= ITranslationUnit.AST_SKIP_ALL_HEADERS | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT
|
||||||
|
| ITranslationUnit.AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do something with an AST.
|
* Do something with an AST.
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
||||||
else {
|
else {
|
||||||
parseFlags |= ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT;
|
parseFlags |= ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT;
|
||||||
}
|
}
|
||||||
|
parseFlags |= ITranslationUnit.AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS;
|
||||||
final IASTTranslationUnit ast;
|
final IASTTranslationUnit ast;
|
||||||
try {
|
try {
|
||||||
ast= fTranslationUnit.getAST(index, parseFlags, fProgressMonitor);
|
ast= fTranslationUnit.getAST(index, parseFlags, fProgressMonitor);
|
||||||
|
|
|
@ -822,6 +822,9 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
||||||
if ((style & AST_CREATE_COMMENT_NODES) != 0) {
|
if ((style & AST_CREATE_COMMENT_NODES) != 0) {
|
||||||
options |= ILanguage.OPTION_ADD_COMMENTS;
|
options |= ILanguage.OPTION_ADD_COMMENTS;
|
||||||
}
|
}
|
||||||
|
if ((style & AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS) != 0) {
|
||||||
|
options |= ILanguage.OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS;
|
||||||
|
}
|
||||||
if (isSourceUnit()) {
|
if (isSourceUnit()) {
|
||||||
options |= ILanguage.OPTION_IS_SOURCE_UNIT;
|
options |= ILanguage.OPTION_IS_SOURCE_UNIT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.eclipse.cdt.core.parser.KeywordSetKey;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
|
import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
|
||||||
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
||||||
import org.eclipse.cdt.internal.core.util.ICancelable;
|
import org.eclipse.cdt.internal.core.util.ICancelable;
|
||||||
|
@ -181,7 +182,13 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
|
||||||
else
|
else
|
||||||
mode= ParserMode.COMPLETE_PARSE;
|
mode= ParserMode.COMPLETE_PARSE;
|
||||||
|
|
||||||
return createParser(scanner, mode, log, index);
|
ISourceCodeParser parser= createParser(scanner, mode, log, index);
|
||||||
|
if ((options & OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS) != 0) {
|
||||||
|
if (parser instanceof AbstractGNUSourceCodeParser) {
|
||||||
|
((AbstractGNUSourceCodeParser) parser).setSkipTrivialExpressionsInAggregateInitializers(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
* Mike Kucera (IBM) - bug #206952
|
* Mike Kucera (IBM) - bug #206952
|
||||||
|
@ -81,10 +81,52 @@ import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
|
import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* Base class for the c- and c++ parser.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
protected static final int DEFAULT_DESIGNATOR_LIST_SIZE = 4;
|
protected static class FoundAggregateInitializer extends Exception {
|
||||||
|
public final IASTDeclarator fDeclarator;
|
||||||
|
public IASTDeclSpecifier fDeclSpec;
|
||||||
|
public FoundAggregateInitializer(IASTDeclarator d) {
|
||||||
|
fDeclarator= d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected static class FoundDeclaratorException extends Exception {
|
||||||
|
private static final long serialVersionUID = 0;
|
||||||
|
|
||||||
|
public IASTDeclSpecifier declSpec;
|
||||||
|
public IASTDeclarator declarator;
|
||||||
|
|
||||||
|
public IASTDeclSpecifier altSpec;
|
||||||
|
public IASTDeclarator altDeclarator;
|
||||||
|
|
||||||
|
public IToken currToken;
|
||||||
|
|
||||||
|
public FoundDeclaratorException(IASTDeclarator d, IToken t) {
|
||||||
|
this.declarator = d;
|
||||||
|
this.currToken =t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static class NameChecker extends ASTVisitor {
|
||||||
|
private boolean fFound;
|
||||||
|
protected NameChecker() {
|
||||||
|
shouldVisitNames= true;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public int visit(IASTName name) {
|
||||||
|
fFound= true;
|
||||||
|
return PROCESS_ABORT;
|
||||||
|
}
|
||||||
|
public boolean containsName(IASTNode node) {
|
||||||
|
fFound= false;
|
||||||
|
node.accept(this);
|
||||||
|
return fFound;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected NameChecker NAME_CHECKER= new NameChecker();
|
||||||
|
|
||||||
|
protected static final int DEFAULT_DESIGNATOR_LIST_SIZE = 4;
|
||||||
protected static int parseCount = 0;
|
protected static int parseCount = 0;
|
||||||
|
|
||||||
protected final AbstractParserLogService log;
|
protected final AbstractParserLogService log;
|
||||||
|
@ -103,6 +145,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
protected final IBuiltinBindingsProvider builtinBindingsProvider;
|
protected final IBuiltinBindingsProvider builtinBindingsProvider;
|
||||||
|
|
||||||
protected boolean functionCallCanBeLValue= false;
|
protected boolean functionCallCanBeLValue= false;
|
||||||
|
protected boolean skipTrivialExpressionsInAggregateInitializers= false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks the beginning of the current declaration. It is important to clear the mark whenever we
|
* Marks the beginning of the current declaration. It is important to clear the mark whenever we
|
||||||
|
@ -141,6 +185,14 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
this.builtinBindingsProvider= builtinBindingsProvider;
|
this.builtinBindingsProvider= builtinBindingsProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instructs the parser not to create ast nodes for expressions within aggregate initializers
|
||||||
|
* when they do not contain names.
|
||||||
|
*/
|
||||||
|
public void setSkipTrivialExpressionsInAggregateInitializers(boolean val) {
|
||||||
|
skipTrivialExpressionsInAggregateInitializers= val;
|
||||||
|
}
|
||||||
|
|
||||||
private AbstractParserLogService wrapLogService(IParserLogService logService) {
|
private AbstractParserLogService wrapLogService(IParserLogService logService) {
|
||||||
if (logService instanceof AbstractParserLogService) {
|
if (logService instanceof AbstractParserLogService) {
|
||||||
return (AbstractParserLogService) logService;
|
return (AbstractParserLogService) logService;
|
||||||
|
@ -1225,13 +1277,17 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return compoundStatement();
|
return compoundStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract IASTDeclarator initDeclarator(DeclarationOptions option) throws EndOfFileException, BacktrackException;
|
protected abstract IASTDeclarator initDeclarator(DeclarationOptions option)
|
||||||
|
throws EndOfFileException, BacktrackException, FoundAggregateInitializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param option the options with which to parse the declaration
|
* @param option the options with which to parse the declaration
|
||||||
* @throws FoundDeclaratorException encountered EOF while looking ahead
|
* @throws FoundDeclaratorException encountered EOF while looking ahead
|
||||||
|
* @throws FoundAggregateInitializer found aggregate initializer, needs special treatment
|
||||||
|
* because of scalability.
|
||||||
*/
|
*/
|
||||||
protected void lookAheadForDeclarator(final DeclarationOptions option) throws FoundDeclaratorException {
|
protected void lookAheadForDeclarator(final DeclarationOptions option)
|
||||||
|
throws FoundDeclaratorException, FoundAggregateInitializer {
|
||||||
IToken mark = null;
|
IToken mark = null;
|
||||||
try {
|
try {
|
||||||
mark = mark();
|
mark = mark();
|
||||||
|
@ -1252,23 +1308,6 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
|
|
||||||
protected abstract boolean verifyLookaheadDeclarator(DeclarationOptions option, IASTDeclarator d, IToken nextToken);
|
protected abstract boolean verifyLookaheadDeclarator(DeclarationOptions option, IASTDeclarator d, IToken nextToken);
|
||||||
|
|
||||||
public static class FoundDeclaratorException extends Exception {
|
|
||||||
private static final long serialVersionUID = 0;
|
|
||||||
|
|
||||||
public IASTDeclSpecifier declSpec;
|
|
||||||
public IASTDeclarator declarator;
|
|
||||||
|
|
||||||
public IASTDeclSpecifier altSpec;
|
|
||||||
public IASTDeclarator altDeclarator;
|
|
||||||
|
|
||||||
public IToken currToken;
|
|
||||||
|
|
||||||
public FoundDeclaratorException(IASTDeclarator d, IToken t) {
|
|
||||||
this.declarator = d;
|
|
||||||
this.currToken =t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse an enumeration specifier, as according to the ANSI specs in C &
|
* Parse an enumeration specifier, as according to the ANSI specs in C &
|
||||||
* C++. enumSpecifier: "enum" (name)? "{" (enumerator-list) "}"
|
* C++. enumSpecifier: "enum" (name)? "{" (enumerator-list) "}"
|
||||||
|
@ -1439,7 +1478,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
protected abstract IASTCaseStatement createCaseStatement();
|
protected abstract IASTCaseStatement createCaseStatement();
|
||||||
|
|
||||||
protected abstract IASTDeclaration declaration(DeclarationOptions option) throws BacktrackException, EndOfFileException;
|
protected abstract IASTDeclaration declaration(DeclarationOptions option) throws BacktrackException, EndOfFileException;
|
||||||
protected abstract IASTDeclSpecifier declSpecifierSeq(DeclarationOptions option) throws BacktrackException, EndOfFileException, FoundDeclaratorException;
|
protected abstract IASTDeclSpecifier declSpecifierSeq(DeclarationOptions option) throws BacktrackException, EndOfFileException, FoundDeclaratorException, FoundAggregateInitializer;
|
||||||
|
|
||||||
protected IASTDeclaration[] problemDeclaration(int offset, BacktrackException bt, DeclarationOptions option) {
|
protected IASTDeclaration[] problemDeclaration(int offset, BacktrackException bt, DeclarationOptions option) {
|
||||||
failParse();
|
failParse();
|
||||||
|
@ -1523,7 +1562,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
protected IASTDeclaration functionStyleAsmDeclaration() throws BacktrackException, EndOfFileException {
|
protected IASTDeclaration functionStyleAsmDeclaration() throws BacktrackException, EndOfFileException {
|
||||||
|
|
||||||
final int offset= LA(1).getOffset();
|
final int offset= LA(1).getOffset();
|
||||||
IASTDeclSpecifier declSpec;
|
IASTDeclSpecifier declSpec= null;
|
||||||
IASTDeclarator dtor;
|
IASTDeclarator dtor;
|
||||||
try {
|
try {
|
||||||
declSpec = declSpecifierSeq(DeclarationOptions.FUNCTION_STYLE_ASM);
|
declSpec = declSpecifierSeq(DeclarationOptions.FUNCTION_STYLE_ASM);
|
||||||
|
@ -1537,6 +1576,10 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
dtor= e.declarator;
|
dtor= e.declarator;
|
||||||
}
|
}
|
||||||
backup( e.currToken );
|
backup( e.currToken );
|
||||||
|
} catch (FoundAggregateInitializer lie) {
|
||||||
|
if (declSpec == null)
|
||||||
|
declSpec= lie.fDeclSpec;
|
||||||
|
dtor= addInitializer(lie);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LT(1) != IToken.tLBRACE)
|
if (LT(1) != IToken.tLBRACE)
|
||||||
|
@ -1561,6 +1604,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return funcDefinition;
|
return funcDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract IASTDeclarator addInitializer(FoundAggregateInitializer lie) throws EndOfFileException;
|
||||||
|
|
||||||
protected IToken asmExpression(StringBuilder content) throws EndOfFileException, BacktrackException {
|
protected IToken asmExpression(StringBuilder content) throws EndOfFileException, BacktrackException {
|
||||||
IToken t= consume(IToken.tLPAREN);
|
IToken t= consume(IToken.tLPAREN);
|
||||||
boolean needspace= false;
|
boolean needspace= false;
|
||||||
|
|
|
@ -159,12 +159,12 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (LT(1) == IToken.tASSIGN) {
|
if (LT(1) == IToken.tASSIGN) {
|
||||||
consume();
|
consume();
|
||||||
final List<IASTNode> empty= Collections.emptyList();
|
final List<IASTNode> empty= Collections.emptyList();
|
||||||
return cInitializerClause(empty);
|
return cInitializerClause(empty, false);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTInitializer cInitializerClause(List<IASTNode> designators)
|
protected IASTInitializer cInitializerClause(List<IASTNode> designators, boolean inAggregateInitializer)
|
||||||
throws EndOfFileException, BacktrackException {
|
throws EndOfFileException, BacktrackException {
|
||||||
IToken la = LA(1);
|
IToken la = LA(1);
|
||||||
int startingOffset = la.getOffset();
|
int startingOffset = la.getOffset();
|
||||||
|
@ -190,10 +190,12 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (LT(1) == IToken.tASSIGN)
|
if (LT(1) == IToken.tASSIGN)
|
||||||
consume();
|
consume();
|
||||||
|
|
||||||
IASTInitializer initializer = cInitializerClause(newDesignators);
|
IASTInitializer initializer = cInitializerClause(newDesignators, true);
|
||||||
|
|
||||||
if (newDesignators.isEmpty()) {
|
if (newDesignators.isEmpty()) {
|
||||||
result.addInitializer(initializer);
|
// depending on value of skipTrivialItemsInCompoundInitializers initializer may be null
|
||||||
|
if (initializer != null)
|
||||||
|
result.addInitializer(initializer);
|
||||||
} else {
|
} else {
|
||||||
ICASTDesignatedInitializer desigInitializer = createDesignatorInitializer();
|
ICASTDesignatedInitializer desigInitializer = createDesignatorInitializer();
|
||||||
((ASTNode) desigInitializer).setOffsetAndLength(
|
((ASTNode) desigInitializer).setOffsetAndLength(
|
||||||
|
@ -232,6 +234,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
// try this now instead
|
// try this now instead
|
||||||
// assignmentExpression
|
// assignmentExpression
|
||||||
IASTExpression assignmentExpression = assignmentExpression();
|
IASTExpression assignmentExpression = assignmentExpression();
|
||||||
|
if (inAggregateInitializer && skipTrivialExpressionsInAggregateInitializers) {
|
||||||
|
if (!NAME_CHECKER.containsName(assignmentExpression))
|
||||||
|
return null;
|
||||||
|
}
|
||||||
IASTInitializerExpression result = createInitializerExpression();
|
IASTInitializerExpression result = createInitializerExpression();
|
||||||
result.setExpression(assignmentExpression);
|
result.setExpression(assignmentExpression);
|
||||||
((ASTNode) result).setOffsetAndLength(
|
((ASTNode) result).setOffsetAndLength(
|
||||||
|
@ -387,17 +393,27 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
final int firstOffset= LA(1).getOffset();
|
final int firstOffset= LA(1).getOffset();
|
||||||
int endOffset= firstOffset;
|
int endOffset= firstOffset;
|
||||||
|
boolean insertSemi= false;
|
||||||
|
boolean parseDtors= true;
|
||||||
|
|
||||||
IASTDeclSpecifier declSpec;
|
IASTDeclSpecifier declSpec= null;
|
||||||
IASTDeclarator dtor= null;
|
IASTDeclarator dtor= null;
|
||||||
IToken markBeforDtor= null;
|
IToken markBeforDtor= null;
|
||||||
try {
|
try {
|
||||||
declSpec = declSpecifierSeq(declOption);
|
declSpec = declSpecifierSeq(declOption);
|
||||||
switch(LTcatchEOF(1)) {
|
final int lt1= LTcatchEOF(1);
|
||||||
|
switch(lt1) {
|
||||||
case 0: // eof
|
case 0: // eof
|
||||||
case IToken.tSEMI:
|
|
||||||
case IToken.tEOC:
|
case IToken.tEOC:
|
||||||
|
case IToken.tSEMI:
|
||||||
|
parseDtors= false;
|
||||||
|
insertSemi= lt1==0;
|
||||||
|
if (lt1 == IToken.tSEMI)
|
||||||
|
endOffset= consume().getEndOffset();
|
||||||
|
else
|
||||||
|
endOffset= calculateEndOffset(declSpec);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
markBeforDtor= mark();
|
markBeforDtor= mark();
|
||||||
try {
|
try {
|
||||||
|
@ -408,6 +424,13 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
backup(markBeforDtor);
|
backup(markBeforDtor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (FoundAggregateInitializer lie) {
|
||||||
|
if (declSpec == null)
|
||||||
|
declSpec= lie.fDeclSpec;
|
||||||
|
// scalability: don't keep references to tokens, initializer may be large
|
||||||
|
declarationMark= null;
|
||||||
|
markBeforDtor= null;
|
||||||
|
dtor= addInitializer(lie);
|
||||||
} catch (FoundDeclaratorException e) {
|
} catch (FoundDeclaratorException e) {
|
||||||
if (e.altSpec != null) {
|
if (e.altSpec != null) {
|
||||||
declSpec= e.altSpec;
|
declSpec= e.altSpec;
|
||||||
|
@ -428,45 +451,53 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTDeclarator[] declarators= {dtor};
|
IASTDeclarator[] declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
||||||
while (LTcatchEOF(1) == IToken.tCOMMA) {
|
if (parseDtors) {
|
||||||
consume();
|
declarators= new IASTDeclarator[]{dtor};
|
||||||
declarators= (IASTDeclarator[]) ArrayUtil.append( IASTDeclarator.class, declarators, initDeclarator(declOption));
|
while (LTcatchEOF(1) == IToken.tCOMMA) {
|
||||||
}
|
consume();
|
||||||
declarators= (IASTDeclarator[]) ArrayUtil.removeNulls( IASTDeclarator.class, declarators );
|
try {
|
||||||
|
dtor= initDeclarator(declOption);
|
||||||
boolean insertSemi= false;
|
} catch (FoundAggregateInitializer e) {
|
||||||
final int lt1= LTcatchEOF(1);
|
// scalability: don't keep references to tokens, initializer may be large
|
||||||
switch (lt1) {
|
declarationMark= null;
|
||||||
case IToken.tLBRACE:
|
markBeforDtor= null;
|
||||||
return functionDefinition(firstOffset, declSpec, declarators);
|
dtor= addInitializer(e);
|
||||||
|
|
||||||
case IToken.tSEMI:
|
|
||||||
endOffset= consume().getEndOffset();
|
|
||||||
break;
|
|
||||||
case IToken.tEOC:
|
|
||||||
endOffset= figureEndOffset(declSpec, declarators);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (declOption != DeclarationOptions.LOCAL) {
|
|
||||||
insertSemi= true;
|
|
||||||
if (markBeforDtor == null || !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) {
|
|
||||||
if (markBeforDtor != null) {
|
|
||||||
backup(markBeforDtor);
|
|
||||||
}
|
|
||||||
declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
|
||||||
endOffset= calculateEndOffset(declSpec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
endOffset= figureEndOffset(declSpec, declarators);
|
|
||||||
if (lt1 == 0 || !isOnSameLine(endOffset, LA(1).getOffset())) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
declarators= (IASTDeclarator[]) ArrayUtil.append( IASTDeclarator.class, declarators, dtor);
|
||||||
|
}
|
||||||
|
declarators= (IASTDeclarator[]) ArrayUtil.removeNulls( IASTDeclarator.class, declarators );
|
||||||
|
|
||||||
|
final int lt1= LTcatchEOF(1);
|
||||||
|
switch (lt1) {
|
||||||
|
case IToken.tLBRACE:
|
||||||
|
return functionDefinition(firstOffset, declSpec, declarators);
|
||||||
|
|
||||||
|
case IToken.tSEMI:
|
||||||
|
endOffset= consume().getEndOffset();
|
||||||
|
break;
|
||||||
|
case IToken.tEOC:
|
||||||
|
endOffset= figureEndOffset(declSpec, declarators);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (declOption != DeclarationOptions.LOCAL) {
|
||||||
|
insertSemi= true;
|
||||||
|
if (markBeforDtor != null && !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) {
|
||||||
|
backup(markBeforDtor);
|
||||||
|
declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
||||||
|
endOffset= calculateEndOffset(declSpec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
endOffset= figureEndOffset(declSpec, declarators);
|
||||||
|
if (lt1 == 0 || !isOnSameLine(endOffset, LA(1).getOffset())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throwBacktrack(LA(1));
|
||||||
}
|
}
|
||||||
throwBacktrack(LA(1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// no function body
|
// no function body
|
||||||
|
@ -657,7 +688,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
consume(IToken.tRPAREN).getEndOffset();
|
consume(IToken.tRPAREN).getEndOffset();
|
||||||
if (LT(1) == IToken.tLBRACE) {
|
if (LT(1) == IToken.tLBRACE) {
|
||||||
final List<IASTNode> emptyList = Collections.emptyList();
|
final List<IASTNode> emptyList = Collections.emptyList();
|
||||||
IASTInitializer i = cInitializerClause(emptyList);
|
IASTInitializer i = cInitializerClause(emptyList, false);
|
||||||
firstExpression = buildTypeIdInitializerExpression(t, i, offset, calculateEndOffset(i));
|
firstExpression = buildTypeIdInitializerExpression(t, i, offset, calculateEndOffset(i));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -896,6 +927,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
declSpecifier= e.declSpec;
|
declSpecifier= e.declSpec;
|
||||||
declarator= e.declarator;
|
declarator= e.declarator;
|
||||||
backup(e.currToken);
|
backup(e.currToken);
|
||||||
|
} catch (FoundAggregateInitializer lie) {
|
||||||
|
// type-ids have not compound initializers
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
} catch (BacktrackException bt) {
|
} catch (BacktrackException bt) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -982,7 +1016,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IASTDeclSpecifier declSpecifierSeq(final DeclarationOptions declOption)
|
protected IASTDeclSpecifier declSpecifierSeq(final DeclarationOptions declOption)
|
||||||
throws BacktrackException, EndOfFileException, FoundDeclaratorException {
|
throws BacktrackException, EndOfFileException, FoundDeclaratorException, FoundAggregateInitializer {
|
||||||
|
|
||||||
final int offset= LA(1).getOffset();
|
final int offset= LA(1).getOffset();
|
||||||
int endOffset= offset;
|
int endOffset= offset;
|
||||||
|
@ -1141,6 +1175,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (endOffset != offset || declOption.fAllowEmptySpecifier) {
|
if (endOffset != offset || declOption.fAllowEmptySpecifier) {
|
||||||
lookAheadForDeclarator(declOption);
|
lookAheadForDeclarator(declOption);
|
||||||
}
|
}
|
||||||
|
} catch (FoundAggregateInitializer e) {
|
||||||
|
e.fDeclSpec= createSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
|
||||||
|
throw e;
|
||||||
} catch (FoundDeclaratorException e) {
|
} catch (FoundDeclaratorException e) {
|
||||||
e.declSpec= createSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
|
e.declSpec= createSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
|
||||||
|
|
||||||
|
@ -1152,6 +1189,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
e.altDeclarator= altDtor;
|
e.altDeclarator= altDtor;
|
||||||
e.altSpec= createNamedTypeSpecifier(idToken, storageClass, options, offset, idToken.getEndOffset());
|
e.altSpec= createNamedTypeSpecifier(idToken, storageClass, options, offset, idToken.getEndOffset());
|
||||||
}
|
}
|
||||||
|
} catch (FoundAggregateInitializer lie) {
|
||||||
|
lie.fDeclSpec= e.declSpec;
|
||||||
|
throw lie;
|
||||||
} catch (BacktrackException bt) {
|
} catch (BacktrackException bt) {
|
||||||
} finally {
|
} finally {
|
||||||
backup(mark);
|
backup(mark);
|
||||||
|
@ -1485,9 +1525,13 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IASTDeclarator initDeclarator(final DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
protected IASTDeclarator initDeclarator(final DeclarationOptions option)
|
||||||
|
throws EndOfFileException, BacktrackException, FoundAggregateInitializer {
|
||||||
IASTDeclarator d = declarator(option);
|
IASTDeclarator d = declarator(option);
|
||||||
|
|
||||||
|
if (LT(1) == IToken.tASSIGN && LT(2) == IToken.tLBRACE)
|
||||||
|
throw new FoundAggregateInitializer(d);
|
||||||
|
|
||||||
IASTInitializer i = optionalCInitializer();
|
IASTInitializer i = optionalCInitializer();
|
||||||
if (i != null) {
|
if (i != null) {
|
||||||
d.setInitializer(i);
|
d.setInitializer(i);
|
||||||
|
@ -1496,6 +1540,21 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected IASTDeclarator addInitializer(FoundAggregateInitializer e) throws EndOfFileException {
|
||||||
|
final IASTDeclarator d = e.fDeclarator;
|
||||||
|
try {
|
||||||
|
IASTInitializer i = optionalCInitializer();
|
||||||
|
if (i != null) {
|
||||||
|
d.setInitializer(i);
|
||||||
|
((ASTNode) d).setLength(calculateEndOffset(i) - ((ASTNode) d).getOffset());
|
||||||
|
}
|
||||||
|
} catch (BacktrackException e1) {
|
||||||
|
// mstodo add problem node
|
||||||
|
}
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
protected IASTDeclarator declarator(DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
protected IASTDeclarator declarator(DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
||||||
final int startingOffset = LA(1).getOffset();
|
final int startingOffset = LA(1).getOffset();
|
||||||
int endOffset = startingOffset;
|
int endOffset = startingOffset;
|
||||||
|
@ -1968,6 +2027,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
altDeclSpec= fd.altSpec;
|
altDeclSpec= fd.altSpec;
|
||||||
altDeclarator= fd.altDeclarator;
|
altDeclarator= fd.altDeclarator;
|
||||||
backup(fd.currToken);
|
backup(fd.currToken);
|
||||||
|
} catch (FoundAggregateInitializer lie) {
|
||||||
|
if (declSpec == null)
|
||||||
|
declSpec= lie.fDeclSpec;
|
||||||
|
declarator= addInitializer(lie);
|
||||||
} finally {
|
} finally {
|
||||||
fPreventKnrCheck--;
|
fPreventKnrCheck--;
|
||||||
}
|
}
|
||||||
|
|
|
@ -874,6 +874,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
declSpecifier= e.declSpec;
|
declSpecifier= e.declSpec;
|
||||||
declarator= e.declarator;
|
declarator= e.declarator;
|
||||||
backup(e.currToken);
|
backup(e.currToken);
|
||||||
|
} catch (FoundAggregateInitializer lie) {
|
||||||
|
// type-ids have no initializers
|
||||||
|
return null;
|
||||||
} catch (BacktrackException bt) {
|
} catch (BacktrackException bt) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -2245,24 +2248,33 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
final int firstOffset= LA(1).getOffset();
|
final int firstOffset= LA(1).getOffset();
|
||||||
int endOffset= firstOffset;
|
int endOffset= firstOffset;
|
||||||
|
boolean insertSemi= false;
|
||||||
|
boolean parseDtors= true;
|
||||||
|
|
||||||
ICPPASTDeclSpecifier declSpec;
|
ICPPASTDeclSpecifier declSpec= null;
|
||||||
IASTDeclarator dtor= null;
|
IASTDeclarator dtor= null;
|
||||||
IToken markBeforDtor= null;
|
IToken markBeforDtor= null;
|
||||||
try {
|
try {
|
||||||
declSpec = declSpecifierSeq(declOption);
|
declSpec = declSpecifierSeq(declOption);
|
||||||
switch(LTcatchEOF(1)) {
|
final int lt1= LTcatchEOF(1);
|
||||||
|
switch(lt1) {
|
||||||
case 0: // eof
|
case 0: // eof
|
||||||
|
case IToken.tEOC:
|
||||||
case IToken.tSEMI:
|
case IToken.tSEMI:
|
||||||
if (!validWithoutDtor(declOption, declSpec)) {
|
if (lt1 != IToken.tEOC && !validWithoutDtor(declOption, declSpec))
|
||||||
throwBacktrack(LA(1));
|
throwBacktrack(LA(1));
|
||||||
}
|
|
||||||
|
parseDtors= false;
|
||||||
|
insertSemi= lt1==0;
|
||||||
|
if (lt1 == IToken.tSEMI)
|
||||||
|
endOffset= consume().getEndOffset();
|
||||||
|
else
|
||||||
|
endOffset= calculateEndOffset(declSpec);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IToken.tCOMMA:
|
case IToken.tCOMMA:
|
||||||
throwBacktrack(LA(1));
|
throwBacktrack(LA(1));
|
||||||
break;
|
break;
|
||||||
case IToken.tEOC:
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
markBeforDtor= mark();
|
markBeforDtor= mark();
|
||||||
try {
|
try {
|
||||||
|
@ -2278,6 +2290,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} catch (FoundAggregateInitializer lie) {
|
||||||
|
if (declSpec == null)
|
||||||
|
declSpec= (ICPPASTDeclSpecifier) lie.fDeclSpec;
|
||||||
|
// scalability: don't keep references to tokens, initializer may be large
|
||||||
|
declarationMark= null;
|
||||||
|
markBeforDtor= null;
|
||||||
|
dtor= addInitializer(lie);
|
||||||
} catch (FoundDeclaratorException e) {
|
} catch (FoundDeclaratorException e) {
|
||||||
declSpec= (ICPPASTDeclSpecifier) e.declSpec;
|
declSpec= (ICPPASTDeclSpecifier) e.declSpec;
|
||||||
dtor= e.declarator;
|
dtor= e.declarator;
|
||||||
|
@ -2293,51 +2312,56 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTDeclarator[] declarators= {dtor};
|
IASTDeclarator[] declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
||||||
while (LTcatchEOF(1) == IToken.tCOMMA) {
|
if (parseDtors) {
|
||||||
consume();
|
declarators= new IASTDeclarator[]{dtor};
|
||||||
declarators= (IASTDeclarator[]) ArrayUtil.append( IASTDeclarator.class, declarators, initDeclarator(declSpec, declOption));
|
while (LTcatchEOF(1) == IToken.tCOMMA) {
|
||||||
}
|
consume();
|
||||||
|
try {
|
||||||
|
dtor= initDeclarator(declSpec, declOption);
|
||||||
|
} catch (FoundAggregateInitializer e) {
|
||||||
|
// scalability: don't keep references to tokens, initializer may be large
|
||||||
|
declarationMark= null;
|
||||||
|
markBeforDtor= null;
|
||||||
|
dtor= addInitializer(e);
|
||||||
|
}
|
||||||
|
declarators = (IASTDeclarator[]) ArrayUtil.append(IASTDeclarator.class, declarators, dtor);
|
||||||
|
}
|
||||||
|
declarators = (IASTDeclarator[]) ArrayUtil.removeNulls(IASTDeclarator.class, declarators);
|
||||||
|
|
||||||
declarators= (IASTDeclarator[]) ArrayUtil.removeNulls( IASTDeclarator.class, declarators );
|
final int lt1= LTcatchEOF(1);
|
||||||
|
switch (lt1) {
|
||||||
boolean insertSemi= false;
|
case IToken.tEOC:
|
||||||
final int lt1= LTcatchEOF(1);
|
endOffset= figureEndOffset(declSpec, declarators);
|
||||||
switch (lt1) {
|
break;
|
||||||
case IToken.tEOC:
|
case IToken.tSEMI:
|
||||||
endOffset= figureEndOffset(declSpec, declarators);
|
endOffset= consume().getEndOffset();
|
||||||
break;
|
break;
|
||||||
case IToken.tSEMI:
|
case IToken.t_try:
|
||||||
endOffset= consume().getEndOffset();
|
case IToken.tCOLON:
|
||||||
break;
|
case IToken.tLBRACE:
|
||||||
case IToken.t_try:
|
return functionDefinition(firstOffset, declSpec, declarators);
|
||||||
case IToken.tCOLON:
|
default:
|
||||||
case IToken.tLBRACE:
|
if (declOption != DeclarationOptions.LOCAL) {
|
||||||
return functionDefinition(firstOffset, declSpec, declarators);
|
insertSemi= true;
|
||||||
default:
|
if (validWithoutDtor(declOption, declSpec)) {
|
||||||
if (declOption != DeclarationOptions.LOCAL) {
|
if (markBeforDtor != null && !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) {
|
||||||
insertSemi= true;
|
|
||||||
if (validWithoutDtor(declOption, declSpec)) {
|
|
||||||
// class definition without semicolon
|
|
||||||
if (markBeforDtor == null || !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) {
|
|
||||||
if (markBeforDtor != null) {
|
|
||||||
backup(markBeforDtor);
|
backup(markBeforDtor);
|
||||||
|
declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
||||||
|
endOffset= calculateEndOffset(declSpec);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
}
|
||||||
endOffset= calculateEndOffset(declSpec);
|
endOffset= figureEndOffset(declSpec, declarators);
|
||||||
|
if (lt1 == 0 || !isOnSameLine(endOffset, LA(1).getOffset())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endOffset= figureEndOffset(declSpec, declarators);
|
throwBacktrack(LA(1));
|
||||||
if (lt1 == 0 || !isOnSameLine(endOffset, LA(1).getOffset())) {
|
|
||||||
insertSemi= true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
throwBacktrack(LA(1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// no function body
|
// no function body
|
||||||
|
@ -2515,7 +2539,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
skipBrackets(IToken.tLBRACKET, IToken.tRBRACKET);
|
skipBrackets(IToken.tLBRACKET, IToken.tRBRACKET);
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTDeclSpecifier declSpec;
|
IASTDeclSpecifier declSpec= null;
|
||||||
IASTDeclarator declarator;
|
IASTDeclarator declarator;
|
||||||
try {
|
try {
|
||||||
declSpec= declSpecifierSeq(DeclarationOptions.PARAMETER);
|
declSpec= declSpecifierSeq(DeclarationOptions.PARAMETER);
|
||||||
|
@ -2524,6 +2548,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
declSpec= e.declSpec;
|
declSpec= e.declSpec;
|
||||||
declarator= e.declarator;
|
declarator= e.declarator;
|
||||||
backup(e.currToken);
|
backup(e.currToken);
|
||||||
|
} catch (FoundAggregateInitializer lie) {
|
||||||
|
if (declSpec == null)
|
||||||
|
declSpec= lie.fDeclSpec;
|
||||||
|
declarator= addInitializer(lie);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ICPPASTParameterDeclaration parm = createParameterDeclaration();
|
final ICPPASTParameterDeclaration parm = createParameterDeclaration();
|
||||||
|
@ -2558,10 +2586,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* ("typename")? name |
|
* ("typename")? name |
|
||||||
* { "class" | "struct" | "union" } classSpecifier |
|
* { "class" | "struct" | "union" } classSpecifier |
|
||||||
* {"enum"} enumSpecifier
|
* {"enum"} enumSpecifier
|
||||||
|
* @throws FoundAggregateInitializer
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected ICPPASTDeclSpecifier declSpecifierSeq(final DeclarationOptions option)
|
protected ICPPASTDeclSpecifier declSpecifierSeq(final DeclarationOptions option)
|
||||||
throws BacktrackException, EndOfFileException, FoundDeclaratorException {
|
throws BacktrackException, EndOfFileException, FoundDeclaratorException, FoundAggregateInitializer {
|
||||||
int storageClass = IASTDeclSpecifier.sc_unspecified;
|
int storageClass = IASTDeclSpecifier.sc_unspecified;
|
||||||
int simpleType = IASTSimpleDeclSpecifier.t_unspecified;
|
int simpleType = IASTSimpleDeclSpecifier.t_unspecified;
|
||||||
int options= 0;
|
int options= 0;
|
||||||
|
@ -2748,7 +2777,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (option.fAllowEmptySpecifier && LT(1) != IToken.tCOMPLETION) {
|
if (option.fAllowEmptySpecifier && LT(1) != IToken.tCOMPLETION) {
|
||||||
lookAheadForDeclarator(option);
|
lookAheadForDeclarator(option);
|
||||||
}
|
}
|
||||||
} catch (FoundDeclaratorException e) {
|
} catch (FoundAggregateInitializer e) {
|
||||||
|
e.fDeclSpec= createSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
|
||||||
|
throw e;
|
||||||
|
}catch (FoundDeclaratorException e) {
|
||||||
if (e.currToken.getType() == IToken.tEOC || option == DeclarationOptions.FUNCTION_STYLE_ASM
|
if (e.currToken.getType() == IToken.tEOC || option == DeclarationOptions.FUNCTION_STYLE_ASM
|
||||||
|| canBeConstructorDestructorOrConversion(option, storageClass, options, e.declarator)) {
|
|| canBeConstructorDestructorOrConversion(option, storageClass, options, e.declarator)) {
|
||||||
e.declSpec= createSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
|
e.declSpec= createSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
|
||||||
|
@ -3046,12 +3078,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IASTDeclarator initDeclarator(DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
protected IASTDeclarator initDeclarator(DeclarationOptions option)
|
||||||
|
throws EndOfFileException, BacktrackException, FoundAggregateInitializer {
|
||||||
// called from the lookahead, only.
|
// called from the lookahead, only.
|
||||||
return initDeclarator(DtorStrategy.PREFER_FUNCTION, option);
|
return initDeclarator(DtorStrategy.PREFER_FUNCTION, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTDeclarator initDeclarator(IASTDeclSpecifier declspec, DeclarationOptions option) throws EndOfFileException, BacktrackException {
|
protected IASTDeclarator initDeclarator(IASTDeclSpecifier declspec, DeclarationOptions option)
|
||||||
|
throws EndOfFileException, BacktrackException, FoundAggregateInitializer {
|
||||||
final IToken mark= mark();
|
final IToken mark= mark();
|
||||||
IASTDeclarator dtor1= null;
|
IASTDeclarator dtor1= null;
|
||||||
IToken end1= null;
|
IToken end1= null;
|
||||||
|
@ -3144,11 +3178,15 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* @return declarator that this parsing produced.
|
* @return declarator that this parsing produced.
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
* request a backtrack
|
* request a backtrack
|
||||||
|
* @throws FoundAggregateInitializer
|
||||||
*/
|
*/
|
||||||
protected IASTDeclarator initDeclarator(DtorStrategy strategy, DeclarationOptions option)
|
protected IASTDeclarator initDeclarator(DtorStrategy strategy, DeclarationOptions option)
|
||||||
throws EndOfFileException, BacktrackException {
|
throws EndOfFileException, BacktrackException, FoundAggregateInitializer {
|
||||||
final IASTDeclarator dtor= declarator(strategy, option);
|
final IASTDeclarator dtor= declarator(strategy, option);
|
||||||
if (option.fAllowInitializer) {
|
if (option.fAllowInitializer) {
|
||||||
|
if (LT(1) == IToken.tASSIGN && LT(2) == IToken.tLBRACE)
|
||||||
|
throw new FoundAggregateInitializer(dtor);
|
||||||
|
|
||||||
IASTInitializer initializer= optionalCPPInitializer(dtor);
|
IASTInitializer initializer= optionalCPPInitializer(dtor);
|
||||||
if (initializer != null) {
|
if (initializer != null) {
|
||||||
dtor.setInitializer(initializer);
|
dtor.setInitializer(initializer);
|
||||||
|
@ -3158,6 +3196,21 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return dtor;
|
return dtor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected IASTDeclarator addInitializer(FoundAggregateInitializer e) throws EndOfFileException {
|
||||||
|
final IASTDeclarator d = e.fDeclarator;
|
||||||
|
try {
|
||||||
|
IASTInitializer i = optionalCPPInitializer(e.fDeclarator);
|
||||||
|
if (i != null) {
|
||||||
|
d.setInitializer(i);
|
||||||
|
((ASTNode) d).setLength(calculateEndOffset(i) - ((ASTNode) d).getOffset());
|
||||||
|
}
|
||||||
|
} catch (BacktrackException e1) {
|
||||||
|
// mstodo add problem node
|
||||||
|
}
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
protected IASTInitializer optionalCPPInitializer(IASTDeclarator d)
|
protected IASTInitializer optionalCPPInitializer(IASTDeclarator d)
|
||||||
throws EndOfFileException, BacktrackException {
|
throws EndOfFileException, BacktrackException {
|
||||||
// handle initializer
|
// handle initializer
|
||||||
|
@ -3165,7 +3218,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (LT(1) == IToken.tASSIGN) {
|
if (LT(1) == IToken.tASSIGN) {
|
||||||
consume();
|
consume();
|
||||||
try {
|
try {
|
||||||
return initializerClause();
|
return initializerClause(false);
|
||||||
} catch (EndOfFileException eof) {
|
} catch (EndOfFileException eof) {
|
||||||
failParse();
|
failParse();
|
||||||
throw eof;
|
throw eof;
|
||||||
|
@ -3200,7 +3253,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected IASTInitializer initializerClause() throws EndOfFileException, BacktrackException {
|
protected IASTInitializer initializerClause(boolean inAggregateInitializer) throws EndOfFileException, BacktrackException {
|
||||||
if (LT(1) == IToken.tLBRACE) {
|
if (LT(1) == IToken.tLBRACE) {
|
||||||
int startingOffset = consume().getOffset();
|
int startingOffset = consume().getOffset();
|
||||||
|
|
||||||
|
@ -3219,7 +3272,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (LT(1) == IToken.tRBRACE)
|
if (LT(1) == IToken.tRBRACE)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
IASTInitializer clause = initializerClause();
|
IASTInitializer clause = initializerClause(true);
|
||||||
if (clause != null) {
|
if (clause != null) {
|
||||||
result.addInitializer(clause);
|
result.addInitializer(clause);
|
||||||
}
|
}
|
||||||
|
@ -3236,6 +3289,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
// try this now instead
|
// try this now instead
|
||||||
// assignmentExpression
|
// assignmentExpression
|
||||||
IASTExpression assignmentExpression = assignmentExpression();
|
IASTExpression assignmentExpression = assignmentExpression();
|
||||||
|
if (inAggregateInitializer && skipTrivialExpressionsInAggregateInitializers) {
|
||||||
|
if (!NAME_CHECKER.containsName(assignmentExpression))
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
IASTInitializerExpression result = createInitializerExpression();
|
IASTInitializerExpression result = createInitializerExpression();
|
||||||
((ASTNode) result).setOffsetAndLength(((ASTNode) assignmentExpression));
|
((ASTNode) result).setOffsetAndLength(((ASTNode) assignmentExpression));
|
||||||
result.setExpression(assignmentExpression);
|
result.setExpression(assignmentExpression);
|
||||||
|
@ -3975,7 +4033,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
private IASTSimpleDeclaration simpleSingleDeclaration(DeclarationOptions options) throws BacktrackException, EndOfFileException {
|
private IASTSimpleDeclaration simpleSingleDeclaration(DeclarationOptions options) throws BacktrackException, EndOfFileException {
|
||||||
final int startOffset= LA(1).getOffset();
|
final int startOffset= LA(1).getOffset();
|
||||||
IASTDeclSpecifier declSpec;
|
IASTDeclSpecifier declSpec= null;
|
||||||
IASTDeclarator declarator;
|
IASTDeclarator declarator;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -3985,6 +4043,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
declSpec= e.declSpec;
|
declSpec= e.declSpec;
|
||||||
declarator= e.declarator;
|
declarator= e.declarator;
|
||||||
backup(e.currToken);
|
backup(e.currToken);
|
||||||
|
} catch (FoundAggregateInitializer lie) {
|
||||||
|
if (declSpec == null)
|
||||||
|
declSpec= lie.fDeclSpec;
|
||||||
|
declarator= addInitializer(lie);
|
||||||
}
|
}
|
||||||
|
|
||||||
final int endOffset = figureEndOffset(declSpec, declarator);
|
final int endOffset = figureEndOffset(declSpec, declarator);
|
||||||
|
|
|
@ -219,7 +219,8 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
}
|
}
|
||||||
fTodoTaskUpdater= createTodoTaskUpdater();
|
fTodoTaskUpdater= createTodoTaskUpdater();
|
||||||
|
|
||||||
fASTOptions= ILanguage.OPTION_ADD_COMMENTS | ILanguage.OPTION_NO_IMAGE_LOCATIONS;
|
fASTOptions= ILanguage.OPTION_ADD_COMMENTS | ILanguage.OPTION_NO_IMAGE_LOCATIONS
|
||||||
|
| ILanguage.OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS;
|
||||||
if (getSkipReferences() == SKIP_ALL_REFERENCES) {
|
if (getSkipReferences() == SKIP_ALL_REFERENCES) {
|
||||||
fASTOptions |= ILanguage.OPTION_SKIP_FUNCTION_BODIES;
|
fASTOptions |= ILanguage.OPTION_SKIP_FUNCTION_BODIES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,7 @@ import junit.framework.Test;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.swt.widgets.Tree;
|
import org.eclipse.swt.widgets.Tree;
|
||||||
import org.eclipse.swt.widgets.TreeItem;
|
import org.eclipse.swt.widgets.TreeItem;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
|
||||||
import org.eclipse.ui.PartInitException;
|
import org.eclipse.ui.PartInitException;
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
import org.eclipse.ui.ide.IDE;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
@ -63,8 +60,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testFunctions");
|
String content = readTaggedComment("testFunctions");
|
||||||
IFile file= createFile(getProject(), filename, content);
|
IFile file= createFile(getProject(), filename, content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("proto"), 5);
|
editor.selectAndReveal(content.indexOf("proto"), 5);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
@ -108,8 +104,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testVariables");
|
String content = readTaggedComment("testVariables");
|
||||||
IFile file= createFile(getProject(), filename, content);
|
IFile file= createFile(getProject(), filename, content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("extern_var"), 0);
|
editor.selectAndReveal(content.indexOf("extern_var"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
@ -164,8 +159,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment(contentTag);
|
String content = readTaggedComment(contentTag);
|
||||||
IFile file= createFile(getProject(), filename, content);
|
IFile file= createFile(getProject(), filename, content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("enumerator"), 0);
|
editor.selectAndReveal(content.indexOf("enumerator"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
@ -220,8 +214,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testStructMembers");
|
String content = readTaggedComment("testStructMembers");
|
||||||
IFile file= createFile(getProject(), "struct_member.c", content);
|
IFile file= createFile(getProject(), "struct_member.c", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem1"), 0);
|
editor.selectAndReveal(content.indexOf("mem1"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
@ -267,8 +260,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testStructMembers");
|
String content = readTaggedComment("testStructMembers");
|
||||||
IFile file= createFile(getProject(), "struct_member.cpp", content);
|
IFile file= createFile(getProject(), "struct_member.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem1"), 0);
|
editor.selectAndReveal(content.indexOf("mem1"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
@ -314,8 +306,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testStructMembers");
|
String content = readTaggedComment("testStructMembers");
|
||||||
IFile file= createFile(getProject(), "anon_struct_member.c", content);
|
IFile file= createFile(getProject(), "anon_struct_member.c", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
@ -343,8 +334,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testStructMembers");
|
String content = readTaggedComment("testStructMembers");
|
||||||
IFile file= createFile(getProject(), "anon_struct_member.cpp", content);
|
IFile file= createFile(getProject(), "anon_struct_member.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
@ -406,8 +396,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testUnionMembers");
|
String content = readTaggedComment("testUnionMembers");
|
||||||
IFile file= createFile(getProject(), "union_member.c", content);
|
IFile file= createFile(getProject(), "union_member.c", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem1"), 0);
|
editor.selectAndReveal(content.indexOf("mem1"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
@ -453,8 +442,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testUnionMembers");
|
String content = readTaggedComment("testUnionMembers");
|
||||||
IFile file= createFile(getProject(), "union_member.cpp", content);
|
IFile file= createFile(getProject(), "union_member.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem1"), 0);
|
editor.selectAndReveal(content.indexOf("mem1"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
@ -500,8 +488,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testUnionMembers");
|
String content = readTaggedComment("testUnionMembers");
|
||||||
IFile file= createFile(getProject(), "anon_union_member.c", content);
|
IFile file= createFile(getProject(), "anon_union_member.c", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
@ -529,8 +516,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testUnionMembers");
|
String content = readTaggedComment("testUnionMembers");
|
||||||
IFile file= createFile(getProject(), "anon_union_member.cpp", content);
|
IFile file= createFile(getProject(), "anon_union_member.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
@ -575,11 +561,9 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
|
|
||||||
TreeItem i1, i2, i3, i4, i5, i6;
|
TreeItem i1, i2, i3, i4, i5, i6;
|
||||||
Tree tree;
|
Tree tree;
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor= openEditor(file1);
|
||||||
CEditor editor;
|
|
||||||
|
|
||||||
// first file with definition of gf()
|
// first file with definition of gf()
|
||||||
editor= (CEditor) IDE.openEditor(page, file1);
|
|
||||||
editor.selectAndReveal(content1.indexOf("sf"), 0);
|
editor.selectAndReveal(content1.indexOf("sf"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
tree = getCHTreeViewer().getTree();
|
tree = getCHTreeViewer().getTree();
|
||||||
|
@ -611,7 +595,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
checkTreeNode(i6, 0, null);
|
checkTreeNode(i6, 0, null);
|
||||||
|
|
||||||
// second file without definition of gf()
|
// second file without definition of gf()
|
||||||
editor= (CEditor) IDE.openEditor(page, file2);
|
editor = openEditor(file2);
|
||||||
editor.selectAndReveal(content1.indexOf("sf"), 0);
|
editor.selectAndReveal(content1.indexOf("sf"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
tree = getCHTreeViewer().getTree();
|
tree = getCHTreeViewer().getTree();
|
||||||
|
@ -646,11 +630,10 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
|
|
||||||
TreeItem i0, i1, i2, i3, i4, i5, i6;
|
TreeItem i0, i1, i2, i3, i4, i5, i6;
|
||||||
Tree tree;
|
Tree tree;
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
CEditor editor;
|
CEditor editor;
|
||||||
|
|
||||||
// first file with definition of gf()
|
// first file with definition of gf()
|
||||||
editor= (CEditor) IDE.openEditor(page, file1);
|
editor= openEditor(file1);
|
||||||
editor.selectAndReveal(content1.indexOf("sf"), 0);
|
editor.selectAndReveal(content1.indexOf("sf"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
tree = getCHTreeViewer().getTree();
|
tree = getCHTreeViewer().getTree();
|
||||||
|
@ -682,7 +665,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
checkTreeNode(i6, 0, null);
|
checkTreeNode(i6, 0, null);
|
||||||
|
|
||||||
// second file without definition of gf()
|
// second file without definition of gf()
|
||||||
editor= (CEditor) IDE.openEditor(page, file2);
|
editor= openEditor(file2);
|
||||||
editor.selectAndReveal(content1.indexOf("sf"), 0);
|
editor.selectAndReveal(content1.indexOf("sf"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
tree = getCHTreeViewer().getTree();
|
tree = getCHTreeViewer().getTree();
|
||||||
|
@ -719,8 +702,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testFunctionsWithParams");
|
String content = readTaggedComment("testFunctionsWithParams");
|
||||||
IFile file= createFile(getProject(), filename, content);
|
IFile file= createFile(getProject(), filename, content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("proto"), 5);
|
editor.selectAndReveal(content.indexOf("proto"), 5);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,16 +8,12 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.tests.callhierarchy;
|
package org.eclipse.cdt.ui.tests.callhierarchy;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.swt.widgets.Tree;
|
import org.eclipse.swt.widgets.Tree;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
import org.eclipse.ui.ide.IDE;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
|
|
||||||
|
@ -56,8 +52,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testMethods");
|
String content = readTaggedComment("testMethods");
|
||||||
IFile file= createFile(getProject(), "testMethods.cpp", content);
|
IFile file= createFile(getProject(), "testMethods.cpp", content);
|
||||||
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("method"), 2);
|
editor.selectAndReveal(content.indexOf("method"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
@ -140,8 +135,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testStaticMethods");
|
String content = readTaggedComment("testStaticMethods");
|
||||||
IFile file= createFile(getProject(), "testStaticMethods.cpp", content);
|
IFile file= createFile(getProject(), "testStaticMethods.cpp", content);
|
||||||
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("method"), 2);
|
editor.selectAndReveal(content.indexOf("method"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
@ -229,8 +223,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testFields");
|
String content = readTaggedComment("testFields");
|
||||||
IFile file= createFile(getProject(), "testFields.cpp", content);
|
IFile file= createFile(getProject(), "testFields.cpp", content);
|
||||||
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("field"), 2);
|
editor.selectAndReveal(content.indexOf("field"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
@ -304,8 +297,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testAutomaticConstructor");
|
String content = readTaggedComment("testAutomaticConstructor");
|
||||||
IFile file= createFile(getProject(), "testConstructor.cpp", content);
|
IFile file= createFile(getProject(), "testConstructor.cpp", content);
|
||||||
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("MyClass()"), 2);
|
editor.selectAndReveal(content.indexOf("MyClass()"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
@ -334,8 +326,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testConstructor");
|
String content = readTaggedComment("testConstructor");
|
||||||
IFile file= createFile(getProject(), "testConstructor.cpp", content);
|
IFile file= createFile(getProject(), "testConstructor.cpp", content);
|
||||||
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("MyClass()"), 2);
|
editor.selectAndReveal(content.indexOf("MyClass()"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
@ -348,8 +339,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testConstructor");
|
String content = readTaggedComment("testConstructor");
|
||||||
IFile file= createFile(getProject(), "testConstructor.cpp", content);
|
IFile file= createFile(getProject(), "testConstructor.cpp", content);
|
||||||
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("~MyClass()"), 2);
|
editor.selectAndReveal(content.indexOf("~MyClass()"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
@ -384,8 +374,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testNamespace");
|
String content = readTaggedComment("testNamespace");
|
||||||
IFile file= createFile(getProject(), "testNamespace.cpp", content);
|
IFile file= createFile(getProject(), "testNamespace.cpp", content);
|
||||||
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("var"), 2);
|
editor.selectAndReveal(content.indexOf("var"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
@ -442,8 +431,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("testNamespace");
|
String content = readTaggedComment("testNamespace");
|
||||||
IFile file= createFile(getProject(), "testNamespace.cpp", content);
|
IFile file= createFile(getProject(), "testNamespace.cpp", content);
|
||||||
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor = openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("var; // r1"), 2);
|
editor.selectAndReveal(content.indexOf("var; // r1"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.eclipse.swt.widgets.Tree;
|
||||||
import org.eclipse.swt.widgets.TreeItem;
|
import org.eclipse.swt.widgets.TreeItem;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.ide.IDE;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
|
@ -41,6 +40,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
|
||||||
return suite(CallHierarchyAcrossProjectsTest.class);
|
return suite(CallHierarchyAcrossProjectsTest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
|
||||||
TestScannerProvider.sIncludes= new String[]{fCProject.getProject().getLocation().toOSString(), fCProject2.getProject().getLocation().toOSString()};
|
TestScannerProvider.sIncludes= new String[]{fCProject.getProject().getLocation().toOSString(), fCProject2.getProject().getLocation().toOSString()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
if (fCProject2 != null) {
|
if (fCProject2 != null) {
|
||||||
CProjectHelper.delete(fCProject2);
|
CProjectHelper.delete(fCProject2);
|
||||||
|
@ -89,7 +90,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
|
||||||
IFile sourceFile= createFile(fCProject2.getProject(), "testMethods.cpp", source);
|
IFile sourceFile= createFile(fCProject2.getProject(), "testMethods.cpp", source);
|
||||||
waitForIndexer(fIndex, sourceFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, sourceFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, sourceFile);
|
CEditor editor= openEditor(sourceFile);
|
||||||
|
|
||||||
|
|
||||||
editor.selectAndReveal(source.indexOf("method"), 2);
|
editor.selectAndReveal(source.indexOf("method"), 2);
|
||||||
|
@ -162,7 +163,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
|
||||||
IFile sourceFile1= createFile(fCProject.getProject(), "testMethods1.cpp", source1);
|
IFile sourceFile1= createFile(fCProject.getProject(), "testMethods1.cpp", source1);
|
||||||
IFile sourceFile2= createFile(fCProject2.getProject(), "testMethods2.cpp", source2);
|
IFile sourceFile2= createFile(fCProject2.getProject(), "testMethods2.cpp", source2);
|
||||||
|
|
||||||
CEditor editor= openFile(sourceFile1);
|
CEditor editor= openEditor(sourceFile1);
|
||||||
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
|
|
||||||
editor.selectAndReveal(source1.indexOf("method3"), 2);
|
editor.selectAndReveal(source1.indexOf("method3"), 2);
|
||||||
|
@ -212,7 +213,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
|
||||||
IFile sourceFile1= createFile(fCProject2.getProject(), "testMethods1.cpp", source1);
|
IFile sourceFile1= createFile(fCProject2.getProject(), "testMethods1.cpp", source1);
|
||||||
IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
|
IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
|
||||||
|
|
||||||
CEditor editor= openFile(sourceFile1);
|
CEditor editor= openEditor(sourceFile1);
|
||||||
waitForIndexer(fIndex, sourceFile1, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, sourceFile1, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
|
|
||||||
|
@ -273,7 +274,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
|
||||||
IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1);
|
IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1);
|
||||||
IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
|
IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
|
||||||
|
|
||||||
CEditor editor= openFile(sourceFile2);
|
CEditor editor= openEditor(sourceFile2);
|
||||||
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
|
|
||||||
editor.selectAndReveal(source2.indexOf("main"), 2);
|
editor.selectAndReveal(source2.indexOf("main"), 2);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.tests.callhierarchy;
|
package org.eclipse.cdt.ui.tests.callhierarchy;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
@ -30,6 +29,7 @@ import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.tests.BaseUITestCase;
|
import org.eclipse.cdt.ui.tests.BaseUITestCase;
|
||||||
|
import org.eclipse.cdt.ui.tests.text.EditorTestHelper;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.callhierarchy.CHViewPart;
|
import org.eclipse.cdt.internal.ui.callhierarchy.CHViewPart;
|
||||||
import org.eclipse.cdt.internal.ui.callhierarchy.CallHierarchyUI;
|
import org.eclipse.cdt.internal.ui.callhierarchy.CallHierarchyUI;
|
||||||
|
@ -46,6 +46,7 @@ public class CallHierarchyBaseTest extends BaseUITestCase {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
CallHierarchyUI.setIsJUnitTest(true);
|
CallHierarchyUI.setIsJUnitTest(true);
|
||||||
|
@ -61,6 +62,7 @@ public class CallHierarchyBaseTest extends BaseUITestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
closeAllEditors();
|
closeAllEditors();
|
||||||
if (fCProject != null) {
|
if (fCProject != null) {
|
||||||
|
@ -73,9 +75,10 @@ public class CallHierarchyBaseTest extends BaseUITestCase {
|
||||||
return fCProject.getProject();
|
return fCProject.getProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CEditor openFile(IFile file) throws PartInitException {
|
protected CEditor openEditor(IFile file) throws PartInitException {
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||||
|
EditorTestHelper.joinReconciler(EditorTestHelper.getSourceViewer(editor), 100, 500, 10);
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,14 +15,9 @@ import junit.framework.Test;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.swt.widgets.Tree;
|
import org.eclipse.swt.widgets.Tree;
|
||||||
import org.eclipse.swt.widgets.TreeItem;
|
import org.eclipse.swt.widgets.TreeItem;
|
||||||
import org.eclipse.ui.IEditorPart;
|
|
||||||
import org.eclipse.ui.IPageLayout;
|
import org.eclipse.ui.IPageLayout;
|
||||||
import org.eclipse.ui.IViewPart;
|
import org.eclipse.ui.IViewPart;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
|
||||||
import org.eclipse.ui.IWorkbenchWindow;
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
import org.eclipse.ui.WorkbenchException;
|
|
||||||
import org.eclipse.ui.ide.IDE;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
@ -145,13 +140,6 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
|
||||||
CallHierarchyUI.open(workbenchWindow, (ICElement) obj);
|
CallHierarchyUI.open(workbenchWindow, (ICElement) obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CEditor openEditor(IFile file) throws WorkbenchException {
|
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
IEditorPart editor= IDE.openEditor(page, file, true);
|
|
||||||
runEventQueue(0);
|
|
||||||
return (CEditor) editor;
|
|
||||||
}
|
|
||||||
|
|
||||||
// class Base {
|
// class Base {
|
||||||
// public:
|
// public:
|
||||||
// virtual void vmethod();
|
// virtual void vmethod();
|
||||||
|
@ -345,26 +333,46 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
|
||||||
// CALL(0);
|
// CALL(0);
|
||||||
// }
|
// }
|
||||||
public void testMacrosHidingCall_249801() throws Exception {
|
public void testMacrosHidingCall_249801() throws Exception {
|
||||||
|
long t= System.currentTimeMillis();
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
|
t= printTime("contents", t);
|
||||||
IFile file= createFile(getProject(), "file249801.cpp", content);
|
IFile file= createFile(getProject(), "file249801.cpp", content);
|
||||||
|
t= printTime("file", t);
|
||||||
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
|
t= printTime("indexer", t);
|
||||||
|
|
||||||
final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);
|
final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);
|
||||||
final IWorkbenchWindow workbenchWindow = ch.getSite().getWorkbenchWindow();
|
t= printTime("view", t);
|
||||||
|
|
||||||
// open editor, check outline
|
// open editor, check outline
|
||||||
CEditor editor= openEditor(file);
|
CEditor editor= openEditor(file);
|
||||||
|
t= printTime("editor", t);
|
||||||
int idx = content.indexOf("MACRO(Test");
|
int idx = content.indexOf("MACRO(Test");
|
||||||
editor.selectAndReveal(idx, 0);
|
editor.selectAndReveal(idx, 0);
|
||||||
openCallHierarchy(editor, false);
|
openCallHierarchy(editor, false);
|
||||||
|
t= printTime("ch1", t);
|
||||||
|
|
||||||
Tree chTree= checkTreeNode(ch, 0, "PREFIX_Test(char *, char *)").getParent();
|
Tree chTree= checkTreeNode(ch, 0, "PREFIX_Test(char *, char *)").getParent();
|
||||||
TreeItem ti= checkTreeNode(chTree, 0, 0, "call(int)");
|
TreeItem ti= checkTreeNode(chTree, 0, 0, "call(int)");
|
||||||
|
t= printTime("checked", t);
|
||||||
|
|
||||||
idx = content.indexOf("CALL(0");
|
idx = content.indexOf("CALL(0");
|
||||||
editor.selectAndReveal(idx+4, 0);
|
editor.selectAndReveal(idx+4, 0);
|
||||||
openCallHierarchy(editor, true);
|
openCallHierarchy(editor, true);
|
||||||
|
t= printTime("ch2",t );
|
||||||
chTree= checkTreeNode(ch, 0, "call(int)").getParent();
|
chTree= checkTreeNode(ch, 0, "call(int)").getParent();
|
||||||
ti= checkTreeNode(chTree, 0, 0, "PREFIX_Test(char *, char *)");
|
ti= checkTreeNode(chTree, 0, 0, "PREFIX_Test(char *, char *)");
|
||||||
|
t= printTime("checked", t);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mstodo
|
||||||
|
* @param string
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private long printTime(String string, long off) {
|
||||||
|
long t= System.currentTimeMillis();
|
||||||
|
System.out.println(string + (t-off));
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.tests.callhierarchy;
|
package org.eclipse.cdt.ui.tests.callhierarchy;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
@ -19,7 +18,6 @@ import org.eclipse.swt.widgets.Tree;
|
||||||
import org.eclipse.swt.widgets.TreeItem;
|
import org.eclipse.swt.widgets.TreeItem;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.ide.IDE;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
|
||||||
|
@ -64,10 +62,9 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String source = content[1].toString();
|
String source = content[1].toString();
|
||||||
IFile headerFile= createFile(getProject(), "testMethods.h", header);
|
IFile headerFile= createFile(getProject(), "testMethods.h", header);
|
||||||
IFile sourceFile= createFile(getProject(), "testMethods.cpp", source);
|
IFile sourceFile= createFile(getProject(), "testMethods.cpp", source);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
waitForIndexer(fIndex, sourceFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, sourceFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
|
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, sourceFile);
|
CEditor editor= openEditor(sourceFile);
|
||||||
editor.selectAndReveal(source.indexOf("method"), 2);
|
editor.selectAndReveal(source.indexOf("method"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
Tree tree = getCHTreeViewer().getTree();
|
Tree tree = getCHTreeViewer().getTree();
|
||||||
|
@ -138,7 +135,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1);
|
IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1);
|
||||||
IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
|
IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
|
||||||
|
|
||||||
CEditor editor= openFile(sourceFile1);
|
CEditor editor= openEditor(sourceFile1);
|
||||||
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
|
|
||||||
editor.selectAndReveal(source1.indexOf("method3"), 2);
|
editor.selectAndReveal(source1.indexOf("method3"), 2);
|
||||||
|
@ -190,7 +187,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
|
|
||||||
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
|
|
||||||
CEditor editor= openFile(sourceFile1);
|
CEditor editor= openEditor(sourceFile1);
|
||||||
editor.selectAndReveal(source1.indexOf("method3"), 2);
|
editor.selectAndReveal(source1.indexOf("method3"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
TreeViewer tv = getCHTreeViewer();
|
TreeViewer tv = getCHTreeViewer();
|
||||||
|
@ -248,7 +245,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1);
|
IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1);
|
||||||
IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
|
IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
|
||||||
|
|
||||||
CEditor editor= openFile(sourceFile2);
|
CEditor editor= openEditor(sourceFile2);
|
||||||
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
|
|
||||||
editor.selectAndReveal(source2.indexOf("main"), 2);
|
editor.selectAndReveal(source2.indexOf("main"), 2);
|
||||||
|
@ -302,8 +299,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String cppSource = content[1].toString();
|
String cppSource = content[1].toString();
|
||||||
IFile cFile= createFile(getProject(), "s.c", cSource);
|
IFile cFile= createFile(getProject(), "s.c", cSource);
|
||||||
IFile cppFile= createFile(getProject(), "s.cpp", cppSource);
|
IFile cppFile= createFile(getProject(), "s.cpp", cppSource);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor= openEditor(cFile);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, cFile);
|
|
||||||
waitForIndexer(fIndex, cppFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, cppFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM);
|
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM);
|
||||||
|
|
||||||
|
@ -320,7 +316,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
checkTreeNode(node, 1, null);
|
checkTreeNode(node, 1, null);
|
||||||
|
|
||||||
|
|
||||||
editor= (CEditor) IDE.openEditor(page, cppFile);
|
editor= openEditor(cppFile);
|
||||||
editor.selectAndReveal(cppSource.indexOf("cppfunc"), 2);
|
editor.selectAndReveal(cppSource.indexOf("cppfunc"), 2);
|
||||||
openCallHierarchy(editor, false);
|
openCallHierarchy(editor, false);
|
||||||
tree = getCHTreeViewer().getTree();
|
tree = getCHTreeViewer().getTree();
|
||||||
|
@ -349,7 +345,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
IFile cFile= createFile(getProject(), "s.c", cSource);
|
IFile cFile= createFile(getProject(), "s.c", cSource);
|
||||||
IFile cppFile= createFile(getProject(), "s.cpp", cppSource);
|
IFile cppFile= createFile(getProject(), "s.cpp", cppSource);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, cFile);
|
CEditor editor= openEditor(cFile);
|
||||||
waitForIndexer(fIndex, cppFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, cppFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM);
|
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM);
|
||||||
|
|
||||||
|
@ -366,7 +362,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
checkTreeNode(node, 1, null);
|
checkTreeNode(node, 1, null);
|
||||||
|
|
||||||
|
|
||||||
editor= (CEditor) IDE.openEditor(page, cppFile);
|
editor= openEditor(cppFile);
|
||||||
editor.selectAndReveal(cppSource.indexOf("cppfunc"), 2);
|
editor.selectAndReveal(cppSource.indexOf("cppfunc"), 2);
|
||||||
openCallHierarchy(editor, true);
|
openCallHierarchy(editor, true);
|
||||||
tree = getCHTreeViewer().getTree();
|
tree = getCHTreeViewer().getTree();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.tests.callhierarchy;
|
package org.eclipse.cdt.ui.tests.callhierarchy;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
@ -35,7 +34,7 @@ public class InitializersInCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
String content = readTaggedComment("intvar");
|
String content = readTaggedComment("intvar");
|
||||||
IFile file= createFile(getProject(), "intvar.c", content);
|
IFile file= createFile(getProject(), "intvar.c", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
CEditor editor = openFile(file);
|
CEditor editor = openEditor(file);
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("a"), 1);
|
editor.selectAndReveal(content.indexOf("a"), 1);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
|
|
|
@ -92,8 +92,10 @@ public class HyperlinkTest extends TestCase {
|
||||||
assertNotNull(file);
|
assertNotNull(file);
|
||||||
assertTrue(file.exists());
|
assertTrue(file.exists());
|
||||||
editor = (CEditor)EditorTestHelper.openInEditor(file, true);
|
editor = (CEditor)EditorTestHelper.openInEditor(file, true);
|
||||||
|
EditorTestHelper.joinReconciler(EditorTestHelper.getSourceViewer(editor), 100, 500, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
EditorTestHelper.closeEditor(editor);
|
EditorTestHelper.closeEditor(editor);
|
||||||
CProjectHelper.delete(project);
|
CProjectHelper.delete(project);
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.tests.text.selection;
|
package org.eclipse.cdt.ui.tests.text.selection;
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ import org.eclipse.search.ui.text.AbstractTextSearchResult;
|
||||||
import org.eclipse.search2.internal.ui.SearchView;
|
import org.eclipse.search2.internal.ui.SearchView;
|
||||||
import org.eclipse.ui.IEditorInput;
|
import org.eclipse.ui.IEditorInput;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
|
import org.eclipse.ui.IViewReference;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
import org.eclipse.ui.PartInitException;
|
import org.eclipse.ui.PartInitException;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
@ -46,17 +47,18 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ILanguage;
|
import org.eclipse.cdt.core.model.ILanguage;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.testplugin.FileManager;
|
import org.eclipse.cdt.core.testplugin.FileManager;
|
||||||
import org.eclipse.cdt.ui.tests.BaseUITestCase;
|
import org.eclipse.cdt.ui.tests.BaseUITestCase;
|
||||||
|
import org.eclipse.cdt.ui.tests.text.EditorTestHelper;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
|
import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.ASTProvider;
|
import org.eclipse.cdt.internal.ui.editor.ASTProvider;
|
||||||
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
|
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
|
||||||
import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
|
import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
|
||||||
|
|
||||||
|
@ -74,10 +76,17 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
OpenDeclarationsAction.sIsJUnitTest= true;
|
OpenDeclarationsAction.sIsJUnitTest= true;
|
||||||
OpenDeclarationsAction.sAllowFallback= false;
|
OpenDeclarationsAction.sAllowFallback= false;
|
||||||
|
IWorkbenchPage page= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
|
IViewReference[] refs= page.getViewReferences();
|
||||||
|
for (int i = 0; i < refs.length; i++) {
|
||||||
|
IViewReference viewReference = refs[i];
|
||||||
|
page.setPartState(viewReference, IWorkbenchPage.STATE_RESTORED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void waitForIndex(int maxSec) throws Exception {
|
public void waitForIndex(int maxSec) throws Exception {
|
||||||
|
@ -192,34 +201,33 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase {
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
IEditorPart part = null;
|
IEditorPart part = null;
|
||||||
try {
|
try {
|
||||||
part = page.openEditor(new FileEditorInput(file), "org.eclipse.cdt.ui.editor.CEditor"); //$NON-NLS-1$
|
part = page.openEditor(new FileEditorInput(file), "org.eclipse.cdt.ui.editor.CEditor", true); //$NON-NLS-1$
|
||||||
} catch (PartInitException e) {
|
} catch (PartInitException e) {
|
||||||
assertFalse(true);
|
assertFalse(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (part instanceof AbstractTextEditor) {
|
if (part instanceof CEditor) {
|
||||||
|
CEditor editor= (CEditor) part;
|
||||||
|
EditorTestHelper.joinReconciler(EditorTestHelper.getSourceViewer(editor), 100, 500, 10);
|
||||||
((AbstractTextEditor)part).getSelectionProvider().setSelection(new TextSelection(offset,length));
|
((AbstractTextEditor)part).getSelectionProvider().setSelection(new TextSelection(offset,length));
|
||||||
|
|
||||||
final OpenDeclarationsAction action = (OpenDeclarationsAction) ((AbstractTextEditor)part).getAction("OpenDeclarations"); //$NON-NLS-1$
|
final OpenDeclarationsAction action = (OpenDeclarationsAction) editor.getAction("OpenDeclarations"); //$NON-NLS-1$
|
||||||
action.runSync();
|
action.runSync();
|
||||||
|
|
||||||
// update the file/part to point to the newly opened IFile/IEditorPart
|
// update the file/part to point to the newly opened IFile/IEditorPart
|
||||||
part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
|
part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
|
||||||
IEditorInput input = part.getEditorInput();
|
assertTrue (part instanceof CEditor);
|
||||||
if (input instanceof FileEditorInput) {
|
editor= (CEditor) part;
|
||||||
file = ((FileEditorInput)input).getFile();
|
EditorTestHelper.joinReconciler(EditorTestHelper.getSourceViewer(editor), 100, 500, 10);
|
||||||
} else {
|
|
||||||
assertFalse(true); // bail!
|
|
||||||
}
|
|
||||||
|
|
||||||
// the action above should highlight the declaration, so now retrieve it and use that selection to get the IASTName selected on the TU
|
// the action above should highlight the declaration, so now retrieve it and use that selection to get the IASTName selected on the TU
|
||||||
ISelection sel = ((AbstractTextEditor)part).getSelectionProvider().getSelection();
|
ISelection sel= editor.getSelectionProvider().getSelection();
|
||||||
|
|
||||||
final IASTName[] result= {null};
|
final IASTName[] result= {null};
|
||||||
if (sel instanceof ITextSelection) {
|
if (sel instanceof ITextSelection) {
|
||||||
final ITextSelection textSel = (ITextSelection)sel;
|
final ITextSelection textSel = (ITextSelection)sel;
|
||||||
ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(file);
|
ITranslationUnit tu = (ITranslationUnit)editor.getInputCElement();
|
||||||
IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_YES, monitor, new ASTRunnable() {
|
IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, monitor, new ASTRunnable() {
|
||||||
public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
|
public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
|
||||||
result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());
|
result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
|
|
|
@ -56,6 +56,7 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||||
import org.eclipse.cdt.core.testplugin.FileManager;
|
import org.eclipse.cdt.core.testplugin.FileManager;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.tests.BaseUITestCase;
|
import org.eclipse.cdt.ui.tests.BaseUITestCase;
|
||||||
|
import org.eclipse.cdt.ui.tests.text.EditorTestHelper;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
|
import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
|
||||||
|
@ -248,6 +249,7 @@ public class CPPSelectionTestsNoIndexer extends BaseUITestCase {
|
||||||
IEditorPart part = null;
|
IEditorPart part = null;
|
||||||
try {
|
try {
|
||||||
part = page.openEditor(new FileEditorInput(file), "org.eclipse.cdt.ui.editor.CEditor"); //$NON-NLS-1$
|
part = page.openEditor(new FileEditorInput(file), "org.eclipse.cdt.ui.editor.CEditor"); //$NON-NLS-1$
|
||||||
|
EditorTestHelper.joinReconciler(EditorTestHelper.getSourceViewer((AbstractTextEditor) part), 100, 500, 10);
|
||||||
} catch (PartInitException e) {
|
} catch (PartInitException e) {
|
||||||
assertFalse(true);
|
assertFalse(true);
|
||||||
}
|
}
|
||||||
|
@ -266,7 +268,7 @@ public class CPPSelectionTestsNoIndexer extends BaseUITestCase {
|
||||||
if (sel instanceof ITextSelection) {
|
if (sel instanceof ITextSelection) {
|
||||||
final ITextSelection textSel = (ITextSelection)sel;
|
final ITextSelection textSel = (ITextSelection)sel;
|
||||||
ITranslationUnit tu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
|
ITranslationUnit tu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
|
||||||
IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_YES, monitor, new ASTRunnable() {
|
IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, monitor, new ASTRunnable() {
|
||||||
public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
|
public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
|
||||||
result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());
|
result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
|
|
|
@ -44,19 +44,20 @@ import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ILanguage;
|
import org.eclipse.cdt.core.model.ILanguage;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||||
import org.eclipse.cdt.core.testplugin.FileManager;
|
import org.eclipse.cdt.core.testplugin.FileManager;
|
||||||
import org.eclipse.cdt.ui.tests.BaseUITestCase;
|
import org.eclipse.cdt.ui.tests.BaseUITestCase;
|
||||||
|
import org.eclipse.cdt.ui.tests.text.EditorTestHelper;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
|
import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.ASTProvider;
|
import org.eclipse.cdt.internal.ui.editor.ASTProvider;
|
||||||
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
|
import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -275,10 +276,12 @@ public class CSelectionTestsNoIndexer extends BaseUITestCase {
|
||||||
assertFalse(true);
|
assertFalse(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (part instanceof AbstractTextEditor) {
|
if (part instanceof CEditor) {
|
||||||
((AbstractTextEditor)part).getSelectionProvider().setSelection(new TextSelection(offset,length));
|
CEditor editor= (CEditor) part;
|
||||||
|
EditorTestHelper.joinReconciler(EditorTestHelper.getSourceViewer(editor), 100, 500, 10);
|
||||||
|
editor.getSelectionProvider().setSelection(new TextSelection(offset,length));
|
||||||
|
|
||||||
final OpenDeclarationsAction action = (OpenDeclarationsAction) ((AbstractTextEditor)part).getAction("OpenDeclarations"); //$NON-NLS-1$
|
final OpenDeclarationsAction action = (OpenDeclarationsAction) editor.getAction("OpenDeclarations"); //$NON-NLS-1$
|
||||||
action.runSync();
|
action.runSync();
|
||||||
|
|
||||||
// the action above should highlight the declaration, so now retrieve it and use that selection to get the IASTName selected on the TU
|
// the action above should highlight the declaration, so now retrieve it and use that selection to get the IASTName selected on the TU
|
||||||
|
@ -287,8 +290,8 @@ public class CSelectionTestsNoIndexer extends BaseUITestCase {
|
||||||
final IASTName[] result= {null};
|
final IASTName[] result= {null};
|
||||||
if (sel instanceof ITextSelection) {
|
if (sel instanceof ITextSelection) {
|
||||||
final ITextSelection textSel = (ITextSelection)sel;
|
final ITextSelection textSel = (ITextSelection)sel;
|
||||||
ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(file);
|
ITranslationUnit tu = (ITranslationUnit) editor.getInputCElement();
|
||||||
IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_YES, monitor, new ASTRunnable() {
|
IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, monitor, new ASTRunnable() {
|
||||||
public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
|
public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
|
||||||
result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());
|
result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.tests.typehierarchy;
|
package org.eclipse.cdt.ui.tests.typehierarchy;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
@ -16,9 +15,6 @@ import junit.framework.Test;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.swt.widgets.Tree;
|
import org.eclipse.swt.widgets.Tree;
|
||||||
import org.eclipse.swt.widgets.TreeItem;
|
import org.eclipse.swt.widgets.TreeItem;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
import org.eclipse.ui.ide.IDE;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
|
|
||||||
|
@ -41,8 +37,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "enum.c", content);
|
IFile file= createFile(getProject(), "enum.c", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor= openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item;
|
TreeItem item;
|
||||||
|
|
||||||
|
@ -78,8 +73,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "enummem.c", content);
|
IFile file= createFile(getProject(), "enummem.c", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor= openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item;
|
TreeItem item;
|
||||||
|
|
||||||
|
@ -115,8 +109,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "enum.cpp", content);
|
IFile file= createFile(getProject(), "enum.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor= openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item;
|
TreeItem item;
|
||||||
|
|
||||||
|
@ -152,8 +145,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "enummem.cpp", content);
|
IFile file= createFile(getProject(), "enummem.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor= openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item;
|
TreeItem item;
|
||||||
|
|
||||||
|
@ -197,8 +189,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "struct.c", content);
|
IFile file= createFile(getProject(), "struct.c", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor= openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("S1"), 1);
|
editor.selectAndReveal(content.indexOf("S1"), 1);
|
||||||
openTypeHierarchy(editor);
|
openTypeHierarchy(editor);
|
||||||
|
@ -252,8 +243,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "structmem.c", content);
|
IFile file= createFile(getProject(), "structmem.c", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor= openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("a1"), 1);
|
editor.selectAndReveal(content.indexOf("a1"), 1);
|
||||||
openTypeHierarchy(editor);
|
openTypeHierarchy(editor);
|
||||||
|
@ -287,8 +277,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "struct.cpp", content);
|
IFile file= createFile(getProject(), "struct.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor= openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("S1"), 1);
|
editor.selectAndReveal(content.indexOf("S1"), 1);
|
||||||
openTypeHierarchy(editor);
|
openTypeHierarchy(editor);
|
||||||
|
@ -343,8 +332,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "structmem.cpp", content);
|
IFile file= createFile(getProject(), "structmem.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor= openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("a1"), 1);
|
editor.selectAndReveal(content.indexOf("a1"), 1);
|
||||||
openTypeHierarchy(editor);
|
openTypeHierarchy(editor);
|
||||||
|
@ -378,8 +366,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "union.c", content);
|
IFile file= createFile(getProject(), "union.c", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor= openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("U1"), 1);
|
editor.selectAndReveal(content.indexOf("U1"), 1);
|
||||||
openTypeHierarchy(editor);
|
openTypeHierarchy(editor);
|
||||||
|
@ -429,8 +416,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "unionmem.c", content);
|
IFile file= createFile(getProject(), "unionmem.c", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor= openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("a1"), 1);
|
editor.selectAndReveal(content.indexOf("a1"), 1);
|
||||||
openTypeHierarchy(editor);
|
openTypeHierarchy(editor);
|
||||||
|
@ -456,8 +442,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "union.cpp", content);
|
IFile file= createFile(getProject(), "union.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor= openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("U1"), 1);
|
editor.selectAndReveal(content.indexOf("U1"), 1);
|
||||||
openTypeHierarchy(editor);
|
openTypeHierarchy(editor);
|
||||||
|
@ -516,8 +501,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "unionmem.cpp", content);
|
IFile file= createFile(getProject(), "unionmem.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor= openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("a1"), 1);
|
editor.selectAndReveal(content.indexOf("a1"), 1);
|
||||||
openTypeHierarchy(editor);
|
openTypeHierarchy(editor);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.tests.typehierarchy;
|
package org.eclipse.cdt.ui.tests.typehierarchy;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
@ -16,9 +15,6 @@ import junit.framework.Test;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.swt.widgets.Tree;
|
import org.eclipse.swt.widgets.Tree;
|
||||||
import org.eclipse.swt.widgets.TreeItem;
|
import org.eclipse.swt.widgets.TreeItem;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
import org.eclipse.ui.ide.IDE;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
|
|
||||||
|
@ -57,8 +53,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "class.cpp", content);
|
IFile file= createFile(getProject(), "class.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor= openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item1, item2, item3, item4;
|
TreeItem item1, item2, item3, item4;
|
||||||
|
|
||||||
|
@ -151,8 +146,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "classmem.cpp", content);
|
IFile file= createFile(getProject(), "classmem.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
CEditor editor= openEditor(file);
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item1, item2, item3, item4;
|
TreeItem item1, item2, item3, item4;
|
||||||
|
|
||||||
|
@ -245,8 +239,8 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "multi.cpp", content);
|
IFile file= createFile(getProject(), "multi.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= openEditor(file);
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item1, item2, item3, item4;
|
TreeItem item1, item2, item3, item4;
|
||||||
|
|
||||||
|
@ -356,8 +350,8 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "multimem.cpp", content);
|
IFile file= createFile(getProject(), "multimem.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= openEditor(file);
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item1, item2, item3, item4;
|
TreeItem item1, item2, item3, item4;
|
||||||
|
|
||||||
|
@ -467,8 +461,8 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "diamond.cpp", content);
|
IFile file= createFile(getProject(), "diamond.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= openEditor(file);
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item1, item2, item3, item4;
|
TreeItem item1, item2, item3, item4;
|
||||||
|
|
||||||
|
@ -578,8 +572,8 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "diamondmem.cpp", content);
|
IFile file= createFile(getProject(), "diamondmem.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= openEditor(file);
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item1, item2, item3, item4;
|
TreeItem item1, item2, item3, item4;
|
||||||
|
|
||||||
|
@ -686,8 +680,8 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "viaTypedef.cpp", content);
|
IFile file= createFile(getProject(), "viaTypedef.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= openEditor(file);
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item1, item2, item3, item4;
|
TreeItem item1, item2, item3, item4;
|
||||||
|
|
||||||
|
@ -777,8 +771,8 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "viaTypedefmem.cpp", content);
|
IFile file= createFile(getProject(), "viaTypedefmem.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= openEditor(file);
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item1, item2, item3, item4;
|
TreeItem item1, item2, item3, item4;
|
||||||
|
|
||||||
|
@ -856,8 +850,8 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "simpleTemplate.cpp", content);
|
IFile file= createFile(getProject(), "simpleTemplate.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= openEditor(file);
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item1, item2, item3, item4;
|
TreeItem item1, item2, item3, item4;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.tests.typehierarchy;
|
package org.eclipse.cdt.ui.tests.typehierarchy;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
@ -17,9 +16,6 @@ import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.swt.widgets.Tree;
|
import org.eclipse.swt.widgets.Tree;
|
||||||
import org.eclipse.swt.widgets.TreeItem;
|
import org.eclipse.swt.widgets.TreeItem;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
import org.eclipse.ui.ide.IDE;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
|
|
||||||
|
@ -58,8 +54,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "class.cpp", content);
|
IFile file= createFile(getProject(), "class.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= openEditor(file);
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item1, item2, item3, item4;
|
TreeItem item1, item2, item3, item4;
|
||||||
|
|
||||||
|
@ -154,8 +150,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "classmem.cpp", content);
|
IFile file= createFile(getProject(), "classmem.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= openEditor(file);
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item1, item2, item3, item4;
|
TreeItem item1, item2, item3, item4;
|
||||||
|
|
||||||
|
@ -251,8 +247,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "multi.cpp", content);
|
IFile file= createFile(getProject(), "multi.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= openEditor(file);
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item1, item2, item3, item4;
|
TreeItem item1, item2, item3, item4;
|
||||||
|
|
||||||
|
@ -362,8 +358,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "multimem.cpp", content);
|
IFile file= createFile(getProject(), "multimem.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= openEditor(file);
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item1, item2, item3, item4;
|
TreeItem item1, item2, item3, item4;
|
||||||
|
|
||||||
|
@ -473,8 +469,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "diamond.cpp", content);
|
IFile file= createFile(getProject(), "diamond.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= openEditor(file);
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item1, item2, item3, item4;
|
TreeItem item1, item2, item3, item4;
|
||||||
|
|
||||||
|
@ -584,8 +580,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "diamondmem.cpp", content);
|
IFile file= createFile(getProject(), "diamondmem.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= openEditor(file);
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item1, item2, item3, item4;
|
TreeItem item1, item2, item3, item4;
|
||||||
|
|
||||||
|
@ -689,8 +685,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "viaTypedef.cpp", content);
|
IFile file= createFile(getProject(), "viaTypedef.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= openEditor(file);
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item1, item2, item3, item4;
|
TreeItem item1, item2, item3, item4;
|
||||||
|
|
||||||
|
@ -783,8 +779,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0].toString();
|
||||||
IFile file= createFile(getProject(), "viaTypedefmem.cpp", content);
|
IFile file= createFile(getProject(), "viaTypedefmem.cpp", content);
|
||||||
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= openEditor(file);
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item1, item2, item3, item4;
|
TreeItem item1, item2, item3, item4;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.tests.typehierarchy;
|
package org.eclipse.cdt.ui.tests.typehierarchy;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
@ -19,9 +18,6 @@ import org.eclipse.core.resources.IProjectDescription;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.swt.widgets.Tree;
|
import org.eclipse.swt.widgets.Tree;
|
||||||
import org.eclipse.swt.widgets.TreeItem;
|
import org.eclipse.swt.widgets.TreeItem;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
import org.eclipse.ui.ide.IDE;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
|
@ -44,6 +40,7 @@ public class TypeHierarchyAcrossProjectsTest extends TypeHierarchyBaseTest {
|
||||||
return suite(TypeHierarchyAcrossProjectsTest.class);
|
return suite(TypeHierarchyAcrossProjectsTest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
|
@ -57,6 +54,7 @@ public class TypeHierarchyAcrossProjectsTest extends TypeHierarchyBaseTest {
|
||||||
TestScannerProvider.sIncludes= new String[]{fCProject.getProject().getLocation().toOSString(), fCProject2.getProject().getLocation().toOSString()};
|
TestScannerProvider.sIncludes= new String[]{fCProject.getProject().getLocation().toOSString(), fCProject2.getProject().getLocation().toOSString()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
if (fCProject2 != null) {
|
if (fCProject2 != null) {
|
||||||
CProjectHelper.delete(fCProject2);
|
CProjectHelper.delete(fCProject2);
|
||||||
|
@ -92,10 +90,9 @@ public class TypeHierarchyAcrossProjectsTest extends TypeHierarchyBaseTest {
|
||||||
String source = content[1].toString();
|
String source = content[1].toString();
|
||||||
IFile headerFile= createFile(fCProject.getProject(), "simpleHeader.h", header);
|
IFile headerFile= createFile(fCProject.getProject(), "simpleHeader.h", header);
|
||||||
IFile sourceFile= createFile(fCProject2.getProject(), "simple.cpp", source);
|
IFile sourceFile= createFile(fCProject2.getProject(), "simple.cpp", source);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
waitForIndexer(fIndex, sourceFile, TypeHierarchyBaseTest.INDEXER_WAIT_TIME);
|
waitForIndexer(fIndex, sourceFile, TypeHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||||
|
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, sourceFile);
|
CEditor editor= openEditor(sourceFile);
|
||||||
Tree tree;
|
Tree tree;
|
||||||
TreeItem item1, item2, item3, item4;
|
TreeItem item1, item2, item3, item4;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.tests.typehierarchy;
|
package org.eclipse.cdt.ui.tests.typehierarchy;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
@ -37,6 +36,7 @@ import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.tests.BaseUITestCase;
|
import org.eclipse.cdt.ui.tests.BaseUITestCase;
|
||||||
|
import org.eclipse.cdt.ui.tests.text.EditorTestHelper;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
import org.eclipse.cdt.internal.ui.typehierarchy.THViewPart;
|
import org.eclipse.cdt.internal.ui.typehierarchy.THViewPart;
|
||||||
|
@ -52,6 +52,7 @@ public class TypeHierarchyBaseTest extends BaseUITestCase {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
fCProject= CProjectHelper.createCCProject("__thTest__", "bin", IPDOMManager.ID_FAST_INDEXER);
|
fCProject= CProjectHelper.createCCProject("__thTest__", "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||||
|
@ -59,6 +60,7 @@ public class TypeHierarchyBaseTest extends BaseUITestCase {
|
||||||
fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
|
fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
closeAllEditors();
|
closeAllEditors();
|
||||||
if (fCProject != null) {
|
if (fCProject != null) {
|
||||||
|
@ -71,9 +73,10 @@ public class TypeHierarchyBaseTest extends BaseUITestCase {
|
||||||
return fCProject.getProject();
|
return fCProject.getProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CEditor openFile(IFile file) throws PartInitException {
|
protected CEditor openEditor(IFile file) throws PartInitException {
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||||
|
EditorTestHelper.joinReconciler(EditorTestHelper.getSourceViewer(editor), 100, 500, 10);
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,9 +188,11 @@ public class CreateParserLogAction implements IObjectActionDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createLog(final PrintStream out, final ITranslationUnit tu, IProgressMonitor pm) {
|
private void createLog(final PrintStream out, final ITranslationUnit tu, IProgressMonitor pm) {
|
||||||
ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_YES, pm, new ASTCache.ASTRunnable() {
|
ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, pm, new ASTCache.ASTRunnable() {
|
||||||
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
|
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
|
||||||
return createLog(out, tu, lang, ast);
|
if (ast != null)
|
||||||
|
return createLog(out, tu, lang, ast);
|
||||||
|
return Status.CANCEL_STATUS;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,17 +65,19 @@ public final class ASTProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait flag indicating that a client requesting an AST
|
* Wait flag indicating that a client requesting an AST
|
||||||
* wants to wait until an AST is ready.
|
* wants to wait until an AST is ready. If the translation unit is not open no ast will
|
||||||
|
* be provided.
|
||||||
* <p>
|
* <p>
|
||||||
* An AST will be created by this AST provider if the shared
|
* If not yet cached and if the translation unit is open, an AST will be created by
|
||||||
* AST is not for the given C element.
|
* this AST provider.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public static final WAIT_FLAG WAIT_YES= new WAIT_FLAG("wait yes"); //$NON-NLS-1$
|
public static final WAIT_FLAG WAIT_IF_OPEN= new WAIT_FLAG("wait if open"); //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait flag indicating that a client requesting an AST
|
* Wait flag indicating that a client requesting an AST
|
||||||
* only wants to wait for the shared AST of the active editor.
|
* only wants to wait for the shared AST of the active editor.
|
||||||
|
* If the translation unit is not open no ast will be provided.
|
||||||
* <p>
|
* <p>
|
||||||
* No AST will be created by the AST provider.
|
* No AST will be created by the AST provider.
|
||||||
* </p>
|
* </p>
|
||||||
|
@ -261,17 +263,6 @@ public final class ASTProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this AST provider is active on the given
|
|
||||||
* translation unit.
|
|
||||||
*
|
|
||||||
* @param tu the translation unit
|
|
||||||
* @return <code>true</code> if the given translation unit is the active one
|
|
||||||
*/
|
|
||||||
public boolean isActive(ITranslationUnit tu) {
|
|
||||||
return fCache.isActiveElement(tu) && tu.isOpen();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Informs that reconciling for the given element is about to be started.
|
* Informs that reconciling for the given element is about to be started.
|
||||||
*
|
*
|
||||||
|
@ -339,13 +330,17 @@ public final class ASTProvider {
|
||||||
public IStatus runOnAST(ICElement cElement, WAIT_FLAG waitFlag, IProgressMonitor monitor,
|
public IStatus runOnAST(ICElement cElement, WAIT_FLAG waitFlag, IProgressMonitor monitor,
|
||||||
ASTCache.ASTRunnable astRunnable) {
|
ASTCache.ASTRunnable astRunnable) {
|
||||||
Assert.isTrue(cElement instanceof ITranslationUnit);
|
Assert.isTrue(cElement instanceof ITranslationUnit);
|
||||||
boolean isActive= isActive((ITranslationUnit)cElement);
|
final ITranslationUnit tu = (ITranslationUnit)cElement;
|
||||||
|
if (!tu.isOpen())
|
||||||
|
return Status.CANCEL_STATUS;
|
||||||
|
|
||||||
|
final boolean isActive= fCache.isActiveElement(tu);
|
||||||
if (waitFlag == WAIT_ACTIVE_ONLY && !isActive) {
|
if (waitFlag == WAIT_ACTIVE_ONLY && !isActive) {
|
||||||
return Status.CANCEL_STATUS;
|
return Status.CANCEL_STATUS;
|
||||||
}
|
}
|
||||||
if (isActive && updateModificationStamp()) {
|
if (isActive && updateModificationStamp()) {
|
||||||
fCache.disposeAST();
|
fCache.disposeAST();
|
||||||
}
|
}
|
||||||
return fCache.runOnAST((ITranslationUnit)cElement, waitFlag != WAIT_NO, monitor, astRunnable);
|
return fCache.runOnAST(tu, waitFlag != WAIT_NO, monitor, astRunnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class CElementHyperlinkDetector extends AbstractHyperlinkDetector {
|
||||||
}
|
}
|
||||||
|
|
||||||
final IHyperlink[] result= {null};
|
final IHyperlink[] result= {null};
|
||||||
IStatus status= ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_YES, null, new ASTRunnable() {
|
IStatus status= ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_ACTIVE_ONLY, null, new ASTRunnable() {
|
||||||
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
|
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
|
||||||
if (ast != null) {
|
if (ast != null) {
|
||||||
final int offset= region.getOffset();
|
final int offset= region.getOffset();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,7 +9,6 @@
|
||||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
package org.eclipse.cdt.internal.ui.editor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -108,7 +107,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
|
||||||
IStatus result = Status.OK_STATUS;
|
IStatus result = Status.OK_STATUS;
|
||||||
if (fTranslationUnit != null) {
|
if (fTranslationUnit != null) {
|
||||||
final ASTProvider astProvider= CUIPlugin.getDefault().getASTProvider();
|
final ASTProvider astProvider= CUIPlugin.getDefault().getASTProvider();
|
||||||
result= astProvider.runOnAST(fTranslationUnit, ASTProvider.WAIT_YES, monitor, new ASTCache.ASTRunnable() {
|
result= astProvider.runOnAST(fTranslationUnit, ASTProvider.WAIT_IF_OPEN, monitor, new ASTCache.ASTRunnable() {
|
||||||
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
|
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
|
||||||
reconciled(ast, true, monitor);
|
reconciled(ast, true, monitor);
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
|
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
package org.eclipse.cdt.internal.ui.editor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -513,7 +512,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
|
|
||||||
final Job me= this;
|
final Job me= this;
|
||||||
ASTProvider astProvider= CUIPlugin.getDefault().getASTProvider();
|
ASTProvider astProvider= CUIPlugin.getDefault().getASTProvider();
|
||||||
IStatus status= astProvider.runOnAST(element, ASTProvider.WAIT_YES, monitor, new ASTCache.ASTRunnable() {
|
IStatus status= astProvider.runOnAST(element, ASTProvider.WAIT_IF_OPEN, monitor, new ASTCache.ASTRunnable() {
|
||||||
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
|
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
|
||||||
reconciled(ast, true, monitor);
|
reconciled(ast, true, monitor);
|
||||||
synchronized (fJobLock) {
|
synchronized (fJobLock) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class PDOMSearchTextSelectionQuery extends PDOMSearchQuery {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IStatus runWithIndex(final IIndex index, IProgressMonitor monitor) {
|
protected IStatus runWithIndex(final IIndex index, IProgressMonitor monitor) {
|
||||||
return ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_YES, monitor, new ASTRunnable() {
|
return ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_ACTIVE_ONLY, monitor, new ASTRunnable() {
|
||||||
public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
|
public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
|
||||||
if (ast != null) {
|
if (ast != null) {
|
||||||
IASTName searchName= ast.getNodeSelector(null).findEnclosingName(selection.getOffset(), selection.getLength());
|
IASTName searchName= ast.getNodeSelector(null).findEnclosingName(selection.getOffset(), selection.getLength());
|
||||||
|
|
|
@ -61,7 +61,6 @@ import org.eclipse.cdt.core.model.ILanguage;
|
||||||
import org.eclipse.cdt.core.model.ISourceRange;
|
import org.eclipse.cdt.core.model.ISourceRange;
|
||||||
import org.eclipse.cdt.core.model.ISourceReference;
|
import org.eclipse.cdt.core.model.ISourceReference;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
|
||||||
import org.eclipse.cdt.core.model.util.CElementBaseLabels;
|
import org.eclipse.cdt.core.model.util.CElementBaseLabels;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
@ -103,7 +102,7 @@ public class OpenDeclarationsAction extends SelectionParseAction implements ASTR
|
||||||
|
|
||||||
ITextSelection fTextSelection;
|
ITextSelection fTextSelection;
|
||||||
private String fSelectedText;
|
private String fSelectedText;
|
||||||
private IWorkingCopy fWorkingCopy;
|
private ITranslationUnit fWorkingCopy;
|
||||||
private IIndex fIndex;
|
private IIndex fIndex;
|
||||||
private IProgressMonitor fMonitor;
|
private IProgressMonitor fMonitor;
|
||||||
|
|
||||||
|
@ -122,10 +121,11 @@ public class OpenDeclarationsAction extends SelectionParseAction implements ASTR
|
||||||
clearStatusLine();
|
clearStatusLine();
|
||||||
|
|
||||||
fMonitor= monitor;
|
fMonitor= monitor;
|
||||||
fWorkingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput());
|
ICElement celem= fEditor.getInputCElement();
|
||||||
if (fWorkingCopy == null)
|
if (!(celem instanceof ITranslationUnit))
|
||||||
return Status.CANCEL_STATUS;
|
return Status.CANCEL_STATUS;
|
||||||
|
|
||||||
|
fWorkingCopy= (ITranslationUnit) celem;
|
||||||
fIndex= CCorePlugin.getIndexManager().getIndex(fWorkingCopy.getCProject(),
|
fIndex= CCorePlugin.getIndexManager().getIndex(fWorkingCopy.getCProject(),
|
||||||
IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
|
IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ public class OpenDeclarationsAction extends SelectionParseAction implements ASTR
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return ASTProvider.getASTProvider().runOnAST(fWorkingCopy, ASTProvider.WAIT_YES, monitor, this);
|
return ASTProvider.getASTProvider().runOnAST(fWorkingCopy, ASTProvider.WAIT_ACTIVE_ONLY, monitor, this);
|
||||||
} finally {
|
} finally {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.text.correction;
|
package org.eclipse.cdt.internal.ui.text.correction;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -120,7 +119,7 @@ public class CorrectionCommandHandler extends AbstractHandler {
|
||||||
private ICompletionProposal getLocalRenameProposal(final IInvocationContext context) {
|
private ICompletionProposal getLocalRenameProposal(final IInvocationContext context) {
|
||||||
final ICCompletionProposal[] proposals= new ICCompletionProposal[1];
|
final ICCompletionProposal[] proposals= new ICCompletionProposal[1];
|
||||||
|
|
||||||
ASTProvider.getASTProvider().runOnAST(context.getTranslationUnit(), ASTProvider.WAIT_YES,
|
ASTProvider.getASTProvider().runOnAST(context.getTranslationUnit(), ASTProvider.WAIT_ACTIVE_ONLY,
|
||||||
new NullProgressMonitor(), new ASTRunnable() {
|
new NullProgressMonitor(), new ASTRunnable() {
|
||||||
|
|
||||||
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
|
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
|
||||||
|
|
|
@ -170,7 +170,7 @@ public class QuickAssistLightBulbUpdater {
|
||||||
if (workingCopy != null) {
|
if (workingCopy != null) {
|
||||||
installSelectionListener();
|
installSelectionListener();
|
||||||
final Point point= fViewer.getSelectedRange();
|
final Point point= fViewer.getSelectedRange();
|
||||||
ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_YES, null, new ASTRunnable() {
|
ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_IF_OPEN, null, new ASTRunnable() {
|
||||||
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) {
|
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) {
|
||||||
if (astRoot != null) {
|
if (astRoot != null) {
|
||||||
doSelectionChanged(point.x, point.y, astRoot);
|
doSelectionChanged(point.x, point.y, astRoot);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2007 IBM Corporation and others.
|
* Copyright (c) 2000, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -14,17 +14,10 @@ package org.eclipse.cdt.internal.ui.text.correction.proposals;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.events.VerifyEvent;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
import org.eclipse.swt.graphics.Point;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.jface.viewers.StyledString;
|
|
||||||
|
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.DocumentEvent;
|
import org.eclipse.jface.text.DocumentEvent;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
|
@ -39,7 +32,12 @@ import org.eclipse.jface.text.link.LinkedPosition;
|
||||||
import org.eclipse.jface.text.link.LinkedPositionGroup;
|
import org.eclipse.jface.text.link.LinkedPositionGroup;
|
||||||
import org.eclipse.jface.text.link.LinkedModeUI.ExitFlags;
|
import org.eclipse.jface.text.link.LinkedModeUI.ExitFlags;
|
||||||
import org.eclipse.jface.text.link.LinkedModeUI.IExitPolicy;
|
import org.eclipse.jface.text.link.LinkedModeUI.IExitPolicy;
|
||||||
|
import org.eclipse.jface.viewers.StyledString;
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.VerifyEvent;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.graphics.Point;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
|
import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
|
||||||
|
|
||||||
|
@ -136,10 +134,13 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
|
||||||
final int secectionOffset = selection.x;
|
final int secectionOffset = selection.x;
|
||||||
final int selectionLength = selection.y;
|
final int selectionLength = selection.y;
|
||||||
|
|
||||||
ASTProvider.getASTProvider().runOnAST(fTranslationUnit, ASTProvider.WAIT_YES,
|
ASTProvider.getASTProvider().runOnAST(fTranslationUnit, ASTProvider.WAIT_ACTIVE_ONLY,
|
||||||
new NullProgressMonitor(), new ASTRunnable() {
|
new NullProgressMonitor(), new ASTRunnable() {
|
||||||
|
|
||||||
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
|
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
|
||||||
|
if (astRoot == null)
|
||||||
|
return Status.CANCEL_STATUS;
|
||||||
|
|
||||||
IASTNodeSelector selector= astRoot.getNodeSelector(null);
|
IASTNodeSelector selector= astRoot.getNodeSelector(null);
|
||||||
IASTName name= selector.findEnclosingName(secectionOffset, selectionLength);
|
IASTName name= selector.findEnclosingName(secectionOffset, selectionLength);
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
|
@ -249,7 +250,7 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
|
||||||
public String getDisplayString() {
|
public String getDisplayString() {
|
||||||
String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
|
String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
|
||||||
if (shortCutString != null) {
|
if (shortCutString != null) {
|
||||||
return CorrectionMessages.bind(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
|
return NLS.bind(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
|
||||||
fLabel, shortCutString);
|
fLabel, shortCutString);
|
||||||
}
|
}
|
||||||
return fLabel;
|
return fLabel;
|
||||||
|
@ -263,7 +264,7 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
|
||||||
|
|
||||||
String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
|
String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
|
||||||
if (shortCutString != null) {
|
if (shortCutString != null) {
|
||||||
String decorated= CorrectionMessages.bind(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
|
String decorated= NLS.bind(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
|
||||||
fLabel, shortCutString);
|
fLabel, shortCutString);
|
||||||
return ColoringLabelProvider.decorateStyledString(str, decorated, StyledString.QUALIFIER_STYLER);
|
return ColoringLabelProvider.decorateStyledString(str, decorated, StyledString.QUALIFIER_STYLER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -393,7 +393,7 @@ public class IndexUI {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
final IASTName[] result= {null};
|
final IASTName[] result= {null};
|
||||||
ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_YES, null, new ASTRunnable() {
|
ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_ACTIVE_ONLY, null, new ASTRunnable() {
|
||||||
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
|
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
|
||||||
if (ast != null) {
|
if (ast != null) {
|
||||||
final IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
|
final IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
|
||||||
|
|
Loading…
Add table
Reference in a new issue