Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Variable definition error with class name starting with underscore or lowercase letter #174

@felixhao28

Description

@felixhao28

Prerequisites

Description

If the class name starts with underscore, the tokenizing of the whole line of variable definition breaks.

public class A {
    public void drop() {
        BaseActionController actionController = new _BaseActionController();
        _BaseActionController actionController = new _BaseActionController();
        BaseActionController actionController = new BaseActionController();
    }
}

image

Steps to Reproduce

  1. Open new tab and select Java language.
  2. Paste code into the editor.

Expected behavior: [What you expect to happen]

_BaseActionController gets treated equally like BaseActionController.

Actual behavior: [What actually happens]

The whole line is not tokenized.

Reproduces how often: [What percentage of the time does it reproduce?]

Versions

You can get this information from copy and pasting the output of atom --version and apm --version from the command line. Also, please include the OS and what version of the OS you're running.

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

Activity

felixhao28

felixhao28 commented on Nov 23, 2018

@felixhao28
Author

Same happens if the class name starts with a lower case character. And the behavior differs a little bit depending on whether the class is fully consisted of lower case characters.

signPdf sign = new signPdf(userinfor.getUserMail(), userinfor.getUserId(), file, fileSign);
signpdf sign = new signPdf(userinfor.getUserMail(), userinfor.getUserId(), file, fileSign);
SignPdf sign = new signPdf(userinfor.getUserMail(), userinfor.getUserId(), file, fileSign);
sadikovi

sadikovi commented on Nov 23, 2018

@sadikovi
Contributor

That is interesting. We might need to extend pattern to handle these characters. Thanks! I will have a look.

self-assigned this
on Nov 23, 2018
rsese

rsese commented on Jun 27, 2019

@rsese

Same happens if the class name starts with a lower case character.

This was mentioned on the message board recently:

https://discuss.atom.io/t/java-syntax-highlighting-for-lowercase-object-variable-names/66322

Their example:

public class Test {
  public static void main(String[] args) {
    for (int i = 0; i < 10; i++) {
      System.out.println(i);
    }

    someObjectType tcObj = null;

    for (int i = 0; i < 10; i++) {
      System.out.println(i);
    }
  }
}

And screenshot:

(See someObjectType).

changed the title [-]Variable definition error with class name starting with underscore[/-] [+]Variable definition error with class name starting with underscore or lowercase letter[/+] on Jun 27, 2019
sadikovi

sadikovi commented on Jun 27, 2019

@sadikovi
Contributor

@rsese this issue does not exist tree-sitter, along with other stuff like generics, variables, multiline methods, etc. that we struggle to fix properly with regex.

I already use experimental tree-sitter when working with Java; and I am trying to merge my PR as soon as possible to get that into Atom release.

Thanks for letting me know!
We can still patch this in TextMate grammar. I will take a look this weekend if it is okay (a bit snowed under with some other stuff at work), or can do tonight, if it is urgent. Let me know!

felixhao28

felixhao28 commented on Jun 27, 2019

@felixhao28
Author

What is tree-sitter?

calebmeyer

calebmeyer commented on Jun 27, 2019

@calebmeyer

Text-mate is where the original syntax highlighting for Atom (and sublime, and I believe VS Code) comes from. It's a whole bunch of regexes with some smarts layered on top so they can do more than a single regex could.

Tree sitter is a new parser generator tool that creates much more correct (and often faster!) parsers using syntax trees: http://tree-sitter.github.io/tree-sitter/

mckinleyrebecca

mckinleyrebecca commented on Jun 27, 2019

@mckinleyrebecca

@sadikovi I made the post on the message board about the lowercase object types. This issue is not urgent, but thank you for looking into it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @rsese@felixhao28@calebmeyer@sadikovi@mckinleyrebecca

      Issue actions

        Variable definition error with class name starting with underscore or lowercase letter · Issue #174 · atom/language-java