@Override public ITextRegionWithLineInformation getTextRegion(final EObject obj) { if ((obj == null)) { return ITextRegionWithLineInformation.EMPTY_REGION; } final ITextRegion textRegion = this.locationInFileProvider.getSignificantTextRegion(obj); return this.toTextRegionWithLineInformation(obj, textRegion); }
protected void computeObjectFolding(EObject eObject, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor) { ITextRegion region = locationInFileProvider.getFullTextRegion(eObject); if (region != null) { ITextRegion significant = locationInFileProvider.getSignificantTextRegion(eObject); if (significant == null) throw new NullPointerException("significant region may not be null"); int offset = region.getOffset(); foldingRegionAcceptor.accept(offset, region.getLength(), significant); } }
protected ITextRegion getOriginalNameRegion(final EObject targetElement, EAttribute nameAttribute) { return locationInFileProvider.getFullTextRegion(targetElement, nameAttribute, 0); }
/** * Returns with the {@link Location location} that represents the {@link ILocationInFileProvider#getFullTextRegion full text region} * of the argument. * * @since 2.16 */ public Location newFullLocation(final EObject object) { final Resource resource = object.eResource(); final ITextRegion textRegion = this.locationInFileProvider.getFullTextRegion(object); return this.newLocation(resource, textRegion); }
protected RefactoringStatusContext createContext(EObject eObject) { if (eObject != null) { ITextRegion textRegion = locationInFileProvider.getSignificantTextRegion(eObject); return createContext(eObject, textRegion); } return null; }
protected void acceptPreferredType(EObject owner, EReference referenceToTypeOrMember) { ITextRegion refRegion = locationInFileProvider.getFullTextRegion(owner, referenceToTypeOrMember, 0); if (refRegion.getLength() > 0) { IParseResult parseResult = resource.getParseResult(); XAbstractFeatureCall root = typeLiteralHelper.getRootTypeLiteral(featureCall); if (root != null) { ITextRegion region = locationInFileProvider.getSignificantTextRegion(root); if (region.getOffset() == refRegion.getOffset()) { suffix = completeText.substring(region.getOffset(), region.getOffset() + region.getLength());
@Override public ITreeAppendable trace(EObject object, EStructuralFeature feature, int indexInList) { ITextRegion textRegion = locationProvider.getFullTextRegion(object, feature, indexInList); if (!(textRegion instanceof ITextRegionWithLineInformation)) { if (log.isDebugEnabled()) log.debug("location provider returned text region without line information. Synthesized dummy data.", new Exception()); textRegion = new TextRegionWithLineInformation(textRegion.getOffset(), textRegion.getLength(), 0, 0); } if (textRegion == ITextRegion.EMPTY_REGION) { return this; } ILocationData newData = createLocationData(traceURIConverter, object, (ITextRegionWithLineInformation) textRegion); return trace(Collections.singleton(newData), false); }
@Override public ITextRegionWithLineInformation getTextRegion(final EObject owner, final EStructuralFeature feature, final int indexInList) { if ((owner == null)) { return ITextRegionWithLineInformation.EMPTY_REGION; } final ITextRegion textRegion = this.locationInFileProvider.getSignificantTextRegion(owner, feature, indexInList); return this.toTextRegionWithLineInformation(owner, textRegion); }
protected void acceptPreferredType(JvmTypeReference ref) { if (ref instanceof JvmParameterizedTypeReference) { acceptPreferredType(ref, JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE); } else { acceptType(ref.getType(), locationInFileProvider.getFullTextRegion(ref)); } }
protected void setCurrentAppendable(/* @Nullable */ RichStringLiteral origin) { if (currentAppendable == null && origin != null) { ITextRegionWithLineInformation region = (ITextRegionWithLineInformation) getLocationInFileProvider().getSignificantTextRegion(origin, XbasePackage.Literals.XSTRING_LITERAL__VALUE, 0); currentAppendable = appendable.trace(new LocationData(region, null), true); } }
public EStructuralFeatureNode createEStructuralFeatureNode(IOutlineNode parentNode, EObject owner, EStructuralFeature feature, ImageDescriptor imageDescriptor, Object text, boolean isLeaf) { boolean isFeatureSet = owner.eIsSet(feature); EStructuralFeatureNode eStructuralFeatureNode = new EStructuralFeatureNode(owner, feature, parentNode, imageDescriptor, text, isLeaf || !isFeatureSet); if (isFeatureSet) { ITextRegion region = locationInFileProvider.getFullTextRegion(owner, feature, 0); if (feature.isMany()) { int numValues = ((Collection<?>) owner.eGet(feature)).size(); ITextRegion fullTextRegion = locationInFileProvider.getFullTextRegion(owner, feature, numValues - 1); if(fullTextRegion != null) region = region.merge(fullTextRegion); } eStructuralFeatureNode.setTextRegion(region); } return eStructuralFeatureNode; }
public Location newLocation(final EObject object) { final Resource resource = object.eResource(); final ITextRegion textRegion = this.locationInFileProvider.getSignificantTextRegion(object); return this.newLocation(resource, textRegion); }
protected EStructuralFeatureNode createEStructuralFeatureNode(IOutlineNode parentNode, EObject owner, EStructuralFeature feature, Image image, Object text, boolean isLeaf) { boolean isFeatureSet = owner.eIsSet(feature); EStructuralFeatureNode eStructuralFeatureNode = new EStructuralFeatureNode(owner, feature, parentNode, image, text, isLeaf || !isFeatureSet); if (isFeatureSet) { ITextRegion region = locationInFileProvider.getFullTextRegion(owner, feature, 0); if (feature.isMany()) { int numValues = ((Collection<?>) owner.eGet(feature)).size(); ITextRegion fullTextRegion = locationInFileProvider.getFullTextRegion(owner, feature, numValues - 1); if (fullTextRegion != null) region = region.merge(fullTextRegion); } eStructuralFeatureNode.setTextRegion(region); } return eStructuralFeatureNode; }
public Location newLocation(final EObject owner, final EStructuralFeature feature, final int indexInList) { final Resource resource = owner.eResource(); final ITextRegion textRegion = this.locationInFileProvider.getSignificantTextRegion(owner, feature, indexInList); return this.newLocation(resource, textRegion); } }
private static ILocationData createLocationData(ITraceURIConverter converter, ILocationInFileProvider locationProvider, EObject object, ILocationInFileProviderExtension.RegionDescription query, boolean skipEmpty) { ITextRegion textRegion = locationProvider instanceof ILocationInFileProviderExtension ? ((ILocationInFileProviderExtension) locationProvider).getTextRegion(object, query) : locationProvider.getFullTextRegion(object); if (!(textRegion instanceof ITextRegionWithLineInformation)) { if (log.isDebugEnabled()) log.debug("location provider returned text region without line information.", new Exception()); if (textRegion != null) textRegion = new TextRegionWithLineInformation(textRegion.getOffset(), textRegion.getLength(), 0, 0); else return null; } // usually we want to skip empty regions but if the root region is empty, we want to use it to store the path information along // with the empty offset / length pair if (skipEmpty && textRegion == ITextRegion.EMPTY_REGION) { return null; } ILocationData newData = createLocationData(converter, object, (ITextRegionWithLineInformation) textRegion); return newData; }
public EObject getElementAt(final XtextResource resource, final int offset) { EObject crossLinkedEObject = this._eObjectAtOffsetHelper.resolveCrossReferencedElementAt(resource, offset); if ((crossLinkedEObject != null)) { return crossLinkedEObject; } else { EObject containedEObject = this._eObjectAtOffsetHelper.resolveContainedElementAt(resource, offset); if ((containedEObject != null)) { final ITextRegion nameRegion = this._iLocationInFileProvider.getSignificantTextRegion(containedEObject); boolean _contains = nameRegion.contains(offset); if (_contains) { return containedEObject; } } } return null; } }
protected ITextRegion getTextRegion(EObject eObject) { if (eObject == null) return null; IParseResult parseResult = ((XtextResource)eObject.eResource()).getParseResult(); if (parseResult == null) return null; ICompositeNode rootNode = parseResult.getRootNode(); Map<ILeafNode, EObject> comments = commentAssociater.associateCommentsWithSemanticEObjects(eObject, singleton(rootNode)); final ITextRegion result = locationProvider.getFullTextRegion(eObject); int start = result.getOffset(); int end = result.getOffset() + result.getLength(); for (Entry<ILeafNode, EObject> entry : comments.entrySet()) { if (entry.getValue() == eObject) { ILeafNode node = entry.getKey(); if (node.getTotalOffset() < start) { start = node.getTotalOffset(); } if (node.getTotalEndOffset() > end) { end = node.getTotalEndOffset(); } } } return new TextRegion(start, end-start); }
final ITextRegion region = locationInFileProvider.getSignificantTextRegion(source, eReference, index); if (!isNullOrEmpty(region)) { resultBuilder.add(textRegionTransformer.apply(docSupplier.get(), region, DocumentHighlightKind.Read)); final ITextRegion region = locationInFileProvider.getSignificantTextRegion(selectedElement); if (!isNullOrEmpty(region)) { resultBuilder.add(textRegionTransformer.apply(docSupplier.get(), region, DocumentHighlightKind.Write));
protected void createReferenceUpdate(EObject referringElement, URI referringResourceURI, EReference reference, int indexInList, EObject newTargetElement, IRefactoringUpdateAcceptor updateAcceptor) { if (!transientValueService.isTransient(referringElement, reference, indexInList)) { ITextRegion referenceTextRegion = locationInFileProvider.getFullTextRegion(referringElement, reference, indexInList); CrossReference crossReference = getCrossReference(referringElement, referenceTextRegion.getOffset()); if (crossReference != null) { RefTextEvaluator refTextComparator = getRefTextEvaluator(referringElement, referringResourceURI, reference, indexInList, newTargetElement); String newReferenceText = crossReferenceSerializer.getCrossRefText(referringElement, crossReference, newTargetElement, refTextComparator, referenceTextRegion, updateAcceptor.getRefactoringStatus()); createTextChange(referenceTextRegion, newReferenceText, referringElement, newTargetElement, reference, referringResourceURI, updateAcceptor); } } }
final ITextRegion region = locationInFileProvider.getSignificantTextRegion(containedElement); return !isNullOrEmpty(region)