Java Code Examples for org.eclipse.emf.common.util.URI#equals()
The following examples show how to use
org.eclipse.emf.common.util.URI#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PackageJsonValidatorExtension.java From n4js with Eclipse Public License 1.0 | 6 votes |
private boolean isContainedOrEqual(URI uri, URI container) { if (uri.equals(container)) { return true; } if (!container.hasTrailingPathSeparator()) { container = container.appendSegment(""); } URI relative = uri.deresolve(container, true, true, false); if (relative != uri) { if (relative.isEmpty()) { return true; } if ("..".equals(relative.segment(0))) { return false; } return true; } return false; }
Example 2
Source File: TextDocumentChangeToString.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected String getTitle(IEmfResourceChange change) { URI newUri = change.getNewURI(); URI oldURI = change.getOldURI(); if (oldURI == null && newUri == null) { return "error, both URIs are null"; } if (newUri == null) { return "deleted " + oldURI; } if (oldURI == null) { return "created " + newUri; } if (oldURI.equals(newUri)) { return oldURI.toString(); } return "renamed " + oldURI + " to " + newUri; }
Example 3
Source File: ValidationContext.java From gama with GNU General Public License v3.0 | 6 votes |
@Override public boolean add(final GamlCompilationError error) { if (error.isWarning()) { if (!GamaPreferences.Modeling.WARNINGS_ENABLED.getValue() || noWarning) { return false; } } else if (error.isInfo()) { if (!GamaPreferences.Modeling.INFO_ENABLED.getValue() || noInfo) { return false; } } final URI uri = error.getURI(); final boolean sameResource = uri.equals(resourceURI); if (sameResource) { return super.add(error); } else if (error.isError()) { importedErrors.add(error); return true; } return false; }
Example 4
Source File: FlatResourceSetBasedAllContainersState.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override public boolean containsURI(String containerHandle, URI candidateURI) { if (!HANDLE.equals(containerHandle)) return false; if (resourceSet instanceof XtextResourceSet) { ResourceDescriptionsData descriptionsData = findResourceDescriptionsData(resourceSet); if (descriptionsData != null) { return descriptionsData.getResourceDescription(candidateURI) != null; } Collection<URI> allUris = ((XtextResourceSet) resourceSet).getNormalizationMap().values(); for (URI uri : allUris) { if (uri.equals(candidateURI)) { return true; } } return false; } URIConverter uriConverter = resourceSet.getURIConverter(); for (Resource r : resourceSet.getResources()) { URI normalized = uriConverter.normalize(r.getURI()); if (normalized.equals(candidateURI)) { return true; } } return false; }
Example 5
Source File: N4JSMarkerResolutionGenerator.java From n4js with Eclipse Public License 1.0 | 5 votes |
private boolean isSameProblem(IMarker marker) { URI myUriToProblem = issue.getUriToProblem(); String code = issueUtil.getCode(marker); if (code != null && code.equals(org.eclipse.n4js.validation.IssueCodes.NON_EXISTING_PROJECT)) { myUriToProblem = myUriToProblem.appendFragment(Integer.toString(marker.hashCode())); } return myUriToProblem != null && myUriToProblem.equals(issueUtil.getUriToProblem(marker)); }
Example 6
Source File: ClasspathBasedChecks.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Verifies that a given catalog file has the same name as the name given in the model. * Also verifies that the given package exists and that the file is in that package. * * @param catalog * a check catalog */ @Check public void checkFileNamingConventions(final CheckCatalog catalog) { Resource resource = catalog.eResource(); URI resourceURI = resource.getURI(); String packageName = catalog.getPackageName(); StringBuilder classpathURIBuilder = new StringBuilder(ClasspathUriUtil.CLASSPATH_SCHEME); classpathURIBuilder.append(":/"); if (packageName != null) { classpathURIBuilder.append(packageName.replace(DOT, SLASH)).append(SLASH); } classpathURIBuilder.append(resourceURI.lastSegment()); URI classpathURI = URI.createURI(classpathURIBuilder.toString()); URIConverter uriConverter = resource.getResourceSet().getURIConverter(); try { URI normalizedClasspathURI = uriConverter.normalize(classpathURI); URI normalizedResourceURI = uriConverter.normalize(resourceURI); // Must normalize both URIs... however, pre-Xtext 2.4.3 we only normalized the classpath URI, and it worked?! // Just to be sure we don't break anything, leave that earlier behavior in. if (!normalizedResourceURI.equals(normalizedClasspathURI) && !resourceURI.equals(normalizedClasspathURI)) { reportInvalidPackage(catalog, packageName, null); } } catch (ClasspathUriResolutionException e) { reportInvalidPackage(catalog, packageName, null); } String catalogName = catalog.getName(); if (catalogName != null && !equal(resourceURI.trimFileExtension().lastSegment(), catalogName)) { error("The catalog '" + (packageName != null ? notNull(packageName) + DOT : "") + catalogName + "' must be defined in its own file", catalog, CheckPackage.Literals.CHECK_CATALOG__NAME, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.WRONG_FILE); } }
Example 7
Source File: RecordingXtextResourceUpdater.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public String toString() { StringBuilder result = new StringBuilder(getClass().getSimpleName()); URI oldURI = getSnapshot().getURI(); URI newURI = getResource().getURI(); if (oldURI.equals(newURI)) { result.append(" " + oldURI); } else { result.append(" " + oldURI + " -> " + newURI); } if (document != null) { result.append("\n" + document); } return result.toString(); }
Example 8
Source File: RecordingEmfResourceUpdater.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public String toString() { StringBuilder result = new StringBuilder(getClass().getSimpleName()); URI oldURI = getSnapshot().getURI(); URI newURI = getResource().getURI(); if (oldURI.equals(newURI)) { result.append(" " + oldURI); } else { result.append(" " + oldURI + " -> " + newURI); } return result.toString(); }
Example 9
Source File: CrossReferenceSerializer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public String serializeCrossRef(EObject semanticObject, CrossReference crossref, EObject target, INode node, Acceptor errors) { if ((target == null || target.eIsProxy()) && node != null) return tokenUtil.serializeNode(node); final EReference ref = GrammarUtil.getReference(crossref, semanticObject.eClass()); final IScope scope = scopeProvider.getScope(semanticObject, ref); if (scope == null) { if (errors != null) errors.accept(diagnostics.getNoScopeFoundDiagnostic(semanticObject, crossref, target)); return null; } if (target != null && target.eIsProxy()) { target = handleProxy(target, semanticObject, ref); } if (target != null && node != null) { String text = linkingHelper.getCrossRefNodeAsString(node, true); QualifiedName qn = qualifiedNameConverter.toQualifiedName(text); URI targetURI = EcoreUtil2.getPlatformResourceOrNormalizedURI(target); for (IEObjectDescription desc : scope.getElements(qn)) { if (targetURI.equals(desc.getEObjectURI())) return tokenUtil.serializeNode(node); } } return getCrossReferenceNameFromScope(semanticObject, crossref, target, scope, errors); }
Example 10
Source File: XtextResourceSet.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
void updateURI(Resource resource, URI old, final Map<URI, Resource> uriResourceMap) { uriResourceMap.remove(old); URI oldNormalized = normalizationMap.remove(old); if (old != null && !old.equals(oldNormalized)) { uriResourceMap.remove(oldNormalized); } registerURI(resource); }
Example 11
Source File: InferredModelAssociator.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Registers a dependency from the resource the inference was originally trigger for to the currently processed one. * * @param sourceModelElement * primary model element, must not be {@code null} */ private void addInferenceDependency(final EObject sourceModelElement) { Resource originalResource = getInferenceStack().peekFirst(); if (originalResource != null) { final URI originalResourceUri = originalResource.getURI(); final URI currentResourceUri = sourceModelElement.eResource().getURI(); if (originalResourceUri != null && currentResourceUri != null && !originalResourceUri.equals(currentResourceUri)) { ImplicitReferencesAdapter.findOrCreate(originalResource).addInferenceDependency(currentResourceUri); } } }
Example 12
Source File: AbstractSummary.java From gama with GNU General Public License v3.0 | 5 votes |
public AbstractSummary<?> getSummaryOf(final URI uri) { // if (this.uri != null) { // DEBUG.OUT("Comparing " + this.uri + " to " + uri); // } if (uri.equals(this.uri)) { return this; } return StreamEx.ofValues(getSummaries()).findFirst(s -> s.getSummaryOf(uri) != null).orElse(null); }
Example 13
Source File: ElementUtils.java From textuml with Eclipse Public License 1.0 | 5 votes |
public static boolean sameRepository(Element elementA, Element elementB) { URI resourceALocation = elementA.eResource().getURI(); URI resourceBLocation = elementB.eResource().getURI(); if (resourceALocation.isHierarchical() && resourceBLocation.isHierarchical()) if (URI.createURI("..").resolve(resourceALocation).equals(URI.createURI("..").resolve(resourceBLocation))) return true; return resourceALocation.equals(resourceBLocation); }
Example 14
Source File: AbstractScopingTest.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Check if scope expected is found in context provided. * * @param context * element from which an element shall be referenced * @param reference * to be used to filter the elements * @param expectedName * name of scope element to look for * @param expectedUri * of source referenced */ private void assertScope(final EObject context, final EReference reference, final QualifiedName expectedName, final URI expectedUri) { IScope scope = getScopeProvider().getScope(context, reference); Iterable<IEObjectDescription> descriptions = scope.getElements(expectedName); assertFalse("Description missing for: " + expectedName, Iterables.isEmpty(descriptions)); URI currentUri = null; for (IEObjectDescription desc : descriptions) { currentUri = desc.getEObjectURI(); if (currentUri.equals(expectedUri)) { return; } } assertEquals("Scope URI is not equal to expected URI", expectedUri, currentUri); }
Example 15
Source File: FileBasedWorkspaceInitializer.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override public XIWorkspaceConfig createWorkspaceConfig(URI workspaceBaseURI) { try { if (workspaceBaseURI.equals(knownWorkspaceBaseURI)) { return new N4JSWorkspaceConfig(workspaceBaseURI, n4jsCore); } // TODO is this correct if we have multiple workspace URIs? workspace.clear(); File workspaceRoot = URIUtils.toFile(workspaceBaseURI); Set<Path> allProjectLocations = projectDiscoveryHelper.collectAllProjectDirs(workspaceRoot.toPath()); List<FileURI> allProjectURIs = new ArrayList<>(); for (Path path : allProjectLocations) { allProjectURIs.add(new FileURI(path.toFile())); } registerProjectsToFileBasedWorkspace(allProjectURIs); return new N4JSWorkspaceConfig(workspaceBaseURI, n4jsCore); } finally { this.knownWorkspaceBaseURI = workspaceBaseURI; } }
Example 16
Source File: ImportHelper.java From fixflow with Apache License 2.0 | 5 votes |
/** * Looks up the list of import elements in the given Definitions object for an import of the given location. * * The location values of the import elements in the Definitions parameter are resolved against the * absolute URI of the resource that contains the Definitions object. The result is compared against * the absolute form of location. * @param referencingModel The Definitions object to search for an import element. * @param location The location to look for in {@link Import#getLocation()}. * @return The import element with a matching location value, or <code>null</code>, if none is found. */ public static Import findImportForLocation(Definitions referencingModel, URI location) { URI referencingURI = makeURICanonical(referencingModel.eResource().getURI()); URI referencedURI = makeURICanonical(location); for (Import imp : referencingModel.getImports()) { if (imp.getLocation() != null) { URI importUri = URI.createURI(imp.getLocation()).resolve(referencingURI); if (importUri.equals(referencedURI)) { // TODO: Also check that imp.getType() is BPMN return imp; } } } return null; }
Example 17
Source File: TestEventListener.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override public void descriptionsChanged(Event event) { URI expectedURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true); for (IResourceDescription.Delta delta : event.getDeltas()) { URI deltaURI = delta.getUri(); if (expectedURI.equals(deltaURI)) { eventFired = true; } } }
Example 18
Source File: DescriptionAddingContainer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public boolean hasResourceDescription(URI uri) { if (uri.equals(description.getURI())) return true; return delegate.hasResourceDescription(uri); }
Example 19
Source File: FilterUriContainer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public IResourceDescription getResourceDescription(URI uri) { if (uri.equals(filterMe)) return null; return delegate.getResourceDescription(uri); }
Example 20
Source File: StateBasedContainerTest.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public boolean contains(URI uri) { if (simulateEmpty) return false; return uri.equals(this.uri); }