Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 117194 Details for
Bug 253690
[scalability] Parser needs a lot of memory parsing large initializer expressions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
the fix
253690.txt (text/plain), 139.73 KB, created by
Markus Schorn
on 2008-11-06 08:49:55 EST
(
hide
)
Description:
the fix
Filename:
MIME Type:
Creator:
Markus Schorn
Created:
2008-11-06 08:49:55 EST
Size:
139.73 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.cdt.ui >Index: src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java,v >retrieving revision 1.15 >diff -u -r1.15 CElementHyperlinkDetector.java >--- src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java 31 Mar 2008 07:53:16 -0000 1.15 >+++ src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java 6 Nov 2008 13:39:24 -0000 >@@ -68,7 +68,7 @@ > } > > 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(); >Index: src/org/eclipse/cdt/internal/ui/editor/ASTProvider.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ASTProvider.java,v >retrieving revision 1.15 >diff -u -r1.15 ASTProvider.java >--- src/org/eclipse/cdt/internal/ui/editor/ASTProvider.java 2 Oct 2008 10:57:09 -0000 1.15 >+++ src/org/eclipse/cdt/internal/ui/editor/ASTProvider.java 6 Nov 2008 13:39:24 -0000 >@@ -65,17 +65,19 @@ > > /** > * Wait flag indicating that a client requesting an AST >- * wants to wait until an AST is ready. >+ * wants to wait until an AST is ready. If the translation unit is not open no ast will >+ * be provided. > * <p> >- * 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. > * </p> > */ >- public static final WAIT_FLAG WAIT_YES= new WAIT_FLAG("wait yes"); //$NON-NLS-1$ >+ public static final WAIT_FLAG WAIT_IF_OPEN= new WAIT_FLAG("wait if open"); //$NON-NLS-1$ > > /** > * Wait flag indicating that a client requesting an AST >- * only wants to wait for the shared AST of the active editor. >+ * only wants to wait for the shared AST of the active editor. >+ * If the translation unit is not open no ast will be provided. > * <p> > * No AST will be created by the AST provider. > * </p> >@@ -262,17 +264,6 @@ > } > > /** >- * Returns whether this AST provider is active on the given >- * translation unit. >- * >- * @param tu the translation unit >- * @return <code>true</code> if the given translation unit is the active one >- */ >- public boolean isActive(ITranslationUnit tu) { >- return fCache.isActiveElement(tu) && tu.isOpen(); >- } >- >- /** > * Informs that reconciling for the given element is about to be started. > * > * @param cElement the C element >@@ -339,13 +330,17 @@ > 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); > } > } >Index: src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java,v >retrieving revision 1.26 >diff -u -r1.26 SemanticHighlightingReconciler.java >--- src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java 5 Nov 2008 10:26:57 -0000 1.26 >+++ src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java 6 Nov 2008 13:39:24 -0000 >@@ -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 @@ > > 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) { >Index: src/org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting.java,v >retrieving revision 1.16 >diff -u -r1.16 InactiveCodeHighlighting.java >--- src/org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting.java 11 Apr 2008 09:26:58 -0000 1.16 >+++ src/org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting.java 6 Nov 2008 13:39:24 -0000 >@@ -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 @@ > 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; >Index: src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java,v >retrieving revision 1.6 >diff -u -r1.6 CorrectionCommandHandler.java >--- src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java 12 Aug 2008 03:39:53 -0000 1.6 >+++ src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java 6 Nov 2008 13:39:24 -0000 >@@ -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 @@ > 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 { >Index: src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java,v >retrieving revision 1.4 >diff -u -r1.4 QuickAssistLightBulbUpdater.java >--- src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java 12 Aug 2008 03:39:53 -0000 1.4 >+++ src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java 6 Nov 2008 13:39:24 -0000 >@@ -170,7 +170,7 @@ > 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); >Index: src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java,v >retrieving revision 1.16 >diff -u -r1.16 PDOMSearchTextSelectionQuery.java >--- src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java 29 Apr 2008 08:43:08 -0000 1.16 >+++ src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java 6 Nov 2008 13:39:24 -0000 >@@ -52,7 +52,7 @@ > > @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()); >Index: src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedNamesAssistProposal.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedNamesAssistProposal.java,v >retrieving revision 1.2 >diff -u -r1.2 LinkedNamesAssistProposal.java >--- src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedNamesAssistProposal.java 22 Sep 2008 03:58:58 -0000 1.2 >+++ src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedNamesAssistProposal.java 6 Nov 2008 13:39:25 -0000 >@@ -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 @@ > 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.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 @@ > 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 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 @@ > > 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); > } >Index: src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java,v >retrieving revision 1.27 >diff -u -r1.27 IndexUI.java >--- src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java 7 Oct 2008 12:49:21 -0000 1.27 >+++ src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java 6 Nov 2008 13:39:25 -0000 >@@ -393,7 +393,7 @@ > 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); >Index: src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java,v >retrieving revision 1.6 >diff -u -r1.6 CreateParserLogAction.java >--- src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java 30 Jul 2008 07:38:12 -0000 1.6 >+++ src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java 6 Nov 2008 13:39:24 -0000 >@@ -188,9 +188,11 @@ > } > > 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; > } > }); > } >Index: src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java,v >retrieving revision 1.76 >diff -u -r1.76 OpenDeclarationsAction.java >--- src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java 29 Oct 2008 10:17:24 -0000 1.76 >+++ src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java 6 Nov 2008 13:39:24 -0000 >@@ -61,7 +61,6 @@ > 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 @@ > > ITextSelection fTextSelection; > private String fSelectedText; >- private IWorkingCopy fWorkingCopy; >+ private ITranslationUnit fWorkingCopy; > private IIndex fIndex; > private IProgressMonitor fMonitor; > >@@ -122,10 +121,11 @@ > 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 @@ > } > > 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(); > } >#P org.eclipse.cdt.ui.tests >Index: ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java,v >retrieving revision 1.22 >diff -u -r1.22 BasicCallHierarchyTest.java >--- ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java 16 Apr 2008 16:32:50 -0000 1.22 >+++ ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java 6 Nov 2008 13:39:26 -0000 >@@ -17,10 +17,7 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > > 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 @@ > 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 @@ > > 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 @@ > 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 @@ > 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); >Index: ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java,v >retrieving revision 1.8 >diff -u -r1.8 CppCallHierarchyTest.java >--- ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java 31 Jul 2008 15:05:49 -0000 1.8 >+++ ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java 6 Nov 2008 13:39:26 -0000 >@@ -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.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 @@ > 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 @@ > 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 @@ > > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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(); >Index: ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java,v >retrieving revision 1.9 >diff -u -r1.9 CallHierarchyAcrossProjectsTest.java >--- ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java 27 Feb 2008 10:48:52 -0000 1.9 >+++ ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java 6 Nov 2008 13:39:26 -0000 >@@ -18,7 +18,6 @@ > 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 @@ > return suite(CallHierarchyAcrossProjectsTest.class); > } > >+ @Override > protected void setUp() throws Exception { > super.setUp(); > >@@ -51,6 +51,7 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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); >Index: ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java,v >retrieving revision 1.28 >diff -u -r1.28 CallHierarchyBaseTest.java >--- ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java 12 Nov 2007 17:12:25 -0000 1.28 >+++ ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java 6 Nov 2008 13:39:26 -0000 >@@ -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.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 @@ > super(name); > } > >+ @Override > protected void setUp() throws Exception { > super.setUp(); > CallHierarchyUI.setIsJUnitTest(true); >@@ -61,6 +62,7 @@ > } > } > >+ @Override > protected void tearDown() throws Exception { > closeAllEditors(); > if (fCProject != null) { >@@ -73,9 +75,10 @@ > 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; > } > >Index: ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java,v >retrieving revision 1.5 >diff -u -r1.5 InitializersInCallHierarchyTest.java >--- ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java 6 Mar 2008 13:27:49 -0000 1.5 >+++ ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java 6 Nov 2008 13:39:26 -0000 >@@ -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 @@ > 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); >Index: ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java,v >retrieving revision 1.12 >diff -u -r1.12 CallHierarchyBugs.java >--- ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java 7 Oct 2008 12:49:25 -0000 1.12 >+++ ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java 6 Nov 2008 13:39:26 -0000 >@@ -15,14 +15,9 @@ > 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 @@ > 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 @@ > // 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; > } > } >Index: ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java,v >retrieving revision 1.9 >diff -u -r1.9 BasicCppCallHierarchyTest.java >--- ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java 13 Dec 2006 15:29:04 -0000 1.9 >+++ ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java 6 Nov 2008 13:39:26 -0000 >@@ -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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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); >Index: ui/org/eclipse/cdt/ui/tests/typehierarchy/CppTypeHierarchyTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CppTypeHierarchyTest.java,v >retrieving revision 1.3 >diff -u -r1.3 CppTypeHierarchyTest.java >--- ui/org/eclipse/cdt/ui/tests/typehierarchy/CppTypeHierarchyTest.java 31 Jan 2007 14:50:11 -0000 1.3 >+++ ui/org/eclipse/cdt/ui/tests/typehierarchy/CppTypeHierarchyTest.java 6 Nov 2008 13:39:27 -0000 >@@ -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 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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; > >Index: ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java,v >retrieving revision 1.11 >diff -u -r1.11 TypeHierarchyBaseTest.java >--- ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java 14 Jun 2007 09:45:42 -0000 1.11 >+++ ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java 6 Nov 2008 13:39:27 -0000 >@@ -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.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 @@ > super(name); > } > >+ @Override > protected void setUp() throws Exception { > super.setUp(); > fCProject= CProjectHelper.createCCProject("__thTest__", "bin", IPDOMManager.ID_FAST_INDEXER); >@@ -59,6 +60,7 @@ > fIndex= CCorePlugin.getIndexManager().getIndex(fCProject); > } > >+ @Override > protected void tearDown() throws Exception { > closeAllEditors(); > if (fCProject != null) { >@@ -71,9 +73,10 @@ > 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; > } > >Index: ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java,v >retrieving revision 1.5 >diff -u -r1.5 TypeHierarchyAcrossProjectsTest.java >--- ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java 19 Feb 2008 12:22:05 -0000 1.5 >+++ ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java 6 Nov 2008 13:39:27 -0000 >@@ -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.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 @@ > return suite(TypeHierarchyAcrossProjectsTest.class); > } > >+ @Override > protected void setUp() throws Exception { > super.setUp(); > >@@ -57,6 +54,7 @@ > 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 @@ > 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; > >Index: ui/org/eclipse/cdt/ui/tests/typehierarchy/CTypeHierarchyTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/CTypeHierarchyTest.java,v >retrieving revision 1.5 >diff -u -r1.5 CTypeHierarchyTest.java >--- ui/org/eclipse/cdt/ui/tests/typehierarchy/CTypeHierarchyTest.java 14 Apr 2007 11:15:55 -0000 1.5 >+++ ui/org/eclipse/cdt/ui/tests/typehierarchy/CTypeHierarchyTest.java 6 Nov 2008 13:39:27 -0000 >@@ -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 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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); >Index: ui/org/eclipse/cdt/ui/tests/typehierarchy/QuickTypeHierarchyTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/QuickTypeHierarchyTest.java,v >retrieving revision 1.2 >diff -u -r1.2 QuickTypeHierarchyTest.java >--- ui/org/eclipse/cdt/ui/tests/typehierarchy/QuickTypeHierarchyTest.java 14 Jun 2007 09:45:42 -0000 1.2 >+++ ui/org/eclipse/cdt/ui/tests/typehierarchy/QuickTypeHierarchyTest.java 6 Nov 2008 13:39:27 -0000 >@@ -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.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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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 @@ > 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; > >Index: ui/org/eclipse/cdt/ui/tests/text/HyperlinkTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/HyperlinkTest.java,v >retrieving revision 1.4 >diff -u -r1.4 HyperlinkTest.java >--- ui/org/eclipse/cdt/ui/tests/text/HyperlinkTest.java 14 May 2008 19:27:35 -0000 1.4 >+++ ui/org/eclipse/cdt/ui/tests/text/HyperlinkTest.java 6 Nov 2008 13:39:26 -0000 >@@ -92,8 +92,10 @@ > 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); >Index: ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java,v >retrieving revision 1.11 >diff -u -r1.11 BaseSelectionTestsIndexer.java >--- ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java 6 Mar 2008 09:57:22 -0000 1.11 >+++ ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java 6 Nov 2008 13:39:26 -0000 >@@ -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.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.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 @@ > 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 @@ > 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; >Index: ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java,v >retrieving revision 1.17 >diff -u -r1.17 CPPSelectionTestsNoIndexer.java >--- ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java 29 Oct 2008 10:17:19 -0000 1.17 >+++ ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java 6 Nov 2008 13:39:26 -0000 >@@ -56,6 +56,7 @@ > 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 @@ > 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 @@ > 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; >Index: ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java,v >retrieving revision 1.13 >diff -u -r1.13 CSelectionTestsNoIndexer.java >--- ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java 18 Jun 2008 12:16:12 -0000 1.13 >+++ ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java 6 Nov 2008 13:39:27 -0000 >@@ -44,19 +44,20 @@ > 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 @@ > 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 @@ > 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; >#P org.eclipse.cdt.core.tests >Index: parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java,v >retrieving revision 1.16 >diff -u -r1.16 AST2SpecBaseTest.java >--- parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java 30 Jun 2008 13:06:07 -0000 1.16 >+++ parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java 6 Nov 2008 13:39:29 -0000 >@@ -100,7 +100,7 @@ > private IASTTranslationUnit parse(CodeReader codeReader, ParserLanguage lang, boolean useGNUExtensions, > boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings, String[] problems) throws ParserException { > ScannerInfo scannerInfo = new ScannerInfo(); >- IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo, false); >+ IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); > > ISourceCodeParser parser2 = null; > if( lang == ParserLanguage.CPP ) >Index: parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java,v >retrieving revision 1.196 >diff -u -r1.196 AST2Tests.java >--- parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java 3 Nov 2008 10:12:13 -0000 1.196 >+++ parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java 6 Nov 2008 13:39:30 -0000 >@@ -5500,4 +5500,35 @@ > parseAndCheckBindings(code, lang); > } > } >+ >+ // int a[]= { >+ >+ // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, >+ >+ // }; >+ public void testScalabilityOfLargeTrivialInitializer_Bug252970() throws Exception { >+ final StringBuffer[] input = getContents(3); >+ StringBuilder buf= new StringBuilder(); >+ buf.append(input[0].toString()); >+ final String line= input[1].toString(); >+ for (int i = 0; i < 25000; i++) { // 250K values >+ buf.append(line); >+ } >+ buf.append(input[2].toString()); >+ final String code= buf.toString(); >+ long mem= memoryUsed(); >+ for (ParserLanguage lang : ParserLanguage.values()) { >+ IASTTranslationUnit tu= parse(code, lang, false, true, true); >+ long diff= memoryUsed()-mem; >+ final int expected = 1024*10 + code.length()*2; // a copy of the buffer + some >+ assertTrue(String.valueOf(diff) + " expected < " + expected, diff < expected); >+ } >+ } >+ >+ private long memoryUsed() { >+ System.gc();System.gc();System.gc(); >+ final Runtime runtime = Runtime.getRuntime(); >+ return runtime.totalMemory()-runtime.freeMemory(); >+ } >+ > } >Index: parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java,v >retrieving revision 1.59 >diff -u -r1.59 AST2BaseTest.java >--- parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java 26 Oct 2008 21:14:41 -0000 1.59 >+++ parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java 6 Nov 2008 13:39:29 -0000 >@@ -54,7 +54,6 @@ > import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification; > import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; > import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration; >-import org.eclipse.cdt.core.dom.parser.ISourceCodeParser; > import org.eclipse.cdt.core.dom.parser.c.ANSICParserExtensionConfiguration; > import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration; > import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration; >@@ -75,6 +74,7 @@ > import org.eclipse.cdt.core.testplugin.CTestPlugin; > import org.eclipse.cdt.core.testplugin.util.BaseTestCase; > import org.eclipse.cdt.core.testplugin.util.TestSourceReader; >+import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser; > import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; > import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; > import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser; >@@ -116,17 +116,17 @@ > } > > protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions, >- boolean expectNoProblems, boolean parseComments) throws ParserException { >+ boolean expectNoProblems, boolean skipTrivialInitializers) throws ParserException { > IScanner scanner = createScanner(new CodeReader(code.toCharArray()), lang, ParserMode.COMPLETE_PARSE, >- new ScannerInfo(), parseComments); >- ISourceCodeParser parser2 = null; >+ new ScannerInfo()); >+ AbstractGNUSourceCodeParser parser = null; > if (lang == ParserLanguage.CPP) { > ICPPParserExtensionConfiguration config = null; > if (useGNUExtensions) > config = new GPPParserExtensionConfiguration(); > else > config = new ANSICPPParserExtensionConfiguration(); >- parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG,config, null); >+ parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG,config, null); > } else { > ICParserExtensionConfiguration config = null; > >@@ -135,12 +135,14 @@ > else > config = new ANSICParserExtensionConfiguration(); > >- parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null); >+ parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null); > } >+ if (skipTrivialInitializers) >+ parser.setSkipTrivialExpressionsInAggregateInitializers(true); > >- IASTTranslationUnit tu = parser2.parse(); >+ IASTTranslationUnit tu = parser.parse(); > >- if (parser2.encounteredError() && expectNoProblems) >+ if (parser.encounteredError() && expectNoProblems) > throw new ParserException("FAILURE"); //$NON-NLS-1$ > > if (lang == ParserLanguage.C && expectNoProblems) { >@@ -157,7 +159,7 @@ > } > > public static IScanner createScanner(CodeReader codeReader, ParserLanguage lang, ParserMode mode, >- IScannerInfo scannerInfo, boolean parseComments) { >+ IScannerInfo scannerInfo) { > IScannerExtensionConfiguration configuration = null; > if (lang == ParserLanguage.C) > configuration= GCCScannerExtensionConfiguration.getInstance(); >Index: parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java,v >retrieving revision 1.14 >diff -u -r1.14 QuickParser2Tests.java >--- parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java 24 Jun 2008 12:50:43 -0000 1.14 >+++ parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java 6 Nov 2008 13:39:31 -0000 >@@ -1355,7 +1355,7 @@ > > CodeReader codeReader = new CodeReader( code.toCharArray() ); > IScannerInfo scannerInfo = new ScannerInfo(); >- IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo, false); >+ IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); > ISourceCodeParser parser2 = null; > if (lang == ParserLanguage.CPP) { > ICPPParserExtensionConfiguration config = null; >Index: parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java,v >retrieving revision 1.4 >diff -u -r1.4 ASTNodeSelectorTest.java >--- parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java 7 Oct 2008 12:49:24 -0000 1.4 >+++ parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java 6 Nov 2008 13:39:30 -0000 >@@ -55,7 +55,7 @@ > fCode= getContents(1)[0].toString(); > CodeReader codeReader = new CodeReader(fCode.toCharArray()); > ScannerInfo scannerInfo = new ScannerInfo(); >- IScanner scanner= AST2BaseTest.createScanner(codeReader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, scannerInfo, false); >+ IScanner scanner= AST2BaseTest.createScanner(codeReader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, scannerInfo); > GNUCPPSourceParser parser= new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, new NullLogService(), new GPPParserExtensionConfiguration()); > fTu= parser.parse(); > fSelector= fTu.getNodeSelector(null); >Index: parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseBaseTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseBaseTest.java,v >retrieving revision 1.8 >diff -u -r1.8 AST2SelectionParseBaseTest.java >--- parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseBaseTest.java 27 Mar 2008 18:31:16 -0000 1.8 >+++ parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseBaseTest.java 6 Nov 2008 13:39:29 -0000 >@@ -83,7 +83,7 @@ > CodeReader codeReader = new CodeReader(code > .toCharArray()); > ScannerInfo scannerInfo = new ScannerInfo(); >- IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo, false); >+ IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); > > ISourceCodeParser parser2 = null; > if( lang == ParserLanguage.CPP ) >Index: parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java,v >retrieving revision 1.38 >diff -u -r1.38 CompleteParser2Tests.java >--- parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java 26 Jun 2008 10:06:46 -0000 1.38 >+++ parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java 6 Nov 2008 13:39:30 -0000 >@@ -180,7 +180,7 @@ > .toCharArray()); > ScannerInfo scannerInfo = new ScannerInfo(); > ISourceCodeParser parser2 = null; >- IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo, false); >+ IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); > if (lang == ParserLanguage.CPP) { > ICPPParserExtensionConfiguration config = null; > if (gcc) >Index: parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java,v >retrieving revision 1.1 >diff -u -r1.1 ASTWriterTest.java >--- parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java 7 Mar 2008 12:13:35 -0000 1.1 >+++ parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java 6 Nov 2008 13:39:31 -0000 >@@ -95,7 +95,7 @@ > ParserLanguage language = getLanguage(testFile); > boolean useGNUExtensions = getGNUExtension(testFile); > >- IScanner scanner = AST2BaseTest.createScanner(codeReader, language, ParserMode.COMPLETE_PARSE, scannerInfo, true); >+ IScanner scanner = AST2BaseTest.createScanner(codeReader, language, ParserMode.COMPLETE_PARSE, scannerInfo); > > ISourceCodeParser parser2 = null; > if( language == ParserLanguage.CPP ) { >Index: parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java,v >retrieving revision 1.6 >diff -u -r1.6 CompletionTestBase.java >--- parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java 6 Nov 2007 16:41:44 -0000 1.6 >+++ parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java 6 Nov 2008 13:39:31 -0000 >@@ -43,7 +43,7 @@ > protected IASTCompletionNode getCompletionNode(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException { > CodeReader codeReader = new CodeReader(code.toCharArray()); > ScannerInfo scannerInfo = new ScannerInfo(); >- IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo, false); >+ IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo); > > ISourceCodeParser parser = null; > if( lang == ParserLanguage.CPP ) >Index: parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java,v >retrieving revision 1.64 >diff -u -r1.64 IndexBugsTests.java >--- parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java 30 Oct 2008 11:07:19 -0000 1.64 >+++ parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java 6 Nov 2008 13:39:31 -0000 >@@ -1370,7 +1370,8 @@ > TestSourceReader.createFile(fCProject.getProject(), "f1/g/h/header.h", "#define ID three\n"); > TestSourceReader.createFile(fCProject.getProject(), "f1/g/source.cpp", contents + "int CONCAT(one, ID);\n"); > TestSourceReader.createFile(fCProject.getProject(), "f2/g/source.cpp", contents + "int CONCAT(two, ID);\n"); >- TestSourceReader.createFile(fCProject.getProject(), "f1/g/h/source.cpp", contents + "int CONCAT(three, ID);\n"); >+ IFile f= TestSourceReader.createFile(fCProject.getProject(), "f1/g/h/source.cpp", contents + "int CONCAT(three, ID);\n"); >+ waitUntilFileIsIndexed(f, 4000); > indexManager.reindex(fCProject); > waitForIndexer(); > fIndex.acquireReadLock(); >#P org.eclipse.cdt.core >Index: model/org/eclipse/cdt/internal/core/model/TranslationUnit.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java,v >retrieving revision 1.95 >diff -u -r1.95 TranslationUnit.java >--- model/org/eclipse/cdt/internal/core/model/TranslationUnit.java 16 Oct 2008 19:50:31 -0000 1.95 >+++ model/org/eclipse/cdt/internal/core/model/TranslationUnit.java 6 Nov 2008 13:39:32 -0000 >@@ -822,6 +822,9 @@ > if ((style & AST_CREATE_COMMENT_NODES) != 0) { > options |= ILanguage.OPTION_ADD_COMMENTS; > } >+ if ((style & AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS) != 0) { >+ options |= ILanguage.OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS; >+ } > if (isSourceUnit()) { > options |= ILanguage.OPTION_IS_SOURCE_UNIT; > } >Index: model/org/eclipse/cdt/internal/core/model/ASTCache.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java,v >retrieving revision 1.11 >diff -u -r1.11 ASTCache.java >--- model/org/eclipse/cdt/internal/core/model/ASTCache.java 24 Apr 2008 16:09:34 -0000 1.11 >+++ model/org/eclipse/cdt/internal/core/model/ASTCache.java 6 Nov 2008 13:39:32 -0000 >@@ -40,7 +40,8 @@ > /** Full parse mode (no PDOM) */ > public static int PARSE_MODE_FULL= ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT; > /** Fast parse mode (use PDOM) */ >- public static int PARSE_MODE_FAST= ITranslationUnit.AST_SKIP_ALL_HEADERS | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT; >+ public static int PARSE_MODE_FAST= ITranslationUnit.AST_SKIP_ALL_HEADERS | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT >+ | ITranslationUnit.AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS; > > /** > * Do something with an AST. >Index: model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java,v >retrieving revision 1.39 >diff -u -r1.39 CModelBuilder2.java >--- model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java 19 Jun 2008 14:54:15 -0000 1.39 >+++ model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java 6 Nov 2008 13:39:32 -0000 >@@ -135,7 +135,7 @@ > else { > parseFlags |= ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT; > } >- >+ parseFlags |= ITranslationUnit.AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS; > final IASTTranslationUnit ast; > try { > ast= fTranslationUnit.getAST(index, parseFlags, fProgressMonitor); >Index: parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java,v >retrieving revision 1.117 >diff -u -r1.117 AbstractGNUSourceCodeParser.java >--- parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java 3 Nov 2008 10:12:16 -0000 1.117 >+++ parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java 6 Nov 2008 13:39:33 -0000 >@@ -6,7 +6,7 @@ > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: >- * IBM Rational Software - Initial API and implementation >+ * John Camelon (IBM Rational Software) - Initial API and implementation > * Markus Schorn (Wind River Systems) > * Ed Swartz (Nokia) > * Mike Kucera (IBM) - bug #206952 >@@ -81,10 +81,52 @@ > import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver; > > /** >- * @author jcamelon >+ * Base class for the c- and c++ parser. > */ > public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { >- protected static final int DEFAULT_DESIGNATOR_LIST_SIZE = 4; >+ protected static class FoundAggregateInitializer extends Exception { >+ public final IASTDeclarator fDeclarator; >+ public IASTDeclSpecifier fDeclSpec; >+ public FoundAggregateInitializer(IASTDeclarator d) { >+ fDeclarator= d; >+ } >+ } >+ protected static class FoundDeclaratorException extends Exception { >+ private static final long serialVersionUID = 0; >+ >+ public IASTDeclSpecifier declSpec; >+ public IASTDeclarator declarator; >+ >+ public IASTDeclSpecifier altSpec; >+ public IASTDeclarator altDeclarator; >+ >+ public IToken currToken; >+ >+ public FoundDeclaratorException(IASTDeclarator d, IToken t) { >+ this.declarator = d; >+ this.currToken =t; >+ } >+ } >+ >+ protected static class NameChecker extends ASTVisitor { >+ private boolean fFound; >+ protected NameChecker() { >+ shouldVisitNames= true; >+ } >+ @Override >+ public int visit(IASTName name) { >+ fFound= true; >+ return PROCESS_ABORT; >+ } >+ public boolean containsName(IASTNode node) { >+ fFound= false; >+ node.accept(this); >+ return fFound; >+ } >+ } >+ protected NameChecker NAME_CHECKER= new NameChecker(); >+ >+ protected static final int DEFAULT_DESIGNATOR_LIST_SIZE = 4; > protected static int parseCount = 0; > > protected final AbstractParserLogService log; >@@ -103,6 +145,8 @@ > protected final IBuiltinBindingsProvider builtinBindingsProvider; > > protected boolean functionCallCanBeLValue= false; >+ protected boolean skipTrivialExpressionsInAggregateInitializers= false; >+ > > /** > * Marks the beginning of the current declaration. It is important to clear the mark whenever we >@@ -141,6 +185,14 @@ > this.builtinBindingsProvider= builtinBindingsProvider; > } > >+ /** >+ * Instructs the parser not to create ast nodes for expressions within aggregate initializers >+ * when they do not contain names. >+ */ >+ public void setSkipTrivialExpressionsInAggregateInitializers(boolean val) { >+ skipTrivialExpressionsInAggregateInitializers= val; >+ } >+ > private AbstractParserLogService wrapLogService(IParserLogService logService) { > if (logService instanceof AbstractParserLogService) { > return (AbstractParserLogService) logService; >@@ -1225,13 +1277,17 @@ > return compoundStatement(); > } > >- protected abstract IASTDeclarator initDeclarator(DeclarationOptions option) throws EndOfFileException, BacktrackException; >+ protected abstract IASTDeclarator initDeclarator(DeclarationOptions option) >+ throws EndOfFileException, BacktrackException, FoundAggregateInitializer; > > /** > * @param option the options with which to parse the declaration > * @throws FoundDeclaratorException encountered EOF while looking ahead >+ * @throws FoundAggregateInitializer found aggregate initializer, needs special treatment >+ * because of scalability. > */ >- protected void lookAheadForDeclarator(final DeclarationOptions option) throws FoundDeclaratorException { >+ protected void lookAheadForDeclarator(final DeclarationOptions option) >+ throws FoundDeclaratorException, FoundAggregateInitializer { > IToken mark = null; > try { > mark = mark(); >@@ -1251,23 +1307,6 @@ > } > > protected abstract boolean verifyLookaheadDeclarator(DeclarationOptions option, IASTDeclarator d, IToken nextToken); >- >- public static class FoundDeclaratorException extends Exception { >- private static final long serialVersionUID = 0; >- >- public IASTDeclSpecifier declSpec; >- public IASTDeclarator declarator; >- >- public IASTDeclSpecifier altSpec; >- public IASTDeclarator altDeclarator; >- >- public IToken currToken; >- >- public FoundDeclaratorException(IASTDeclarator d, IToken t) { >- this.declarator = d; >- this.currToken =t; >- } >- } > > /** > * Parse an enumeration specifier, as according to the ANSI specs in C & >@@ -1439,7 +1478,7 @@ > protected abstract IASTCaseStatement createCaseStatement(); > > protected abstract IASTDeclaration declaration(DeclarationOptions option) throws BacktrackException, EndOfFileException; >- protected abstract IASTDeclSpecifier declSpecifierSeq(DeclarationOptions option) throws BacktrackException, EndOfFileException, FoundDeclaratorException; >+ protected abstract IASTDeclSpecifier declSpecifierSeq(DeclarationOptions option) throws BacktrackException, EndOfFileException, FoundDeclaratorException, FoundAggregateInitializer; > > protected IASTDeclaration[] problemDeclaration(int offset, BacktrackException bt, DeclarationOptions option) { > failParse(); >@@ -1523,7 +1562,7 @@ > protected IASTDeclaration functionStyleAsmDeclaration() throws BacktrackException, EndOfFileException { > > final int offset= LA(1).getOffset(); >- IASTDeclSpecifier declSpec; >+ IASTDeclSpecifier declSpec= null; > IASTDeclarator dtor; > try { > declSpec = declSpecifierSeq(DeclarationOptions.FUNCTION_STYLE_ASM); >@@ -1537,6 +1576,10 @@ > dtor= e.declarator; > } > backup( e.currToken ); >+ } catch (FoundAggregateInitializer lie) { >+ if (declSpec == null) >+ declSpec= lie.fDeclSpec; >+ dtor= addInitializer(lie); > } > > if (LT(1) != IToken.tLBRACE) >@@ -1561,6 +1604,8 @@ > return funcDefinition; > } > >+ protected abstract IASTDeclarator addInitializer(FoundAggregateInitializer lie) throws EndOfFileException; >+ > protected IToken asmExpression(StringBuilder content) throws EndOfFileException, BacktrackException { > IToken t= consume(IToken.tLPAREN); > boolean needspace= false; >Index: parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java,v >retrieving revision 1.7 >diff -u -r1.7 AbstractCLikeLanguage.java >--- parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java 30 Apr 2008 15:16:41 -0000 1.7 >+++ parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java 6 Nov 2008 13:39:33 -0000 >@@ -38,6 +38,7 @@ > import org.eclipse.cdt.core.parser.ParserLanguage; > import org.eclipse.cdt.core.parser.ParserMode; > import org.eclipse.cdt.core.parser.util.CharArrayIntMap; >+import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser; > import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor; > import org.eclipse.cdt.internal.core.parser.token.KeywordSets; > import org.eclipse.cdt.internal.core.util.ICancelable; >@@ -181,7 +182,13 @@ > else > mode= ParserMode.COMPLETE_PARSE; > >- return createParser(scanner, mode, log, index); >+ ISourceCodeParser parser= createParser(scanner, mode, log, index); >+ if ((options & OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS) != 0) { >+ if (parser instanceof AbstractGNUSourceCodeParser) { >+ ((AbstractGNUSourceCodeParser) parser).setSkipTrivialExpressionsInAggregateInitializers(true); >+ } >+ } >+ return parser; > } > > >Index: model/org/eclipse/cdt/core/model/ITranslationUnit.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java,v >retrieving revision 1.27 >diff -u -r1.27 ITranslationUnit.java >--- model/org/eclipse/cdt/core/model/ITranslationUnit.java 16 Apr 2008 08:27:25 -0000 1.27 >+++ model/org/eclipse/cdt/core/model/ITranslationUnit.java 6 Nov 2008 13:39:32 -0000 >@@ -30,6 +30,8 @@ > * If a <code>.c</code> file cannot be parsed, its structure remains unknown. > * Use <code>ICElement.isStructureKnown</code> to determine whether this is > * the case. >+ * >+ * @noimplement This interface is not intended to be implemented by clients. > */ > public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISourceReference, ISourceManipulation { > >@@ -38,21 +40,21 @@ > * Meaning: Skip function and method bodies. > * @since 4.0 > */ >- public static final int AST_SKIP_FUNCTION_BODIES= 1; >+ public static final int AST_SKIP_FUNCTION_BODIES= 0x1; > > /** > * Style constant for {@link #getAST(IIndex, int)}. > * Meaning: Skip over headers that are found in the index, parse all others. > * Macro definitions and bindings are taken from index for skipped files. > */ >- public static final int AST_SKIP_INDEXED_HEADERS = 2; >+ public static final int AST_SKIP_INDEXED_HEADERS = 0x2; > > /** > * Style constant for {@link #getAST(IIndex, int)}. > * Meaning: Skip headers even if they are not found in the index. > * Makes practically only sense in combination with {@link #AST_SKIP_INDEXED_HEADERS}. > */ >- public static final int AST_SKIP_NONINDEXED_HEADERS = 4; >+ public static final int AST_SKIP_NONINDEXED_HEADERS = 0x4; > > /** > * Style constant for {@link #getAST(IIndex, int)}. >@@ -66,14 +68,14 @@ > * Style constant for {@link #getAST(IIndex, int)}. > * Meaning: Don't parse the file if there is no build information for it. > */ >- public static final int AST_SKIP_IF_NO_BUILD_INFO = 8; >+ public static final int AST_SKIP_IF_NO_BUILD_INFO = 0x8; > > /** > * Style constant for {@link #getAST(IIndex, int)}. > * Meaning: Add nodes for comments to the ast. > * @since 4.0 > */ >- public static final int AST_CREATE_COMMENT_NODES = 16; >+ public static final int AST_CREATE_COMMENT_NODES = 0x10; > > /** > * Style constant for {@link #getAST(IIndex, int)}. >@@ -82,7 +84,15 @@ > * the flag is ignored. > * @since 4.0 > */ >- public static final int AST_CONFIGURE_USING_SOURCE_CONTEXT= 32; >+ public static final int AST_CONFIGURE_USING_SOURCE_CONTEXT= 0x20; >+ >+ /** >+ * Style constant for {@link #getAST(IIndex, int)}. >+ * Instructs the parser not to create ast nodes for expressions within aggregate initializers >+ * when they do not contain names. >+ * @since 5.1 >+ */ >+ public final static int AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS= 0x40; > > /** > * Creates and returns an include declaration in this translation unit >Index: model/org/eclipse/cdt/core/model/ILanguage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java,v >retrieving revision 1.18 >diff -u -r1.18 ILanguage.java >--- model/org/eclipse/cdt/core/model/ILanguage.java 18 Apr 2008 09:23:05 -0000 1.18 >+++ model/org/eclipse/cdt/core/model/ILanguage.java 6 Nov 2008 13:39:32 -0000 >@@ -6,7 +6,7 @@ > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: >- * QNX - Initial API and implementation >+ * Doug Schaefer (QNX) - Initial API and implementation > * Markus Schorn (Wind River Systems) > * IBM Corporation > *******************************************************************************/ >@@ -27,7 +27,8 @@ > /** > * Models differences between languages. The interface is not supposed to be implemented directly. > * Rather than that clients may subclass {@link AbstractLanguage}. >- * @author Doug Schaefer >+ * >+ * @noimplement This interface is not intended to be implemented by clients. > */ > public interface ILanguage extends IAdaptable { > >@@ -35,27 +36,35 @@ > * Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)} > * Instructs the parser to skip function and method bodies. > */ >- public final static int OPTION_SKIP_FUNCTION_BODIES= 1; >+ public final static int OPTION_SKIP_FUNCTION_BODIES= 0x1; > > /** > * Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)} > * Instructs the parser to add comment nodes to the ast. > */ >- public final static int OPTION_ADD_COMMENTS= 2; >+ public final static int OPTION_ADD_COMMENTS= 0x2; > > /** > * Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)} > * Performance optimization, instructs the parser not to create image-locations. > * When using this option {@link IASTName#getImageLocation()} will always return <code>null</code>. > */ >- public final static int OPTION_NO_IMAGE_LOCATIONS= 4; >+ public final static int OPTION_NO_IMAGE_LOCATIONS= 0x4; > > /** > * Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)} > * Marks the ast as being based on a source-file rather than a header-file. This makes a difference > * when bindings from the AST are used for searching the index, e.g. for static variables. > */ >- public final static int OPTION_IS_SOURCE_UNIT= 8; >+ public final static int OPTION_IS_SOURCE_UNIT= 0x8; >+ >+ /** >+ * Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)} >+ * Instructs the parser not to create ast nodes for expressions within aggregate initializers >+ * when they do not contain names. >+ * @since 5.1 >+ */ >+ public final static int OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS= 0x10; > > /** > * Return the language id for this language. >Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java,v >retrieving revision 1.186 >diff -u -r1.186 GNUCPPSourceParser.java >--- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java 3 Nov 2008 10:12:16 -0000 1.186 >+++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java 6 Nov 2008 13:39:34 -0000 >@@ -874,6 +874,9 @@ > 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 @@ > > 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 @@ > } > 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 @@ > 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 @@ > skipBrackets(IToken.tLBRACKET, IToken.tRBRACKET); > } > >- IASTDeclSpecifier declSpec; >+ IASTDeclSpecifier declSpec= null; > IASTDeclarator declarator; > try { > declSpec= declSpecifierSeq(DeclarationOptions.PARAMETER); >@@ -2524,6 +2548,10 @@ > 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 @@ > * ("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 @@ > 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 @@ > } > > @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 @@ > } > } catch (BacktrackException e) { > bt= e; >- } >+ } > > if (!option.fAllowConstructorInitializer || !canHaveConstructorInitializer(declspec)) { > if (bt != null) >@@ -3096,7 +3130,7 @@ > return dtor1; > } > throw e; >- } >+ } > > // we have an ambiguity > if (end1 != null && LA(1).getEndOffset() != end1.getEndOffset()) { >@@ -3144,11 +3178,15 @@ > * @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 @@ > } > 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 @@ > if (LT(1) == IToken.tASSIGN) { > consume(); > try { >- return initializerClause(); >+ return initializerClause(false); > } catch (EndOfFileException eof) { > failParse(); > throw eof; >@@ -3200,7 +3253,7 @@ > } > > >- 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 @@ > if (LT(1) == IToken.tRBRACE) > break; > >- IASTInitializer clause = initializerClause(); >+ IASTInitializer clause = initializerClause(true); > if (clause != null) { > result.addInitializer(clause); > } >@@ -3236,6 +3289,11 @@ > // 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 @@ > > 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 @@ > 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); >Index: parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java,v >retrieving revision 1.122 >diff -u -r1.122 GNUCSourceParser.java >--- parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java 3 Nov 2008 10:12:16 -0000 1.122 >+++ parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java 6 Nov 2008 13:39:33 -0000 >@@ -159,12 +159,12 @@ > if (LT(1) == IToken.tASSIGN) { > consume(); > final List<IASTNode> empty= Collections.emptyList(); >- return cInitializerClause(empty); >+ return cInitializerClause(empty, false); > } > return null; > } > >- protected IASTInitializer cInitializerClause(List<IASTNode> designators) >+ protected IASTInitializer cInitializerClause(List<IASTNode> designators, boolean inAggregateInitializer) > throws EndOfFileException, BacktrackException { > IToken la = LA(1); > int startingOffset = la.getOffset(); >@@ -190,10 +190,12 @@ > if (LT(1) == IToken.tASSIGN) > consume(); > >- IASTInitializer initializer = cInitializerClause(newDesignators); >+ IASTInitializer initializer = cInitializerClause(newDesignators, true); > > if (newDesignators.isEmpty()) { >- result.addInitializer(initializer); >+ // depending on value of skipTrivialItemsInCompoundInitializers initializer may be null >+ if (initializer != null) >+ result.addInitializer(initializer); > } else { > ICASTDesignatedInitializer desigInitializer = createDesignatorInitializer(); > ((ASTNode) desigInitializer).setOffsetAndLength( >@@ -232,6 +234,10 @@ > // try this now instead > // assignmentExpression > IASTExpression assignmentExpression = assignmentExpression(); >+ if (inAggregateInitializer && skipTrivialExpressionsInAggregateInitializers) { >+ if (!NAME_CHECKER.containsName(assignmentExpression)) >+ return null; >+ } > IASTInitializerExpression result = createInitializerExpression(); > result.setExpression(assignmentExpression); > ((ASTNode) result).setOffsetAndLength( >@@ -387,17 +393,27 @@ > > final int firstOffset= LA(1).getOffset(); > int endOffset= firstOffset; >+ boolean insertSemi= false; >+ boolean parseDtors= true; > >- IASTDeclSpecifier declSpec; >+ IASTDeclSpecifier 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.tSEMI: > case IToken.tEOC: >+ case IToken.tSEMI: >+ parseDtors= false; >+ insertSemi= lt1==0; >+ if (lt1 == IToken.tSEMI) >+ endOffset= consume().getEndOffset(); >+ else >+ endOffset= calculateEndOffset(declSpec); > break; >+ > default: > markBeforDtor= mark(); > try { >@@ -408,6 +424,13 @@ > backup(markBeforDtor); > } > } >+ } catch (FoundAggregateInitializer lie) { >+ if (declSpec == null) >+ declSpec= lie.fDeclSpec; >+ // scalability: don't keep references to tokens, initializer may be large >+ declarationMark= null; >+ markBeforDtor= null; >+ dtor= addInitializer(lie); > } catch (FoundDeclaratorException e) { > if (e.altSpec != null) { > declSpec= e.altSpec; >@@ -428,45 +451,53 @@ > throw e; > } > >- IASTDeclarator[] declarators= {dtor}; >- while (LTcatchEOF(1) == IToken.tCOMMA) { >- consume(); >- declarators= (IASTDeclarator[]) ArrayUtil.append( IASTDeclarator.class, declarators, initDeclarator(declOption)); >- } >- declarators= (IASTDeclarator[]) ArrayUtil.removeNulls( IASTDeclarator.class, declarators ); >+ IASTDeclarator[] declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY; >+ if (parseDtors) { >+ declarators= new IASTDeclarator[]{dtor}; >+ while (LTcatchEOF(1) == IToken.tCOMMA) { >+ consume(); >+ try { >+ dtor= initDeclarator(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 ); > >- boolean insertSemi= false; >- final int lt1= LTcatchEOF(1); >- switch (lt1) { >- case IToken.tLBRACE: >- return functionDefinition(firstOffset, declSpec, declarators); >+ final int lt1= LTcatchEOF(1); >+ switch (lt1) { >+ case IToken.tLBRACE: >+ return functionDefinition(firstOffset, declSpec, declarators); > >- case IToken.tSEMI: >- endOffset= consume().getEndOffset(); >- break; >- case IToken.tEOC: >- endOffset= figureEndOffset(declSpec, declarators); >- break; >- default: >- if (declOption != DeclarationOptions.LOCAL) { >- insertSemi= true; >- if (markBeforDtor == null || !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) { >- if (markBeforDtor != null) { >+ case IToken.tSEMI: >+ endOffset= consume().getEndOffset(); >+ break; >+ case IToken.tEOC: >+ endOffset= figureEndOffset(declSpec, declarators); >+ break; >+ default: >+ if (declOption != DeclarationOptions.LOCAL) { >+ insertSemi= true; >+ if (markBeforDtor != null && !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) { > backup(markBeforDtor); >+ declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY; >+ endOffset= calculateEndOffset(declSpec); >+ break; >+ } >+ endOffset= figureEndOffset(declSpec, declarators); >+ if (lt1 == 0 || !isOnSameLine(endOffset, LA(1).getOffset())) { >+ break; >+ } >+ if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) { >+ break; > } >- declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY; >- endOffset= calculateEndOffset(declSpec); >- break; >- } >- endOffset= figureEndOffset(declSpec, declarators); >- if (lt1 == 0 || !isOnSameLine(endOffset, LA(1).getOffset())) { >- break; >- } >- if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) { >- break; > } >+ throwBacktrack(LA(1)); > } >- throwBacktrack(LA(1)); > } > > // no function body >@@ -657,7 +688,7 @@ > consume(IToken.tRPAREN).getEndOffset(); > if (LT(1) == IToken.tLBRACE) { > final List<IASTNode> emptyList = Collections.emptyList(); >- IASTInitializer i = cInitializerClause(emptyList); >+ IASTInitializer i = cInitializerClause(emptyList, false); > firstExpression = buildTypeIdInitializerExpression(t, i, offset, calculateEndOffset(i)); > break; > } >@@ -896,6 +927,9 @@ > 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 @@ > > @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 @@ > 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 @@ > 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 @@ > } > > @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 @@ > } > 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 @@ > altDeclSpec= fd.altSpec; > altDeclarator= fd.altDeclarator; > backup(fd.currToken); >+ } catch (FoundAggregateInitializer lie) { >+ if (declSpec == null) >+ declSpec= lie.fDeclSpec; >+ declarator= addInitializer(lie); > } finally { > fPreventKnrCheck--; > } >Index: parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java,v >retrieving revision 1.19 >diff -u -r1.19 AbstractIndexerTask.java >--- parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java 1 Oct 2008 09:59:42 -0000 1.19 >+++ parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java 6 Nov 2008 13:39:34 -0000 >@@ -219,7 +219,8 @@ > } > 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; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 253690
:
116932
|
117176
|
117193
| 117194 |
117293
|
117297
|
117439