use of org.eclipse.emf.common.util.URI in project xtext-xtend by eclipse.
the class XtendReferenceFinder method addReferenceIfTarget.
protected void addReferenceIfTarget(final EObject candidate, final Predicate<URI> targetURISet, final EObject sourceElement, final EReference reference, final IReferenceFinder.Acceptor acceptor) {
final URI candidateURI = EcoreUtil2.getPlatformResourceOrNormalizedURI(candidate);
boolean _apply = targetURISet.apply(candidateURI);
if (_apply) {
final URI sourceURI = EcoreUtil2.getPlatformResourceOrNormalizedURI(sourceElement);
acceptor.accept(sourceElement, sourceURI, reference, (-1), candidate, candidateURI);
}
}
use of org.eclipse.emf.common.util.URI in project xtext-xtend by eclipse.
the class AbstractFileSystemSupport method getURI.
protected URI getURI(final Path path) {
if (((path == null) || Objects.equal(path, Path.ROOT))) {
return null;
}
final IProjectConfig projectConfig = this.projectConfigProvider.getProjectConfig(this.context);
if ((projectConfig == null)) {
return null;
}
final URI projectURI = projectConfig.getPath();
final String projectName = IterableExtensions.<String>head(path.getSegments());
String _name = projectConfig.getName();
boolean _notEquals = (!Objects.equal(projectName, _name));
if (_notEquals) {
return null;
}
final Iterable<String> segments = IterableExtensions.<String>tail(path.getSegments());
boolean _isEmpty = IterableExtensions.isEmpty(segments);
if (_isEmpty) {
return projectURI;
}
final URI relativeURI = URI.createURI(IterableExtensions.<String>head(segments)).appendSegments(((String[]) Conversions.unwrapArray(IterableExtensions.<String>tail(segments), String.class)));
final URI uri = relativeURI.resolve(projectURI);
Boolean _isFolder = this.isFolder(uri);
if ((_isFolder).booleanValue()) {
return UriUtil.toFolderURI(uri);
}
return uri;
}
use of org.eclipse.emf.common.util.URI in project xtext-xtend by eclipse.
the class AbstractFileSystemSupport method setContents.
@Override
public void setContents(final Path path, final CharSequence contents) {
final URI uri = this.getURI(path);
if ((uri == null)) {
throw new IllegalArgumentException(("The file cannot be found: " + path));
}
CharSequence _elvis = null;
CharSequence _postProcess = null;
if (this.postProcessor != null) {
_postProcess = this.postProcessor.postProcess(uri, contents);
}
if (_postProcess != null) {
_elvis = _postProcess;
} else {
_elvis = contents;
}
final CharSequence processedContents = _elvis;
try {
String _string = processedContents.toString();
String _charset = this.getCharset(path);
StringInputStream _stringInputStream = new StringInputStream(_string, _charset);
this.setContentsAsStream(path, _stringInputStream);
} catch (final Throwable _t) {
if (_t instanceof UnsupportedEncodingException) {
final UnsupportedEncodingException exc = (UnsupportedEncodingException) _t;
String _message = exc.getMessage();
throw new IllegalArgumentException(_message, exc);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
use of org.eclipse.emf.common.util.URI in project xtext-xtend by eclipse.
the class XAnnotationExtensions method isProcessed.
/**
* Checks whether this annotation is pointing to a processed annotation, without resolving the proxy
*/
public boolean isProcessed(final XAnnotation it) {
Object _eGet = it.eGet(XAnnotationsPackage.Literals.XANNOTATION__ANNOTATION_TYPE, false);
final Object proxy = _eGet;
boolean _matched = false;
if (proxy instanceof EObject) {
boolean _eIsProxy = ((EObject) proxy).eIsProxy();
if (_eIsProxy) {
_matched = true;
final URI uri = ((InternalEObject) proxy).eProxyURI();
boolean _isCrossLinkFragment = this.encoder.isCrossLinkFragment(it.eResource(), uri.fragment());
if (_isCrossLinkFragment) {
final Triple<EObject, EReference, INode> triple = this.encoder.decode(it.eResource(), uri.fragment());
final List<EObject> candidates = this.linkingService.getLinkedObjects(triple.getFirst(), triple.getSecond(), triple.getThird());
boolean _isEmpty = candidates.isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
final EObject head = IterableExtensions.<EObject>head(candidates);
if ((head instanceof JvmAnnotationType)) {
return this.isActiveAnnotation(((JvmAnnotationType) head));
}
}
}
}
}
if (!_matched) {
if (proxy instanceof JvmAnnotationType) {
_matched = true;
return this.isActiveAnnotation(((JvmAnnotationType) proxy));
}
}
return false;
}
use of org.eclipse.emf.common.util.URI in project xtext-xtend by eclipse.
the class XtendBatchCompiler method createIssueMessage.
private StringBuilder createIssueMessage(Issue issue) {
StringBuilder issueBuilder = new StringBuilder("\n");
issueBuilder.append(issue.getSeverity()).append(": \t");
URI uriToProblem = issue.getUriToProblem();
if (uriToProblem != null) {
URI resourceUri = uriToProblem.trimFragment();
issueBuilder.append(resourceUri.lastSegment()).append(" - ");
if (resourceUri.isFile()) {
issueBuilder.append(resourceUri.toFileString());
}
}
issueBuilder.append("\n").append(issue.getLineNumber()).append(": ").append(issue.getMessage());
return issueBuilder;
}
Aggregations