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

[NETBEANS-791] Highlights for the top line of JavaDoc are done on every line. #550

Merged
merged 4 commits into from Jul 17, 2018

Conversation

junichi11
Copy link
Member

@junichi11 junichi11 requested a review from sdedic May 16, 2018 11:49
@@ -55,21 +57,26 @@
public class Highlighting extends AbstractHighlightsContainer implements TokenHierarchyListener {

private static final Logger LOG = Logger.getLogger(Highlighting.class.getName());

private static final String WS = " \t\n"; // NOI18N
private static final String JAPANESE_PERIOD = "。"; // NOI18N
Copy link
Member

Choose a reason for hiding this comment

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

If the character does not fall into ANSI/ISO-8859-1 charset, better encode it as unicode escape in the java source.

Copy link
Member Author

Choose a reason for hiding this comment

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

Instead of "。", use "\u3002" i.e. private static final String JAPANESE_PERIOD = "\u3002"; Is this OK?

Copy link
Member

Choose a reason for hiding this comment

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

sure

String period = null;
int indexOfPeriod = -1;
for (String p : PERIODS) {
int index = TokenUtilities.indexOf(seq.token().text(), p);
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be more appropriate if Javadoc lexer returned some specific tokenID japanese period char (and ordinary period char), since the period after the 1st sentence is a lexical element. But I fear that a new token ID could break existing lexer clients.

Copy link
Member Author

Choose a reason for hiding this comment

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

I fear that a new token ID could break existing lexer clients.

Me, too...

Copy link
Member Author

Choose a reason for hiding this comment

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

@sdedic So, I would like to avoid changing the JavadocLexer(java.lexer) because a new tokenID(e.g. JavadocTokenId.JAPANESE_DOT) is needed only for this feature at the moment. Even if someone adds the new tokenID, probably, we can notice that because I added unit tests to this feature.

However, if you prefer adding the tokenID, I'll try it :)

if (seq.token().id() == JavadocTokenId.DOT) {
if (seq.moveNext()) {
if (isWhiteSpace(seq.token())) {
return new int [] { start, seq.offset()};
}
seq.movePrevious();
}
} else if (period != null && indexOfPeriod != -1) {
// NETBEANS-791
int offset = TokenUtilities.indexOf(seq.token().text(), period) + 1;
Copy link
Member

Choose a reason for hiding this comment

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

Isn't TokenUtilities.indexOf(seq.token().text(), period) the same value as indexOfPeriod ?

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right. Thank you for catching it.

@junichi11
Copy link
Member Author

@sdedic Should I add the tokenID? or Can I merge this?

@jlahoda
Copy link
Contributor

jlahoda commented Jun 29, 2018 via email

@sdedic
Copy link
Member

sdedic commented Jun 29, 2018

Possibly. But DOT is used inside tags, as qname part delimiter (IDENT DOT IDENT HASH IDENT). If japanese dot char becomes DOT, then {@link org<japanesedot>netbeans ...) will be interpreted as qname.

@junichi11
Copy link
Member Author

I'm not sure where impact area of that change is because I'm not an expert of Java area...

@junichi11
Copy link
Member Author

My Proposal:

  1. Merge this PR
  2. Create a new issue for improving this in the JIRA

That way, someone other than me also may be able to work on it. I suppose that the person can do it even if the person doesn't know the Japanese language because I added test cases for it.

@sdedic @jlahoda What do you think?

@sdedic
Copy link
Member

sdedic commented Jul 17, 2018

@junichi11 OK, let's do gradual improvements.

@junichi11
Copy link
Member Author

@sdedic Thank you! Will merge this.
I've created a new issue: https://issues.apache.org/jira/browse/NETBEANS-1053

@junichi11 junichi11 merged commit 5de5478 into apache:master Jul 17, 2018
@junichi11 junichi11 deleted the netbeans-791 branch July 18, 2018 00:26
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