本文整理汇总了Java中org.eclipse.xtext.naming.QualifiedName类的典型用法代码示例。如果您正苦于以下问题:Java QualifiedName类的具体用法?Java QualifiedName怎么用?Java QualifiedName使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
QualifiedName类属于org.eclipse.xtext.naming包,在下文中一共展示了QualifiedName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLoadingBuiltInTypes
import org.eclipse.xtext.naming.QualifiedName; //导入依赖的package包/类
@SuppressWarnings("javadoc")
@Test
public void testLoadingBuiltInTypes() {
BuiltInTypeScope scope = BuiltInTypeScope.get(resourceSet);
IEObjectDescription anyType = scope.getSingleElement(QualifiedName.create("any"));
Assert.assertNotNull(anyType);
String s = "";
for (Resource resource : resourceSet.getResources()) {
if (resource.getErrors().size() > 0) {
for (Diagnostic d : resource.getErrors()) {
s += "\n " + d.getMessage() + " at " + resource.getURI() + ":" + d.getLine();
}
}
}
Assert.assertEquals("Resources definine built-in types must have no error."
, "", s);
}
示例2: getCheckedDescription
import org.eclipse.xtext.naming.QualifiedName; //导入依赖的package包/类
@Override
protected IEObjectDescription getCheckedDescription(String name, TMember member) {
IEObjectDescription description = EObjectDescription.create(member.getName(), member);
QualifiedName qn = QualifiedName.create(name);
for (IScope currSubScope : subScopes) {
IEObjectDescription subDescription = currSubScope.getSingleElement(qn);
boolean descrWithError = subDescription == null || subDescription instanceof IEObjectDescriptionWithError;
if (descrWithError) {
return createComposedMemberDescriptionWithErrors(description);
}
}
return description;
}
示例3: apply
import org.eclipse.xtext.naming.QualifiedName; //导入依赖的package包/类
@Override
public boolean apply(String nameWithPosition) {
String name = getNameFromNameWithPosition(nameWithPosition);
String position = getPositionFromNameWithPosition(nameWithPosition);
QualifiedName qualifiedName = converter.toQualifiedName(name);
IEObjectDescription desc = scope.getSingleElement(qualifiedName);
if (desc != null
&& !(desc instanceof IEObjectDescriptionWithError)
&& !(desc instanceof UnresolvableObjectDescription)) {
if (!Strings.isNullOrEmpty(position)) {
String nameWithPositionOfScopeELement = descriptionToNameWithPosition(currentURI, withLineNumber, desc);
String positionOfScopeElement = getPositionFromNameWithPosition(nameWithPositionOfScopeELement);
if (position.equals(positionOfScopeElement)) {
return true;
}
} else {
return true;
}
}
return false;
}
示例4: getItemsComparator
import org.eclipse.xtext.naming.QualifiedName; //导入依赖的package包/类
@Override
@SuppressWarnings({ "rawtypes", "unchecked", "static-access" })
protected Comparator getItemsComparator() {
return Ordering.natural().nullsLast().from(new Comparator() {
@Override
public int compare(final Object o1, final Object o2) {
if (o1 instanceof IEObjectDescription && o2 instanceof IEObjectDescription) {
final IEObjectDescription d1 = (IEObjectDescription) o1;
final IEObjectDescription d2 = (IEObjectDescription) o2;
final QualifiedName fqn1 = d1.getQualifiedName();
final QualifiedName fqn2 = d2.getQualifiedName();
if (null != fqn1 && null != fqn2) {
return nullToEmpty(fqn1.getLastSegment()).compareToIgnoreCase(
nullToEmpty(fqn2.getLastSegment()));
}
}
return Objects.hashCode(o1) - Objects.hashCode(o2);
}
});
}
示例5: getTypes
import org.eclipse.xtext.naming.QualifiedName; //导入依赖的package包/类
public ArrayList<IEObjectDescription> getTypes(final Extension ext) {
ArrayList<IEObjectDescription> _xblockexpression = null;
{
ArrayList<IEObjectDescription> res = new ArrayList<IEObjectDescription>();
EList<DataType> _types = ext.getTypes();
for (final DataType k : _types) {
res.add(EObjectDescription.create(QualifiedName.create(k.getName()), k));
}
EList<Extension> _import = ext.getImport();
for (final Extension importExtension : _import) {
EList<DataType> _types_1 = importExtension.getTypes();
for (final DataType k_1 : _types_1) {
res.add(EObjectDescription.create(QualifiedName.create(importExtension.getName(), k_1.getName()), k_1));
}
}
_xblockexpression = res;
}
return _xblockexpression;
}
示例6: createNamedImport
import org.eclipse.xtext.naming.QualifiedName; //导入依赖的package包/类
/** Creates a new named import of 'name' from 'module' */
private ImportDeclaration createNamedImport(String name, IN4JSProject contextProject, TExportableElement te,
Adapter nodelessMarker) {
TModule tmodule = te.getContainingModule();
IN4JSProject targetProject = core.findProject(te.eResource().getURI()).orNull();
String moduleQN;
if (targetProject != null && tmodule.getQualifiedName().toString().equals(targetProject.getMainModule())) {
// If the project has a main module, use project import instead.
moduleQN = targetProject.getProjectId();
} else {
// Standard case
moduleQN = te.getContainingModule().getQualifiedName();
}
QualifiedName qn = qualifiedNameConverter.toQualifiedName(moduleQN);
String firstSegment = qn.getFirstSegment();
IN4JSProject project = ImportSpecifierUtil.getDependencyWithID(firstSegment, contextProject);
return createImportDeclaration(qn, name, project, nodelessMarker, this::addNamedImport);
}
示例7: createNamespaceImport
import org.eclipse.xtext.naming.QualifiedName; //导入依赖的package包/类
/** Creates a new default import with name 'name' from object description. */
private ImportDeclaration createNamespaceImport(String name, IN4JSProject contextProject, TExportableElement te,
Adapter nodelessMarker) {
String moduleQN = te.getContainingModule().getQualifiedName();
QualifiedName qn = qualifiedNameConverter.toQualifiedName(moduleQN);
String firstSegment = qn.getFirstSegment();
IN4JSProject project = ImportSpecifierUtil.getDependencyWithID(firstSegment, contextProject);
if (project == null) {
IN4JSProject projectByNamespace = ImportSpecifierUtil.getDependencyWithID(name, contextProject);
IN4JSProject projectByEObject = core.findProject(te.eResource().getURI()).orNull();
if (projectByNamespace != null && projectByEObject != null
&& projectByNamespace.getLocation() == projectByEObject.getLocation())
project = projectByNamespace;
}
return createImportDeclaration(qn, name, project, nodelessMarker, this::addNamespaceImport);
}
示例8: getElements
import org.eclipse.xtext.naming.QualifiedName; //导入依赖的package包/类
@Override
public Iterable<IEObjectDescription> getElements(QualifiedName name) {
switch (computeImportType(name, this.contextProject)) {
case PROJECT_IMPORT:
final String firstSegment = name.getFirstSegment();
final IN4JSProject targetProject = findProject(firstSegment, contextProject);
return getElementsWithDesiredProjectID(ImportSpecifierUtil.getMainModuleOfProject(targetProject),
name.getFirstSegment());
case COMPLETE_IMPORT:
return getElementsWithDesiredProjectID(name.skipFirst(1), name.getFirstSegment());
case SIMPLE_IMPORT:
return parent.getElements(name);
default:
return Collections.emptyList();
}
}
示例9: getSingleLocalElementByName
import org.eclipse.xtext.naming.QualifiedName; //导入依赖的package包/类
/**
* Returns description for given element, name is assumed to consist of a single segment containing the simple name
* of the member. If no subScope contains a member with given name, null is returned. In other error cases (no or
* wrong access, mixed types etc.), {@link IEObjectDescriptionWithError}, and in particular
* {@link UnionMemberDescriptionWithError}, will be returned.
*/
@Override
protected IEObjectDescription getSingleLocalElementByName(QualifiedName qualifiedName) {
String name = qualifiedName.getLastSegment();
TMember member = getOrCreateComposedMember(name);
if (member == null) { // no such member, no need for "merging" descriptions, there won't be any
return null;
}
if (isErrorPlaceholder(member)) {
return createComposedMemberDescriptionWithErrors(EObjectDescription.create(member.getName(), member));
}
IEObjectDescription description = getCheckedDescription(name, member);
return description;
}
示例10: updateMainElementName
import org.eclipse.xtext.naming.QualifiedName; //导入依赖的package包/类
/**
* Update _entryPointModelElement with pretty name
*/
private void updateMainElementName(){
try {
Resource model = getModel();
EObject mainElement = null;
if(model != null){
mainElement = model.getEObject(_entryPointModelElementText.getText());
}
if(mainElement != null){
org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider nameprovider = new DefaultDeclarativeQualifiedNameProvider();
QualifiedName qname = nameprovider.getFullyQualifiedName(mainElement);
String objectName = qname != null ? qname.toString(): mainElement.toString();
String prettyName = objectName+ " : "+mainElement.eClass().getName();
_entryPointModelElementLabel.setText(prettyName);
}
} catch (Exception e) { }
}
示例11: toTextEdit
import org.eclipse.xtext.naming.QualifiedName; //导入依赖的package包/类
/**
* Add the necessary text edits to the accumulating result. Optionally return the offset of the alias.
*/
private AliasLocation toTextEdit(QualifiedName qualifiedName, String optionalAlias, int insertionOffset,
MultiTextEdit result) {
QualifiedName moduleName = qualifiedName.skipLast(1);
// the following code for enhancing existing ImportDeclarations makes use of the Xtext serializer, which is not
// yet compatible with fragments in Xtext grammars (as of Xtext 2.9.1) -> deactivated for now
// @formatter:off
// String moduleNameAsString = unquoted(syntacticModuleName(moduleName));
// for (ImportDeclaration existing : existingImports) {
// String importedModuleName = existing.getModule().getQualifiedName();
// if (moduleNameAsString.equals(importedModuleName)) {
// return enhanceExistingImportDeclaration(existing, qualifiedName, optionalAlias, result);
// }
// }
// @formatter:on
return addNewImportDeclaration(moduleName, qualifiedName, optionalAlias, insertionOffset, result);
}
示例12: registerDescription
import org.eclipse.xtext.naming.QualifiedName; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void registerDescription(final IResourceDescription description,
final Map<QualifiedName, Object> target) {
for (final IEObjectDescription object : description.getExportedObjects()) {
final QualifiedName lowerCase = object.getName().toLowerCase();
final Object existing = target.put(lowerCase, description);
if (existing != null && existing != description) {
Set<IResourceDescription> set = null;
if (existing instanceof IResourceDescription) {
// The linked hash set is the difference comparing to the super class.
set = Sets.newLinkedHashSetWithExpectedSize(2);
set.add((IResourceDescription) existing);
} else {
set = (Set<IResourceDescription>) existing;
}
set.add(description);
target.put(lowerCase, set);
}
}
}
示例13: getPolyfillTypesFromScope
import org.eclipse.xtext.naming.QualifiedName; //导入依赖的package包/类
private List<Type> getPolyfillTypesFromScope(QualifiedName fqn) {
IScope contextScope = polyfillScopeAccess.getRecordingPolyfillScope(contextResource);
List<Type> types = new ArrayList<>();
// contextScope.getElements(fqn) returns all polyfills, since shadowing is handled differently
// for them!
for (IEObjectDescription descr : contextScope.getElements(fqn)) {
Type polyfillType = (Type) descr.getEObjectOrProxy();
if (polyfillType.eIsProxy()) {
// TODO review: this seems odd... is this a test setup problem (since we do not use the
// index
// there and load the resource separately)?
polyfillType = (Type) EcoreUtil.resolve(polyfillType, contextResource);
if (polyfillType.eIsProxy()) {
throw new IllegalStateException("unexpected proxy");
}
}
types.add(polyfillType);
}
// }
return types;
}
示例14: isDirectPolyfill
import org.eclipse.xtext.naming.QualifiedName; //导入依赖的package包/类
/**
* Returns true if the given container type is a polyfill of the bottom type.
* <p>
* Note: we compare via FQN here, since the bottom type may not stem from the index but from the type model
* derived from the AST. In that case, the type instance, although similar, differs from the type instance
* from the index.
*/
private boolean isDirectPolyfill(ContainerType<?> containerType) {
if (!containerType.isStaticPolyfill() || !(bottomType instanceof TClassifier)) {
return false;
}
QualifiedName qn = N4TSQualifiedNameProvider.getStaticPolyfillFQN((TClassifier) bottomType,
qualifiedNameProvider);
if (containerType instanceof TClass) { // short cut
return qn.equals(qualifiedNameProvider.getFullyQualifiedName(containerType));
}
if (containerType instanceof TN4Classifier) {
return Iterables.any(((TN4Classifier) containerType).getSuperClassifierRefs(),
ref -> qn.equals(qualifiedNameProvider.getFullyQualifiedName(ref.getDeclaredType())));
}
return false;
}
示例15: findArtifact
import org.eclipse.xtext.naming.QualifiedName; //导入依赖的package包/类
/**
* @see IN4JSSourceContainer#findArtifact(QualifiedName, Optional)
*/
public URI findArtifact(IN4JSSourceContainer sourceContainer, QualifiedName name, Optional<String> fileExtension) {
final String ext = fileExtension.or("").trim();
final String extWithDot = !ext.isEmpty() && !ext.startsWith(".") ? "." + ext : ext;
final String pathStr = name.toString("/") + extWithDot; // no need for IQualifiedNameConverter here!
if (sourceContainer.isLibrary()) {
return null; // TODO support for finding artifacts in libraries
} else {
URI artifactLocation = workspace.findArtifactInFolder(sourceContainer.getLocation(), pathStr);
if (null == artifactLocation) {
artifactLocation = externalLibraryWorkspace.findArtifactInFolder(sourceContainer.getLocation(),
pathStr);
}
return artifactLocation;
}
}