Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 358131 - [M2x IDE Integration] Make Xtend/Xpand/CheckJobs more robust against template file encoding mismatches
Summary: [M2x IDE Integration] Make Xtend/Xpand/CheckJobs more robust against template...
Status: CLOSED FIXED
Alias: None
Product: Sphinx
Classification: Automotive
Component: Core (show other bugs)
Version: 0.7.0   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 0.7.0   Edit
Assignee: Stephan Eberle CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-19 11:20 EDT by Stephan Eberle CLA
Modified: 2021-07-14 02:16 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Eberle CLA 2011-09-19 11:20:41 EDT
= Problem description =
Currently, Xtend/Xpand/CheckJob don't make any assumptions about the encoding of the Xtend/Xpand/Check files they have to process. They just create and let the respective execution contexts use an instance of org.eclipse.xtend.expression.ResourceManagerDefaultImpl which in turn attempts to detect the encoding of Xtend/Xpand/Check files using org.eclipse.internal.xtend.util.internal.icu.CharsetDetector.CharsetDetector() and other things. The problem is, that this doesn't work out well for Eclipse workspace files all the time. It occasionally causes Xtend/Xpand/Check files to be loaded with inappropriate encoding information and exceptions like this

org.eclipse.internal.xtend.xtend.parser.ParseException: no viable alternative at input 'Â' on line 15
	at org.eclipse.internal.xpand2.parser.XpandParseFacade$3.handleError(XpandParseFacade.java:77)
	at org.eclipse.internal.xpand2.parser.XpandParseFacade$2.reportError(XpandParseFacade.java:66)
	at org.eclipse.internal.xpand2.parser.XpandParser.template(XpandParser.java:371)
	at org.eclipse.internal.xpand2.parser.XpandLocationAddingParser.template(XpandLocationAddingParser.java:289)
	at org.eclipse.internal.xpand2.parser.XpandParseFacade.file(XpandParseFacade.java:44)
	at org.eclipse.internal.xpand2.parser.XpandParseFacade.file(XpandParseFacade.java:31)
	at org.eclipse.xpand2.XpandExecutionContextImpl$1.parse(XpandExecutionContextImpl.java:174)
	at org.eclipse.xtend.expression.ResourceManagerDefaultImpl.loadResource(ResourceManagerDefaultImpl.java:70)
	at org.eclipse.xpand2.XpandExecutionContextImpl.findTemplate(XpandExecutionContextImpl.java:277)
	at org.eclipse.xpand2.XpandExecutionContextImpl.findTemplate(XpandExecutionContextImpl.java:270)
	at org.eclipse.xpand2.XpandExecutionContextImpl.findDefinition(XpandExecutionContextImpl.java:227)
	at org.eclipse.xpand2.XpandFacade.evaluate2(XpandFacade.java:57)
	at org.eclipse.xpand2.XpandFacade.evaluate(XpandFacade.java:43)
	at org.eclipse.sphinx.xtendxpand.jobs.XpandJob$1.run(XpandJob.java:352)
	at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
	at org.eclipse.sphinx.xtendxpand.jobs.XpandJob.runInWorkspace(XpandJob.java:358)
	at org.eclipse.sphinx.xtendxpand.jobs.M2TJob.runInWorkspace(M2TJob.java:64)
	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
	
to be raised subsequently.

= Proposed resolution =
Improve implementation of Xtend/Xpand/CheckJob#runInWorkspace() methods so follows: For each Xtend/Xpand/Check file under evaluation
* call IFile#getCharset() to retrieve concise encoding information
* call ResourceManager#setFileEncoding() on ResourceManager instance used by the respective execution context so as to make sure that Xtend/Xpand/Check files get loaded with correct encoding information.
Comment 1 Stephan Eberle CLA 2011-09-19 11:36:00 EDT
Fixed as proposed in description.
Comment 2 Balazs Grill CLA 2021-07-14 02:16:32 EDT
Mass-closing Resolved tickets