String prefix = Schemas.getTargetPrefix( schema ); String file = new File( schema.eResource().getURI().toFileString() ).getName();
protected void clearPackage(Resource resource, EPackage pack) { Map<InternalEObject, URI> uris = Maps.newHashMap(); for(EClassifier classifier: pack.getEClassifiers()) { InternalEObject internalEObject = (InternalEObject) classifier; URI appendFragment = resource.getURI().appendFragment(resource.getURIFragment(internalEObject)); uris.put(internalEObject, appendFragment); } pack.getEClassifiers().clear(); for (Map.Entry<InternalEObject, URI> entry : uris.entrySet()) { entry.getKey().eSetProxyURI(entry.getValue()); } }
protected void checkSameResource(Resource eResource, Resource eResource2) { if (!LOG.isDebugEnabled()) return; if (eResource != eResource2 && eResource2 != null) { IllegalArgumentException e = new IllegalArgumentException("Cross resource associations are not supported (resources were "+eResource.getURI()+" and "+eResource2.getURI()); LOG.debug(e.getMessage(), e); } }
protected boolean isMatch(Resource resource) { if (uris.isEmpty()) return true; for (Pattern uriPattern : uris) { if (uriPattern.matcher(resource.getURI().toString()).matches()) return true; } return false; }
/** * Return true if the uri for * * @aResource is one of the known resource uris. */ public boolean isInterrestedInResource(Resource aResource) { return isInterrestedInResourceUri(aResource.getURI()); }
@Override protected void validateResourceState(Resource resource) { super.validateResourceState(resource); if (resource instanceof DerivedStateAwareResource && ((DerivedStateAwareResource) resource).isInitializing()) { LOG.error("Discouraged attempt to compute types during model inference. Resource was : "+resource.getURI(), new Exception()); } if (resource instanceof JvmMemberInitializableResource && ((JvmMemberInitializableResource) resource).isInitializingJvmMembers()) { LOG.error("Discouraged attempt to compute types during JvmMember initialization. Resource was : "+resource.getURI(), new Exception()); } }
public void after(final ActiveAnnotationContexts.AnnotationCallback phase) { boolean _equals = Objects.equal(phase, ActiveAnnotationContexts.AnnotationCallback.INDEXING); if (_equals) { this.identityCache.clear(); } boolean _equals_1 = Objects.equal(phase, ActiveAnnotationContexts.AnnotationCallback.GENERATION); if (_equals_1) { this.resourceChangeRegistry.discardCreateOrModifyInformation(this.xtendFile.eResource().getURI()); } }
public void addSaveAsUpdate(Resource resource, IRefactoringUpdateAcceptor updateAcceptor) throws IOException { IRefactoringDocument document = updateAcceptor.getDocument(resource.getURI()); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); resource.save(outputStream, null); String newContent = new String(outputStream.toByteArray(), encodingProvider.getEncoding(resource.getURI())); updateAcceptor.accept(resource.getURI(), new ReplaceEdit(0, document.getOriginalContents().length(), newContent)); }
protected static IFile internalGetFile(Resource aResource) { if (aResource != null) return getFile(aResource.getResourceSet(), aResource.getURI()); return null; }
protected boolean validate(final Resource resource) { String _lastSegment = resource.getURI().lastSegment(); String _plus = ("Starting validation for input: \'" + _lastSegment); String _plus_1 = (_plus + "\'"); StandaloneBuilder.LOG.info(_plus_1); final IResourceValidator resourceValidator = this.languageAccess(resource.getURI()).getResourceValidator(); final List<Issue> validationResult = resourceValidator.validate(resource, CheckMode.ALL, null); return this.issueHandler.handleIssue(validationResult); }
protected <T> T getService(Resource resource, Class<T> clazz) { if (resource instanceof XtextResource) { return ((XtextResource) resource).getResourceServiceProvider().get(clazz); } return getService(resource.getURI(), clazz); }
/** * Override this method for pre- or post-processing hooks. */ protected void processReferringResource(Resource referringResource, Iterable<IReferenceDescription> referenceDescriptions, ElementRenameArguments elementRenameArguments, IRefactoringUpdateAcceptor updateAcceptor) { ((XtextResource) referringResource).getCache().clear(referringResource); for (IReferenceDescription referenceDescription : referenceDescriptions) { createReferenceUpdate(referenceDescription, referringResource.getURI(), elementRenameArguments, referringResource.getResourceSet(), updateAcceptor); } }
protected static ModuleFile getModuleFileUsingAltDD(EARFile ear, Resource res) { if (res == null) return null; String uri = res.getURI().toString(); Module m = ear.getDeploymentDescriptor().getModuleHavingAltDD(uri); if (m == null) return null; ModuleRef ref = ear.getModuleRef(m); if (ref == null) return null; return ref.getModuleFile(); }
/** * @see Archive */ public void addOrReplaceMofResource(Resource aResource) { Resource existingResource = getResourceSet().getResource(aResource.getURI(), false); if (existingResource != null) getResourceSet().getResources().remove(existingResource); getResourceSet().getResources().add(aResource); }
protected URI getXtendFileLocation(GeneratedMetamodel metamodel) { URI uri = metamodel.eResource().getURI(); // check if uri can be used for resolve if (!uri.isHierarchical() || uri.isRelative()) return null; uri = URI.createURI(Strings.lastToken(getExtensionName(metamodel), "::")).appendFileExtension( XtendFile.FILE_EXTENSION).resolve(uri); return uri; }
private static URI getResolvedImportUri(Resource context, URI uri) { URI contextURI = context.getURI(); if (contextURI.isHierarchical() && !contextURI.isRelative() && (uri.isRelative() && !uri.isEmpty())) { uri = uri.resolve(contextURI); } return uri; }
protected URI getNormalizedURI(Resource resource) { URI uri = resource.getURI(); if (uri != null && !uri.isPlatform() && resource.getResourceSet() != null) return resource.getResourceSet().getURIConverter().normalize(uri); else return uri; }
private static URI getResolvedImportUri(Resource context, URI uri) { URI contextURI = context.getURI(); if (contextURI.isHierarchical() && !contextURI.isRelative() && (uri.isRelative() && !uri.isEmpty())) { uri = uri.resolve(contextURI); } return uri; } }
protected VersionedTextDocumentIdentifier toVersionedTextDocumentIdentifier(final ILanguageServerAccess.Context context) { VersionedTextDocumentIdentifier _versionedTextDocumentIdentifier = new VersionedTextDocumentIdentifier(); final Procedure1<VersionedTextDocumentIdentifier> _function = (VersionedTextDocumentIdentifier it) -> { it.setUri(this._uriExtensions.toUriString(context.getResource().getURI())); it.setVersion(context.getDocument().getVersion()); }; return ObjectExtensions.<VersionedTextDocumentIdentifier>operator_doubleArrow(_versionedTextDocumentIdentifier, _function); }