Skip to content

[scala] Fix scala text bounds#2021

Merged
jsotuyod merged 6 commits into
pmd:masterfrom
oowekyala:scala-cleanups
Sep 17, 2019
Merged

[scala] Fix scala text bounds#2021
jsotuyod merged 6 commits into
pmd:masterfrom
oowekyala:scala-cleanups

Conversation

@oowekyala

@oowekyala oowekyala commented Sep 17, 2019

Copy link
Copy Markdown
Member

While working on pmd/pmd-designer#26 I noticed the text coordinates for scala nodes were off by one. This is because PMD's end column is inclusive. This is undesirable for many reasons but we're stuck with it until 7.0.0. For example, with inclusive column bound, it's impossible to represent an empty region without making the end column strictly smaller than the start column, which is very weird. For example, a zero-length node at the very beginning of a line has (start,end)-columns (1,0).

The Scala AST has a lot of zero-length nodes, because they're implicit, so I added an isImplicit method to ScalaNode.

Apex also has implicit nodes, but the Jorje parser doesn't use empty text regions for those (since its tree is "semantic", it doesn't reflect correctly the source file...). An apex version of isImplicit could be written as Locations.isReal(node.getLoc()).

This PR also contains some cleanups for the scala parser.

Also, Scala node constructors are public, which we should restrict. I think that is appropriate for 6.19.0.

@oowekyala oowekyala added this to the 6.19.0 milestone Sep 17, 2019
@ghost

ghost commented Sep 17, 2019

Copy link
Copy Markdown
1 Message
📖 This changeset introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report

Generated by 🚫 Danger

}

@Override
public void testingOnlySetEndLine(int i) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we need to get rid of these methods from the interface for 7.0.0 -_-

@jsotuyod jsotuyod merged commit 691f01d into pmd:master Sep 17, 2019
@oowekyala oowekyala deleted the scala-cleanups branch September 17, 2019 21:01
oowekyala added a commit that referenced this pull request Sep 18, 2019
oowekyala added a commit to oowekyala/pmd that referenced this pull request Jan 28, 2020
Javacc nodes now use this convention,
and since this PR updates the test
module to take implicit nodes into
account, the scala module needs to
be ported too.

Refs pmd#2021
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.

2 participants