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

Do not allow snippets of type method or field before a class statement #476

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

turkeylurkey
Copy link

The issue is that rest_get and mpirc snippets are provided as suggestions when the user's cursor is between the package statement and the class statement. This is incorrect and it is easy for a person to stumble across.

This fix helps with this problem but it means these two snippets do not appear when the cursor is just before an enum or an inner class statement. This seems like an improvement.

Is this change acceptable?

Fixes #402

@angelozerr
Copy link
Contributor

I understand it is an annoying problem but we need to see if in JDT with vscode microprofile we have the same problem.

@datho7561 what do you think about this change?

@angelozerr
Copy link
Contributor

angelozerr commented Nov 5, 2024

I will test also in IJ Quarkus if we have the same problem and if we can do something on IJ side.

@datho7561
Copy link
Contributor

This issue with this change is this case:

package com.github.datho7561;

/**
 * My documentation
 */
public class MyObject {

	public int getValue() {
		return 12;
	}

	|

	static public class MyInnerClass {

	}
}

The snippet mpirc (for creating a rest client) should be available here, but it isn't. Having a descriptor BEFORE_CLASS is useful for annotations that can only be applied to classes (and interfaces and records and such). However, in order to properly handle completion, we need to distinguish between BEFORE_INNER_CLASS and BEFORE_TOP_LEVEL_CLASS. Currently, in the JDT code, there are two locations where we return BEFORE_CLASS; one of them should be changed to BEFORE_TOP_LEVEL_CLASS and the other to BEFORE_INNER_CLASS. Then we can use this more specific information to better inform snippet completion results.

@angelozerr
Copy link
Contributor

angelozerr commented Nov 5, 2024

Thanks @datho7561 for your relevant information. IJ need to improve this usecase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid snippet suggested in completion before the Class statement [context]
3 participants