org.eclipse.xtext.xbase.jvmmodel.IJvmModelAssociations Java Examples

The following examples show how to use org.eclipse.xtext.xbase.jvmmodel.IJvmModelAssociations. 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: ErrorTreeAppendable.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public ErrorTreeAppendable(SharedAppendableState state, 
		ITraceURIConverter converter,
		ILocationInFileProvider locationProvider,
		IJvmModelAssociations jvmModelAssociations,
		Set<ILocationData> sourceLocations, 
		boolean useForDebugging) {
	super(state, converter, locationProvider, jvmModelAssociations, sourceLocations, useForDebugging);
	encoder = getOrCreateURIEncoder();
}
 
Example #2
Source File: InferredJvmModelUtil.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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;
  }
}
 
Example #3
Source File: InferredJvmModelUtil.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #4
Source File: InferredJvmModelUtil.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #5
Source File: InferredJvmModelUtil.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #6
Source File: TreeAppendable.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
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();
}
 
Example #7
Source File: TreeAppendable.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
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);
}
 
Example #8
Source File: TreeAppendable.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
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);
}
 
Example #9
Source File: TreeAppendable.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @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);
}
 
Example #10
Source File: TreeAppendable.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
private static Set<ILocationData> createAllLocationData(ITraceURIConverter converter, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, EObject object, ILocationInFileProviderExtension.RegionDescription query) {
	return createAllLocationData(converter, locationProvider, jvmModelAssociations, object, query, true);
}
 
Example #11
Source File: CommonTypeComputationServices.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public IJvmModelAssociations getJvmModelAssociations() {
	return jvmModelAssociations;
}
 
Example #12
Source File: ErrorTreeAppendable.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected TreeAppendable createChild(SharedAppendableState state, ILocationInFileProvider locationProvider, 
		IJvmModelAssociations jvmModelAssociations, Set<ILocationData> newData, boolean useForDebugging) {
	return this;
}
 
Example #13
Source File: DefaultJvmModelRenameStrategy.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected IJvmModelAssociations getJvmModelAssociations() {
	return jvmModelAssociations;
}
 
Example #14
Source File: JvmModelDependentElementsCalculator.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected IJvmModelAssociations getJvmModelAssociations() {
	return jvmModelAssociations;
}
 
Example #15
Source File: XImportSectionNamespaceScopeProvider.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected IJvmModelAssociations getAssociations() {
	return associations;
}
 
Example #16
Source File: CommonTypeComputationServices.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public void setJvmModelAssociations(IJvmModelAssociations jvmModelAssociations) {
	this.jvmModelAssociations = jvmModelAssociations;
}
 
Example #17
Source File: InferredJvmModelUtil.java    From dsl-devkit with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * 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;
}