本文整理汇总了Java中org.eclipse.xtext.resource.IEObjectDescription.getUserData方法的典型用法代码示例。如果您正苦于以下问题:Java IEObjectDescription.getUserData方法的具体用法?Java IEObjectDescription.getUserData怎么用?Java IEObjectDescription.getUserData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.resource.IEObjectDescription
的用法示例。
在下文中一共展示了IEObjectDescription.getUserData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: equalDescriptions
import org.eclipse.xtext.resource.IEObjectDescription; //导入方法依赖的package包/类
private boolean equalDescriptions(IEObjectDescription newDescription,
IEObjectDescription oldDescription, URI uri) {
if (!newDescription.getQualifiedName().equals(oldDescription.getQualifiedName())) {
return false;
}
if (!newDescription.getEClass().equals(oldDescription.getEClass())) {
return false;
}
if (!newDescription.getEObjectURI().equals(oldDescription.getEObjectURI())) {
return false;
}
if (TypesPackage.Literals.TMODULE == newDescription.getEClass()) {
String newModule = newDescription.getUserData(UserdataMapper.USERDATA_KEY_SERIALIZED_SCRIPT);
String oldModule = oldDescription.getUserData(UserdataMapper.USERDATA_KEY_SERIALIZED_SCRIPT);
if (newModule == null || oldModule == null) {
return true;
}
if (!newModule.equals(oldModule)) {
TModule newModuleObj = UserdataMapper.getDeserializedModuleFromDescription(newDescription, uri);
TModule oldModuleObj = UserdataMapper.getDeserializedModuleFromDescription(oldDescription, uri);
// we deserialize the TModules and ignore the MD5 Hash
newModuleObj.setAstMD5("");
oldModuleObj.setAstMD5("");
if (!EcoreUtilN4.equalsNonResolving(newModuleObj, oldModuleObj)) {
return false;
}
}
}
// todo compare user data if module
return true;
}
示例2: getDeserializedModuleFromDescription
import org.eclipse.xtext.resource.IEObjectDescription; //导入方法依赖的package包/类
/**
* Reads the TModule stored in the given IEObjectDescription.
*/
public static TModule getDeserializedModuleFromDescription(IEObjectDescription eObjectDescription, URI uri) {
final String serializedData = eObjectDescription.getUserData(USERDATA_KEY_SERIALIZED_SCRIPT);
if (Strings.isNullOrEmpty(serializedData)) {
return null;
}
final XMIResource xres = new XMIResourceImpl(uri);
try {
final boolean binary = !serializedData.startsWith("<");
final ByteArrayInputStream bais = new ByteArrayInputStream(
binary ? XMLTypeFactory.eINSTANCE.createBase64Binary(serializedData)
: serializedData.getBytes(TRANSFORMATION_CHARSET_NAME));
xres.load(bais, getOptions(uri, binary));
} catch (Exception e) {
LOGGER.warn("error deserializing module from IEObjectDescription: " + uri); //$NON-NLS-1$
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("error deserializing module from IEObjectDescription=" + eObjectDescription
+ ": " + uri, e); //$NON-NLS-1$
}
// fail safe, because not uncommon (serialized data might have been created with an old version of the N4JS
// IDE, so the format could be out of date (after an update of the IDE))
return null;
}
final List<EObject> contents = xres.getContents();
if (contents.isEmpty() || !(contents.get(0) instanceof TModule)) {
return null;
}
final TModule module = (TModule) contents.get(0);
xres.getContents().clear();
return module;
}
示例3: readDependenciesFromDescription
import org.eclipse.xtext.resource.IEObjectDescription; //导入方法依赖的package包/类
/**
* Reads the list of direct dependencies of the resource R represented by the given resource description from its
* user data. Returns a list of strings, in which each string represents the URI of a resource D that is a direct
* dependency of R (i.e. R depends on D).
* <p>
* Definition: a resource R <em>directly depends on</em> a resource D, if R imports an identifiable element from D.
* In this case, we also say D <em>is a dependency of</em> R.
*
* Returns none if the information is missing in the resource description.
*/
public static Optional<List<String>> readDependenciesFromDescription(IResourceDescription description) {
final Iterable<IEObjectDescription> modules = description
.getExportedObjectsByType(TypesPackage.Literals.TMODULE);
for (IEObjectDescription module : modules) {
final String dependenciesStr = module.getUserData(USERDATA_KEY_DEPENDENCIES);
if (dependenciesStr != null) {
return Optional.of(splitter.splitToList(dependenciesStr));
}
}
return Optional.empty();
}
示例4: isShadowed
import org.eclipse.xtext.resource.IEObjectDescription; //导入方法依赖的package包/类
/**
* {@inheritDoc} Always returns false for polyfills, otherwise super method is called.
*/
@Override
protected boolean isShadowed(IEObjectDescription fromParent) {
if (fromParent != null) {
String userData = fromParent.getUserData(N4JSResourceDescriptionStrategy.MAIN_MODULE_KEY);
if (userData != null) {
boolean describesMainModule = Boolean.parseBoolean(userData);
if (describesMainModule) {
return false;// main modules are never shadowed
}
}
}
return super.isShadowed(fromParent);
}
示例5: hasSerializedModule
import org.eclipse.xtext.resource.IEObjectDescription; //导入方法依赖的package包/类
/**
* Checks whether the given {@link IEObjectDescription} instance contains a serialized types module in its user
* data.
* <p>
* Note that this method does not check whether the serialized types module is an empty string, or whether the
* deserialized module is empty.
* </p>
*
* @param eObjectDescription
* the object to check
* @return <code>true</code> if the given object description contains a serialized types module and
* <code>false</code> otherwise
*/
public static boolean hasSerializedModule(IEObjectDescription eObjectDescription) {
return eObjectDescription.getUserData(USERDATA_KEY_SERIALIZED_SCRIPT) != null;
}