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

(-)ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java (-1 / +1 lines)
Lines 266-272 Link Here
266
            if (sel instanceof ITextSelection) {
266
            if (sel instanceof ITextSelection) {
267
            	final ITextSelection textSel = (ITextSelection)sel;
267
            	final ITextSelection textSel = (ITextSelection)sel;
268
            	ITranslationUnit tu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
268
            	ITranslationUnit tu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
269
        		IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_YES, monitor, new ASTRunnable() {
269
        		IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, monitor, new ASTRunnable() {
270
        			public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
270
        			public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
271
        				result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());        	
271
        				result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());        	
272
        				return Status.OK_STATUS;
272
        				return Status.OK_STATUS;
(-)ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java (-1 / +1 lines)
Lines 288-294 Link Here
288
            if (sel instanceof ITextSelection) {
288
            if (sel instanceof ITextSelection) {
289
            	final ITextSelection textSel = (ITextSelection)sel;
289
            	final ITextSelection textSel = (ITextSelection)sel;
290
            	ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(file);
290
            	ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(file);
291
        		IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_YES, monitor, new ASTRunnable() {
291
        		IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, monitor, new ASTRunnable() {
292
        			public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
292
        			public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
293
        				result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());
293
        				result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());
294
        				return Status.OK_STATUS;
294
        				return Status.OK_STATUS;
(-)ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java (-1 / +2 lines)
Lines 74-79 Link Here
74
		super(name);
74
		super(name);
75
	}
75
	}
76
	
76
	
77
	@Override
77
	protected void setUp() throws Exception {
78
	protected void setUp() throws Exception {
78
		super.setUp();
79
		super.setUp();
79
		OpenDeclarationsAction.sIsJUnitTest= true;
80
		OpenDeclarationsAction.sIsJUnitTest= true;
Lines 219-225 Link Here
219
            if (sel instanceof ITextSelection) {
220
            if (sel instanceof ITextSelection) {
220
            	final ITextSelection textSel = (ITextSelection)sel;
221
            	final ITextSelection textSel = (ITextSelection)sel;
221
            	ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(file);
222
            	ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(file);
222
        		IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_YES, monitor, new ASTRunnable() {
223
        		IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, monitor, new ASTRunnable() {
223
        			public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
224
        			public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
224
        				result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());
225
        				result[0]= ast.getNodeSelector(null).findName(textSel.getOffset(), textSel.getLength());
225
        				return Status.OK_STATUS;
226
        				return Status.OK_STATUS;
(-)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 (-1 / +1 lines)
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
		}
(-)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