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


Java XImportDeclaration类代码示例

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


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


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