public String getJavaFileName(IEObjectDescription description) { if (!isJvmDeclaredType(description)) { return null; } QualifiedName typeName = description.getName(); return Strings.concat("/", typeName.getSegments()) + ".java"; }
@Test public void testGetElementByInstance_01() { JvmVoid voidType = TypesFactory.eINSTANCE.createJvmVoid(); IEObjectDescription element = getTypeScope().getSingleElement(voidType); assertNotNull(element); assertEquals(voidType.getIdentifier(), element.getName().toString()); }
protected boolean checkImportedNamespaceExists(String importedNamespace, Resource res) { if (importedNamespace.endsWith(".*")) { importedNamespace = importedNamespace.substring(0, importedNamespace.length() - 2); // remove // wildcard } IResourceDescriptions resourceDescriptions = resourceDescriptionsProvider.getResourceDescriptions(res); URI uri = res.getURI(); IResourceDescription resourceDescription = resourceDescriptions.getResourceDescription(uri); if (resourceDescription == null) { return false; // no resource description could be found, so package // cannot be resolved anyway } for (IContainer container : containerManager.getVisibleContainers(resourceDescription, resourceDescriptions)) { final Iterable<IResourceDescription> currentDescriptions = container.getResourceDescriptions(); for (IResourceDescription resDesc : currentDescriptions) { Iterable<IEObjectDescription> visiblePackages = resDesc.getExportedObjectsByType(TypesPackage.Literals.PACKAGE); for (IEObjectDescription pkgDesc : visiblePackages) { if (pkgDesc.getName().toString().equals(importedNamespace)) { return true; } } } } return false; }
protected boolean isAffected( Collection<QualifiedName> importedNames, IResourceDescription description) { if (description != null) { for (IEObjectDescription desc : description.getExportedObjects()) if (importedNames.contains(desc.getName().toLowerCase())) return true; } return false; }
protected void addExportedNames( Set<QualifiedName> names, IResourceDescription resourceDescriptor) { if (resourceDescriptor == null) return; Iterable<IEObjectDescription> iterable = resourceDescriptor.getExportedObjects(); for (IEObjectDescription ieObjectDescription : iterable) { names.add(ieObjectDescription.getName().toLowerCase()); } }
@Test public void testGetElementByName_03() { IEObjectDescription objectElement = getTypeScope().getSingleElement(QualifiedName.create(int.class.getName())); assertNotNull(objectElement); assertFalse(objectElement.getEObjectOrProxy().eIsProxy()); assertEquals(QualifiedName.create("int"), objectElement.getName()); }
@Test public void testGetElementByName_01() { IEObjectDescription objectElement = getTypeScope().getSingleElement(QualifiedName.create(Object.class.getName())); assertNotNull(objectElement); assertFalse(objectElement.getEObjectOrProxy().eIsProxy()); assertEquals("java.lang.Object", objectElement.getName().toString()); }
public Sortable(final IEObjectDescription desc) { this.object = desc; QualifiedName _name = desc.getName(); this.name = _name; final String tempVersion = desc.getUserData(MobaResourceDescriptionStrategy.VERSION); String _replace = tempVersion.replace("-SNAPSHOT", ""); this.version = _replace; boolean _endsWith = tempVersion.endsWith("-SNAPSHOT"); this.snapshot = _endsWith; }
public String getCrossRefText( EObject owner, CrossReference crossref, EObject target, RefTextEvaluator refTextEvaluator, ITextRegion linkTextRegion, StatusWrapper status) { try { final EReference ref = GrammarUtil.getReference(crossref, owner.eClass()); final IScope scope = scopeProvider.getScope(owner, ref); if (scope == null) { throw new IllegalStateException("Could not create scope for the given cross reference."); } String ruleName = linkingHelper.getRuleNameFrom(crossref); Iterable<IEObjectDescription> descriptionsForCrossRef = scope.getElements(target); String bestRefText = null; for (IEObjectDescription desc : descriptionsForCrossRef) { try { String unconvertedRefText = qualifiedNameConverter.toString(desc.getName()); String convertedRefText = valueConverter.toString(unconvertedRefText, ruleName); if (refTextEvaluator.isValid(convertedRefText) && (bestRefText == null || refTextEvaluator.isBetterThan(convertedRefText, bestRefText))) bestRefText = convertedRefText; } catch (ValueConverterException e) { status.add( RefactoringStatus.WARNING, "Missconfigured language: New reference text has invalid syntax.", owner, linkTextRegion); } } if (bestRefText == null) status.add( RefactoringStatus.ERROR, "Refactoring introduces a name conflict.", owner, linkTextRegion); return bestRefText; } catch (Exception exc) { status.add(ERROR, exc.getMessage(), owner, linkTextRegion); return null; } }
@Override public Object[] getVariants() { ArrayList<LookupElementBuilder> _xblockexpression = null; { ProgressIndicatorProvider.checkCanceled(); ICrossReferenceDescription crossReferenceDescription = this.getCrossReferenceDescription(); boolean _equals = Objects.equal(crossReferenceDescription, null); if (_equals) { return ((Object[]) Conversions.unwrapArray(CollectionLiterals.<Object>emptyList(), Object.class)); } ArrayList<LookupElementBuilder> variants = CollectionLiterals.<LookupElementBuilder>newArrayList(); Iterable<IEObjectDescription> _variants = crossReferenceDescription.getVariants(); for (final IEObjectDescription objectDescription : _variants) { { ProgressIndicatorProvider.checkCanceled(); QualifiedName _name = objectDescription.getName(); String name = this.qualifiedNameConverter.toString(_name); BaseXtextFile _xtextFile = this.myElement.getXtextFile(); XtextResource _resource = _xtextFile.getResource(); PsiElement element = this.psiModelAssociations.getPsiElement(objectDescription, _resource); boolean _notEquals = (!Objects.equal(element, null)); if (_notEquals) { LookupElementBuilder _create = LookupElementBuilder.create(name); PsiElement _navigationElement = element.getNavigationElement(); PsiFile _containingFile = _navigationElement.getContainingFile(); String _name_1 = _containingFile.getName(); LookupElementBuilder _withTypeText = _create.withTypeText(_name_1); variants.add(_withTypeText); } } } _xblockexpression = variants; } return ((Object[]) Conversions.unwrapArray(_xblockexpression, Object.class)); }
@Override public Object text(final IEObjectDescription ele) { QualifiedName _name = ele.getName(); return ("" + _name); }
protected List<IEObjectDescription> findExternal( EObject scopeDetermeningObject, QualifiedName fqn, PPImportedNamesAdapter importedNames, boolean prefixMatch, EClass... eClasses) { if (scopeDetermeningObject == null) throw new IllegalArgumentException("scope determening object is null"); if (fqn == null) throw new IllegalArgumentException("name is null"); if (eClasses == null || eClasses.length < 1) throw new IllegalArgumentException("eClass is null or empty"); if (fqn.getSegmentCount() == 1 && "".equals(fqn.getSegment(0))) throw new IllegalArgumentException("FQN has one empty segment"); // Not meaningful to record the fact that an Absolute reference was used as nothing // is named with an absolute FQN (i.e. it is only used to do lookup). final boolean absoluteFQN = fqn.getSegmentCount() > 0 && "".equals(fqn.getSegment(0)); if (importedNames != null) importedNames.add(absoluteFQN ? fqn.skipFirst(1) : fqn); List<IEObjectDescription> targets = Lists.newArrayList(); Resource scopeDetermeningResource = scopeDetermeningObject.eResource(); if (scopeDetermeningResource != resource) { // This is a lookup in the perspective of some other resource IResourceDescriptions descriptionIndex = indexProvider.getResourceDescriptions(scopeDetermeningResource); IResourceDescription descr = descriptionIndex.getResourceDescription(scopeDetermeningResource.getURI()); // GIVE UP (the system is performing a build clean). if (descr == null) return targets; QualifiedName nameOfScope = getNameOfScope(scopeDetermeningObject); // for(IContainer visibleContainer : manager.getVisibleContainers(descr, descriptionIndex)) { // for(EClass aClass : eClasses) for (IEObjectDescription objDesc : new NameInScopeFilter( prefixMatch, getExportedObjects(descr, descriptionIndex), // visibleContainer.getExportedObjects(), fqn, nameOfScope, eClasses)) targets.add(objDesc); } else { // This is lookup from the main resource perspective QualifiedName nameOfScope = getNameOfScope(scopeDetermeningObject); for (IEObjectDescription objDesc : new NameInScopeFilter( prefixMatch, // prefixMatch ? exportedPerLastSegment.values() : exportedPerLastSegment.get(fqn.getLastSegment()), // fqn, nameOfScope, eClasses)) targets.add(objDesc); } if (tracer.isTracing()) { for (IEObjectDescription d : targets) tracer.trace(" : ", converter.toString(d.getName()), " in: ", d.getEObjectURI().path()); } return searchPathAdjusted(targets); }
public String text(IEObjectDescription ele) { return "" + ele.getName(); }
@Override public ContentAssistEntry createProposal( final IEObjectDescription candidate, final CrossReference crossRef, final ContentAssistContext context) { boolean _hasIdRule = this.hasIdRule(crossRef); if (_hasIdRule) { final XbaseIdeCrossrefProposalProvider.ProposalBracketInfo bracketInfo = this.getProposalBracketInfo(candidate, context); IQualifiedNameConverter _qualifiedNameConverter = this.getQualifiedNameConverter(); QualifiedName _name = candidate.getName(); String _string = _qualifiedNameConverter.toString(_name); final String proposalString = (_string + bracketInfo.brackets); int insignificantParameters = 0; if ((candidate instanceof IIdentifiableElementDescription)) { int _numberOfIrrelevantParameters = ((IIdentifiableElementDescription) candidate).getNumberOfIrrelevantParameters(); insignificantParameters = _numberOfIrrelevantParameters; } XtextResource _resource = context.getResource(); final LightweightTypeReferenceFactory converter = this.getTypeConverter(_resource); final EObject objectOrProxy = candidate.getEObjectOrProxy(); ContentAssistEntry _contentAssistEntry = new ContentAssistEntry(); final Procedure1<ContentAssistEntry> _function = new Procedure1<ContentAssistEntry>() { @Override public void apply(final ContentAssistEntry it) { String _prefix = context.getPrefix(); it.setPrefix(_prefix); it.setProposal(proposalString); } }; final ContentAssistEntry result = ObjectExtensions.<ContentAssistEntry>operator_doubleArrow(_contentAssistEntry, _function); if ((objectOrProxy instanceof JvmFeature)) { boolean _startsWith = bracketInfo.brackets.startsWith(" ="); if (_startsWith) { IQualifiedNameConverter _qualifiedNameConverter_1 = this.getQualifiedNameConverter(); QualifiedName _name_1 = candidate.getName(); String _string_1 = _qualifiedNameConverter_1.toString(_name_1); String _plus = (_string_1 + bracketInfo.brackets); this.addNameAndDescription( result, ((JvmFeature) objectOrProxy), false, insignificantParameters, _plus, converter); } else { boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(bracketInfo.brackets); boolean _not = (!_isNullOrEmpty); IQualifiedNameConverter _qualifiedNameConverter_2 = this.getQualifiedNameConverter(); QualifiedName _name_2 = candidate.getName(); String _string_2 = _qualifiedNameConverter_2.toString(_name_2); this.addNameAndDescription( result, ((JvmFeature) objectOrProxy), _not, insignificantParameters, _string_2, converter); } } else { IQualifiedNameConverter _qualifiedNameConverter_3 = this.getQualifiedNameConverter(); QualifiedName _qualifiedName = candidate.getQualifiedName(); String _string_3 = _qualifiedNameConverter_3.toString(_qualifiedName); IQualifiedNameConverter _qualifiedNameConverter_4 = this.getQualifiedNameConverter(); QualifiedName _name_3 = candidate.getName(); String _string_4 = _qualifiedNameConverter_4.toString(_name_3); this.addNameAndDescription(result, objectOrProxy, _string_3, _string_4); } int _offset = context.getOffset(); String _prefix = context.getPrefix(); int _length = _prefix.length(); int _minus = (_offset - _length); int _length_1 = proposalString.length(); int offset = (_minus + _length_1); result.setEscapePosition(Integer.valueOf((offset + bracketInfo.caretOffset))); if ((bracketInfo.selectionOffset != 0)) { int _offset_1 = offset; offset = (_offset_1 + bracketInfo.selectionOffset); ArrayList<TextRegion> _editPositions = result.getEditPositions(); TextRegion _textRegion = new TextRegion(offset, bracketInfo.selectionLength); _editPositions.add(_textRegion); } if ((objectOrProxy instanceof JvmExecutable)) { final StringBuilder parameterList = new StringBuilder(); this.appendParameters( parameterList, ((JvmExecutable) objectOrProxy), insignificantParameters, converter); } return result; } return super.createProposal(candidate, crossRef, context); }