use of org.eclipse.xtext.xbase.typesystem.override.IResolvedConstructor in project xtext-xtend by eclipse.
the class CompilationUnitImpl method toResolvedConstructor.
public ResolvedConstructor toResolvedConstructor(final IResolvedConstructor delegate) {
final Function1<IResolvedConstructor, ResolvedConstructorImpl> _function = (IResolvedConstructor it) -> {
ResolvedConstructorImpl _resolvedConstructorImpl = new ResolvedConstructorImpl();
final Procedure1<ResolvedConstructorImpl> _function_1 = (ResolvedConstructorImpl it_1) -> {
it_1.setDelegate(delegate);
it_1.setCompilationUnit(this);
};
return ObjectExtensions.<ResolvedConstructorImpl>operator_doubleArrow(_resolvedConstructorImpl, _function_1);
};
return this.<IResolvedConstructor, ResolvedConstructorImpl>getOrCreate(delegate, _function);
}
use of org.eclipse.xtext.xbase.typesystem.override.IResolvedConstructor in project xtext-xtend by eclipse.
the class ImplementMemberFromSuperAssist method createOverrideMethodProposal.
protected ICompletionProposal createOverrideMethodProposal(XtendTypeDeclaration model, IResolvedExecutable overrideable, final ContentAssistContext context, IProposalConflictHelper conflictHelper) {
IXtextDocument document = context.getDocument();
XtextResource resource = (XtextResource) model.eResource();
int offset = context.getReplaceRegion().getOffset();
int currentIndentation = appendableFactory.getIndentationLevelAtOffset(offset, document, resource);
final int indentationLevel = currentIndentation == 0 ? 1 : currentIndentation;
ReplacingAppendable appendable = appendableFactory.create(document, resource, offset, context.getReplaceRegion().getLength(), new OptionalParameters() {
{
ensureEmptyLinesAround = true;
baseIndentationLevel = indentationLevel;
}
});
final String simpleName;
JvmExecutable declaration = overrideable.getDeclaration();
if (overrideable instanceof IResolvedOperation) {
implementor.appendOverrideFunction(model, (IResolvedOperation) overrideable, appendable);
simpleName = overrideable.getDeclaration().getSimpleName();
} else if (model instanceof XtendClass) {
implementor.appendConstructorFromSuper((XtendClass) model, (IResolvedConstructor) overrideable, appendable);
simpleName = "new";
} else {
return null;
}
String code = appendable.getCode();
if (!isValidProposal(code.trim(), context, conflictHelper) && !isValidProposal(simpleName, context, conflictHelper))
return null;
ImageDescriptor imageDescriptor = images.forOperation(declaration.getVisibility(), adornments.getOverrideAdornment(declaration));
ImportOrganizingProposal completionProposal = createCompletionProposal(appendable, context.getReplaceRegion(), getLabel(overrideable), imageHelper.getImage(imageDescriptor));
Matcher matcher = bodyExpressionPattern.matcher(code);
if (matcher.find()) {
int bodyExpressionLength = matcher.end(1) - matcher.start(1);
int bodyExpressionStart = matcher.start(1) + appendable.getTotalOffset() - completionProposal.getReplacementOffset();
if (bodyExpressionLength == 0) {
completionProposal.setCursorPosition(bodyExpressionStart);
} else {
completionProposal.setSelectionStart(completionProposal.getReplacementOffset() + bodyExpressionStart);
completionProposal.setSelectionLength(bodyExpressionLength);
completionProposal.setAutoInsertable(false);
completionProposal.setCursorPosition(bodyExpressionStart + bodyExpressionLength);
completionProposal.setSimpleLinkedMode(context.getViewer(), '\t');
}
}
completionProposal.setPriority(getPriority(model, declaration, context));
completionProposal.setMatcher(new PrefixMatcher() {
@Override
public boolean isCandidateMatchingPrefix(String name, String prefix) {
PrefixMatcher delegate = context.getMatcher();
boolean result = delegate.isCandidateMatchingPrefix(simpleName, prefix);
return result;
}
});
return completionProposal;
}
use of org.eclipse.xtext.xbase.typesystem.override.IResolvedConstructor in project xtext-xtend by eclipse.
the class AbstractXtendOutlineTreeBuilder method buildInheritedMembers.
protected void buildInheritedMembers(final JvmDeclaredType inferredType, final IXtendOutlineContext context) {
ResourceSet _resourceSet = inferredType.eResource().getResourceSet();
final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(this.services, _resourceSet);
final LightweightTypeReference typeReference = owner.toLightweightTypeReference(inferredType);
final List<LightweightTypeReference> superTypes = typeReference.getAllSuperTypes();
IXtendOutlineContext superTypeContext = context;
for (final LightweightTypeReference superTypeRef : superTypes) {
{
superTypeContext = superTypeContext.increaseInheritanceDepth();
final ResolvedFeatures resolvedFeatures = new ResolvedFeatures(superTypeRef);
List<IResolvedField> _declaredFields = resolvedFeatures.getDeclaredFields();
for (final IResolvedField jvmField : _declaredFields) {
boolean _skipFeature = this.skipFeature(jvmField.getDeclaration());
boolean _not = (!_skipFeature);
if (_not) {
this.xtendOutlineNodeBuilder.buildResolvedFeatureNode(inferredType, jvmField, superTypeContext);
}
}
List<IResolvedConstructor> _declaredConstructors = resolvedFeatures.getDeclaredConstructors();
for (final IResolvedConstructor constructor : _declaredConstructors) {
boolean _skipFeature_1 = this.skipFeature(constructor.getDeclaration());
boolean _not_1 = (!_skipFeature_1);
if (_not_1) {
this.xtendOutlineNodeBuilder.buildResolvedFeatureNode(inferredType, constructor, superTypeContext);
}
}
List<IResolvedOperation> _declaredOperations = resolvedFeatures.getDeclaredOperations();
for (final IResolvedOperation operation : _declaredOperations) {
if (((!this.skipFeature(operation.getDeclaration())) && (!superTypeContext.isProcessed(operation.getDeclaration())))) {
this.xtendOutlineNodeBuilder.buildResolvedFeatureNode(inferredType, operation, superTypeContext);
}
}
final JvmType declaredType = superTypeRef.getType();
if ((declaredType instanceof JvmDeclaredType)) {
final IXtendOutlineContext nestedTypeContext = superTypeContext.hideInherited();
final Consumer<JvmDeclaredType> _function = (JvmDeclaredType it) -> {
this.buildJvmType(it, nestedTypeContext);
};
Iterables.<JvmDeclaredType>filter(((JvmDeclaredType) declaredType).getMembers(), JvmDeclaredType.class).forEach(_function);
}
}
}
}
Aggregations