GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [swift] Add more swift 5.x support (#unavailable mainly) by kenji21 · Pull Request #4384 · pmd/pmd

Conversation

@kenji21

@kenji21 kenji21 commented Feb 7, 2023 •
edited by adangel
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Describe the PR

Fix a crash occurring when parsing Swift 5.6 code with #unavailable, for example, analysing this swift 5.6 new feature:

// https://github.com/apple/swift-evolution/blob/main/proposals/0290-negative-availability.md
if #unavailable(iOS 15.0) {
    // Old functionality
} else {
    // iOS 15 functionality
}

lead to a crash with this stack trace :

Encountered: token recognition error at: '#u'
	at net.sourceforge.pmd.cpd.AntlrTokenizer.tokenize(AntlrTokenizer.java:44)
	at net.sourceforge.pmd.cpd.CPD.addAndThrowLexicalError(CPD.java:144)
	at net.sourceforge.pmd.cpd.CPD.add(CPD.java:139)
	at net.sourceforge.pmd.cpd.CPD.add(CPD.java:108)
	at net.sourceforge.pmd.cpd.CPD.add(CPD.java:70)
	at net.sourceforge.pmd.cpd.CPD.addDirectory(CPD.java:80)
	at net.sourceforge.pmd.cpd.CPD.addRecursively(CPD.java:65)
	at net.sourceforge.pmd.cpd.CPDCommandLineInterface.addSourcesFilesToCPD(CPDCommandLineInterface.java:166)
	at net.sourceforge.pmd.cpd.CPDCommandLineInterface.addSourceFilesToCPD(CPDCommandLineInterface.java:146)
	at net.sourceforge.pmd.cpd.CPDCommandLineInterface.main(CPDCommandLineInterface.java:100)
	at net.sourceforge.pmd.cpd.CPD.main(CPD.java:178)
Caused by: LexerNoViableAltException('#')
	at org.antlr.v4.runtime.atn.LexerATNSimulator.failOrAccept(LexerATNSimulator.java:312)
	at org.antlr.v4.runtime.atn.LexerATNSimulator.execATN(LexerATNSimulator.java:233)
	at org.antlr.v4.runtime.atn.LexerATNSimulator.match(LexerATNSimulator.java:117)
	at org.antlr.v4.runtime.Lexer.nextToken(Lexer.java:141)
	at net.sourceforge.pmd.lang.antlr.AntlrTokenManager.getNextTokenFromAnyChannel(AntlrTokenManager.java:47)
	at net.sourceforge.pmd.lang.antlr.AntlrTokenManager.getNextToken(AntlrTokenManager.java:40)
	at net.sourceforge.pmd.cpd.token.internal.BaseTokenFilter.getNextToken(BaseTokenFilter.java:45)
	at net.sourceforge.pmd.cpd.AntlrTokenizer.tokenize(AntlrTokenizer.java:39)
	... 10 more
Feb 07, 2023 5:04:38 PM net.sourceforge.pmd.cpd.CPDCommandLineInterface main
SEVERE: An error occurred while executing CPD.

Related issues

  • [swift] Swift 5 (up to 5.2) support for CPD #2473
  • Fixes crash mentioned above

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kenji21
Add more swift 5.x support (#unavalaible mainly)
a106627
@ghost

ghost commented Feb 7, 2023

Copy link
Copy Markdown
1 Message
📖 No regression tested rules have been changed.

Generated by 🚫 Danger

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@adangel adangel added this to the 6.55.0 milestone Feb 9, 2023
@adangel adangel added the an:enhancement An improvement on existing features / rules label Feb 9, 2023
@adangel adangel changed the title Add more swift 5.x support (#unavalaible mainly) [swift] Add more swift 5.x support (#unavalaible mainly) Feb 9, 2023
@adangel adangel changed the title [swift] Add more swift 5.x support (#unavalaible mainly) [swift] Add more swift 5.x support (#unavailable mainly) Feb 9, 2023
adangel
adangel approved these changes Feb 9, 2023
View reviewed changes

@adangel adangel left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks! LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pmd-swift/src/test/resources/net/sourceforge/pmd/lang/swift/cpd/testdata/Swift5.3.swift Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-swift/src/test/resources/net/sourceforge/pmd/lang/swift/cpd/testdata/Swift5.5.swift Resolved

Uh oh!

There was an error while loading. Please reload this page.

adangel added a commit to adangel/pmd that referenced this pull request Feb 9, 2023
@adangel
Fixups from pmd#4384
ea0b8ff
adangel added a commit to adangel/pmd that referenced this pull request Feb 9, 2023
@adangel
[doc] Update release notes (pmd#4384)
300c32a
adangel added a commit to adangel/pmd that referenced this pull request Feb 9, 2023
@adangel
Merge pull request pmd#4384 from openium:master
e10cf6a
[swift] Add more swift 5.x support (#unavailable mainly) pmd#4384
@adangel
adangel merged commit a106627 into pmd:master Feb 9, 2023
@adangel adangel added in:cpd Affects the copy-paste detector in:grammar About the grammar of a lexer or parser, eg, a parse/lex exception labels Feb 9, 2023
@jsotuyod jsotuyod mentioned this pull request Apr 24, 2023
[swift] CPD #unavailable(_) breaks token parsing #4186
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@adangel adangel adangel approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

an:enhancement An improvement on existing features / rules in:cpd Affects the copy-paste detector in:grammar About the grammar of a lexer or parser, eg, a parse/lex exception

Projects

None yet

Milestone

6.55.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@kenji21 @adangel
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.