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

Added Basic Java Highlighting #38

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

Added Basic Java Highlighting #38

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Feb 21, 2020

Highlights most (all?) Java keywords and comments. Most of the boilerplate code was copied from the C++ highlighter. Keywords retrieved here.

@coder3101
Copy link
Contributor

coder3101 commented Feb 21, 2020

@ouuan You might need to pull this to your QCodeEditor, It will be good to have Actual Java Syntaxhighlighting in 6.0 for us. Or maybe @tay10r could you also open this PR at https://github.com/ouuan/QCodeEditor

</root>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was by mistake, but can probably stay in the PR.

@ghost
Copy link
Author

ghost commented Feb 21, 2020

@coder3101 It looks like @ouuan has made some commits that have not been merged to upstream. I think it's best in this case for any forks to pull the changes if they want them, either from my fork or from upstream if this gets merged.

@coder3101
Copy link
Contributor

These commits add some specific features to the editor that we need in our project, which might not be needed here. If your PR was possibly showing a conflict, It would still be when he tries to pull upstream.

@ouuan will merge these changes directly because it might take more time for your PR to get merged here and even more time for us to pull upstream changes. I asked you to open a PR because there because it would have eased his job of visiting your fork to get changes!

@ghost
Copy link
Author

ghost commented Feb 21, 2020

@coder3101 I see what you're saying. If it takes more than a few days to merge this PR, I'll just start sending this and further PRs to your branch (if they're useful to what you're using it for.)

In the mean time, the feature isn't really complete anyway so you'll probably be better off waiting. There's still missing language features that haven't been added, such as annotation highlighting and Javadoc highlighting.

@ouuan
Copy link
Contributor

ouuan commented Feb 22, 2020

I forked and not send PR basically because:

  1. The upstream author seldom updates.
  2. I don't know the contribution rules, so I just ignore everything and do what I like. For example, I use the .clang-format file for CP Editor, so I don't need to change the settings when I have turned "format on save" on.

Feel free to either use my fork, merge/cherry-pick my changes, or even copy my codes without commits if there are conflicts that are hard to resolve.

ouuan added a commit to cpeditor/QCodeEditor that referenced this pull request Feb 22, 2020
@ouuan
Copy link
Contributor

ouuan commented Feb 22, 2020

I think the numbers regex should be modified? I don't know Java much, but I think it should be different from C++17.

@ghost
Copy link
Author

ghost commented Feb 22, 2020

Sure, let's adjust this for Java:

(?<=\b|\s|^)(?i)(?:(?:(?:(?:(?:\d+(?:'\d+)*)?\.(?:\d+(?:'\d+)*)(?:e[+-]?(?:\d+(?:'\d+)*))?)|(?:(?:\d+(?:'\d+)*)\.(?:e[+-]?(?:\d+(?:'\d+)*))?)|(?:(?:\d+(?:'\d+)*)(?:e[+-]?(?:\d+(?:'\d+)*)))|(?:0x(?:[0-9a-f]+(?:'[0-9a-f]+)*)?\.(?:[0-9a-f]+(?:'[0-9a-f]+)*)(?:p[+-]?(?:\d+(?:'\d+)*)))|(?:0x(?:[0-9a-f]+(?:'[0-9a-f]+)*)\.?(?:p[+-]?(?:\d+(?:'\d+)*))))[lf]?)|(?:(?:(?:[1-9]\d*(?:'\d+)*)|(?:0[0-7]*(?:'[0-7]+)*)|(?:0x[0-9a-f]+(?:'[0-9a-f]+)*)|(?:0b[01]+(?:'[01]+)*))(?:u?l{0,2}|l{0,2}u?)))(?=\b|\s|$)

All jokes aside, there's no way I'm touching that. Java supports a very similar set of a rules for numeric literals, as described here. If there's someone who is smarter with regex who can patch this, they can go ahead and give it a go. Otherwise, they're similar enough that I wouldn't care too much.

Is it binary literals? If it is, I can't really tell towards the end what part of the pattern I can remove. Feel free to suggest something.

@ouuan
Copy link
Contributor

ouuan commented Feb 22, 2020

I just couldn't find a good reference for number literals in Java, now I can work on it.

@ouuan
Copy link
Contributor

ouuan commented Feb 22, 2020

See 11f5647

@ghost
Copy link
Author

ghost commented Feb 22, 2020

@ouuan thank you that's really helpful! I'll commit that here shortly. Thanks for the help

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.

None yet

3 participants