Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 253690 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java (-1 / +1 lines)
Lines 68-74 Link Here
68
		}
68
		}
69
69
70
		final IHyperlink[] result= {null};
70
		final IHyperlink[] result= {null};
71
		IStatus status= ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_YES, null, new ASTRunnable() {
71
		IStatus status= ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_ACTIVE_ONLY, null, new ASTRunnable() {
72
			public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
72
			public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
73
				if (ast != null) {
73
				if (ast != null) {
74
					final int offset= region.getOffset();
74
					final int offset= region.getOffset();
(-)src/org/eclipse/cdt/internal/ui/editor/ASTProvider.java (-18 / +13 lines)
Lines 65-81 Link Here
65
65
66
	/**
66
	/**
67
	 * Wait flag indicating that a client requesting an AST
67
	 * Wait flag indicating that a client requesting an AST
68
	 * wants to wait until an AST is ready.
68
	 * wants to wait until an AST is ready. If the translation unit is not open no ast will
69
	 * be provided.
69
	 * <p>
70
	 * <p>
70
	 * An AST will be created by this AST provider if the shared
71
	 * If not yet cached and if the translation unit is open, an AST will be created by 
71
	 * AST is not for the given C element.
72
	 * this AST provider.
72
	 * </p>
73
	 * </p>
73
	 */
74
	 */
74
	public static final WAIT_FLAG WAIT_YES= new WAIT_FLAG("wait yes"); //$NON-NLS-1$
75
	public static final WAIT_FLAG WAIT_IF_OPEN= new WAIT_FLAG("wait if open"); //$NON-NLS-1$
75
76
76
	/**
77
	/**
77
	 * Wait flag indicating that a client requesting an AST
78
	 * Wait flag indicating that a client requesting an AST
78
	 * only wants to wait for the shared AST of the active editor.
79
	 * only wants to wait for the shared AST of the active editor. 
80
	 * If the translation unit is not open no ast will be provided.
79
	 * <p>
81
	 * <p>
80
	 * No AST will be created by the AST provider.
82
	 * No AST will be created by the AST provider.
81
	 * </p>
83
	 * </p>
Lines 262-278 Link Here
262
	}
264
	}
263
265
264
	/**
266
	/**
265
	 * Returns whether this AST provider is active on the given
266
	 * translation unit.
267
	 *
268
	 * @param tu the translation unit
269
	 * @return <code>true</code> if the given translation unit is the active one
270
	 */
271
	public boolean isActive(ITranslationUnit tu) {
272
		return fCache.isActiveElement(tu) && tu.isOpen();
273
	}
274
275
	/**
276
	 * Informs that reconciling for the given element is about to be started.
267
	 * Informs that reconciling for the given element is about to be started.
277
	 *
268
	 *
278
	 * @param cElement the C element
269
	 * @param cElement the C element
Lines 339-351 Link Here
339
	public IStatus runOnAST(ICElement cElement, WAIT_FLAG waitFlag, IProgressMonitor monitor,
330
	public IStatus runOnAST(ICElement cElement, WAIT_FLAG waitFlag, IProgressMonitor monitor,
340
			ASTCache.ASTRunnable astRunnable) {
331
			ASTCache.ASTRunnable astRunnable) {
341
		Assert.isTrue(cElement instanceof ITranslationUnit);
332
		Assert.isTrue(cElement instanceof ITranslationUnit);
342
		boolean isActive= isActive((ITranslationUnit)cElement);
333
		final ITranslationUnit tu = (ITranslationUnit)cElement;
334
		if (!tu.isOpen())
335
			return Status.CANCEL_STATUS;
336
		
337
		final boolean isActive= fCache.isActiveElement(tu);
343
		if (waitFlag == WAIT_ACTIVE_ONLY && !isActive) {
338
		if (waitFlag == WAIT_ACTIVE_ONLY && !isActive) {
344
			return Status.CANCEL_STATUS;
339
			return Status.CANCEL_STATUS;
345
		}
340
		}
346
		if (isActive && updateModificationStamp()) {
341
		if (isActive && updateModificationStamp()) {
347
			fCache.disposeAST();
342
			fCache.disposeAST();
348
		}
343
		}
349
		return fCache.runOnAST((ITranslationUnit)cElement, waitFlag != WAIT_NO, monitor, astRunnable);
344
		return fCache.runOnAST(tu, waitFlag != WAIT_NO, monitor, astRunnable);
350
	}
345
	}
351
}
346
}
(-)src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java (-2 / +1 lines)
Lines 10-16 Link Here
10
 *     Anton Leherbauer (Wind River Systems) - Adapted for CDT
10
 *     Anton Leherbauer (Wind River Systems) - Adapted for CDT
11
 *     Markus Schorn (Wind River Systems)
11
 *     Markus Schorn (Wind River Systems)
12
 *******************************************************************************/
12
 *******************************************************************************/
13
14
package org.eclipse.cdt.internal.ui.editor;
13
package org.eclipse.cdt.internal.ui.editor;
15
14
16
import java.util.ArrayList;
15
import java.util.ArrayList;
Lines 513-519 Link Here
513
						
512
						
514
						final Job me= this;
513
						final Job me= this;
515
						ASTProvider astProvider= CUIPlugin.getDefault().getASTProvider();
514
						ASTProvider astProvider= CUIPlugin.getDefault().getASTProvider();
516
						IStatus status= astProvider.runOnAST(element, ASTProvider.WAIT_YES, monitor, new ASTCache.ASTRunnable() {
515
						IStatus status= astProvider.runOnAST(element, ASTProvider.WAIT_IF_OPEN, monitor, new ASTCache.ASTRunnable() {
517
							public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
516
							public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
518
								reconciled(ast, true, monitor);
517
								reconciled(ast, true, monitor);
519
								synchronized (fJobLock) {
518
								synchronized (fJobLock) {
(-)src/org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting.java (-3 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 9-15 Link Here
9
 *     Anton Leherbauer (Wind River Systems) - initial API and implementation
9
 *     Anton Leherbauer (Wind River Systems) - initial API and implementation
10
 *     Markus Schorn (Wind River Systems)
10
 *     Markus Schorn (Wind River Systems)
11
 *******************************************************************************/
11
 *******************************************************************************/
12
13
package org.eclipse.cdt.internal.ui.editor;
12
package org.eclipse.cdt.internal.ui.editor;
14
13
15
import java.util.ArrayList;
14
import java.util.ArrayList;
Lines 108-114 Link Here
108
						IStatus result = Status.OK_STATUS;
107
						IStatus result = Status.OK_STATUS;
109
						if (fTranslationUnit != null) {
108
						if (fTranslationUnit != null) {
110
							final ASTProvider astProvider= CUIPlugin.getDefault().getASTProvider();
109
							final ASTProvider astProvider= CUIPlugin.getDefault().getASTProvider();
111
							result= astProvider.runOnAST(fTranslationUnit, ASTProvider.WAIT_YES, monitor, new ASTCache.ASTRunnable() {
110
							result= astProvider.runOnAST(fTranslationUnit, ASTProvider.WAIT_IF_OPEN, monitor, new ASTCache.ASTRunnable() {
112
								public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
111
								public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
113
									reconciled(ast, true, monitor);
112
									reconciled(ast, true, monitor);
114
									return Status.OK_STATUS;
113
									return Status.OK_STATUS;
(-)src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java (-2 / +1 lines)
Lines 9-15 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 * 	   Sergey Prigogin (Google)
10
 * 	   Sergey Prigogin (Google)
11
 *******************************************************************************/
11
 *******************************************************************************/
12
13
package org.eclipse.cdt.internal.ui.text.correction;
12
package org.eclipse.cdt.internal.ui.text.correction;
14
13
15
import java.util.ArrayList;
14
import java.util.ArrayList;
Lines 120-126 Link Here
120
	private ICompletionProposal getLocalRenameProposal(final IInvocationContext context) {
119
	private ICompletionProposal getLocalRenameProposal(final IInvocationContext context) {
121
		final ICCompletionProposal[] proposals= new ICCompletionProposal[1];
120
		final ICCompletionProposal[] proposals= new ICCompletionProposal[1];
122
121
123
		ASTProvider.getASTProvider().runOnAST(context.getTranslationUnit(), ASTProvider.WAIT_YES,
122
		ASTProvider.getASTProvider().runOnAST(context.getTranslationUnit(), ASTProvider.WAIT_ACTIVE_ONLY,
124
				new NullProgressMonitor(), new ASTRunnable() {
123
				new NullProgressMonitor(), new ASTRunnable() {
125
124
126
			public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
125
			public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
(-)src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java (-1 / +1 lines)
Lines 170-176 Link Here
170
				if (workingCopy != null) {
170
				if (workingCopy != null) {
171
					installSelectionListener();
171
					installSelectionListener();
172
					final Point point= fViewer.getSelectedRange();
172
					final Point point= fViewer.getSelectedRange();
173
					ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_YES, null, new ASTRunnable() {
173
					ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_IF_OPEN, null, new ASTRunnable() {
174
						public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) {
174
						public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) {
175
							if (astRoot != null) {
175
							if (astRoot != null) {
176
								doSelectionChanged(point.x, point.y, astRoot);
176
								doSelectionChanged(point.x, point.y, astRoot);
(-)src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java (-1 / +1 lines)
Lines 52-58 Link Here
52
52
53
	@Override
53
	@Override
54
	protected IStatus runWithIndex(final IIndex index, IProgressMonitor monitor) {
54
	protected IStatus runWithIndex(final IIndex index, IProgressMonitor monitor) {
55
		return ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_YES, monitor, new ASTRunnable() {
55
		return ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_ACTIVE_ONLY, monitor, new ASTRunnable() {
56
			public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
56
			public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
57
				if (ast != null) {
57
				if (ast != null) {
58
					IASTName searchName= ast.getNodeSelector(null).findEnclosingName(selection.getOffset(), selection.getLength());
58
					IASTName searchName= ast.getNodeSelector(null).findEnclosingName(selection.getOffset(), selection.getLength());
(-)src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedNamesAssistProposal.java (-12 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-30 Link Here
14
import java.util.Arrays;
14
import java.util.Arrays;
15
import java.util.Comparator;
15
import java.util.Comparator;
16
16
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.events.VerifyEvent;
19
import org.eclipse.swt.graphics.Image;
20
import org.eclipse.swt.graphics.Point;
21
22
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.CoreException;
23
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.IStatus;
24
import org.eclipse.core.runtime.NullProgressMonitor;
19
import org.eclipse.core.runtime.NullProgressMonitor;
25
import org.eclipse.core.runtime.Status;
20
import org.eclipse.core.runtime.Status;
26
import org.eclipse.jface.viewers.StyledString;
27
28
import org.eclipse.jface.text.BadLocationException;
21
import org.eclipse.jface.text.BadLocationException;
29
import org.eclipse.jface.text.DocumentEvent;
22
import org.eclipse.jface.text.DocumentEvent;
30
import org.eclipse.jface.text.IDocument;
23
import org.eclipse.jface.text.IDocument;
Lines 39-45 Link Here
39
import org.eclipse.jface.text.link.LinkedPositionGroup;
32
import org.eclipse.jface.text.link.LinkedPositionGroup;
40
import org.eclipse.jface.text.link.LinkedModeUI.ExitFlags;
33
import org.eclipse.jface.text.link.LinkedModeUI.ExitFlags;
41
import org.eclipse.jface.text.link.LinkedModeUI.IExitPolicy;
34
import org.eclipse.jface.text.link.LinkedModeUI.IExitPolicy;
42
35
import org.eclipse.jface.viewers.StyledString;
36
import org.eclipse.osgi.util.NLS;
37
import org.eclipse.swt.SWT;
38
import org.eclipse.swt.events.VerifyEvent;
39
import org.eclipse.swt.graphics.Image;
40
import org.eclipse.swt.graphics.Point;
43
import org.eclipse.ui.IEditorPart;
41
import org.eclipse.ui.IEditorPart;
44
import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
42
import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
45
43
Lines 136-145 Link Here
136
			final int secectionOffset = selection.x;
134
			final int secectionOffset = selection.x;
137
			final int selectionLength = selection.y;
135
			final int selectionLength = selection.y;
138
136
139
			ASTProvider.getASTProvider().runOnAST(fTranslationUnit, ASTProvider.WAIT_YES,
137
			ASTProvider.getASTProvider().runOnAST(fTranslationUnit, ASTProvider.WAIT_ACTIVE_ONLY,
140
					new NullProgressMonitor(), new ASTRunnable() {
138
					new NullProgressMonitor(), new ASTRunnable() {
141
139
142
				public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
140
				public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
141
					if (astRoot == null)
142
						return Status.CANCEL_STATUS;
143
					
143
					IASTNodeSelector selector= astRoot.getNodeSelector(null);
144
					IASTNodeSelector selector= astRoot.getNodeSelector(null);
144
					IASTName name= selector.findEnclosingName(secectionOffset, selectionLength);
145
					IASTName name= selector.findEnclosingName(secectionOffset, selectionLength);
145
					if (name != null) {
146
					if (name != null) {
Lines 249-255 Link Here
249
	public String getDisplayString() {
250
	public String getDisplayString() {
250
		String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
251
		String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
251
		if (shortCutString != null) {
252
		if (shortCutString != null) {
252
			return CorrectionMessages.bind(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
253
			return NLS.bind(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
253
					fLabel, shortCutString);
254
					fLabel, shortCutString);
254
		}
255
		}
255
		return fLabel;
256
		return fLabel;
Lines 263-269 Link Here
263
		
264
		
264
		String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
265
		String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
265
		if (shortCutString != null) {
266
		if (shortCutString != null) {
266
			String decorated= CorrectionMessages.bind(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
267
			String decorated= NLS.bind(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
267
					fLabel, shortCutString);
268
					fLabel, shortCutString);
268
			return ColoringLabelProvider.decorateStyledString(str, decorated, StyledString.QUALIFIER_STYLER); 
269
			return ColoringLabelProvider.decorateStyledString(str, decorated, StyledString.QUALIFIER_STYLER); 
269
		}
270
		}
(-)src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java (-1 / +1 lines)
Lines 393-399 Link Here
393
			return null;
393
			return null;
394
		
394
		
395
		final IASTName[] result= {null};
395
		final IASTName[] result= {null};
396
		ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_YES, null, new ASTRunnable() {
396
		ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_ACTIVE_ONLY, null, new ASTRunnable() {
397
			public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
397
			public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
398
				if (ast != null) {
398
				if (ast != null) {
399
					final IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
399
					final IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
(-)src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java (-2 / +4 lines)
Lines 188-196 Link Here
188
	}
188
	}
189
189
190
	private void createLog(final PrintStream out, final ITranslationUnit tu, IProgressMonitor pm) {
190
	private void createLog(final PrintStream out, final ITranslationUnit tu, IProgressMonitor pm) {
191
		ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_YES, pm, new ASTCache.ASTRunnable() {
191
		ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, pm, new ASTCache.ASTRunnable() {
192
			public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
192
			public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
193
				return createLog(out, tu, lang, ast);
193
				if (ast != null)
194
					return createLog(out, tu, lang, ast);
195
				return Status.CANCEL_STATUS;
194
			}
196
			}
195
		});
197
		});
196
	}
198
	}
(-)src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java (-5 / +5 lines)
Lines 61-67 Link Here
61
import org.eclipse.cdt.core.model.ISourceRange;
61
import org.eclipse.cdt.core.model.ISourceRange;
62
import org.eclipse.cdt.core.model.ISourceReference;
62
import org.eclipse.cdt.core.model.ISourceReference;
63
import org.eclipse.cdt.core.model.ITranslationUnit;
63
import org.eclipse.cdt.core.model.ITranslationUnit;
64
import org.eclipse.cdt.core.model.IWorkingCopy;
65
import org.eclipse.cdt.core.model.util.CElementBaseLabels;
64
import org.eclipse.cdt.core.model.util.CElementBaseLabels;
66
import org.eclipse.cdt.core.parser.util.ArrayUtil;
65
import org.eclipse.cdt.core.parser.util.ArrayUtil;
67
import org.eclipse.cdt.ui.CUIPlugin;
66
import org.eclipse.cdt.ui.CUIPlugin;
Lines 103-109 Link Here
103
	
102
	
104
	ITextSelection fTextSelection;
103
	ITextSelection fTextSelection;
105
	private String fSelectedText;
104
	private String fSelectedText;
106
	private IWorkingCopy fWorkingCopy;
105
	private ITranslationUnit fWorkingCopy;
107
	private IIndex fIndex;
106
	private IIndex fIndex;
108
	private IProgressMonitor fMonitor;
107
	private IProgressMonitor fMonitor;
109
108
Lines 122-131 Link Here
122
		clearStatusLine();
121
		clearStatusLine();
123
122
124
		fMonitor= monitor;
123
		fMonitor= monitor;
125
		fWorkingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput());
124
		ICElement celem= fEditor.getInputCElement();
126
		if (fWorkingCopy == null)
125
		if (!(celem instanceof ITranslationUnit)) 
127
			return Status.CANCEL_STATUS;
126
			return Status.CANCEL_STATUS;
128
127
128
		fWorkingCopy= (ITranslationUnit) celem;
129
		fIndex= CCorePlugin.getIndexManager().getIndex(fWorkingCopy.getCProject(),
129
		fIndex= CCorePlugin.getIndexManager().getIndex(fWorkingCopy.getCProject(),
130
				IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
130
				IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
131
131
Lines 136-142 Link Here
136
		}
136
		}
137
137
138
		try {
138
		try {
139
			return ASTProvider.getASTProvider().runOnAST(fWorkingCopy, ASTProvider.WAIT_YES, monitor, this);
139
			return ASTProvider.getASTProvider().runOnAST(fWorkingCopy, ASTProvider.WAIT_ACTIVE_ONLY, monitor, this);
140
		} finally {
140
		} finally {
141
			fIndex.releaseReadLock();
141
			fIndex.releaseReadLock();
142
		}
142
		}
(-)ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java (-34 / +16 lines)
Lines 17-26 Link Here
17
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.resources.IFile;
18
import org.eclipse.swt.widgets.Tree;
18
import org.eclipse.swt.widgets.Tree;
19
import org.eclipse.swt.widgets.TreeItem;
19
import org.eclipse.swt.widgets.TreeItem;
20
import org.eclipse.ui.IWorkbenchPage;
21
import org.eclipse.ui.PartInitException;
20
import org.eclipse.ui.PartInitException;
22
import org.eclipse.ui.PlatformUI;
23
import org.eclipse.ui.ide.IDE;
24
21
25
import org.eclipse.cdt.core.dom.IPDOMManager;
22
import org.eclipse.cdt.core.dom.IPDOMManager;
26
import org.eclipse.cdt.core.model.ICProject;
23
import org.eclipse.cdt.core.model.ICProject;
Lines 63-70 Link Here
63
		String content = readTaggedComment("testFunctions");
60
		String content = readTaggedComment("testFunctions");
64
		IFile file= createFile(getProject(), filename, content);
61
		IFile file= createFile(getProject(), filename, content);
65
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
62
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
66
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
63
		CEditor editor = openEditor(file);
67
		CEditor editor= (CEditor) IDE.openEditor(page, file);
68
64
69
		editor.selectAndReveal(content.indexOf("proto"), 5);
65
		editor.selectAndReveal(content.indexOf("proto"), 5);
70
		openCallHierarchy(editor);
66
		openCallHierarchy(editor);
Lines 108-115 Link Here
108
		String content = readTaggedComment("testVariables");
104
		String content = readTaggedComment("testVariables");
109
		IFile file= createFile(getProject(), filename, content);
105
		IFile file= createFile(getProject(), filename, content);
110
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
106
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
111
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
107
		CEditor editor = openEditor(file);
112
		CEditor editor= (CEditor) IDE.openEditor(page, file);
113
108
114
		editor.selectAndReveal(content.indexOf("extern_var"), 0);
109
		editor.selectAndReveal(content.indexOf("extern_var"), 0);
115
		openCallHierarchy(editor);
110
		openCallHierarchy(editor);
Lines 164-171 Link Here
164
		String content = readTaggedComment(contentTag);
159
		String content = readTaggedComment(contentTag);
165
		IFile file= createFile(getProject(), filename, content);
160
		IFile file= createFile(getProject(), filename, content);
166
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
161
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
167
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
162
		CEditor editor = openEditor(file);
168
		CEditor editor= (CEditor) IDE.openEditor(page, file);
169
163
170
		editor.selectAndReveal(content.indexOf("enumerator"), 0);
164
		editor.selectAndReveal(content.indexOf("enumerator"), 0);
171
		openCallHierarchy(editor);
165
		openCallHierarchy(editor);
Lines 220-227 Link Here
220
		String content = readTaggedComment("testStructMembers");
214
		String content = readTaggedComment("testStructMembers");
221
		IFile file= createFile(getProject(), "struct_member.c", content);
215
		IFile file= createFile(getProject(), "struct_member.c", content);
222
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
216
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
223
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
217
		CEditor editor = openEditor(file);
224
		CEditor editor= (CEditor) IDE.openEditor(page, file);
225
		
218
		
226
		editor.selectAndReveal(content.indexOf("mem1"), 0);
219
		editor.selectAndReveal(content.indexOf("mem1"), 0);
227
		openCallHierarchy(editor);
220
		openCallHierarchy(editor);
Lines 267-274 Link Here
267
		String content = readTaggedComment("testStructMembers");
260
		String content = readTaggedComment("testStructMembers");
268
		IFile file= createFile(getProject(), "struct_member.cpp", content);
261
		IFile file= createFile(getProject(), "struct_member.cpp", content);
269
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
262
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
270
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
263
		CEditor editor = openEditor(file);
271
		CEditor editor= (CEditor) IDE.openEditor(page, file);
272
		
264
		
273
		editor.selectAndReveal(content.indexOf("mem1"), 0);
265
		editor.selectAndReveal(content.indexOf("mem1"), 0);
274
		openCallHierarchy(editor);
266
		openCallHierarchy(editor);
Lines 314-321 Link Here
314
		String content = readTaggedComment("testStructMembers");
306
		String content = readTaggedComment("testStructMembers");
315
		IFile file= createFile(getProject(), "anon_struct_member.c", content);
307
		IFile file= createFile(getProject(), "anon_struct_member.c", content);
316
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
308
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
317
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
309
		CEditor editor = openEditor(file);
318
		CEditor editor= (CEditor) IDE.openEditor(page, file);
319
		
310
		
320
		editor.selectAndReveal(content.indexOf("mem3"), 0);
311
		editor.selectAndReveal(content.indexOf("mem3"), 0);
321
		openCallHierarchy(editor);
312
		openCallHierarchy(editor);
Lines 343-350 Link Here
343
		String content = readTaggedComment("testStructMembers");
334
		String content = readTaggedComment("testStructMembers");
344
		IFile file= createFile(getProject(), "anon_struct_member.cpp", content);
335
		IFile file= createFile(getProject(), "anon_struct_member.cpp", content);
345
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
336
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
346
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
337
		CEditor editor = openEditor(file);
347
		CEditor editor= (CEditor) IDE.openEditor(page, file);
348
		
338
		
349
		editor.selectAndReveal(content.indexOf("mem3"), 0);
339
		editor.selectAndReveal(content.indexOf("mem3"), 0);
350
		openCallHierarchy(editor);
340
		openCallHierarchy(editor);
Lines 406-413 Link Here
406
		String content = readTaggedComment("testUnionMembers");
396
		String content = readTaggedComment("testUnionMembers");
407
		IFile file= createFile(getProject(), "union_member.c", content);
397
		IFile file= createFile(getProject(), "union_member.c", content);
408
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
398
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
409
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
399
		CEditor editor = openEditor(file);
410
		CEditor editor= (CEditor) IDE.openEditor(page, file);
411
		
400
		
412
		editor.selectAndReveal(content.indexOf("mem1"), 0);
401
		editor.selectAndReveal(content.indexOf("mem1"), 0);
413
		openCallHierarchy(editor);
402
		openCallHierarchy(editor);
Lines 453-460 Link Here
453
		String content = readTaggedComment("testUnionMembers");
442
		String content = readTaggedComment("testUnionMembers");
454
		IFile file= createFile(getProject(), "union_member.cpp", content);
443
		IFile file= createFile(getProject(), "union_member.cpp", content);
455
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
444
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
456
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
445
		CEditor editor = openEditor(file);
457
		CEditor editor= (CEditor) IDE.openEditor(page, file);
458
		
446
		
459
		editor.selectAndReveal(content.indexOf("mem1"), 0);
447
		editor.selectAndReveal(content.indexOf("mem1"), 0);
460
		openCallHierarchy(editor);
448
		openCallHierarchy(editor);
Lines 500-507 Link Here
500
		String content = readTaggedComment("testUnionMembers");
488
		String content = readTaggedComment("testUnionMembers");
501
		IFile file= createFile(getProject(), "anon_union_member.c", content);
489
		IFile file= createFile(getProject(), "anon_union_member.c", content);
502
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
490
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
503
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
491
		CEditor editor = openEditor(file);
504
		CEditor editor= (CEditor) IDE.openEditor(page, file);
505
		
492
		
506
		editor.selectAndReveal(content.indexOf("mem3"), 0);
493
		editor.selectAndReveal(content.indexOf("mem3"), 0);
507
		openCallHierarchy(editor);
494
		openCallHierarchy(editor);
Lines 529-536 Link Here
529
		String content = readTaggedComment("testUnionMembers");
516
		String content = readTaggedComment("testUnionMembers");
530
		IFile file= createFile(getProject(), "anon_union_member.cpp", content);
517
		IFile file= createFile(getProject(), "anon_union_member.cpp", content);
531
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
518
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
532
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
519
		CEditor editor = openEditor(file);
533
		CEditor editor= (CEditor) IDE.openEditor(page, file);
534
		
520
		
535
		editor.selectAndReveal(content.indexOf("mem3"), 0);
521
		editor.selectAndReveal(content.indexOf("mem3"), 0);
536
		openCallHierarchy(editor);
522
		openCallHierarchy(editor);
Lines 575-585 Link Here
575
561
576
		TreeItem i1, i2, i3, i4, i5, i6;
562
		TreeItem i1, i2, i3, i4, i5, i6;
577
		Tree tree;
563
		Tree tree;
578
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
564
		CEditor editor= openEditor(file1);
579
		CEditor editor;
580
		
565
		
581
		// first file with definition of gf()
566
		// first file with definition of gf()
582
		editor= (CEditor) IDE.openEditor(page, file1);
583
		editor.selectAndReveal(content1.indexOf("sf"), 0);
567
		editor.selectAndReveal(content1.indexOf("sf"), 0);
584
		openCallHierarchy(editor);
568
		openCallHierarchy(editor);
585
		tree = getCHTreeViewer().getTree();
569
		tree = getCHTreeViewer().getTree();
Lines 611-617 Link Here
611
		checkTreeNode(i6, 0, null);
595
		checkTreeNode(i6, 0, null);
612
596
613
		// second file without definition of gf()
597
		// second file without definition of gf()
614
		editor= (CEditor) IDE.openEditor(page, file2);
598
		editor = openEditor(file2);
615
		editor.selectAndReveal(content1.indexOf("sf"), 0);
599
		editor.selectAndReveal(content1.indexOf("sf"), 0);
616
		openCallHierarchy(editor);
600
		openCallHierarchy(editor);
617
		tree = getCHTreeViewer().getTree();
601
		tree = getCHTreeViewer().getTree();
Lines 646-656 Link Here
646
630
647
		TreeItem i0, i1, i2, i3, i4, i5, i6;
631
		TreeItem i0, i1, i2, i3, i4, i5, i6;
648
		Tree tree;
632
		Tree tree;
649
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
650
		CEditor editor;
633
		CEditor editor;
651
		
634
		
652
		// first file with definition of gf()
635
		// first file with definition of gf()
653
		editor= (CEditor) IDE.openEditor(page, file1);
636
		editor= openEditor(file1);
654
		editor.selectAndReveal(content1.indexOf("sf"), 0);
637
		editor.selectAndReveal(content1.indexOf("sf"), 0);
655
		openCallHierarchy(editor);
638
		openCallHierarchy(editor);
656
		tree = getCHTreeViewer().getTree();
639
		tree = getCHTreeViewer().getTree();
Lines 682-688 Link Here
682
		checkTreeNode(i6, 0, null);
665
		checkTreeNode(i6, 0, null);
683
666
684
		// second file without definition of gf()
667
		// second file without definition of gf()
685
		editor= (CEditor) IDE.openEditor(page, file2);
668
		editor= openEditor(file2);
686
		editor.selectAndReveal(content1.indexOf("sf"), 0);
669
		editor.selectAndReveal(content1.indexOf("sf"), 0);
687
		openCallHierarchy(editor);
670
		openCallHierarchy(editor);
688
		tree = getCHTreeViewer().getTree();
671
		tree = getCHTreeViewer().getTree();
Lines 719-726 Link Here
719
			String content = readTaggedComment("testFunctionsWithParams");
702
			String content = readTaggedComment("testFunctionsWithParams");
720
			IFile file= createFile(getProject(), filename, content);
703
			IFile file= createFile(getProject(), filename, content);
721
			waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
704
			waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
722
			IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
705
			CEditor editor = openEditor(file);
723
			CEditor editor= (CEditor) IDE.openEditor(page, file);
724
706
725
			editor.selectAndReveal(content.indexOf("proto"), 5);
707
			editor.selectAndReveal(content.indexOf("proto"), 5);
726
			openCallHierarchy(editor);
708
			openCallHierarchy(editor);
(-)ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java (-13 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 8-14 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *    Markus Schorn - initial API and implementation
9
 *    Markus Schorn - initial API and implementation
10
 *******************************************************************************/ 
10
 *******************************************************************************/ 
11
12
package org.eclipse.cdt.ui.tests.callhierarchy;
11
package org.eclipse.cdt.ui.tests.callhierarchy;
13
12
14
import junit.framework.Test;
13
import junit.framework.Test;
Lines 19-25 Link Here
19
import org.eclipse.swt.widgets.TreeItem;
18
import org.eclipse.swt.widgets.TreeItem;
20
import org.eclipse.ui.IWorkbenchPage;
19
import org.eclipse.ui.IWorkbenchPage;
21
import org.eclipse.ui.PlatformUI;
20
import org.eclipse.ui.PlatformUI;
22
import org.eclipse.ui.ide.IDE;
23
21
24
import org.eclipse.cdt.core.CCorePlugin;
22
import org.eclipse.cdt.core.CCorePlugin;
25
23
Lines 64-73 Link Here
64
		String source = content[1].toString();
62
		String source = content[1].toString();
65
		IFile headerFile= createFile(getProject(), "testMethods.h", header);
63
		IFile headerFile= createFile(getProject(), "testMethods.h", header);
66
		IFile sourceFile= createFile(getProject(), "testMethods.cpp", source);
64
		IFile sourceFile= createFile(getProject(), "testMethods.cpp", source);
67
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
68
		waitForIndexer(fIndex, sourceFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
65
		waitForIndexer(fIndex, sourceFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
69
		
66
		
70
		CEditor editor= (CEditor) IDE.openEditor(page, sourceFile);
67
		CEditor editor= openEditor(sourceFile);
71
		editor.selectAndReveal(source.indexOf("method"), 2);
68
		editor.selectAndReveal(source.indexOf("method"), 2);
72
		openCallHierarchy(editor);
69
		openCallHierarchy(editor);
73
		Tree tree = getCHTreeViewer().getTree();
70
		Tree tree = getCHTreeViewer().getTree();
Lines 138-144 Link Here
138
		IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1);
135
		IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1);
139
		IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
136
		IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
140
137
141
		CEditor editor= openFile(sourceFile1);
138
		CEditor editor= openEditor(sourceFile1);
142
		waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
139
		waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
143
		
140
		
144
		editor.selectAndReveal(source1.indexOf("method3"), 2);
141
		editor.selectAndReveal(source1.indexOf("method3"), 2);
Lines 190-196 Link Here
190
187
191
		waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
188
		waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
192
		
189
		
193
		CEditor editor= openFile(sourceFile1);
190
		CEditor editor= openEditor(sourceFile1);
194
		editor.selectAndReveal(source1.indexOf("method3"), 2);
191
		editor.selectAndReveal(source1.indexOf("method3"), 2);
195
		openCallHierarchy(editor);
192
		openCallHierarchy(editor);
196
		TreeViewer tv = getCHTreeViewer();
193
		TreeViewer tv = getCHTreeViewer();
Lines 248-254 Link Here
248
		IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1);
245
		IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1);
249
		IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
246
		IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
250
247
251
		CEditor editor= openFile(sourceFile2);
248
		CEditor editor= openEditor(sourceFile2);
252
		waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
249
		waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
253
		
250
		
254
		editor.selectAndReveal(source2.indexOf("main"), 2);
251
		editor.selectAndReveal(source2.indexOf("main"), 2);
Lines 302-309 Link Here
302
		String cppSource = content[1].toString();
299
		String cppSource = content[1].toString();
303
		IFile cFile= createFile(getProject(), "s.c", cSource);
300
		IFile cFile= createFile(getProject(), "s.c", cSource);
304
		IFile cppFile= createFile(getProject(), "s.cpp", cppSource);
301
		IFile cppFile= createFile(getProject(), "s.cpp", cppSource);
305
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
302
		CEditor editor= openEditor(cFile);
306
		CEditor editor= (CEditor) IDE.openEditor(page, cFile);
307
		waitForIndexer(fIndex, cppFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
303
		waitForIndexer(fIndex, cppFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
308
		CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM);
304
		CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM);
309
		
305
		
Lines 320-326 Link Here
320
		checkTreeNode(node, 1, null);
316
		checkTreeNode(node, 1, null);
321
		
317
		
322
318
323
		editor= (CEditor) IDE.openEditor(page, cppFile);
319
		editor= openEditor(cppFile);
324
		editor.selectAndReveal(cppSource.indexOf("cppfunc"), 2);
320
		editor.selectAndReveal(cppSource.indexOf("cppfunc"), 2);
325
		openCallHierarchy(editor, false);
321
		openCallHierarchy(editor, false);
326
		tree = getCHTreeViewer().getTree();
322
		tree = getCHTreeViewer().getTree();
Lines 349-355 Link Here
349
		IFile cFile= createFile(getProject(), "s.c", cSource);
345
		IFile cFile= createFile(getProject(), "s.c", cSource);
350
		IFile cppFile= createFile(getProject(), "s.cpp", cppSource);
346
		IFile cppFile= createFile(getProject(), "s.cpp", cppSource);
351
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
347
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
352
		CEditor editor= (CEditor) IDE.openEditor(page, cFile);
348
		CEditor editor= openEditor(cFile);
353
		waitForIndexer(fIndex, cppFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
349
		waitForIndexer(fIndex, cppFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
354
		CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM);
350
		CCorePlugin.getIndexManager().joinIndexer(INDEXER_WAIT_TIME, NPM);
355
		
351
		
Lines 366-372 Link Here
366
		checkTreeNode(node, 1, null);
362
		checkTreeNode(node, 1, null);
367
		
363
		
368
364
369
		editor= (CEditor) IDE.openEditor(page, cppFile);
365
		editor= openEditor(cppFile);
370
		editor.selectAndReveal(cppSource.indexOf("cppfunc"), 2);
366
		editor.selectAndReveal(cppSource.indexOf("cppfunc"), 2);
371
		openCallHierarchy(editor, true);
367
		openCallHierarchy(editor, true);
372
		tree = getCHTreeViewer().getTree();
368
		tree = getCHTreeViewer().getTree();
(-)ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java (-5 / +6 lines)
Lines 18-24 Link Here
18
import org.eclipse.swt.widgets.TreeItem;
18
import org.eclipse.swt.widgets.TreeItem;
19
import org.eclipse.ui.IWorkbenchPage;
19
import org.eclipse.ui.IWorkbenchPage;
20
import org.eclipse.ui.PlatformUI;
20
import org.eclipse.ui.PlatformUI;
21
import org.eclipse.ui.ide.IDE;
22
21
23
import org.eclipse.cdt.core.CCorePlugin;
22
import org.eclipse.cdt.core.CCorePlugin;
24
import org.eclipse.cdt.core.dom.IPDOMManager;
23
import org.eclipse.cdt.core.dom.IPDOMManager;
Lines 41-46 Link Here
41
		return suite(CallHierarchyAcrossProjectsTest.class);
40
		return suite(CallHierarchyAcrossProjectsTest.class);
42
	}
41
	}
43
	
42
	
43
	@Override
44
	protected void setUp() throws Exception {
44
	protected void setUp() throws Exception {
45
		super.setUp();
45
		super.setUp();
46
46
Lines 51-56 Link Here
51
		TestScannerProvider.sIncludes= new String[]{fCProject.getProject().getLocation().toOSString(), fCProject2.getProject().getLocation().toOSString()};
51
		TestScannerProvider.sIncludes= new String[]{fCProject.getProject().getLocation().toOSString(), fCProject2.getProject().getLocation().toOSString()};
52
	}
52
	}
53
53
54
	@Override
54
	protected void tearDown() throws Exception {
55
	protected void tearDown() throws Exception {
55
		if (fCProject2 != null) {
56
		if (fCProject2 != null) {
56
			CProjectHelper.delete(fCProject2);
57
			CProjectHelper.delete(fCProject2);
Lines 89-95 Link Here
89
		IFile sourceFile= createFile(fCProject2.getProject(), "testMethods.cpp", source);
90
		IFile sourceFile= createFile(fCProject2.getProject(), "testMethods.cpp", source);
90
		waitForIndexer(fIndex, sourceFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
91
		waitForIndexer(fIndex, sourceFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
91
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
92
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
92
		CEditor editor= (CEditor) IDE.openEditor(page, sourceFile);
93
		CEditor editor= openEditor(sourceFile);
93
		
94
		
94
		
95
		
95
		editor.selectAndReveal(source.indexOf("method"), 2);
96
		editor.selectAndReveal(source.indexOf("method"), 2);
Lines 162-168 Link Here
162
		IFile sourceFile1= createFile(fCProject.getProject(), "testMethods1.cpp", source1);
163
		IFile sourceFile1= createFile(fCProject.getProject(), "testMethods1.cpp", source1);
163
		IFile sourceFile2= createFile(fCProject2.getProject(), "testMethods2.cpp", source2);
164
		IFile sourceFile2= createFile(fCProject2.getProject(), "testMethods2.cpp", source2);
164
165
165
		CEditor editor= openFile(sourceFile1);
166
		CEditor editor= openEditor(sourceFile1);
166
		waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
167
		waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
167
		
168
		
168
		editor.selectAndReveal(source1.indexOf("method3"), 2);
169
		editor.selectAndReveal(source1.indexOf("method3"), 2);
Lines 212-218 Link Here
212
		IFile sourceFile1= createFile(fCProject2.getProject(), "testMethods1.cpp", source1);
213
		IFile sourceFile1= createFile(fCProject2.getProject(), "testMethods1.cpp", source1);
213
		IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
214
		IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
214
215
215
		CEditor editor= openFile(sourceFile1);
216
		CEditor editor= openEditor(sourceFile1);
216
		waitForIndexer(fIndex, sourceFile1, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
217
		waitForIndexer(fIndex, sourceFile1, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
217
		waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
218
		waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
218
		
219
		
Lines 273-279 Link Here
273
		IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1);
274
		IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1);
274
		IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
275
		IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2);
275
276
276
		CEditor editor= openFile(sourceFile2);
277
		CEditor editor= openEditor(sourceFile2);
277
		waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
278
		waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
278
		
279
		
279
		editor.selectAndReveal(source2.indexOf("main"), 2);
280
		editor.selectAndReveal(source2.indexOf("main"), 2);
(-)ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java (-3 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 8-14 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *    Markus Schorn - initial API and implementation
9
 *    Markus Schorn - initial API and implementation
10
 *******************************************************************************/ 
10
 *******************************************************************************/ 
11
12
package org.eclipse.cdt.ui.tests.callhierarchy;
11
package org.eclipse.cdt.ui.tests.callhierarchy;
13
12
14
import org.eclipse.core.resources.IFile;
13
import org.eclipse.core.resources.IFile;
Lines 30-35 Link Here
30
import org.eclipse.cdt.core.testplugin.CProjectHelper;
29
import org.eclipse.cdt.core.testplugin.CProjectHelper;
31
import org.eclipse.cdt.ui.CUIPlugin;
30
import org.eclipse.cdt.ui.CUIPlugin;
32
import org.eclipse.cdt.ui.tests.BaseUITestCase;
31
import org.eclipse.cdt.ui.tests.BaseUITestCase;
32
import org.eclipse.cdt.ui.tests.text.EditorTestHelper;
33
33
34
import org.eclipse.cdt.internal.ui.callhierarchy.CHViewPart;
34
import org.eclipse.cdt.internal.ui.callhierarchy.CHViewPart;
35
import org.eclipse.cdt.internal.ui.callhierarchy.CallHierarchyUI;
35
import org.eclipse.cdt.internal.ui.callhierarchy.CallHierarchyUI;
Lines 46-51 Link Here
46
		super(name);
46
		super(name);
47
	}
47
	}
48
48
49
	@Override
49
	protected void setUp() throws Exception {
50
	protected void setUp() throws Exception {
50
		super.setUp();
51
		super.setUp();
51
		CallHierarchyUI.setIsJUnitTest(true);
52
		CallHierarchyUI.setIsJUnitTest(true);
Lines 61-66 Link Here
61
		}
62
		}
62
	}
63
	}
63
	
64
	
65
	@Override
64
	protected void tearDown() throws Exception {
66
	protected void tearDown() throws Exception {
65
		closeAllEditors();
67
		closeAllEditors();
66
		if (fCProject != null) {
68
		if (fCProject != null) {
Lines 73-81 Link Here
73
		return fCProject.getProject();
75
		return fCProject.getProject();
74
	}
76
	}
75
	
77
	
76
	protected CEditor openFile(IFile file) throws PartInitException {
78
	protected CEditor openEditor(IFile file) throws PartInitException {
77
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
79
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
78
		CEditor editor= (CEditor) IDE.openEditor(page, file);
80
		CEditor editor= (CEditor) IDE.openEditor(page, file);
81
		EditorTestHelper.joinReconciler(EditorTestHelper.getSourceViewer(editor), 100, 500, 10);
79
		return editor;
82
		return editor;
80
	}	
83
	}	
81
84
(-)ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java (-3 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 8-14 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *    Markus Schorn - initial API and implementation
9
 *    Markus Schorn - initial API and implementation
10
 *******************************************************************************/ 
10
 *******************************************************************************/ 
11
12
package org.eclipse.cdt.ui.tests.callhierarchy;
11
package org.eclipse.cdt.ui.tests.callhierarchy;
13
12
14
import junit.framework.Test;
13
import junit.framework.Test;
Lines 35-41 Link Here
35
		String content = readTaggedComment("intvar");
34
		String content = readTaggedComment("intvar");
36
		IFile file= createFile(getProject(), "intvar.c", content);
35
		IFile file= createFile(getProject(), "intvar.c", content);
37
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
36
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
38
		CEditor editor = openFile(file);
37
		CEditor editor = openEditor(file);
39
38
40
		editor.selectAndReveal(content.indexOf("a"), 1);
39
		editor.selectAndReveal(content.indexOf("a"), 1);
41
		openCallHierarchy(editor);
40
		openCallHierarchy(editor);
(-)ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java (-13 / +21 lines)
Lines 15-28 Link Here
15
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IFile;
16
import org.eclipse.swt.widgets.Tree;
16
import org.eclipse.swt.widgets.Tree;
17
import org.eclipse.swt.widgets.TreeItem;
17
import org.eclipse.swt.widgets.TreeItem;
18
import org.eclipse.ui.IEditorPart;
19
import org.eclipse.ui.IPageLayout;
18
import org.eclipse.ui.IPageLayout;
20
import org.eclipse.ui.IViewPart;
19
import org.eclipse.ui.IViewPart;
21
import org.eclipse.ui.IWorkbenchPage;
22
import org.eclipse.ui.IWorkbenchWindow;
20
import org.eclipse.ui.IWorkbenchWindow;
23
import org.eclipse.ui.PlatformUI;
24
import org.eclipse.ui.WorkbenchException;
25
import org.eclipse.ui.ide.IDE;
26
21
27
import org.eclipse.cdt.core.model.ICElement;
22
import org.eclipse.cdt.core.model.ICElement;
28
import org.eclipse.cdt.ui.CUIPlugin;
23
import org.eclipse.cdt.ui.CUIPlugin;
Lines 144-156 Link Here
144
		assertTrue(obj instanceof ICElement);
139
		assertTrue(obj instanceof ICElement);
145
		CallHierarchyUI.open(workbenchWindow, (ICElement) obj);
140
		CallHierarchyUI.open(workbenchWindow, (ICElement) obj);
146
	}
141
	}
147
148
	private CEditor openEditor(IFile file) throws WorkbenchException {
149
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
150
		IEditorPart editor= IDE.openEditor(page, file, true);
151
		runEventQueue(0);
152
		return (CEditor) editor;
153
	}
154
	
142
	
155
	// class Base {
143
	// class Base {
156
	// public:
144
	// public:
Lines 345-370 Link Here
345
	//		CALL(0);
333
	//		CALL(0);
346
	//	}
334
	//	}
347
	public void testMacrosHidingCall_249801() throws Exception {
335
	public void testMacrosHidingCall_249801() throws Exception {
336
		long t= System.currentTimeMillis();
348
		String content= getContentsForTest(1)[0].toString();
337
		String content= getContentsForTest(1)[0].toString();
338
		t= printTime("contents", t);
349
		IFile file= createFile(getProject(), "file249801.cpp", content);
339
		IFile file= createFile(getProject(), "file249801.cpp", content);
340
		t= printTime("file", t);
350
		waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
341
		waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
342
		t= printTime("indexer", t);
351
343
352
		final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);
344
		final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);
353
		final IWorkbenchWindow workbenchWindow = ch.getSite().getWorkbenchWindow();
345
		t= printTime("view", t);
354
346
355
		// open editor, check outline
347
		// open editor, check outline
356
		CEditor editor= openEditor(file);
348
		CEditor editor= openEditor(file);
349
		t= printTime("editor", t);
357
		int idx = content.indexOf("MACRO(Test");
350
		int idx = content.indexOf("MACRO(Test");
358
		editor.selectAndReveal(idx, 0);
351
		editor.selectAndReveal(idx, 0);
359
		openCallHierarchy(editor, false);
352
		openCallHierarchy(editor, false);
353
		t= printTime("ch1", t);
360
354
361
		Tree chTree= checkTreeNode(ch, 0, "PREFIX_Test(char *, char *)").getParent();
355
		Tree chTree= checkTreeNode(ch, 0, "PREFIX_Test(char *, char *)").getParent();
362
		TreeItem ti= checkTreeNode(chTree, 0, 0, "call(int)");
356
		TreeItem ti= checkTreeNode(chTree, 0, 0, "call(int)");
357
		t= printTime("checked", t);
363
358
364
		idx = content.indexOf("CALL(0");
359
		idx = content.indexOf("CALL(0");
365
		editor.selectAndReveal(idx+4, 0);
360
		editor.selectAndReveal(idx+4, 0);
366
		openCallHierarchy(editor, true);
361
		openCallHierarchy(editor, true);
362
		t= printTime("ch2",t );
367
		chTree= checkTreeNode(ch, 0, "call(int)").getParent();
363
		chTree= checkTreeNode(ch, 0, "call(int)").getParent();
368
		ti= checkTreeNode(chTree, 0, 0, "PREFIX_Test(char *, char *)");
364
		ti= checkTreeNode(chTree, 0, 0, "PREFIX_Test(char *, char *)");
365
		t= printTime("checked", t);
366
	}
367
368
	/**
369
	 * mstodo
370
	 * @param string
371
	 * @return
372
	 */
373
	private long printTime(String string, long off) {
374
		long t= System.currentTimeMillis();
375
		System.out.println(string + (t-off));
376
		return t;
369
	}
377
	}
370
}
378
}
(-)ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java (-21 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 8-23 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *    Markus Schorn - initial API and implementation
9
 *    Markus Schorn - initial API and implementation
10
 *******************************************************************************/ 
10
 *******************************************************************************/ 
11
12
package org.eclipse.cdt.ui.tests.callhierarchy;
11
package org.eclipse.cdt.ui.tests.callhierarchy;
13
12
14
import junit.framework.Test;
13
import junit.framework.Test;
15
14
16
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IFile;
17
import org.eclipse.swt.widgets.Tree;
16
import org.eclipse.swt.widgets.Tree;
18
import org.eclipse.ui.IWorkbenchPage;
19
import org.eclipse.ui.PlatformUI;
20
import org.eclipse.ui.ide.IDE;
21
17
22
import org.eclipse.cdt.internal.ui.editor.CEditor;
18
import org.eclipse.cdt.internal.ui.editor.CEditor;
23
19
Lines 56-63 Link Here
56
		String content = readTaggedComment("testMethods");
52
		String content = readTaggedComment("testMethods");
57
		IFile file= createFile(getProject(), "testMethods.cpp", content);
53
		IFile file= createFile(getProject(), "testMethods.cpp", content);
58
		waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
54
		waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
59
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
55
		CEditor editor = openEditor(file);
60
		CEditor editor= (CEditor) IDE.openEditor(page, file);
61
56
62
		editor.selectAndReveal(content.indexOf("method"), 2);
57
		editor.selectAndReveal(content.indexOf("method"), 2);
63
		openCallHierarchy(editor);
58
		openCallHierarchy(editor);
Lines 140-147 Link Here
140
		String content = readTaggedComment("testStaticMethods");
135
		String content = readTaggedComment("testStaticMethods");
141
		IFile file= createFile(getProject(), "testStaticMethods.cpp", content);
136
		IFile file= createFile(getProject(), "testStaticMethods.cpp", content);
142
		waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
137
		waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
143
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
138
		CEditor editor = openEditor(file);
144
		CEditor editor= (CEditor) IDE.openEditor(page, file);
145
139
146
		editor.selectAndReveal(content.indexOf("method"), 2);
140
		editor.selectAndReveal(content.indexOf("method"), 2);
147
		openCallHierarchy(editor);
141
		openCallHierarchy(editor);
Lines 229-236 Link Here
229
		String content = readTaggedComment("testFields");
223
		String content = readTaggedComment("testFields");
230
		IFile file= createFile(getProject(), "testFields.cpp", content);
224
		IFile file= createFile(getProject(), "testFields.cpp", content);
231
		waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
225
		waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
232
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
226
		CEditor editor = openEditor(file);
233
		CEditor editor= (CEditor) IDE.openEditor(page, file);
234
227
235
		editor.selectAndReveal(content.indexOf("field"), 2);
228
		editor.selectAndReveal(content.indexOf("field"), 2);
236
		openCallHierarchy(editor);
229
		openCallHierarchy(editor);
Lines 304-311 Link Here
304
		String content = readTaggedComment("testAutomaticConstructor");
297
		String content = readTaggedComment("testAutomaticConstructor");
305
		IFile file= createFile(getProject(), "testConstructor.cpp", content);
298
		IFile file= createFile(getProject(), "testConstructor.cpp", content);
306
		waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
299
		waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
307
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
300
		CEditor editor = openEditor(file);
308
		CEditor editor= (CEditor) IDE.openEditor(page, file);
309
301
310
		editor.selectAndReveal(content.indexOf("MyClass()"), 2);
302
		editor.selectAndReveal(content.indexOf("MyClass()"), 2);
311
		openCallHierarchy(editor);
303
		openCallHierarchy(editor);
Lines 334-341 Link Here
334
		String content = readTaggedComment("testConstructor");
326
		String content = readTaggedComment("testConstructor");
335
		IFile file= createFile(getProject(), "testConstructor.cpp", content);
327
		IFile file= createFile(getProject(), "testConstructor.cpp", content);
336
		waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
328
		waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
337
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
329
		CEditor editor = openEditor(file);
338
		CEditor editor= (CEditor) IDE.openEditor(page, file);
339
330
340
		editor.selectAndReveal(content.indexOf("MyClass()"), 2);
331
		editor.selectAndReveal(content.indexOf("MyClass()"), 2);
341
		openCallHierarchy(editor);
332
		openCallHierarchy(editor);
Lines 348-355 Link Here
348
		String content = readTaggedComment("testConstructor");
339
		String content = readTaggedComment("testConstructor");
349
		IFile file= createFile(getProject(), "testConstructor.cpp", content);
340
		IFile file= createFile(getProject(), "testConstructor.cpp", content);
350
		waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
341
		waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
351
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
342
		CEditor editor = openEditor(file);
352
		CEditor editor= (CEditor) IDE.openEditor(page, file);
353
343
354
		editor.selectAndReveal(content.indexOf("~MyClass()"), 2);
344
		editor.selectAndReveal(content.indexOf("~MyClass()"), 2);
355
		openCallHierarchy(editor);
345
		openCallHierarchy(editor);
Lines 384-391 Link Here
384
		String content = readTaggedComment("testNamespace");
374
		String content = readTaggedComment("testNamespace");
385
		IFile file= createFile(getProject(), "testNamespace.cpp", content);
375
		IFile file= createFile(getProject(), "testNamespace.cpp", content);
386
		waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
376
		waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
387
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
377
		CEditor editor = openEditor(file);
388
		CEditor editor= (CEditor) IDE.openEditor(page, file);
389
378
390
		editor.selectAndReveal(content.indexOf("var"), 2);
379
		editor.selectAndReveal(content.indexOf("var"), 2);
391
		openCallHierarchy(editor);
380
		openCallHierarchy(editor);
Lines 442-449 Link Here
442
		String content = readTaggedComment("testNamespace");
431
		String content = readTaggedComment("testNamespace");
443
		IFile file= createFile(getProject(), "testNamespace.cpp", content);
432
		IFile file= createFile(getProject(), "testNamespace.cpp", content);
444
		waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
433
		waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
445
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
434
		CEditor editor = openEditor(file);
446
		CEditor editor= (CEditor) IDE.openEditor(page, file);
447
435
448
		editor.selectAndReveal(content.indexOf("var; // r1"), 2);
436
		editor.selectAndReveal(content.indexOf("var; // r1"), 2);
449
		openCallHierarchy(editor);
437
		openCallHierarchy(editor);
(-)ui/org/eclipse/cdt/ui/tests/typehierarchy/CppTypeHierarchyTest.java (-23 / +17 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 8-14 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *    Markus Schorn - initial API and implementation
9
 *    Markus Schorn - initial API and implementation
10
 *******************************************************************************/ 
10
 *******************************************************************************/ 
11
12
package org.eclipse.cdt.ui.tests.typehierarchy;
11
package org.eclipse.cdt.ui.tests.typehierarchy;
13
12
14
import junit.framework.Test;
13
import junit.framework.Test;
Lines 16-24 Link Here
16
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IFile;
17
import org.eclipse.swt.widgets.Tree;
16
import org.eclipse.swt.widgets.Tree;
18
import org.eclipse.swt.widgets.TreeItem;
17
import org.eclipse.swt.widgets.TreeItem;
19
import org.eclipse.ui.IWorkbenchPage;
20
import org.eclipse.ui.PlatformUI;
21
import org.eclipse.ui.ide.IDE;
22
18
23
import org.eclipse.cdt.internal.ui.editor.CEditor;
19
import org.eclipse.cdt.internal.ui.editor.CEditor;
24
20
Lines 57-64 Link Here
57
		String content= getContentsForTest(1)[0].toString();
53
		String content= getContentsForTest(1)[0].toString();
58
		IFile file= createFile(getProject(), "class.cpp", content);
54
		IFile file= createFile(getProject(), "class.cpp", content);
59
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
55
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
60
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
56
		CEditor editor= openEditor(file);
61
		CEditor editor= (CEditor) IDE.openEditor(page, file);
62
		Tree tree;
57
		Tree tree;
63
		TreeItem item1, item2, item3, item4;
58
		TreeItem item1, item2, item3, item4;
64
		
59
		
Lines 151-158 Link Here
151
		String content= getContentsForTest(1)[0].toString();
146
		String content= getContentsForTest(1)[0].toString();
152
		IFile file= createFile(getProject(), "classmem.cpp", content);
147
		IFile file= createFile(getProject(), "classmem.cpp", content);
153
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
148
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
154
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
149
		CEditor editor= openEditor(file);
155
		CEditor editor= (CEditor) IDE.openEditor(page, file);
156
		Tree tree;
150
		Tree tree;
157
		TreeItem item1, item2, item3, item4;
151
		TreeItem item1, item2, item3, item4;
158
		
152
		
Lines 245-252 Link Here
245
		String content= getContentsForTest(1)[0].toString();
239
		String content= getContentsForTest(1)[0].toString();
246
		IFile file= createFile(getProject(), "multi.cpp", content);
240
		IFile file= createFile(getProject(), "multi.cpp", content);
247
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
241
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
248
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
242
		
249
		CEditor editor= (CEditor) IDE.openEditor(page, file);
243
		CEditor editor= openEditor(file);
250
		Tree tree;
244
		Tree tree;
251
		TreeItem item1, item2, item3, item4;
245
		TreeItem item1, item2, item3, item4;
252
		
246
		
Lines 356-363 Link Here
356
		String content= getContentsForTest(1)[0].toString();
350
		String content= getContentsForTest(1)[0].toString();
357
		IFile file= createFile(getProject(), "multimem.cpp", content);
351
		IFile file= createFile(getProject(), "multimem.cpp", content);
358
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
352
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
359
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
353
		
360
		CEditor editor= (CEditor) IDE.openEditor(page, file);
354
		CEditor editor= openEditor(file);
361
		Tree tree;
355
		Tree tree;
362
		TreeItem item1, item2, item3, item4;
356
		TreeItem item1, item2, item3, item4;
363
		
357
		
Lines 467-474 Link Here
467
		String content= getContentsForTest(1)[0].toString();
461
		String content= getContentsForTest(1)[0].toString();
468
		IFile file= createFile(getProject(), "diamond.cpp", content);
462
		IFile file= createFile(getProject(), "diamond.cpp", content);
469
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
463
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
470
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
464
		
471
		CEditor editor= (CEditor) IDE.openEditor(page, file);
465
		CEditor editor= openEditor(file);
472
		Tree tree;
466
		Tree tree;
473
		TreeItem item1, item2, item3, item4;
467
		TreeItem item1, item2, item3, item4;
474
		
468
		
Lines 578-585 Link Here
578
		String content= getContentsForTest(1)[0].toString();
572
		String content= getContentsForTest(1)[0].toString();
579
		IFile file= createFile(getProject(), "diamondmem.cpp", content);
573
		IFile file= createFile(getProject(), "diamondmem.cpp", content);
580
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
574
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
581
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
575
		
582
		CEditor editor= (CEditor) IDE.openEditor(page, file);
576
		CEditor editor= openEditor(file);
583
		Tree tree;
577
		Tree tree;
584
		TreeItem item1, item2, item3, item4;
578
		TreeItem item1, item2, item3, item4;
585
		
579
		
Lines 686-693 Link Here
686
		String content= getContentsForTest(1)[0].toString();
680
		String content= getContentsForTest(1)[0].toString();
687
		IFile file= createFile(getProject(), "viaTypedef.cpp", content);
681
		IFile file= createFile(getProject(), "viaTypedef.cpp", content);
688
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
682
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
689
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
683
		
690
		CEditor editor= (CEditor) IDE.openEditor(page, file);
684
		CEditor editor= openEditor(file);
691
		Tree tree;
685
		Tree tree;
692
		TreeItem item1, item2, item3, item4;
686
		TreeItem item1, item2, item3, item4;
693
		
687
		
Lines 777-784 Link Here
777
		String content= getContentsForTest(1)[0].toString();
771
		String content= getContentsForTest(1)[0].toString();
778
		IFile file= createFile(getProject(), "viaTypedefmem.cpp", content);
772
		IFile file= createFile(getProject(), "viaTypedefmem.cpp", content);
779
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
773
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
780
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
774
		
781
		CEditor editor= (CEditor) IDE.openEditor(page, file);
775
		CEditor editor= openEditor(file);
782
		Tree tree;
776
		Tree tree;
783
		TreeItem item1, item2, item3, item4;
777
		TreeItem item1, item2, item3, item4;
784
		
778
		
Lines 856-863 Link Here
856
		String content= getContentsForTest(1)[0].toString();
850
		String content= getContentsForTest(1)[0].toString();
857
		IFile file= createFile(getProject(), "simpleTemplate.cpp", content);
851
		IFile file= createFile(getProject(), "simpleTemplate.cpp", content);
858
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
852
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
859
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
853
		
860
		CEditor editor= (CEditor) IDE.openEditor(page, file);
854
		CEditor editor= openEditor(file);
861
		Tree tree;
855
		Tree tree;
862
		TreeItem item1, item2, item3, item4;
856
		TreeItem item1, item2, item3, item4;
863
		
857
		
(-)ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyBaseTest.java (-3 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 8-14 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *    Markus Schorn - initial API and implementation
9
 *    Markus Schorn - initial API and implementation
10
 *******************************************************************************/ 
10
 *******************************************************************************/ 
11
12
package org.eclipse.cdt.ui.tests.typehierarchy;
11
package org.eclipse.cdt.ui.tests.typehierarchy;
13
12
14
import org.eclipse.core.resources.IFile;
13
import org.eclipse.core.resources.IFile;
Lines 37-42 Link Here
37
import org.eclipse.cdt.core.testplugin.CProjectHelper;
36
import org.eclipse.cdt.core.testplugin.CProjectHelper;
38
import org.eclipse.cdt.ui.CUIPlugin;
37
import org.eclipse.cdt.ui.CUIPlugin;
39
import org.eclipse.cdt.ui.tests.BaseUITestCase;
38
import org.eclipse.cdt.ui.tests.BaseUITestCase;
39
import org.eclipse.cdt.ui.tests.text.EditorTestHelper;
40
40
41
import org.eclipse.cdt.internal.ui.editor.CEditor;
41
import org.eclipse.cdt.internal.ui.editor.CEditor;
42
import org.eclipse.cdt.internal.ui.typehierarchy.THViewPart;
42
import org.eclipse.cdt.internal.ui.typehierarchy.THViewPart;
Lines 52-57 Link Here
52
		super(name);
52
		super(name);
53
	}
53
	}
54
54
55
	@Override
55
	protected void setUp() throws Exception {
56
	protected void setUp() throws Exception {
56
		super.setUp();
57
		super.setUp();
57
		fCProject= CProjectHelper.createCCProject("__thTest__", "bin", IPDOMManager.ID_FAST_INDEXER);
58
		fCProject= CProjectHelper.createCCProject("__thTest__", "bin", IPDOMManager.ID_FAST_INDEXER);
Lines 59-64 Link Here
59
		fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
60
		fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
60
	}
61
	}
61
	
62
	
63
	@Override
62
	protected void tearDown() throws Exception {
64
	protected void tearDown() throws Exception {
63
		closeAllEditors();
65
		closeAllEditors();
64
		if (fCProject != null) {
66
		if (fCProject != null) {
Lines 71-79 Link Here
71
		return fCProject.getProject();
73
		return fCProject.getProject();
72
	}
74
	}
73
	
75
	
74
	protected CEditor openFile(IFile file) throws PartInitException {
76
	protected CEditor openEditor(IFile file) throws PartInitException {
75
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
77
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
76
		CEditor editor= (CEditor) IDE.openEditor(page, file);
78
		CEditor editor= (CEditor) IDE.openEditor(page, file);
79
		EditorTestHelper.joinReconciler(EditorTestHelper.getSourceViewer(editor), 100, 500, 10);
77
		return editor;
80
		return editor;
78
	}	
81
	}	
79
82
(-)ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java (-7 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 8-14 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *    Markus Schorn - initial API and implementation
9
 *    Markus Schorn - initial API and implementation
10
 *******************************************************************************/ 
10
 *******************************************************************************/ 
11
12
package org.eclipse.cdt.ui.tests.typehierarchy;
11
package org.eclipse.cdt.ui.tests.typehierarchy;
13
12
14
import junit.framework.Test;
13
import junit.framework.Test;
Lines 19-27 Link Here
19
import org.eclipse.core.runtime.NullProgressMonitor;
18
import org.eclipse.core.runtime.NullProgressMonitor;
20
import org.eclipse.swt.widgets.Tree;
19
import org.eclipse.swt.widgets.Tree;
21
import org.eclipse.swt.widgets.TreeItem;
20
import org.eclipse.swt.widgets.TreeItem;
22
import org.eclipse.ui.IWorkbenchPage;
23
import org.eclipse.ui.PlatformUI;
24
import org.eclipse.ui.ide.IDE;
25
21
26
import org.eclipse.cdt.core.CCorePlugin;
22
import org.eclipse.cdt.core.CCorePlugin;
27
import org.eclipse.cdt.core.dom.IPDOMManager;
23
import org.eclipse.cdt.core.dom.IPDOMManager;
Lines 44-49 Link Here
44
		return suite(TypeHierarchyAcrossProjectsTest.class);
40
		return suite(TypeHierarchyAcrossProjectsTest.class);
45
	}
41
	}
46
	
42
	
43
	@Override
47
	protected void setUp() throws Exception {
44
	protected void setUp() throws Exception {
48
		super.setUp();
45
		super.setUp();
49
46
Lines 57-62 Link Here
57
		TestScannerProvider.sIncludes= new String[]{fCProject.getProject().getLocation().toOSString(), fCProject2.getProject().getLocation().toOSString()};
54
		TestScannerProvider.sIncludes= new String[]{fCProject.getProject().getLocation().toOSString(), fCProject2.getProject().getLocation().toOSString()};
58
	}
55
	}
59
56
57
	@Override
60
	protected void tearDown() throws Exception {
58
	protected void tearDown() throws Exception {
61
		if (fCProject2 != null) {
59
		if (fCProject2 != null) {
62
			CProjectHelper.delete(fCProject2);
60
			CProjectHelper.delete(fCProject2);
Lines 92-101 Link Here
92
		String source = content[1].toString();
90
		String source = content[1].toString();
93
		IFile headerFile= createFile(fCProject.getProject(), "simpleHeader.h", header);
91
		IFile headerFile= createFile(fCProject.getProject(), "simpleHeader.h", header);
94
		IFile sourceFile= createFile(fCProject2.getProject(), "simple.cpp", source);
92
		IFile sourceFile= createFile(fCProject2.getProject(), "simple.cpp", source);
95
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
96
		waitForIndexer(fIndex, sourceFile, TypeHierarchyBaseTest.INDEXER_WAIT_TIME);
93
		waitForIndexer(fIndex, sourceFile, TypeHierarchyBaseTest.INDEXER_WAIT_TIME);
97
		
94
		
98
		CEditor editor= (CEditor) IDE.openEditor(page, sourceFile);
95
		CEditor editor= openEditor(sourceFile);
99
		Tree tree;
96
		Tree tree;
100
		TreeItem item1, item2, item3, item4;
97
		TreeItem item1, item2, item3, item4;
101
		
98
		
(-)ui/org/eclipse/cdt/ui/tests/typehierarchy/CTypeHierarchyTest.java (-29 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 8-14 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *    Markus Schorn - initial API and implementation
9
 *    Markus Schorn - initial API and implementation
10
 *******************************************************************************/ 
10
 *******************************************************************************/ 
11
12
package org.eclipse.cdt.ui.tests.typehierarchy;
11
package org.eclipse.cdt.ui.tests.typehierarchy;
13
12
14
import junit.framework.Test;
13
import junit.framework.Test;
Lines 16-24 Link Here
16
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IFile;
17
import org.eclipse.swt.widgets.Tree;
16
import org.eclipse.swt.widgets.Tree;
18
import org.eclipse.swt.widgets.TreeItem;
17
import org.eclipse.swt.widgets.TreeItem;
19
import org.eclipse.ui.IWorkbenchPage;
20
import org.eclipse.ui.PlatformUI;
21
import org.eclipse.ui.ide.IDE;
22
18
23
import org.eclipse.cdt.internal.ui.editor.CEditor;
19
import org.eclipse.cdt.internal.ui.editor.CEditor;
24
20
Lines 41-48 Link Here
41
		String content= getContentsForTest(1)[0].toString();
37
		String content= getContentsForTest(1)[0].toString();
42
		IFile file= createFile(getProject(), "enum.c", content);
38
		IFile file= createFile(getProject(), "enum.c", content);
43
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
39
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
44
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
40
		CEditor editor= openEditor(file);
45
		CEditor editor= (CEditor) IDE.openEditor(page, file);
46
		Tree tree;
41
		Tree tree;
47
		TreeItem item;
42
		TreeItem item;
48
		
43
		
Lines 78-85 Link Here
78
		String content= getContentsForTest(1)[0].toString();
73
		String content= getContentsForTest(1)[0].toString();
79
		IFile file= createFile(getProject(), "enummem.c", content);
74
		IFile file= createFile(getProject(), "enummem.c", content);
80
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
75
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
81
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
76
		CEditor editor= openEditor(file);
82
		CEditor editor= (CEditor) IDE.openEditor(page, file);
83
		Tree tree;
77
		Tree tree;
84
		TreeItem item;
78
		TreeItem item;
85
		
79
		
Lines 115-122 Link Here
115
		String content= getContentsForTest(1)[0].toString();
109
		String content= getContentsForTest(1)[0].toString();
116
		IFile file= createFile(getProject(), "enum.cpp", content);
110
		IFile file= createFile(getProject(), "enum.cpp", content);
117
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
111
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
118
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
112
		CEditor editor= openEditor(file);
119
		CEditor editor= (CEditor) IDE.openEditor(page, file);
120
		Tree tree;
113
		Tree tree;
121
		TreeItem item;
114
		TreeItem item;
122
		
115
		
Lines 152-159 Link Here
152
		String content= getContentsForTest(1)[0].toString();
145
		String content= getContentsForTest(1)[0].toString();
153
		IFile file= createFile(getProject(), "enummem.cpp", content);
146
		IFile file= createFile(getProject(), "enummem.cpp", content);
154
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
147
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
155
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
148
		CEditor editor= openEditor(file);
156
		CEditor editor= (CEditor) IDE.openEditor(page, file);
157
		Tree tree;
149
		Tree tree;
158
		TreeItem item;
150
		TreeItem item;
159
		
151
		
Lines 197-204 Link Here
197
		String content= getContentsForTest(1)[0].toString();
189
		String content= getContentsForTest(1)[0].toString();
198
		IFile file= createFile(getProject(), "struct.c", content);
190
		IFile file= createFile(getProject(), "struct.c", content);
199
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
191
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
200
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
192
		CEditor editor= openEditor(file);
201
		CEditor editor= (CEditor) IDE.openEditor(page, file);
202
193
203
		editor.selectAndReveal(content.indexOf("S1"), 1);
194
		editor.selectAndReveal(content.indexOf("S1"), 1);
204
		openTypeHierarchy(editor);
195
		openTypeHierarchy(editor);
Lines 252-259 Link Here
252
		String content= getContentsForTest(1)[0].toString();
243
		String content= getContentsForTest(1)[0].toString();
253
		IFile file= createFile(getProject(), "structmem.c", content);
244
		IFile file= createFile(getProject(), "structmem.c", content);
254
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
245
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
255
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
246
		CEditor editor= openEditor(file);
256
		CEditor editor= (CEditor) IDE.openEditor(page, file);
257
247
258
		editor.selectAndReveal(content.indexOf("a1"), 1);
248
		editor.selectAndReveal(content.indexOf("a1"), 1);
259
		openTypeHierarchy(editor);
249
		openTypeHierarchy(editor);
Lines 287-294 Link Here
287
		String content= getContentsForTest(1)[0].toString();
277
		String content= getContentsForTest(1)[0].toString();
288
		IFile file= createFile(getProject(), "struct.cpp", content);
278
		IFile file= createFile(getProject(), "struct.cpp", content);
289
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
279
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
290
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
280
		CEditor editor= openEditor(file);
291
		CEditor editor= (CEditor) IDE.openEditor(page, file);
292
281
293
		editor.selectAndReveal(content.indexOf("S1"), 1);
282
		editor.selectAndReveal(content.indexOf("S1"), 1);
294
		openTypeHierarchy(editor);
283
		openTypeHierarchy(editor);
Lines 343-350 Link Here
343
		String content= getContentsForTest(1)[0].toString();
332
		String content= getContentsForTest(1)[0].toString();
344
		IFile file= createFile(getProject(), "structmem.cpp", content);
333
		IFile file= createFile(getProject(), "structmem.cpp", content);
345
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
334
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
346
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
335
		CEditor editor= openEditor(file);
347
		CEditor editor= (CEditor) IDE.openEditor(page, file);
348
336
349
		editor.selectAndReveal(content.indexOf("a1"), 1);
337
		editor.selectAndReveal(content.indexOf("a1"), 1);
350
		openTypeHierarchy(editor);
338
		openTypeHierarchy(editor);
Lines 378-385 Link Here
378
		String content= getContentsForTest(1)[0].toString();
366
		String content= getContentsForTest(1)[0].toString();
379
		IFile file= createFile(getProject(), "union.c", content);
367
		IFile file= createFile(getProject(), "union.c", content);
380
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
368
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
381
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
369
		CEditor editor= openEditor(file);
382
		CEditor editor= (CEditor) IDE.openEditor(page, file);
383
370
384
		editor.selectAndReveal(content.indexOf("U1"), 1);
371
		editor.selectAndReveal(content.indexOf("U1"), 1);
385
		openTypeHierarchy(editor);
372
		openTypeHierarchy(editor);
Lines 429-436 Link Here
429
		String content= getContentsForTest(1)[0].toString();
416
		String content= getContentsForTest(1)[0].toString();
430
		IFile file= createFile(getProject(), "unionmem.c", content);
417
		IFile file= createFile(getProject(), "unionmem.c", content);
431
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
418
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
432
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
419
		CEditor editor= openEditor(file);
433
		CEditor editor= (CEditor) IDE.openEditor(page, file);
434
420
435
		editor.selectAndReveal(content.indexOf("a1"), 1);
421
		editor.selectAndReveal(content.indexOf("a1"), 1);
436
		openTypeHierarchy(editor);
422
		openTypeHierarchy(editor);
Lines 456-463 Link Here
456
		String content= getContentsForTest(1)[0].toString();
442
		String content= getContentsForTest(1)[0].toString();
457
		IFile file= createFile(getProject(), "union.cpp", content);
443
		IFile file= createFile(getProject(), "union.cpp", content);
458
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
444
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
459
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
445
		CEditor editor= openEditor(file);
460
		CEditor editor= (CEditor) IDE.openEditor(page, file);
461
446
462
		editor.selectAndReveal(content.indexOf("U1"), 1);
447
		editor.selectAndReveal(content.indexOf("U1"), 1);
463
		openTypeHierarchy(editor);
448
		openTypeHierarchy(editor);
Lines 516-523 Link Here
516
		String content= getContentsForTest(1)[0].toString();
501
		String content= getContentsForTest(1)[0].toString();
517
		IFile file= createFile(getProject(), "unionmem.cpp", content);
502
		IFile file= createFile(getProject(), "unionmem.cpp", content);
518
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
503
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
519
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
504
		CEditor editor= openEditor(file);
520
		CEditor editor= (CEditor) IDE.openEditor(page, file);
521
505
522
		editor.selectAndReveal(content.indexOf("a1"), 1);
506
		editor.selectAndReveal(content.indexOf("a1"), 1);
523
		openTypeHierarchy(editor);
507
		openTypeHierarchy(editor);
(-)ui/org/eclipse/cdt/ui/tests/typehierarchy/QuickTypeHierarchyTest.java (-21 / +17 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 8-14 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *    Markus Schorn - initial API and implementation
9
 *    Markus Schorn - initial API and implementation
10
 *******************************************************************************/ 
10
 *******************************************************************************/ 
11
12
package org.eclipse.cdt.ui.tests.typehierarchy;
11
package org.eclipse.cdt.ui.tests.typehierarchy;
13
12
14
import junit.framework.Test;
13
import junit.framework.Test;
Lines 17-25 Link Here
17
import org.eclipse.core.runtime.Platform;
16
import org.eclipse.core.runtime.Platform;
18
import org.eclipse.swt.widgets.Tree;
17
import org.eclipse.swt.widgets.Tree;
19
import org.eclipse.swt.widgets.TreeItem;
18
import org.eclipse.swt.widgets.TreeItem;
20
import org.eclipse.ui.IWorkbenchPage;
21
import org.eclipse.ui.PlatformUI;
22
import org.eclipse.ui.ide.IDE;
23
19
24
import org.eclipse.cdt.internal.ui.editor.CEditor;
20
import org.eclipse.cdt.internal.ui.editor.CEditor;
25
21
Lines 58-65 Link Here
58
		String content= getContentsForTest(1)[0].toString();
54
		String content= getContentsForTest(1)[0].toString();
59
		IFile file= createFile(getProject(), "class.cpp", content);
55
		IFile file= createFile(getProject(), "class.cpp", content);
60
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
56
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
61
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
57
		
62
		CEditor editor= (CEditor) IDE.openEditor(page, file);
58
		CEditor editor= openEditor(file);
63
		Tree tree;
59
		Tree tree;
64
		TreeItem item1, item2, item3, item4;
60
		TreeItem item1, item2, item3, item4;
65
		
61
		
Lines 154-161 Link Here
154
		String content= getContentsForTest(1)[0].toString();
150
		String content= getContentsForTest(1)[0].toString();
155
		IFile file= createFile(getProject(), "classmem.cpp", content);
151
		IFile file= createFile(getProject(), "classmem.cpp", content);
156
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
152
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
157
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
153
		
158
		CEditor editor= (CEditor) IDE.openEditor(page, file);
154
		CEditor editor= openEditor(file);
159
		Tree tree;
155
		Tree tree;
160
		TreeItem item1, item2, item3, item4;
156
		TreeItem item1, item2, item3, item4;
161
		
157
		
Lines 251-258 Link Here
251
		String content= getContentsForTest(1)[0].toString();
247
		String content= getContentsForTest(1)[0].toString();
252
		IFile file= createFile(getProject(), "multi.cpp", content);
248
		IFile file= createFile(getProject(), "multi.cpp", content);
253
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
249
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
254
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
250
		
255
		CEditor editor= (CEditor) IDE.openEditor(page, file);
251
		CEditor editor= openEditor(file);
256
		Tree tree;
252
		Tree tree;
257
		TreeItem item1, item2, item3, item4;
253
		TreeItem item1, item2, item3, item4;
258
		
254
		
Lines 362-369 Link Here
362
		String content= getContentsForTest(1)[0].toString();
358
		String content= getContentsForTest(1)[0].toString();
363
		IFile file= createFile(getProject(), "multimem.cpp", content);
359
		IFile file= createFile(getProject(), "multimem.cpp", content);
364
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
360
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
365
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
361
		
366
		CEditor editor= (CEditor) IDE.openEditor(page, file);
362
		CEditor editor= openEditor(file);
367
		Tree tree;
363
		Tree tree;
368
		TreeItem item1, item2, item3, item4;
364
		TreeItem item1, item2, item3, item4;
369
		
365
		
Lines 473-480 Link Here
473
		String content= getContentsForTest(1)[0].toString();
469
		String content= getContentsForTest(1)[0].toString();
474
		IFile file= createFile(getProject(), "diamond.cpp", content);
470
		IFile file= createFile(getProject(), "diamond.cpp", content);
475
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
471
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
476
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
472
		
477
		CEditor editor= (CEditor) IDE.openEditor(page, file);
473
		CEditor editor= openEditor(file);
478
		Tree tree;
474
		Tree tree;
479
		TreeItem item1, item2, item3, item4;
475
		TreeItem item1, item2, item3, item4;
480
		
476
		
Lines 584-591 Link Here
584
		String content= getContentsForTest(1)[0].toString();
580
		String content= getContentsForTest(1)[0].toString();
585
		IFile file= createFile(getProject(), "diamondmem.cpp", content);
581
		IFile file= createFile(getProject(), "diamondmem.cpp", content);
586
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
582
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
587
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
583
		
588
		CEditor editor= (CEditor) IDE.openEditor(page, file);
584
		CEditor editor= openEditor(file);
589
		Tree tree;
585
		Tree tree;
590
		TreeItem item1, item2, item3, item4;
586
		TreeItem item1, item2, item3, item4;
591
		
587
		
Lines 689-696 Link Here
689
		String content= getContentsForTest(1)[0].toString();
685
		String content= getContentsForTest(1)[0].toString();
690
		IFile file= createFile(getProject(), "viaTypedef.cpp", content);
686
		IFile file= createFile(getProject(), "viaTypedef.cpp", content);
691
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
687
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
692
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
688
		
693
		CEditor editor= (CEditor) IDE.openEditor(page, file);
689
		CEditor editor= openEditor(file);
694
		Tree tree;
690
		Tree tree;
695
		TreeItem item1, item2, item3, item4;
691
		TreeItem item1, item2, item3, item4;
696
		
692
		
Lines 783-790 Link Here
783
		String content= getContentsForTest(1)[0].toString();
779
		String content= getContentsForTest(1)[0].toString();
784
		IFile file= createFile(getProject(), "viaTypedefmem.cpp", content);
780
		IFile file= createFile(getProject(), "viaTypedefmem.cpp", content);
785
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
781
		waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
786
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
782
		
787
		CEditor editor= (CEditor) IDE.openEditor(page, file);
783
		CEditor editor= openEditor(file);
788
		Tree tree;
784
		Tree tree;
789
		TreeItem item1, item2, item3, item4;
785
		TreeItem item1, item2, item3, item4;
790
		
786
		
(-)ui/org/eclipse/cdt/ui/tests/text/HyperlinkTest.java (+2 lines)
Lines 92-99 Link Here
92
		assertNotNull(file);
92
		assertNotNull(file);
93
		assertTrue(file.exists());
93
		assertTrue(file.exists());
94
		editor = (CEditor)EditorTestHelper.openInEditor(file, true);
94
		editor = (CEditor)EditorTestHelper.openInEditor(file, true);
95
		EditorTestHelper.joinReconciler(EditorTestHelper.getSourceViewer(editor), 100, 500, 10);
95
	}
96
	}
96
	
97
	
98
	@Override
97
	protected void tearDown() throws Exception {
99
	protected void tearDown() throws Exception {
98
		EditorTestHelper.closeEditor(editor);
100
		EditorTestHelper.closeEditor(editor);
99
		CProjectHelper.delete(project);
101
		CProjectHelper.delete(project);
(-)ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java (-17 / +25 lines)
Lines 6-13 Link Here
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM - Initial API and implementation
9
 *    IBM - Initial API and implementation
10
 * Markus Schorn (Wind River Systems)
10
 *    Markus Schorn (Wind River Systems)
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.cdt.ui.tests.text.selection;
12
package org.eclipse.cdt.ui.tests.text.selection;
13
13
Lines 36-41 Link Here
36
import org.eclipse.search2.internal.ui.SearchView;
36
import org.eclipse.search2.internal.ui.SearchView;
37
import org.eclipse.ui.IEditorInput;
37
import org.eclipse.ui.IEditorInput;
38
import org.eclipse.ui.IEditorPart;
38
import org.eclipse.ui.IEditorPart;
39
import org.eclipse.ui.IViewReference;
39
import org.eclipse.ui.IWorkbenchPage;
40
import org.eclipse.ui.IWorkbenchPage;
40
import org.eclipse.ui.PartInitException;
41
import org.eclipse.ui.PartInitException;
41
import org.eclipse.ui.PlatformUI;
42
import org.eclipse.ui.PlatformUI;
Lines 46-62 Link Here
46
import org.eclipse.cdt.core.dom.ast.IASTName;
47
import org.eclipse.cdt.core.dom.ast.IASTName;
47
import org.eclipse.cdt.core.dom.ast.IASTNode;
48
import org.eclipse.cdt.core.dom.ast.IASTNode;
48
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
49
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
49
import org.eclipse.cdt.core.model.CoreModel;
50
import org.eclipse.cdt.core.model.ICProject;
50
import org.eclipse.cdt.core.model.ICProject;
51
import org.eclipse.cdt.core.model.ILanguage;
51
import org.eclipse.cdt.core.model.ILanguage;
52
import org.eclipse.cdt.core.model.ITranslationUnit;
52
import org.eclipse.cdt.core.model.ITranslationUnit;
53
import org.eclipse.cdt.core.testplugin.FileManager;
53
import org.eclipse.cdt.core.testplugin.FileManager;
54
import org.eclipse.cdt.ui.tests.BaseUITestCase;
54
import org.eclipse.cdt.ui.tests.BaseUITestCase;
55
import org.eclipse.cdt.ui.tests.text.EditorTestHelper;
55
56
56
import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
57
import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
57
import org.eclipse.cdt.internal.core.parser.ParserException;
58
import org.eclipse.cdt.internal.core.parser.ParserException;
58
59
59
import org.eclipse.cdt.internal.ui.editor.ASTProvider;
60
import org.eclipse.cdt.internal.ui.editor.ASTProvider;
61
import org.eclipse.cdt.internal.ui.editor.CEditor;
60
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
62
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
61
import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
63
import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
62
64
Lines 74-83 Link Here
74
		super(name);
76
		super(name);
75
	}
77
	}
76
	
78
	
79
	@Override
77
	protected void setUp() throws Exception {
80
	protected void setUp() throws Exception {
78
		super.setUp();
81
		super.setUp();
79
		OpenDeclarationsAction.sIsJUnitTest= true;
82
		OpenDeclarationsAction.sIsJUnitTest= true;
80
		OpenDeclarationsAction.sAllowFallback= false;
83
		OpenDeclarationsAction.sAllowFallback= false;
84
		IWorkbenchPage page= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
85
		IViewReference[] refs= page.getViewReferences();
86
		for (int i = 0; i < refs.length; i++) {
87
			IViewReference viewReference = refs[i];
88
			page.setPartState(viewReference, IWorkbenchPage.STATE_RESTORED);
89
		}
81
	}
90
	}
82
	
91
	
83
	public void waitForIndex(int maxSec) throws Exception {
92
	public void waitForIndex(int maxSec) throws Exception {
Lines 192-225 Link Here
192
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
201
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
193
        IEditorPart part = null;
202
        IEditorPart part = null;
194
        try {
203
        try {
195
            part = page.openEditor(new FileEditorInput(file), "org.eclipse.cdt.ui.editor.CEditor"); //$NON-NLS-1$
204
            part = page.openEditor(new FileEditorInput(file), "org.eclipse.cdt.ui.editor.CEditor", true); //$NON-NLS-1$
196
        } catch (PartInitException e) {
205
        } catch (PartInitException e) {
197
            assertFalse(true);
206
            assertFalse(true);
198
        }
207
        }
199
        
208
        
200
        if (part instanceof AbstractTextEditor) {
209
        if (part instanceof CEditor) {
210
        	CEditor editor= (CEditor) part;
211
    		EditorTestHelper.joinReconciler(EditorTestHelper.getSourceViewer(editor), 100, 500, 10);
201
            ((AbstractTextEditor)part).getSelectionProvider().setSelection(new TextSelection(offset,length));
212
            ((AbstractTextEditor)part).getSelectionProvider().setSelection(new TextSelection(offset,length));
202
            
213
            
203
            final OpenDeclarationsAction action = (OpenDeclarationsAction) ((AbstractTextEditor)part).getAction("OpenDeclarations"); //$NON-NLS-1$
214
            final OpenDeclarationsAction action = (OpenDeclarationsAction) editor.getAction("OpenDeclarations"); //$NON-NLS-1$
204
            action.runSync();
215
            action.runSync();
205
        
216
        
206
        	// update the file/part to point to the newly opened IFile/IEditorPart
217
        	// update the file/part to point to the newly opened IFile/IEditorPart
207
            part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); 
218
            part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); 
208
            IEditorInput input = part.getEditorInput(); 
219
            assertTrue (part instanceof CEditor);
209
            if (input instanceof FileEditorInput) {
220
            editor= (CEditor) part;
210
            	file = ((FileEditorInput)input).getFile();
221
    		EditorTestHelper.joinReconciler(EditorTestHelper.getSourceViewer(editor), 100, 500, 10);
211
            } else {
222
212
            	assertFalse(true); // bail!
223
    		// the action above should highlight the declaration, so now retrieve it and use that selection to get the IASTName selected on the TU
213
            }             
224
            ISelection sel= editor.getSelectionProvider().getSelection();
214
            
215
            // the action above should highlight the declaration, so now retrieve it and use that selection to get the IASTName selected on the TU
216
            ISelection sel = ((AbstractTextEditor)part).getSelectionProvider().getSelection();
217
            
225
            
218
            final IASTName[] result= {null};
226
            final IASTName[] result= {null};
219
            if (sel instanceof ITextSelection) {
227
            if (sel instanceof ITextSelection) {
220
            	final ITextSelection textSel = (ITextSelection)sel;
228
            	final ITextSelection textSel = (ITextSelection)sel;
221
            	ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(file);
229
            	ITranslationUnit tu = (ITranslationUnit)editor.getInputCElement();
222
        		IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_YES, monitor, new ASTRunnable() {
230
        		IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, monitor, new ASTRunnable() {
223
        			public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
231
        			public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
224
        				result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());
232
        				result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());
225
        				return Status.OK_STATUS;
233
        				return Status.OK_STATUS;
(-)ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java (-1 / +3 lines)
Lines 56-61 Link Here
56
import org.eclipse.cdt.core.testplugin.FileManager;
56
import org.eclipse.cdt.core.testplugin.FileManager;
57
import org.eclipse.cdt.ui.CUIPlugin;
57
import org.eclipse.cdt.ui.CUIPlugin;
58
import org.eclipse.cdt.ui.tests.BaseUITestCase;
58
import org.eclipse.cdt.ui.tests.BaseUITestCase;
59
import org.eclipse.cdt.ui.tests.text.EditorTestHelper;
59
60
60
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
61
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
61
import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
62
import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
Lines 248-253 Link Here
248
        IEditorPart part = null;
249
        IEditorPart part = null;
249
        try {
250
        try {
250
            part = page.openEditor(new FileEditorInput(file), "org.eclipse.cdt.ui.editor.CEditor"); //$NON-NLS-1$
251
            part = page.openEditor(new FileEditorInput(file), "org.eclipse.cdt.ui.editor.CEditor"); //$NON-NLS-1$
252
    		EditorTestHelper.joinReconciler(EditorTestHelper.getSourceViewer((AbstractTextEditor) part), 100, 500, 10);
251
        } catch (PartInitException e) {
253
        } catch (PartInitException e) {
252
            assertFalse(true);
254
            assertFalse(true);
253
        }
255
        }
Lines 266-272 Link Here
266
            if (sel instanceof ITextSelection) {
268
            if (sel instanceof ITextSelection) {
267
            	final ITextSelection textSel = (ITextSelection)sel;
269
            	final ITextSelection textSel = (ITextSelection)sel;
268
            	ITranslationUnit tu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
270
            	ITranslationUnit tu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
269
        		IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_YES, monitor, new ASTRunnable() {
271
        		IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, monitor, new ASTRunnable() {
270
        			public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
272
        			public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
271
        				result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());        	
273
        				result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());        	
272
        				return Status.OK_STATUS;
274
        				return Status.OK_STATUS;
(-)ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java (-6 / +9 lines)
Lines 44-62 Link Here
44
import org.eclipse.cdt.core.dom.ast.IASTName;
44
import org.eclipse.cdt.core.dom.ast.IASTName;
45
import org.eclipse.cdt.core.dom.ast.IASTNode;
45
import org.eclipse.cdt.core.dom.ast.IASTNode;
46
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
46
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
47
import org.eclipse.cdt.core.model.CoreModel;
48
import org.eclipse.cdt.core.model.ICProject;
47
import org.eclipse.cdt.core.model.ICProject;
49
import org.eclipse.cdt.core.model.ILanguage;
48
import org.eclipse.cdt.core.model.ILanguage;
50
import org.eclipse.cdt.core.model.ITranslationUnit;
49
import org.eclipse.cdt.core.model.ITranslationUnit;
51
import org.eclipse.cdt.core.testplugin.CProjectHelper;
50
import org.eclipse.cdt.core.testplugin.CProjectHelper;
52
import org.eclipse.cdt.core.testplugin.FileManager;
51
import org.eclipse.cdt.core.testplugin.FileManager;
53
import org.eclipse.cdt.ui.tests.BaseUITestCase;
52
import org.eclipse.cdt.ui.tests.BaseUITestCase;
53
import org.eclipse.cdt.ui.tests.text.EditorTestHelper;
54
54
55
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
55
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
56
import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
56
import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
57
import org.eclipse.cdt.internal.core.parser.ParserException;
57
import org.eclipse.cdt.internal.core.parser.ParserException;
58
58
59
import org.eclipse.cdt.internal.ui.editor.ASTProvider;
59
import org.eclipse.cdt.internal.ui.editor.ASTProvider;
60
import org.eclipse.cdt.internal.ui.editor.CEditor;
60
import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
61
import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
61
62
62
/**
63
/**
Lines 275-284 Link Here
275
            assertFalse(true);
276
            assertFalse(true);
276
        }
277
        }
277
        
278
        
278
        if (part instanceof AbstractTextEditor) {
279
        if (part instanceof CEditor) {
279
            ((AbstractTextEditor)part).getSelectionProvider().setSelection(new TextSelection(offset,length));
280
        	CEditor editor= (CEditor) part;
281
    		EditorTestHelper.joinReconciler(EditorTestHelper.getSourceViewer(editor), 100, 500, 10);
282
            editor.getSelectionProvider().setSelection(new TextSelection(offset,length));
280
            
283
            
281
            final OpenDeclarationsAction action = (OpenDeclarationsAction) ((AbstractTextEditor)part).getAction("OpenDeclarations"); //$NON-NLS-1$
284
            final OpenDeclarationsAction action = (OpenDeclarationsAction) editor.getAction("OpenDeclarations"); //$NON-NLS-1$
282
            action.runSync();
285
            action.runSync();
283
        
286
        
284
            // the action above should highlight the declaration, so now retrieve it and use that selection to get the IASTName selected on the TU
287
            // the action above should highlight the declaration, so now retrieve it and use that selection to get the IASTName selected on the TU
Lines 287-294 Link Here
287
            final IASTName[] result= {null};
290
            final IASTName[] result= {null};
288
            if (sel instanceof ITextSelection) {
291
            if (sel instanceof ITextSelection) {
289
            	final ITextSelection textSel = (ITextSelection)sel;
292
            	final ITextSelection textSel = (ITextSelection)sel;
290
            	ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(file);
293
            	ITranslationUnit tu = (ITranslationUnit) editor.getInputCElement();
291
        		IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_YES, monitor, new ASTRunnable() {
294
        		IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, monitor, new ASTRunnable() {
292
        			public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
295
        			public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
293
        				result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());
296
        				result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());
294
        				return Status.OK_STATUS;
297
        				return Status.OK_STATUS;
(-)parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java (-1 / +1 lines)
Lines 100-106 Link Here
100
	private IASTTranslationUnit parse(CodeReader codeReader, ParserLanguage lang, boolean useGNUExtensions, 
100
	private IASTTranslationUnit parse(CodeReader codeReader, ParserLanguage lang, boolean useGNUExtensions, 
101
			boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings, String[] problems) throws ParserException {
101
			boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings, String[] problems) throws ParserException {
102
        ScannerInfo scannerInfo = new ScannerInfo();
102
        ScannerInfo scannerInfo = new ScannerInfo();
103
        IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo, false);
103
        IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
104
        
104
        
105
        ISourceCodeParser parser2 = null;
105
        ISourceCodeParser parser2 = null;
106
        if( lang == ParserLanguage.CPP )
106
        if( lang == ParserLanguage.CPP )
(-)parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java (+31 lines)
Lines 5500-5503 Link Here
5500
			parseAndCheckBindings(code, lang);
5500
			parseAndCheckBindings(code, lang);
5501
		}
5501
		}
5502
	}
5502
	}
5503
	
5504
	// int a[]= {
5505
	
5506
	// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
5507
	
5508
	// };
5509
	public void testScalabilityOfLargeTrivialInitializer_Bug252970() throws Exception {
5510
		final StringBuffer[] input = getContents(3);
5511
		StringBuilder buf= new StringBuilder();
5512
		buf.append(input[0].toString());
5513
		final String line= input[1].toString();
5514
		for (int i = 0; i < 25000; i++) { // 250K values
5515
			buf.append(line);
5516
		}
5517
		buf.append(input[2].toString());
5518
		final String code= buf.toString();
5519
		long mem= memoryUsed();
5520
		for (ParserLanguage lang : ParserLanguage.values()) {
5521
			IASTTranslationUnit tu= parse(code, lang, false, true, true);
5522
			long diff= memoryUsed()-mem;
5523
			final int expected = 1024*10 + code.length()*2; // a copy of the buffer + some
5524
			assertTrue(String.valueOf(diff) + " expected < " + expected, diff < expected);
5525
		}
5526
	}
5527
5528
	private long memoryUsed() {
5529
		System.gc();System.gc();System.gc();
5530
		final Runtime runtime = Runtime.getRuntime();
5531
		return runtime.totalMemory()-runtime.freeMemory();
5532
	}
5533
5503
}
5534
}
(-)parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java (-9 / +11 lines)
Lines 54-60 Link Here
54
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
54
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
55
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
55
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
56
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
56
import org.eclipse.cdt.core.dom.parser.IScannerExtensionConfiguration;
57
import org.eclipse.cdt.core.dom.parser.ISourceCodeParser;
58
import org.eclipse.cdt.core.dom.parser.c.ANSICParserExtensionConfiguration;
57
import org.eclipse.cdt.core.dom.parser.c.ANSICParserExtensionConfiguration;
59
import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration;
58
import org.eclipse.cdt.core.dom.parser.c.GCCParserExtensionConfiguration;
60
import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration;
59
import org.eclipse.cdt.core.dom.parser.c.GCCScannerExtensionConfiguration;
Lines 75-80 Link Here
75
import org.eclipse.cdt.core.testplugin.CTestPlugin;
74
import org.eclipse.cdt.core.testplugin.CTestPlugin;
76
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
75
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
77
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
76
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
77
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
78
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
78
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
79
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
79
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
80
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
80
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
Lines 116-132 Link Here
116
    }
116
    }
117
    
117
    
118
    protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
118
    protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
119
    		boolean expectNoProblems, boolean parseComments) throws ParserException {
119
    		boolean expectNoProblems, boolean skipTrivialInitializers) throws ParserException {
120
        IScanner scanner = createScanner(new CodeReader(code.toCharArray()), lang, ParserMode.COMPLETE_PARSE, 
120
        IScanner scanner = createScanner(new CodeReader(code.toCharArray()), lang, ParserMode.COMPLETE_PARSE, 
121
        		new ScannerInfo(), parseComments);
121
        		new ScannerInfo());
122
        ISourceCodeParser parser2 = null;
122
        AbstractGNUSourceCodeParser parser = null;
123
        if (lang == ParserLanguage.CPP) {
123
        if (lang == ParserLanguage.CPP) {
124
            ICPPParserExtensionConfiguration config = null;
124
            ICPPParserExtensionConfiguration config = null;
125
            if (useGNUExtensions)
125
            if (useGNUExtensions)
126
            	config = new GPPParserExtensionConfiguration();
126
            	config = new GPPParserExtensionConfiguration();
127
            else
127
            else
128
            	config = new ANSICPPParserExtensionConfiguration();
128
            	config = new ANSICPPParserExtensionConfiguration();
129
            parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG,config, null);
129
            parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG,config, null);
130
        } else {
130
        } else {
131
            ICParserExtensionConfiguration config = null;
131
            ICParserExtensionConfiguration config = null;
132
132
Lines 135-146 Link Here
135
            else
135
            else
136
            	config = new ANSICParserExtensionConfiguration();
136
            	config = new ANSICParserExtensionConfiguration();
137
            
137
            
138
            parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
138
            parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
139
        }
139
        }
140
        if (skipTrivialInitializers)
141
        	parser.setSkipTrivialExpressionsInAggregateInitializers(true);
140
        
142
        
141
        IASTTranslationUnit tu = parser2.parse();
143
        IASTTranslationUnit tu = parser.parse();
142
144
143
        if (parser2.encounteredError() && expectNoProblems)
145
        if (parser.encounteredError() && expectNoProblems)
144
            throw new ParserException("FAILURE"); //$NON-NLS-1$
146
            throw new ParserException("FAILURE"); //$NON-NLS-1$
145
         
147
         
146
        if (lang == ParserLanguage.C && expectNoProblems) {
148
        if (lang == ParserLanguage.C && expectNoProblems) {
Lines 157-163 Link Here
157
    }
159
    }
158
160
159
	public static IScanner createScanner(CodeReader codeReader, ParserLanguage lang, ParserMode mode,
161
	public static IScanner createScanner(CodeReader codeReader, ParserLanguage lang, ParserMode mode,
160
			IScannerInfo scannerInfo, boolean parseComments) {
162
			IScannerInfo scannerInfo) {
161
		IScannerExtensionConfiguration configuration = null;
163
		IScannerExtensionConfiguration configuration = null;
162
        if (lang == ParserLanguage.C)
164
        if (lang == ParserLanguage.C)
163
            configuration= GCCScannerExtensionConfiguration.getInstance();
165
            configuration= GCCScannerExtensionConfiguration.getInstance();
(-)parser/org/eclipse/cdt/core/parser/tests/ast2/QuickParser2Tests.java (-1 / +1 lines)
Lines 1355-1361 Link Here
1355
1355
1356
        CodeReader codeReader = new CodeReader( code.toCharArray() );
1356
        CodeReader codeReader = new CodeReader( code.toCharArray() );
1357
        IScannerInfo scannerInfo = new ScannerInfo();
1357
        IScannerInfo scannerInfo = new ScannerInfo();
1358
        IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo, false);
1358
        IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
1359
        ISourceCodeParser parser2 = null;
1359
        ISourceCodeParser parser2 = null;
1360
        if (lang == ParserLanguage.CPP) {
1360
        if (lang == ParserLanguage.CPP) {
1361
            ICPPParserExtensionConfiguration config = null;
1361
            ICPPParserExtensionConfiguration config = null;
(-)parser/org/eclipse/cdt/core/parser/tests/ast2/ASTNodeSelectorTest.java (-1 / +1 lines)
Lines 55-61 Link Here
55
		fCode= getContents(1)[0].toString();
55
		fCode= getContents(1)[0].toString();
56
        CodeReader codeReader = new CodeReader(fCode.toCharArray());
56
        CodeReader codeReader = new CodeReader(fCode.toCharArray());
57
        ScannerInfo scannerInfo = new ScannerInfo();
57
        ScannerInfo scannerInfo = new ScannerInfo();
58
        IScanner scanner= AST2BaseTest.createScanner(codeReader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, scannerInfo, false);
58
        IScanner scanner= AST2BaseTest.createScanner(codeReader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, scannerInfo);
59
        GNUCPPSourceParser parser= new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, new NullLogService(), new GPPParserExtensionConfiguration());
59
        GNUCPPSourceParser parser= new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, new NullLogService(), new GPPParserExtensionConfiguration());
60
        fTu= parser.parse();
60
        fTu= parser.parse();
61
        fSelector= fTu.getNodeSelector(null);
61
        fSelector= fTu.getNodeSelector(null);
(-)parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseBaseTest.java (-1 / +1 lines)
Lines 83-89 Link Here
83
        CodeReader codeReader = new CodeReader(code
83
        CodeReader codeReader = new CodeReader(code
84
                .toCharArray());
84
                .toCharArray());
85
        ScannerInfo scannerInfo = new ScannerInfo();
85
        ScannerInfo scannerInfo = new ScannerInfo();
86
        IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo, false);
86
        IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
87
        
87
        
88
        ISourceCodeParser parser2 = null;
88
        ISourceCodeParser parser2 = null;
89
        if( lang == ParserLanguage.CPP )
89
        if( lang == ParserLanguage.CPP )
(-)parser/org/eclipse/cdt/core/parser/tests/ast2/CompleteParser2Tests.java (-1 / +1 lines)
Lines 180-186 Link Here
180
                .toCharArray());
180
                .toCharArray());
181
        ScannerInfo scannerInfo = new ScannerInfo();
181
        ScannerInfo scannerInfo = new ScannerInfo();
182
        ISourceCodeParser parser2 = null;
182
        ISourceCodeParser parser2 = null;
183
        IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo, false);
183
        IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
184
        if (lang == ParserLanguage.CPP) {
184
        if (lang == ParserLanguage.CPP) {
185
            ICPPParserExtensionConfiguration config = null;
185
            ICPPParserExtensionConfiguration config = null;
186
            if (gcc)
186
            if (gcc)
(-)parser/org/eclipse/cdt/core/parser/tests/rewrite/astwriter/ASTWriterTest.java (-1 / +1 lines)
Lines 95-101 Link Here
95
        ParserLanguage language = getLanguage(testFile);
95
        ParserLanguage language = getLanguage(testFile);
96
    	boolean useGNUExtensions = getGNUExtension(testFile);
96
    	boolean useGNUExtensions = getGNUExtension(testFile);
97
                
97
                
98
        IScanner scanner = AST2BaseTest.createScanner(codeReader, language, ParserMode.COMPLETE_PARSE, scannerInfo, true);
98
        IScanner scanner = AST2BaseTest.createScanner(codeReader, language, ParserMode.COMPLETE_PARSE, scannerInfo);
99
        
99
        
100
        ISourceCodeParser parser2 = null;
100
        ISourceCodeParser parser2 = null;
101
        if( language == ParserLanguage.CPP ) {
101
        if( language == ParserLanguage.CPP ) {
(-)parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java (-1 / +1 lines)
Lines 43-49 Link Here
43
	protected IASTCompletionNode getCompletionNode(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException {
43
	protected IASTCompletionNode getCompletionNode(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException {
44
        CodeReader codeReader = new CodeReader(code.toCharArray());
44
        CodeReader codeReader = new CodeReader(code.toCharArray());
45
        ScannerInfo scannerInfo = new ScannerInfo();
45
        ScannerInfo scannerInfo = new ScannerInfo();
46
        IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo, false);
46
        IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
47
        
47
        
48
        ISourceCodeParser parser = null;
48
        ISourceCodeParser parser = null;
49
        if( lang == ParserLanguage.CPP )
49
        if( lang == ParserLanguage.CPP )
(-)parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java (-1 / +2 lines)
Lines 1370-1376 Link Here
1370
		TestSourceReader.createFile(fCProject.getProject(), "f1/g/h/header.h", "#define ID three\n");
1370
		TestSourceReader.createFile(fCProject.getProject(), "f1/g/h/header.h", "#define ID three\n");
1371
		TestSourceReader.createFile(fCProject.getProject(), "f1/g/source.cpp", contents + "int CONCAT(one, ID);\n");
1371
		TestSourceReader.createFile(fCProject.getProject(), "f1/g/source.cpp", contents + "int CONCAT(one, ID);\n");
1372
		TestSourceReader.createFile(fCProject.getProject(), "f2/g/source.cpp", contents + "int CONCAT(two, ID);\n");
1372
		TestSourceReader.createFile(fCProject.getProject(), "f2/g/source.cpp", contents + "int CONCAT(two, ID);\n");
1373
		TestSourceReader.createFile(fCProject.getProject(), "f1/g/h/source.cpp", contents + "int CONCAT(three, ID);\n");
1373
		IFile f= TestSourceReader.createFile(fCProject.getProject(), "f1/g/h/source.cpp", contents + "int CONCAT(three, ID);\n");
1374
		waitUntilFileIsIndexed(f, 4000);
1374
		indexManager.reindex(fCProject);
1375
		indexManager.reindex(fCProject);
1375
		waitForIndexer();
1376
		waitForIndexer();
1376
		fIndex.acquireReadLock();
1377
		fIndex.acquireReadLock();
(-)model/org/eclipse/cdt/internal/core/model/TranslationUnit.java (+3 lines)
Lines 822-827 Link Here
822
				if ((style & AST_CREATE_COMMENT_NODES) != 0) {
822
				if ((style & AST_CREATE_COMMENT_NODES) != 0) {
823
					options |= ILanguage.OPTION_ADD_COMMENTS;
823
					options |= ILanguage.OPTION_ADD_COMMENTS;
824
				}
824
				}
825
				if ((style & AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS) != 0) {
826
					options |= ILanguage.OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS;
827
				}
825
				if (isSourceUnit()) {
828
				if (isSourceUnit()) {
826
					options |= ILanguage.OPTION_IS_SOURCE_UNIT;
829
					options |= ILanguage.OPTION_IS_SOURCE_UNIT;
827
				}
830
				}
(-)model/org/eclipse/cdt/internal/core/model/ASTCache.java (-1 / +2 lines)
Lines 40-46 Link Here
40
	/** Full parse mode (no PDOM) */
40
	/** Full parse mode (no PDOM) */
41
	public static int PARSE_MODE_FULL= ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT;
41
	public static int PARSE_MODE_FULL= ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT;
42
	/** Fast parse mode (use PDOM) */
42
	/** Fast parse mode (use PDOM) */
43
	public static int PARSE_MODE_FAST= ITranslationUnit.AST_SKIP_ALL_HEADERS | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT;
43
	public static int PARSE_MODE_FAST= ITranslationUnit.AST_SKIP_ALL_HEADERS | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT
44
		| ITranslationUnit.AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS;
44
45
45
	/**
46
	/**
46
	 * Do something with an AST.
47
	 * Do something with an AST.
(-)model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java (-1 / +1 lines)
Lines 135-141 Link Here
135
			else {
135
			else {
136
				parseFlags |= ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT;
136
				parseFlags |= ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT;
137
			}
137
			}
138
			
138
			parseFlags |= ITranslationUnit.AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS;
139
			final IASTTranslationUnit ast;
139
			final IASTTranslationUnit ast;
140
			try {
140
			try {
141
				ast= fTranslationUnit.getAST(index, parseFlags, fProgressMonitor);
141
				ast= fTranslationUnit.getAST(index, parseFlags, fProgressMonitor);
(-)parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java (-24 / +69 lines)
Lines 6-12 Link Here
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    IBM Rational Software - Initial API and implementation
9
 *    John Camelon (IBM Rational Software) - Initial API and implementation
10
 *    Markus Schorn (Wind River Systems)
10
 *    Markus Schorn (Wind River Systems)
11
 *    Ed Swartz (Nokia)
11
 *    Ed Swartz (Nokia)
12
 *    Mike Kucera (IBM) - bug #206952
12
 *    Mike Kucera (IBM) - bug #206952
Lines 81-90 Link Here
81
import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
81
import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
82
82
83
/**
83
/**
84
 * @author jcamelon
84
 * Base class for the c- and c++ parser.
85
 */
85
 */
86
public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
86
public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
87
    protected static final int DEFAULT_DESIGNATOR_LIST_SIZE = 4;
87
	protected static class FoundAggregateInitializer extends Exception {
88
		public final IASTDeclarator fDeclarator;
89
		public IASTDeclSpecifier fDeclSpec;
90
		public FoundAggregateInitializer(IASTDeclarator d) {
91
			fDeclarator= d;
92
		}
93
	}
94
    protected static class FoundDeclaratorException extends Exception {
95
    	private static final long serialVersionUID = 0;
96
    	
97
        public IASTDeclSpecifier declSpec;
98
        public IASTDeclarator declarator;
99
100
		public IASTDeclSpecifier altSpec;
101
		public IASTDeclarator altDeclarator;
102
        
103
        public IToken currToken;
104
105
        public FoundDeclaratorException(IASTDeclarator d, IToken t) {
106
            this.declarator = d;
107
            this.currToken =t;
108
        }
109
    }
110
111
	protected static class NameChecker extends ASTVisitor {
112
		private boolean fFound;
113
		protected NameChecker() {
114
			shouldVisitNames= true;
115
		}
116
		@Override
117
		public int visit(IASTName name) {
118
			fFound= true;
119
			return PROCESS_ABORT;
120
		}
121
		public boolean containsName(IASTNode node) {
122
			fFound= false;
123
			node.accept(this);
124
			return fFound;
125
		}
126
	}
127
	protected NameChecker NAME_CHECKER= new NameChecker();
128
129
	protected static final int DEFAULT_DESIGNATOR_LIST_SIZE = 4;
88
    protected static int parseCount = 0;
130
    protected static int parseCount = 0;
89
131
90
	protected final AbstractParserLogService log;
132
	protected final AbstractParserLogService log;
Lines 103-108 Link Here
103
    protected final IBuiltinBindingsProvider builtinBindingsProvider;
145
    protected final IBuiltinBindingsProvider builtinBindingsProvider;
104
    
146
    
105
    protected boolean functionCallCanBeLValue= false;
147
    protected boolean functionCallCanBeLValue= false;
148
	protected boolean skipTrivialExpressionsInAggregateInitializers= false; 
149
106
    
150
    
107
    /**
151
    /**
108
     *  Marks the beginning of the current declaration. It is important to clear the mark whenever we
152
     *  Marks the beginning of the current declaration. It is important to clear the mark whenever we
Lines 141-146 Link Here
141
        this.builtinBindingsProvider= builtinBindingsProvider;
185
        this.builtinBindingsProvider= builtinBindingsProvider;
142
    }
186
    }
143
    
187
    
188
	/**
189
	 * Instructs the parser not to create ast nodes for expressions within aggregate initializers
190
	 * when they do not contain names.
191
	 */
192
	public void setSkipTrivialExpressionsInAggregateInitializers(boolean val) {
193
		skipTrivialExpressionsInAggregateInitializers= val;
194
	}
195
144
    private AbstractParserLogService wrapLogService(IParserLogService logService) {
196
    private AbstractParserLogService wrapLogService(IParserLogService logService) {
145
		if (logService instanceof AbstractParserLogService) {
197
		if (logService instanceof AbstractParserLogService) {
146
			return (AbstractParserLogService) logService;
198
			return (AbstractParserLogService) logService;
Lines 1225-1237 Link Here
1225
        return compoundStatement();
1277
        return compoundStatement();
1226
    }
1278
    }
1227
1279
1228
    protected abstract IASTDeclarator initDeclarator(DeclarationOptions option) throws EndOfFileException, BacktrackException;
1280
    protected abstract IASTDeclarator initDeclarator(DeclarationOptions option) 
1281
    		throws EndOfFileException, BacktrackException, FoundAggregateInitializer;
1229
1282
1230
    /**
1283
    /**
1231
     * @param option the options with which to parse the declaration
1284
     * @param option the options with which to parse the declaration
1232
     * @throws FoundDeclaratorException encountered EOF while looking ahead
1285
     * @throws FoundDeclaratorException encountered EOF while looking ahead
1286
     * @throws FoundAggregateInitializer found aggregate initializer, needs special treatment
1287
     *   because of scalability.
1233
     */
1288
     */
1234
    protected void lookAheadForDeclarator(final DeclarationOptions option) throws FoundDeclaratorException {
1289
    protected void lookAheadForDeclarator(final DeclarationOptions option) 
1290
    		throws FoundDeclaratorException, FoundAggregateInitializer {
1235
        IToken mark = null;
1291
        IToken mark = null;
1236
        try {
1292
        try {
1237
            mark = mark();
1293
            mark = mark();
Lines 1251-1273 Link Here
1251
    }
1307
    }
1252
1308
1253
	protected abstract boolean verifyLookaheadDeclarator(DeclarationOptions option, IASTDeclarator d, IToken nextToken);
1309
	protected abstract boolean verifyLookaheadDeclarator(DeclarationOptions option, IASTDeclarator d, IToken nextToken);
1254
1255
    public static class FoundDeclaratorException extends Exception {
1256
    	private static final long serialVersionUID = 0;
1257
    	
1258
        public IASTDeclSpecifier declSpec;
1259
        public IASTDeclarator declarator;
1260
1261
		public IASTDeclSpecifier altSpec;
1262
		public IASTDeclarator altDeclarator;
1263
        
1264
        public IToken currToken;
1265
1266
        public FoundDeclaratorException(IASTDeclarator d, IToken t) {
1267
            this.declarator = d;
1268
            this.currToken =t;
1269
        }
1270
    }
1271
    
1310
    
1272
    /**
1311
    /**
1273
     * Parse an enumeration specifier, as according to the ANSI specs in C &
1312
     * Parse an enumeration specifier, as according to the ANSI specs in C &
Lines 1439-1445 Link Here
1439
    protected abstract IASTCaseStatement createCaseStatement();
1478
    protected abstract IASTCaseStatement createCaseStatement();
1440
1479
1441
    protected abstract IASTDeclaration declaration(DeclarationOptions option) throws BacktrackException, EndOfFileException;
1480
    protected abstract IASTDeclaration declaration(DeclarationOptions option) throws BacktrackException, EndOfFileException;
1442
    protected abstract IASTDeclSpecifier declSpecifierSeq(DeclarationOptions option) throws BacktrackException, EndOfFileException, FoundDeclaratorException;
1481
    protected abstract IASTDeclSpecifier declSpecifierSeq(DeclarationOptions option) throws BacktrackException, EndOfFileException, FoundDeclaratorException, FoundAggregateInitializer;
1443
1482
1444
    protected IASTDeclaration[] problemDeclaration(int offset, BacktrackException bt, DeclarationOptions option) {
1483
    protected IASTDeclaration[] problemDeclaration(int offset, BacktrackException bt, DeclarationOptions option) {
1445
    	failParse();
1484
    	failParse();
Lines 1523-1529 Link Here
1523
	protected IASTDeclaration functionStyleAsmDeclaration() throws BacktrackException, EndOfFileException {
1562
	protected IASTDeclaration functionStyleAsmDeclaration() throws BacktrackException, EndOfFileException {
1524
1563
1525
		final int offset= LA(1).getOffset();
1564
		final int offset= LA(1).getOffset();
1526
		IASTDeclSpecifier declSpec;
1565
		IASTDeclSpecifier declSpec= null;
1527
		IASTDeclarator dtor;
1566
		IASTDeclarator dtor;
1528
    	try {
1567
    	try {
1529
			declSpec = declSpecifierSeq(DeclarationOptions.FUNCTION_STYLE_ASM);
1568
			declSpec = declSpecifierSeq(DeclarationOptions.FUNCTION_STYLE_ASM);
Lines 1537-1542 Link Here
1537
        		dtor= e.declarator;
1576
        		dtor= e.declarator;
1538
        	}
1577
        	}
1539
            backup( e.currToken );
1578
            backup( e.currToken );
1579
        } catch (FoundAggregateInitializer lie) {
1580
        	if (declSpec == null)
1581
        		declSpec= lie.fDeclSpec;
1582
        	dtor= addInitializer(lie);
1540
    	}
1583
    	}
1541
1584
1542
    	if (LT(1) != IToken.tLBRACE)
1585
    	if (LT(1) != IToken.tLBRACE)
Lines 1561-1566 Link Here
1561
    	return funcDefinition;
1604
    	return funcDefinition;
1562
	}
1605
	}
1563
1606
1607
	protected abstract IASTDeclarator addInitializer(FoundAggregateInitializer lie) throws EndOfFileException;
1608
1564
	protected IToken asmExpression(StringBuilder content) throws EndOfFileException, BacktrackException {
1609
	protected IToken asmExpression(StringBuilder content) throws EndOfFileException, BacktrackException {
1565
		IToken t= consume(IToken.tLPAREN);
1610
		IToken t= consume(IToken.tLPAREN);
1566
    	boolean needspace= false;
1611
    	boolean needspace= false;
(-)parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java (-1 / +8 lines)
Lines 38-43 Link Here
38
import org.eclipse.cdt.core.parser.ParserLanguage;
38
import org.eclipse.cdt.core.parser.ParserLanguage;
39
import org.eclipse.cdt.core.parser.ParserMode;
39
import org.eclipse.cdt.core.parser.ParserMode;
40
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
40
import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
41
import org.eclipse.cdt.internal.core.dom.parser.AbstractGNUSourceCodeParser;
41
import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
42
import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
42
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
43
import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
43
import org.eclipse.cdt.internal.core.util.ICancelable;
44
import org.eclipse.cdt.internal.core.util.ICancelable;
Lines 181-187 Link Here
181
		else
182
		else
182
			mode= ParserMode.COMPLETE_PARSE;
183
			mode= ParserMode.COMPLETE_PARSE;
183
184
184
		return createParser(scanner, mode, log, index);
185
		ISourceCodeParser parser= createParser(scanner, mode, log, index);
186
		if ((options & OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS) != 0) {
187
			if (parser instanceof AbstractGNUSourceCodeParser) {
188
				((AbstractGNUSourceCodeParser) parser).setSkipTrivialExpressionsInAggregateInitializers(true);
189
			}
190
		}
191
		return parser;
185
	}
192
	}
186
	
193
	
187
	
194
	
(-)model/org/eclipse/cdt/core/model/ITranslationUnit.java (-6 / +16 lines)
Lines 30-35 Link Here
30
 * If a <code>.c</code> file cannot be parsed, its structure remains unknown.
30
 * If a <code>.c</code> file cannot be parsed, its structure remains unknown.
31
 * Use <code>ICElement.isStructureKnown</code> to determine whether this is 
31
 * Use <code>ICElement.isStructureKnown</code> to determine whether this is 
32
 * the case.
32
 * the case.
33
 * 
34
 * @noimplement This interface is not intended to be implemented by clients.
33
 */
35
 */
34
public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISourceReference, ISourceManipulation {
36
public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISourceReference, ISourceManipulation {
35
	
37
	
Lines 38-58 Link Here
38
	 * Meaning: Skip function and method bodies.
40
	 * Meaning: Skip function and method bodies.
39
	 * @since 4.0
41
	 * @since 4.0
40
	 */
42
	 */
41
	public static final int AST_SKIP_FUNCTION_BODIES= 1;
43
	public static final int AST_SKIP_FUNCTION_BODIES= 0x1;
42
44
43
	/**
45
	/**
44
	 * Style constant for {@link #getAST(IIndex, int)}. 
46
	 * Style constant for {@link #getAST(IIndex, int)}. 
45
	 * Meaning: Skip over headers that are found in the index, parse all others.
47
	 * Meaning: Skip over headers that are found in the index, parse all others.
46
	 * Macro definitions and bindings are taken from index for skipped files.
48
	 * Macro definitions and bindings are taken from index for skipped files.
47
	 */
49
	 */
48
	public static final int AST_SKIP_INDEXED_HEADERS = 2;
50
	public static final int AST_SKIP_INDEXED_HEADERS = 0x2;
49
51
50
	/**
52
	/**
51
	 * Style constant for {@link #getAST(IIndex, int)}. 
53
	 * Style constant for {@link #getAST(IIndex, int)}. 
52
	 * Meaning: Skip headers even if they are not found in the index. 
54
	 * Meaning: Skip headers even if they are not found in the index. 
53
	 * Makes practically only sense in combination with {@link #AST_SKIP_INDEXED_HEADERS}.
55
	 * Makes practically only sense in combination with {@link #AST_SKIP_INDEXED_HEADERS}.
54
	 */
56
	 */
55
	public static final int AST_SKIP_NONINDEXED_HEADERS = 4;
57
	public static final int AST_SKIP_NONINDEXED_HEADERS = 0x4;
56
58
57
	/**
59
	/**
58
	 * Style constant for {@link #getAST(IIndex, int)}. 
60
	 * Style constant for {@link #getAST(IIndex, int)}. 
Lines 66-79 Link Here
66
	 * Style constant for {@link #getAST(IIndex, int)}. 
68
	 * Style constant for {@link #getAST(IIndex, int)}. 
67
	 * Meaning: Don't parse the file if there is no build information for it.
69
	 * Meaning: Don't parse the file if there is no build information for it.
68
	 */
70
	 */
69
	public static final int AST_SKIP_IF_NO_BUILD_INFO = 8;
71
	public static final int AST_SKIP_IF_NO_BUILD_INFO = 0x8;
70
72
71
	/**
73
	/**
72
	 * Style constant for {@link #getAST(IIndex, int)}. 
74
	 * Style constant for {@link #getAST(IIndex, int)}. 
73
	 * Meaning: Add nodes for comments to the ast.
75
	 * Meaning: Add nodes for comments to the ast.
74
	 * @since 4.0
76
	 * @since 4.0
75
	 */
77
	 */
76
	public static final int AST_CREATE_COMMENT_NODES = 16;
78
	public static final int AST_CREATE_COMMENT_NODES = 0x10;
77
	
79
	
78
	/**
80
	/**
79
	 * Style constant for {@link #getAST(IIndex, int)}. 
81
	 * Style constant for {@link #getAST(IIndex, int)}. 
Lines 82-88 Link Here
82
	 * the flag is ignored.
84
	 * the flag is ignored.
83
	 * @since 4.0
85
	 * @since 4.0
84
	 */
86
	 */
85
	public static final int AST_CONFIGURE_USING_SOURCE_CONTEXT= 32;
87
	public static final int AST_CONFIGURE_USING_SOURCE_CONTEXT= 0x20;
88
89
	/**
90
	 * Style constant for {@link #getAST(IIndex, int)}. 
91
	 * Instructs the parser not to create ast nodes for expressions within aggregate initializers
92
	 * when they do not contain names.
93
	 * @since 5.1
94
	 */
95
	public final static int AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS= 0x40;
86
96
87
	/**
97
	/**
88
	 * Creates and returns an include declaration in this translation unit
98
	 * Creates and returns an include declaration in this translation unit
(-)model/org/eclipse/cdt/core/model/ILanguage.java (-6 / +15 lines)
Lines 6-12 Link Here
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    QNX - Initial API and implementation
9
 *    Doug Schaefer (QNX) - Initial API and implementation
10
 *    Markus Schorn (Wind River Systems)
10
 *    Markus Schorn (Wind River Systems)
11
 *    IBM Corporation
11
 *    IBM Corporation
12
 *******************************************************************************/
12
 *******************************************************************************/
Lines 27-33 Link Here
27
/**
27
/**
28
 * Models differences between languages. The interface is not supposed to be implemented directly.
28
 * Models differences between languages. The interface is not supposed to be implemented directly.
29
 * Rather than that clients may subclass {@link AbstractLanguage}.
29
 * Rather than that clients may subclass {@link AbstractLanguage}.
30
 * @author Doug Schaefer
30
 * 
31
 * @noimplement This interface is not intended to be implemented by clients.
31
 */
32
 */
32
public interface ILanguage extends IAdaptable {
33
public interface ILanguage extends IAdaptable {
33
34
Lines 35-61 Link Here
35
	 * Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
36
	 * Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
36
	 * Instructs the parser to skip function and method bodies.
37
	 * Instructs the parser to skip function and method bodies.
37
	 */
38
	 */
38
	public final static int OPTION_SKIP_FUNCTION_BODIES= 1;
39
	public final static int OPTION_SKIP_FUNCTION_BODIES= 0x1;
39
40
40
	/**
41
	/**
41
	 * Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
42
	 * Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
42
	 * Instructs the parser to add comment nodes to the ast.
43
	 * Instructs the parser to add comment nodes to the ast.
43
	 */
44
	 */
44
	public final static int OPTION_ADD_COMMENTS= 2;
45
	public final static int OPTION_ADD_COMMENTS= 0x2;
45
46
46
	/**
47
	/**
47
	 * Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
48
	 * Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
48
	 * Performance optimization, instructs the parser not to create image-locations. 
49
	 * Performance optimization, instructs the parser not to create image-locations. 
49
	 * When using this option {@link IASTName#getImageLocation()} will always return <code>null</code>.
50
	 * When using this option {@link IASTName#getImageLocation()} will always return <code>null</code>.
50
	 */
51
	 */
51
	public final static int OPTION_NO_IMAGE_LOCATIONS= 4;
52
	public final static int OPTION_NO_IMAGE_LOCATIONS= 0x4;
52
53
53
	/**
54
	/**
54
	 * Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
55
	 * Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
55
	 * Marks the ast as being based on a source-file rather than a header-file. This makes a difference
56
	 * Marks the ast as being based on a source-file rather than a header-file. This makes a difference
56
	 * when bindings from the AST are used for searching the index, e.g. for static variables. 
57
	 * when bindings from the AST are used for searching the index, e.g. for static variables. 
57
	 */
58
	 */
58
	public final static int OPTION_IS_SOURCE_UNIT= 8;
59
	public final static int OPTION_IS_SOURCE_UNIT= 0x8;
60
61
	/**
62
	 * Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
63
	 * Instructs the parser not to create ast nodes for expressions within aggregate initializers
64
	 * when they do not contain names.
65
	 * @since 5.1
66
	 */
67
	public final static int OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS= 0x10;
59
68
60
	/**
69
	/**
61
	 * Return the language id for this language.
70
	 * Return the language id for this language.
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java (-57 / +119 lines)
Lines 874-879 Link Here
874
        	declSpecifier= e.declSpec;
874
        	declSpecifier= e.declSpec;
875
        	declarator= e.declarator;
875
        	declarator= e.declarator;
876
        	backup(e.currToken);
876
        	backup(e.currToken);
877
        } catch (FoundAggregateInitializer lie) {
878
            // type-ids have no initializers
879
        	return null;
877
        } catch (BacktrackException bt) {
880
        } catch (BacktrackException bt) {
878
        	return null;
881
        	return null;
879
        }
882
        }
Lines 2245-2268 Link Here
2245
        
2248
        
2246
        final int firstOffset= LA(1).getOffset();
2249
        final int firstOffset= LA(1).getOffset();
2247
        int endOffset= firstOffset;
2250
        int endOffset= firstOffset;
2251
        boolean insertSemi= false;
2252
        boolean parseDtors= true;
2248
2253
2249
        ICPPASTDeclSpecifier declSpec;
2254
        ICPPASTDeclSpecifier declSpec= null;
2250
        IASTDeclarator dtor= null;
2255
        IASTDeclarator dtor= null;
2251
        IToken markBeforDtor= null;
2256
        IToken markBeforDtor= null;
2252
        try {
2257
        try {
2253
            declSpec = declSpecifierSeq(declOption);
2258
            declSpec = declSpecifierSeq(declOption);
2254
            switch(LTcatchEOF(1)) {
2259
            final int lt1= LTcatchEOF(1);
2260
            switch(lt1) {
2255
            case 0: // eof
2261
            case 0: // eof
2262
            case IToken.tEOC:
2256
            case IToken.tSEMI:
2263
            case IToken.tSEMI:
2257
            	if (!validWithoutDtor(declOption, declSpec)) {
2264
            	if (lt1 != IToken.tEOC && !validWithoutDtor(declOption, declSpec)) 
2258
                	throwBacktrack(LA(1));
2265
                	throwBacktrack(LA(1));
2259
            	}
2266
            	
2267
            	parseDtors= false;
2268
            	insertSemi= lt1==0;
2269
            	if (lt1 == IToken.tSEMI)
2270
            		endOffset= consume().getEndOffset();
2271
            	else 
2272
            		endOffset= calculateEndOffset(declSpec);
2260
            	break;
2273
            	break;
2274
2261
            case IToken.tCOMMA:
2275
            case IToken.tCOMMA:
2262
            	throwBacktrack(LA(1));
2276
            	throwBacktrack(LA(1));
2263
            	break;
2277
            	break;
2264
            case IToken.tEOC:
2265
            	break;
2266
            default:
2278
            default:
2267
            	markBeforDtor= mark();
2279
            	markBeforDtor= mark();
2268
            	try {
2280
            	try {
Lines 2278-2283 Link Here
2278
            	}
2290
            	}
2279
            	break;
2291
            	break;
2280
            }
2292
            }
2293
        } catch (FoundAggregateInitializer lie) {
2294
        	if (declSpec == null)
2295
        		declSpec= (ICPPASTDeclSpecifier) lie.fDeclSpec;
2296
        	// scalability: don't keep references to tokens, initializer may be large
2297
        	declarationMark= null;
2298
        	markBeforDtor= null;
2299
        	dtor= addInitializer(lie);
2281
        } catch (FoundDeclaratorException e) {
2300
        } catch (FoundDeclaratorException e) {
2282
        	declSpec= (ICPPASTDeclSpecifier) e.declSpec;
2301
        	declSpec= (ICPPASTDeclSpecifier) e.declSpec;
2283
        	dtor= e.declarator;
2302
        	dtor= e.declarator;
Lines 2293-2343 Link Here
2293
        	throw e;
2312
        	throw e;
2294
        }
2313
        }
2295
        
2314
        
2296
        IASTDeclarator[] declarators= {dtor};
2315
        IASTDeclarator[] declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
2297
        while (LTcatchEOF(1) == IToken.tCOMMA) {
2316
        if (parseDtors) {
2298
        	consume();
2317
        	declarators= new IASTDeclarator[]{dtor};
2299
        	declarators= (IASTDeclarator[]) ArrayUtil.append( IASTDeclarator.class, declarators, initDeclarator(declSpec, declOption));
2318
        	while (LTcatchEOF(1) == IToken.tCOMMA) {
2300
        }
2319
        		consume();
2301
2320
        		try {
2302
        declarators= (IASTDeclarator[]) ArrayUtil.removeNulls( IASTDeclarator.class, declarators );
2321
        			dtor= initDeclarator(declSpec, declOption);
2303
2322
        		} catch (FoundAggregateInitializer e) {
2304
        boolean insertSemi= false;
2323
        	        // scalability: don't keep references to tokens, initializer may be large
2305
        final int lt1= LTcatchEOF(1);
2324
        			declarationMark= null;
2306
        switch (lt1) {
2325
        			markBeforDtor= null;
2307
        case IToken.tEOC:
2326
        			dtor= addInitializer(e);
2308
        	endOffset= figureEndOffset(declSpec, declarators);
2327
        		}
2309
            break;
2328
        		declarators = (IASTDeclarator[]) ArrayUtil.append(IASTDeclarator.class, declarators, dtor);
2310
        case IToken.tSEMI:
2329
        	}
2311
            endOffset= consume().getEndOffset();
2330
        	declarators = (IASTDeclarator[]) ArrayUtil.removeNulls(IASTDeclarator.class, declarators);
2312
            break;
2331
        
2313
        case IToken.t_try:
2332
        	final int lt1= LTcatchEOF(1);
2314
        case IToken.tCOLON:
2333
        	switch (lt1) {
2315
        case IToken.tLBRACE:
2334
        	case IToken.tEOC:
2316
            return functionDefinition(firstOffset, declSpec, declarators);
2335
        		endOffset= figureEndOffset(declSpec, declarators);
2317
        default:
2336
        		break;
2318
        	if (declOption != DeclarationOptions.LOCAL) {
2337
        	case IToken.tSEMI:
2319
        		insertSemi= true;
2338
        		endOffset= consume().getEndOffset();
2320
        		if (validWithoutDtor(declOption, declSpec)) {
2339
        		break;
2321
        			// class definition without semicolon
2340
        	case IToken.t_try:
2322
        			if (markBeforDtor == null || !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) {
2341
        	case IToken.tCOLON:
2323
        				if (markBeforDtor != null) {
2342
        	case IToken.tLBRACE:
2343
        		return functionDefinition(firstOffset, declSpec, declarators);
2344
        	default:	
2345
        		if (declOption != DeclarationOptions.LOCAL) {
2346
    				insertSemi= true;
2347
        			if (validWithoutDtor(declOption, declSpec)) {
2348
        				if (markBeforDtor != null && !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) {
2324
        					backup(markBeforDtor);
2349
        					backup(markBeforDtor);
2350
        					declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
2351
        					endOffset= calculateEndOffset(declSpec);
2352
        					break;
2325
        				}
2353
        				}
2326
        				declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
2354
        			}
2327
        				endOffset= calculateEndOffset(declSpec);
2355
        			endOffset= figureEndOffset(declSpec, declarators);
2356
        			if (lt1 == 0 || !isOnSameLine(endOffset, LA(1).getOffset())) {
2357
        				break;
2358
        			}
2359
        			if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) {
2328
        				break;
2360
        				break;
2329
        			}
2361
        			}
2330
        		} 
2331
        		endOffset= figureEndOffset(declSpec, declarators);
2332
        		if (lt1 == 0 || !isOnSameLine(endOffset, LA(1).getOffset())) {
2333
        			insertSemi= true;
2334
        			break;
2335
        		}
2336
        		if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) {
2337
        			break;
2338
        		}
2362
        		}
2363
        		throwBacktrack(LA(1));
2339
        	}
2364
        	}
2340
        	throwBacktrack(LA(1));
2341
        }
2365
        }
2342
2366
2343
        // no function body
2367
        // no function body
Lines 2515-2521 Link Here
2515
			skipBrackets(IToken.tLBRACKET, IToken.tRBRACKET);
2539
			skipBrackets(IToken.tLBRACKET, IToken.tRBRACKET);
2516
		}
2540
		}
2517
		
2541
		
2518
        IASTDeclSpecifier declSpec;
2542
        IASTDeclSpecifier declSpec= null;
2519
        IASTDeclarator declarator;
2543
        IASTDeclarator declarator;
2520
        try {
2544
        try {
2521
        	declSpec= declSpecifierSeq(DeclarationOptions.PARAMETER);
2545
        	declSpec= declSpecifierSeq(DeclarationOptions.PARAMETER);
Lines 2524-2529 Link Here
2524
        	declSpec= e.declSpec;
2548
        	declSpec= e.declSpec;
2525
        	declarator= e.declarator;
2549
        	declarator= e.declarator;
2526
        	backup(e.currToken);
2550
        	backup(e.currToken);
2551
        } catch (FoundAggregateInitializer lie) {
2552
        	if (declSpec == null)
2553
        		declSpec= lie.fDeclSpec;
2554
        	declarator= addInitializer(lie);
2527
        }
2555
        }
2528
2556
2529
        final ICPPASTParameterDeclaration parm = createParameterDeclaration();
2557
        final ICPPASTParameterDeclaration parm = createParameterDeclaration();
Lines 2558-2567 Link Here
2558
     * 		("typename")? name | 
2586
     * 		("typename")? name | 
2559
     * 		{ "class" | "struct" | "union" } classSpecifier | 
2587
     * 		{ "class" | "struct" | "union" } classSpecifier | 
2560
     * 		{"enum"} enumSpecifier
2588
     * 		{"enum"} enumSpecifier
2589
     * @throws FoundAggregateInitializer 
2561
     */
2590
     */
2562
    @Override
2591
    @Override
2563
	protected ICPPASTDeclSpecifier declSpecifierSeq(final DeclarationOptions option)
2592
	protected ICPPASTDeclSpecifier declSpecifierSeq(final DeclarationOptions option)
2564
    		throws BacktrackException, EndOfFileException, FoundDeclaratorException {
2593
    		throws BacktrackException, EndOfFileException, FoundDeclaratorException, FoundAggregateInitializer {
2565
        int storageClass = IASTDeclSpecifier.sc_unspecified;
2594
        int storageClass = IASTDeclSpecifier.sc_unspecified;
2566
        int simpleType = IASTSimpleDeclSpecifier.t_unspecified;
2595
        int simpleType = IASTSimpleDeclSpecifier.t_unspecified;
2567
        int options= 0;
2596
        int options= 0;
Lines 2748-2754 Link Here
2748
                	if (option.fAllowEmptySpecifier && LT(1) != IToken.tCOMPLETION) {
2777
                	if (option.fAllowEmptySpecifier && LT(1) != IToken.tCOMPLETION) {
2749
                		lookAheadForDeclarator(option);
2778
                		lookAheadForDeclarator(option);
2750
                	}
2779
                	}
2751
                } catch (FoundDeclaratorException e) {
2780
                } catch (FoundAggregateInitializer e) {
2781
                	e.fDeclSpec= createSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
2782
                	throw e;
2783
                }catch (FoundDeclaratorException e) {
2752
                	if (e.currToken.getType() == IToken.tEOC || option == DeclarationOptions.FUNCTION_STYLE_ASM 
2784
                	if (e.currToken.getType() == IToken.tEOC || option == DeclarationOptions.FUNCTION_STYLE_ASM 
2753
                			|| canBeConstructorDestructorOrConversion(option, storageClass, options, e.declarator)) {
2785
                			|| canBeConstructorDestructorOrConversion(option, storageClass, options, e.declarator)) {
2754
                		e.declSpec= createSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
2786
                		e.declSpec= createSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
Lines 3046-3057 Link Here
3046
    }
3078
    }
3047
3079
3048
    @Override
3080
    @Override
3049
	protected IASTDeclarator initDeclarator(DeclarationOptions option) throws EndOfFileException, BacktrackException {
3081
	protected IASTDeclarator initDeclarator(DeclarationOptions option) 
3082
    		throws EndOfFileException, BacktrackException, FoundAggregateInitializer {
3050
    	// called from the lookahead, only.
3083
    	// called from the lookahead, only.
3051
    	return initDeclarator(DtorStrategy.PREFER_FUNCTION, option);
3084
    	return initDeclarator(DtorStrategy.PREFER_FUNCTION, option);
3052
    }
3085
    }
3053
    
3086
    
3054
	protected IASTDeclarator initDeclarator(IASTDeclSpecifier declspec, DeclarationOptions option) throws EndOfFileException, BacktrackException {
3087
	protected IASTDeclarator initDeclarator(IASTDeclSpecifier declspec, DeclarationOptions option) 
3088
			throws EndOfFileException, BacktrackException, FoundAggregateInitializer {
3055
    	final IToken mark= mark();
3089
    	final IToken mark= mark();
3056
    	IASTDeclarator dtor1= null;
3090
    	IASTDeclarator dtor1= null;
3057
    	IToken end1= null;
3091
    	IToken end1= null;
Lines 3076-3082 Link Here
3076
    		}
3110
    		}
3077
    	} catch (BacktrackException e) {
3111
    	} catch (BacktrackException e) {
3078
    		bt= e;
3112
    		bt= e;
3079
    	}
3113
    	} 
3080
    	
3114
    	
3081
    	if (!option.fAllowConstructorInitializer || !canHaveConstructorInitializer(declspec)) {
3115
    	if (!option.fAllowConstructorInitializer || !canHaveConstructorInitializer(declspec)) {
3082
    		if (bt != null)
3116
    		if (bt != null)
Lines 3096-3102 Link Here
3096
    			return dtor1;
3130
    			return dtor1;
3097
    		}
3131
    		}
3098
    		throw e;
3132
    		throw e;
3099
    	}
3133
    	} 
3100
    	
3134
    	
3101
		// we have an ambiguity
3135
		// we have an ambiguity
3102
		if (end1 != null && LA(1).getEndOffset() != end1.getEndOffset()) {
3136
		if (end1 != null && LA(1).getEndOffset() != end1.getEndOffset()) {
Lines 3144-3154 Link Here
3144
     * @return declarator that this parsing produced.
3178
     * @return declarator that this parsing produced.
3145
     * @throws BacktrackException
3179
     * @throws BacktrackException
3146
     *             request a backtrack
3180
     *             request a backtrack
3181
	 * @throws FoundAggregateInitializer 
3147
     */
3182
     */
3148
    protected IASTDeclarator initDeclarator(DtorStrategy strategy, DeclarationOptions option)
3183
    protected IASTDeclarator initDeclarator(DtorStrategy strategy, DeclarationOptions option)
3149
            throws EndOfFileException, BacktrackException {
3184
            throws EndOfFileException, BacktrackException, FoundAggregateInitializer {
3150
    	final IASTDeclarator dtor= declarator(strategy, option);
3185
    	final IASTDeclarator dtor= declarator(strategy, option);
3151
        if (option.fAllowInitializer) {
3186
        if (option.fAllowInitializer) {
3187
            if (LT(1) == IToken.tASSIGN && LT(2) == IToken.tLBRACE) 
3188
            	throw new FoundAggregateInitializer(dtor);
3189
3152
        	IASTInitializer initializer= optionalCPPInitializer(dtor);
3190
        	IASTInitializer initializer= optionalCPPInitializer(dtor);
3153
        	if (initializer != null) {
3191
        	if (initializer != null) {
3154
        		dtor.setInitializer(initializer);
3192
        		dtor.setInitializer(initializer);
Lines 3157-3162 Link Here
3157
        }
3195
        }
3158
        return dtor;
3196
        return dtor;
3159
    }
3197
    }
3198
    
3199
    @Override
3200
	protected IASTDeclarator addInitializer(FoundAggregateInitializer e) throws EndOfFileException {
3201
	    final IASTDeclarator d = e.fDeclarator;
3202
        try {
3203
			IASTInitializer i = optionalCPPInitializer(e.fDeclarator);
3204
			if (i != null) {
3205
				d.setInitializer(i);
3206
			    ((ASTNode) d).setLength(calculateEndOffset(i) - ((ASTNode) d).getOffset());
3207
			}
3208
		} catch (BacktrackException e1) {
3209
			// mstodo add problem node
3210
		}
3211
		return d;
3212
    }
3160
3213
3161
    protected IASTInitializer optionalCPPInitializer(IASTDeclarator d)
3214
    protected IASTInitializer optionalCPPInitializer(IASTDeclarator d)
3162
            throws EndOfFileException, BacktrackException {
3215
            throws EndOfFileException, BacktrackException {
Lines 3165-3171 Link Here
3165
        if (LT(1) == IToken.tASSIGN) {
3218
        if (LT(1) == IToken.tASSIGN) {
3166
            consume();
3219
            consume();
3167
            try {
3220
            try {
3168
                return initializerClause();
3221
                return initializerClause(false);
3169
            } catch (EndOfFileException eof) {
3222
            } catch (EndOfFileException eof) {
3170
                failParse();
3223
                failParse();
3171
                throw eof;
3224
                throw eof;
Lines 3200-3206 Link Here
3200
    }
3253
    }
3201
3254
3202
3255
3203
    protected IASTInitializer initializerClause() throws EndOfFileException, BacktrackException {
3256
    protected IASTInitializer initializerClause(boolean inAggregateInitializer) throws EndOfFileException, BacktrackException {
3204
        if (LT(1) == IToken.tLBRACE) {
3257
        if (LT(1) == IToken.tLBRACE) {
3205
            int startingOffset = consume().getOffset();
3258
            int startingOffset = consume().getOffset();
3206
3259
Lines 3219-3225 Link Here
3219
                if (LT(1) == IToken.tRBRACE)
3272
                if (LT(1) == IToken.tRBRACE)
3220
                    break;
3273
                    break;
3221
3274
3222
                IASTInitializer clause = initializerClause();
3275
                IASTInitializer clause = initializerClause(true);
3223
                if (clause != null) {
3276
                if (clause != null) {
3224
                    result.addInitializer(clause);
3277
                    result.addInitializer(clause);
3225
                }
3278
                }
Lines 3236-3241 Link Here
3236
        // try this now instead
3289
        // try this now instead
3237
        // assignmentExpression
3290
        // assignmentExpression
3238
        IASTExpression assignmentExpression = assignmentExpression();
3291
        IASTExpression assignmentExpression = assignmentExpression();
3292
        if (inAggregateInitializer && skipTrivialExpressionsInAggregateInitializers) {
3293
        	if (!NAME_CHECKER.containsName(assignmentExpression))
3294
        		return null;
3295
        }
3296
3239
        IASTInitializerExpression result = createInitializerExpression();
3297
        IASTInitializerExpression result = createInitializerExpression();
3240
        ((ASTNode) result).setOffsetAndLength(((ASTNode) assignmentExpression));
3298
        ((ASTNode) result).setOffsetAndLength(((ASTNode) assignmentExpression));
3241
        result.setExpression(assignmentExpression);
3299
        result.setExpression(assignmentExpression);
Lines 3975-3981 Link Here
3975
4033
3976
	private IASTSimpleDeclaration simpleSingleDeclaration(DeclarationOptions options) throws BacktrackException,	EndOfFileException {
4034
	private IASTSimpleDeclaration simpleSingleDeclaration(DeclarationOptions options) throws BacktrackException,	EndOfFileException {
3977
        final int startOffset= LA(1).getOffset();
4035
        final int startOffset= LA(1).getOffset();
3978
    	IASTDeclSpecifier declSpec;
4036
    	IASTDeclSpecifier declSpec= null;
3979
    	IASTDeclarator declarator;
4037
    	IASTDeclarator declarator;
3980
4038
3981
    	try {
4039
    	try {
Lines 3985-3990 Link Here
3985
    		declSpec= e.declSpec;
4043
    		declSpec= e.declSpec;
3986
    		declarator= e.declarator;
4044
    		declarator= e.declarator;
3987
    		backup(e.currToken);
4045
    		backup(e.currToken);
4046
        } catch (FoundAggregateInitializer lie) {
4047
        	if (declSpec == null)
4048
        		declSpec= lie.fDeclSpec;
4049
        	declarator= addInitializer(lie);
3988
    	}
4050
    	}
3989
4051
3990
    	final int endOffset = figureEndOffset(declSpec, declarator);
4052
    	final int endOffset = figureEndOffset(declSpec, declarator);
(-)parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java (-43 / +106 lines)
Lines 159-170 Link Here
159
        if (LT(1) == IToken.tASSIGN) {
159
        if (LT(1) == IToken.tASSIGN) {
160
            consume();
160
            consume();
161
            final List<IASTNode> empty= Collections.emptyList();
161
            final List<IASTNode> empty= Collections.emptyList();
162
            return cInitializerClause(empty);
162
            return cInitializerClause(empty, false);
163
        }
163
        }
164
        return null;
164
        return null;
165
    }
165
    }
166
166
167
    protected IASTInitializer cInitializerClause(List<IASTNode> designators)
167
    protected IASTInitializer cInitializerClause(List<IASTNode> designators, boolean inAggregateInitializer)
168
            throws EndOfFileException, BacktrackException {
168
            throws EndOfFileException, BacktrackException {
169
        IToken la = LA(1);
169
        IToken la = LA(1);
170
        int startingOffset = la.getOffset();
170
        int startingOffset = la.getOffset();
Lines 190-199 Link Here
190
                    if (LT(1) == IToken.tASSIGN)
190
                    if (LT(1) == IToken.tASSIGN)
191
                        consume();
191
                        consume();
192
192
193
                IASTInitializer initializer = cInitializerClause(newDesignators);
193
                IASTInitializer initializer = cInitializerClause(newDesignators, true);
194
194
195
                if (newDesignators.isEmpty()) {
195
                if (newDesignators.isEmpty()) {
196
                    result.addInitializer(initializer);
196
                    // depending on value of skipTrivialItemsInCompoundInitializers initializer may be null
197
                	if (initializer != null)
198
                		result.addInitializer(initializer);
197
                } else {
199
                } else {
198
                    ICASTDesignatedInitializer desigInitializer = createDesignatorInitializer();
200
                    ICASTDesignatedInitializer desigInitializer = createDesignatorInitializer();
199
                    ((ASTNode) desigInitializer).setOffsetAndLength(
201
                    ((ASTNode) desigInitializer).setOffsetAndLength(
Lines 232-237 Link Here
232
        // try this now instead
234
        // try this now instead
233
        // assignmentExpression
235
        // assignmentExpression
234
        IASTExpression assignmentExpression = assignmentExpression();
236
        IASTExpression assignmentExpression = assignmentExpression();
237
        if (inAggregateInitializer && skipTrivialExpressionsInAggregateInitializers) {
238
        	if (!NAME_CHECKER.containsName(assignmentExpression))
239
        		return null;
240
        }
235
        IASTInitializerExpression result = createInitializerExpression();
241
        IASTInitializerExpression result = createInitializerExpression();
236
        result.setExpression(assignmentExpression);
242
        result.setExpression(assignmentExpression);
237
        ((ASTNode) result).setOffsetAndLength(
243
        ((ASTNode) result).setOffsetAndLength(
Lines 387-403 Link Here
387
        
393
        
388
        final int firstOffset= LA(1).getOffset();
394
        final int firstOffset= LA(1).getOffset();
389
        int endOffset= firstOffset;
395
        int endOffset= firstOffset;
396
        boolean insertSemi= false;
397
        boolean parseDtors= true;
390
398
391
        IASTDeclSpecifier declSpec;
399
        IASTDeclSpecifier declSpec= null;
392
        IASTDeclarator dtor= null;
400
        IASTDeclarator dtor= null;
393
        IToken markBeforDtor= null;
401
        IToken markBeforDtor= null;
394
        try {
402
        try {
395
            declSpec = declSpecifierSeq(declOption);
403
            declSpec = declSpecifierSeq(declOption);
396
            switch(LTcatchEOF(1)) {
404
            final int lt1= LTcatchEOF(1);
405
            switch(lt1) {
397
            case 0: // eof
406
            case 0: // eof
398
            case IToken.tSEMI:
399
            case IToken.tEOC:
407
            case IToken.tEOC:
408
            case IToken.tSEMI:
409
            	parseDtors= false;
410
            	insertSemi= lt1==0;
411
            	if (lt1 == IToken.tSEMI)
412
            		endOffset= consume().getEndOffset();
413
            	else 
414
            		endOffset= calculateEndOffset(declSpec);
400
            	break;
415
            	break;
416
            	
401
            default:
417
            default:
402
            	markBeforDtor= mark();
418
            	markBeforDtor= mark();
403
            	try {
419
            	try {
Lines 408-413 Link Here
408
            		backup(markBeforDtor);
424
            		backup(markBeforDtor);
409
            	}
425
            	}
410
            }
426
            }
427
        } catch (FoundAggregateInitializer lie) {
428
        	if (declSpec == null)
429
        		declSpec= lie.fDeclSpec;
430
        	// scalability: don't keep references to tokens, initializer may be large
431
        	declarationMark= null;
432
        	markBeforDtor= null;
433
        	dtor= addInitializer(lie);
411
        } catch (FoundDeclaratorException e) {
434
        } catch (FoundDeclaratorException e) {
412
        	if (e.altSpec != null) {
435
        	if (e.altSpec != null) {
413
        		declSpec= e.altSpec;
436
        		declSpec= e.altSpec;
Lines 428-472 Link Here
428
        	throw e;
451
        	throw e;
429
        }
452
        }
430
        
453
        
431
        IASTDeclarator[] declarators= {dtor};
454
        IASTDeclarator[] declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
432
        while (LTcatchEOF(1) == IToken.tCOMMA) {
455
        if (parseDtors) {
433
        	consume();
456
        	declarators= new IASTDeclarator[]{dtor};
434
        	declarators= (IASTDeclarator[]) ArrayUtil.append( IASTDeclarator.class, declarators, initDeclarator(declOption));
457
        	while (LTcatchEOF(1) == IToken.tCOMMA) {
435
        }
458
        		consume();
436
        declarators= (IASTDeclarator[]) ArrayUtil.removeNulls( IASTDeclarator.class, declarators );
459
        		try {
460
        			dtor= initDeclarator(declOption);
461
        		} catch (FoundAggregateInitializer e) {
462
        	        // scalability: don't keep references to tokens, initializer may be large
463
        			declarationMark= null;
464
        			markBeforDtor= null;
465
        			dtor= addInitializer(e);
466
        		}
467
        		declarators= (IASTDeclarator[]) ArrayUtil.append( IASTDeclarator.class, declarators, dtor);
468
        	}
469
        	declarators= (IASTDeclarator[]) ArrayUtil.removeNulls( IASTDeclarator.class, declarators );
437
470
438
        boolean insertSemi= false;
471
        	final int lt1= LTcatchEOF(1);
439
        final int lt1= LTcatchEOF(1);
472
        	switch (lt1) {
440
        switch (lt1) {
473
        	case IToken.tLBRACE:
441
        case IToken.tLBRACE:
474
        		return functionDefinition(firstOffset, declSpec, declarators);
442
            return functionDefinition(firstOffset, declSpec, declarators);
443
475
444
        case IToken.tSEMI:
476
        	case IToken.tSEMI:
445
            endOffset= consume().getEndOffset();
477
        		endOffset= consume().getEndOffset();
446
            break;
478
        		break;
447
        case IToken.tEOC:
479
        	case IToken.tEOC:
448
        	endOffset= figureEndOffset(declSpec, declarators);
480
        		endOffset= figureEndOffset(declSpec, declarators);
449
            break;
481
        		break;
450
        default:
482
        	default:
451
        	if (declOption != DeclarationOptions.LOCAL) {
483
        		if (declOption != DeclarationOptions.LOCAL) {
452
        		insertSemi= true;
484
        			insertSemi= true;
453
        		if (markBeforDtor == null || !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) {
485
        			if (markBeforDtor != null && !isOnSameLine(calculateEndOffset(declSpec), markBeforDtor.getOffset())) {
454
        			if (markBeforDtor != null) {
455
        				backup(markBeforDtor);
486
        				backup(markBeforDtor);
487
        				declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
488
        				endOffset= calculateEndOffset(declSpec);
489
        				break;
490
        			}
491
        			endOffset= figureEndOffset(declSpec, declarators);
492
        			if (lt1 == 0 || !isOnSameLine(endOffset, LA(1).getOffset())) {
493
        				break;
494
        			}
495
        			if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) {
496
        				break;
456
        			}
497
        			}
457
        			declarators= IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
458
        			endOffset= calculateEndOffset(declSpec);
459
        			break;
460
        		}
461
        		endOffset= figureEndOffset(declSpec, declarators);
462
        		if (lt1 == 0 || !isOnSameLine(endOffset, LA(1).getOffset())) {
463
        			break;
464
        		}
465
        		if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) {
466
        			break;
467
        		}
498
        		}
499
        		throwBacktrack(LA(1));
468
        	}
500
        	}
469
        	throwBacktrack(LA(1));
470
        }
501
        }
471
502
472
        // no function body
503
        // no function body
Lines 657-663 Link Here
657
        			consume(IToken.tRPAREN).getEndOffset();
688
        			consume(IToken.tRPAREN).getEndOffset();
658
                	if (LT(1) == IToken.tLBRACE) {
689
                	if (LT(1) == IToken.tLBRACE) {
659
        				final List<IASTNode> emptyList = Collections.emptyList();
690
        				final List<IASTNode> emptyList = Collections.emptyList();
660
						IASTInitializer i = cInitializerClause(emptyList);
691
						IASTInitializer i = cInitializerClause(emptyList, false);
661
        				firstExpression = buildTypeIdInitializerExpression(t, i, offset, calculateEndOffset(i));
692
        				firstExpression = buildTypeIdInitializerExpression(t, i, offset, calculateEndOffset(i));
662
        				break;        
693
        				break;        
663
                	}
694
                	}
Lines 896-901 Link Here
896
            	declSpecifier= e.declSpec;
927
            	declSpecifier= e.declSpec;
897
            	declarator= e.declarator;
928
            	declarator= e.declarator;
898
            	backup(e.currToken);
929
            	backup(e.currToken);
930
            } catch (FoundAggregateInitializer lie) {
931
                // type-ids have not compound initializers
932
            	return null;
899
            }
933
            }
900
        } catch (BacktrackException bt) {
934
        } catch (BacktrackException bt) {
901
        	return null;
935
        	return null;
Lines 982-988 Link Here
982
1016
983
    @Override
1017
    @Override
984
	protected IASTDeclSpecifier declSpecifierSeq(final DeclarationOptions declOption)
1018
	protected IASTDeclSpecifier declSpecifierSeq(final DeclarationOptions declOption)
985
            throws BacktrackException, EndOfFileException, FoundDeclaratorException {
1019
            throws BacktrackException, EndOfFileException, FoundDeclaratorException, FoundAggregateInitializer {
986
1020
987
        final int offset= LA(1).getOffset();
1021
        final int offset= LA(1).getOffset();
988
        int endOffset= offset;
1022
        int endOffset= offset;
Lines 1141-1146 Link Here
1141
                	if (endOffset != offset || declOption.fAllowEmptySpecifier) {
1175
                	if (endOffset != offset || declOption.fAllowEmptySpecifier) {
1142
                		lookAheadForDeclarator(declOption);
1176
                		lookAheadForDeclarator(declOption);
1143
                	}
1177
                	}
1178
                } catch (FoundAggregateInitializer e) {
1179
                	e.fDeclSpec= createSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
1180
                	throw e;
1144
                } catch (FoundDeclaratorException e) {
1181
                } catch (FoundDeclaratorException e) {
1145
                	e.declSpec= createSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
1182
                	e.declSpec= createSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
1146
1183
Lines 1152-1157 Link Here
1152
							e.altDeclarator= altDtor;
1189
							e.altDeclarator= altDtor;
1153
                			e.altSpec= createNamedTypeSpecifier(idToken, storageClass, options, offset, idToken.getEndOffset());
1190
                			e.altSpec= createNamedTypeSpecifier(idToken, storageClass, options, offset, idToken.getEndOffset());
1154
                		}
1191
                		}
1192
                	} catch (FoundAggregateInitializer lie) {
1193
                		lie.fDeclSpec= e.declSpec;
1194
                		throw lie;
1155
                	} catch (BacktrackException bt) {
1195
                	} catch (BacktrackException bt) {
1156
                	} finally {
1196
                	} finally {
1157
                		backup(mark);
1197
                		backup(mark);
Lines 1485-1493 Link Here
1485
    }
1525
    }
1486
1526
1487
    @Override
1527
    @Override
1488
	protected IASTDeclarator initDeclarator(final DeclarationOptions option) throws EndOfFileException, BacktrackException {
1528
	protected IASTDeclarator initDeclarator(final DeclarationOptions option) 
1529
    		throws EndOfFileException, BacktrackException, FoundAggregateInitializer {
1489
        IASTDeclarator d = declarator(option);
1530
        IASTDeclarator d = declarator(option);
1490
1531
1532
        if (LT(1) == IToken.tASSIGN && LT(2) == IToken.tLBRACE) 
1533
        	throw new FoundAggregateInitializer(d);
1534
       
1491
        IASTInitializer i = optionalCInitializer();
1535
        IASTInitializer i = optionalCInitializer();
1492
        if (i != null) {
1536
        if (i != null) {
1493
            d.setInitializer(i);
1537
            d.setInitializer(i);
Lines 1495-1500 Link Here
1495
        }
1539
        }
1496
        return d;
1540
        return d;
1497
    }
1541
    }
1542
    
1543
    @Override
1544
	protected IASTDeclarator addInitializer(FoundAggregateInitializer e) throws EndOfFileException {
1545
	    final IASTDeclarator d = e.fDeclarator;
1546
        try {
1547
			IASTInitializer i = optionalCInitializer();
1548
			if (i != null) {
1549
				d.setInitializer(i);
1550
			    ((ASTNode) d).setLength(calculateEndOffset(i) - ((ASTNode) d).getOffset());
1551
			}
1552
		} catch (BacktrackException e1) {
1553
			// mstodo add problem node
1554
		}
1555
		return d;
1556
    }
1498
1557
1499
    protected IASTDeclarator declarator(DeclarationOptions option) throws EndOfFileException, BacktrackException {
1558
    protected IASTDeclarator declarator(DeclarationOptions option) throws EndOfFileException, BacktrackException {
1500
        final int startingOffset = LA(1).getOffset();
1559
        final int startingOffset = LA(1).getOffset();
Lines 1968-1973 Link Here
1968
        	altDeclSpec= fd.altSpec;
2027
        	altDeclSpec= fd.altSpec;
1969
        	altDeclarator= fd.altDeclarator;
2028
        	altDeclarator= fd.altDeclarator;
1970
        	backup(fd.currToken);
2029
        	backup(fd.currToken);
2030
        } catch (FoundAggregateInitializer lie) {
2031
        	if (declSpec == null)
2032
        		declSpec= lie.fDeclSpec;
2033
        	declarator= addInitializer(lie);
1971
        } finally {
2034
        } finally {
1972
        	fPreventKnrCheck--;
2035
        	fPreventKnrCheck--;
1973
        }
2036
        }
(-)parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java (-1 / +2 lines)
Lines 219-225 Link Here
219
		}
219
		}
220
		fTodoTaskUpdater= createTodoTaskUpdater();
220
		fTodoTaskUpdater= createTodoTaskUpdater();
221
		
221
		
222
		fASTOptions= ILanguage.OPTION_ADD_COMMENTS | ILanguage.OPTION_NO_IMAGE_LOCATIONS;
222
		fASTOptions= ILanguage.OPTION_ADD_COMMENTS | ILanguage.OPTION_NO_IMAGE_LOCATIONS 
223
				| ILanguage.OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS;
223
		if (getSkipReferences() == SKIP_ALL_REFERENCES) {
224
		if (getSkipReferences() == SKIP_ALL_REFERENCES) {
224
			fASTOptions |= ILanguage.OPTION_SKIP_FUNCTION_BODIES;
225
			fASTOptions |= ILanguage.OPTION_SKIP_FUNCTION_BODIES;
225
		}
226
		}

Return to bug 253690