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

bug: should reject invalid names according to the Java specification #2237

Closed
danglotb opened this issue Jul 17, 2018 · 2 comments · Fixed by #3189
Closed

bug: should reject invalid names according to the Java specification #2237

danglotb opened this issue Jul 17, 2018 · 2 comments · Fixed by #3189

Comments

@danglotb
Copy link
Member

danglotb commented Jul 17, 2018

Hi all.

I am opening this thread to discuss the possibility of checking the name against the specification names.

Currently in Spoon, I can do the following:

CtVariableReference reference = factory.createLocalVariableReference().setSimpleName("tacos.EatIt()")
factory.createVariableRead(reference, false);

This can lead to an inconsistency of the spoon model because the invocation is represented by a local variable.

What can be done, is a check on the provided name, using a regex.

WDYT?

EDIT: I fixed the snippet since it was incorrect. However, the discussion remains the same and open.

@pvojtechovsky
Copy link
Collaborator

Do you mean that Spoon should allow only reference and element names, which can be java identifier?
I like this idea. 👍

@surli
Copy link
Collaborator

surli commented Jul 17, 2018

I think we can easily enforce the usage of identifier as defined in the JLS through regexp in our different factories. I can take this one.

@monperrus monperrus changed the title Check name against specification names bug: should reject invalid names according to the Java specification Nov 12, 2019
MartinWitt added a commit to MartinWitt/spoon that referenced this issue Dec 9, 2019
MartinWitt added a commit to MartinWitt/spoon that referenced this issue Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants