mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 14:15:23 +02:00
bugs 72824, 69334
This commit is contained in:
parent
a76ec38690
commit
bb6eaf7e55
8 changed files with 324 additions and 86 deletions
|
@ -20,7 +20,9 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
|
@ -75,46 +77,36 @@ import org.eclipse.cdt.testplugin.CProjectHelper;
|
|||
import org.eclipse.cdt.testplugin.FileManager;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CompleteParsePluginTest extends TestCase {
|
||||
NullProgressMonitor monitor;
|
||||
IWorkspace workspace;
|
||||
IProject project;
|
||||
FileManager fileManager;
|
||||
static NullProgressMonitor monitor;
|
||||
static IWorkspace workspace;
|
||||
static IProject project;
|
||||
static FileManager fileManager;
|
||||
|
||||
public CompleteParsePluginTest()
|
||||
{
|
||||
super();
|
||||
try{
|
||||
initProject();
|
||||
} catch( Exception e){ /*boo*/ }
|
||||
}
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CompleteParsePluginTest(String name)
|
||||
{
|
||||
super(name);
|
||||
try{
|
||||
initProject();
|
||||
} catch( Exception e){ /*boo*/ }
|
||||
}
|
||||
protected void initProject() throws Exception {
|
||||
(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
workspace = ResourcesPlugin.getWorkspace();
|
||||
|
||||
ICProject cPrj = CProjectHelper.createCCProject("ParserTestProject", "bin"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
project = cPrj.getProject();
|
||||
project.setSessionProperty(IndexManager.activationKey,new Boolean(false));
|
||||
|
||||
ICProject cPrj;
|
||||
try {
|
||||
cPrj = CProjectHelper.createCCProject("ParserTestProject", "bin"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
project = cPrj.getProject();
|
||||
project.setSessionProperty(IndexManager.activationKey,new Boolean(false));
|
||||
} catch ( CoreException e ) {
|
||||
/*boo*/
|
||||
}
|
||||
if (project == null)
|
||||
fail("Unable to create project"); //$NON-NLS-1$
|
||||
|
||||
|
@ -122,6 +114,48 @@ public class CompleteParsePluginTest extends TestCase {
|
|||
fileManager = new FileManager();
|
||||
}
|
||||
|
||||
public CompleteParsePluginTest()
|
||||
{
|
||||
super();
|
||||
}
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CompleteParsePluginTest(String name)
|
||||
{
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite( CompleteParsePluginTest.class );
|
||||
suite.addTest( new CompleteParsePluginTest("cleanupProject") ); //$NON-NLS-1$
|
||||
return suite;
|
||||
}
|
||||
|
||||
public void cleanupProject() throws Exception {
|
||||
try{
|
||||
project.delete( true, false, monitor );
|
||||
project = null;
|
||||
} catch( Throwable e ){
|
||||
/*boo*/
|
||||
}
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
if( project == null || !project.exists() )
|
||||
return;
|
||||
|
||||
IResource [] members = project.members();
|
||||
for( int i = 0; i < members.length; i++ ){
|
||||
if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cdtproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
continue;
|
||||
try{
|
||||
members[i].delete( false, monitor );
|
||||
} catch( Throwable e ){
|
||||
/*boo*/
|
||||
}
|
||||
}
|
||||
}
|
||||
protected IFile importFile(String fileName, String contents ) throws Exception{
|
||||
//Obtain file handle
|
||||
IFile file = project.getProject().getFile(fileName);
|
||||
|
@ -256,10 +290,12 @@ public class CompleteParsePluginTest extends TestCase {
|
|||
protected IASTScope parse(IFile code, List callbackList, ParserLanguage language) throws Exception
|
||||
{
|
||||
callback = new CallbackTracker( callbackList );
|
||||
InputStream stream = code.getContents();
|
||||
IParser parser = ParserFactory.createParser(
|
||||
ParserFactory.createScanner( new CodeReader( code.getLocation().toOSString(), code.getContents() ), new ScannerInfo(), //$NON-NLS-1$
|
||||
ParserFactory.createScanner( new CodeReader( code.getLocation().toOSString(), stream ), new ScannerInfo(), //$NON-NLS-1$
|
||||
ParserMode.COMPLETE_PARSE, language, callback, new NullLogService(), null ), callback, ParserMode.COMPLETE_PARSE, language, null
|
||||
);
|
||||
stream.close();
|
||||
boolean parseResult = parser.parse();
|
||||
// throw exception if there are generated IProblems
|
||||
if( !parseResult ) throw new ParserException( "FAILURE"); //$NON-NLS-1$
|
||||
|
|
|
@ -47,7 +47,9 @@ public class ParserTestSuite extends TestCase {
|
|||
suite.addTestSuite( CompleteParseASTTemplateTest.class );
|
||||
suite.addTestSuite( StructuralParseTest.class );
|
||||
suite.addTestSuite( ObjectMapTest.class );
|
||||
suite.addTestSuite( CompleteParsePluginTest.class );
|
||||
|
||||
suite.addTest( CompleteParsePluginTest.suite() );
|
||||
|
||||
// suite.addTest( GCCParserExtensionTestSuite.suite() );
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.parser.util.ObjectSet;
|
|||
public class TypeFilter {
|
||||
|
||||
public TypeFilter(){
|
||||
//empty
|
||||
}
|
||||
|
||||
public TypeFilter( ITypeInfo.eType type ){
|
||||
|
@ -66,7 +67,8 @@ public class TypeFilter {
|
|||
if( typeInfo.isType( ITypeInfo.t_function ) )
|
||||
{
|
||||
if( ( acceptedKinds.containsKey( LookupKind.FUNCTIONS ) && !symbolIsMember ) ||
|
||||
( acceptedKinds.containsKey( LookupKind.METHODS ) && symbolIsMember ) )
|
||||
( acceptedKinds.containsKey( LookupKind.METHODS ) && symbolIsMember ) ||
|
||||
( acceptedKinds.containsKey( LookupKind.MEMBERS ) && symbolIsMember ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -84,7 +86,8 @@ public class TypeFilter {
|
|||
{
|
||||
if( ( acceptedKinds.containsKey( LookupKind.VARIABLES ) && !symbolIsMember && !symbolIsLocal ) ||
|
||||
( acceptedKinds.containsKey( LookupKind.LOCAL_VARIABLES ) && !symbolIsMember && symbolIsLocal ) ||
|
||||
( acceptedKinds.containsKey( LookupKind.FIELDS ) && symbolIsMember ) )
|
||||
( acceptedKinds.containsKey( LookupKind.FIELDS ) && symbolIsMember ) ||
|
||||
( acceptedKinds.containsKey( LookupKind.MEMBERS ) && symbolIsMember ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_TypeRef_Prefix
|
|||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_VariableType_NestedPrefix;
|
||||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_VariableType_NoPrefix;
|
||||
import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_VariableType_Prefix;
|
||||
import org.eclipse.cdt.ui.tests.text.contentassist.ContentAssistTests;
|
||||
import org.eclipse.cdt.ui.tests.textmanipulation.TextBufferTest;
|
||||
|
||||
|
||||
|
@ -112,6 +113,7 @@ public class AutomatedSuite extends TestSuite {
|
|||
addTest(CompletionTest_TypeDef_NoPrefix.suite());
|
||||
addTest(CompletionTest_VariableType_NestedPrefix.suite());
|
||||
|
||||
addTest( ContentAssistTests.suite() );
|
||||
// Failed Tests
|
||||
addTest(CompletionFailedTest_MemberReference_Arrow_Prefix2.suite());
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class CompletionTest_FunctionReference_Prefix extends CompletionProposal
|
|||
"xFunction() bool",
|
||||
"xOtherFunction() void",
|
||||
"xNamespace",
|
||||
"xEnumeration",
|
||||
"xOtherClass",
|
||||
"xFirstEnum",
|
||||
"xSecondEnum",
|
||||
"xThirdEnum",
|
||||
|
|
|
@ -0,0 +1,196 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on Sep 9, 2004
|
||||
*/
|
||||
package org.eclipse.cdt.ui.tests.text.contentassist;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||
import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProcessor;
|
||||
import org.eclipse.cdt.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.testplugin.FileManager;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.jface.text.Document;
|
||||
import org.eclipse.jface.text.contentassist.ICompletionProposal;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class ContentAssistTests extends TestCase {
|
||||
static NullProgressMonitor monitor;
|
||||
static IWorkspace workspace;
|
||||
static IProject project;
|
||||
static FileManager fileManager;
|
||||
|
||||
{
|
||||
(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
workspace = ResourcesPlugin.getWorkspace();
|
||||
|
||||
ICProject cPrj;
|
||||
try {
|
||||
cPrj = CProjectHelper.createCCProject("ContentAssistTestProject", "bin"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
project = cPrj.getProject();
|
||||
project.setSessionProperty(IndexManager.activationKey,new Boolean(false));
|
||||
} catch ( CoreException e ) {
|
||||
/*boo*/
|
||||
}
|
||||
if (project == null)
|
||||
fail("Unable to create project"); //$NON-NLS-1$
|
||||
|
||||
//Create file manager
|
||||
fileManager = new FileManager();
|
||||
}
|
||||
public ContentAssistTests()
|
||||
{
|
||||
super();
|
||||
}
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public ContentAssistTests(String name)
|
||||
{
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite( ContentAssistTests.class );
|
||||
suite.addTest( new ContentAssistTests("cleanupProject") ); //$NON-NLS-1$
|
||||
return suite;
|
||||
}
|
||||
|
||||
public void cleanupProject() throws Exception {
|
||||
try{
|
||||
project.delete( true, false, monitor );
|
||||
project = null;
|
||||
} catch( Throwable e ){
|
||||
/*boo*/
|
||||
}
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
if( project == null || !project.exists() )
|
||||
return;
|
||||
|
||||
IResource [] members = project.members();
|
||||
for( int i = 0; i < members.length; i++ ){
|
||||
if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cdtproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
continue;
|
||||
try{
|
||||
members[i].delete( false, monitor );
|
||||
} catch( Throwable e ){
|
||||
/*boo*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected IFile importFile(String fileName, String contents ) throws Exception{
|
||||
//Obtain file handle
|
||||
IFile file = project.getProject().getFile(fileName);
|
||||
|
||||
InputStream stream = new ByteArrayInputStream( contents.getBytes() );
|
||||
//Create file input stream
|
||||
if( file.exists() )
|
||||
file.setContents( stream, false, false, monitor );
|
||||
else
|
||||
file.create( stream, false, monitor );
|
||||
|
||||
fileManager.addFile(file);
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
protected ICompletionProposal[] getResults( IFile file, int offset ) throws Exception {
|
||||
ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create( file );
|
||||
String buffer = tu.getBuffer().getContents();
|
||||
IWorkingCopy wc = null;
|
||||
try{
|
||||
wc = tu.getWorkingCopy();
|
||||
}catch (CModelException e){
|
||||
fail("Failed to get working copy"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
// call the CompletionProcessor
|
||||
CCompletionProcessor completionProcessor = new CCompletionProcessor(null);
|
||||
ICompletionProposal[] results = completionProcessor.evalProposals( new Document(buffer), offset, wc, null);
|
||||
return results;
|
||||
}
|
||||
|
||||
public void testBug69334() throws Exception {
|
||||
importFile( "test.h", "class Test{ public : Test( int ); }; \n" ); //$NON-NLS-1$//$NON-NLS-2$
|
||||
StringWriter writer = new StringWriter();
|
||||
writer.write( "#include \"test.h\" \n"); //$NON-NLS-1$
|
||||
writer.write( "Test::Test( int i ) { return; } \n"); //$NON-NLS-1$
|
||||
writer.write( "int main() { \n"); //$NON-NLS-1$
|
||||
writer.write( " int veryLongName = 1; \n"); //$NON-NLS-1$
|
||||
writer.write( " Test * ptest = new Test( very \n"); //$NON-NLS-1$
|
||||
|
||||
String code = writer.toString();
|
||||
IFile cu = importFile( "test.cpp", code ); //$NON-NLS-1$
|
||||
|
||||
ICompletionProposal [] results = getResults( cu, code.indexOf( "very " ) + 4 ); //$NON-NLS-1$
|
||||
|
||||
assertEquals( results.length, 1 );
|
||||
assertEquals( results[0].getDisplayString(), "veryLongName : int" ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testBug72824() throws Exception {
|
||||
StringWriter writer = new StringWriter();
|
||||
writer.write( "class Strategy { \n"); //$NON-NLS-1$
|
||||
writer.write( "public : \n"); //$NON-NLS-1$
|
||||
writer.write( " enum _Ability { IDIOT, NORMAL, CHEAT } ; \n"); //$NON-NLS-1$
|
||||
writer.write( " Strategy( _Ability a ) { } \n"); //$NON-NLS-1$
|
||||
writer.write( "}; \n"); //$NON-NLS-1$
|
||||
writer.write( "int main(){ \n"); //$NON-NLS-1$
|
||||
|
||||
String code = writer.toString();
|
||||
String c2 = code + " Strategy *p[3] = { new Strategy( Str \n"; //$NON-NLS-1$
|
||||
|
||||
IFile cu = importFile( "strategy.cpp", c2 ); //$NON-NLS-1$
|
||||
|
||||
ICompletionProposal [] results = getResults( cu, c2.indexOf( "Str " ) + 3 ); //$NON-NLS-1$
|
||||
assertEquals( results.length, 1 );
|
||||
assertEquals( results[0].getDisplayString(), "Strategy" ); //$NON-NLS-1$
|
||||
|
||||
c2 = code + " Strategy *p[3] = { new Strategy( Strategy:: \n"; //$NON-NLS-1$
|
||||
|
||||
cu = importFile( "strategy.cpp", c2 ); //$NON-NLS-1$
|
||||
|
||||
results = getResults( cu, c2.indexOf( "::" ) + 2 ); //$NON-NLS-1$
|
||||
assertEquals( results.length, 3 );
|
||||
assertEquals( results[0].getDisplayString(), "CHEAT" ); //$NON-NLS-1$
|
||||
assertEquals( results[1].getDisplayString(), "IDIOT" ); //$NON-NLS-1$
|
||||
assertEquals( results[2].getDisplayString(), "NORMAL" ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
|
@ -96,13 +96,10 @@ public class CompletionEngine implements RelevanceConstants {
|
|||
if (CharOperation.prefixEquals(prefix.toCharArray(), proposalName.toCharArray(), true /* do not ignore case */)) {
|
||||
if(CharOperation.equals(prefix.toCharArray(), proposalName.toCharArray(), true /* do not ignore case */)) {
|
||||
return CASE_MATCH_RELEVANCE + EXACT_NAME_MATCH_RELEVANCE;
|
||||
} else {
|
||||
return CASE_MATCH_RELEVANCE;
|
||||
}
|
||||
}
|
||||
return CASE_MATCH_RELEVANCE;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
private int computeTypeRelevance(int type){
|
||||
switch (type){
|
||||
|
@ -175,7 +172,7 @@ public class CompletionEngine implements RelevanceConstants {
|
|||
}
|
||||
catch( ParserFactoryError pfe )
|
||||
{
|
||||
|
||||
return null;
|
||||
}
|
||||
if(parser != null){
|
||||
IASTCompletionNode result = null;
|
||||
|
@ -204,9 +201,8 @@ public class CompletionEngine implements RelevanceConstants {
|
|||
elementRequestor.stopTimer();
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addNodeToCompletions(IASTNode node, String prefix, int totalNumberOfResults, boolean addStaticMethodsOnly, boolean addStaticFieldsOnly, int parameterIndex){
|
||||
|
@ -567,9 +563,9 @@ public class CompletionEngine implements RelevanceConstants {
|
|||
kinds[3] = IASTNode.LookupKind.TYPEDEFS;
|
||||
result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext(), null);
|
||||
addToCompletions(result);
|
||||
} else // prefix is empty, we can not look for everything
|
||||
} else
|
||||
{
|
||||
|
||||
//prefix is empty, we can not look for everything
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -722,51 +718,54 @@ public class CompletionEngine implements RelevanceConstants {
|
|||
completionOnTypeReference(completionNode);
|
||||
}
|
||||
|
||||
private void completionOnConstructorReference(IASTCompletionNode completionNode){
|
||||
// 1. Get the search scope node
|
||||
IASTScope searchNode = completionNode.getCompletionScope();
|
||||
if( completionNode.getFunctionName().length() > 0 &&
|
||||
completionNode.getCompletionContext() == null )
|
||||
{
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[]{ IASTNode.LookupKind.STRUCTURES };
|
||||
ILookupResult result = lookup( searchNode, completionNode.getFunctionName(), kinds, null, null );
|
||||
if( result != null && result.getResultsSize() == 1 ){
|
||||
IASTClassSpecifier cls = (IASTClassSpecifier) result.getNodes().next();
|
||||
kinds[ 0 ] = IASTNode.LookupKind.CONSTRUCTORS;
|
||||
result = lookup( searchNode, completionNode.getCompletionPrefix(), kinds, cls, completionNode.getFunctionParameters() );
|
||||
addToCompletions( result, false, false, result.getIndexOfNextParameter() );
|
||||
}
|
||||
} else {
|
||||
// only lookup constructors
|
||||
IASTNode.LookupKind[] kinds = new IASTNode.LookupKind[1];
|
||||
kinds[0] = IASTNode.LookupKind.CONSTRUCTORS;
|
||||
ILookupResult result = lookup(searchNode, completionNode.getCompletionPrefix(), kinds, completionNode.getCompletionContext(), null);
|
||||
addToCompletions(result);
|
||||
}
|
||||
}
|
||||
private void completionOnFunctionReference(IASTCompletionNode completionNode){
|
||||
//NOTE:
|
||||
// Hoda, I changed this so it makes sense with regards to your JUnit tests
|
||||
// and examples. If my assumptions are not correct as to what deserves to be
|
||||
// looked up for FUNCTION_REFRENCE then please update the documentation in
|
||||
// IASTCompletionNode.java.
|
||||
//called for both FUNCTION_REFERENCE and CONSTRUCTOR_REFERENCE
|
||||
private void completionOnFunctionReference(IASTCompletionNode completionNode, CompletionKind kind ){
|
||||
IASTNode context = completionNode.getCompletionContext();
|
||||
IASTScope scope = completionNode.getCompletionScope();
|
||||
String prefix = completionNode.getCompletionPrefix();
|
||||
boolean functionsOnly = false;
|
||||
IASTNode.LookupKind[] kinds = null;
|
||||
if( prefix.length() == 0 )
|
||||
boolean statics = false;
|
||||
|
||||
if( prefix.length() == 0 && !(context instanceof IASTClassSpecifier || context instanceof IASTNamespaceDefinition ) )
|
||||
{
|
||||
kinds = new IASTNode.LookupKind[] { IASTNode.LookupKind.CONSTRUCTORS, IASTNode.LookupKind.FUNCTIONS, IASTNode.LookupKind.METHODS };
|
||||
//completing functions: function( [CTRL+SPACE],
|
||||
//results in a list of functions we may be trying to call
|
||||
if( kind == CompletionKind.CONSTRUCTOR_REFERENCE ){
|
||||
kinds = new IASTNode.LookupKind[]{ IASTNode.LookupKind.STRUCTURES };
|
||||
ILookupResult result = lookup( scope, completionNode.getFunctionName(), kinds, null, null );
|
||||
if( result != null && result.getResultsSize() == 1 ){
|
||||
scope = (IASTScope) result.getNodes().next();
|
||||
}
|
||||
kinds[ 0 ] = IASTNode.LookupKind.CONSTRUCTORS;
|
||||
}
|
||||
else
|
||||
kinds = new IASTNode.LookupKind[] { IASTNode.LookupKind.CONSTRUCTORS, IASTNode.LookupKind.FUNCTIONS, IASTNode.LookupKind.METHODS };
|
||||
prefix = completionNode.getFunctionName();
|
||||
functionsOnly = true;
|
||||
}
|
||||
else
|
||||
kinds = new IASTNode.LookupKind[] { IASTNode.LookupKind.ALL };
|
||||
|
||||
ILookupResult result = lookup(completionNode.getCompletionScope(), prefix, kinds, completionNode.getCompletionContext(), completionNode.getFunctionParameters());
|
||||
else if( context != null )
|
||||
{
|
||||
//completing a qualified argument : function( context::prefix[CTRL+SPACE]
|
||||
kinds = new IASTNode.LookupKind[] { IASTNode.LookupKind.STRUCTURES, IASTNode.LookupKind.NAMESPACES,
|
||||
IASTNode.LookupKind.ENUMERATORS, IASTNode.LookupKind.MEMBERS };
|
||||
statics = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//completing an unqualified argument : function( prefix[CTRL+SPACE]
|
||||
kinds = new IASTNode.LookupKind[] { IASTNode.LookupKind.STRUCTURES, IASTNode.LookupKind.NAMESPACES,
|
||||
IASTNode.LookupKind.ENUMERATORS, IASTNode.LookupKind.VARIABLES,
|
||||
IASTNode.LookupKind.LOCAL_VARIABLES, IASTNode.LookupKind.MEMBERS,
|
||||
IASTNode.LookupKind.FUNCTIONS };
|
||||
}
|
||||
//note completions of the form: function( context->prefix[CTRL+SPACE] etc will come up in completionOnMemberReference
|
||||
|
||||
ILookupResult result = lookup(scope, prefix, kinds, context, completionNode.getFunctionParameters());
|
||||
if( result != null)
|
||||
addToCompletions(result, false, false, functionsOnly ? result.getIndexOfNextParameter() : -1 );
|
||||
addToCompletions(result, statics, statics, functionsOnly ? result.getIndexOfNextParameter() : -1 );
|
||||
|
||||
if( !functionsOnly ){
|
||||
if( !functionsOnly && context == null ){
|
||||
List macros = lookupMacros(completionNode.getCompletionPrefix());
|
||||
addMacrosToCompletions(prefix, macros.iterator());
|
||||
}
|
||||
|
@ -864,14 +863,14 @@ public class CompletionEngine implements RelevanceConstants {
|
|||
// completionOnNewTypeReference
|
||||
completionOnNewTypeReference(completionNode);
|
||||
}
|
||||
else if(kind == CompletionKind.FUNCTION_REFERENCE){
|
||||
else if(kind == CompletionKind.FUNCTION_REFERENCE || kind == CompletionKind.CONSTRUCTOR_REFERENCE ){
|
||||
// completionOnFunctionReference
|
||||
completionOnFunctionReference(completionNode);
|
||||
}
|
||||
else if(kind == CompletionKind.CONSTRUCTOR_REFERENCE){
|
||||
// completionOnConstructorReference
|
||||
completionOnConstructorReference(completionNode);
|
||||
completionOnFunctionReference(completionNode, kind);
|
||||
}
|
||||
// else if(kind == CompletionKind.CONSTRUCTOR_REFERENCE){
|
||||
// // completionOnConstructorReference
|
||||
// completionOnConstructorReference(completionNode, kind);
|
||||
// }
|
||||
else if(kind == CompletionKind.STRUCT_REFERENCE){
|
||||
// CompletionOnClassReference
|
||||
completionOnStructReference(completionNode);
|
||||
|
|
|
@ -24,9 +24,9 @@ public interface RelevanceConstants {
|
|||
final int UNION_TYPE_RELEVANCE = 70;
|
||||
final int TYPEDEF_TYPE_RELEVANCE = 60;
|
||||
final int NAMESPACE_TYPE_RELEVANCE = 50;
|
||||
final int MACRO_TYPE_RELEVANCE = 40;
|
||||
final int ENUMERATOR_TYPE_RELEVANCE = 40;
|
||||
final int ENUMERATION_TYPE_RELEVANCE = 30;
|
||||
final int ENUMERATOR_TYPE_RELEVANCE = 20;
|
||||
final int MACRO_TYPE_RELEVANCE = 20;
|
||||
final int KEYWORD_TYPE_RELEVANCE = 10;
|
||||
final int DEFAULT_TYPE_RELEVANCE = 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue