Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add quickfix for non accessible references #440

Closed
fbricon opened this issue Nov 17, 2017 · 4 comments · Fixed by #1172
Closed

Add quickfix for non accessible references #440

fbricon opened this issue Nov 17, 2017 · 4 comments · Fixed by #1172

Comments

@fbricon
Copy link
Contributor

fbricon commented Nov 17, 2017

Handle the following cases in QuickFixProcessor:

case IProblem.StaticMethodRequested:
case IProblem.NonStaticFieldFromStaticInvocation:
case IProblem.InstanceMethodDuringConstructorInvocation:
case IProblem.InstanceFieldDuringConstructorInvocation:
    ModifierCorrectionSubProcessor.addNonAccessibleReferenceProposal(context, problem, proposals, 
    ModifierCorrectionSubProcessor.TO_STATIC, IProposalRelevance.CHANGE_MODIFIER_TO_STATIC);
@fbricon
Copy link
Contributor Author

fbricon commented Sep 6, 2019

@NikolasKomonen can you investigate if this one is doable, or if it requires jdt.ui -> jdt.core refactoring?

NikolasKomonen added a commit to NikolasKomonen/eclipse.jdt.ls that referenced this issue Sep 9, 2019
@NikolasKomonen
Copy link
Contributor

NikolasKomonen commented Sep 9, 2019

@fbricon No refactoring was needed, I wasn't able to figure out how to trigger the quick fixes for:

case IProblem.InstanceMethodDuringConstructorInvocation:
case IProblem.InstanceFieldDuringConstructorInvocation:

but the other 2 work, and are tested.

@fbricon
Copy link
Contributor Author

fbricon commented Sep 9, 2019

@snjeza any pointers for the 2 missing cases? Is it related to enabling some more warnings?

@fbricon fbricon added this to the Mid September 2019 milestone Sep 9, 2019
@snjeza
Copy link
Contributor

snjeza commented Sep 9, 2019

case IProblem.InstanceMethodDuringConstructorInvocation:
case IProblem.InstanceFieldDuringConstructorInvocation:

@NikolasKomonen you can try the following:

public class Test {
	int i;
	Test () {
		this(i);
	}
	Test (int x) {
	}
	Test (long x) {
	    this(test());
	}

	int test() {
		return 0;
	}
}

Both quick fixes work. You need to create tests.

NikolasKomonen added a commit to NikolasKomonen/eclipse.jdt.ls that referenced this issue Sep 13, 2019
fbricon pushed a commit that referenced this issue Sep 16, 2019
NikolasKomonen added a commit to NikolasKomonen/eclipse.jdt.ls that referenced this issue Sep 20, 2019
fbricon pushed a commit that referenced this issue Sep 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants