question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sad sad panda error with nested sealed classes

See original GitHub issue

Prettier-Java 1.6.0

I have a class that contains a static sealed class and its static subclasses. When I try to format it, I get a Sad sad panda error.

# .prettierrc:
tabWidth: 4
printWidth: 100
trailingComma: "none"

Input:

package nl.jqno.equalsverifier.integration.extended_contract;

public class SealedClasses {
    public static sealed abstract class SealedParent permits SealedChild {}

    final static class SealedChild extends SealedParent {}
}

Output:

unchanged, but got this error:

└─❯ prettier SealedClasses.java
SealedClasses.java[error] SealedClasses.java: Error: Sad sad panda, parsing errors detected in line: 4, column: 12!
[error] Expecting token of type --> Identifier <-- but found --> 'static' <--!
[error] 	->compilationUnit
[error] 	->ordinaryCompilationUnit
[error] 	->typeDeclaration
[error] 	->classDeclaration
[error] 	->normalClassDeclaration
[error] 	->classBody
[error] 	->classBodyDeclaration
[error] 	->constructorDeclaration
[error] 	->constructorDeclarator
[error] 	->simpleTypeName
[error]     at Object.parse (/home/jqno/.npm-global/lib/node_modules/prettier-plugin-java/node_modules/java-parser/src/index.js:41:11)
[error]     at Object.parse (/home/jqno/.npm-global/lib/node_modules/prettier-plugin-java/src/parser.js:6:26)
[error]     at Object.parse$a [as parse] (/home/jqno/.npm-global/lib/node_modules/prettier/index.js:13684:19)
[error]     at coreFormat (/home/jqno/.npm-global/lib/node_modules/prettier/index.js:15215:16)
[error]     at formatWithCursor$1 (/home/jqno/.npm-global/lib/node_modules/prettier/index.js:15455:14)
[error]     at Object.formatWithCursor (/home/jqno/.npm-global/lib/node_modules/prettier/index.js:60228:12)
[error]     at format$1 (/home/jqno/.npm-global/lib/node_modules/prettier/bin-prettier.js:16827:21)
[error]     at Object.formatFiles$1 [as formatFiles] (/home/jqno/.npm-global/lib/node_modules/prettier/bin-prettier.js:16941:16)
[error]     at async main (/home/jqno/.npm-global/lib/node_modules/prettier/bin-prettier.js:18802:5)
[error]     at async Object.run (/home/jqno/.npm-global/lib/node_modules/prettier/bin-prettier.js:18745:5)

Expected behavior:

No error and properly formatted file

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jqnocommented, Jan 6, 2022

Confirmed, it works! Thanks for the quick turnaround!

0reactions
pascalgrimaudcommented, Jan 10, 2022

@clementdessoude : approved

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support for nested sealed classes? · Issue #117 - GitHub
Hi, I'm trying to migrate to moshi.sealed but this I'm not sure if is supported @JsonClass(generateAdapter = true, ...
Read more >
Accessing the nested level of sealed class in android kotlin
I call the sealed class sendTheEventEvent(MyEvents.HelloBroadcasting.FeatureSegments.SegmentationChapterNameClicked(mContext,it.
Read more >
News Altona Gnk - Gentle Monster
C# base class for an anonymous type, Dreitagebart model, Kmjk computrabajo, ... Serum tryptase angioedema, Sell non op car, Vladimir bogdanovic novi sad, ......
Read more >
D'oh!! There is no copy method for Sealed Classes in Kotlin!
A few weeks ago we looked at one of my pain points of working with Kotlin Data Classes: nested copy and we improved...
Read more >
A base class for custom WPF binding markup extensions
And failed because BindingBase.ProvideValue is sealed? Me too… The result is a MarkupExtension that works around the issue that you cannot ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found