View | Details | Raw Unified | Return to bug 169860 | Differences between
and this patch

Collapse All | Expand All

(-)parser/org/eclipse/cdt/internal/pdom/tests/NamespaceTests.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation.
2
 * Copyright (c) 2006 2007 IBM Corporation.
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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.cdt.internal.pdom.tests;
13
package org.eclipse.cdt.internal.pdom.tests;
Lines 62-68 Link Here
62
		}
63
		}
63
	}
64
	}
64
	
65
	
65
	public void _testAlias() throws Exception {
66
	public void testAlias() throws Exception {
66
		/* Find all the namespace */
67
		/* Find all the namespace */
67
		IBinding[] namespaces = pdom.findBindings(Pattern.compile("namespace1"), false, INDEX_FILTER, NULL_MONITOR);
68
		IBinding[] namespaces = pdom.findBindings(Pattern.compile("namespace1"), false, INDEX_FILTER, NULL_MONITOR);
68
		assertEquals(1, namespaces.length);
69
		assertEquals(1, namespaces.length);
(-)parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java (-7 / +6 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.core.parser.tests.prefix;
12
package org.eclipse.cdt.core.parser.tests.prefix;
12
13
Lines 54-62 Link Here
54
		assertEquals("func2", ((IFunction)bindings[1]).getName());
55
		assertEquals("func2", ((IFunction)bindings[1]).getName());
55
		// The second name shouldn't be hooked up
56
		// The second name shouldn't be hooked up
56
		assertNull(names[1].getTranslationUnit());
57
		assertNull(names[1].getTranslationUnit());
57
		// The declaration should point to nothing since there are no types
58
		// The third name shouldn't be hooked up either
58
		bindings = names[2].resolvePrefix();
59
		assertNull(names[2].getTranslationUnit());
59
		assertEquals(0, bindings.length);
60
60
61
		// C
61
		// C
62
		node = getGCCCompletionNode(code.toString());
62
		node = getGCCCompletionNode(code.toString());
Lines 69-77 Link Here
69
		assertEquals(2, bindings.length);
69
		assertEquals(2, bindings.length);
70
		assertEquals("func", ((IFunction)bindings[0]).getName());
70
		assertEquals("func", ((IFunction)bindings[0]).getName());
71
		assertEquals("func2", ((IFunction)bindings[1]).getName());
71
		assertEquals("func2", ((IFunction)bindings[1]).getName());
72
		// The declaration should point to nothing since there are no types
72
		// The second name shouldn't be hooked up
73
		bindings = names[1].resolvePrefix();
73
		assertNull(names[1].getTranslationUnit());
74
		assertEquals(0, bindings.length);
75
	}
74
	}
76
75
77
	public void testTypedef() throws Exception {
76
	public void testTypedef() throws Exception {
(-)src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProcessor2.java (-6 / +12 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM - Initial API and implementation
9
 * IBM - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.internal.ui.text.contentassist;
12
package org.eclipse.cdt.internal.ui.text.contentassist;
12
13
Lines 29-37 Link Here
29
import org.eclipse.ui.IEditorPart;
30
import org.eclipse.ui.IEditorPart;
30
31
31
import org.eclipse.cdt.core.CCorePlugin;
32
import org.eclipse.cdt.core.CCorePlugin;
33
import org.eclipse.cdt.core.dom.IPDOMManager;
32
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
34
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
33
import org.eclipse.cdt.core.index.IIndex;
35
import org.eclipse.cdt.core.index.IIndex;
34
import org.eclipse.cdt.core.index.IIndexManager;
36
import org.eclipse.cdt.core.index.IIndexManager;
37
import org.eclipse.cdt.core.model.ITranslationUnit;
35
import org.eclipse.cdt.core.model.IWorkingCopy;
38
import org.eclipse.cdt.core.model.IWorkingCopy;
36
import org.eclipse.cdt.ui.CUIPlugin;
39
import org.eclipse.cdt.ui.CUIPlugin;
37
import org.eclipse.cdt.ui.text.ICCompletionProposal;
40
import org.eclipse.cdt.ui.text.ICCompletionProposal;
Lines 78-88 Link Here
78
				String prefix = null;
81
				String prefix = null;
79
	
82
	
80
				if (workingCopy != null) {
83
				if (workingCopy != null) {
81
					// TODO, to improve performance, we want to skip all headers
84
					IPDOMManager manager = CCorePlugin.getPDOMManager();
82
					// But right now we're not getting any completions
85
					String indexerId = manager.getIndexerId(workingCopy.getCProject());
83
//					fCurrentCompletionNode = workingCopy.getCompletionNode(index, ITranslationUnit.AST_SKIP_ALL_HEADERS, offset);
86
					int flags = ITranslationUnit.AST_SKIP_ALL_HEADERS;
84
					fCurrentCompletionNode = workingCopy.getCompletionNode(index, 0, offset);
87
					if (IPDOMManager.ID_NO_INDEXER.equals(indexerId)) {
85
	
88
						flags = 0;
89
					}
90
					fCurrentCompletionNode = workingCopy.getCompletionNode(index, flags, offset);
91
					
86
	                if (fCurrentCompletionNode != null)
92
	                if (fCurrentCompletionNode != null)
87
	                    prefix = fCurrentCompletionNode.getPrefix();
93
	                    prefix = fCurrentCompletionNode.getPrefix();
88
	            }
94
	            }
(-)src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionContributor.java (-2 / +8 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Anton Leherbauer (Wind River Systems)
10
 *     Anton Leherbauer (Wind River Systems)
11
 *     Bryan Wilkinson (QNX)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.cdt.internal.ui.text.contentassist;
13
package org.eclipse.cdt.internal.ui.text.contentassist;
13
14
Lines 23-28 Link Here
23
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
24
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
24
import org.eclipse.cdt.core.dom.ast.DOMException;
25
import org.eclipse.cdt.core.dom.ast.DOMException;
25
import org.eclipse.cdt.core.dom.ast.IASTFunctionStyleMacroParameter;
26
import org.eclipse.cdt.core.dom.ast.IASTFunctionStyleMacroParameter;
27
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
26
import org.eclipse.cdt.core.dom.ast.IASTName;
28
import org.eclipse.cdt.core.dom.ast.IASTName;
27
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorFunctionStyleMacroDefinition;
29
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorFunctionStyleMacroDefinition;
28
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
30
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
Lines 48-53 Link Here
48
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
50
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
49
import org.eclipse.cdt.core.model.IWorkingCopy;
51
import org.eclipse.cdt.core.model.IWorkingCopy;
50
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
52
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
53
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
51
import org.eclipse.cdt.ui.CUIPlugin;
54
import org.eclipse.cdt.ui.CUIPlugin;
52
import org.eclipse.cdt.ui.text.contentassist.ICompletionContributor;
55
import org.eclipse.cdt.ui.text.contentassist.ICompletionContributor;
53
56
Lines 61-67 Link Here
61
											  ASTCompletionNode completionNode,
64
											  ASTCompletionNode completionNode,
62
                                              String prefix,
65
                                              String prefix,
63
											  List proposals) {
66
											  List proposals) {
67
		
64
		if (completionNode != null) {
68
		if (completionNode != null) {
69
			boolean handleMacros = false;
65
			IASTName[] names = completionNode.getNames();
70
			IASTName[] names = completionNode.getNames();
66
			if (names == null || names.length == 0)
71
			if (names == null || names.length == 0)
67
				// No names, not much we can do here
72
				// No names, not much we can do here
Lines 74-79 Link Here
74
					// The node isn't properly hooked up, must have backtracked out of this node
79
					// The node isn't properly hooked up, must have backtracked out of this node
75
					continue;
80
					continue;
76
				IBinding[] bindings = names[i].resolvePrefix();
81
				IBinding[] bindings = names[i].resolvePrefix();
82
				if (names[i].getParent() instanceof IASTIdExpression) handleMacros = true;
77
				if (bindings != null)
83
				if (bindings != null)
78
					for (int j = 0; j < bindings.length; ++j) {
84
					for (int j = 0; j < bindings.length; ++j) {
79
						IBinding binding = bindings[j];
85
						IBinding binding = bindings[j];
Lines 91-101 Link Here
91
			}
97
			}
92
			
98
			
93
			// Find all macros if there is a prefix
99
			// Find all macros if there is a prefix
94
			if (prefix.length() > 0) {
100
			if (prefix.length() > 0 && handleMacros) {
95
				IASTPreprocessorMacroDefinition[] macros = completionNode.getTranslationUnit().getMacroDefinitions();
101
				IASTPreprocessorMacroDefinition[] macros = completionNode.getTranslationUnit().getMacroDefinitions();
96
				if (macros != null)
102
				if (macros != null)
97
					for (int i = 0; i < macros.length; ++i)
103
					for (int i = 0; i < macros.length; ++i)
98
						if (macros[i].getName().toString().startsWith(prefix))
104
						if (CharArrayUtils.equals(macros[i].getName().toCharArray(), 0, prefix.length(), prefix.toCharArray(), false))
99
							handleMacro(macros[i], completionNode, offset, viewer, proposals);
105
							handleMacro(macros[i], completionNode, offset, viewer, proposals);
100
			}
106
			}
101
        }
107
        }
(-)ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java (-3 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2006, 2007 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Anton Leherbauer (Wind River Systems) - initial API and implementation
9
 *     Anton Leherbauer (Wind River Systems) - initial API and implementation
10
 *     Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
13
Lines 239-245 Link Here
239
	//void f() {gf/*cursor*/
240
	//void f() {gf/*cursor*/
240
	public void testGlobalFunctions_GlobalScope() throws Exception {
241
	public void testGlobalFunctions_GlobalScope() throws Exception {
241
		final String[] expected= {
242
		final String[] expected= {
242
				"gfC1(void)", "gfC2(void)", "gfC3(void)"
243
				"gfC1(void)", "gfC2(void)"
244
				/* gfC3(void) is not expected since static methods are only
245
				 * accessible inside the file in which it is defined
246
				 */
243
		};
247
		};
244
		assertCompletionResults(fCursorOffset, expected, true);
248
		assertCompletionResults(fCursorOffset, expected, true);
245
	}
249
	}
Lines 247-253 Link Here
247
	//void C3::f() {gf/*cursor*/
251
	//void C3::f() {gf/*cursor*/
248
	public void testGlobalFunctions_MethodScope() throws Exception {
252
	public void testGlobalFunctions_MethodScope() throws Exception {
249
		final String[] expected= {
253
		final String[] expected= {
250
				"gfC1(void)", "gfC2(void)", "gfC3(void)"
254
				"gfC1(void)", "gfC2(void)"
255
				/* gfC3(void) is not expected since static methods are only
256
				 * accessible inside the file in which it is defined
257
				 */
251
		};
258
		};
252
		assertCompletionResults(fCursorOffset, expected, true);
259
		assertCompletionResults(fCursorOffset, expected, true);
253
	}
260
	}
(-)ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_VariableType_NoPrefix.java (-3 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM Rational Software - Initial API and implementation
9
 * IBM Rational Software - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
import junit.framework.Test;
13
import junit.framework.Test;
Lines 38-45 Link Here
38
	
39
	
39
	public CompletionTest_VariableType_NoPrefix(String name) {
40
	public CompletionTest_VariableType_NoPrefix(String name) {
40
		super(name);
41
		super(name);
41
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860
42
		setExpectFailure(169860);
43
	}
42
	}
44
	
43
	
45
	public static Test suite() {
44
	public static Test suite() {
(-)ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_NoPrefix.java (-3 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM Rational Software - Initial API and implementation
9
 * IBM Rational Software - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
import junit.framework.Test;
13
import junit.framework.Test;
Lines 33-40 Link Here
33
	
34
	
34
	public CompletionTest_NamespaceRef_NoPrefix(String name) {
35
	public CompletionTest_NamespaceRef_NoPrefix(String name) {
35
		super(name);
36
		super(name);
36
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860
37
		setExpectFailure(169860);
38
	}
37
	}
39
38
40
	public static Test suite() {
39
	public static Test suite() {
(-)ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_FieldType_NoPrefix2.java (-3 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM Rational Software - Initial API and implementation
9
 * IBM Rational Software - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
import junit.framework.Test;
13
import junit.framework.Test;
Lines 41-48 Link Here
41
	
42
	
42
	public CompletionTest_FieldType_NoPrefix2(String name) {
43
	public CompletionTest_FieldType_NoPrefix2(String name) {
43
		super(name);
44
		super(name);
44
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860
45
		setExpectFailure(169860);
46
	}
45
	}
47
46
48
	public static Test suite() {
47
	public static Test suite() {
(-)ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ClassReference_Prefix.java (-3 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
13
Lines 34-41 Link Here
34
	
35
	
35
	public CompletionTest_ClassReference_Prefix(String name) {
36
	public CompletionTest_ClassReference_Prefix(String name) {
36
		super(name);
37
		super(name);
37
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860
38
		setExpectFailure(169860);
39
	}
38
	}
40
39
41
	public static Test suite() {
40
	public static Test suite() {
(-)ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_FieldType_NoPrefix.java (-3 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM Rational Software - Initial API and implementation
9
 * IBM Rational Software - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
13
Lines 40-47 Link Here
40
	
41
	
41
	public CompletionTest_FieldType_NoPrefix(String name) {
42
	public CompletionTest_FieldType_NoPrefix(String name) {
42
		super(name);
43
		super(name);
43
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860
44
		setExpectFailure(169860);
45
	}
44
	}
46
	
45
	
47
	public static Test suite() {
46
	public static Test suite() {
(-)ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ArgumentType_NoPrefix2.java (-3 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM Rational Software - Initial API and implementation
9
 * IBM Rational Software - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
13
Lines 41-48 Link Here
41
	
42
	
42
	public CompletionTest_ArgumentType_NoPrefix2(String name) {
43
	public CompletionTest_ArgumentType_NoPrefix2(String name) {
43
		super(name);
44
		super(name);
44
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860
45
		setExpectFailure(169860);
46
	}
45
	}
47
	
46
	
48
	public static Test suite() {
47
	public static Test suite() {
(-)ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ClassReference_NoPrefix.java (-3 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM Rational Software - Initial API and implementation
9
 * IBM Rational Software - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
13
Lines 36-43 Link Here
36
	
37
	
37
	public CompletionTest_ClassReference_NoPrefix(String name) {
38
	public CompletionTest_ClassReference_NoPrefix(String name) {
38
		super(name);
39
		super(name);
39
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860
40
		setExpectFailure(169860);
41
	}
40
	}
42
41
43
	public static Test suite() {
42
	public static Test suite() {
(-)ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeRef_NoPrefix.java (-3 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM Rational Software - Initial API and implementation
9
 * IBM Rational Software - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
import junit.framework.Test;
13
import junit.framework.Test;
Lines 33-40 Link Here
33
	
34
	
34
	public CompletionTest_TypeRef_NoPrefix(String name) {
35
	public CompletionTest_TypeRef_NoPrefix(String name) {
35
		super(name);
36
		super(name);
36
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860
37
		setExpectFailure(169860);
38
	}
37
	}
39
38
40
	public static Test suite() {
39
	public static Test suite() {
(-)ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_Prefix.java (-3 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM Rational Software - Initial API and implementation
9
 * IBM Rational Software - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
13
Lines 33-40 Link Here
33
	
34
	
34
	public CompletionTest_NamespaceRef_Prefix(String name) {
35
	public CompletionTest_NamespaceRef_Prefix(String name) {
35
		super(name);
36
		super(name);
36
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860
37
		setExpectFailure(169860);
38
	}
37
	}
39
38
40
	public static Test suite() {
39
	public static Test suite() {
(-)ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeRef_Prefix.java (-3 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM Rational Software - Initial API and implementation
9
 * IBM Rational Software - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
13
Lines 33-40 Link Here
33
	
34
	
34
	public CompletionTest_TypeRef_Prefix(String name) {
35
	public CompletionTest_TypeRef_Prefix(String name) {
35
		super(name);
36
		super(name);
36
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860
37
		setExpectFailure(169860);
38
	}
37
	}
39
38
40
	public static Test suite() {
39
	public static Test suite() {
(-)ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ExceptionReference_NoPrefix.java (-3 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM Rational Software - Initial API and implementation
9
 * IBM Rational Software - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
13
Lines 42-49 Link Here
42
	
43
	
43
	public CompletionTest_ExceptionReference_NoPrefix(String name) {
44
	public CompletionTest_ExceptionReference_NoPrefix(String name) {
44
		super(name);
45
		super(name);
45
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860
46
		setExpectFailure(169860);
47
	}
46
	}
48
47
49
	public static Test suite() {
48
	public static Test suite() {
(-)ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ArgumentType_NoPrefix.java (-3 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM Rational Software - Initial API and implementation
9
 * IBM Rational Software - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
package org.eclipse.cdt.ui.tests.text.contentassist2;
12
13
Lines 41-48 Link Here
41
	
42
	
42
	public CompletionTest_ArgumentType_NoPrefix(String name) {
43
	public CompletionTest_ArgumentType_NoPrefix(String name) {
43
		super(name);
44
		super(name);
44
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=169860
45
		setExpectFailure(169860);
46
	}
45
	}
47
	
46
	
48
	public static Test suite() {
47
	public static Test suite() {
(-)parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2006 QNX Software Systems and others.
2
 * Copyright (c) 2005, 2007 QNX Software Systems 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 97-103 Link Here
97
				scanner,
97
				scanner,
98
				ParserMode.COMPLETION_PARSE,
98
				ParserMode.COMPLETION_PARSE,
99
				ParserUtil.getParserLogService(),
99
				ParserUtil.getParserLogService(),
100
				new GPPParserExtensionConfiguration());
100
				new GPPParserExtensionConfiguration(),
101
				index);
101
		
102
		
102
		// Run the parse and return the completion node
103
		// Run the parse and return the completion node
103
		parser.parse();
104
		parser.parse();
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstanceScope.java (-1 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
2
 * Copyright (c) 2005, 2007 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 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 * IBM - Initial API and implementation
9
 * IBM - Initial API and implementation
10
 * Markus Schorn (Wind River Systems)
10
 * Markus Schorn (Wind River Systems)
11
 * Bryan Wilkinson (QNX)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
/*
13
/*
13
 * Created on Mar 28, 2005
14
 * Created on Mar 28, 2005
Lines 243-248 Link Here
243
	 * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
244
	 * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
244
	 */
245
	 */
245
	public IBinding[] find(String name) {
246
	public IBinding[] find(String name) {
247
		return find(name, false);
248
	}
249
	
250
	/* (non-Javadoc)
251
	 * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
252
	 */
253
	public IBinding[] find(String name, boolean prefixLookup) {
246
		if( name != null ) {}
254
		if( name != null ) {}
247
		return null;
255
		return null;
248
	}
256
	}
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java (-2 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Markus Schorn (Wind River Systems)
10
 *     Markus Schorn (Wind River Systems)
11
 *     Bryan Wilkinson (QNX)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
/*
13
/*
13
 * Created on Nov 29, 2004
14
 * Created on Nov 29, 2004
Lines 201-207 Link Here
201
	 * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
202
	 * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
202
	 */
203
	 */
203
	public IBinding[] find(String name) throws DOMException {
204
	public IBinding[] find(String name) throws DOMException {
204
	    return CPPSemantics.findBindings( this, name, false );
205
	    return CPPSemantics.findBindings( this, name, false, false );
206
	}
207
	
208
	/* (non-Javadoc)
209
	 * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
210
	 */
211
	public IBinding[] find(String name, boolean prefixLookup) throws DOMException {
212
	    return CPPSemantics.findBindings( this, name, false, prefixLookup );
205
	}
213
	}
206
	
214
	
207
	public void flushCache() {
215
	public void flushCache() {
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTIdExpression.java (-1 / +40 lines)
Lines 7-24 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM - Initial API and implementation
9
 * IBM - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.internal.core.dom.parser.cpp;
12
package org.eclipse.cdt.internal.core.dom.parser.cpp;
12
13
13
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
14
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
15
import org.eclipse.cdt.core.dom.ast.DOMException;
14
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
16
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
15
import org.eclipse.cdt.core.dom.ast.IASTName;
17
import org.eclipse.cdt.core.dom.ast.IASTName;
18
import org.eclipse.cdt.core.dom.ast.IBinding;
19
import org.eclipse.cdt.core.dom.ast.IScope;
16
import org.eclipse.cdt.core.dom.ast.IType;
20
import org.eclipse.cdt.core.dom.ast.IType;
21
import org.eclipse.cdt.core.index.IIndex;
22
import org.eclipse.cdt.core.index.IndexFilter;
23
import org.eclipse.cdt.core.parser.util.ArrayUtil;
24
import org.eclipse.cdt.internal.core.dom.Linkage;
25
import org.eclipse.cdt.internal.core.dom.parser.IASTCompletionContext;
26
import org.eclipse.core.runtime.CoreException;
17
27
18
/**
28
/**
19
 * @author jcamelon
29
 * @author jcamelon
20
 */
30
 */
21
public class CPPASTIdExpression extends CPPASTNode implements IASTIdExpression {
31
public class CPPASTIdExpression extends CPPASTNode implements IASTIdExpression, IASTCompletionContext {
22
    private IASTName name;
32
    private IASTName name;
23
33
24
    public IASTName getName() {
34
    public IASTName getName() {
Lines 59-62 Link Here
59
		return CPPVisitor.getExpressionType(this);
69
		return CPPVisitor.getExpressionType(this);
60
	}
70
	}
61
	
71
	
72
	public IBinding[] resolvePrefix(IASTName n) {
73
		IScope scope = CPPVisitor.getContainingScope(n);
74
		
75
		IBinding[] b1 = null;
76
		if (scope != null) {
77
			try {
78
				b1 = scope.find(n.toString(), true);
79
			} catch (DOMException e) {
80
			}	
81
		}
82
		
83
		IIndex index = getTranslationUnit().getIndex();
84
		
85
		IBinding[] b2 = null;
86
		if (index != null) {
87
			try {
88
				b2 = index.findBindingsForPrefix(
89
						n.toString(),
90
						IndexFilter.getFilter(Linkage.CPP_LINKAGE));
91
			} catch (CoreException e) {
92
			} 	
93
		}
94
		
95
		int size = (b1 == null ? 0 : b1.length) + (b2 == null ? 0 : b2.length);
96
		IBinding[] all = new IBinding[size];
97
		if (b1 != null) ArrayUtil.addAll(IBinding.class, all, b1);
98
		if (b2 != null) ArrayUtil.addAll(IBinding.class, all, b2);
99
		return all;
100
	}
62
}
101
}
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java (-8 / +40 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 * IBM - Initial API and implementation
9
 * IBM - Initial API and implementation
10
 * Markus Schorn (Wind River Systems)
10
 * Markus Schorn (Wind River Systems)
11
 * Bryan Wilkinson (QNX)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
/*
13
/*
13
 * Created on Dec 8, 2004
14
 * Created on Dec 8, 2004
Lines 90-95 Link Here
90
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement;
91
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement;
91
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
92
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
92
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
93
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
94
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
93
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
95
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
94
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
96
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
95
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
97
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
Lines 116-121 Link Here
116
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
118
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
117
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
119
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
118
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
120
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
121
import org.eclipse.cdt.core.index.IIndex;
119
import org.eclipse.cdt.core.index.IIndexBinding;
122
import org.eclipse.cdt.core.index.IIndexBinding;
120
import org.eclipse.cdt.core.parser.util.ArrayUtil;
123
import org.eclipse.cdt.core.parser.util.ArrayUtil;
121
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
124
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
Lines 127-132 Link Here
127
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
130
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
128
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
131
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
129
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
132
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
133
import org.eclipse.core.runtime.CoreException;
130
134
131
/**
135
/**
132
 * @author aniefer
136
 * @author aniefer
Lines 1023-1028 Link Here
1023
						b= scope.getBinding( data.astName, false );
1027
						b= scope.getBinding( data.astName, false );
1024
						if (b instanceof CPPImplicitFunction || b instanceof CPPImplicitTypedef) 
1028
						if (b instanceof CPPImplicitFunction || b instanceof CPPImplicitTypedef) 
1025
							mergeResults( data, b, true );
1029
							mergeResults( data, b, true );
1030
					} else if (data.prefixLookup && data.astName != null) {
1031
						IASTNode parent = ASTInternal.getPhysicalNodeOfScope(scope);
1032
						if (parent == null && scope instanceof IIndexBinding) {
1033
							IBinding[] bindings = scope.find(data.astName.toString(), data.prefixLookup);
1034
							mergeResults(data, bindings, true);
1035
						} else if (scope instanceof ICPPNamespaceScope && !(scope instanceof ICPPBlockScope)) {
1036
							ICPPNamespaceScope ns = (ICPPNamespaceScope) scope;
1037
							IIndex index = parent.getTranslationUnit().getIndex();
1038
							if (index != null) {
1039
								try {
1040
									IIndexBinding binding = index.findBinding(ns.getScopeName());
1041
									if (binding instanceof ICPPNamespaceScope) {
1042
										ICPPNamespaceScope indexNs = (ICPPNamespaceScope) binding;
1043
										IBinding[] bindings = indexNs.find(data.astName.toString(), data.prefixLookup);
1044
										mergeResults(data, bindings, true);
1045
									}
1046
								} catch (CoreException e) {
1047
								}
1048
							}
1049
						}
1026
					}
1050
					}
1027
				    IASTName[] inScope = lookupInScope( data, scope, blockItem );
1051
				    IASTName[] inScope = lookupInScope( data, scope, blockItem );
1028
				    if (inScope != null) {
1052
				    if (inScope != null) {
Lines 1789-1796 Link Here
1789
	    }
1813
	    }
1790
	    char[] c = potential.toCharArray();
1814
	    char[] c = potential.toCharArray();
1791
	    char [] n = data.name();
1815
	    char [] n = data.name();
1792
	    return ( (data.prefixLookup && CharArrayUtils.equals( c, 0, n.length, n )) || 
1816
	    return (data.prefixLookup && CharArrayUtils.equals(c, 0, n.length, n, false))
1793
			     (!data.prefixLookup && CharArrayUtils.equals( c, n )) );
1817
			|| (!data.prefixLookup && CharArrayUtils.equals(c, n));
1794
	}
1818
	}
1795
	
1819
	
1796
	private static void addDefinition( IBinding binding, IASTName name ){
1820
	private static void addDefinition( IBinding binding, IASTName name ){
Lines 3251-3265 Link Here
3251
		return null;
3275
		return null;
3252
	}
3276
	}
3253
	
3277
	
3254
	public static IBinding[] findBindings( IScope scope, String name, boolean qualified ) throws DOMException{
3278
	public static IBinding[] findBindings( IScope scope, String name, boolean qualified, boolean prefixLookup ) throws DOMException{
3255
		return findBindings( scope, name.toCharArray(), qualified );
3279
		return findBindings( scope, name.toCharArray(), qualified, prefixLookup );
3256
	}
3280
	}
3257
	public static IBinding[] findBindings( IScope scope, char []name, boolean qualified ) throws DOMException{
3281
	public static IBinding[] findBindings( IScope scope, char []name, boolean qualified, boolean prefixLookup ) throws DOMException{
3258
	    CPPASTName astName = new CPPASTName();
3282
	    CPPASTName astName = new CPPASTName();
3259
	    astName.setName( name );
3283
	    astName.setName( name );
3260
	    astName.setParent( ASTInternal.getPhysicalNodeOfScope(scope));
3284
	    astName.setParent( ASTInternal.getPhysicalNodeOfScope(scope));
3261
	    astName.setPropertyInParent( STRING_LOOKUP_PROPERTY );
3285
	    astName.setPropertyInParent( STRING_LOOKUP_PROPERTY );
3262
	    
3286
	    
3287
	    if (prefixLookup) {
3288
	    	return prefixLookup(astName, scope);
3289
	    }
3290
	    
3263
	    LookupData data = new LookupData( astName );
3291
	    LookupData data = new LookupData( astName );
3264
	    data.forceQualified = qualified;
3292
	    data.forceQualified = qualified;
3265
	            
3293
	            
Lines 3296-3308 Link Here
3296
	    return (IBinding[]) set.keyArray( IBinding.class );
3324
	    return (IBinding[]) set.keyArray( IBinding.class );
3297
	}
3325
	}
3298
	
3326
	
3299
    public static IBinding [] prefixLookup( IASTName name ){
3327
	public static IBinding [] prefixLookup( IASTName name ){
3328
		return prefixLookup(name, name);
3329
	}
3330
	
3331
    public static IBinding [] prefixLookup( IASTName name, Object start ){
3300
        LookupData data = createLookupData( name, true );
3332
        LookupData data = createLookupData( name, true );
3301
        data.prefixLookup = true;
3333
        data.prefixLookup = true;
3302
        data.foundItems = new CharArrayObjectMap( 2 );
3334
        data.foundItems = new CharArrayObjectMap( 2 );
3303
        
3335
        
3304
        try {
3336
        try {
3305
            lookup( data, name );
3337
            lookup( data, start );
3306
        } catch ( DOMException e ) {
3338
        } catch ( DOMException e ) {
3307
        }
3339
        }
3308
        CharArrayObjectMap map = (CharArrayObjectMap) data.foundItems;
3340
        CharArrayObjectMap map = (CharArrayObjectMap) data.foundItems;
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBaseSpecifier.java (-1 / +63 lines)
Lines 7-25 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM - Initial API and implementation
9
 * IBM - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.internal.core.dom.parser.cpp;
12
package org.eclipse.cdt.internal.core.dom.parser.cpp;
12
13
14
import java.util.ArrayList;
15
import java.util.List;
16
17
import org.eclipse.cdt.core.dom.ILinkage;
13
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
18
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
19
import org.eclipse.cdt.core.dom.ast.DOMException;
14
import org.eclipse.cdt.core.dom.ast.IASTName;
20
import org.eclipse.cdt.core.dom.ast.IASTName;
21
import org.eclipse.cdt.core.dom.ast.IBinding;
22
import org.eclipse.cdt.core.dom.ast.IScope;
15
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
23
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
24
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
16
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
25
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
26
import org.eclipse.cdt.core.index.IIndex;
27
import org.eclipse.cdt.core.index.IndexFilter;
28
import org.eclipse.cdt.internal.core.dom.parser.IASTCompletionContext;
29
import org.eclipse.core.runtime.CoreException;
17
30
18
/**
31
/**
19
 * @author jcamelon
32
 * @author jcamelon
20
 */
33
 */
21
public class CPPASTBaseSpecifier extends CPPASTNode implements
34
public class CPPASTBaseSpecifier extends CPPASTNode implements
22
        ICPPASTBaseSpecifier {
35
        ICPPASTBaseSpecifier, IASTCompletionContext {
23
36
24
    private boolean isVirtual;
37
    private boolean isVirtual;
25
    private int visibility;
38
    private int visibility;
Lines 98-101 Link Here
98
		return r_unclear;
111
		return r_unclear;
99
	}
112
	}
100
113
114
	public IBinding[] resolvePrefix(IASTName n) {
115
		List filtered = new ArrayList();
116
		IndexFilter filter = new IndexFilter(){
117
			public boolean acceptBinding(IBinding binding) {
118
				if (binding instanceof ICPPClassType) {
119
					ICPPClassType classType = (ICPPClassType) binding;
120
					try {
121
						int key = classType.getKey();
122
						if (key == ICPPClassType.k_class) {
123
							return true;
124
						}
125
					} catch (DOMException e) {
126
					}
127
				}
128
				return false;
129
			}
130
			public boolean acceptLinkage(ILinkage linkage) {
131
				return linkage.getID() == ILinkage.CPP_LINKAGE_ID;
132
			}
133
		};
134
		
135
		IScope scope = CPPVisitor.getContainingScope(n);
136
		
137
		if (scope != null) {
138
			try {
139
				IBinding[] bindings = scope.find(n.toString(), true);
140
				for (int i = 0; i < bindings.length; i++) {
141
					if (filter.acceptBinding(bindings[i])) {
142
						filtered.add(bindings[i]);
143
					}
144
				}
145
			} catch (DOMException e) {
146
			}	
147
		}
148
				
149
		IIndex index = getTranslationUnit().getIndex();
150
		
151
		if (index != null) {
152
			try {
153
				IBinding[] bindings = index.findBindingsForPrefix(n.toString(), filter);
154
				for (int i = 0; i < bindings.length; i++) {
155
					filtered.add(bindings[i]);
156
				}
157
			} catch (CoreException e) {
158
			}
159
		}
160
			
161
		return (IBinding[]) filtered.toArray(new IBinding[filtered.size()]);
162
	}
101
}
163
}
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionScope.java (-5 / +29 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 8-19 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Markus Schorn (Wind River Systems)
10
 *     Markus Schorn (Wind River Systems)
11
 *     Bryan Wilkinson (QNX)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
/*
13
/*
13
 * Created on Dec 1, 2004
14
 * Created on Dec 1, 2004
14
 */
15
 */
15
package org.eclipse.cdt.internal.core.dom.parser.cpp;
16
package org.eclipse.cdt.internal.core.dom.parser.cpp;
16
17
18
import java.util.ArrayList;
19
import java.util.List;
20
17
import org.eclipse.cdt.core.dom.IName;
21
import org.eclipse.cdt.core.dom.IName;
18
import org.eclipse.cdt.core.dom.ast.DOMException;
22
import org.eclipse.cdt.core.dom.ast.DOMException;
19
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
23
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
Lines 31-36 Link Here
31
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
35
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
32
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
36
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
33
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
37
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
38
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
34
39
35
/**
40
/**
36
 * @author aniefer
41
 * @author aniefer
Lines 72-82 Link Here
72
	 * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
77
	 * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
73
	 */
78
	 */
74
	public IBinding[] find(String name) throws DOMException {
79
	public IBinding[] find(String name) throws DOMException {
80
	    return find(name, false);
81
	}
82
	
83
	/* (non-Javadoc)
84
	 * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
85
	 */
86
	public IBinding[] find(String name, boolean prefixLookup) throws DOMException {
75
	    char [] n = name.toCharArray();
87
	    char [] n = name.toCharArray();
76
	    if( labels.containsKey( n ) )
88
	    List bindings = new ArrayList();
77
	        return new IBinding[] { (IBinding) labels.get( n ) };
89
	    
78
90
	    for (int i = 0; i < labels.size(); i++) {
79
	    return super.find( name );
91
	    	char[] key = labels.keyAt(i);
92
	    	if ((prefixLookup && CharArrayUtils.equals(key, 0, n.length, n, false))
93
		    		|| (!prefixLookup && CharArrayUtils.equals(key, n))) {
94
	    		bindings.add((IBinding) labels.get(key));
95
	    	}
96
	    }
97
	    
98
	    IBinding[] additional = super.find( name, prefixLookup );
99
	    for (int i = 0; i < additional.length; i++) {
100
	    	bindings.add(additional[i]);
101
	    }
102
	    
103
	    return (IBinding[]) bindings.toArray(new IBinding[bindings.size()]);
80
	}
104
	}
81
	
105
	
82
	public IScope getParent() throws DOMException {
106
	public IScope getParent() throws DOMException {
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDirective.java (-1 / +56 lines)
Lines 7-24 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM - Initial API and implementation
9
 * IBM - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.internal.core.dom.parser.cpp;
12
package org.eclipse.cdt.internal.core.dom.parser.cpp;
12
13
14
import java.util.ArrayList;
15
import java.util.List;
16
17
import org.eclipse.cdt.core.dom.ILinkage;
13
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
18
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
19
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
14
import org.eclipse.cdt.core.dom.ast.IASTName;
20
import org.eclipse.cdt.core.dom.ast.IASTName;
21
import org.eclipse.cdt.core.dom.ast.IBinding;
22
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
15
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
23
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
24
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
25
import org.eclipse.cdt.core.index.IIndex;
26
import org.eclipse.cdt.core.index.IndexFilter;
27
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
28
import org.eclipse.cdt.internal.core.dom.parser.IASTCompletionContext;
29
import org.eclipse.core.runtime.CoreException;
16
30
17
/**
31
/**
18
 * @author jcamelon
32
 * @author jcamelon
19
 */
33
 */
20
public class CPPASTUsingDirective extends CPPASTNode implements
34
public class CPPASTUsingDirective extends CPPASTNode implements
21
        ICPPASTUsingDirective {
35
        ICPPASTUsingDirective, IASTCompletionContext {
22
36
23
    private IASTName name;
37
    private IASTName name;
24
38
Lines 65-68 Link Here
65
			return r_reference;
79
			return r_reference;
66
		return r_unclear;
80
		return r_unclear;
67
	}
81
	}
82
	
83
	public IBinding[] resolvePrefix(IASTName n) {
84
		List filtered = new ArrayList();
85
		IndexFilter filter = new IndexFilter() {
86
			public boolean acceptBinding(IBinding binding) {
87
				return binding instanceof ICPPNamespace;
88
			}
89
			public boolean acceptLinkage(ILinkage linkage) {
90
				return linkage.getID() == ILinkage.CPP_LINKAGE_ID;
91
			}
92
		};
93
		
94
		IASTDeclaration[] decls = getTranslationUnit().getDeclarations();
95
		char[] nChars = n.toCharArray();
96
		for (int i = 0; i < decls.length; i++) {
97
			if (decls[i] instanceof ICPPASTNamespaceDefinition) {
98
				ICPPASTNamespaceDefinition defn = (ICPPASTNamespaceDefinition) decls[i];
99
				IASTName name = defn.getName();
100
				if (CharArrayUtils.equals(name.toCharArray(), 0, nChars.length, nChars, false)) {
101
					IBinding binding = name.resolveBinding();
102
					if (filter.acceptBinding(binding)) {
103
						filtered.add(binding);
104
					}
105
				}
106
			}
107
		}
108
		
109
		IIndex index = getTranslationUnit().getIndex();
110
		
111
		if (index != null) {
112
			try {
113
				IBinding[] bindings = index.findBindingsForPrefix(n.toString(), filter);
114
				for (int i = 0; i < bindings.length; i++) {
115
					filtered.add(bindings[i]);
116
				}
117
			} catch (CoreException e) {
118
			}	
119
		}
120
		
121
		return (IBinding[]) filtered.toArray(new IBinding[filtered.size()]);
122
	}
68
}
123
}
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldReference.java (-1 / +73 lines)
Lines 7-28 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM - Initial API and implementation
9
 * IBM - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.internal.core.dom.parser.cpp;
12
package org.eclipse.cdt.internal.core.dom.parser.cpp;
12
13
14
import java.util.ArrayList;
15
import java.util.List;
16
13
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
17
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
18
import org.eclipse.cdt.core.dom.ast.DOMException;
14
import org.eclipse.cdt.core.dom.ast.IASTExpression;
19
import org.eclipse.cdt.core.dom.ast.IASTExpression;
15
import org.eclipse.cdt.core.dom.ast.IASTName;
20
import org.eclipse.cdt.core.dom.ast.IASTName;
16
import org.eclipse.cdt.core.dom.ast.IASTNode;
21
import org.eclipse.cdt.core.dom.ast.IASTNode;
22
import org.eclipse.cdt.core.dom.ast.IBinding;
23
import org.eclipse.cdt.core.dom.ast.IField;
17
import org.eclipse.cdt.core.dom.ast.IType;
24
import org.eclipse.cdt.core.dom.ast.IType;
18
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
25
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
26
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
27
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
28
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
29
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
30
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
19
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
31
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
32
import org.eclipse.cdt.internal.core.dom.parser.IASTCompletionContext;
20
33
21
/**
34
/**
22
 * @author jcamelon
35
 * @author jcamelon
23
 */
36
 */
24
public class CPPASTFieldReference extends CPPASTNode implements
37
public class CPPASTFieldReference extends CPPASTNode implements
25
        ICPPASTFieldReference, IASTAmbiguityParent {
38
        ICPPASTFieldReference, IASTAmbiguityParent, IASTCompletionContext {
26
39
27
    private boolean isTemplate;
40
    private boolean isTemplate;
28
    private IASTExpression owner;
41
    private IASTExpression owner;
Lines 101-105 Link Here
101
    public IType getExpressionType() {
114
    public IType getExpressionType() {
102
    	return CPPVisitor.getExpressionType(this);
115
    	return CPPVisitor.getExpressionType(this);
103
    }
116
    }
117
118
	public IBinding[] resolvePrefix(IASTName n) {
119
		IASTExpression expression = getFieldOwner();
120
		IType type = expression.getExpressionType();
121
		type = CPPSemantics.getUltimateType(type, true); //stop at pointer to member?
122
		
123
		if (type instanceof ICPPClassType) {
124
			ICPPClassType classType = (ICPPClassType) type;
125
			List bindings = new ArrayList();
126
			char[] name = n.toCharArray();
127
			
128
			try {
129
				IField[] fields = classType.getFields();
130
				for (int i = 0; i < fields.length; i++) {
131
					char[] potential = fields[i].getNameCharArray();
132
					if (CharArrayUtils.equals(potential, 0, name.length, name, false)) {
133
						bindings.add(fields[i]);
134
					}
135
				}
136
			} catch (DOMException e) {
137
			}
138
			
139
			try {
140
				ICPPMethod[] methods = classType.getMethods();
141
				for (int i = 0; i < methods.length; i++) {
142
					if (!(methods[i] instanceof ICPPConstructor) && !methods[i].isImplicit()) {
143
						char[] potential = methods[i].getNameCharArray();
144
						if (CharArrayUtils.equals(potential, 0, name.length, name, false)) {
145
							bindings.add(methods[i]);
146
						}
147
					}
148
				}
149
			} catch (DOMException e) {
150
			}
151
			
152
			collectBases(classType, bindings, n.toCharArray());
153
			return (IBinding[]) bindings.toArray(new IBinding[bindings.size()]);
154
		}
155
		
156
		return null;
157
	}
104
    
158
    
159
	private void collectBases(ICPPClassType classType, List bindings, char[] prefix) {
160
		if (CharArrayUtils.equals(classType.getNameCharArray(),
161
				0, prefix.length, prefix, false)) {
162
			bindings.add(classType);
163
		}
164
		
165
		try {
166
			ICPPBase[] bases = classType.getBases();
167
			for (int i = 0; i < bases.length; i++) {
168
				IBinding base = bases[i].getBaseClass();
169
				if (base instanceof ICPPClassType) {
170
					ICPPClassType baseClass = (ICPPClassType) base;
171
					collectBases(baseClass, bindings, prefix);
172
				}
173
			}
174
		} catch (DOMException e) {
175
		}
176
	}
105
}
177
}
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java (-3 / +12 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Markus Schorn (Wind River Systems)
10
 *     Markus Schorn (Wind River Systems)
11
 *     Bryan Wilkinson (QNX)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
/*
13
/*
13
 * Created on Nov 29, 2004
14
 * Created on Nov 29, 2004
Lines 300-305 Link Here
300
	 * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
301
	 * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
301
	 */
302
	 */
302
	public IBinding[] find(String name) throws DOMException {
303
	public IBinding[] find(String name) throws DOMException {
304
	    return find(name, false);
305
	}
306
	
307
	/* (non-Javadoc)
308
	 * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
309
	 */
310
	public IBinding[] find(String name, boolean prefixLookup) throws DOMException {
303
	    char [] n = name.toCharArray();
311
	    char [] n = name.toCharArray();
304
	    ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
312
	    ICPPASTCompositeTypeSpecifier compType = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
305
	    IASTName compName = compType.getName();
313
	    IASTName compName = compType.getName();
Lines 307-316 Link Here
307
	    	IASTName [] ns = ((ICPPASTQualifiedName)compName).getNames();
315
	    	IASTName [] ns = ((ICPPASTQualifiedName)compName).getNames();
308
	    	compName = ns[ ns.length - 1 ];
316
	    	compName = ns[ ns.length - 1 ];
309
	    }
317
	    }
310
	    if( CharArrayUtils.equals( n, compName.toCharArray() ) ){
318
	    if((prefixLookup && CharArrayUtils.equals(compName.toCharArray(), 0, n.length, n, false))
319
	    		|| (!prefixLookup && CharArrayUtils.equals(compName.toCharArray(), n))) {
311
	        return (IBinding[]) ArrayUtil.addAll( IBinding.class, null, getConstructors( bindings, true ) );
320
	        return (IBinding[]) ArrayUtil.addAll( IBinding.class, null, getConstructors( bindings, true ) );
312
	    }
321
	    }
313
	    return super.find( name );
322
	    return super.find( name, prefixLookup );
314
	}
323
	}
315
	
324
	
316
	public static boolean isConstructorReference( IASTName name ){
325
	public static boolean isConstructorReference( IASTName name ){
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUsingDeclaration.java (-1 / +56 lines)
Lines 7-24 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM - Initial API and implementation
9
 * IBM - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.internal.core.dom.parser.cpp;
12
package org.eclipse.cdt.internal.core.dom.parser.cpp;
12
13
14
import java.util.ArrayList;
15
import java.util.List;
16
17
import org.eclipse.cdt.core.dom.ILinkage;
13
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
18
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
19
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
14
import org.eclipse.cdt.core.dom.ast.IASTName;
20
import org.eclipse.cdt.core.dom.ast.IASTName;
21
import org.eclipse.cdt.core.dom.ast.IBinding;
22
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
15
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
23
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
24
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
25
import org.eclipse.cdt.core.index.IIndex;
26
import org.eclipse.cdt.core.index.IndexFilter;
27
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
28
import org.eclipse.cdt.internal.core.dom.parser.IASTCompletionContext;
29
import org.eclipse.core.runtime.CoreException;
16
30
17
/**
31
/**
18
 * @author jcamelon
32
 * @author jcamelon
19
 */
33
 */
20
public class CPPASTUsingDeclaration extends CPPASTNode implements
34
public class CPPASTUsingDeclaration extends CPPASTNode implements
21
        ICPPASTUsingDeclaration {
35
        ICPPASTUsingDeclaration, IASTCompletionContext {
22
36
23
    private boolean typeName;
37
    private boolean typeName;
24
    private IASTName name;
38
    private IASTName name;
Lines 80-83 Link Here
80
			return r_reference;
94
			return r_reference;
81
		return r_unclear;
95
		return r_unclear;
82
	}
96
	}
97
	
98
	public IBinding[] resolvePrefix(IASTName n) {
99
		List filtered = new ArrayList();
100
		IndexFilter filter = new IndexFilter() {
101
			public boolean acceptBinding(IBinding binding) {
102
				return binding instanceof ICPPNamespace;
103
			}
104
			public boolean acceptLinkage(ILinkage linkage) {
105
				return linkage.getID() == ILinkage.CPP_LINKAGE_ID;
106
			}
107
		};
108
		
109
		IASTDeclaration[] decls = getTranslationUnit().getDeclarations();
110
		char[] nChars = n.toCharArray();
111
		for (int i = 0; i < decls.length; i++) {
112
			if (decls[i] instanceof ICPPASTNamespaceDefinition) {
113
				ICPPASTNamespaceDefinition defn = (ICPPASTNamespaceDefinition) decls[i];
114
				IASTName name = defn.getName();
115
				if (CharArrayUtils.equals(name.toCharArray(), 0, nChars.length, nChars, false)) {
116
					IBinding binding = name.resolveBinding();
117
					if (filter.acceptBinding(binding)) {
118
						filtered.add(binding);
119
					}
120
				}
121
			}
122
		}
123
		
124
		IIndex index = getTranslationUnit().getIndex();
125
		
126
		if (index != null) {
127
			try {
128
				IBinding[] bindings = index.findBindingsForPrefix(n.toString(), filter);
129
				for (int i = 0; i < bindings.length; i++) {
130
					filtered.add(bindings[i]);
131
				}
132
			} catch (CoreException e) {
133
			}	
134
		}
135
		
136
		return (IBinding[]) filtered.toArray(new IBinding[filtered.size()]);
137
	}
83
}
138
}
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNamedTypeSpecifier.java (-2 / +73 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 20057 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 7-24 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM - Initial API and implementation
9
 * IBM - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.internal.core.dom.parser.cpp;
12
package org.eclipse.cdt.internal.core.dom.parser.cpp;
12
13
14
import java.util.ArrayList;
15
import java.util.List;
16
17
import org.eclipse.cdt.core.dom.ILinkage;
13
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
18
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
19
import org.eclipse.cdt.core.dom.ast.DOMException;
14
import org.eclipse.cdt.core.dom.ast.IASTName;
20
import org.eclipse.cdt.core.dom.ast.IASTName;
21
import org.eclipse.cdt.core.dom.ast.IBinding;
22
import org.eclipse.cdt.core.dom.ast.IEnumeration;
23
import org.eclipse.cdt.core.dom.ast.IScope;
24
import org.eclipse.cdt.core.dom.ast.ITypedef;
15
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
25
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
26
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
27
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
28
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
29
import org.eclipse.cdt.core.index.IIndex;
30
import org.eclipse.cdt.core.index.IndexFilter;
31
import org.eclipse.cdt.internal.core.dom.parser.IASTCompletionContext;
32
import org.eclipse.core.runtime.CoreException;
16
33
17
/**
34
/**
18
 * @author jcamelon
35
 * @author jcamelon
19
 */
36
 */
20
public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier implements
37
public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier implements
21
        ICPPASTNamedTypeSpecifier {
38
        ICPPASTNamedTypeSpecifier, IASTCompletionContext {
22
39
23
    private boolean typename;
40
    private boolean typename;
24
    private IASTName name;
41
    private IASTName name;
Lines 79-82 Link Here
79
			return r_reference;
96
			return r_reference;
80
		return r_unclear;
97
		return r_unclear;
81
	}
98
	}
99
	
100
	public IBinding[] resolvePrefix(IASTName n) {
101
		List filtered = new ArrayList();
102
		
103
		IScope scope = CPPVisitor.getContainingScope(n);
104
		
105
		if (scope != null) {
106
			try {
107
				IBinding[] bindings = scope.find(n.toString(), true);
108
				for (int i = 0; i < bindings.length; i++) {
109
					if (bindings[i] instanceof ICPPTemplateParameter) {
110
						filtered.add(bindings[i]);
111
					}
112
				}
113
			} catch (DOMException e) {
114
			}	
115
		}
116
117
		IndexFilter filter = new IndexFilter() {
118
			public boolean acceptBinding(IBinding binding) {
119
				return binding instanceof ICPPClassType
120
				|| binding instanceof IEnumeration
121
				|| binding instanceof ICPPNamespace
122
				|| binding instanceof ITypedef;
123
			}
124
			public boolean acceptLinkage(ILinkage linkage) {
125
				return linkage.getID() == ILinkage.CPP_LINKAGE_ID;
126
			}
127
		};
128
		
129
		try {
130
			IBinding[] bindings = getTranslationUnit().getScope().find(n.toString(), true);
131
			for (int i = 0 ; i < bindings.length; i++) {
132
				if (filter.acceptBinding(bindings[i])) {
133
					filtered.add(bindings[i]);
134
				}
135
			}
136
		} catch (DOMException e1) {
137
		}
138
139
		IIndex index = getTranslationUnit().getIndex();
140
		
141
		if (index != null) {
142
			try {
143
				IBinding[] bindings = index.findBindingsForPrefix(n.toString(), filter);
144
				for (int i = 0; i < bindings.length; i++) {
145
					filtered.add(bindings[i]);
146
				}
147
			} catch (CoreException e) {
148
			}	
149
		}
150
		
151
		return (IBinding[]) filtered.toArray(new IBinding[filtered.size()]);
152
	}
82
}
153
}
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Markus Schorn (Wind River Systems)
10
 *     Markus Schorn (Wind River Systems)
11
 *     Bryan Wilkinson (QNX)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
/*
13
/*
13
 * Created on Nov 29, 2004
14
 * Created on Nov 29, 2004
Lines 333-339 Link Here
333
	 * @see org.eclipse.cdt.core.dom.ast.ICompositeType#findField(java.lang.String)
334
	 * @see org.eclipse.cdt.core.dom.ast.ICompositeType#findField(java.lang.String)
334
	 */
335
	 */
335
	public IField findField(String name) throws DOMException {
336
	public IField findField(String name) throws DOMException {
336
		IBinding [] bindings = CPPSemantics.findBindings( getCompositeScope(), name, true );
337
		IBinding [] bindings = CPPSemantics.findBindings( getCompositeScope(), name, true, false );
337
		IField field = null;
338
		IField field = null;
338
		for ( int i = 0; i < bindings.length; i++ ) {
339
		for ( int i = 0; i < bindings.length; i++ ) {
339
            if( bindings[i] instanceof IField ){
340
            if( bindings[i] instanceof IField ){
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java (-1 / +12 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 * IBM - Initial API and implementation
9
 * IBM - Initial API and implementation
10
 * Markus Schorn (Wind River Systems)
10
 * Markus Schorn (Wind River Systems)
11
 * Bryan Wilkinson (QNX)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.cdt.internal.core.dom.parser.cpp;
13
package org.eclipse.cdt.internal.core.dom.parser.cpp;
13
14
Lines 18-23 Link Here
18
import org.eclipse.cdt.core.dom.ast.IBinding;
19
import org.eclipse.cdt.core.dom.ast.IBinding;
19
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
20
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
20
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
21
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
22
import org.eclipse.cdt.internal.core.dom.parser.IASTCompletionContext;
21
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
23
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
22
24
23
/**
25
/**
Lines 75-81 Link Here
75
    }
77
    }
76
78
77
    public IBinding[] resolvePrefix() {
79
    public IBinding[] resolvePrefix() {
78
    	return CPPSemantics.prefixLookup(this);
80
    	IASTNode node = getParent();
81
    	while (!(node instanceof IASTCompletionContext)) {
82
    		if (node == null) {
83
    			return null;
84
    		}
85
    		node = node.getParent();
86
    	}
87
    	
88
    	IASTCompletionContext context = (IASTCompletionContext) node;
89
    	return context.resolvePrefix(this);
79
    }
90
    }
80
91
81
    public void setBinding(IBinding binding) {
92
    public void setBinding(IBinding binding) {
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java (-1 / +2 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM - Initial API and implementation
9
 * IBM - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
/*
12
/*
12
 * Created on Mar 31, 2005
13
 * Created on Mar 31, 2005
Lines 236-242 Link Here
236
	 * @see org.eclipse.cdt.core.dom.ast.ICompositeType#findField(java.lang.String)
237
	 * @see org.eclipse.cdt.core.dom.ast.ICompositeType#findField(java.lang.String)
237
	 */
238
	 */
238
	public IField findField(String name) throws DOMException {
239
	public IField findField(String name) throws DOMException {
239
		IBinding [] bindings = CPPSemantics.findBindings( getCompositeScope(), name, true );
240
		IBinding [] bindings = CPPSemantics.findBindings( getCompositeScope(), name, true, false );
240
		IField field = null;
241
		IField field = null;
241
		for ( int i = 0; i < bindings.length; i++ ) {
242
		for ( int i = 0; i < bindings.length; i++ ) {
242
            if( bindings[i] instanceof IField ){
243
            if( bindings[i] instanceof IField ){
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java (-2 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Markus Schorn (Wind River Systems)
10
 *     Markus Schorn (Wind River Systems)
11
 *     Bryan Wilkinson (QNX)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
13
13
/*
14
/*
Lines 59-65 Link Here
59
     * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
60
     * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
60
     */
61
     */
61
    public IBinding[] find( String name ) {
62
    public IBinding[] find( String name ) {
62
        // TODO Auto-generated method stub
63
        return null;
64
    }
65
    
66
    /* (non-Javadoc)
67
     * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
68
     */
69
    public IBinding[] find( String name, boolean prefixLookup ) {
63
        return null;
70
        return null;
64
    }
71
    }
65
72
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTQualifiedName.java (-1 / +52 lines)
Lines 7-16 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM - Initial API and implementation
9
 * IBM - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.internal.core.dom.parser.cpp;
12
package org.eclipse.cdt.internal.core.dom.parser.cpp;
12
13
14
import java.util.ArrayList;
15
import java.util.List;
16
13
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
17
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
18
import org.eclipse.cdt.core.dom.ast.DOMException;
14
import org.eclipse.cdt.core.dom.ast.IASTName;
19
import org.eclipse.cdt.core.dom.ast.IASTName;
15
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
20
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
16
import org.eclipse.cdt.core.dom.ast.IASTNode;
21
import org.eclipse.cdt.core.dom.ast.IASTNode;
Lines 19-31 Link Here
19
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
24
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
20
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
25
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
21
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
26
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
27
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
28
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
29
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
22
import org.eclipse.cdt.core.parser.util.ArrayUtil;
30
import org.eclipse.cdt.core.parser.util.ArrayUtil;
31
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
32
import org.eclipse.cdt.internal.core.dom.parser.IASTCompletionContext;
23
33
24
/**
34
/**
25
 * @author jcamelon
35
 * @author jcamelon
26
 */
36
 */
27
public class CPPASTQualifiedName extends CPPASTNode implements
37
public class CPPASTQualifiedName extends CPPASTNode implements
28
		ICPPASTQualifiedName {
38
		ICPPASTQualifiedName, IASTCompletionContext {
29
39
30
	/**
40
	/**
31
	 * @param duple
41
	 * @param duple
Lines 287-290 Link Here
287
        }
297
        }
288
        return false;
298
        return false;
289
    }
299
    }
300
301
	public IBinding[] resolvePrefix(IASTName n) {
302
		IBinding binding = names[names.length - 2].resolveBinding();
303
		if (binding instanceof ICPPClassType) {
304
			ICPPClassType classType = (ICPPClassType) binding;
305
			List bindings = new ArrayList();
306
			char[] name = n.toCharArray();
307
			
308
			try {
309
				ICPPMethod[] methods = classType.getDeclaredMethods();
310
				for (int i = 0; i < methods.length; i++) {
311
					char[] potential = methods[i].getNameCharArray();
312
					if (CharArrayUtils.equals(potential, 0, name.length, name, false)) {
313
						bindings.add(methods[i]);
314
					}
315
				}
316
			} catch (DOMException e) {
317
			}
318
			
319
			return (IBinding[]) bindings.toArray(new IBinding[bindings.size()]);
320
		} else if (binding instanceof ICPPNamespace) {
321
			ICPPNamespace namespace = (ICPPNamespace) binding;
322
			List bindings = new ArrayList();
323
			char[] name = n.toCharArray();
324
			
325
			try {
326
				IBinding[] members = namespace.getMemberBindings();
327
				for (int i = 0 ; i < members.length; i++) {
328
					char[] potential = members[i].getNameCharArray();
329
					if (CharArrayUtils.equals(potential, 0, name.length, name, false)) {
330
						bindings.add(members[i]);
331
					}
332
				}
333
			} catch (DOMException e) {
334
			}
335
			
336
			return (IBinding[]) bindings.toArray(new IBinding[bindings.size()]);
337
		}
338
		
339
		return null;
340
	}
290
}
341
}
(-)parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTIdExpression.java (-2 / +41 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
2
 * Copyright (c) 2005, 2007 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 8-25 Link Here
8
 * Contributors:
8
 * Contributors:
9
 * IBM Rational Software - Initial API and implementation
9
 * IBM Rational Software - Initial API and implementation
10
 * Yuan Zhang / Beth Tibbitts (IBM Research)
10
 * Yuan Zhang / Beth Tibbitts (IBM Research)
11
 * Bryan Wilkinson (QNX)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.cdt.internal.core.dom.parser.c;
13
package org.eclipse.cdt.internal.core.dom.parser.c;
13
14
14
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
15
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
16
import org.eclipse.cdt.core.dom.ast.DOMException;
15
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
17
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
16
import org.eclipse.cdt.core.dom.ast.IASTName;
18
import org.eclipse.cdt.core.dom.ast.IASTName;
19
import org.eclipse.cdt.core.dom.ast.IBinding;
20
import org.eclipse.cdt.core.dom.ast.IScope;
17
import org.eclipse.cdt.core.dom.ast.IType;
21
import org.eclipse.cdt.core.dom.ast.IType;
22
import org.eclipse.cdt.core.index.IIndex;
23
import org.eclipse.cdt.core.index.IndexFilter;
24
import org.eclipse.cdt.core.parser.util.ArrayUtil;
25
import org.eclipse.cdt.internal.core.dom.Linkage;
26
import org.eclipse.cdt.internal.core.dom.parser.IASTCompletionContext;
27
import org.eclipse.core.runtime.CoreException;
18
28
19
/**
29
/**
20
 * @author jcamelon
30
 * @author jcamelon
21
 */
31
 */
22
public class CASTIdExpression extends CASTNode implements IASTIdExpression {
32
public class CASTIdExpression extends CASTNode implements IASTIdExpression, IASTCompletionContext {
23
33
24
    private IASTName name;
34
    private IASTName name;
25
35
Lines 61-64 Link Here
61
		return CVisitor.getExpressionType(this);
71
		return CVisitor.getExpressionType(this);
62
	}
72
	}
63
	
73
	
74
	public IBinding[] resolvePrefix(IASTName n) {
75
		IScope scope = CVisitor.getContainingScope(n);
76
		
77
		IBinding[] b1 = null;
78
		if (scope != null) {
79
			try {
80
				b1 = scope.find(n.toString(), true);
81
			} catch (DOMException e) {
82
			}	
83
		}
84
		
85
		IIndex index = getTranslationUnit().getIndex();
86
		
87
		IBinding[] b2 = null;
88
		if (index != null) {
89
			try {
90
				b2 = index.findBindingsForPrefix(
91
						n.toString(),
92
						IndexFilter.getFilter(Linkage.C_LINKAGE));
93
			} catch (CoreException e) {
94
			}
95
		}
96
		
97
		int size = (b1 == null ? 0 : b1.length) + (b2 == null ? 0 : b2.length);
98
		IBinding[] all = new IBinding[size];
99
		if (b1 != null) ArrayUtil.addAll(IBinding.class, all, b1);
100
		if (b2 != null) ArrayUtil.addAll(IBinding.class, all, b2);
101
		return all;
102
	}
64
}
103
}
(-)parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTypedefNameSpecifier.java (-2 / +60 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
2
 * Copyright (c) 2005, 2007 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 8-25 Link Here
8
 * Contributors:
8
 * Contributors:
9
 * IBM Rational Software - Initial API and implementation
9
 * IBM Rational Software - Initial API and implementation
10
 * Yuan Zhang / Beth Tibbitts (IBM Research)
10
 * Yuan Zhang / Beth Tibbitts (IBM Research)
11
 * Bryan Wilkinson (QNX)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.cdt.internal.core.dom.parser.c;
13
package org.eclipse.cdt.internal.core.dom.parser.c;
13
14
15
import java.util.ArrayList;
16
import java.util.List;
17
18
import org.eclipse.cdt.core.dom.ILinkage;
14
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
19
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
20
import org.eclipse.cdt.core.dom.ast.DOMException;
15
import org.eclipse.cdt.core.dom.ast.IASTName;
21
import org.eclipse.cdt.core.dom.ast.IASTName;
22
import org.eclipse.cdt.core.dom.ast.IBinding;
23
import org.eclipse.cdt.core.dom.ast.ICompositeType;
24
import org.eclipse.cdt.core.dom.ast.IEnumeration;
25
import org.eclipse.cdt.core.dom.ast.IScope;
26
import org.eclipse.cdt.core.dom.ast.ITypedef;
16
import org.eclipse.cdt.core.dom.ast.c.ICASTTypedefNameSpecifier;
27
import org.eclipse.cdt.core.dom.ast.c.ICASTTypedefNameSpecifier;
28
import org.eclipse.cdt.core.index.IIndex;
29
import org.eclipse.cdt.core.index.IndexFilter;
30
import org.eclipse.cdt.internal.core.dom.parser.IASTCompletionContext;
31
import org.eclipse.core.runtime.CoreException;
17
32
18
/**
33
/**
19
 * @author jcamelon
34
 * @author jcamelon
20
 */
35
 */
21
public class CASTTypedefNameSpecifier extends CASTBaseDeclSpecifier implements
36
public class CASTTypedefNameSpecifier extends CASTBaseDeclSpecifier implements
22
        ICASTTypedefNameSpecifier {
37
        ICASTTypedefNameSpecifier, IASTCompletionContext {
23
38
24
    private IASTName name;
39
    private IASTName name;
25
    /* (non-Javadoc)
40
    /* (non-Javadoc)
Lines 63-66 Link Here
63
		return r_unclear;
78
		return r_unclear;
64
	}
79
	}
65
80
81
	public IBinding[] resolvePrefix(IASTName n) {
82
		List filtered = new ArrayList();
83
		IndexFilter filter = new IndexFilter() {
84
			public boolean acceptBinding(IBinding binding) {
85
				return binding instanceof ICompositeType
86
				|| binding instanceof IEnumeration
87
				|| binding instanceof ITypedef;
88
			}
89
			public boolean acceptLinkage(ILinkage linkage) {
90
				return linkage.getID() == ILinkage.C_LINKAGE_ID;
91
			}
92
		};
93
		
94
		IScope scope = CVisitor.getContainingScope(n);
95
		
96
		if (scope == null) {
97
			scope = getTranslationUnit().getScope();
98
		}
99
		
100
		try {
101
			IBinding[] bindings = scope.find(n.toString(), true);
102
			for (int i = 0 ; i < bindings.length; i++) {
103
				if (filter.acceptBinding(bindings[i])) {
104
					filtered.add(bindings[i]);
105
				}
106
			}
107
		} catch (DOMException e) {
108
		}
109
		
110
		IIndex index = getTranslationUnit().getIndex();
111
		
112
		if (index != null) {
113
			try {
114
				IBinding[] bindings = index.findBindingsForPrefix(n.toString(), filter);
115
				for (int i = 0; i < bindings.length; i++) {
116
					filtered.add(bindings[i]);
117
				}
118
			} catch (CoreException e) {
119
			}
120
		}
121
		
122
		return (IBinding[]) filtered.toArray(new IBinding[filtered.size()]);
123
	}
66
}
124
}
(-)parser/org/eclipse/cdt/internal/core/dom/parser/c/CScope.java (-2 / +11 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Markus Schorn (Wind River Systems)
10
 *     Markus Schorn (Wind River Systems)
11
 *     Bryan Wilkinson (QNX)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
13
13
/*
14
/*
Lines 95-105 Link Here
95
            return (IASTName[]) ArrayUtil.trim( IASTName.class, result );
96
            return (IASTName[]) ArrayUtil.trim( IASTName.class, result );
96
        }
97
        }
97
    }
98
    }
99
    
98
    /* (non-Javadoc)
100
    /* (non-Javadoc)
99
     * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
101
     * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
100
     */
102
     */
101
    public IBinding[] find( String name ) throws DOMException {
103
    public IBinding[] find( String name ) throws DOMException {
102
        return CVisitor.findBindings( this, name );
104
    	return CVisitor.findBindings( this, name, false );
105
    }
106
    
107
    /* (non-Javadoc)
108
     * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
109
     */
110
    public IBinding[] find( String name, boolean prefixLookup ) throws DOMException {
111
    	return CVisitor.findBindings( this, name, prefixLookup );
103
    }
112
    }
104
113
105
    public IBinding getBinding( int namespaceType, char [] name ){
114
    public IBinding getBinding( int namespaceType, char [] name ){
(-)parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java (-20 / +50 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
2
 * Copyright (c) 2005, 2007 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 8-17 Link Here
8
 * Contributors:
8
 * Contributors:
9
 * IBM Rational Software - Initial API and implementation 
9
 * IBM Rational Software - Initial API and implementation 
10
 * Markus Schorn (Wind River Systems)
10
 * Markus Schorn (Wind River Systems)
11
 * Bryan Wilkinson (QNX)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
13
13
package org.eclipse.cdt.internal.core.dom.parser.c;
14
package org.eclipse.cdt.internal.core.dom.parser.c;
14
15
16
import java.util.ArrayList;
17
import java.util.List;
18
15
import org.eclipse.cdt.core.CCorePlugin;
19
import org.eclipse.cdt.core.CCorePlugin;
16
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
20
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
17
import org.eclipse.cdt.core.dom.ast.DOMException;
21
import org.eclipse.cdt.core.dom.ast.DOMException;
Lines 609-615 Link Here
609
		            char [] p = fieldReference.getFieldName().toCharArray();
613
		            char [] p = fieldReference.getFieldName().toCharArray();
610
                    IField [] fields = ((ICompositeType) type).getFields();
614
                    IField [] fields = ((ICompositeType) type).getFields();
611
                    for ( int i = 0; i < fields.length; i++ ) {
615
                    for ( int i = 0; i < fields.length; i++ ) {
612
                        if( CharArrayUtils.equals( fields[i].getNameCharArray(), 0, p.length, p ) ){
616
                        if( CharArrayUtils.equals( fields[i].getNameCharArray(), 0, p.length, p, false ) ){
613
                            result = (IBinding[]) ArrayUtil.append( IBinding.class, result, fields[i] );
617
                            result = (IBinding[]) ArrayUtil.append( IBinding.class, result, fields[i] );
614
                        }
618
                        }
615
                    }
619
                    }
Lines 1415-1421 Link Here
1415
	    char [] c = candidate.toCharArray();
1419
	    char [] c = candidate.toCharArray();
1416
        if( prefixMap == null && CharArrayUtils.equals( c, name ) ){
1420
        if( prefixMap == null && CharArrayUtils.equals( c, name ) ){
1417
            return candidate;
1421
            return candidate;
1418
        } else if( prefixMap != null && CharArrayUtils.equals( c, 0, name.length, name ) && !prefixMap.containsKey( c ) ){
1422
        } else if( prefixMap != null && CharArrayUtils.equals( c, 0, name.length, name, false ) && !prefixMap.containsKey( c ) ){
1419
	        prefixMap.put( c, candidate );
1423
	        prefixMap.put( c, candidate );
1420
	    }
1424
	    }
1421
        return prefixMap;
1425
        return prefixMap;
Lines 1437-1443 Link Here
1437
		    char [] n = name.toCharArray();
1441
		    char [] n = name.toCharArray();
1438
		    if( prefixMap == null && CharArrayUtils.equals( c, n ) )
1442
		    if( prefixMap == null && CharArrayUtils.equals( c, n ) )
1439
		        return tempName;
1443
		        return tempName;
1440
		    else if( prefixMap != null && CharArrayUtils.equals( c, 0, n.length, n ) && !prefixMap.containsKey( c ) )
1444
		    else if( prefixMap != null && CharArrayUtils.equals( c, 0, n.length, n, false ) && !prefixMap.containsKey( c ) )
1441
		        prefixMap.put( c, tempName );
1445
		        prefixMap.put( c, tempName );
1442
		} else {
1446
		} else {
1443
		    return checkForBinding( scope, paramDecl.getDeclSpecifier(), name, typesOnly, prefixMap );
1447
		    return checkForBinding( scope, paramDecl.getDeclSpecifier(), name, typesOnly, prefixMap );
Lines 1920-1926 Link Here
1920
        return (IBinding[]) ArrayUtil.trim( IBinding.class, result );
1924
        return (IBinding[]) ArrayUtil.trim( IBinding.class, result );
1921
    }
1925
    }
1922
    
1926
    
1923
    public static IBinding[] findBindings( IScope scope, String name ) throws DOMException{
1927
    public static IBinding[] findBindings( IScope scope, String name, boolean prefixLookup ) throws DOMException{
1924
        IASTNode node = ASTInternal.getPhysicalNodeOfScope(scope);
1928
        IASTNode node = ASTInternal.getPhysicalNodeOfScope(scope);
1925
        if( node instanceof IASTFunctionDefinition )
1929
        if( node instanceof IASTFunctionDefinition )
1926
            node = ((IASTFunctionDefinition)node).getBody();
1930
            node = ((IASTFunctionDefinition)node).getBody();
Lines 1930-1968 Link Here
1930
	    
1934
	    
1931
	    //normal names
1935
	    //normal names
1932
	    astName.setPropertyInParent( STRING_LOOKUP_PROPERTY );
1936
	    astName.setPropertyInParent( STRING_LOOKUP_PROPERTY );
1933
	    IBinding b1 = (IBinding) findBinding( astName, astName, COMPLETE );
1937
	    int flags = prefixLookup ? COMPLETE | PREFIX_LOOKUP : COMPLETE;
1938
	    Object o1 = findBinding( astName, astName, flags );
1934
        
1939
        
1940
	    IBinding[] b1 = null;
1941
	    if (o1 instanceof IBinding) {
1942
	    	b1 = new IBinding[] { (IBinding) o1 };
1943
	    } else {
1944
	    	b1 = (IBinding[]) o1;
1945
	    }
1946
	    
1935
	    //structure names
1947
	    //structure names
1936
        astName.setPropertyInParent( STRING_LOOKUP_TAGS_PROPERTY );
1948
        astName.setPropertyInParent( STRING_LOOKUP_TAGS_PROPERTY );
1937
        IBinding b2 = (IBinding) findBinding( astName, astName, COMPLETE | TAGS );
1949
        flags = prefixLookup ? COMPLETE | TAGS | PREFIX_LOOKUP : COMPLETE | TAGS;
1950
        Object o2 = findBinding( astName, astName, flags );
1938
1951
1952
	    IBinding[] b2 = null;
1953
	    if (o2 instanceof IBinding) {
1954
	    	b2 = new IBinding[] { (IBinding) o2 };
1955
	    } else {
1956
	    	b2 = (IBinding[]) o2;
1957
	    }
1958
        
1939
        //label names
1959
        //label names
1940
        ILabel b3 = null;
1960
        List b3 = new ArrayList();
1941
        do{
1961
        do{
1942
            char [] n = name.toCharArray();
1962
            char [] n = name.toCharArray();
1943
            if( scope instanceof ICFunctionScope ){
1963
            if( scope instanceof ICFunctionScope ){
1944
                ILabel [] labels = ((CFunctionScope)scope).getLabels();
1964
                ILabel [] labels = ((CFunctionScope)scope).getLabels();
1945
                for( int i = 0; i < labels.length; i++ ){
1965
                for( int i = 0; i < labels.length; i++ ){
1946
	                ILabel label = labels[i];
1966
	                ILabel label = labels[i];
1947
	                if( CharArrayUtils.equals( label.getNameCharArray(), n) ){
1967
	                if (prefixLookup) {
1948
	                    b3 = label;
1968
	                	if (CharArrayUtils.equals(label.getNameCharArray(),
1949
	                    break;
1969
	                			0, n.length, n, false)) {
1970
	                		b3.add(label);
1971
	                	}
1972
	                } else {
1973
	                	if (CharArrayUtils.equals(label.getNameCharArray(), n)) {
1974
	                		b3.add(label);
1975
	                		break;
1976
	                	}
1950
	                }
1977
	                }
1951
	            }
1978
	            }
1952
                break;
1979
                if (!prefixLookup) break;
1953
            }
1980
            }
1954
            scope = scope.getParent();
1981
            scope = scope.getParent();
1955
        } while( scope != null );
1982
        } while( scope != null );
1956
        
1983
        
1957
        int c = (( b1 != null ) ? 1 : 0) + (( b2 != null ) ? 1 : 0) + (( b3 != null ) ? 1 : 0);
1984
        int c = (b1 == null ? 0 : b1.length) + (b2 == null ? 0 :b2.length) + (b3 == null ? 0 : b3.size());
1985
1958
        IBinding [] result = new IBinding [c];
1986
        IBinding [] result = new IBinding [c];
1959
        c = 0;
1987
        
1960
        if( b1 != null ) 
1988
        if (b1 != null)
1961
            result[c++] = b1;
1989
        	ArrayUtil.addAll(IBinding.class, result, b1);
1962
        if( b2 != null )
1990
        
1963
            result[c++] = b2;
1991
        if (b2 != null)
1964
        if( b3 != null )
1992
        	ArrayUtil.addAll(IBinding.class, result, b2);
1965
            result[c] = b3;
1993
       
1994
        if (b3 != null)
1995
        	ArrayUtil.addAll(IBinding.class, result, b3.toArray(new IBinding[b3.size()]));
1966
        
1996
        
1967
        return result;
1997
        return result;
1968
    }
1998
    }
(-)parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java (-2 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
2
 * Copyright (c) 2005, 2007 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 9-14 Link Here
9
 * IBM Rational Software - Initial API and implementation
9
 * IBM Rational Software - Initial API and implementation
10
 * Markus Schorn (Wind River Systems)
10
 * Markus Schorn (Wind River Systems)
11
 * Yuan Zhang / Beth Tibbitts (IBM Research)
11
 * Yuan Zhang / Beth Tibbitts (IBM Research)
12
 * Bryan Wilkinson (QNX)
12
 *******************************************************************************/
13
 *******************************************************************************/
13
package org.eclipse.cdt.internal.core.dom.parser.c;
14
package org.eclipse.cdt.internal.core.dom.parser.c;
14
15
Lines 19-24 Link Here
19
import org.eclipse.cdt.core.dom.ast.IASTNode;
20
import org.eclipse.cdt.core.dom.ast.IASTNode;
20
import org.eclipse.cdt.core.dom.ast.IBinding;
21
import org.eclipse.cdt.core.dom.ast.IBinding;
21
import org.eclipse.cdt.internal.core.dom.Linkage;
22
import org.eclipse.cdt.internal.core.dom.Linkage;
23
import org.eclipse.cdt.internal.core.dom.parser.IASTCompletionContext;
22
24
23
/**
25
/**
24
 * @author jcamelon
26
 * @author jcamelon
Lines 56-62 Link Here
56
    }
58
    }
57
59
58
    public IBinding[] resolvePrefix() {
60
    public IBinding[] resolvePrefix() {
59
        return CVisitor.prefixLookup(this);
61
        IASTNode node = getParent();
62
    	while (!(node instanceof IASTCompletionContext)) {
63
    		if (node == null) {
64
    			return null;
65
    		}
66
    		node = node.getParent();
67
    	}
68
    	
69
    	IASTCompletionContext context = (IASTCompletionContext) node;
70
    	return context.resolvePrefix(this);
60
    }
71
    }
61
72
62
    public void setBinding(IBinding binding) {
73
    public void setBinding(IBinding binding) {
(-)parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldReference.java (-3 / +40 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
2
 * Copyright (c) 2005, 2007 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 8-28 Link Here
8
 * Contributors:
8
 * Contributors:
9
 * IBM Rational Software - Initial API and implementation
9
 * IBM Rational Software - Initial API and implementation
10
 * Yuan Zhang / Beth Tibbitts (IBM Research)
10
 * Yuan Zhang / Beth Tibbitts (IBM Research)
11
 * Bryan Wilkinson (QNX)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.cdt.internal.core.dom.parser.c;
13
package org.eclipse.cdt.internal.core.dom.parser.c;
13
14
15
import java.util.ArrayList;
16
import java.util.List;
17
14
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
18
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
19
import org.eclipse.cdt.core.dom.ast.DOMException;
15
import org.eclipse.cdt.core.dom.ast.IASTExpression;
20
import org.eclipse.cdt.core.dom.ast.IASTExpression;
16
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
21
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
17
import org.eclipse.cdt.core.dom.ast.IASTName;
22
import org.eclipse.cdt.core.dom.ast.IASTName;
18
import org.eclipse.cdt.core.dom.ast.IASTNode;
23
import org.eclipse.cdt.core.dom.ast.IASTNode;
24
import org.eclipse.cdt.core.dom.ast.IBinding;
25
import org.eclipse.cdt.core.dom.ast.ICompositeType;
26
import org.eclipse.cdt.core.dom.ast.IField;
19
import org.eclipse.cdt.core.dom.ast.IType;
27
import org.eclipse.cdt.core.dom.ast.IType;
28
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
20
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
29
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
30
import org.eclipse.cdt.internal.core.dom.parser.IASTCompletionContext;
31
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
21
32
22
/**
33
/**
23
 * @author jcamelon
34
 * @author jcamelon
24
 */
35
 */
25
public class CASTFieldReference extends CASTNode implements IASTFieldReference, IASTAmbiguityParent {
36
public class CASTFieldReference extends CASTNode implements IASTFieldReference, IASTAmbiguityParent, IASTCompletionContext {
26
37
27
    private IASTExpression owner;
38
    private IASTExpression owner;
28
    private IASTName name;
39
    private IASTName name;
Lines 92-96 Link Here
92
    public IType getExpressionType() {
103
    public IType getExpressionType() {
93
    	return CVisitor.getExpressionType(this);
104
    	return CVisitor.getExpressionType(this);
94
    }
105
    }
95
    
106
107
	public IBinding[] resolvePrefix(IASTName n) {
108
		IASTExpression expression = getFieldOwner();
109
		IType type = expression.getExpressionType();
110
		type = CPPSemantics.getUltimateType(type, true); //stop at pointer to member?
111
		
112
		if (type instanceof ICompositeType) {
113
			ICompositeType compType = (ICompositeType) type;
114
			List bindings = new ArrayList();
115
			char[] name = n.toCharArray();
116
			
117
			try {
118
				IField[] fields = compType.getFields();
119
				for (int i = 0; i < fields.length; i++) {
120
					char[] potential = fields[i].getNameCharArray();
121
					if (CharArrayUtils.equals(potential, 0, name.length, name, false)) {
122
						bindings.add(fields[i]);
123
					}
124
				}
125
			} catch (DOMException e) {
126
			}
127
			
128
			return (IBinding[]) bindings.toArray(new IBinding[bindings.size()]);
129
		}
130
		
131
		return null;
132
	}
96
}
133
}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPBase.java (-2 / +8 lines)
Lines 16-21 Link Here
16
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
16
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
17
import org.eclipse.cdt.internal.core.pdom.PDOM;
17
import org.eclipse.cdt.internal.core.pdom.PDOM;
18
import org.eclipse.cdt.internal.core.pdom.db.Database;
18
import org.eclipse.cdt.internal.core.pdom.db.Database;
19
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
19
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
20
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.CoreException;
21
22
Lines 83-90 Link Here
83
	public IBinding getBaseClass() {
84
	public IBinding getBaseClass() {
84
		try {
85
		try {
85
			PDOMName name= getBaseClassSpecifierImpl();
86
			PDOMName name= getBaseClassSpecifierImpl();
86
			if (name != null)
87
			if (name != null) {
87
				return name.getPDOMBinding();				
88
				PDOMBinding b = name.getPDOMBinding();
89
		    	while( b instanceof PDOMCPPTypedef && ((PDOMCPPTypedef)b).getType() instanceof PDOMBinding ){
90
					b = (PDOMBinding) ((PDOMCPPTypedef)b).getType();
91
		    	}
92
		    	return b;
93
			}				
88
		} catch (CoreException e) {
94
		} catch (CoreException e) {
89
			CCorePlugin.log(e);
95
			CCorePlugin.log(e);
90
		}
96
		}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java (-1 / +45 lines)
Lines 35-40 Link Here
35
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
35
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
36
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
36
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
37
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
37
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
38
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
38
import org.eclipse.cdt.internal.core.Util;
39
import org.eclipse.cdt.internal.core.Util;
39
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
40
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
40
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
41
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
Lines 169-174 Link Here
169
			acceptInHierarchy(new HashSet(), methods);
170
			acceptInHierarchy(new HashSet(), methods);
170
			return methods.getMethods();
171
			return methods.getMethods();
171
		} catch (CoreException e) {
172
		} catch (CoreException e) {
173
			CCorePlugin.log(e);
172
			return new ICPPMethod[0];
174
			return new ICPPMethod[0];
173
		}
175
		}
174
	}
176
	}
Lines 401-412 Link Here
401
		return null;
403
		return null;
402
	}
404
	}
403
405
406
	private static class BindingFinder implements IPDOMVisitor {
407
		private List fBindings = new ArrayList();
408
		private char[] fName;
409
		private boolean fPrefixLookup;
410
		
411
		public BindingFinder(char[] name, boolean prefiexLookup) {
412
			fName= name;
413
			fPrefixLookup= prefiexLookup;
414
		}
415
		
416
		public boolean visit(IPDOMNode node) throws CoreException {
417
			if (node instanceof PDOMNamedNode && node instanceof IBinding
418
					&& !(node instanceof ICPPConstructor)) {
419
				char[] n= ((PDOMNamedNode) node).getDBName().getChars();
420
				if ((fPrefixLookup && CharArrayUtils.equals(n, 0, fName.length, fName, false))
421
						|| (!fPrefixLookup && CharArrayUtils.equals(n, fName))) {
422
					fBindings.add(node);
423
				}
424
			}
425
			return false;
426
		}
427
		public void leave(IPDOMNode node) throws CoreException {
428
		}
429
		public IBinding[] getBindings() {
430
			return (IBinding[])fBindings.toArray(new IBinding[fBindings.size()]);
431
		}
432
	}
433
	
434
	public IBinding[] find(String name) throws DOMException {
435
		return find(name, false);
436
	}
437
	
438
	public IBinding[] find(String name, boolean prefixLookup) throws DOMException {
439
		try {
440
			BindingFinder visitor= new BindingFinder(name.toCharArray(), prefixLookup);
441
			acceptInHierarchy(new HashSet(), visitor);
442
			return visitor.getBindings();
443
		} catch (CoreException e) {
444
			CCorePlugin.log(e);
445
		}
446
		return null;
447
	}
448
	
404
	// Not implemented
449
	// Not implemented
405
450
406
	public Object clone() {fail();return null;}
451
	public Object clone() {fail();return null;}
407
	public IField findField(String name) throws DOMException {fail();return null;}
452
	public IField findField(String name) throws DOMException {fail();return null;}
408
	public IBinding[] getFriends() throws DOMException {fail();return null;}
453
	public IBinding[] getFriends() throws DOMException {fail();return null;}
409
	public IBinding[] find(String name) throws DOMException {fail();return null;}
410
454
411
	public IScope getParent() throws DOMException {
455
	public IScope getParent() throws DOMException {
412
		try {
456
		try {
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java (-3 / +37 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 QNX Software Systems and others.
2
 * Copyright (c) 2006, 2007 QNX Software Systems 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 13-19 Link Here
13
13
14
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
14
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
15
15
16
import java.util.ArrayList;
17
import java.util.List;
18
16
import org.eclipse.cdt.core.CCorePlugin;
19
import org.eclipse.cdt.core.CCorePlugin;
20
import org.eclipse.cdt.core.dom.IPDOMNode;
17
import org.eclipse.cdt.core.dom.IPDOMVisitor;
21
import org.eclipse.cdt.core.dom.IPDOMVisitor;
18
import org.eclipse.cdt.core.dom.ast.DOMException;
22
import org.eclipse.cdt.core.dom.ast.DOMException;
19
import org.eclipse.cdt.core.dom.ast.IASTName;
23
import org.eclipse.cdt.core.dom.ast.IASTName;
Lines 28-33 Link Here
28
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
32
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
29
import org.eclipse.cdt.internal.core.pdom.dom.FindBindingsInBTree;
33
import org.eclipse.cdt.internal.core.pdom.dom.FindBindingsInBTree;
30
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
34
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
35
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNamedNode;
31
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
36
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
32
import org.eclipse.core.runtime.CoreException;
37
import org.eclipse.core.runtime.CoreException;
33
38
Lines 93-100 Link Here
93
	}
98
	}
94
99
95
	public IBinding[] find(String name) {
100
	public IBinding[] find(String name) {
101
		return find(name, false);
102
	}
103
	
104
	public IBinding[] find(String name, boolean prefixLookup) {
96
		try {
105
		try {
97
			FindBindingsInBTree visitor = new FindBindingsInBTree(getLinkageImpl(), name.toCharArray());
106
			FindBindingsInBTree visitor = new FindBindingsInBTree(getLinkageImpl(), name.toCharArray(), null, prefixLookup);
98
			getIndex().accept(visitor);
107
			getIndex().accept(visitor);
99
			return visitor.getBinding();
108
			return visitor.getBinding();
100
		} catch (CoreException e) {
109
		} catch (CoreException e) {
Lines 124-129 Link Here
124
		return true;
133
		return true;
125
	}
134
	}
126
135
127
	public IBinding[] getMemberBindings() throws DOMException {fail(); return null;}
136
	private static class BindingCollector implements IPDOMVisitor {
137
		private List fBindings = new ArrayList();
138
		
139
		public boolean visit(IPDOMNode node) throws CoreException {
140
			if (node instanceof PDOMNamedNode && node instanceof IBinding) {
141
				fBindings.add(node);
142
			}
143
			return false;
144
		}
145
		public void leave(IPDOMNode node) throws CoreException {
146
		}
147
		public IBinding[] getBindings() {
148
			return (IBinding[])fBindings.toArray(new IBinding[fBindings.size()]);
149
		}
150
	}
151
	
152
	public IBinding[] getMemberBindings() throws DOMException {
153
		BindingCollector visitor= new BindingCollector();
154
		try {
155
			accept(visitor);
156
		} catch (CoreException e) {
157
			CCorePlugin.log(e);
158
		}
159
		return visitor.getBindings();
160
	}
161
	
128
	public void addUsingDirective(IASTNode directive) throws DOMException {fail();}
162
	public void addUsingDirective(IASTNode directive) throws DOMException {fail();}
129
}
163
}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCField.java (-11 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 QNX Software Systems and others.
2
 * Copyright (c) 2006, 2007 QNX Software Systems 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-23 Link Here
14
14
15
import org.eclipse.cdt.core.dom.ast.DOMException;
15
import org.eclipse.cdt.core.dom.ast.DOMException;
16
import org.eclipse.cdt.core.dom.ast.IField;
16
import org.eclipse.cdt.core.dom.ast.IField;
17
import org.eclipse.cdt.core.dom.ast.IType;
18
import org.eclipse.cdt.internal.core.pdom.PDOM;
17
import org.eclipse.cdt.internal.core.pdom.PDOM;
19
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
18
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
20
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
21
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
19
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
22
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.CoreException;
23
21
Lines 25-34 Link Here
25
 * @author Doug Schaefer
23
 * @author Doug Schaefer
26
 *
24
 *
27
 */
25
 */
28
class PDOMCField extends PDOMBinding implements IField {
26
class PDOMCField extends PDOMCVariable implements IField {
29
27
30
	public PDOMCField(PDOM pdom, IPDOMMemberOwner parent, IField field) throws CoreException {
28
	public PDOMCField(PDOM pdom, IPDOMMemberOwner parent, IField field) throws CoreException {
31
		super(pdom, (PDOMNode) parent, field.getNameCharArray());
29
		super(pdom, (PDOMNode) parent, field);
32
	}
30
	}
33
31
34
	public PDOMCField(PDOM pdom, int record) {
32
	public PDOMCField(PDOM pdom, int record) {
Lines 42-53 Link Here
42
	public int getNodeType() {
40
	public int getNodeType() {
43
		return PDOMCLinkage.CFIELD;
41
		return PDOMCLinkage.CFIELD;
44
	}
42
	}
45
	
46
	public IType getType() throws DOMException {
47
		return null;
48
		// TODO - do we need the real type?
49
		//throw new PDOMNotImplementedError();
50
	}
51
43
52
	public boolean isStatic() throws DOMException {
44
	public boolean isStatic() throws DOMException {
53
		// ISO/IEC 9899:TC1 6.7.2.1
45
		// ISO/IEC 9899:TC1 6.7.2.1
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCStructure.java (-5 / +45 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 QNX Software Systems and others.
2
 * Copyright (c) 2006, 2007 QNX Software Systems 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 28-39 Link Here
28
import org.eclipse.cdt.core.dom.ast.IType;
28
import org.eclipse.cdt.core.dom.ast.IType;
29
import org.eclipse.cdt.core.dom.ast.ITypedef;
29
import org.eclipse.cdt.core.dom.ast.ITypedef;
30
import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
30
import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
31
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
31
import org.eclipse.cdt.internal.core.Util;
32
import org.eclipse.cdt.internal.core.Util;
32
import org.eclipse.cdt.internal.core.index.IIndexType;
33
import org.eclipse.cdt.internal.core.index.IIndexType;
33
import org.eclipse.cdt.internal.core.pdom.PDOM;
34
import org.eclipse.cdt.internal.core.pdom.PDOM;
34
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
35
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
35
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
36
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
36
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
37
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
38
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNamedNode;
37
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
39
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
38
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
40
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
39
import org.eclipse.core.runtime.CoreException;
41
import org.eclipse.core.runtime.CoreException;
Lines 196-206 Link Here
196
		fail(); return null;
198
		fail(); return null;
197
	}
199
	}
198
200
199
	public IBinding[] find(String name) throws DOMException {
200
		fail(); return null;
201
	}
202
203
	public IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
201
	public IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
204
		fail(); return null;
202
		fail(); return null;
205
	}
203
	}
204
	
205
	private static class BindingFinder implements IPDOMVisitor {
206
		private List fBindings = new ArrayList();
207
		private char[] fName;
208
		private boolean fPrefixLookup;
209
		
210
		public BindingFinder(char[] name, boolean prefiexLookup) {
211
			fName= name;
212
			fPrefixLookup= prefiexLookup;
213
		}
214
		
215
		public boolean visit(IPDOMNode node) throws CoreException {
216
			if (node instanceof PDOMNamedNode && node instanceof IBinding) {
217
				char[] n= ((PDOMNamedNode) node).getDBName().getChars();
218
				if ((fPrefixLookup && CharArrayUtils.equals(n, 0, fName.length, fName, false))
219
						|| (!fPrefixLookup && CharArrayUtils.equals(n, fName))) {
220
					fBindings.add(node);
221
				}
222
			}
223
			return false;
224
		}
225
		public void leave(IPDOMNode node) throws CoreException {
226
		}
227
		public IBinding[] getBindings() {
228
			return (IBinding[])fBindings.toArray(new IBinding[fBindings.size()]);
229
		}
230
	}
231
	
232
	public IBinding[] find(String name) throws DOMException {
233
		return find(name, false);
234
	}
235
	
236
	public IBinding[] find(String name, boolean prefixLookup) throws DOMException {
237
		try {
238
			BindingFinder visitor= new BindingFinder(name.toCharArray(), prefixLookup);
239
			accept(visitor);
240
			return visitor.getBindings();
241
		} catch (CoreException e) {
242
			CCorePlugin.log(e);
243
		}
244
		return null;
245
	}
206
}
246
}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java (-4 / +30 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 QNX Software Systems and others.
2
 * Copyright (c) 2006, 2007 QNX Software Systems 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 44-63 Link Here
44
	public static final int FIRST_PARAM = PDOMBinding.RECORD_SIZE + 4;
44
	public static final int FIRST_PARAM = PDOMBinding.RECORD_SIZE + 4;
45
	
45
	
46
	/**
46
	/**
47
	 * Offset for return type of this function (relative to
48
	 * the beginning of the record).
49
	 */
50
	private static final int RETURN_TYPE = PDOMBinding.RECORD_SIZE + 8;
51
	
52
	/**
47
	 * Offset of annotation information (relative to the beginning of the
53
	 * Offset of annotation information (relative to the beginning of the
48
	 * record).
54
	 * record).
49
	 */
55
	 */
50
	private static final int ANNOTATIONS = PDOMBinding.RECORD_SIZE + 8; // byte
56
	private static final int ANNOTATIONS = PDOMBinding.RECORD_SIZE + 12; // byte
51
	
57
	
52
	/**
58
	/**
53
	 * The size in bytes of a PDOMCPPFunction record in the database.
59
	 * The size in bytes of a PDOMCPPFunction record in the database.
54
	 */
60
	 */
55
	public static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 9;
61
	public static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 13;
56
	
62
	
57
	public PDOMCFunction(PDOM pdom, PDOMNode parent, IFunction function) throws CoreException {
63
	public PDOMCFunction(PDOM pdom, PDOMNode parent, IFunction function) throws CoreException {
58
		super(pdom, parent, function.getNameCharArray());
64
		super(pdom, parent, function.getNameCharArray());
59
		
65
		
60
		try {
66
		try {
67
			IFunctionType ft= function.getType();
68
			IType rt= ft.getReturnType();
69
			if (rt != null) {
70
				PDOMNode typeNode = getLinkageImpl().addType(this, rt);
71
				if (typeNode != null) {
72
					pdom.getDB().putInt(record + RETURN_TYPE, typeNode.getRecord());
73
				}
74
			}
75
			
61
			IParameter[] params = function.getParameters();
76
			IParameter[] params = function.getParameters();
62
			pdom.getDB().putInt(record + NUM_PARAMS, params.length);
77
			pdom.getDB().putInt(record + NUM_PARAMS, params.length);
63
			for (int i = 0; i < params.length; ++i) {
78
			for (int i = 0; i < params.length; ++i) {
Lines 173-180 Link Here
173
		return getBit(getByte(record + ANNOTATIONS), PDOMCAnnotation.VARARGS_OFFSET);
188
		return getBit(getByte(record + ANNOTATIONS), PDOMCAnnotation.VARARGS_OFFSET);
174
	}
189
	}
175
	
190
	
191
	public IType getReturnType() throws DOMException {
192
		try {
193
			PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + RETURN_TYPE));
194
			if (node instanceof IType) {
195
				return (IType) node;
196
			}
197
		} catch (CoreException e) {
198
			CCorePlugin.log(e);
199
		}
200
		return null;
201
	}
202
	
176
	public IScope getFunctionScope() throws DOMException {fail(); return null;}
203
	public IScope getFunctionScope() throws DOMException {fail(); return null;}
177
	public IType getReturnType() throws DOMException {fail();return null;}
178
	public boolean isSameType(IType type) {fail(); return false;}
204
	public boolean isSameType(IType type) {fail(); return false;}
179
	public Object clone() {fail(); return null;}
205
	public Object clone() {fail(); return null;}
180
}
206
}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCVariable.java (-6 / +24 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 QNX Software Systems and others.
2
 * Copyright (c) 2006, 2007 QNX Software Systems 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 12-22 Link Here
12
12
13
package org.eclipse.cdt.internal.core.pdom.dom.c;
13
package org.eclipse.cdt.internal.core.pdom.dom.c;
14
14
15
import org.eclipse.cdt.core.CCorePlugin;
15
import org.eclipse.cdt.core.dom.ast.DOMException;
16
import org.eclipse.cdt.core.dom.ast.DOMException;
16
import org.eclipse.cdt.core.dom.ast.IType;
17
import org.eclipse.cdt.core.dom.ast.IType;
17
import org.eclipse.cdt.core.dom.ast.IVariable;
18
import org.eclipse.cdt.core.dom.ast.IVariable;
18
import org.eclipse.cdt.internal.core.Util;
19
import org.eclipse.cdt.internal.core.Util;
19
import org.eclipse.cdt.internal.core.pdom.PDOM;
20
import org.eclipse.cdt.internal.core.pdom.PDOM;
21
import org.eclipse.cdt.internal.core.pdom.db.Database;
20
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
22
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
21
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
23
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
22
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.CoreException;
Lines 28-47 Link Here
28
class PDOMCVariable extends PDOMBinding implements IVariable {
30
class PDOMCVariable extends PDOMBinding implements IVariable {
29
31
30
	/**
32
	/**
33
	 * Offset of pointer to type information for this parameter
34
	 * (relative to the beginning of the record).
35
	 */
36
	private static final int TYPE_OFFSET = PDOMBinding.RECORD_SIZE + 0;
37
	
38
	/**
31
	 * Offset of annotation information (relative to the beginning of the
39
	 * Offset of annotation information (relative to the beginning of the
32
	 * record).
40
	 * record).
33
	 */
41
	 */
34
	private static final int ANNOTATIONS = PDOMBinding.RECORD_SIZE + 0;
42
	private static final int ANNOTATIONS = PDOMBinding.RECORD_SIZE + 4;
35
	
43
	
36
	/**
44
	/**
37
	 * The size in bytes of a PDOMCVariable record in the database.
45
	 * The size in bytes of a PDOMCVariable record in the database.
38
	 */
46
	 */
39
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 1;
47
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 5;
40
	
48
	
41
	public PDOMCVariable(PDOM pdom, PDOMNode parent, IVariable variable) throws CoreException {
49
	public PDOMCVariable(PDOM pdom, PDOMNode parent, IVariable variable) throws CoreException {
42
		super(pdom, parent, variable.getNameCharArray());
50
		super(pdom, parent, variable.getNameCharArray());
43
51
44
		try {
52
		try {
53
			// Find the type record
54
			Database db = pdom.getDB();
55
			PDOMNode typeNode = parent.getLinkageImpl().addType(this, variable.getType());
56
			if (typeNode != null)
57
				db.putInt(record + TYPE_OFFSET, typeNode.getRecord());
58
			
45
			pdom.getDB().putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(variable));
59
			pdom.getDB().putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(variable));
46
		} catch (DOMException e) {
60
		} catch (DOMException e) {
47
			throw new CoreException(Util.createStatus(e));
61
			throw new CoreException(Util.createStatus(e));
Lines 61-69 Link Here
61
	}
75
	}
62
	
76
	
63
	public IType getType() throws DOMException {
77
	public IType getType() throws DOMException {
64
		return null;
78
		try {
65
		// TODO - do we need the real type?
79
			int typeRec = pdom.getDB().getInt(record + TYPE_OFFSET);
66
		//throw new PDOMNotImplementedError();
80
			return (IType)getLinkageImpl().getNode(typeRec);
81
		} catch (CoreException e) {
82
			CCorePlugin.log(e);
83
			return null;
84
		}
67
	}
85
	}
68
86
69
	public boolean isStatic() throws DOMException {
87
	public boolean isStatic() throws DOMException {
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java (+49 lines)
Lines 14-19 Link Here
14
14
15
package org.eclipse.cdt.internal.core.pdom.dom;
15
package org.eclipse.cdt.internal.core.pdom.dom;
16
16
17
import java.util.ArrayList;
18
import java.util.List;
19
17
import org.eclipse.cdt.core.dom.ILinkage;
20
import org.eclipse.cdt.core.dom.ILinkage;
18
import org.eclipse.cdt.core.dom.IName;
21
import org.eclipse.cdt.core.dom.IName;
19
import org.eclipse.cdt.core.dom.IPDOMVisitor;
22
import org.eclipse.cdt.core.dom.IPDOMVisitor;
Lines 29-37 Link Here
29
import org.eclipse.cdt.core.dom.ast.IQualifierType;
32
import org.eclipse.cdt.core.dom.ast.IQualifierType;
30
import org.eclipse.cdt.core.dom.ast.IScope;
33
import org.eclipse.cdt.core.dom.ast.IScope;
31
import org.eclipse.cdt.core.dom.ast.IType;
34
import org.eclipse.cdt.core.dom.ast.IType;
35
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
32
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
36
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
33
import org.eclipse.cdt.core.index.IIndexBinding;
37
import org.eclipse.cdt.core.index.IIndexBinding;
34
import org.eclipse.cdt.core.index.IIndexLinkage;
38
import org.eclipse.cdt.core.index.IIndexLinkage;
39
import org.eclipse.cdt.core.index.IndexFilter;
35
import org.eclipse.cdt.internal.core.Util;
40
import org.eclipse.cdt.internal.core.Util;
36
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
41
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
37
import org.eclipse.cdt.internal.core.pdom.PDOM;
42
import org.eclipse.cdt.internal.core.pdom.PDOM;
Lines 228-233 Link Here
228
		return visitor.getBinding();
233
		return visitor.getBinding();
229
	}
234
	}
230
235
236
	private static class PrefixedBindingFinder implements IBTreeVisitor {
237
		private PDOMLinkage linkage;
238
		private String prefix;
239
		private IndexFilter filter;
240
		private List bindings = new ArrayList();
241
		
242
		PrefixedBindingFinder(PDOMLinkage linkage, String prefix, IndexFilter filter) {
243
			this.linkage = linkage;
244
			this.prefix = prefix;
245
			this.filter = filter;
246
		}
247
		
248
		public int compare(int record) throws CoreException {
249
			PDOMNamedNode node = (PDOMNamedNode) linkage.getNode(record);
250
			IString name = node.getDBName();
251
			if (name.getString().startsWith(prefix)) {
252
				return 0;
253
			}
254
			return name.compare(prefix);
255
		}
256
257
		public boolean visit(int record) throws CoreException {
258
			PDOMBinding binding = linkage.getPDOM().getBinding(record);
259
			if (filter.acceptImplicitMethods() || !(binding instanceof ICPPMethod) ||
260
					!((ICPPMethod)binding).isImplicit()) {
261
				if (filter.acceptBinding(binding)) {
262
					bindings.add(binding);
263
				}
264
			}
265
			return true;
266
		}
267
		
268
		public IBinding[] getBindings() {
269
			return (IBinding[]) bindings.toArray(new IBinding[bindings.size()]);
270
		}
271
	}
272
	
273
	public IBinding[] findBindingsForPrefix(String prefix, IndexFilter filter) throws CoreException {
274
		PrefixedBindingFinder visitor = new PrefixedBindingFinder(this, prefix, filter);
275
		getIndex().accept(visitor);
276
		
277
		return visitor.getBindings();
278
	}
279
	
231
	/**
280
	/**
232
	 * Callback informing the linkage that a name has been added. This is
281
	 * Callback informing the linkage that a name has been added. This is
233
	 * used to do addtional processing, like establishing inheritance relationships.
282
	 * used to do addtional processing, like establishing inheritance relationships.
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/FindBindingsInBTree.java (-5 / +27 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 QNX Software Systems and others.
2
 * Copyright (c) 2006, 2007 QNX Software Systems 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.List;
14
import java.util.List;
15
15
16
import org.eclipse.cdt.core.dom.ast.IBinding;
16
import org.eclipse.cdt.core.dom.ast.IBinding;
17
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
17
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
18
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
19
import org.eclipse.cdt.internal.core.pdom.db.IString;
18
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.CoreException;
19
21
20
public final class FindBindingsInBTree implements IBTreeVisitor {
22
public final class FindBindingsInBTree implements IBTreeVisitor {
21
	protected final PDOMLinkage linkage;
23
	protected final PDOMLinkage linkage;
22
	protected final char[] name;
24
	protected final char[] name;
25
	protected final boolean prefixLookup;
23
	
26
	
24
	
27
	
25
	public int compare(int record) throws CoreException {
28
	public int compare(int record) throws CoreException {
26
		PDOMNamedNode node = ((PDOMNamedNode)linkage.getNode(record)); 
29
		PDOMNamedNode node = ((PDOMNamedNode)linkage.getNode(record));
27
		return node.getDBName().compare(name);
30
		IString n = node.getDBName();
31
		if (prefixLookup && n.getString().startsWith(new String(name))) {
32
			return 0;
33
		}
34
		return n.compare(name);
28
	}
35
	}
29
	
36
	
30
	private List bindings = new ArrayList();
37
	private List bindings = new ArrayList();
Lines 59-67 Link Here
59
	 * @param desiredType
66
	 * @param desiredType
60
	 */
67
	 */
61
	public FindBindingsInBTree(PDOMLinkage linkage, char[] name, int[] desiredType) {
68
	public FindBindingsInBTree(PDOMLinkage linkage, char[] name, int[] desiredType) {
69
		this(linkage, name, desiredType, false);
70
	}
71
	
72
	/**
73
	 * Match a collection of types.
74
	 * 
75
	 * @param pdom
76
	 * @param name
77
	 * @param desiredType
78
	 * @param prefixLookup
79
	 */
80
	public FindBindingsInBTree(PDOMLinkage linkage, char[] name, int[] desiredType, boolean prefixLookup) {
62
		this.name = name;
81
		this.name = name;
63
		this.desiredType = desiredType;
82
		this.desiredType = desiredType;
64
		this.linkage= linkage;
83
		this.linkage= linkage;
84
		this.prefixLookup = prefixLookup;
65
	}
85
	}
66
	
86
	
67
	public boolean visit(int record) throws CoreException {
87
	public boolean visit(int record) throws CoreException {
Lines 69-76 Link Here
69
			return true;
89
			return true;
70
		
90
		
71
		PDOMBinding tBinding = linkage.getPDOM().getBinding(record);
91
		PDOMBinding tBinding = linkage.getPDOM().getBinding(record);
72
		if (!tBinding.hasName(name))
92
		if ((!prefixLookup && !tBinding.hasName(name))
73
			// no more bindings with our desired name
93
				|| (prefixLookup && !CharArrayUtils.equals(
94
						tBinding.getNameCharArray(),
95
						0, name.length, name, false)))
74
			return false;
96
			return false;
75
		
97
		
76
		if (desiredType == null) {
98
		if (desiredType == null) {
(-)parser/org/eclipse/cdt/internal/core/pdom/PDOM.java (-6 / +23 lines)
Lines 95-100 Link Here
95
	// 20 - add pointer to member types, array types, return types for functions
95
	// 20 - add pointer to member types, array types, return types for functions
96
	// 21 - change representation of paths in the pdom (167549)
96
	// 21 - change representation of paths in the pdom (167549)
97
	// 22 - fix inheritance relations (167396)
97
	// 22 - fix inheritance relations (167396)
98
	// 23 - port content assist to PDOM (169860)
98
99
99
	public static final int LINKAGES = Database.DATA_AREA;
100
	public static final int LINKAGES = Database.DATA_AREA;
100
	public static final int FILE_INDEX = Database.DATA_AREA + 4;
101
	public static final int FILE_INDEX = Database.DATA_AREA + 4;
Lines 257-269 Link Here
257
		private List bindings = new ArrayList();
258
		private List bindings = new ArrayList();
258
		private boolean isFullyQualified;
259
		private boolean isFullyQualified;
259
		private BitSet matchesUpToLevel;
260
		private BitSet matchesUpToLevel;
260
		private boolean acceptImplicitMethods;
261
		private IndexFilter filter;
261
262
262
		public BindingFinder(Pattern[] pattern, boolean isFullyQualified, boolean acceptImplicitMethods, IProgressMonitor monitor) {
263
		public BindingFinder(Pattern[] pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) {
263
			this.pattern = pattern;
264
			this.pattern = pattern;
264
			this.monitor = monitor;
265
			this.monitor = monitor;
265
			this.isFullyQualified= isFullyQualified;
266
			this.isFullyQualified= isFullyQualified;
266
			this.acceptImplicitMethods= acceptImplicitMethods;
267
			this.filter= filter;
267
			matchesUpToLevel= new BitSet();
268
			matchesUpToLevel= new BitSet();
268
			matchesUpToLevel.set(0);
269
			matchesUpToLevel.set(0);
269
			matchStack.add(matchesUpToLevel);
270
			matchStack.add(matchesUpToLevel);
Lines 280-288 Link Here
280
				// check if we have a complete match.
281
				// check if we have a complete match.
281
				final int lastIdx = pattern.length-1;
282
				final int lastIdx = pattern.length-1;
282
				if (matchesUpToLevel.get(lastIdx) && pattern[lastIdx].matcher(name).matches()) {
283
				if (matchesUpToLevel.get(lastIdx) && pattern[lastIdx].matcher(name).matches()) {
283
					if (acceptImplicitMethods || !(binding instanceof ICPPMethod) ||
284
					if (filter.acceptImplicitMethods() || !(binding instanceof ICPPMethod) ||
284
							!((ICPPMethod)binding).isImplicit()) {
285
							!((ICPPMethod)binding).isImplicit()) {
285
						bindings.add(binding);
286
						if (filter.acceptBinding(binding)) {
287
							bindings.add(binding);
288
						}
286
					}
289
					}
287
				}
290
				}
288
291
Lines 344-350 Link Here
344
	}
347
	}
345
348
346
	public IIndexFragmentBinding[] findBindings(Pattern[] pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
349
	public IIndexFragmentBinding[] findBindings(Pattern[] pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
347
		BindingFinder finder = new BindingFinder(pattern, isFullyQualified, filter.acceptImplicitMethods(), monitor);
350
		BindingFinder finder = new BindingFinder(pattern, isFullyQualified, filter, monitor);
348
		for (Iterator iter = fLinkageIDCache.values().iterator(); iter.hasNext();) {
351
		for (Iterator iter = fLinkageIDCache.values().iterator(); iter.hasNext();) {
349
			PDOMLinkage linkage = (PDOMLinkage) iter.next();
352
			PDOMLinkage linkage = (PDOMLinkage) iter.next();
350
			if (filter.acceptLinkage(linkage)) {
353
			if (filter.acceptLinkage(linkage)) {
Lines 614-617 Link Here
614
		}
617
		}
615
		return IIndexBinding.EMPTY_INDEX_BINDING_ARRAY;
618
		return IIndexBinding.EMPTY_INDEX_BINDING_ARRAY;
616
	}
619
	}
620
	
621
	public IBinding[] findBindingsForPrefix(String prefix, IndexFilter filter) throws CoreException {
622
		ArrayList result = new ArrayList();
623
		for (Iterator iter = fLinkageIDCache.values().iterator(); iter.hasNext();) {
624
			PDOMLinkage linkage = (PDOMLinkage) iter.next();
625
			if (filter.acceptLinkage(linkage)) {
626
				IBinding[] bindings = linkage.findBindingsForPrefix(prefix, filter);
627
				for (int j = 0; j < bindings.length; j++) {
628
					result.add(bindings[j]);
629
				}
630
			}
631
		}
632
		return (IBinding[]) result.toArray(new IBinding[result.size()]);
633
	}
617
}
634
}
(-)parser/org/eclipse/cdt/core/index/IIndex.java (-1 / +11 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *    Markus Schorn - initial API and implementation
9
 *    Markus Schorn - initial API and implementation
10
 *    Andrew Ferguson (Symbian)
10
 *    Andrew Ferguson (Symbian)
11
 *    Bryan Wilkinson (QNX)
11
 *******************************************************************************/ 
12
 *******************************************************************************/ 
12
13
13
package org.eclipse.cdt.core.index;
14
package org.eclipse.cdt.core.index;
Lines 242-247 Link Here
242
	public IBinding[] findInNamespace(IBinding nsbinding, char[] name);
243
	public IBinding[] findInNamespace(IBinding nsbinding, char[] name);
243
244
244
	/**
245
	/**
246
	 * Searches for all bindings with names that start with the given prefix.
247
	 * @param prefix the prefix with which all returned bindings must start
248
	 * @param filter a filter that allows for skipping parts of the index
249
	 * @return an array of bindings with the prefix
250
	 * @throws CoreException
251
	 */
252
	public IBinding[] findBindingsForPrefix(String prefix, IndexFilter filter) throws CoreException;
253
	
254
	/**
245
	 * Searches for all names that resolve to the given binding. You can limit the result to references, declarations
255
	 * Searches for all names that resolve to the given binding. You can limit the result to references, declarations
246
	 * or definitions, or a combination of those.
256
	 * or definitions, or a combination of those.
247
	 * @param binding a binding for which names are searched for
257
	 * @param binding a binding for which names are searched for
(-)parser/org/eclipse/cdt/core/index/IndexFilter.java (-1 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 8-18 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *    Markus Schorn - initial API and implementation
9
 *    Markus Schorn - initial API and implementation
10
 *    Andrew Ferguson (Symbian)
10
 *    Andrew Ferguson (Symbian)
11
 *    Bryan Wilkinson (QNX)
11
 *******************************************************************************/ 
12
 *******************************************************************************/ 
12
13
13
package org.eclipse.cdt.core.index;
14
package org.eclipse.cdt.core.index;
14
15
15
import org.eclipse.cdt.core.dom.ILinkage;
16
import org.eclipse.cdt.core.dom.ILinkage;
17
import org.eclipse.cdt.core.dom.ast.IBinding;
16
18
17
/**
19
/**
18
 * Can be subclassed and used for queries in the index.
20
 * Can be subclassed and used for queries in the index.
Lines 61-64 Link Here
61
	public boolean acceptImplicitMethods() {
63
	public boolean acceptImplicitMethods() {
62
		return false;
64
		return false;
63
	}
65
	}
66
	
67
	/**
68
	 * Determines whether or not a binding is valid.
69
	 * 
70
	 * @param binding the binding being checked for validity
71
	 * @return whether or not the binding is valid
72
	 */
73
	public boolean acceptBinding(IBinding binding) {
74
		return true;
75
	}
64
}
76
}
(-)parser/org/eclipse/cdt/internal/core/index/CIndex.java (-3 / +24 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2006, 2007 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    Markus Schorn - initial API and implementation
9
 *    Markus Schorn - initial API and implementation
10
 *    Bryan Wilkinson (QNX)
10
 *******************************************************************************/ 
11
 *******************************************************************************/ 
11
12
12
package org.eclipse.cdt.internal.core.index;
13
package org.eclipse.cdt.internal.core.index;
Lines 154-161 Link Here
154
		monitor.done();
155
		monitor.done();
155
		return (IIndexBinding[]) result.toArray(new IIndexBinding[result.size()]);
156
		return (IIndexBinding[]) result.toArray(new IIndexBinding[result.size()]);
156
	}
157
	}
157
158
	
158
159
	public IIndexName[] findNames(IBinding binding, int flags) throws CoreException {
159
	public IIndexName[] findNames(IBinding binding, int flags) throws CoreException {
160
		ArrayList result= new ArrayList();
160
		ArrayList result= new ArrayList();
161
		for (int i = 0; i < fPrimaryFragmentCount; i++) {
161
		for (int i = 0; i < fPrimaryFragmentCount; i++) {
Lines 368-371 Link Here
368
		}
368
		}
369
		return IIndexBinding.EMPTY_INDEX_BINDING_ARRAY;
369
		return IIndexBinding.EMPTY_INDEX_BINDING_ARRAY;
370
	}
370
	}
371
	
372
	public IBinding[] findBindingsForPrefix(String prefix, IndexFilter filter) throws CoreException {
373
		ArrayList result= new ArrayList();
374
		for (int i = 0; i < fFragments.length; i++) {
375
			try {
376
				IBinding[] part = fFragments[i].findBindingsForPrefix(prefix, filter);
377
				for (int j = 0; j < part.length; j++) {
378
					IBinding binding = part[j];
379
					if (binding instanceof IIndexBinding) {
380
						result.add(binding);
381
					}
382
				}
383
			} catch (CoreException e) {
384
				CCorePlugin.log(e);
385
			}
386
		}
387
		if (!result.isEmpty()) {
388
			return (IIndexBinding[]) result.toArray(new IIndexBinding[result.size()]);
389
		}
390
		return IIndexBinding.EMPTY_INDEX_BINDING_ARRAY;
391
	}
371
}
392
}
(-)parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java (-1 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2006, 2007 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    Markus Schorn - initial API and implementation
9
 *    Markus Schorn - initial API and implementation
10
 *    Bryan Wilkinson (QNX)
10
 *******************************************************************************/ 
11
 *******************************************************************************/ 
11
12
12
package org.eclipse.cdt.internal.core.index;
13
package org.eclipse.cdt.internal.core.index;
Lines 143-146 Link Here
143
	 * Returns all bindings with the given name in the given namespace
144
	 * Returns all bindings with the given name in the given namespace
144
	 */
145
	 */
145
	IBinding[] findInNamespace(IBinding nsbinding, char[] name) throws CoreException;
146
	IBinding[] findInNamespace(IBinding nsbinding, char[] name) throws CoreException;
147
	
148
	/**
149
	 * Returns all bindings with the given prefix, accepted by the given filter
150
	 */
151
	IBinding[] findBindingsForPrefix(String prefix, IndexFilter filter) throws CoreException;
146
}
152
}
(-)parser/org/eclipse/cdt/internal/core/index/EmptyCIndex.java (-2 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2006, 2007 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    Markus Schorn - initial API and implementation
9
 *    Markus Schorn - initial API and implementation
10
 *    Bryan Wilkinson (QNX)
10
 *******************************************************************************/ 
11
 *******************************************************************************/ 
11
12
12
package org.eclipse.cdt.internal.core.index;
13
package org.eclipse.cdt.internal.core.index;
Lines 93-99 Link Here
93
	public IIndexBinding[] findBindings(Pattern[] pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
94
	public IIndexBinding[] findBindings(Pattern[] pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
94
		return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
95
		return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
95
	}
96
	}
96
97
	
97
	public IIndexBinding adaptBinding(IBinding binding) throws CoreException {
98
	public IIndexBinding adaptBinding(IBinding binding) throws CoreException {
98
		return null;
99
		return null;
99
	}
100
	}
Lines 105-108 Link Here
105
	public IBinding[] findInNamespace(IBinding nsbinding, char[] name) {
106
	public IBinding[] findInNamespace(IBinding nsbinding, char[] name) {
106
		return IIndexBinding.EMPTY_INDEX_BINDING_ARRAY;
107
		return IIndexBinding.EMPTY_INDEX_BINDING_ARRAY;
107
	}
108
	}
109
	
110
	public IBinding[] findBindingsForPrefix(String prefix, IndexFilter filter) throws CoreException {
111
		return IIndexBinding.EMPTY_INDEX_BINDING_ARRAY;
112
	}
108
}
113
}
(-)parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2006 QNX Software Systems and others.
2
 * Copyright (c) 2005, 2007 QNX Software Systems 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 97-103 Link Here
97
				scanner,
97
				scanner,
98
				ParserMode.COMPLETION_PARSE,
98
				ParserMode.COMPLETION_PARSE,
99
				ParserUtil.getParserLogService(),
99
				ParserUtil.getParserLogService(),
100
				new GCCParserExtensionConfiguration());
100
				new GCCParserExtensionConfiguration(),
101
				index);
101
		
102
		
102
		// Run the parse and return the completion node
103
		// Run the parse and return the completion node
103
		parser.parse();
104
		parser.parse();
(-)parser/org/eclipse/cdt/core/dom/ast/IScope.java (-1 / +14 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 * IBM - Initial API and implementation
9
 * IBM - Initial API and implementation
10
 * Markus Schorn (Wind River Systems)
10
 * Markus Schorn (Wind River Systems)
11
 * Bryan Wilkinson (QNX)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.cdt.core.dom.ast;
13
package org.eclipse.cdt.core.dom.ast;
13
14
Lines 47-52 Link Here
47
	public IBinding[] find(String name) throws DOMException;
48
	public IBinding[] find(String name) throws DOMException;
48
        	
49
        	
49
	/**
50
	/**
51
	 * This is the general lookup entry point. It returns the list of
52
	 * valid bindings for a given name or prefix.  The lookup proceeds as an unqualified
53
	 * lookup.  Constructors are not considered during this lookup and won't be returned.
54
	 * No attempt is made to resolve potential ambiguities or perform access checking.
55
	 * 
56
	 * @param name the name for which to search
57
	 * @param prefixLookup whether or not to only check prefixes
58
	 * @return List of IBinding
59
	 */
60
	public IBinding[] find(String name, boolean prefixLookup) throws DOMException;
61
	
62
	/**
50
	 * Get the binding in this scope that the given name would resolve to. Could
63
	 * Get the binding in this scope that the given name would resolve to. Could
51
	 * return null if there is no matching binding in this scope, if the binding has not
64
	 * return null if there is no matching binding in this scope, if the binding has not
52
	 * yet been cached in this scope, or if resolve == false and the appropriate binding 
65
	 * yet been cached in this scope, or if resolve == false and the appropriate binding 
(-)parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java (-2 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 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 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Markus Schorn (Wind River Systems)
10
 *     Markus Schorn (Wind River Systems)
11
 *     Bryan Wilkinson (QNX)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
13
13
/*
14
/*
Lines 134-146 Link Here
134
        throw new DOMException( this );
135
        throw new DOMException( this );
135
    }
136
    }
136
137
137
138
    /* (non-Javadoc)
138
    /* (non-Javadoc)
139
     * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
139
     * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
140
     */
140
     */
141
    public IBinding[] find( String name ) throws DOMException {
141
    public IBinding[] find( String name ) throws DOMException {
142
        throw new DOMException( this );
142
        throw new DOMException( this );
143
    }
143
    }
144
    
145
    /* (non-Javadoc)
146
     * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
147
     */
148
    public IBinding[] find( String name, boolean prefixLookup ) throws DOMException {
149
        throw new DOMException( this );
150
    }
144
151
145
	/* (non-Javadoc)
152
	/* (non-Javadoc)
146
	 * @see org.eclipse.cdt.core.dom.ast.IScope#getScopeName()
153
	 * @see org.eclipse.cdt.core.dom.ast.IScope#getScopeName()
(-)parser/org/eclipse/cdt/internal/core/dom/parser/IASTCompletionContext.java (+44 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 QNX Software Systems and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     QNX - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.internal.core.dom.parser;
13
14
import org.eclipse.cdt.core.dom.ast.IASTName;
15
import org.eclipse.cdt.core.dom.ast.IBinding;
16
17
/**
18
 * Interface for a code completion's context. Used for context-sensitive
19
 * finding of bindings with a certain prefix.
20
 * 
21
 * <p>
22
 * This interface is not intended to be implemented by clients.
23
 * </p>
24
 * <p>
25
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
26
 * part of a work in progress. There is no guarantee that this API will work or
27
 * that it will remain the same. Please do not use this API without consulting
28
 * with the CDT team.
29
 * </p>
30
 * 
31
 * @author Bryan Wilkinson
32
 * @since 4.0
33
 */
34
public interface IASTCompletionContext {
35
	
36
	/**
37
	 * Returns bindings that start with the given prefix, only considering those
38
	 * that are valid for this context.
39
	 * 
40
	 * @param n the name containing a prefix
41
	 * @return valid bindings in this context for the given prefix
42
	 */
43
	IBinding[] resolvePrefix(IASTName n);
44
}

Return to bug 169860