Class WorkspaceManager


  • public class WorkspaceManager
    extends java.lang.Object
    Since:
    2.11
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addBuildListener​(ILanguageServerAccess.IBuildListener listener)
      Add the listener to this workspace.
      protected void afterBuild​(java.util.List<org.eclipse.xtext.resource.IResourceDescription.Delta> deltas)
      Callback after a build was performend
      protected java.util.Map<org.eclipse.emf.common.util.URI,​Document> createOpenDocuments()
      Creates the open document map and returns it, never null.
      protected org.eclipse.xtext.workspace.IWorkspaceConfig createWorkspaceConfig()  
      BuildManager.Buildable didChangeFiles​(java.util.List<org.eclipse.emf.common.util.URI> dirtyFiles, java.util.List<org.eclipse.emf.common.util.URI> deletedFiles)
      Announce dirty and deleted files and provide means to start a build.
      BuildManager.Buildable didChangeTextDocumentContent​(org.eclipse.emf.common.util.URI uri, java.lang.Integer version, java.lang.Iterable<org.eclipse.lsp4j.TextDocumentContentChangeEvent> changes)
      As opposed to TextEdit[] the positions in the edits of a DidChangeTextDocumentParams refer to the state after applying the preceding edits.
      void didChangeWorkspaceFolders​(org.eclipse.lsp4j.DidChangeWorkspaceFoldersParams params, org.eclipse.xtext.util.CancelIndicator cancelIndicator)
      Updates the workspace folders and refreshes the workspace.
      BuildManager.Buildable didClose​(org.eclipse.emf.common.util.URI uri)
      Mark the given document as cloded.
      BuildManager.Buildable didOpen​(org.eclipse.emf.common.util.URI uri, java.lang.Integer version, java.lang.String contents)
      Mark the given document as open.
      java.util.List<org.eclipse.xtext.resource.IResourceDescription.Delta> didOpen​(org.eclipse.emf.common.util.URI uri, java.lang.Integer version, java.lang.String contents, org.eclipse.xtext.util.CancelIndicator cancelIndicator)
      Mark the given document as open and build it.
      java.util.List<org.eclipse.xtext.resource.IResourceDescription.Delta> doBuild​(java.util.List<org.eclipse.emf.common.util.URI> dirtyFiles, java.util.List<org.eclipse.emf.common.util.URI> deletedFiles, org.eclipse.xtext.util.CancelIndicator cancelIndicator)
      Announce dirty and deleted files and perform a build.
      <T> T doRead​(org.eclipse.emf.common.util.URI uri, org.eclipse.xtext.xbase.lib.Functions.Function2<? super Document,​? super org.eclipse.xtext.resource.XtextResource,​? extends T> work)
      Find the resource and the document with the given URI and perform a a read operation.
      protected boolean exists​(org.eclipse.emf.common.util.URI uri)
      Return true if the given resource still exists.
      protected Document getDocument​(org.eclipse.xtext.resource.XtextResource resource)
      Find the document for the given resource.
      org.eclipse.xtext.resource.IResourceDescriptions getIndex()
      Returns the current index.
      protected java.util.Map<org.eclipse.emf.common.util.URI,​Document> getOpenDocuments()  
      org.eclipse.emf.common.util.URI getProjectBaseDir​(org.eclipse.emf.common.util.URI uri)
      Returns the project that contains the given URI.
      protected org.eclipse.xtext.workspace.IProjectConfig getProjectConfig​(org.eclipse.emf.common.util.URI uri)
      Find the project that contains the uri.
      ProjectManager getProjectManager​(java.lang.String projectName)
      Return the project manager for the project with the given name.
      ProjectManager getProjectManager​(org.eclipse.emf.common.util.URI uri)  
      java.util.List<ProjectManager> getProjectManagers()
      Return all project managers.
      protected org.eclipse.xtext.workspace.IWorkspaceConfig getWorkspaceConfig()  
      protected java.util.List<org.eclipse.lsp4j.WorkspaceFolder> getWorkspaceFolders()  
      void initialize​(java.util.List<org.eclipse.lsp4j.WorkspaceFolder> workspaceFolders, org.eclipse.xtext.xbase.lib.Procedures.Procedure2<? super org.eclipse.emf.common.util.URI,​? super java.lang.Iterable<org.eclipse.xtext.validation.Issue>> issueAcceptor, org.eclipse.xtext.util.CancelIndicator cancelIndicator)
      Initialize a workspace with the given workspace folders.
      void initialize​(org.eclipse.emf.common.util.URI baseDir, org.eclipse.xtext.xbase.lib.Procedures.Procedure2<? super org.eclipse.emf.common.util.URI,​? super java.lang.Iterable<org.eclipse.xtext.validation.Issue>> issueAcceptor, org.eclipse.xtext.util.CancelIndicator cancelIndicator)
      Initialize a workspace at the given location.
      boolean isDocumentOpen​(org.eclipse.emf.common.util.URI uri)
      Return true if there is a open document with the givne URI.
      boolean isSupportsWorkspaceFolders()  
      org.eclipse.xtext.util.Pair<? super Document,​? super org.eclipse.xtext.resource.XtextResource> read​(org.eclipse.emf.common.util.URI uri)
      Find the resource and the document with the given URI.
      protected void refreshWorkspaceConfig​(org.eclipse.xtext.util.CancelIndicator cancelIndicator)
      Refresh the workspace.
      void removeBuildListener​(ILanguageServerAccess.IBuildListener listener)
      Removes a build listener if it was previously registered
      void setBuildManager​(BuildManager buildManager)
      Inject the build manager and establish circular dependency.
      protected void setWorkspaceConfig​(org.eclipse.xtext.workspace.IWorkspaceConfig workspaceConfig)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • WorkspaceManager

        public WorkspaceManager()
    • Method Detail

      • setBuildManager

        @Inject
        public void setBuildManager​(BuildManager buildManager)
        Inject the build manager and establish circular dependency.
        Parameters:
        buildManager - the build manager.
      • initialize

        public void initialize​(org.eclipse.emf.common.util.URI baseDir,
                               org.eclipse.xtext.xbase.lib.Procedures.Procedure2<? super org.eclipse.emf.common.util.URI,​? super java.lang.Iterable<org.eclipse.xtext.validation.Issue>> issueAcceptor,
                               org.eclipse.xtext.util.CancelIndicator cancelIndicator)
        Initialize a workspace at the given location.
        Parameters:
        baseDir - the location
        issueAcceptor - the issue acceptor
        cancelIndicator - allows to cancel the initialization
      • initialize

        public void initialize​(java.util.List<org.eclipse.lsp4j.WorkspaceFolder> workspaceFolders,
                               org.eclipse.xtext.xbase.lib.Procedures.Procedure2<? super org.eclipse.emf.common.util.URI,​? super java.lang.Iterable<org.eclipse.xtext.validation.Issue>> issueAcceptor,
                               org.eclipse.xtext.util.CancelIndicator cancelIndicator)
        Initialize a workspace with the given workspace folders.
        Parameters:
        workspaceFolders - the list of workspace root folders
        issueAcceptor - the issue acceptor
        cancelIndicator - allows to cancel the initialization
        Since:
        2.21
      • isSupportsWorkspaceFolders

        public boolean isSupportsWorkspaceFolders()
        Returns:
        whether this workspace manager supports multiple workspace root folders.
        Since:
        2.21
      • getWorkspaceFolders

        protected java.util.List<org.eclipse.lsp4j.WorkspaceFolder> getWorkspaceFolders()
      • createOpenDocuments

        protected java.util.Map<org.eclipse.emf.common.util.URI,​Document> createOpenDocuments()
        Creates the open document map and returns it, never null.
        Since:
        2.28
      • getOpenDocuments

        protected java.util.Map<org.eclipse.emf.common.util.URI,​Document> getOpenDocuments()
        Returns:
        the open document map, never null.
        Since:
        2.28
      • didChangeWorkspaceFolders

        public void didChangeWorkspaceFolders​(org.eclipse.lsp4j.DidChangeWorkspaceFoldersParams params,
                                              org.eclipse.xtext.util.CancelIndicator cancelIndicator)
        Updates the workspace folders and refreshes the workspace.
        Since:
        2.21
      • createWorkspaceConfig

        protected org.eclipse.xtext.workspace.IWorkspaceConfig createWorkspaceConfig()
      • refreshWorkspaceConfig

        protected void refreshWorkspaceConfig​(org.eclipse.xtext.util.CancelIndicator cancelIndicator)
        Refresh the workspace.
      • getWorkspaceConfig

        protected org.eclipse.xtext.workspace.IWorkspaceConfig getWorkspaceConfig()
                                                                           throws org.eclipse.lsp4j.jsonrpc.ResponseErrorException
        Returns:
        the workspace configuration
        Throws:
        org.eclipse.lsp4j.jsonrpc.ResponseErrorException - if the workspace is not yet initialized
      • setWorkspaceConfig

        protected void setWorkspaceConfig​(org.eclipse.xtext.workspace.IWorkspaceConfig workspaceConfig)
        Parameters:
        workspaceConfig - the new workspace configuration.
      • afterBuild

        protected void afterBuild​(java.util.List<org.eclipse.xtext.resource.IResourceDescription.Delta> deltas)
        Callback after a build was performend
      • didChangeFiles

        public BuildManager.Buildable didChangeFiles​(java.util.List<org.eclipse.emf.common.util.URI> dirtyFiles,
                                                     java.util.List<org.eclipse.emf.common.util.URI> deletedFiles)
        Announce dirty and deleted files and provide means to start a build.
        Parameters:
        dirtyFiles - the dirty files
        deletedFiles - the deleted files
        Returns:
        a build command that can be triggered
      • doBuild

        public java.util.List<org.eclipse.xtext.resource.IResourceDescription.Delta> doBuild​(java.util.List<org.eclipse.emf.common.util.URI> dirtyFiles,
                                                                                             java.util.List<org.eclipse.emf.common.util.URI> deletedFiles,
                                                                                             org.eclipse.xtext.util.CancelIndicator cancelIndicator)
        Announce dirty and deleted files and perform a build.
        Parameters:
        dirtyFiles - the dirty files
        deletedFiles - the deleted files
        cancelIndicator - cancellation support
        Returns:
        the delta
      • getIndex

        public org.eclipse.xtext.resource.IResourceDescriptions getIndex()
        Returns the current index.
      • getProjectBaseDir

        public org.eclipse.emf.common.util.URI getProjectBaseDir​(org.eclipse.emf.common.util.URI uri)
        Returns the project that contains the given URI.
        Parameters:
        uri - the contained uri
        Returns:
        the project base uri.
      • getProjectManager

        public ProjectManager getProjectManager​(org.eclipse.emf.common.util.URI uri)
        Parameters:
        uri - the contained uri
        Returns:
        the project manager.
      • getProjectConfig

        protected org.eclipse.xtext.workspace.IProjectConfig getProjectConfig​(org.eclipse.emf.common.util.URI uri)
        Find the project that contains the uri.
      • getProjectManager

        public ProjectManager getProjectManager​(java.lang.String projectName)
        Return the project manager for the project with the given name.
        Parameters:
        projectName - the project name
        Returns:
        the project manager
      • getProjectManagers

        public java.util.List<ProjectManager> getProjectManagers()
        Return all project managers.
        Returns:
        all project managers.
      • didChangeTextDocumentContent

        public BuildManager.Buildable didChangeTextDocumentContent​(org.eclipse.emf.common.util.URI uri,
                                                                   java.lang.Integer version,
                                                                   java.lang.Iterable<org.eclipse.lsp4j.TextDocumentContentChangeEvent> changes)
        As opposed to TextEdit[] the positions in the edits of a DidChangeTextDocumentParams refer to the state after applying the preceding edits. See https://microsoft.github.io/language-server-protocol/specification#textedit-1 and https://github.com/microsoft/vscode/issues/23173#issuecomment-289378160 for details. In particular, this has to be taken into account when undoing the deletion of multiple characters at the end of a line.
        Parameters:
        version - unused
        Since:
        2.18
      • didOpen

        public java.util.List<org.eclipse.xtext.resource.IResourceDescription.Delta> didOpen​(org.eclipse.emf.common.util.URI uri,
                                                                                             java.lang.Integer version,
                                                                                             java.lang.String contents,
                                                                                             org.eclipse.xtext.util.CancelIndicator cancelIndicator)
        Mark the given document as open and build it.
      • didOpen

        public BuildManager.Buildable didOpen​(org.eclipse.emf.common.util.URI uri,
                                              java.lang.Integer version,
                                              java.lang.String contents)
        Mark the given document as open.
      • didClose

        public BuildManager.Buildable didClose​(org.eclipse.emf.common.util.URI uri)
        Mark the given document as cloded.
      • exists

        protected boolean exists​(org.eclipse.emf.common.util.URI uri)
        Return true if the given resource still exists.
      • doRead

        public <T> T doRead​(org.eclipse.emf.common.util.URI uri,
                            org.eclipse.xtext.xbase.lib.Functions.Function2<? super Document,​? super org.eclipse.xtext.resource.XtextResource,​? extends T> work)
        Find the resource and the document with the given URI and perform a a read operation.
      • read

        public org.eclipse.xtext.util.Pair<? super Document,​? super org.eclipse.xtext.resource.XtextResource> read​(org.eclipse.emf.common.util.URI uri)
        Find the resource and the document with the given URI.
      • getDocument

        protected Document getDocument​(org.eclipse.xtext.resource.XtextResource resource)
        Find the document for the given resource.
        Parameters:
        resource - the resource.
        Returns:
        the document
      • isDocumentOpen

        public boolean isDocumentOpen​(org.eclipse.emf.common.util.URI uri)
        Return true if there is a open document with the givne URI.
        Parameters:
        uri - the URI