当前位置: 首页>>代码示例>>Java>>正文


Java ImportNormalizer类代码示例

本文整理汇总了Java中org.eclipse.xtext.scoping.impl.ImportNormalizer的典型用法代码示例。如果您正苦于以下问题:Java ImportNormalizer类的具体用法?Java ImportNormalizer怎么用?Java ImportNormalizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ImportNormalizer类属于org.eclipse.xtext.scoping.impl包,在下文中一共展示了ImportNormalizer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getResourceScope

import org.eclipse.xtext.scoping.impl.ImportNormalizer; //导入依赖的package包/类
protected IScope getResourceScope(Resource res, EReference reference) {
	if (reference == TypesPackage.Literals.COMPLEX_TYPE__SUPER_TYPES)
		return super.getResourceScope(res, reference);
	EObject context = res.getContents().get(0);
	IScope globalScope = getGlobalScope(res, reference);
	List<ImportNormalizer> normalizers = getSuperTypeImports(res, reference);
	if (!normalizers.isEmpty()) {
		globalScope = createImportScope(globalScope, normalizers, null, reference.getEReferenceType(),
				isIgnoreCase(reference));
	}
	return getResourceScope(globalScope, context, reference);
}
 
开发者ID:Yakindu,项目名称:solidity-ide,代码行数:13,代码来源:SolidityImportedNamespaceAwareLocalScopeProvider.java

示例2: getSuperTypeImports

import org.eclipse.xtext.scoping.impl.ImportNormalizer; //导入依赖的package包/类
protected List<ImportNormalizer> getSuperTypeImports(Resource res, EReference reference) {
	List<ImportNormalizer> result = Lists.newArrayList();
	TreeIterator<EObject> allContents = res.getAllContents();
	while (allContents.hasNext()) {
		EObject next = allContents.next();
		if (next instanceof ContractDefinition) {
			ContractDefinition contract = (ContractDefinition) next;
			EList<ComplexType> superTypes = contract.getSuperTypes();
			for (ComplexType complexType : superTypes) {
				// if (complexType.eIsProxy() || complexType.getName() ==
				// null)
				// continue;
				ImportNormalizer resolver = createImportedNamespaceResolver(complexType.getName() + ".*", false);
				result.add(resolver);
			}
			allContents.prune();
		}
	}
	return result;
}
 
开发者ID:Yakindu,项目名称:solidity-ide,代码行数:21,代码来源:SolidityImportedNamespaceAwareLocalScopeProvider.java

示例3: createImportedNamespaceResolver

import org.eclipse.xtext.scoping.impl.ImportNormalizer; //导入依赖的package包/类
/**
 * Create a new {@link ImportNormalizer} for the given namespace.
 * @param namespace the namespace.
 * @param ignoreCase <code>true</code> if the resolver should be case insensitive.
 * @return a new {@link ImportNormalizer} or <code>null</code> if the namespace cannot be converted to a valid
 * qualified name.
 */
