Bug 546857 - [code mining] skip parameter names for library method with no source information
Summary: [code mining] skip parameter names for library method with no source information
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.12   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday, helpwanted
Depends on:
Blocks:
 
Reported: 2019-04-30 07:33 EDT by Gayan Perera CLA
Modified: 2019-09-20 17:46 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gayan Perera CLA 2019-04-30 07:33:00 EDT
When working with libraries which don't have source code attached, the parameter names are shown as arg0...arg(n). This is because the default parameter name strategy in JDT is to look and the variable name and parameter name.

IMO we should not show arg0 arg1 since that doesn't give any value. So its better to remove them from showing up as parameter info mining.
Comment 1 Mickael Istria CLA 2019-06-20 03:26:56 EDT
@Gayan: I like your proposal. Maybe you could submit a patch for it. ParameterNamesCodeMiningTest is where you can write (and run) automated tests for it, and CalleeJavaMethodParameterVisitor.skipParameterNamesCodeMinings() is where you can add some extra conditions to skip parameters.
Comment 2 Gayan Perera CLA 2019-08-16 12:46:20 EDT
@Mickael i'm trying to write a test case for this scenario where the parameter info is not available. How could i achieve this ? Should i create a new test class with a new project setup base on a sample compiled class in the classpath which doesn't have parameter info and refer in the CU under testing ? Or do i have more better option to do this ?
Comment 3 Mickael Istria CLA 2019-08-17 04:18:15 EDT
(In reply to Gayan Perera from comment #2)
> @Mickael i'm trying to write a test case for this scenario where the
> parameter info is not available. How could i achieve this ? Should i create
> a new test class with a new project setup base on a sample compiled class in
> the classpath which doesn't have parameter info and refer in the CU under
> testing ? Or do i have more better option to do this ?

See ParameterNamesCodeMiningTest.testVarargs for a simple example.
For this specific case, I suggest you just:
1. add a dummy class in org.eclipse.jdt.text.tests, in same package as the test code
2. In the test code, extract this class into a temporary folder (with the right hierarchy of parents folders/packages)
3. add this folder as a classpath entry to the test project
4. Then you should be able to reference the method from this type, without the source information and see the argN to finalize the test case.