emptyList = Collections.emptyList();
- IASTInitializer i = cInitializerClause(emptyList);
+ IASTInitializer i = cInitializerClause(emptyList, false);
firstExpression = buildTypeIdInitializerExpression(t, i, offset, calculateEndOffset(i));
break;
}
@@ -896,6 +927,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
declSpecifier= e.declSpec;
declarator= e.declarator;
backup(e.currToken);
+ } catch (FoundAggregateInitializer lie) {
+ // type-ids have not compound initializers
+ return null;
}
} catch (BacktrackException bt) {
return null;
@@ -982,7 +1016,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
@Override
protected IASTDeclSpecifier declSpecifierSeq(final DeclarationOptions declOption)
- throws BacktrackException, EndOfFileException, FoundDeclaratorException {
+ throws BacktrackException, EndOfFileException, FoundDeclaratorException, FoundAggregateInitializer {
final int offset= LA(1).getOffset();
int endOffset= offset;
@@ -1141,6 +1175,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
if (endOffset != offset || declOption.fAllowEmptySpecifier) {
lookAheadForDeclarator(declOption);
}
+ } catch (FoundAggregateInitializer e) {
+ e.fDeclSpec= createSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
+ throw e;
} catch (FoundDeclaratorException e) {
e.declSpec= createSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
@@ -1152,6 +1189,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
e.altDeclarator= altDtor;
e.altSpec= createNamedTypeSpecifier(idToken, storageClass, options, offset, idToken.getEndOffset());
}
+ } catch (FoundAggregateInitializer lie) {
+ lie.fDeclSpec= e.declSpec;
+ throw lie;
} catch (BacktrackException bt) {
} finally {
backup(mark);
@@ -1485,9 +1525,13 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
}
@Override
- protected IASTDeclarator initDeclarator(final DeclarationOptions option) throws EndOfFileException, BacktrackException {
+ protected IASTDeclarator initDeclarator(final DeclarationOptions option)
+ throws EndOfFileException, BacktrackException, FoundAggregateInitializer {
IASTDeclarator d = declarator(option);
+ if (LT(1) == IToken.tASSIGN && LT(2) == IToken.tLBRACE)
+ throw new FoundAggregateInitializer(d);
+
IASTInitializer i = optionalCInitializer();
if (i != null) {
d.setInitializer(i);
@@ -1495,6 +1539,21 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
}
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 {
final int startingOffset = LA(1).getOffset();
@@ -1968,6 +2027,10 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
altDeclSpec= fd.altSpec;
altDeclarator= fd.altDeclarator;
backup(fd.currToken);
+ } catch (FoundAggregateInitializer lie) {
+ if (declSpec == null)
+ declSpec= lie.fDeclSpec;
+ declarator= addInitializer(lie);
} finally {
fPreventKnrCheck--;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
index d324affbcae..5b4350e325a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
@@ -874,6 +874,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
declSpecifier= e.declSpec;
declarator= e.declarator;
backup(e.currToken);
+ } catch (FoundAggregateInitializer lie) {
+ // type-ids have no initializers
+ return null;
} catch (BacktrackException bt) {
return null;
}
@@ -2245,24 +2248,33 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
final int firstOffset= LA(1).getOffset();
int endOffset= firstOffset;
+ boolean insertSemi= false;
+ boolean parseDtors= true;
- ICPPASTDeclSpecifier declSpec;
+ ICPPASTDeclSpecifier declSpec= null;
IASTDeclarator dtor= null;
IToken markBeforDtor= null;
try {
declSpec = declSpecifierSeq(declOption);
- switch(LTcatchEOF(1)) {
+ final int lt1= LTcatchEOF(1);
+ switch(lt1) {
case 0: // eof
+ case IToken.tEOC:
case IToken.tSEMI:
- if (!validWithoutDtor(declOption, declSpec)) {
+ if (lt1 != IToken.tEOC && !validWithoutDtor(declOption, declSpec))
throwBacktrack(LA(1));
- }
+
+ parseDtors= false;
+ insertSemi= lt1==0;
+ if (lt1 == IToken.tSEMI)
+ endOffset= consume().getEndOffset();
+ else
+ endOffset= calculateEndOffset(declSpec);
break;
+
case IToken.tCOMMA:
throwBacktrack(LA(1));
break;
- case IToken.tEOC:
- break;
default:
markBeforDtor= mark();
try {
@@ -2278,6 +2290,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
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) {
declSpec= (ICPPASTDeclSpecifier) e.declSpec;
dtor= e.declarator;
@@ -2293,51 +2312,56 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
throw e;
}
- IASTDeclarator[] declarators= {dtor};
- while (LTcatchEOF(1) == IToken.tCOMMA) {
- consume();
- declarators= (IASTDeclarator[]) ArrayUtil.append( IASTDeclarator.class, declarators, initDeclarator(declSpec, declOption));
- }
-
- declarators= (IASTDeclarator[]) ArrayUtil.removeNulls( IASTDeclarator.class, declarators );
-
- boolean insertSemi= false;
- final int lt1= LTcatchEOF(1);
- switch (lt1) {
- case IToken.tEOC:
- endOffset= figureEndOffset(declSpec, declarators);
- break;
- case IToken.tSEMI:
- endOffset= consume().getEndOffset();
- break;
- case IToken.t_try:
- case IToken.tCOLON:
- case IToken.tLBRACE:
- return functionDefinition(firstOffset, declSpec, declarators);
- default:
- if (declOption != DeclarationOptions.LOCAL) {
- insertSemi= true;
- if (validWithoutDtor(declOption, declSpec)) {
- // class definition without semicolon
- if (markBeforDtor == null || !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) {
- if (markBeforDtor != null) {
+ IASTDeclarator[] declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
+ if (parseDtors) {
+ declarators= new IASTDeclarator[]{dtor};
+ 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);
+
+ final int lt1= LTcatchEOF(1);
+ switch (lt1) {
+ case IToken.tEOC:
+ endOffset= figureEndOffset(declSpec, declarators);
+ break;
+ case IToken.tSEMI:
+ endOffset= consume().getEndOffset();
+ break;
+ case IToken.t_try:
+ case IToken.tCOLON:
+ case IToken.tLBRACE:
+ return functionDefinition(firstOffset, declSpec, declarators);
+ default:
+ if (declOption != DeclarationOptions.LOCAL) {
+ insertSemi= true;
+ if (validWithoutDtor(declOption, declSpec)) {
+ if (markBeforDtor != null && !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) {
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;
}
- }
- endOffset= figureEndOffset(declSpec, declarators);
- if (lt1 == 0 || !isOnSameLine(endOffset, LA(1).getOffset())) {
- insertSemi= true;
- break;
- }
- if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) {
- break;
}
+ throwBacktrack(LA(1));
}
- throwBacktrack(LA(1));
}
// no function body
@@ -2515,7 +2539,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
skipBrackets(IToken.tLBRACKET, IToken.tRBRACKET);
}
- IASTDeclSpecifier declSpec;
+ IASTDeclSpecifier declSpec= null;
IASTDeclarator declarator;
try {
declSpec= declSpecifierSeq(DeclarationOptions.PARAMETER);
@@ -2524,6 +2548,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
declSpec= e.declSpec;
declarator= e.declarator;
backup(e.currToken);
+ } catch (FoundAggregateInitializer lie) {
+ if (declSpec == null)
+ declSpec= lie.fDeclSpec;
+ declarator= addInitializer(lie);
}
final ICPPASTParameterDeclaration parm = createParameterDeclaration();
@@ -2558,10 +2586,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
* ("typename")? name |
* { "class" | "struct" | "union" } classSpecifier |
* {"enum"} enumSpecifier
+ * @throws FoundAggregateInitializer
*/
@Override
protected ICPPASTDeclSpecifier declSpecifierSeq(final DeclarationOptions option)
- throws BacktrackException, EndOfFileException, FoundDeclaratorException {
+ throws BacktrackException, EndOfFileException, FoundDeclaratorException, FoundAggregateInitializer {
int storageClass = IASTDeclSpecifier.sc_unspecified;
int simpleType = IASTSimpleDeclSpecifier.t_unspecified;
int options= 0;
@@ -2748,7 +2777,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (option.fAllowEmptySpecifier && LT(1) != IToken.tCOMPLETION) {
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
|| canBeConstructorDestructorOrConversion(option, storageClass, options, e.declarator)) {
e.declSpec= createSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
@@ -3046,12 +3078,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
@Override
- protected IASTDeclarator initDeclarator(DeclarationOptions option) throws EndOfFileException, BacktrackException {
+ protected IASTDeclarator initDeclarator(DeclarationOptions option)
+ throws EndOfFileException, BacktrackException, FoundAggregateInitializer {
// called from the lookahead, only.
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();
IASTDeclarator dtor1= null;
IToken end1= null;
@@ -3076,7 +3110,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
} catch (BacktrackException e) {
bt= e;
- }
+ }
if (!option.fAllowConstructorInitializer || !canHaveConstructorInitializer(declspec)) {
if (bt != null)
@@ -3096,7 +3130,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
return dtor1;
}
throw e;
- }
+ }
// we have an ambiguity
if (end1 != null && LA(1).getEndOffset() != end1.getEndOffset()) {
@@ -3144,11 +3178,15 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
* @return declarator that this parsing produced.
* @throws BacktrackException
* request a backtrack
+ * @throws FoundAggregateInitializer
*/
protected IASTDeclarator initDeclarator(DtorStrategy strategy, DeclarationOptions option)
- throws EndOfFileException, BacktrackException {
+ throws EndOfFileException, BacktrackException, FoundAggregateInitializer {
final IASTDeclarator dtor= declarator(strategy, option);
if (option.fAllowInitializer) {
+ if (LT(1) == IToken.tASSIGN && LT(2) == IToken.tLBRACE)
+ throw new FoundAggregateInitializer(dtor);
+
IASTInitializer initializer= optionalCPPInitializer(dtor);
if (initializer != null) {
dtor.setInitializer(initializer);
@@ -3157,6 +3195,21 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
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)
throws EndOfFileException, BacktrackException {
@@ -3165,7 +3218,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (LT(1) == IToken.tASSIGN) {
consume();
try {
- return initializerClause();
+ return initializerClause(false);
} catch (EndOfFileException eof) {
failParse();
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) {
int startingOffset = consume().getOffset();
@@ -3219,7 +3272,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (LT(1) == IToken.tRBRACE)
break;
- IASTInitializer clause = initializerClause();
+ IASTInitializer clause = initializerClause(true);
if (clause != null) {
result.addInitializer(clause);
}
@@ -3236,6 +3289,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
// try this now instead
// assignmentExpression
IASTExpression assignmentExpression = assignmentExpression();
+ if (inAggregateInitializer && skipTrivialExpressionsInAggregateInitializers) {
+ if (!NAME_CHECKER.containsName(assignmentExpression))
+ return null;
+ }
+
IASTInitializerExpression result = createInitializerExpression();
((ASTNode) result).setOffsetAndLength(((ASTNode) assignmentExpression));
result.setExpression(assignmentExpression);
@@ -3975,7 +4033,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
private IASTSimpleDeclaration simpleSingleDeclaration(DeclarationOptions options) throws BacktrackException, EndOfFileException {
final int startOffset= LA(1).getOffset();
- IASTDeclSpecifier declSpec;
+ IASTDeclSpecifier declSpec= null;
IASTDeclarator declarator;
try {
@@ -3985,6 +4043,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
declSpec= e.declSpec;
declarator= e.declarator;
backup(e.currToken);
+ } catch (FoundAggregateInitializer lie) {
+ if (declSpec == null)
+ declSpec= lie.fDeclSpec;
+ declarator= addInitializer(lie);
}
final int endOffset = figureEndOffset(declSpec, declarator);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java
index 85e5dce9ffa..2e64e2f385e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java
@@ -219,7 +219,8 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
}
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) {
fASTOptions |= ILanguage.OPTION_SKIP_FUNCTION_BODIES;
}
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java
index 3c49e2d668d..db3dbca748c 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java
@@ -17,10 +17,7 @@ import junit.framework.Test;
import org.eclipse.core.resources.IFile;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.IWorkbenchPage;
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.model.ICProject;
@@ -63,8 +60,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testFunctions");
IFile file= createFile(getProject(), filename, content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("proto"), 5);
openCallHierarchy(editor);
@@ -108,8 +104,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testVariables");
IFile file= createFile(getProject(), filename, content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("extern_var"), 0);
openCallHierarchy(editor);
@@ -164,8 +159,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment(contentTag);
IFile file= createFile(getProject(), filename, content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("enumerator"), 0);
openCallHierarchy(editor);
@@ -220,8 +214,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testStructMembers");
IFile file= createFile(getProject(), "struct_member.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("mem1"), 0);
openCallHierarchy(editor);
@@ -267,8 +260,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testStructMembers");
IFile file= createFile(getProject(), "struct_member.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("mem1"), 0);
openCallHierarchy(editor);
@@ -314,8 +306,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testStructMembers");
IFile file= createFile(getProject(), "anon_struct_member.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("mem3"), 0);
openCallHierarchy(editor);
@@ -343,8 +334,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testStructMembers");
IFile file= createFile(getProject(), "anon_struct_member.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("mem3"), 0);
openCallHierarchy(editor);
@@ -406,8 +396,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testUnionMembers");
IFile file= createFile(getProject(), "union_member.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("mem1"), 0);
openCallHierarchy(editor);
@@ -453,8 +442,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testUnionMembers");
IFile file= createFile(getProject(), "union_member.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("mem1"), 0);
openCallHierarchy(editor);
@@ -500,8 +488,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testUnionMembers");
IFile file= createFile(getProject(), "anon_union_member.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("mem3"), 0);
openCallHierarchy(editor);
@@ -529,8 +516,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testUnionMembers");
IFile file= createFile(getProject(), "anon_union_member.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("mem3"), 0);
openCallHierarchy(editor);
@@ -575,11 +561,9 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
TreeItem i1, i2, i3, i4, i5, i6;
Tree tree;
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor;
+ CEditor editor= openEditor(file1);
// first file with definition of gf()
- editor= (CEditor) IDE.openEditor(page, file1);
editor.selectAndReveal(content1.indexOf("sf"), 0);
openCallHierarchy(editor);
tree = getCHTreeViewer().getTree();
@@ -611,7 +595,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
checkTreeNode(i6, 0, null);
// second file without definition of gf()
- editor= (CEditor) IDE.openEditor(page, file2);
+ editor = openEditor(file2);
editor.selectAndReveal(content1.indexOf("sf"), 0);
openCallHierarchy(editor);
tree = getCHTreeViewer().getTree();
@@ -646,11 +630,10 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
TreeItem i0, i1, i2, i3, i4, i5, i6;
Tree tree;
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor;
// first file with definition of gf()
- editor= (CEditor) IDE.openEditor(page, file1);
+ editor= openEditor(file1);
editor.selectAndReveal(content1.indexOf("sf"), 0);
openCallHierarchy(editor);
tree = getCHTreeViewer().getTree();
@@ -682,7 +665,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
checkTreeNode(i6, 0, null);
// second file without definition of gf()
- editor= (CEditor) IDE.openEditor(page, file2);
+ editor= openEditor(file2);
editor.selectAndReveal(content1.indexOf("sf"), 0);
openCallHierarchy(editor);
tree = getCHTreeViewer().getTree();
@@ -719,8 +702,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testFunctionsWithParams");
IFile file= createFile(getProject(), filename, content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("proto"), 5);
openCallHierarchy(editor);
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java
index 6e31b178926..8b26c0ca2ff 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java
@@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,16 +8,12 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
-
package org.eclipse.cdt.ui.tests.callhierarchy;
import junit.framework.Test;
import org.eclipse.core.resources.IFile;
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;
@@ -56,8 +52,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testMethods");
IFile file= createFile(getProject(), "testMethods.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("method"), 2);
openCallHierarchy(editor);
@@ -140,8 +135,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testStaticMethods");
IFile file= createFile(getProject(), "testStaticMethods.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("method"), 2);
openCallHierarchy(editor);
@@ -229,8 +223,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testFields");
IFile file= createFile(getProject(), "testFields.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("field"), 2);
openCallHierarchy(editor);
@@ -304,8 +297,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testAutomaticConstructor");
IFile file= createFile(getProject(), "testConstructor.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("MyClass()"), 2);
openCallHierarchy(editor);
@@ -334,8 +326,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testConstructor");
IFile file= createFile(getProject(), "testConstructor.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("MyClass()"), 2);
openCallHierarchy(editor);
@@ -348,8 +339,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testConstructor");
IFile file= createFile(getProject(), "testConstructor.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("~MyClass()"), 2);
openCallHierarchy(editor);
@@ -384,8 +374,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testNamespace");
IFile file= createFile(getProject(), "testNamespace.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("var"), 2);
openCallHierarchy(editor);
@@ -442,8 +431,7 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("testNamespace");
IFile file= createFile(getProject(), "testNamespace.cpp", content);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("var; // r1"), 2);
openCallHierarchy(editor);
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java
index 716079a134e..610ae71fe60 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java
@@ -18,7 +18,6 @@ import org.eclipse.swt.widgets.Tree;
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.dom.IPDOMManager;
@@ -41,6 +40,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
return suite(CallHierarchyAcrossProjectsTest.class);
}
+ @Override
protected void setUp() throws Exception {
super.setUp();
@@ -51,6 +51,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
TestScannerProvider.sIncludes= new String[]{fCProject.getProject().getLocation().toOSString(), fCProject2.getProject().getLocation().toOSString()};
}
+ @Override
protected void tearDown() throws Exception {
if (fCProject2 != null) {
CProjectHelper.delete(fCProject2);
@@ -89,7 +90,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
IFile sourceFile= createFile(fCProject2.getProject(), "testMethods.cpp", source);
waitForIndexer(fIndex, sourceFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, sourceFile);
+ CEditor editor= openEditor(sourceFile);
editor.selectAndReveal(source.indexOf("method"), 2);
@@ -162,7 +163,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
IFile sourceFile1= createFile(fCProject.getProject(), "testMethods1.cpp", source1);
IFile sourceFile2= createFile(fCProject2.getProject(), "testMethods2.cpp", source2);
- CEditor editor= openFile(sourceFile1);
+ CEditor editor= openEditor(sourceFile1);
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
editor.selectAndReveal(source1.indexOf("method3"), 2);
@@ -212,7 +213,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
IFile sourceFile1= createFile(fCProject2.getProject(), "testMethods1.cpp", source1);
IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
- CEditor editor= openFile(sourceFile1);
+ CEditor editor= openEditor(sourceFile1);
waitForIndexer(fIndex, sourceFile1, 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 sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
- CEditor editor= openFile(sourceFile2);
+ CEditor editor= openEditor(sourceFile2);
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
editor.selectAndReveal(source2.indexOf("main"), 2);
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java
index 2076e9f3a2c..7ebf0e93798 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java
@@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
-
package org.eclipse.cdt.ui.tests.callhierarchy;
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.ui.CUIPlugin;
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.CallHierarchyUI;
@@ -46,6 +46,7 @@ public class CallHierarchyBaseTest extends BaseUITestCase {
super(name);
}
+ @Override
protected void setUp() throws Exception {
super.setUp();
CallHierarchyUI.setIsJUnitTest(true);
@@ -61,6 +62,7 @@ public class CallHierarchyBaseTest extends BaseUITestCase {
}
}
+ @Override
protected void tearDown() throws Exception {
closeAllEditors();
if (fCProject != null) {
@@ -73,9 +75,10 @@ public class CallHierarchyBaseTest extends BaseUITestCase {
return fCProject.getProject();
}
- protected CEditor openFile(IFile file) throws PartInitException {
+ protected CEditor openEditor(IFile file) throws PartInitException {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
+ EditorTestHelper.joinReconciler(EditorTestHelper.getSourceViewer(editor), 100, 500, 10);
return editor;
}
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java
index 022472194be..deac1f57f64 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java
@@ -15,14 +15,9 @@ import junit.framework.Test;
import org.eclipse.core.resources.IFile;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
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.ui.CUIPlugin;
@@ -144,13 +139,6 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
assertTrue(obj instanceof ICElement);
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 {
// public:
@@ -345,26 +333,46 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
// CALL(0);
// }
public void testMacrosHidingCall_249801() throws Exception {
+ long t= System.currentTimeMillis();
String content= getContentsForTest(1)[0].toString();
+ t= printTime("contents", t);
IFile file= createFile(getProject(), "file249801.cpp", content);
+ t= printTime("file", t);
waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
+ t= printTime("indexer", t);
final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);
- final IWorkbenchWindow workbenchWindow = ch.getSite().getWorkbenchWindow();
+ t= printTime("view", t);
// open editor, check outline
CEditor editor= openEditor(file);
+ t= printTime("editor", t);
int idx = content.indexOf("MACRO(Test");
editor.selectAndReveal(idx, 0);
openCallHierarchy(editor, false);
+ t= printTime("ch1", t);
Tree chTree= checkTreeNode(ch, 0, "PREFIX_Test(char *, char *)").getParent();
TreeItem ti= checkTreeNode(chTree, 0, 0, "call(int)");
+ t= printTime("checked", t);
idx = content.indexOf("CALL(0");
editor.selectAndReveal(idx+4, 0);
openCallHierarchy(editor, true);
+ t= printTime("ch2",t );
chTree= checkTreeNode(ch, 0, "call(int)").getParent();
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;
}
}
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java
index 9377acc4f8e..4feaa41b9ff 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java
@@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
-
package org.eclipse.cdt.ui.tests.callhierarchy;
import junit.framework.Test;
@@ -19,7 +18,6 @@ import org.eclipse.swt.widgets.Tree;
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;
@@ -64,10 +62,9 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
String source = content[1].toString();
IFile headerFile= createFile(getProject(), "testMethods.h", header);
IFile sourceFile= createFile(getProject(), "testMethods.cpp", source);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
waitForIndexer(fIndex, sourceFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
- CEditor editor= (CEditor) IDE.openEditor(page, sourceFile);
+ CEditor editor= openEditor(sourceFile);
editor.selectAndReveal(source.indexOf("method"), 2);
openCallHierarchy(editor);
Tree tree = getCHTreeViewer().getTree();
@@ -138,7 +135,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1);
IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
- CEditor editor= openFile(sourceFile1);
+ CEditor editor= openEditor(sourceFile1);
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
editor.selectAndReveal(source1.indexOf("method3"), 2);
@@ -190,7 +187,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
- CEditor editor= openFile(sourceFile1);
+ CEditor editor= openEditor(sourceFile1);
editor.selectAndReveal(source1.indexOf("method3"), 2);
openCallHierarchy(editor);
TreeViewer tv = getCHTreeViewer();
@@ -248,7 +245,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1);
IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
- CEditor editor= openFile(sourceFile2);
+ CEditor editor= openEditor(sourceFile2);
waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
editor.selectAndReveal(source2.indexOf("main"), 2);
@@ -302,8 +299,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
String cppSource = content[1].toString();
IFile cFile= createFile(getProject(), "s.c", cSource);
IFile cppFile= createFile(getProject(), "s.cpp", cppSource);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, cFile);
+ CEditor editor= openEditor(cFile);
waitForIndexer(fIndex, cppFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM);
@@ -320,7 +316,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
checkTreeNode(node, 1, null);
- editor= (CEditor) IDE.openEditor(page, cppFile);
+ editor= openEditor(cppFile);
editor.selectAndReveal(cppSource.indexOf("cppfunc"), 2);
openCallHierarchy(editor, false);
tree = getCHTreeViewer().getTree();
@@ -349,7 +345,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
IFile cFile= createFile(getProject(), "s.c", cSource);
IFile cppFile= createFile(getProject(), "s.cpp", cppSource);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, cFile);
+ CEditor editor= openEditor(cFile);
waitForIndexer(fIndex, cppFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM);
@@ -366,7 +362,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest {
checkTreeNode(node, 1, null);
- editor= (CEditor) IDE.openEditor(page, cppFile);
+ editor= openEditor(cppFile);
editor.selectAndReveal(cppSource.indexOf("cppfunc"), 2);
openCallHierarchy(editor, true);
tree = getCHTreeViewer().getTree();
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java
index ba1bf91bb9b..368f49c8b0d 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java
@@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
-
package org.eclipse.cdt.ui.tests.callhierarchy;
import junit.framework.Test;
@@ -35,7 +34,7 @@ public class InitializersInCallHierarchyTest extends CallHierarchyBaseTest {
String content = readTaggedComment("intvar");
IFile file= createFile(getProject(), "intvar.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- CEditor editor = openFile(file);
+ CEditor editor = openEditor(file);
editor.selectAndReveal(content.indexOf("a"), 1);
openCallHierarchy(editor);
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/HyperlinkTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/HyperlinkTest.java
index 419f93ce134..bd440ade4f2 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/HyperlinkTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/HyperlinkTest.java
@@ -92,8 +92,10 @@ public class HyperlinkTest extends TestCase {
assertNotNull(file);
assertTrue(file.exists());
editor = (CEditor)EditorTestHelper.openInEditor(file, true);
+ EditorTestHelper.joinReconciler(EditorTestHelper.getSourceViewer(editor), 100, 500, 10);
}
+ @Override
protected void tearDown() throws Exception {
EditorTestHelper.closeEditor(editor);
CProjectHelper.delete(project);
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java
index ff1fcd615e2..e5eae6819f6 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java
@@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM - Initial API and implementation
- * Markus Schorn (Wind River Systems)
+ * IBM - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.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.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
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.IASTNode;
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.ILanguage;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.testplugin.FileManager;
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.parser.ParserException;
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.search.actions.OpenDeclarationsAction;
@@ -74,10 +76,17 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase {
super(name);
}
+ @Override
protected void setUp() throws Exception {
super.setUp();
OpenDeclarationsAction.sIsJUnitTest= true;
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 {
@@ -192,34 +201,33 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart part = null;
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) {
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));
- final OpenDeclarationsAction action = (OpenDeclarationsAction) ((AbstractTextEditor)part).getAction("OpenDeclarations"); //$NON-NLS-1$
+ final OpenDeclarationsAction action = (OpenDeclarationsAction) editor.getAction("OpenDeclarations"); //$NON-NLS-1$
action.runSync();
// update the file/part to point to the newly opened IFile/IEditorPart
part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- IEditorInput input = part.getEditorInput();
- if (input instanceof FileEditorInput) {
- file = ((FileEditorInput)input).getFile();
- } 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
- ISelection sel = ((AbstractTextEditor)part).getSelectionProvider().getSelection();
+ assertTrue (part instanceof CEditor);
+ editor= (CEditor) part;
+ EditorTestHelper.joinReconciler(EditorTestHelper.getSourceViewer(editor), 100, 500, 10);
+
+ // 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= editor.getSelectionProvider().getSelection();
final IASTName[] result= {null};
if (sel instanceof ITextSelection) {
final ITextSelection textSel = (ITextSelection)sel;
- ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(file);
- IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_YES, monitor, new ASTRunnable() {
+ ITranslationUnit tu = (ITranslationUnit)editor.getInputCElement();
+ IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, monitor, new ASTRunnable() {
public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());
return Status.OK_STATUS;
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java
index 265a426b421..0f155a99b1b 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java
@@ -56,6 +56,7 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.FileManager;
import org.eclipse.cdt.ui.CUIPlugin;
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.model.ASTCache.ASTRunnable;
@@ -248,6 +249,7 @@ public class CPPSelectionTestsNoIndexer extends BaseUITestCase {
IEditorPart part = null;
try {
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) {
assertFalse(true);
}
@@ -266,7 +268,7 @@ public class CPPSelectionTestsNoIndexer extends BaseUITestCase {
if (sel instanceof ITextSelection) {
final ITextSelection textSel = (ITextSelection)sel;
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 {
result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());
return Status.OK_STATUS;
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java
index 5d39ccbd23d..7c073751354 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java
@@ -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.IASTNode;
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.ILanguage;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.FileManager;
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.model.ASTCache.ASTRunnable;
import org.eclipse.cdt.internal.core.parser.ParserException;
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;
/**
@@ -275,10 +276,12 @@ public class CSelectionTestsNoIndexer extends BaseUITestCase {
assertFalse(true);
}
- if (part instanceof AbstractTextEditor) {
- ((AbstractTextEditor)part).getSelectionProvider().setSelection(new TextSelection(offset,length));
+ if (part instanceof CEditor) {
+ 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();
// 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};
if (sel instanceof ITextSelection) {
final ITextSelection textSel = (ITextSelection)sel;
- ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(file);
- IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_YES, monitor, new ASTRunnable() {
+ ITranslationUnit tu = (ITranslationUnit) editor.getInputCElement();
+ IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, monitor, new ASTRunnable() {
public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());
return Status.OK_STATUS;
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CTypeHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CTypeHierarchyTest.java
index b66f28ba3a0..40befb1a427 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CTypeHierarchyTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CTypeHierarchyTest.java
@@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
-
package org.eclipse.cdt.ui.tests.typehierarchy;
import junit.framework.Test;
@@ -16,9 +15,6 @@ import junit.framework.Test;
import org.eclipse.core.resources.IFile;
import org.eclipse.swt.widgets.Tree;
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;
@@ -41,8 +37,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "enum.c", content);
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;
TreeItem item;
@@ -78,8 +73,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "enummem.c", content);
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;
TreeItem item;
@@ -115,8 +109,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "enum.cpp", content);
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;
TreeItem item;
@@ -152,8 +145,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "enummem.cpp", content);
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;
TreeItem item;
@@ -197,8 +189,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "struct.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor= openEditor(file);
editor.selectAndReveal(content.indexOf("S1"), 1);
openTypeHierarchy(editor);
@@ -252,8 +243,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "structmem.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor= openEditor(file);
editor.selectAndReveal(content.indexOf("a1"), 1);
openTypeHierarchy(editor);
@@ -287,8 +277,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "struct.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor= openEditor(file);
editor.selectAndReveal(content.indexOf("S1"), 1);
openTypeHierarchy(editor);
@@ -343,8 +332,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "structmem.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor= openEditor(file);
editor.selectAndReveal(content.indexOf("a1"), 1);
openTypeHierarchy(editor);
@@ -378,8 +366,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "union.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor= openEditor(file);
editor.selectAndReveal(content.indexOf("U1"), 1);
openTypeHierarchy(editor);
@@ -429,8 +416,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "unionmem.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor= openEditor(file);
editor.selectAndReveal(content.indexOf("a1"), 1);
openTypeHierarchy(editor);
@@ -456,8 +442,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "union.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor= openEditor(file);
editor.selectAndReveal(content.indexOf("U1"), 1);
openTypeHierarchy(editor);
@@ -516,8 +501,7 @@ public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "unionmem.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- CEditor editor= (CEditor) IDE.openEditor(page, file);
+ CEditor editor= openEditor(file);
editor.selectAndReveal(content.indexOf("a1"), 1);
openTypeHierarchy(editor);
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CppTypeHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CppTypeHierarchyTest.java
index b06550ea5d9..f5e0369a604 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CppTypeHierarchyTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CppTypeHierarchyTest.java
@@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
-
package org.eclipse.cdt.ui.tests.typehierarchy;
import junit.framework.Test;
@@ -16,9 +15,6 @@ import junit.framework.Test;
import org.eclipse.core.resources.IFile;
import org.eclipse.swt.widgets.Tree;
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;
@@ -57,8 +53,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "class.cpp", content);
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;
TreeItem item1, item2, item3, item4;
@@ -151,8 +146,7 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "classmem.cpp", content);
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;
TreeItem item1, item2, item3, item4;
@@ -245,8 +239,8 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "multi.cpp", content);
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;
TreeItem item1, item2, item3, item4;
@@ -356,8 +350,8 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "multimem.cpp", content);
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;
TreeItem item1, item2, item3, item4;
@@ -467,8 +461,8 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "diamond.cpp", content);
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;
TreeItem item1, item2, item3, item4;
@@ -578,8 +572,8 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "diamondmem.cpp", content);
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;
TreeItem item1, item2, item3, item4;
@@ -686,8 +680,8 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "viaTypedef.cpp", content);
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;
TreeItem item1, item2, item3, item4;
@@ -777,8 +771,8 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "viaTypedefmem.cpp", content);
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;
TreeItem item1, item2, item3, item4;
@@ -856,8 +850,8 @@ public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "simpleTemplate.cpp", content);
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;
TreeItem item1, item2, item3, item4;
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/QuickTypeHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/QuickTypeHierarchyTest.java
index 0d2e245429d..f4a0c3f16b1 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/QuickTypeHierarchyTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/QuickTypeHierarchyTest.java
@@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
-
package org.eclipse.cdt.ui.tests.typehierarchy;
import junit.framework.Test;
@@ -17,9 +16,6 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.widgets.Tree;
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;
@@ -58,8 +54,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "class.cpp", content);
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;
TreeItem item1, item2, item3, item4;
@@ -154,8 +150,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "classmem.cpp", content);
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;
TreeItem item1, item2, item3, item4;
@@ -251,8 +247,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "multi.cpp", content);
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;
TreeItem item1, item2, item3, item4;
@@ -362,8 +358,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "multimem.cpp", content);
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;
TreeItem item1, item2, item3, item4;
@@ -473,8 +469,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "diamond.cpp", content);
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;
TreeItem item1, item2, item3, item4;
@@ -584,8 +580,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "diamondmem.cpp", content);
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;
TreeItem item1, item2, item3, item4;
@@ -689,8 +685,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "viaTypedef.cpp", content);
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;
TreeItem item1, item2, item3, item4;
@@ -783,8 +779,8 @@ public class QuickTypeHierarchyTest extends TypeHierarchyBaseTest {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "viaTypedefmem.cpp", content);
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;
TreeItem item1, item2, item3, item4;
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java
index 9d5ab791215..1e4caa21779 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java
@@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
-
package org.eclipse.cdt.ui.tests.typehierarchy;
import junit.framework.Test;
@@ -19,9 +18,6 @@ import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.swt.widgets.Tree;
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.dom.IPDOMManager;
@@ -44,6 +40,7 @@ public class TypeHierarchyAcrossProjectsTest extends TypeHierarchyBaseTest {
return suite(TypeHierarchyAcrossProjectsTest.class);
}
+ @Override
protected void setUp() throws Exception {
super.setUp();
@@ -57,6 +54,7 @@ public class TypeHierarchyAcrossProjectsTest extends TypeHierarchyBaseTest {
TestScannerProvider.sIncludes= new String[]{fCProject.getProject().getLocation().toOSString(), fCProject2.getProject().getLocation().toOSString()};
}
+ @Override
protected void tearDown() throws Exception {
if (fCProject2 != null) {
CProjectHelper.delete(fCProject2);
@@ -92,10 +90,9 @@ public class TypeHierarchyAcrossProjectsTest extends TypeHierarchyBaseTest {
String source = content[1].toString();
IFile headerFile= createFile(fCProject.getProject(), "simpleHeader.h", header);
IFile sourceFile= createFile(fCProject2.getProject(), "simple.cpp", source);
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
waitForIndexer(fIndex, sourceFile, TypeHierarchyBaseTest.INDEXER_WAIT_TIME);
- CEditor editor= (CEditor) IDE.openEditor(page, sourceFile);
+ CEditor editor= openEditor(sourceFile);
Tree tree;
TreeItem item1, item2, item3, item4;
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java
index be5629e1ac9..281f34354a8 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java
@@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
-
package org.eclipse.cdt.ui.tests.typehierarchy;
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.ui.CUIPlugin;
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.typehierarchy.THViewPart;
@@ -52,6 +52,7 @@ public class TypeHierarchyBaseTest extends BaseUITestCase {
super(name);
}
+ @Override
protected void setUp() throws Exception {
super.setUp();
fCProject= CProjectHelper.createCCProject("__thTest__", "bin", IPDOMManager.ID_FAST_INDEXER);
@@ -59,6 +60,7 @@ public class TypeHierarchyBaseTest extends BaseUITestCase {
fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
}
+ @Override
protected void tearDown() throws Exception {
closeAllEditors();
if (fCProject != null) {
@@ -71,9 +73,10 @@ public class TypeHierarchyBaseTest extends BaseUITestCase {
return fCProject.getProject();
}
- protected CEditor openFile(IFile file) throws PartInitException {
+ protected CEditor openEditor(IFile file) throws PartInitException {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
+ EditorTestHelper.joinReconciler(EditorTestHelper.getSourceViewer(editor), 100, 500, 10);
return editor;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java
index b9fa63d660d..91bc854276c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java
@@ -188,9 +188,11 @@ public class CreateParserLogAction implements IObjectActionDelegate {
}
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 {
- return createLog(out, tu, lang, ast);
+ if (ast != null)
+ return createLog(out, tu, lang, ast);
+ return Status.CANCEL_STATUS;
}
});
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ASTProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ASTProvider.java
index fdd6fe5ebd6..61eba01c23a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ASTProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ASTProvider.java
@@ -65,17 +65,19 @@ public final class ASTProvider {
/**
* 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.
*
- * An AST will be created by this AST provider if the shared
- * AST is not for the given C element.
+ * If not yet cached and if the translation unit is open, an AST will be created by
+ * this AST provider.
*
*/
- 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
- * 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.
*
* No AST will be created by the AST provider.
*
@@ -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 true
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.
*
@@ -339,13 +330,17 @@ public final class ASTProvider {
public IStatus runOnAST(ICElement cElement, WAIT_FLAG waitFlag, IProgressMonitor monitor,
ASTCache.ASTRunnable astRunnable) {
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) {
return Status.CANCEL_STATUS;
}
if (isActive && updateModificationStamp()) {
fCache.disposeAST();
}
- return fCache.runOnAST((ITranslationUnit)cElement, waitFlag != WAIT_NO, monitor, astRunnable);
+ return fCache.runOnAST(tu, waitFlag != WAIT_NO, monitor, astRunnable);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java
index ad0b99d37c9..0315df3b486 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java
@@ -68,7 +68,7 @@ public class CElementHyperlinkDetector extends AbstractHyperlinkDetector {
}
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) {
if (ast != null) {
final int offset= region.getOffset();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting.java
index a8ebb66ede6..6a86cb25ca7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting.java
@@ -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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -9,7 +9,6 @@
* Anton Leherbauer (Wind River Systems) - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
-
package org.eclipse.cdt.internal.ui.editor;
import java.util.ArrayList;
@@ -108,7 +107,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
IStatus result = Status.OK_STATUS;
if (fTranslationUnit != null) {
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) {
reconciled(ast, true, monitor);
return Status.OK_STATUS;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java
index 3a632b5aa16..226ca4ddd41 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java
@@ -10,7 +10,6 @@
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
* Markus Schorn (Wind River Systems)
*******************************************************************************/
-
package org.eclipse.cdt.internal.ui.editor;
import java.util.ArrayList;
@@ -513,7 +512,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
final Job me= this;
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) {
reconciled(ast, true, monitor);
synchronized (fJobLock) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java
index 1db125b00ac..2beb79188d5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java
@@ -52,7 +52,7 @@ public class PDOMSearchTextSelectionQuery extends PDOMSearchQuery {
@Override
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 {
if (ast != null) {
IASTName searchName= ast.getNodeSelector(null).findEnclosingName(selection.getOffset(), selection.getLength());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java
index 714f89407e9..07eebe07fc3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java
@@ -61,7 +61,6 @@ import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.ISourceRange;
import org.eclipse.cdt.core.model.ISourceReference;
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.parser.util.ArrayUtil;
import org.eclipse.cdt.ui.CUIPlugin;
@@ -103,7 +102,7 @@ public class OpenDeclarationsAction extends SelectionParseAction implements ASTR
ITextSelection fTextSelection;
private String fSelectedText;
- private IWorkingCopy fWorkingCopy;
+ private ITranslationUnit fWorkingCopy;
private IIndex fIndex;
private IProgressMonitor fMonitor;
@@ -122,10 +121,11 @@ public class OpenDeclarationsAction extends SelectionParseAction implements ASTR
clearStatusLine();
fMonitor= monitor;
- fWorkingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput());
- if (fWorkingCopy == null)
+ ICElement celem= fEditor.getInputCElement();
+ if (!(celem instanceof ITranslationUnit))
return Status.CANCEL_STATUS;
+ fWorkingCopy= (ITranslationUnit) celem;
fIndex= CCorePlugin.getIndexManager().getIndex(fWorkingCopy.getCProject(),
IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
@@ -136,7 +136,7 @@ public class OpenDeclarationsAction extends SelectionParseAction implements ASTR
}
try {
- return ASTProvider.getASTProvider().runOnAST(fWorkingCopy, ASTProvider.WAIT_YES, monitor, this);
+ return ASTProvider.getASTProvider().runOnAST(fWorkingCopy, ASTProvider.WAIT_ACTIVE_ONLY, monitor, this);
} finally {
fIndex.releaseReadLock();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java
index 97acfd03173..85672841837 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java
@@ -9,7 +9,6 @@
* IBM Corporation - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
-
package org.eclipse.cdt.internal.ui.text.correction;
import java.util.ArrayList;
@@ -120,7 +119,7 @@ public class CorrectionCommandHandler extends AbstractHandler {
private ICompletionProposal getLocalRenameProposal(final IInvocationContext context) {
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() {
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java
index 512e1422554..5702a0d37a7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java
@@ -170,7 +170,7 @@ public class QuickAssistLightBulbUpdater {
if (workingCopy != null) {
installSelectionListener();
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) {
if (astRoot != null) {
doSelectionChanged(point.x, point.y, astRoot);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedNamesAssistProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedNamesAssistProposal.java
index ff8cc009073..50a3146f072 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedNamesAssistProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedNamesAssistProposal.java
@@ -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
* are made available under the terms of the Eclipse Public License v1.0
* 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.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.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.StyledString;
-
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DocumentEvent;
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.LinkedModeUI.ExitFlags;
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.texteditor.link.EditorLinkedModeUI;
@@ -136,10 +134,13 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
final int secectionOffset = selection.x;
final int selectionLength = selection.y;
- ASTProvider.getASTProvider().runOnAST(fTranslationUnit, ASTProvider.WAIT_YES,
+ ASTProvider.getASTProvider().runOnAST(fTranslationUnit, ASTProvider.WAIT_ACTIVE_ONLY,
new NullProgressMonitor(), new ASTRunnable() {
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
+ if (astRoot == null)
+ return Status.CANCEL_STATUS;
+
IASTNodeSelector selector= astRoot.getNodeSelector(null);
IASTName name= selector.findEnclosingName(secectionOffset, selectionLength);
if (name != null) {
@@ -249,7 +250,7 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
public String getDisplayString() {
String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
if (shortCutString != null) {
- return CorrectionMessages.bind(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
+ return NLS.bind(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
fLabel, shortCutString);
}
return fLabel;
@@ -263,7 +264,7 @@ public class LinkedNamesAssistProposal implements ICCompletionProposal, IComplet
String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
if (shortCutString != null) {
- String decorated= CorrectionMessages.bind(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
+ String decorated= NLS.bind(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
fLabel, shortCutString);
return ColoringLabelProvider.decorateStyledString(str, decorated, StyledString.QUALIFIER_STYLER);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java
index d88e4d0e52f..821e715ec93 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java
@@ -393,7 +393,7 @@ public class IndexUI {
return 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) {
if (ast != null) {
final IASTNodeSelector nodeSelector = ast.getNodeSelector(null);