Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Different bahaviour of code completion in Junit and in editor of JDT codeAssist
Different bahaviour of code completion in Junit and in editor of JDT codeAssist [message #1759434] Tue, 11 April 2017 16:31 Go to next message
bhuvan gupta is currently offline bhuvan guptaFriend
Messages: 1
Registered: April 2017
Junior Member
I am playing with the junit test case of JDT
org.eclipse.jdt.core.tests.model.CompletionTests18


String x = "import java.util.Map;" +
		"public class X { \n"      +
		"public void main() {\n"   +		
		"Map"+		
	"} \n"+
"}\n";

public void test002() throws JavaModelException {
	this.workingCopies = new ICompilationUnit[1];
	long t = System.currentTimeMillis();
	
	this.workingCopies[0] = getWorkingCopy(
			"/Completion/src/X.java",x);
	boolean ignoreAll = false;
	boolean showModifiers = true;
	boolean showTokenPositions = true;
	boolean showMissingTypes = true;
	boolean shortContext = true;
	boolean showPositions = true;
	boolean showUniqueKeys = true;
	boolean showParamNames = true;
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(ignoreAll,
			showParamNames,showUniqueKeys,showPositions, 
			shortContext, showMissingTypes,showTokenPositions, 
			showModifiers);
	requestor.allowAllRequiredProposals();
	String str = this.workingCopies[0].getSource();
	
	String completeBehind = "Map";
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
	System.out.println("Proposals ans:" + requestor.getResults());


The result i get for Map is

Map[TYPE_REF]{Map, java.util, Ljava.util.Map;, null, null, null(PARAMERNTER NAME), null, replace[124, 127], token[124, 127], public abstract, 56}


Note that the completion text is Map

Now if i try in editor it completes to Map<K, V>

Question 1 : How is editor getting this extra info <K,V>?

-------------------------------------------------------------

Also if i check in editor the suggestion for map[dot] it give get(Object key) where as in junit test i get the information that the argument is Object but i dont find information that it variable name is key

Question 2: where does this info comes from?

[Updated on: Wed, 12 April 2017 12:51]

Report message to a moderator

Re: Different bahaviour of code completion in Junit and in editor of JDT codeAssist [message #1759588 is a reply to message #1759434] Thu, 13 April 2017 13:31 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
As you are already looking at JDT code, I believe the answer to your Question1 to be in or around org.eclipse.jdt.internal.codeassist.CompletionEngine.createTypeProposal(ReferenceBinding, char[], int, char[], int, Binding[], int[], int[], boolean)

Regarding the type arguments, e.g., look at
			proposal.setDeclarationSignature(refBinding.qualifiedPackageName());
			proposal.setSignature(getCompletedTypeSignature(refBinding));
Re: Different bahaviour of code completion in Junit and in editor of JDT codeAssist [message #1759589 is a reply to message #1759588] Thu, 13 April 2017 13:38 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
For question 2 see org.eclipse.jdt.internal.codeassist.CompletionEngine.findMethodParameterNames(MethodBinding, char[][])
Previous Topic:Assignments coloring
Next Topic:Content assist extension point in JDT core?
Goto Forum:
  


Current Time: Tue Apr 16 11:55:05 GMT 2024

Powered by FUDForum. Page generated in 0.09341 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top