protected ImportNormalizer createImportedNamespaceResolver(final String namespace, boolean ignoreCase) {
	if (Strings.isEmpty(namespace))
		return null;
	QualifiedName importedNamespace = qualifiedNameConverter.toQualifiedName(namespace);
	if (importedNamespace == null || importedNamespace.isEmpty()) {
		return null;
	}
	boolean hasWildCard = ignoreCase ? 
			importedNamespace.getLastSegment().equalsIgnoreCase(getWildCard()) :
			importedNamespace.getLastSegment().equals(getWildCard());
	if (hasWildCard) {
		if (importedNamespace.getSegmentCount() <= 1)
			return null;
		return doCreateImportNormalizer(importedNamespace.skipLast(1), true, ignoreCase);
	} else {
		return doCreateImportNormalizer(importedNamespace, false, ignoreCase);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:26,代码来源:XbaseImportedNamespaceScopeProvider.java

示例4: createImportedNamespaceResolver

import org.eclipse.xtext.scoping.impl.ImportNormalizer; //导入依赖的package包/类
/**
 * Create a new {@link ImportNormalizer} for the given namespace.
 * @param namespace the namespace.
 * @param ignoreCase <code>true</code> if the resolver should be case insensitive.
 * @return a new {@link ImportNormalizer} or <code>null</code> if the namespace cannot be converted to a valid
 * qualified name.
 */
protected ImportNormalizer createImportedNamespaceResolver(final String namespace, boolean ignoreCase) {
	if (Strings.isEmpty(namespace))
		return null;
	QualifiedName importedNamespace = qualifiedNameConverter.toQualifiedName(namespace);
	if (importedNamespace == null || importedNamespace.isEmpty()) {
		return null;
	}
	boolean hasWildcard = ignoreCase ? 
			importedNamespace.getLastSegment().equalsIgnoreCase(getWildcard()) :
			importedNamespace.getLastSegment().equals(getWildcard());
	if (hasWildcard) {
		if (importedNamespace.getSegmentCount() <= 1)
			return null;
		return doCreateImportNormalizer(importedNamespace.skipLast(1), true, ignoreCase);
	} else {
		return doCreateImportNormalizer(importedNamespace, false, ignoreCase);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:26,代码来源:XImportSectionNamespaceScopeProvider.java

示例5: testResolve_ImportNormalizer

import org.eclipse.xtext.scoping.impl.ImportNormalizer; //导入依赖的package包/类
@Test public void testResolve_ImportNormalizer() throws Exception {
	QualifiedName xtextRelativeName = QualifiedName.create("xtext");
	QualifiedName ytextRelativeName = QualifiedName.create("ytext");
	QualifiedName xytextRelativeName = QualifiedName.create("xtext", "ytext");
	QualifiedName xytextRelativeNameWithDollar = QualifiedName.create("xtext$ytext");

	QualifiedName namespace = QualifiedName.create("org", "eclipse", "xtext");
	ImportNormalizer importNormalizer = new ImportNormalizer(namespace, false, false);
	assertEquals(namespace, importNormalizer.resolve(xtextRelativeName));
	assertEquals(null, importNormalizer.resolve(ytextRelativeName));
	assertEquals(null, importNormalizer.resolve(xytextRelativeName));
	assertEquals(null, importNormalizer.resolve(xytextRelativeNameWithDollar));
	
	ImportNormalizer wildcardImportNormalizer = new ImportNormalizer(namespace, true, false);
	assertEquals(namespace.append(xtextRelativeName), wildcardImportNormalizer.resolve(xtextRelativeName));
	assertEquals(namespace.append(ytextRelativeName), wildcardImportNormalizer.resolve(ytextRelativeName));
	assertEquals(namespace.append(xytextRelativeName), wildcardImportNormalizer.resolve(xytextRelativeName));
	assertEquals(namespace.append(xytextRelativeNameWithDollar), wildcardImportNormalizer.resolve(xytextRelativeNameWithDollar));

	ImportNormalizer xtextImportNormalizer = new ImportNormalizer(xtextRelativeName, false, false);
	assertEquals(xtextRelativeName, xtextImportNormalizer.resolve(xtextRelativeName));
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:ImportNormalizerTest.java

示例6: testResolve_ImportNormalizer

import org.eclipse.xtext.scoping.impl.ImportNormalizer; //导入依赖的package包/类
@Test public void testResolve_ImportNormalizer() throws Exception {
	QualifiedName xtextRelativeName = QualifiedName.create("xtext");
	QualifiedName ytextRelativeName = QualifiedName.create("ytext");
	QualifiedName xytextRelativeName = QualifiedName.create("xtext", "ytext");
	QualifiedName xytextRelativeNameWithDollar = QualifiedName.create("xtext$ytext");

	QualifiedName namespace = QualifiedName.create("org", "eclipse", "xtext");
	ImportNormalizer importNormalizer = createImportNormalizer(namespace, false);
	assertEquals(namespace, importNormalizer.resolve(xtextRelativeName));
	assertEquals(null, importNormalizer.resolve(ytextRelativeName));
	assertEquals(namespace.skipLast(1).append(xytextRelativeName), importNormalizer.resolve(xytextRelativeName));
	assertEquals(namespace.skipLast(1).append(xytextRelativeName), importNormalizer.resolve(xytextRelativeNameWithDollar));
	
	ImportNormalizer wildcardImportNormalizer = createImportNormalizer(namespace, true);
	assertEquals(namespace.append(xtextRelativeName), wildcardImportNormalizer.resolve(xtextRelativeName));
	assertEquals(namespace.append(ytextRelativeName), wildcardImportNormalizer.resolve(ytextRelativeName));
	assertEquals(namespace.append(xytextRelativeNameWithDollar), wildcardImportNormalizer.resolve(xytextRelativeName));
	assertEquals(namespace.append(xytextRelativeNameWithDollar), wildcardImportNormalizer.resolve(xytextRelativeNameWithDollar));

	ImportNormalizer xtextImportNormalizer = createImportNormalizer(xtextRelativeName, false);
	assertEquals(xtextRelativeName, xtextImportNormalizer.resolve(xtextRelativeName));
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:NestedTypeAwareImportNormalizerWithDotSeparatorTest.java

示例7: testDeesolve_NestedTypes

import org.eclipse.xtext.scoping.impl.ImportNormalizer; //导入依赖的package包/类
@Test public void testDeesolve_NestedTypes() throws Exception {
	QualifiedName mapEntry = QualifiedName.create("Map", "Entry");
	QualifiedName imported = QualifiedName.create("java", "util", "Map");
	QualifiedName fqnMapEntry = QualifiedName.create("java", "util", "Map", "Entry");
	QualifiedName fqnMaps = QualifiedName.create("java", "util", "Maps");
	QualifiedName fqnMapsInternal = QualifiedName.create("java", "util", "Maps", "Internal");

	ImportNormalizer importNormalizer = createImportNormalizer(imported, false);
	assertEquals(mapEntry, importNormalizer.deresolve(fqnMapEntry));
	assertEquals(null, importNormalizer.deresolve(fqnMaps));
	assertEquals(null, importNormalizer.deresolve(fqnMapsInternal));
	
	importNormalizer = createImportNormalizer(fqnMapEntry, false);
	assertEquals(QualifiedName.create("Entry"), importNormalizer.deresolve(fqnMapEntry));
	assertEquals(QualifiedName.create("Entry", "Nested"), importNormalizer.deresolve(QualifiedName.create("java", "util", "Map$Entry$Nested")));

	ImportNormalizer wildcardImportNormalizer = createImportNormalizer(QualifiedName.create("java", "util"), true);
	assertEquals(QualifiedName.create("Map", "Entry"), wildcardImportNormalizer.deresolve(fqnMapEntry));
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:20,代码来源:NestedTypeAwareImportNormalizerWithDotSeparatorTest.java

示例8: testResolve_ImportNormalizer

import org.eclipse.xtext.scoping.impl.ImportNormalizer; //导入依赖的package包/类
@Test public void testResolve_ImportNormalizer() throws Exception {
	QualifiedName xtextRelativeName = QualifiedName.create("xtext");
	QualifiedName ytextRelativeName = QualifiedName.create("ytext");
	QualifiedName xytextRelativeName = QualifiedName.create("xtext", "ytext");
	QualifiedName xytextRelativeNameWithDollar = QualifiedName.create("xtext$ytext");

	QualifiedName namespace = QualifiedName.create("org", "eclipse$xtext");
	ImportNormalizer importNormalizer = createImportNormalizer(namespace, false);
	assertEquals(namespace, importNormalizer.resolve(xtextRelativeName));
	assertEquals(null, importNormalizer.resolve(ytextRelativeName));
	assertEquals(namespace.skipLast(1).append("eclipse$xtext$ytext"), importNormalizer.resolve(xytextRelativeName));
	assertEquals(namespace.skipLast(1).append("eclipse$xtext$ytext"), importNormalizer.resolve(xytextRelativeNameWithDollar));
	
	ImportNormalizer wildcardImportNormalizer = createImportNormalizer(namespace, true);
	assertEquals(null, wildcardImportNormalizer.resolve(xtextRelativeName));
	assertEquals(null, wildcardImportNormalizer.resolve(ytextRelativeName));
	assertEquals(null, wildcardImportNormalizer.resolve(xytextRelativeName));
	assertEquals(null, wildcardImportNormalizer.resolve(xytextRelativeNameWithDollar));

	ImportNormalizer xytextRelativeNameWithDollarNormalizer = createImportNormalizer(xytextRelativeNameWithDollar, false);
	assertEquals(xytextRelativeNameWithDollar, xytextRelativeNameWithDollarNormalizer.resolve(xytextRelativeNameWithDollar));
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:NestedTypeAwareImportNormalizerTest.java

示例9: testDeresolve_ImportNormalizer

import org.eclipse.xtext.scoping.impl.ImportNormalizer; //导入依赖的package包/类
@Test public void testDeresolve_ImportNormalizer() throws Exception {
	QualifiedName namespace = QualifiedName.create("org", "eclipse", "xtext");
	QualifiedName xtextFQN = namespace.append("Xtext$Xtext");
	QualifiedName ytextFQN = namespace.skipLast(1).append("ytext");
	QualifiedName xytextFQN = namespace.append("ytext$ytext");

	ImportNormalizer importNormalizer = createImportNormalizer(xtextFQN, false);
	assertEquals(QualifiedName.create("Xtext"), importNormalizer.deresolve(xtextFQN));
	assertEquals(null, importNormalizer.deresolve(ytextFQN));
	assertEquals(null, importNormalizer.deresolve(xytextFQN));
	
	importNormalizer = createImportNormalizer(xytextFQN, false);
	assertEquals(null, importNormalizer.deresolve(xtextFQN));
	assertEquals(null, importNormalizer.deresolve(ytextFQN));
	assertEquals(QualifiedName.create("ytext"), importNormalizer.deresolve(xytextFQN));

	ImportNormalizer wildcardImportNormalizer = createImportNormalizer(xtextFQN, true);
	assertEquals(null, wildcardImportNormalizer.deresolve(xtextFQN));
	assertEquals(null, wildcardImportNormalizer.deresolve(ytextFQN));
	assertEquals(null, wildcardImportNormalizer.deresolve(xytextFQN));
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:22,代码来源:NestedTypeAwareImportNormalizerTest.java

示例10: testResolve_ImportNormalizer

import org.eclipse.xtext.scoping.impl.ImportNormalizer; //导入依赖的package包/类
@Test public void testResolve_ImportNormalizer() throws Exception {
	QualifiedName xtextRelativeName = QualifiedName.create("xtext");
	QualifiedName ytextRelativeName = QualifiedName.create("ytext");
	QualifiedName xytextRelativeName = QualifiedName.create("xtext", "ytext");
	QualifiedName xytextRelativeNameWithDollar = QualifiedName.create("xtext$ytext");

	QualifiedName namespace = QualifiedName.create("org", "eclipse", "xtext");
	ImportNormalizer importNormalizer = createImportNormalizer(namespace, false);
	assertEquals(namespace, importNormalizer.resolve(xtextRelativeName));
	assertEquals(null, importNormalizer.resolve(ytextRelativeName));
	assertEquals(namespace.skipLast(1).append(xytextRelativeNameWithDollar), importNormalizer.resolve(xytextRelativeName));
	assertEquals(namespace.skipLast(1).append(xytextRelativeNameWithDollar), importNormalizer.resolve(xytextRelativeNameWithDollar));
	
	ImportNormalizer wildcardImportNormalizer = createImportNormalizer(namespace, true);
	assertEquals(namespace.append(xtextRelativeName), wildcardImportNormalizer.resolve(xtextRelativeName));
	assertEquals(namespace.append(ytextRelativeName), wildcardImportNormalizer.resolve(ytextRelativeName));
	assertEquals(namespace.append(xytextRelativeNameWithDollar), wildcardImportNormalizer.resolve(xytextRelativeName));
	assertEquals(namespace.append(xytextRelativeNameWithDollar), wildcardImportNormalizer.resolve(xytextRelativeNameWithDollar));

	ImportNormalizer xtextImportNormalizer = createImportNormalizer(xtextRelativeName, false);
	assertEquals(xtextRelativeName, xtextImportNormalizer.resolve(xtextRelativeName));
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:NestedTypeAwareImportNormalizerWIthInvalidConfigTest.java

示例11: testDeresolve_ImportNormalizer

import org.eclipse.xtext.scoping.impl.ImportNormalizer; //导入依赖的package包/类
@Test public void testDeresolve_ImportNormalizer() throws Exception {
	QualifiedName namespace = QualifiedName.create("org", "eclipse", "xtext");
	QualifiedName xtextFQN = namespace.append("Xtext");
	QualifiedName ytextFQN = namespace.skipLast(1).append("ytext");
	QualifiedName xytextFQN = namespace.append("ytext");

	ImportNormalizer importNormalizer = createImportNormalizer(xtextFQN, false);
	assertEquals(QualifiedName.create("Xtext"), importNormalizer.deresolve(xtextFQN));
	assertEquals(null, importNormalizer.deresolve(ytextFQN));
	assertEquals(null, importNormalizer.deresolve(xytextFQN));
	
	importNormalizer = createImportNormalizer(xytextFQN, false);
	assertEquals(null, importNormalizer.deresolve(xtextFQN));
	assertEquals(null, importNormalizer.deresolve(ytextFQN));
	assertEquals(QualifiedName.create("ytext"), importNormalizer.deresolve(xytextFQN));

	ImportNormalizer wildcardImportNormalizer = createImportNormalizer(namespace, true);
	assertEquals(QualifiedName.create("Xtext"), wildcardImportNormalizer.deresolve(xtextFQN));
	assertEquals(null, wildcardImportNormalizer.deresolve(ytextFQN));
	assertEquals(QualifiedName.create("ytext"), wildcardImportNormalizer.deresolve(xytextFQN));
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:22,代码来源:NestedTypeAwareImportNormalizerWIthInvalidConfigTest.java

示例12: testDeesolve_NestedTypes

import org.eclipse.xtext.scoping.impl.ImportNormalizer; //导入依赖的package包/类
@Test public void testDeesolve_NestedTypes() throws Exception {
	QualifiedName mapEntry = QualifiedName.create("Map$Entry");
	QualifiedName imported = QualifiedName.create("java", "util", "Map");
	QualifiedName fqnMapEntry = QualifiedName.create("java", "util", "Map$Entry");
	QualifiedName fqnMaps = QualifiedName.create("java", "util", "Maps");
	QualifiedName fqnMapsInternal = QualifiedName.create("java", "util", "Maps$Internal");

	ImportNormalizer importNormalizer = createImportNormalizer(imported, false);
	assertEquals(mapEntry, importNormalizer.deresolve(fqnMapEntry));
	assertEquals(null, importNormalizer.deresolve(fqnMaps));
	assertEquals(null, importNormalizer.deresolve(fqnMapsInternal));
	
	importNormalizer = createImportNormalizer(fqnMapEntry, false);
	assertEquals(QualifiedName.create("Entry"), importNormalizer.deresolve(fqnMapEntry));
	assertEquals(QualifiedName.create("Entry$Nested"), importNormalizer.deresolve(QualifiedName.create("java", "util", "Map$Entry$Nested")));

	ImportNormalizer wildcardImportNormalizer = createImportNormalizer(QualifiedName.create("java", "util"), true);
	assertEquals(QualifiedName.create("Map$Entry"), wildcardImportNormalizer.deresolve(fqnMapEntry));
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:20,代码来源:NestedTypeAwareImportNormalizerWIthInvalidConfigTest.java

示例13: internalGetImportedNamespaceResolvers

import org.eclipse.xtext.scoping.impl.ImportNormalizer; //导入依赖的package包/类
@Override
protected List<ImportNormalizer> internalGetImportedNamespaceResolvers(final EObject context, final boolean ignoreCase) {
  final List<ImportNormalizer> resolvers = super.internalGetImportedNamespaceResolvers(context, ignoreCase);
  if ((context instanceof PackageDeclaration)) {
    QualifiedName _qualifiedName = this.getQualifiedNameConverter().toQualifiedName(((PackageDeclaration)context).getName());
    ImportNormalizer _importNormalizer = new ImportNormalizer(_qualifiedName, true, false);
    resolvers.add(_importNormalizer);
    EList<Import> _imports = ((PackageDeclaration)context).getImports();
    for (final Import imp : _imports) {
      {
        final QualifiedName name = this.getImportedNamespace(imp);
        ImportNormalizer _importNormalizer_1 = new ImportNormalizer(name, false, false);
        resolvers.add(_importNormalizer_1);
      }
    }
  }
  return resolvers;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:19,代码来源:FileAwareTestLanguageImportScopeProvider.java

示例14: getAliasedElements

import org.eclipse.xtext.scoping.impl.ImportNormalizer; //导入依赖的package包/类
@Override
protected Iterable<IEObjectDescription> getAliasedElements(Iterable<IEObjectDescription> candidates) {
	Multimap<QualifiedName, IEObjectDescription> keyToDescription = LinkedHashMultimap.create();
	Multimap<QualifiedName, ImportNormalizer> keyToNormalizer = HashMultimap.create();

	for (IEObjectDescription imported : candidates) {
		QualifiedName fullyQualifiedName = imported.getName();
		for (ImportNormalizer normalizer : normalizers) {
			QualifiedName alias = normalizer.deresolve(fullyQualifiedName);
			if (alias != null) {
				QualifiedName key = alias;
				if (isIgnoreCase()) {
					key = key.toLowerCase();
				}
				keyToDescription.put(key, new AliasedEObjectDescription(alias, imported));
				keyToNormalizer.put(key, normalizer);
			}
		}
	}

	return keyToDescription.values();
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:23,代码来源:DuplicateImportScope.java

示例15: getLocalElementsByName

import org.eclipse.xtext.scoping.impl.ImportNormalizer; //导入依赖的package包/类
@Override
protected Iterable<IEObjectDescription> getLocalElementsByName(QualifiedName name) {
	List<IEObjectDescription> result = newArrayList();
	ISelectable importFrom = getImportFrom();
	for (ImportNormalizer normalizer : normalizers) {
		final QualifiedName resolvedName = normalizer.resolve(name);
		if (resolvedName != null) {
			Iterable<IEObjectDescription> resolvedElements = importFrom.getExportedObjects(type, resolvedName,
					isIgnoreCase());
			for (IEObjectDescription resolvedElement : resolvedElements) {
				QualifiedName alias = normalizer.deresolve(resolvedElement.getName());
				if (alias == null)
					throw new IllegalStateException("Couldn't deresolve " + resolvedElement.getName()
							+ " with import " + normalizer);
				final AliasedEObjectDescription aliasedEObjectDescription = new AliasedEObjectDescription(alias,
						resolvedElement);
				result.add(aliasedEObjectDescription);
			}
		}
	}
	return result;
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:23,代码来源:DuplicateImportScope.java


注:本文中的org.eclipse.xtext.scoping.impl.ImportNormalizer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。