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

Old error while running with JDK 17 and plugin@2.2.2 #1809

Open
1 of 2 tasks
Alfystar opened this issue Jan 20, 2025 · 6 comments
Open
1 of 2 tasks

Old error while running with JDK 17 and plugin@2.2.2 #1809

Alfystar opened this issue Jan 20, 2025 · 6 comments

Comments

@Alfystar
Copy link

Alfystar commented Jan 20, 2025

Self-Troubleshooting Checklist

  • Are you running Prettier Apex >= 2.0.0? If Yes, have you gone through the Upgrade Guide?
  • Are you running VSCode and recently upgraded Prettier or Prettier Apex? If Yes, have you restarted VSCode after the upgrade?

Describe your issue

Hi, I am running your plugin from bash on a bamboo pipeline.

I ran into an error due to the java version being too old (JDK 11) and we updated the agent to openJDK 17.

Now the error has changed and I get this:

>> [error] src/main/default/classes/ITA_IFM_UTL045_GestioneAttivitaGC.cls: Error: {"apex.jorje.semantic.compiler.parser.ParserOutput": {"internalErrors": [],"parseErrors": [],"unit": {"@class": "apex.jorje.data.ast.CompilationUnit$ClassDeclUnit","body": {"@class": "apex.jorje.data.ast.ClassDecl","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 1191,"endIndex": 45770,"line": 22,"...

Searching online I found an error similar to the issue: #490

My system configuration on the agent is:

- Node tool version:
  ├── @prettier/plugin-xml@3.4.1
  ├── prettier-plugin-apex@2.2.2
  ├── prettier@3.4.2
  └── sfdx-plugin-source-read@1.4.1
- Java version:
  ├── openjdk version "17.0.2" 2022-01-18
  ├── OpenJDK Runtime Environment (build 17.0.2+8-86)
  ├── OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)

Could you please help us understand if this is the problem?

Thanks a lot in advance

Prettier options (if any)

System Info

npmPackages:
    @prettier-apex/apex-ast-serializer-darwin-arm64:  2.2.2 
    @prettier/plugin-xml: ^3.4.1 => 3.4.1 
    prettier: ^3.4.2 => 3.4.2 
    prettier-plugin-apex: ^2.2.2 => 2.2.2
@dangmai
Copy link
Owner

dangmai commented Jan 20, 2025

Hi there, do you mind posting the full error? It's currently cut off so I can't troubleshoot effectively.

A few points I'd like to point out to help you self-troubleshoot:

  • Your version of Prettier Apex doesn't need Java if you're running it with no custom options - this is the default behavior starting with Prettier Apex 2.2.0
  • Does this happen to only one file, or to every file? If it happens to only one file, could you double check that that file is actually syntactically correct?

@Alfystar
Copy link
Author

Alfystar commented Jan 21, 2025

Hi @dangmai

About the error, yes of course, i send only the first part because is really long:

[error] src/main/default/classes/ITA_IFM_UTL045_GestioneAttivitaGC.cls: Error: {"apex.jorje.semantic.compiler.parser.ParserOutput": {"internalErrors": [],"parseErrors": [],"unit": {"@class": "apex.jorje.data.ast.CompilationUnit$ClassDeclUnit","body": {"@class": "apex.jorje.data.ast.ClassDecl","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 1191,"endIndex": 45770,"line": 22,"column": 22},"modifiers": [{"@class": "apex.jorje.data.ast.Modifier$GlobalModifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 1171,"endIndex": 1177,"line": 22,"column": 2}},{"@class": "apex.jorje.data.ast.Modifier$WithSharingModifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 1178,"endIndex": 1190,"line": 22,"column": 9}}],"name": {"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 1197,"endIndex": 1230,"line": 22,"column": 28},"value": "ITA_IFM_UTL045_GestioneAttivitaGC"},"typeArguments": {},"members": [{"@class": "apex.jorje.data.ast.BlockMember$FieldMember","variableDecls": {"@class": "apex.jorje.data.ast.VariableDecls","modifiers": [{"@class": "apex.jorje.data.ast.Modifier$PublicModifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 1234,"endIndex": 1240,"line": 23,"column": 2}},{"@class": "apex.jorje.data.ast.Modifier$StaticModifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 1241,"endIndex": 1247,"line": 23,"column": 9}}],"type": {"@class": "apex.jorje.data.ast.TypeRefs$ClassTypeRef","names": [{"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 1248,"endIndex": 1250,"line": 23,"column": 16},"value": "Id"}],"typeArguments": []},"decls": [{"@class": "apex.jorje.data.ast.VariableDecl","name": {"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 1251,"endIndex": 1267,"line": 23,"column": 19},"value": "useridBarraAtlas"},"assignment": {}}]}},{"@class": "apex.jorje.data.ast.BlockMember$Fi
 ...

To see all, go to the link: https://ctxt.io/2/AAB4XrYnFg (Save before expired, in 1 Day pls) [It was too long to share here in comment box]

About the second question, to run the pretiter i use:

sed "s/^/'/;s/$/'/" < "$PRETTIER_ARTIFACT_FOLDER/$DETECT_FILE_OUT" | xargs npx prettier --write 2> >(tee "$PRETTIER_ERROR_LOG" | prepend " >> " >&2)

# After the translation should be like:
npx prettier --write <resourcePath_1>
npx prettier --write <resourcePath_2>
npx prettier --write <resourcePath_3>
...

# This is an example output:
>> Start prettify...
src/main/default/classes/ITA_IFM_RefuseHandler_RVC_Test.cls 179ms (unchanged)
src/main/default/classes/ITA_IFM_UTIL_IvaCimp_Test.cls 226ms (unchanged)
src/main/default/classes/ITA_IFM_MS008_EngineDocumentale.cls 297ms (unchanged)
src/main/default/lwc/ita_ifm_lwc071_supply_use_change_comm_ele/ita_ifm_lwc071_supply_use_change_comm_ele.js 191ms
src/main/default/classes/ITA_IFM_SCH510_OnCondition.cls 74ms (unchanged)
src/main/default/classes/ITA_IFM_VFC452_IncomingFlow.cls 111ms (unchanged)
...

In my case the problem comes out only with one Apex Class, but when i try to execute prettier in local, it work!
An is for that reason i think the problem are in java.

The class with the problem, look good, is possible deploy it inside the org and work, so... i honestly don't know

to finish this is my .prettierc if can help:

{
	"plugins": ["prettier-plugin-apex", "@prettier/plugin-xml"],
	"printWidth": 600,
	"singleQuote": true,
	"trailingComma": "all",
	"bracketSpacing": false,
	"useTabs": true,
	"bracketSameLine": true,
	"apexInsertFinalNewline": false,
	"overrides": [
		{
			"files": "*.{trigger,cls}",
			"options": {"parser": "apex"}
		},
		{
			"files": "*.{apex}",
			"options": {"parser": "apex-anonymous"}
		},
		{
			"files": "**/lwc/**/*.html",
			"options": {"parser": "lwc"}
		},
		{
			"files": "*.{cmp,page,component,evt}",
			"options": {
				"parser": "html",
				"trailingComma": "none"
			}
		},
		{
			"files": "**/aura/**/*.js",
			"options": {"trailingComma": "none"}
		},
		{
			"files": "**/aura/**/*.{auradoc,design,app}",
			"options": {"parser": "angular"}
		},
		{
			"files": "**/*.xml",
			"options": {
				"parser": "xml",
				"useTabs": false,
				"tabWidth": 4,
				"xmlWhitespaceSensitivity": "preserve",
				"embeddedLanguageFormatting": "off",
				"xmlSelfClosingSpace": false
			}
		}
	]
}

@dangmai
Copy link
Owner

dangmai commented Jan 21, 2025

I see, thank you for the detailed description! I believe it's a bug that I was trying to track down in another ticket. If possible, could you send me the source code of the file that fails to contact at dangmai.net? I've been trying to find reproducible case for this problem to no avail, so it'd help me a ton. Thank you!

@Alfystar
Copy link
Author

Hi @dangmai 😁,

I have sent you an email with the source files that are causing issues. Could you please confirm if you have received it? I want to make sure I didn't send it to the wrong address.

Thanks!

@dangmai
Copy link
Owner

dangmai commented Jan 22, 2025

I've got it, thank you! I'm currently on vacation, so I'll try to look at it when I get back. Thank you again for helping troubleshooting this issue!

@Alfystar
Copy link
Author

Enjoy your vacation then!
We will wait without any problems 😊

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

No branches or pull requests

2 participants