public TreeAppendable(ImportManager importManager, ITraceURIConverter converter, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, EObject source, String indentation, String lineSeparator) { this( new SharedAppendableState(indentation, lineSeparator, importManager, source.eResource()), converter, locationProvider, jvmModelAssociations, source); }
protected TreeAppendable(SharedAppendableState state, ITraceURIConverter converter, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, EObject source) { this( state, converter, locationProvider, jvmModelAssociations, createAllLocationData( converter, locationProvider, jvmModelAssociations, source, ILocationInFileProviderExtension.RegionDescription.INCLUDING_COMMENTS, false), // don't skip empty root regions false); }
protected TreeAppendable(SharedAppendableState state, final ITraceURIConverter converter, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, Set<ILocationData> sourceLocations, boolean useForDebugging) { this.state = state; this.traceURIConverter = converter; this.locationProvider = locationProvider; this.jvmModelAssociations = jvmModelAssociations; this.children = Lists.newArrayList(); this.locationData = sourceLocations; this.useForDebugging = useForDebugging; this.lightweightTypeReferenceSerializer = createLightweightTypeReferenceSerializer(); }
public ErrorTreeAppendable(SharedAppendableState state, ITraceURIConverter converter, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, Set<ILocationData> sourceLocations, boolean useForDebugging) { super(state, converter, locationProvider, jvmModelAssociations, sourceLocations, useForDebugging); encoder = getOrCreateURIEncoder(); }
/** * Returns an inferred model element of a given type for a given source element. * * @param <T> * the type of inferred model element to return * @param source * the source of the inferred model element, must not be {@code null} * @param clazz * the class of the inferred model element to return, must not be {@code null} * @return the inferred model element, or {@code null} if there is none */ @SuppressWarnings("unchecked") public static <T extends EObject> T getInferredElement(final EObject source, final Class<T> clazz) { final IJvmModelAssociations modelAssociations = getModelAssociations(source); if (modelAssociations != null) { for (EObject eObj : modelAssociations.getJvmElements(source)) { if (clazz.isInstance(eObj)) { return (T) eObj; } } } return null; }
/** * Returns all inferred model elements of a given type for a given source element. * * @param <T> * the type of inferred model elements to return * @param source * the source of the inferred model elements, must not be {@code null} * @param clazz * the class of the inferred model elements to return, must not be {@code null} * @return the set of inferred model elements or an empty set if there are none */ @SuppressWarnings("unchecked") public static <T extends EObject> Set<T> getInferredElements(final EObject source, final Class<T> clazz) { final IJvmModelAssociations modelAssociations = getModelAssociations(source); if (modelAssociations != null) { final Set<EObject> inferredModelElements = modelAssociations.getJvmElements(source); return (Set<T>) Sets.filter(inferredModelElements, new Predicate<EObject>() { public boolean apply(final EObject input) { return clazz.isInstance(input); } }); } return Collections.emptySet(); }
/** * Returns all inferred model elements for a given source element. * * @param source * the source of the inferred model elements, must not be {@code null} * @return the set of inferred model elements or an empty set if there are none */ public static Set<EObject> getInferredElements(final EObject source) { final IJvmModelAssociations modelAssociations = getModelAssociations(source); if (modelAssociations != null) { return modelAssociations.getJvmElements(source); } return Collections.emptySet(); }
/** * Gets the primary source model element that inferred a given {@link EObject}, if there is one. * * @param eObject * the object to get the primary source for, must not be {@code null} * @return the primary source model element for the given {link EObject}, or null if there is none */ public static EObject getPrimarySource(final EObject eObject) { final IJvmModelAssociations modelAssociations = getModelAssociations(eObject); if (modelAssociations != null) { return modelAssociations.getPrimarySourceElement(eObject); } else { return null; } }
protected IJvmModelAssociations getAssociations() { return associations; }
/** * @since 2.4 */ protected TreeAppendable createChild(SharedAppendableState state, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, Set<ILocationData> newData, boolean useForDebugging) { return new TreeAppendable(state, traceURIConverter, locationProvider, jvmModelAssociations, newData, useForDebugging); }
private static Set<ILocationData> createAllLocationData(ITraceURIConverter converter, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, EObject object, ILocationInFileProviderExtension.RegionDescription query) { return createAllLocationData(converter, locationProvider, jvmModelAssociations, object, query, true); }
@Override protected TreeAppendable createChild(SharedAppendableState state, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, Set<ILocationData> newData, boolean useForDebugging) { return this; }
@Pure public IJvmModelAssociations getJvmModelAssociations() { return this.jvmModelAssociations; }
public void setJvmModelAssociations(final IJvmModelAssociations jvmModelAssociations) { this.jvmModelAssociations = jvmModelAssociations; }
/** * Returns the model associations corresponding to an EObject. * <p> * Model associations are maintained per resource. This returns the model associations for the EObject's containing resource. * </p> * * @param eObject * the object to get the model associations from, must not be {@code null} * @return the model associations for {@code eObject}, or null if there are none */ public static IJvmModelAssociations getModelAssociations(final EObject eObject) { if (eObject != null) { final Resource resource = eObject.eResource(); if (resource instanceof XtextResource) { return ((XtextResource) resource).getResourceServiceProvider().get(IJvmModelAssociations.class); } } return null; }