use of org.eclipse.xtext.ide.server.ProjectManager in project xtext-core by eclipse.
the class BuildManager method internalBuild.
protected List<IResourceDescription.Delta> internalBuild(final CancelIndicator cancelIndicator) {
final ArrayList<URI> allDirty = new ArrayList<URI>(this.dirtyFiles);
final HashMultimap<ProjectDescription, URI> project2dirty = HashMultimap.<ProjectDescription, URI>create();
for (final URI dirty : allDirty) {
{
final ProjectDescription projectManager = this.workspaceManager.getProjectManager(dirty).getProjectDescription();
project2dirty.put(projectManager, dirty);
}
}
final HashMultimap<ProjectDescription, URI> project2deleted = HashMultimap.<ProjectDescription, URI>create();
for (final URI deleted : this.deletedFiles) {
{
final ProjectDescription projectManager = this.workspaceManager.getProjectManager(deleted).getProjectDescription();
project2deleted.put(projectManager, deleted);
}
}
Set<ProjectDescription> _keySet = project2dirty.keySet();
Set<ProjectDescription> _keySet_1 = project2deleted.keySet();
Iterable<ProjectDescription> _plus = Iterables.<ProjectDescription>concat(_keySet, _keySet_1);
final List<ProjectDescription> sortedDescriptions = this.sortByDependencies(_plus);
final ArrayList<IResourceDescription.Delta> result = CollectionLiterals.<IResourceDescription.Delta>newArrayList();
for (final ProjectDescription it : sortedDescriptions) {
{
final ProjectManager projectManager = this.workspaceManager.getProjectManager(it.getName());
final List<URI> projectDirty = IterableExtensions.<URI>toList(project2dirty.get(it));
final List<URI> projectDeleted = IterableExtensions.<URI>toList(project2deleted.get(it));
final IncrementalBuilder.Result partialResult = projectManager.doBuild(projectDirty, projectDeleted, result, cancelIndicator);
final Function1<IResourceDescription.Delta, URI> _function = (IResourceDescription.Delta it_1) -> {
return it_1.getUri();
};
allDirty.addAll(ListExtensions.<IResourceDescription.Delta, URI>map(partialResult.getAffectedResources(), _function));
Iterables.removeAll(this.dirtyFiles, projectDirty);
Iterables.removeAll(this.deletedFiles, projectDeleted);
result.addAll(partialResult.getAffectedResources());
}
}
return result;
}
use of org.eclipse.xtext.ide.server.ProjectManager in project xtext-core by eclipse.
the class WorkspaceManager method exists.
protected boolean exists(final URI uri) {
ProjectManager _projectManager = this.getProjectManager(uri);
XtextResourceSet _resourceSet = null;
if (_projectManager != null) {
_resourceSet = _projectManager.getResourceSet();
}
final XtextResourceSet rs = _resourceSet;
if ((rs == null)) {
return false;
}
return rs.getURIConverter().exists(uri, null);
}
use of org.eclipse.xtext.ide.server.ProjectManager in project xtext-core by eclipse.
the class WorkspaceManager method doRead.
public <T extends Object> T doRead(final URI uri, final Function2<? super Document, ? super XtextResource, ? extends T> work) {
final URI resourceURI = uri.trimFragment();
final ProjectManager projectMnr = this.getProjectManager(resourceURI);
Resource _resource = null;
if (projectMnr != null) {
_resource = projectMnr.getResource(resourceURI);
}
final XtextResource resource = ((XtextResource) _resource);
if ((resource == null)) {
return work.apply(null, null);
}
Document doc = this.getDocument(resource);
Resource _resource_1 = projectMnr.getResource(resourceURI);
return work.apply(doc, ((XtextResource) _resource_1));
}
use of org.eclipse.xtext.ide.server.ProjectManager in project xtext-core by eclipse.
the class RenameService method rename.
@Override
public WorkspaceEdit rename(final WorkspaceManager workspaceManager, final RenameParams renameParams, final CancelIndicator cancelIndicator) {
WorkspaceEdit _xblockexpression = null;
{
final URI uri = this._uriExtensions.toUri(renameParams.getTextDocument().getUri());
final ServerRefactoringIssueAcceptor issueAcceptor = this.issueProvider.get();
final Function2<Document, XtextResource, WorkspaceEdit> _function = (Document document, XtextResource resource) -> {
final ProjectManager projectManager = workspaceManager.getProjectManager(uri);
final XtextResourceSet resourceSet = projectManager.createNewResourceSet(projectManager.getIndexState().getResourceDescriptions());
resourceSet.getLoadOptions().put(ResourceDescriptionsProvider.LIVE_SCOPE, Boolean.valueOf(true));
final int offset = document.getOffSet(renameParams.getPosition());
final WorkspaceEdit workspaceEdit = new WorkspaceEdit();
final Resource xtextResource = resourceSet.getResource(resource.getURI(), true);
if ((xtextResource instanceof XtextResource)) {
final EObject element = this._eObjectAtOffsetHelper.resolveElementAt(((XtextResource) xtextResource), offset);
if (((element == null) || element.eIsProxy())) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("No element found at position line:");
int _line = renameParams.getPosition().getLine();
_builder.append(_line);
_builder.append(" column:");
int _character = renameParams.getPosition().getCharacter();
_builder.append(_character);
issueAcceptor.add(RefactoringIssueAcceptor.Severity.FATAL, _builder.toString());
} else {
String _newName = renameParams.getNewName();
URI _uRI = EcoreUtil.getURI(element);
final RenameChange change = new RenameChange(_newName, _uRI);
final IChangeSerializer changeSerializer = this.changeSerializerProvider.get();
final RenameContext context = new RenameContext(Collections.<RenameChange>unmodifiableList(CollectionLiterals.<RenameChange>newArrayList(change)), resourceSet, changeSerializer, issueAcceptor);
this.renameStrategy.applyRename(context);
final ChangeConverter changeConverter = this.converterFactory.create(workspaceManager, workspaceEdit);
changeSerializer.applyModifications(changeConverter);
}
} else {
issueAcceptor.add(RefactoringIssueAcceptor.Severity.FATAL, "Loaded resource is not an XtextResource", resource.getURI());
}
return workspaceEdit;
};
_xblockexpression = workspaceManager.<WorkspaceEdit>doRead(uri, _function);
}
return _xblockexpression;
}
Aggregations