Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » absolute paths in ._trace files
absolute paths in ._trace files [message #1214968] Wed, 27 November 2013 23:06 Go to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1815
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

If I run the Xtend standalone compiler in the headless build (with
Buckminster), the corresponding .java._trace files contain a reference
to the original xtend file with an absolute path (starting with
file:/home/...). This happens in spite of the compiler being called
with command line argument: "-d xtend-gen src".

This way, the corresponding generated source bundles are not very
useful, since you can't inspect the source of a Java class generated
from an xtend file (Eclipse will show an empty file in the editor). Of
course you can manually open the corresponding .xtend file in the source
bundle but that's not convenient.

This does not happen if the xtend compilation takes place in the
workbench: the .java._trace files contain a reference to the original
xtend file with a relative path, and the corresponding source bundles
can be efficiently used.

Any clue about this issue?

thanks in advance
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Re: absolute paths in ._trace files [message #1215770 is a reply to message #1214968] Thu, 28 November 2013 07:17 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Could you file a bugzilla for that?

Thanks,
Sven
Re: absolute paths in ._trace files [message #1219025 is a reply to message #1215770] Fri, 29 November 2013 18:25 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1815
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 28/11/2013 08:17, Sven Efftinge wrote:
> Could you file a bugzilla for that?
>
> Thanks,
> Sven

Done

https://bugs.eclipse.org/bugs/show_bug.cgi?id=422874

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Re: absolute paths in ._trace files [message #1744807 is a reply to message #1219025] Fri, 30 September 2016 10:39 Go to previous messageGo to next message
Peter Luthardt is currently offline Peter LuthardtFriend
Messages: 43
Registered: February 2014
Member
I have a similar issue.
When building a maven module which uses xtext-maven-plugin for code generation the created *java._trace files contains a String like
"Jenkins/workspace/emulator%20nightly%20build/emulator.topology/src/main/java/com/.."
When building it in eclipse the same *java._trace contains "com/.."
I have no idea how this trace thing works, but it seems to be the cause of my problem, that in some cases the F3 (Open Declaration) does not work.
When I debug into org.eclipse.xtext.xbase.ui.editor.XbaseResourceForEditorInputFactory.createResource(IClassFile classFile) I get an uri
"C:/../maven/../emulator.topology-0.0.10-SNAPSHOT-sources.jar!/Jenkins/workspace/emulator%20nightly%20build/emulator.topology/src/main/java/com/.." which does not exists.
I see that your issue has been solved, but I do not know what I have to do.
Could you please help me?

Re: absolute paths in ._trace files [message #1744941 is a reply to message #1744807] Mon, 03 October 2016 07:49 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1815
Registered: July 2009
Location: Firenze, Italy
Senior Member
Indeed, this was fixed long time ago... which version of the xtext-maven-plugin are you using?

Re: absolute paths in ._trace files [message #1745003 is a reply to message #1744941] Tue, 04 October 2016 06:58 Go to previous messageGo to next message
Peter Luthardt is currently offline Peter LuthardtFriend
Messages: 43
Registered: February 2014
Member
Thanks for your answer, yes it was a long time ago, and it took me one day to find this thread Smile
I am using xtext 2.9.2 . The grammer was originally created with 2.8.2. (I am not sure whether the issue accorded with 2.8.2)

Any hint welcome.

Re: absolute paths in ._trace files [message #1745008 is a reply to message #1745003] Tue, 04 October 2016 07:51 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1815
Registered: July 2009
Location: Firenze, Italy
Senior Member
oh oh... I've just checked one of such generated files in my Jenkins, with 2.10, and I can confirm your behavior for generated files with xtext-maven-plugin.

The original bug was for Xtend, and that was fixed.

But the problem seems in xtext-maven-plugin... probably you should issue a new bug


Re: absolute paths in ._trace files [message #1745011 is a reply to message #1745008] Tue, 04 October 2016 08:16 Go to previous messageGo to next message
Peter Luthardt is currently offline Peter LuthardtFriend
Messages: 43
Registered: February 2014
Member
This is no good news.

I created a bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=503309
Re: absolute paths in ._trace files [message #1745016 is a reply to message #1745011] Tue, 04 October 2016 08:36 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1815
Registered: July 2009
Location: Firenze, Italy
Senior Member
Probably I spoke too fast: in my case the culprit could be using an absolute path

<outputDirectory>${basedir}/src-gen</outputDirectory>

I can't check it right now, but please check if you're doing the same in your xtext-maven-plugin configuration.


Re: absolute paths in ._trace files [message #1745017 is a reply to message #1745016] Tue, 04 October 2016 08:41 Go to previous messageGo to next message
Peter Luthardt is currently offline Peter LuthardtFriend
Messages: 43
Registered: February 2014
Member
I have the same lines in my pom.xml
<outputConfiguration>
<name>gen_resource</name>
<outputDirectory>${basedir}/target/src-gen/main/resources</outputDirectory>
</outputConfiguration>

When I change it to
<outputDirectory>./target/src-gen/main/resources</outputDirectory>
Nothing happens.

[Updated on: Tue, 04 October 2016 09:39]

Report message to a moderator

Re: absolute paths in ._trace files [message #1745029 is a reply to message #1745017] Tue, 04 October 2016 10:27 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1815
Registered: July 2009
Location: Firenze, Italy
Senior Member
maybe just

<outputDirectory>src-gen/main/resources</outputDirectory>


Re: absolute paths in ._trace files [message #1745099 is a reply to message #1745029] Wed, 05 October 2016 07:41 Go to previous messageGo to next message
Peter Luthardt is currently offline Peter LuthardtFriend
Messages: 43
Registered: February 2014
Member
changing the source folder location is not an option for me.
I did a dirty work around which seems to work for me.
import java.util.HashSet
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.xtext.generator.trace.AbsoluteURI
import org.eclipse.xtext.generator.trace.DefaultTraceURIConverter
import org.eclipse.xtext.generator.trace.ITraceURIConverter
import org.eclipse.xtext.generator.trace.SourceRelativeURI
import org.eclipse.xtext.workspace.IProjectConfig

class DomainTraceUriConverter extends DefaultTraceURIConverter implements ITraceURIConverter {
	
	override getURIForTrace(IProjectConfig projectConfig, AbsoluteURI absoluteURI) {
		super.getURIForTrace(projectConfig, absoluteURI).convertToSourceUri
	}
	
	override getURIForTrace(Resource resource) {
		super.getURIForTrace(resource).convertToSourceUri
	}
	
	def SourceRelativeURI convertToSourceUri (SourceRelativeURI uri)
	{
		val segementList = uri.URI.segmentsList
		val HashSet<Integer> mainIndexes = newHashSet()
		val HashSet<Integer> srcIndexes = newHashSet()
		val HashSet<Integer> javaIndexes = newHashSet()
		for (index: 0 ..< segementList.size)
		{
			if ("main".equals(segementList.get(index)))
			{
				mainIndexes.add (index)
			} else if ("src".equals(segementList.get(index)))
			{
				srcIndexes.add (index)
			} else if ("java".equals(segementList.get(index)))
			{
				javaIndexes.add (index)
			}
		}
		val convertedUri = javaIndexes.filter[javaIndex|
			mainIndexes.contains(javaIndex-1)
			srcIndexes.contains(javaIndex-2)
		].map[javaIndex|
			val srcUri = segementList.subList(javaIndex+1, segementList.size)
			val String[] strArray = newArrayOfSize(srcUri.size)
			val segementsArray = srcUri.toArray(strArray)
			new SourceRelativeURI(URI.createHierarchicalURI(segementsArray, null, null))
		].head
		
		if (convertedUri !== null)
		{
			println('''convertUri «uri.toString» -> «convertedUri.toString»''')
			convertedUri
		} else
		{
			println('''not converted Uri «uri.toString»''')
			uri
		}
	}


and bound it in in RuntimeModule
	def Class<? extends ITraceURIConverter> bindITraceURIConverter(){
//		println("bind ITraceURIConverter to "+DomainTraceUriConverter.name)
		DomainTraceUriConverter
	}


Something like this should to be done in the xtext-maven-plugin as he has the information of the source roots.
Re: absolute paths in ._trace files [message #1871295 is a reply to message #1745099] Thu, 19 September 2024 16:38 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1815
Registered: July 2009
Location: Firenze, Italy
Senior Member
I've forgotten to mention that this bug is now fixed

Previous Topic:Error "Failed to create injector"
Next Topic:LSP: How to trigger build after dependency changes
Goto Forum:
  


Current Time: Thu Dec 05 11:12:50 GMT 2024

Powered by FUDForum. Page generated in 0.05794 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top