Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Missing fsa.deleteFile implementation in generator of language server
Missing fsa.deleteFile implementation in generator of language server [message #1858997] Thu, 04 May 2023 18:36 Go to next message
Sascha aka. GlancingMind is currently offline Sascha aka. GlancingMindFriend
Messages: 5
Registered: April 2023
Junior Member
Hello,

my code-generator implementation requires to call the deleteFile-method of the given FileSystemAccess2 implementation.
While the eclipse runtime instance seems to work fine, the language server crashes with an UnsupportedOperationException which can be traced back to https://github.com/eclipse/xtext/blob/main/org.eclipse.xtext/src/org/eclipse/xtext/generator/AbstractFileSystemAccess.java#L116 (See appended img).

I already tried to use the deleteFile-method of an injected JavaIoFileSystemAccess, which successfully deletes the file when using the language server. But within an eclipse-runtime instance, the files won't be deleted. So I tried to also invoke fsa.deleteFile like in following code snipped:

@Inject JavaIoFileSystemAccess javaFsa

void doGenerate(Resource model, IFileSystemAccess2 fsa, IGeneratorContext context) {
    // ...

    // successfully deletes the specified file when using the language server,
    // but not when using the eclipse-runtime instance.
    javaFsa.deleteFile(filepath); 

    // Prevent language server from calling fsa.deleteFile to prevent UnsupportedOperationException.
    if(fsa.isFile(filepath) { 
        // While this is never called by the language server, the eclipse instance doesn't call it either...
        fsa.deleteFile(filepath); 
    }
   // ...
}


I am grateful for any possible solution.

Kind regards

[Updated on: Sat, 06 May 2023 08:46]

Report message to a moderator

Re: Missing fsa.deleteFile implementation in generator of language server [message #1858999 is a reply to message #1858997] Fri, 05 May 2023 03:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14677
Registered: July 2009
Senior Member
Can you debug which filesystem access class is actually in the context.
Is it really the abstract class, if yes why


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Missing fsa.deleteFile implementation in generator of language server [message #1859015 is a reply to message #1858999] Sat, 06 May 2023 09:32 Go to previous messageGo to next message
Sascha aka. GlancingMind is currently offline Sascha aka. GlancingMindFriend
Messages: 5
Registered: April 2023
Junior Member
Hi Christian,

I dig a bit further and it seems like, that the IncrementalBuilder retrieves an URIBasedFileSystemAccess instance (as seen here: https://github.com/eclipse/xtext/blob/main/org.eclipse.xtext/src/org/eclipse/xtext/build/IncrementalBuilder.java#L364).
The URIBasedFileSystemAccess does not implement/override the deleteFile-method. Neither does the AbstractFileSystemAccess2, which URIBasedFileSystemAccess extends.
Therefore the implementation of deleteFile is taken from the parent class of AbstractFileSystemAccess2, which is AbstractFileSystemAccess.

In other words:
URIBasedFileSystemAccess::deleteFile calls AbstractFileSystemAccess2::deleteFile, which calls AbstractFileSystemAccess::deleteFile, which then throws the exception.

I've created a minimal xtext-lsp project. You can find it over here: https://github.com/GlancingMind/xtext-lsp-missing-deleteFile-impl.
The only things I've changed are the generator implementation and a custom LSP-ServerLauncher class.

Greetings

Re: Missing fsa.deleteFile implementation in generator of language server [message #1859021 is a reply to message #1859015] Sat, 06 May 2023 15:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14677
Registered: July 2009
Senior Member
have no idea why it is designed that way. i propose you customize that class

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Missing fsa.deleteFile implementation in generator of language server [message #1859022 is a reply to message #1859021] Sat, 06 May 2023 15:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14677
Registered: July 2009
Senior Member
can you also create a bug at github.com/eclipse/xtext

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sat, 06 May 2023 15:26]

Report message to a moderator

Re: Missing fsa.deleteFile implementation in generator of language server [message #1859027 is a reply to message #1859022] Sun, 07 May 2023 12:40 Go to previous message
Sascha aka. GlancingMind is currently offline Sascha aka. GlancingMindFriend
Messages: 5
Registered: April 2023
Junior Member
Hey Christian,

thanks for the reply. For now I'm fine with only one working application (eclipse-instance or language server).
Nonetheless I've opened a bug report. The link is https://github.com/eclipse/xtext/issues/2655.

Greetings
Previous Topic:Xtext 2.31.0.M2 is out
Next Topic:Adding a standard library to a DSL
Goto Forum:
  


Current Time: Fri May 17 23:40:59 GMT 2024

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

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

Back to the top