本文整理汇总了Java中org.eclipse.xtext.naming.QualifiedName.getFirstSegment方法的典型用法代码示例。如果您正苦于以下问题:Java QualifiedName.getFirstSegment方法的具体用法?Java QualifiedName.getFirstSegment怎么用?Java QualifiedName.getFirstSegment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.naming.QualifiedName
的用法示例。
在下文中一共展示了QualifiedName.getFirstSegment方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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();
}
}
示例4: createDefaultImport
import org.eclipse.xtext.naming.QualifiedName; //导入方法依赖的package包/类
/** Creates a new default import with name 'name' from object description. */
private ImportDeclaration createDefaultImport(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);
return createImportDeclaration(qn, name, project, nodelessMarker, this::addDefaultImport);
}
示例5: computeImportType
import org.eclipse.xtext.naming.QualifiedName; //导入方法依赖的package包/类
/**
* Convenience method over {@link ImportSpecifierUtil#computeImportType(QualifiedName, boolean, IN4JSProject)}
*/
private ImportType computeImportType(QualifiedName name, IN4JSProject project) {
final String firstSegment = name.getFirstSegment();
final IN4JSProject targetProject = findProject(firstSegment, project);
final boolean firstSegmentIsProjectId = targetProject != null;
return ImportSpecifierUtil.computeImportType(name, firstSegmentIsProjectId, targetProject);
}
示例6: computeImportType
import org.eclipse.xtext.naming.QualifiedName; //导入方法依赖的package包/类
/**
* Convenience method over {@link ImportSpecifierUtil#computeImportType(QualifiedName, boolean, IN4JSProject)}
*/
public static ImportType computeImportType(QualifiedName name, IN4JSProject project) {
final String firstSegment = name.getFirstSegment();
final IN4JSProject targetProject = getDependencyWithID(firstSegment, project);
final boolean firstSegmentIsProjectId = targetProject != null;
return ImportSpecifierUtil.computeImportType(name, firstSegmentIsProjectId, targetProject);
}
示例7: getSingleLocalElementByName
import org.eclipse.xtext.naming.QualifiedName; //导入方法依赖的package包/类
@Override
protected IEObjectDescription getSingleLocalElementByName(QualifiedName name) {
if (name.getSegmentCount() != 1) {
return null;
}
final String nameAsString = name.getFirstSegment();
// both read/write required
if (ExpressionExtensions.isBothReadFromAndWrittenTo(context)) {
TMember reader = findMember(nameAsString, false, staticAccess);
TMember writer = findMember(nameAsString, true, staticAccess);
if (null == reader && null == writer) {
// will be caught as error "Could not resolve reference"
return null;
}
if (null == reader) {
return new UnsatisfiedRWAccessDescription(EObjectDescription.create(writer.getName(), writer), true);
}
if (null == writer) {
return new UnsatisfiedRWAccessDescription(EObjectDescription.create(reader.getName(), reader), false);
}
// pick arbitrarily the setter
return createSingleElementDescription(writer);
}
// either read or write requirement that moreover is satisfied
final boolean accessForWriteOperation = ExpressionExtensions.isLeftHandSide(context);
TMember existingMember = findMember(nameAsString, accessForWriteOperation, staticAccess);
if (existingMember != null) {
return createSingleElementDescription(existingMember);
}
// wrong read/write
existingMember = findMember(nameAsString, !accessForWriteOperation, staticAccess);
if (existingMember != null) {
// allowed special case: writing in the ctor to a final field that lacks init value
final boolean isAssOfFinalInCtor = N4JSASTUtils
.isSemiLegalAssignmentToFinalFieldInCtor(context.eContainer(), existingMember);
final boolean isLegalAssOfFinalInCtor = isAssOfFinalInCtor && !((TField) existingMember).isHasExpression();
if (isLegalAssOfFinalInCtor) {
return createSingleElementDescription(existingMember);
}
// allowed special case: wrong read/write in a mode other than N4JS
if (jsVariantHelper.allowWrongReadWrite(context)) { // cf. sec. 13.1
return createSingleElementDescription(existingMember);
}
return new WrongWriteAccessDescription(
EObjectDescription.create(existingMember.getName(), existingMember),
accessForWriteOperation, isAssOfFinalInCtor);
}
// wrong static / non-static
existingMember = findMember(nameAsString, accessForWriteOperation, !staticAccess);
if (existingMember == null) {
// if both read/write access and static access are wrong, we want to
// complain (only) about "wrong static access" -> so include this case here
existingMember = findMember(nameAsString, !accessForWriteOperation, !staticAccess);
}
if (existingMember != null) {
return new WrongStaticAccessDescription(
EObjectDescription.create(existingMember.getName(), existingMember),
staticAccess);
}
return null;
}