Java Code Examples for org.eclipse.xtext.common.types.JvmIdentifiableElement#getSimpleName()
The following examples show how to use
org.eclipse.xtext.common.types.JvmIdentifiableElement#getSimpleName() .
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: DefaultFeatureCallValidator.java From sarl with Apache License 2.0 | 6 votes |
@Override public boolean isDisallowedCall(XAbstractFeatureCall call) { if (call != null && call.getFeature() != null) { final JvmIdentifiableElement feature = call.getFeature(); final String id = feature.getQualifiedName(); // Exit is forbidden on a agent-based system if ("java.lang.System.exit".equals(id)) { //$NON-NLS-1$ return !isInsideOOTypeDeclaration(call); } // Avoid any call to the hidden functions (function name contains "$" character). final String simpleName = feature.getSimpleName(); if (Utils.isHiddenMember(simpleName) && !Utils.isNameForHiddenCapacityImplementationCallingMethod(simpleName) && (!Utils.isImplicitLambdaParameterName(simpleName) || !isInsideClosure(call))) { return true; } // Avoid any reference to private API. if (isPrivateAPI(feature) && !isPrivateAPI(call)) { return true; } } return false; }
Example 2
Source File: SerializerScopeProvider.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected IScope getExecutableScope(XAbstractFeatureCall call, JvmIdentifiableElement feature) { final String simpleName = feature.getSimpleName(); QualifiedName name = QualifiedName.create(simpleName); if (call.isOperation()) { QualifiedName operator = getOperator(call, name); if (operator == null) { return IScope.NULLSCOPE; } return new SingletonScope(EObjectDescription.create(operator, feature), IScope.NULLSCOPE); } if (call instanceof XAssignment) { return getAccessorScope(simpleName, name, feature); } if (call.isExplicitOperationCallOrBuilderSyntax() || ((JvmExecutable) feature).getParameters().size() > 1 || (!call.isExtension() && ((JvmExecutable) feature).getParameters().size() == 1)) { return new SingletonScope(EObjectDescription.create(name, feature), IScope.NULLSCOPE); } return getAccessorScope(simpleName, name, feature); }
Example 3
Source File: FeatureCallCompiler.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
private boolean isPotentialJavaOperation(XAbstractFeatureCall featureCall) { if (featureCall.isOperation()) { return true; } if (featureCall.eClass() == XbasePackage.Literals.XMEMBER_FEATURE_CALL && featureCall.isStatic() && featureCall.isExtension() && featureCall.getActualArguments().size() == 2) { JvmIdentifiableElement feature = featureCall.getFeature(); if (feature.eClass() == TypesPackage.Literals.JVM_OPERATION) { JvmDeclaredType declarator = ((JvmOperation) feature).getDeclaringType(); if (IntegerExtensions.class.getName().equals(declarator.getIdentifier()) || LongExtensions.class.getName().equals(declarator.getIdentifier())) { String simpleName = feature.getSimpleName(); if (simpleName.startsWith("bitwise") || simpleName.startsWith("shift")) { return true; } } } } return false; }
Example 4
Source File: Oven.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public void assertIdentifiableTypeIsResolved(JvmIdentifiableElement identifiable, IResolvedTypes types) { if (identifiable.getSimpleName() == null) { return; } LightweightTypeReference type = types.getActualType(identifiable); Assert.assertNotNull(identifiable.toString(), type); Assert.assertNotNull(identifiable.toString() + " / " + type, type.getIdentifier()); }
Example 5
Source File: AmbiguousCastOperatorLinkingCandidate.java From sarl with Apache License 2.0 | 5 votes |
@Override protected String[] getDiagnosticData() { final Set<String> data = Sets.newLinkedHashSet(); for (final ILinkingCandidate candidate : getAlternatives()) { final JvmIdentifiableElement feature = candidate.getFeature(); final String simpleName = feature.getSimpleName(); data.add(simpleName + "()"); //$NON-NLS-1$ } return data.toArray(new String[data.size()]); }
Example 6
Source File: SARLHoverSerializer.java From sarl with Apache License 2.0 | 5 votes |
@Override public String computeUnsugaredExpression(EObject object) { if (object instanceof XAbstractFeatureCall) { final XAbstractFeatureCall featureCall = (XAbstractFeatureCall) object; final JvmIdentifiableElement feature = featureCall.getFeature(); if (feature instanceof JvmExecutable && !feature.eIsProxy() && (featureCall.getImplicitReceiver() != null || featureCall.getImplicitFirstArgument() != null) && !featureCall.isStatic()) { final XExpression receiver = featureCall.getActualReceiver(); if (receiver instanceof XMemberFeatureCall) { final JvmIdentifiableElement memberFeature = ((XMemberFeatureCall) receiver).getFeature(); final String name = memberFeature.getSimpleName(); if (Utils.isNameForHiddenCapacityImplementationCallingMethod(name)) { final JvmOperation op = (JvmOperation) memberFeature; final StringBuilder result = new StringBuilder(); result.append("getSkill(typeof("); //$NON-NLS-1$ result.append(op.getReturnType().getSimpleName()); result.append("))."); //$NON-NLS-1$ result.append(feature.getSimpleName()); result.append(computeArguments(featureCall)); return result.toString(); } } } } return super.computeUnsugaredExpression(object); }
Example 7
Source File: SyntheticNameClashResolver.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected boolean isRenameable(JvmIdentifiableElement element) { String simpleName = element.getSimpleName(); if (!simpleName.startsWith("_")) { return false; } EObject source = associations.getPrimarySourceElement(element); return (isCreateExtension(source) && (simpleName .startsWith(XtendJvmModelInferrer.CREATE_CHACHE_VARIABLE_PREFIX) || simpleName .startsWith(XtendJvmModelInferrer.CREATE_INITIALIZER_PREFIX))) || isAnonymousExtensionField(source); }
Example 8
Source File: Oven.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public void assertIdentifiableTypeIsResolved(final JvmIdentifiableElement identifiable, final IResolvedTypes types) { String _simpleName = identifiable.getSimpleName(); boolean _tripleEquals = (_simpleName == null); if (_tripleEquals) { return; } final LightweightTypeReference type = types.getActualType(identifiable); Assert.assertNotNull(identifiable.toString(), type); String _string = identifiable.toString(); String _plus = (_string + " / "); String _plus_1 = (_plus + type); Assert.assertNotNull(_plus_1, type.getIdentifier()); }
Example 9
Source File: Oven.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public void assertIdentifiableTypeIsResolved(JvmIdentifiableElement identifiable, IResolvedTypes types) { if (identifiable.getSimpleName() == null) { return; } LightweightTypeReference type = types.getActualType(identifiable); Assert.assertNotNull(identifiable.toString(), type); Assert.assertNotNull(identifiable.toString() + " / " + type, type.getIdentifier()); }
Example 10
Source File: Oven.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public void assertIdentifiableTypeIsResolved(JvmIdentifiableElement identifiable, IResolvedTypes types) { if (identifiable.getSimpleName() == null) { return; } LightweightTypeReference type = types.getActualType(identifiable); Assert.assertNotNull(identifiable.toString(), type); Assert.assertNotNull(identifiable.toString() + " / " + type, type.getIdentifier()); }
Example 11
Source File: BucketedEObjectDescription.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public String getShadowingKey() { EObject object = getEObjectOrProxy(); if (object instanceof JvmIdentifiableElement) { JvmIdentifiableElement identifiable = (JvmIdentifiableElement) object; StringBuilder builder = new StringBuilder(identifiable.getSimpleName()); computeShadowingKey(identifiable, builder); return builder.toString(); } return getName().toString() + (isVisible() ? '+' : '-'); }
Example 12
Source File: IdentifiableSimpleNameProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public /* @Nullable */ String getSimpleName(JvmIdentifiableElement element) { if (element == null || element.eIsProxy()) { return null; } if (element instanceof JvmFeature) { return ((JvmFeature) element).getSimpleName(); } if (element instanceof JvmFormalParameter) { return ((JvmFormalParameter) element).getName(); } if (element instanceof XVariableDeclaration) { return ((XVariableDeclaration) element).getName(); } return element.getSimpleName(); }
Example 13
Source File: AmbiguousFeatureLinkingCandidate.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override protected String[] getDiagnosticData() { FeatureLinkingCandidate primaryCandidate = getPrimaryCandidate(); XAbstractFeatureCall expression = primaryCandidate.getExpression(); if (expression.isExplicitOperationCallOrBuilderSyntax()) { return null; } Set<String> data = Sets.newLinkedHashSet(); for (ILinkingCandidate candidate : getAlternatives()) { JvmIdentifiableElement feature = candidate.getFeature(); String simpleName = feature.getSimpleName(); data.add(simpleName + "()"); } return data.toArray(new String[data.size()]); }
Example 14
Source File: AbstractTypeComputationState.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public void addLocalToCurrentScope(JvmIdentifiableElement element) { String simpleName = element.getSimpleName(); if (Strings.isNullOrEmpty(simpleName)) return; QualifiedName elementName = QualifiedName.create(simpleName); addLocalToCurrentScope(elementName, element, !getResolver().isShadowingAllowed(elementName)); }
Example 15
Source File: ExtractMethodRefactoring.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public RefactoringStatus checkInitialConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException { StatusWrapper status = statusProvider.get(); IResolvedTypes resolvedTypes = typeResolver.resolveTypes(firstExpression, new CancelIndicator() { @Override public boolean isCanceled() { return pm.isCanceled(); } }); try { Set<String> calledExternalFeatureNames = newHashSet(); returnType = calculateReturnType(resolvedTypes); if (returnType != null && !equal("void", returnType.getIdentifier())) returnExpression = lastExpression; boolean isReturnAllowed = isEndOfOriginalMethod(); for (EObject element : EcoreUtil2.eAllContents(originalMethod.getExpression())) { if (pm.isCanceled()) { throw new OperationCanceledException(); } boolean isLocalExpression = EcoreUtil.isAncestor(expressions, element); if (element instanceof XFeatureCall) { XFeatureCall featureCall = (XFeatureCall) element; JvmIdentifiableElement feature = featureCall.getFeature(); LightweightTypeReference featureType = resolvedTypes.getActualType(featureCall); boolean isLocalFeature = EcoreUtil.isAncestor(expressions, feature); if (!isLocalFeature && isLocalExpression) { // call-out if (feature instanceof JvmFormalParameter || feature instanceof XVariableDeclaration) { if (!calledExternalFeatureNames.contains(feature.getSimpleName())) { calledExternalFeatureNames.add(feature.getSimpleName()); ParameterInfo parameterInfo = new ParameterInfo(featureType.getIdentifier(), feature.getSimpleName(), parameterInfos.size()); parameterInfos.add(parameterInfo); parameter2type.put(parameterInfo, featureType); } externalFeatureCalls.put(feature.getSimpleName(), featureCall); } } else if (isLocalFeature && !isLocalExpression) { // call-in if (returnExpression != null) { status.add(RefactoringStatus.FATAL, "Ambiguous return value: Multiple local variables are accessed in subsequent code."); break; } returnExpression = featureCall; returnType = featureType; } } else if(isLocalExpression) { if(element instanceof XReturnExpression && !isReturnAllowed) { status.add(RefactoringStatus.FATAL, "Extracting method would break control flow due to return statements."); break; } else if (element instanceof JvmTypeReference) { JvmType type = ((JvmTypeReference) element).getType(); if (type instanceof JvmTypeParameter) { JvmOperation operation = associations.getDirectlyInferredOperation(originalMethod); if (operation != null) { List<JvmTypeParameter> typeParameters = operation.getTypeParameters(); if (typeParameters.contains(type)) neededTypeParameters.add((JvmTypeParameter) type); } } } else if (element instanceof JvmFormalParameter) localFeatureNames.add(((JvmFormalParameter) element).getName()); else if (element instanceof XVariableDeclaration) localFeatureNames.add(((XVariableDeclaration) element).getIdentifier()); } } } catch (OperationCanceledException e) { throw e; } catch (Exception exc) { handleException(exc, status); } return status.getRefactoringStatus(); }
Example 16
Source File: CacheMethodCompileStrategy.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
protected String getVarName(JvmIdentifiableElement ex) { return ex.getSimpleName(); }
Example 17
Source File: XbaseValidator.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
private String getQualifiedSimpleName(JvmIdentifiableElement element) { if (element.eContainer() instanceof JvmType) { return getQualifiedSimpleName((JvmIdentifiableElement) element.eContainer()) + "." + element.getSimpleName(); } return element.getSimpleName(); }