• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java XImportDeclaration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: checkConflicts

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
protected void checkConflicts(XImportSection importSection, final Map<String, List<XImportDeclaration>> imports,
		final Map<String, JvmType> importedNames) {
	for (JvmDeclaredType declaredType : importsConfiguration.getLocallyDefinedTypes((XtextResource)importSection.eResource())) {
		if(importedNames.containsKey(declaredType.getSimpleName())){
			JvmType importedType = importedNames.get(declaredType.getSimpleName());
			if (importedType != declaredType  && importedType.eResource() != importSection.eResource()) {
				List<XImportDeclaration> list = imports.get(importedType.getIdentifier());
				if (list != null) {
					for (XImportDeclaration importDeclaration: list ) {
						error("The import '" 
								+ importedType.getIdentifier() 
								+ "' conflicts with a type defined in the same file", 
								importDeclaration, null, IssueCodes.IMPORT_CONFLICT);
					}
				}
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:20,代码来源:XbaseValidator.java


示例2: RewritableImportSection

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
public RewritableImportSection(XtextResource resource, IImportsConfiguration importsConfiguration, XImportSection originalImportSection,
		String lineSeparator, ImportSectionRegionUtil regionUtil, IValueConverter<String> nameConverter) {
	this.importsConfiguration = importsConfiguration;
	this.resource = resource;
	this.lineSeparator = lineSeparator;
	this.regionUtil = regionUtil;
	this.nameValueConverter = nameConverter;
	this.implicitlyImportedPackages = importsConfiguration.getImplicitlyImportedPackages(resource);
	this.importRegion = regionUtil.computeRegion(resource);
	if (originalImportSection != null) {
		for (XImportDeclaration originalImportDeclaration : originalImportSection.getImportDeclarations()) {
			this.originalImportDeclarations.add(originalImportDeclaration);
			JvmDeclaredType importedType = originalImportDeclaration.getImportedType();
			if (originalImportDeclaration.isStatic()) {
				String memberName = originalImportDeclaration.getMemberName();
				if (originalImportDeclaration.isExtension()) {
					Maps2.putIntoSetMap(importedType, memberName, staticExtensionImports);
				} else {
					Maps2.putIntoSetMap(importedType, memberName, staticImports);
				}
			} else if (importedType != null) {
				Maps2.putIntoListMap(importedType.getSimpleName(), importedType, plainImports);
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:27,代码来源:RewritableImportSection.java


示例3: removeImport

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
public boolean removeImport(JvmDeclaredType type) {
	List<XImportDeclaration> addedImportDeclarationsToRemove = findOriginalImports(type, null, addedImportDeclarations, false, false);
	addedImportDeclarations.removeAll(addedImportDeclarationsToRemove);

	List<XImportDeclaration> originalImportDeclarationsToRemove = findOriginalImports(type, null, originalImportDeclarations, false, false);
	removedImportDeclarations.addAll(originalImportDeclarationsToRemove);

	for (Map.Entry<String, List<JvmDeclaredType>> entry : plainImports.entrySet()) {
		List<JvmDeclaredType> values = entry.getValue();
		if (values.size() == 1) {
			if (values.get(0) == type) {
				plainImports.remove(type.getSimpleName());
				return true;
			}
		}
		Iterator<JvmDeclaredType> iterator = values.iterator();
		while (iterator.hasNext()) {
			JvmDeclaredType value = iterator.next();
			if (value == type) {
				iterator.remove();
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:27,代码来源:RewritableImportSection.java


示例4: addStaticImport

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
public boolean addStaticImport(JvmDeclaredType type, String memberName) {
	if (hasStaticImport(staticImports, type, memberName)) {
		return false;
	}
	Maps2.putIntoSetMap(type, memberName, staticImports);
	XImportDeclaration importDeclaration = XtypeFactory.eINSTANCE.createXImportDeclaration();
	importDeclaration.setImportedType(type);
	importDeclaration.setStatic(true);
	if (memberName == null) {
		importDeclaration.setWildcard(true);
	} else {
		importDeclaration.setMemberName(memberName);
	}
	addedImportDeclarations.add(importDeclaration);
	return true;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:RewritableImportSection.java


示例5: addStaticExtensionImport

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
public boolean addStaticExtensionImport(JvmDeclaredType type, String memberName) {
	if (hasStaticImport(staticExtensionImports, type, memberName)) {
		return false;
	}
	Maps2.putIntoSetMap(type, memberName, staticExtensionImports);
	XImportDeclaration importDeclaration = XtypeFactory.eINSTANCE.createXImportDeclaration();
	importDeclaration.setImportedType(type);
	importDeclaration.setStatic(true);
	importDeclaration.setExtension(true);
	if (memberName == null) {
		importDeclaration.setWildcard(true);
	} else {
		importDeclaration.setMemberName(memberName);
	}
	addedImportDeclarations.add(importDeclaration);
	return true;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:RewritableImportSection.java


示例6: update

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
public void update() {
	XImportSection importSection = importsConfiguration.getImportSection(resource);
	if (importSection == null && importsConfiguration instanceof IMutableImportsConfiguration) {
		importSection = XtypeFactory.eINSTANCE.createXImportSection();

		IMutableImportsConfiguration mutableImportsConfiguration = (IMutableImportsConfiguration) importsConfiguration;
		mutableImportsConfiguration.setImportSection(resource, importSection);
	}
	if (importSection == null) {
		return;
	}
	removeObsoleteStaticImports();

	List<XImportDeclaration> allImportDeclarations = newArrayList();
	allImportDeclarations.addAll(originalImportDeclarations);
	allImportDeclarations.addAll(addedImportDeclarations);
	allImportDeclarations.removeAll(removedImportDeclarations);

	List<XImportDeclaration> importDeclarations = importSection.getImportDeclarations();
	importDeclarations.clear();
	importDeclarations.addAll(allImportDeclarations);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:23,代码来源:RewritableImportSection.java


示例7: appendImport

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
protected void appendImport(StringBuilder builder, XImportDeclaration newImportDeclaration) {
	builder.append("import ");
	if (newImportDeclaration.isStatic()) {
		builder.append("static ");
		if (newImportDeclaration.isExtension()) {
			builder.append("extension ");
		}
	}
	String qualifiedTypeName = newImportDeclaration.getImportedNamespace();
	if (newImportDeclaration.getImportedType() != null) {
		qualifiedTypeName = serializeType(newImportDeclaration.getImportedType());
	}
	String escapedTypeName = nameValueConverter.toString(qualifiedTypeName);
	builder.append(escapedTypeName);
	if (newImportDeclaration.isStatic()) {
		builder.append(".");
		if (newImportDeclaration.isWildcard()) {
			builder.append("*");
		} else {
			builder.append(newImportDeclaration.getMemberName());
		}
	}
	builder.append(lineSeparator);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:25,代码来源:RewritableImportSection.java


示例8: hasStaticImport

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
private boolean hasStaticImport(String typeName, String memberName, boolean extension) {
	for (String string : implicitlyImportedPackages) {
		if (typeName.startsWith(string)) {
			return typeName.substring(string.length()).lastIndexOf('.') == 0;
		}
	}
	Map<JvmDeclaredType, Set<String>> imports = staticImports;
	if (extension) {
		imports = staticExtensionImports;
	}
	for (JvmDeclaredType type : imports.keySet()) {
		if (typeName.equals(type.getIdentifier())) {
			Set<String> members = imports.get(type);
			return members != null && ((members.contains(memberName) || members.contains(null)));
		}
	}
	for (XImportDeclaration importDeclr : addedImportDeclarations) {
		String identifier = importDeclr.getImportedTypeName();
		if (importDeclr.isStatic() && typeName.equals(identifier)) {
			if (Objects.equal(importDeclr.getMemberName(), memberName) || importDeclr.isWildcard() || "*".equals(importDeclr.getMemberName())) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:27,代码来源:RewritableImportSection.java


示例9: getLegacyImportSyntax

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
@Override
public String getLegacyImportSyntax(XImportDeclaration importDeclaration) {
	List<INode> list = NodeModelUtils.findNodesForFeature(importDeclaration, XtypePackage.Literals.XIMPORT_DECLARATION__IMPORTED_TYPE);
	if (list.isEmpty()) {
		return null;
	}
	INode singleNode = list.get(0);
	if (singleNode.getText().indexOf('$') < 0) {
		return null;
	}
	StringBuilder sb = new StringBuilder();
	for(ILeafNode node: singleNode.getLeafNodes()) {
		if (!node.isHidden()) {
			sb.append(node.getText().replace("^", ""));
		}
	}
	return sb.toString();
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:DefaultImportsConfiguration.java


示例10: findAllFeatures

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
public Iterable<JvmFeature> findAllFeatures(final XImportDeclaration it) {
  Iterable<JvmFeature> _xblockexpression = null;
  {
    final JvmDeclaredType importedType = it.getImportedType();
    if (((!it.isStatic()) || (importedType == null))) {
      return CollectionLiterals.<JvmFeature>emptyList();
    }
    final IVisibilityHelper visibilityHelper = this.getVisibilityHelper(it.eResource());
    final IResolvedFeatures resolvedFeatures = this._provider.getResolvedFeatures(importedType);
    final Function1<JvmFeature, Boolean> _function = (JvmFeature feature) -> {
      return Boolean.valueOf(((feature.isStatic() && visibilityHelper.isVisible(feature)) && ((it.getMemberName() == null) || feature.getSimpleName().startsWith(it.getMemberName()))));
    };
    _xblockexpression = IterableExtensions.<JvmFeature>filter(resolvedFeatures.getAllFeatures(), _function);
  }
  return _xblockexpression;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:StaticallyImportedMemberProvider.java


示例11: removeStaticImport

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
private boolean removeStaticImport(Map<String, List<XImportDeclaration>> staticImports, JvmMember member) {
	JvmDeclaredType declaringType = member.getDeclaringType();
	String identifier = declaringType.getIdentifier();
	
	List<XImportDeclaration> list = staticImports.get(identifier);
	if (list == null) {
		return false;
	}
	if (list.size() == 1) {
		staticImports.remove(identifier);
		return true;
	}
	int indexToRemove = -1;
	for (int i = 0; i < list.size(); i++) {
		XImportDeclaration staticImportDeclaration = list.get(i);
		if (staticImportDeclaration.isWildcard()) {
			if (indexToRemove == -1) {
				indexToRemove = i;
			}
			continue;
		}
		if (Objects.equal(member.getSimpleName(), staticImportDeclaration.getMemberName())) {
			indexToRemove = i;
			break;
		}
	}
	if (indexToRemove == -1) {
		indexToRemove = 0;
	}
	list.remove(indexToRemove);
	return true;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:33,代码来源:XbaseValidator.java


示例12: removeTypeImport

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
private boolean removeTypeImport(Map<String, List<XImportDeclaration>> imports, JvmType declaringType) {
	String identifier = declaringType.getIdentifier();
	List<XImportDeclaration> list = imports.get(identifier);
	if (list == null) {
		return false;
	}
	if (list.size() == 1) {
		imports.remove(identifier);
		return true;
	}
	list.remove(0);
	return true;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:14,代码来源:XbaseValidator.java


示例13: addImportUnusedIssues

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
protected void addImportUnusedIssues(final Map<String, List<XImportDeclaration>> imports) {
	for (List<XImportDeclaration> importDeclarations : imports.values()) {
		for (XImportDeclaration importDeclaration : importDeclarations) {
			addIssue("The import '" + importDeclaration.getImportedName() + "' is never used.", importDeclaration, IMPORT_UNUSED);
		}	
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:XbaseValidator.java


示例14: checkDeprecated

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
@Check
public void checkDeprecated(XImportDeclaration decl) {
	if (!isIgnored(DEPRECATED_MEMBER_REFERENCE)) {
		JvmType jvmType = decl.getImportedType();
		checkDeprecated(
				jvmType,
				decl,
				XtypePackage.Literals.XIMPORT_DECLARATION__IMPORTED_TYPE);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:11,代码来源:XbaseValidator.java


示例15: internalGetScope

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
protected IScope internalGetScope(IScope parent, IScope globalScope, EObject context, EReference reference) {
	if(context instanceof XImportDeclaration) {
		return globalScope;
	}
	IScope result = parent;
	if (context.eContainer() == null) {
		if (parent != globalScope)
			throw new IllegalStateException("the parent should be the global scope");
		result = getResourceScope(globalScope, context.eResource(), reference);
	} else {
		result = internalGetScope(parent, globalScope, context.eContainer(), reference);
	}
	return getLocalElementsScope(result, globalScope, context, reference);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:15,代码来源:XImportSectionNamespaceScopeProvider.java


示例16: getImportedNamespaceResolvers

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
protected List<ImportNormalizer> getImportedNamespaceResolvers(XImportSection importSection, boolean ignoreCase) {
	List<XImportDeclaration> importDeclarations = importSection.getImportDeclarations();
	List<ImportNormalizer> result = Lists.newArrayListWithExpectedSize(importDeclarations.size());
	for (XImportDeclaration imp: importDeclarations) {
		if (!imp.isStatic()) {
			String value = imp.getImportedNamespace();
			if(value == null)
				value = imp.getImportedTypeName();
			ImportNormalizer resolver = createImportedNamespaceResolver(value, ignoreCase);
			if (resolver != null)
				result.add(resolver);
		}
	}
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:16,代码来源:XImportSectionNamespaceScopeProvider.java


示例17: newSession

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
@Override
public IFeatureScopeSession newSession(Resource context) {
	List<JvmType> literalClasses = implicitlyImportedFeatures.getStaticImportClasses(context);
	List<JvmType> extensionClasses = implicitlyImportedFeatures.getExtensionClasses(context);
	IFeatureScopeSession result = rootSession.addTypesToStaticScope(literalClasses, extensionClasses);
	if (context.getContents().isEmpty() || !(context instanceof XtextResource))
		return result;
	final XImportSection importSection = importsConfig.getImportSection((XtextResource) context);
	if(importSection != null) {
		result = result.addImports(new ITypeImporter.Client() {

			@Override
			public void doAddImports(ITypeImporter importer) {
				List<XImportDeclaration> imports = importSection.getImportDeclarations();
				for(XImportDeclaration _import: imports) {
					if (_import.isStatic()) {
						if (_import.isWildcard()) {
							if (_import.isExtension()) {
								importer.importStaticExtension(_import.getImportedType(), false);
							} else {
								importer.importStatic(_import.getImportedType());
							}
						} else {
							if (_import.isExtension()) {
								importer.importStaticExtension(_import.getImportedType(), _import.getMemberName(), false);
							} else {
								importer.importStatic(_import.getImportedType(), _import.getMemberName());
							}
						}
					}
				}
			}
			
		});
	}
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:38,代码来源:XbaseBatchScopeProvider.java


示例18: addImport

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
public boolean addImport(JvmDeclaredType type) {
	if (plainImports.containsKey(type.getSimpleName()) || !needsImport(type))
		return false;
	Maps2.putIntoListMap(type.getSimpleName(), type, plainImports);
	XImportDeclaration importDeclaration = XtypeFactory.eINSTANCE.createXImportDeclaration();
	importDeclaration.setImportedType(type);
	addedImportDeclarations.add(importDeclaration);
	return true;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:10,代码来源:RewritableImportSection.java


示例19: createImport

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
protected XImportDeclaration createImport(String importedNamespace, final String member) {
	XImportDeclaration importDeclaration = XtypeFactory.eINSTANCE.createXImportDeclaration();
	importDeclaration.setImportedNamespace(importedNamespace);
	if (member != null) {
		importDeclaration.setMemberName(member);
	}
	return importDeclaration;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:RewritableImportSection.java


示例20: findOriginalImports

import org.eclipse.xtext.xtype.XImportDeclaration; //导入依赖的package包/类
protected List<XImportDeclaration> findOriginalImports(JvmDeclaredType type, String memberName, Collection<XImportDeclaration> list, boolean isStatic,
		boolean isExtension) {
	List<XImportDeclaration> result = newArrayList();
	for (XImportDeclaration importDeclaration : list) {
		if (!(isStatic ^ importDeclaration.isStatic()) && !(isExtension ^ importDeclaration.isExtension()) && importDeclaration.getImportedType() == type
				&& (memberName == null || memberName.equals(importDeclaration.getMemberName()))) {
			result.add(importDeclaration);
		}
	}
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:12,代码来源:RewritableImportSection.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Collectors类代码示例发布时间:2022-05-22
下一篇:
Java JspSourceDependent类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap