Java Code Examples for org.eclipse.xtext.common.types.JvmDeclaredType#getQualifiedName()

The following examples show how to use org.eclipse.xtext.common.types.JvmDeclaredType#getQualifiedName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegisterGlobalsContextImpl.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
private JvmDeclaredType findRecursively(final String string, final Iterable<? extends JvmDeclaredType> types) {
  for (final JvmDeclaredType type : types) {
    {
      final String candidateQualifiedName = type.getQualifiedName('.');
      boolean _equals = Objects.equal(string, candidateQualifiedName);
      if (_equals) {
        return type;
      }
      boolean _startsWith = string.startsWith(candidateQualifiedName);
      if (_startsWith) {
        final JvmDeclaredType result = this.findRecursively(string, Iterables.<JvmDeclaredType>filter(type.getMembers(), JvmDeclaredType.class));
        if ((result != null)) {
          return result;
        }
      }
    }
  }
  return null;
}
 
Example 2
Source File: SARLJvmGenerator.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
protected void _internalDoGenerate(JvmDeclaredType type, IFileSystemAccess fsa) {
	if (DisableCodeGenerationAdapter.isDisabled(type)) {
		return;
	}
	final String qn = type.getQualifiedName();
	if (!Strings.isEmpty(qn)) {
		final String fn = qn.replace('.', '/') + ".java"; //$NON-NLS-1$
		final CharSequence content = generateType(type, this.generatorConfigProvider.get(type));
		final String outputConfigurationName;
		final Boolean isTest = this.resourceTypeDetector.isTestResource(type.eResource());
		if (isTest != null && isTest.booleanValue()) {
			outputConfigurationName = SARLConfig.TEST_OUTPUT_CONFIGURATION;
		} else {
			outputConfigurationName = IFileSystemAccess.DEFAULT_OUTPUT;
		}
		fsa.generateFile(fn, outputConfigurationName, content);
	}
}
 
Example 3
Source File: NestedTypesScope.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void addDescriptions(JvmDeclaredType type, JvmType declarator, List<IEObjectDescription> result) {
	String typeName = type.getQualifiedName('.');
	String declaratorName = declarator.getQualifiedName('.');
	int declaratorLength = declaratorName.length();
	String subName = typeName.substring(declaratorLength + 1);
	List<String> segments = Strings.split(subName, '.');
	result.add(EObjectDescription.create(QualifiedName.create(segments), type));
	result.add(EObjectDescription.create(subName.replace('.', '$'), type));
	for(JvmDeclaredType nestedType: type.getAllNestedTypes()) {
		addDescriptions(nestedType, declarator, result);
	}
}
 
Example 4
Source File: ImportOrganizer.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected String getPackageLocalName(JvmDeclaredType type) {
	String packageName = type.getPackageName();
	if (isEmpty(packageName))
		return type.getQualifiedName('.');
	else
		return type.getQualifiedName('.').substring(packageName.length() + 1);
}
 
Example 5
Source File: JvmModelGenerator.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void _internalDoGenerate(final JvmDeclaredType type, final IFileSystemAccess fsa) {
  boolean _isDisabled = DisableCodeGenerationAdapter.isDisabled(type);
  if (_isDisabled) {
    return;
  }
  String _qualifiedName = type.getQualifiedName();
  boolean _tripleNotEquals = (_qualifiedName != null);
  if (_tripleNotEquals) {
    String _replace = type.getQualifiedName().replace(".", "/");
    String _plus = (_replace + ".java");
    fsa.generateFile(_plus, this.generateType(type, this.generatorConfigProvider.get(type)));
  }
}
 
Example 6
Source File: JvmMemberImplCustom.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public String getQualifiedName(char innerClassDelimiter) {
	if (simpleName == null)
		return null;
	JvmDeclaredType declaringType = getDeclaringType();
	if (declaringType == null)
		return simpleName;
	return declaringType.getQualifiedName(innerClassDelimiter) + '.' + simpleName;
}
 
Example 7
Source File: JvmConstructorImplCustom.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public String getQualifiedName(char innerClassDelimiter) {
	JvmDeclaredType declaringType = getDeclaringType();
	if (declaringType != null)
		return declaringType.getQualifiedName(innerClassDelimiter);
	return getSimpleName();
}
 
Example 8
Source File: JvmDeclaredTypeImplCustom.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public String getQualifiedName(char innerClassDelimiter) {
	if (simpleName == null)
		return null;
	JvmDeclaredType declaringType = getDeclaringType();
	if (declaringType == null) {
		if (Strings.isEmpty(packageName))
			return simpleName;
		return packageName + "." + simpleName;
	}
	String parentName = declaringType.getQualifiedName(innerClassDelimiter);
	if (parentName == null)
		return null;
	return parentName + innerClassDelimiter + simpleName;
}
 
Example 9
Source File: JavaElementFinder.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public IJavaElement caseJvmDeclaredType(JvmDeclaredType object) {
	try {
		String canonicalName = object.getQualifiedName('.');
		IType result = javaProject.findType(canonicalName);
		return result;
	}
	catch (JavaModelException e) {
		return null;
	}
}
 
Example 10
Source File: MissedMethodAddModification.java    From sarl with Apache License 2.0 5 votes vote down vote up
private static String typeParameterId(JvmTypeReference type) {
	final JvmType realType = type.getType();
	if (realType instanceof JvmTypeParameter) {
		final JvmDeclaredType container = EcoreUtil2.getContainerOfType(realType, JvmDeclaredType.class);
		if (container != null) {
			return container.getQualifiedName() + "$" + realType.getIdentifier(); //$NON-NLS-1$
		}
	}
	return type.getQualifiedName();
}
 
Example 11
Source File: RewritableImportSection.java    From xtext-extras with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * We cannot rely on JvmType#getIdentifier as it is cached and does not pick up changed simpleNames, e.g. in rename
 * refactoring.
 */
protected String serializeType(JvmDeclaredType type) {
	return type.getQualifiedName('.');
}