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

Running with new native parser makes all classes interfaces! #1335

Closed
mnunezdm opened this issue Apr 19, 2024 · 3 comments
Closed

Running with new native parser makes all classes interfaces! #1335

mnunezdm opened this issue Apr 19, 2024 · 3 comments

Comments

@mnunezdm
Copy link

mnunezdm commented Apr 19, 2024

Self-Troubleshooting Checklist

  • [x ] Are you running Prettier Apex >= 2.0.0? If Yes, have you gone through the Upgrade Guide?
  • [ x] Are you running Java < 11? If Yes, you need to install a newer Java version.

Describe your Issue

# Prettier options (if any):
		{
			"files": "**/*.{cls,trigger,apex}",
			"options": {
				"tabWidth": 4,
				"apexStandaloneParser": "native"
			}
		},

I have tried the experimental feature and try to format thid code

/**
 * @description       : clase para emitir eventos de cliente 360
 * @last modified on  : 19-04-2024
 **/
public with sharing class ClientEventHelper {
	private static final String CLASS_NAME = 'ClientEventHelper';
	private static final String ERROR_MESSAGE = 'Errors while inserting client 360 events';

	/**
	 * @description Different types of ids
	 */
	public enum IdType {
		gigya,
		contactId
	}

	/**
	 * @description publica un listado de eventos
	 * @param List<Event__c> events
	 **/
	public void publish(List<Event__c> events) {
		ClientEventHelper.publishEvents(events);
	}

	/**
	 * @description publica un listado de eventos
	 * @param List<Event__c> events
	 **/
	public static void publishEvents(List<Event__c> events) {
		String method = 'publishEvents';
		System.debug(
			LoggingLevel.INFO,
			CLASS_NAME + ' - ' + method + ' INICIO'
		);
		new PlatformEventHelper('aaa', CLASS_NAME)
			.publishEvents(events);
		System.debug(LoggingLevel.INFO, CLASS_NAME + ' - ' + method + ' FIN');
	}

	/**
	 * @description contruye un evento desde un cgr
	 * @param contactRequest__c cgr
	 * @return Event__c
	 **/
	public static Event__c buildByCgr(
		contactRequest__c cgr
	) {
		return new Event__c(
			id__c = cgr.Contact__c,
			idType__c = IdType.contactId.name()
		);
	}

	/**
	 * @description contruye un evento desde la tenencia
	 * @param tenencia__c tenencia
	 * @return Event__c
	 **/
	public static Event__c buildByTenencia(
		tenencia__c tenencia
	) {
		return new Event__c(
			id__c = tenencia.Contact__c,
			idType__c = IdType.contactId.name()
		);
	}
}

After running it, this was the result

/**
 * @description       : clase para emitir eventos de cliente 360
 * @last modified on  : 19-04-2024
 **/
public with sharing class ClientEventHelper {
	private static final String CLASS_NAME;
	private static final String ERROR_MESSAGE;

	/**
	 * @description Different types of ids
	 */
	public enum IdType {
		gigya,
		contactId
	}

	/**
	 * @description publica un listado de eventos
	 * @param List<Event__c> events
	 **/
	public publish(List<Event__c> events);
	/**
	 * @description publica un listado de eventos
	 * @param List<Event__c> events
	 **/
	public static publishEvents(List<Event__c> events);
	/**
	 * @description contruye un evento desde un cgr
	 * @param contactRequest cgr
	 * @return Event__c
	 **/
	public static buildByCgr(contactRequest cgr);
	/**
	 * @description contruye un evento desde la tenencia
	 * @param tenencia__c tenencia
	 * @return Event__c
	 **/
	public static buildByTenencia(tenencia__c tenencia);
}

Additional information (please fill this out):

  • OS: macos
  • Version (you can check this by running npm ls prettier-plugin-apex): [e.g. [email protected]]
AP_SALESFORCE@ /Users/miguelnunezdiaz-montes/work/AP_SALESFORCE
└── [email protected]
  • Prettier Version (you can check this by running npm ls prettier): [e.g. [email protected]]
AP_SALESFORCE@ /Users/miguelnunezdiaz-montes/work/AP_SALESFORCE
├─┬ [email protected]
│ └── [email protected] deduped
└── [email protected]
  • Java Version (you can check this by running java -version):
java -version
openjdk version "21.0.2" 2024-01-16 LTS
OpenJDK Runtime Environment Temurin-21.0.2+13 (build 21.0.2+13-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.2+13 (build 21.0.2+13-LTS, mixed mode)
@mnunezdm mnunezdm changed the title Running with new native parser makes all classes Running with new native parser makes all classes interfaces! Apr 19, 2024
@dangmai
Copy link
Owner

dangmai commented Apr 19, 2024

Thank you for trying out the experimental parser! Finally I have some real world folks who use it, so now I can debug it more easily 😅 I'll take a look at this soon and see what I can do to fix it.

@dangmai
Copy link
Owner

dangmai commented Apr 20, 2024

I've fixed this in master, the next version will contain it. Thanks again for trying this out!

Updated: v2.1.1 has been released with this fix, please try it out and let me know if you run into any more issues in the future 😇

@dangmai
Copy link
Owner

dangmai commented Oct 28, 2024

Just fyi the native parser is now the default parser in v2.2.0. I'd appreciate if you could upgrade and let me know if you run into any issues ⚡

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