Package org.eclipse.xtext.ide.server
Class WorkspaceManager
- java.lang.Object
-
- org.eclipse.xtext.ide.server.WorkspaceManager
-
public class WorkspaceManager extends java.lang.Object- Since:
- 2.11
-
-
Constructor Summary
Constructors Constructor Description WorkspaceManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBuildListener(ILanguageServerAccess.IBuildListener listener)Add the listener to this workspace.protected voidafterBuild(java.util.List<org.eclipse.xtext.resource.IResourceDescription.Delta> deltas)Callback after a build was performendprotected java.util.Map<org.eclipse.emf.common.util.URI,Document>createOpenDocuments()Creates the open document map and returns it, nevernull.protected org.eclipse.xtext.workspace.IWorkspaceConfigcreateWorkspaceConfig()BuildManager.BuildabledidChangeFiles(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.BuildabledidChangeTextDocumentContent(org.eclipse.emf.common.util.URI uri, java.lang.Integer version, java.lang.Iterable<org.eclipse.lsp4j.TextDocumentContentChangeEvent> changes)As opposed toTextEdit[] the positions in the edits of aDidChangeTextDocumentParamsrefer to the state after applying the preceding edits.voiddidChangeWorkspaceFolders(org.eclipse.lsp4j.DidChangeWorkspaceFoldersParams params, org.eclipse.xtext.util.CancelIndicator cancelIndicator)Updates the workspace folders and refreshes the workspace.BuildManager.BuildabledidClose(org.eclipse.emf.common.util.URI uri)Mark the given document as cloded.BuildManager.BuildabledidOpen(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> TdoRead(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 booleanexists(org.eclipse.emf.common.util.URI uri)Return true if the given resource still exists.protected DocumentgetDocument(org.eclipse.xtext.resource.XtextResource resource)Find the document for the given resource.org.eclipse.xtext.resource.IResourceDescriptionsgetIndex()Returns the current index.protected java.util.Map<org.eclipse.emf.common.util.URI,Document>getOpenDocuments()org.eclipse.emf.common.util.URIgetProjectBaseDir(org.eclipse.emf.common.util.URI uri)Returns the project that contains the given URI.protected org.eclipse.xtext.workspace.IProjectConfiggetProjectConfig(org.eclipse.emf.common.util.URI uri)Find the project that contains the uri.ProjectManagergetProjectManager(java.lang.String projectName)Return the project manager for the project with the given name.ProjectManagergetProjectManager(org.eclipse.emf.common.util.URI uri)java.util.List<ProjectManager>getProjectManagers()Return all project managers.protected org.eclipse.xtext.workspace.IWorkspaceConfiggetWorkspaceConfig()protected java.util.List<org.eclipse.lsp4j.WorkspaceFolder>getWorkspaceFolders()voidinitialize(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.voidinitialize(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.booleanisDocumentOpen(org.eclipse.emf.common.util.URI uri)Return true if there is a open document with the givne URI.booleanisSupportsWorkspaceFolders()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 voidrefreshWorkspaceConfig(org.eclipse.xtext.util.CancelIndicator cancelIndicator)Refresh the workspace.voidremoveBuildListener(ILanguageServerAccess.IBuildListener listener)Removes a build listener if it was previously registeredvoidsetBuildManager(BuildManager buildManager)Inject the build manager and establish circular dependency.protected voidsetWorkspaceConfig(org.eclipse.xtext.workspace.IWorkspaceConfig workspaceConfig)
-
-
-
Method Detail
-
addBuildListener
public void addBuildListener(ILanguageServerAccess.IBuildListener listener)
Add the listener to this workspace.- Parameters:
listener- the new listener.
-
removeBuildListener
public void removeBuildListener(ILanguageServerAccess.IBuildListener listener)
Removes a build listener if it was previously registered- Since:
- 2.18
-
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 locationissueAcceptor- the issue acceptorcancelIndicator- 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 foldersissueAcceptor- the issue acceptorcancelIndicator- 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, nevernull.- 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 filesdeletedFiles- 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 filesdeletedFiles- the deleted filescancelIndicator- 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 toTextEdit[] the positions in the edits of aDidChangeTextDocumentParamsrefer 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
-
-