Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Langium 1.3 #515

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ export class JayveeCompletionProvider extends DefaultCompletionProvider {
const isBlockTypeCompletion =
isBlockDefinition(astNode) && next.property === 'type';
if (isBlockTypeCompletion) {
return this.completionForBlockType(acceptor);
return this.completionForBlockType(context, acceptor);
}

const isConstraintTypeCompletion =
isConstraintDefinition(astNode) && next.property === 'type';
if (isConstraintTypeCompletion) {
return this.completionForConstraintType(acceptor);
return this.completionForConstraintType(context, acceptor);
}

const isValuetypeDefinitionCompletion = next.type === ValuetypeReference;
Expand All @@ -78,20 +78,21 @@ export class JayveeCompletionProvider extends DefaultCompletionProvider {
const isOtherPropertyCompletion =
isPropertyAssignment(astNode) && next.type === PropertyAssignment;
if (isFirstPropertyCompletion || isOtherPropertyCompletion) {
return this.completionForPropertyName(astNode, acceptor);
return this.completionForPropertyName(astNode, context, acceptor);
}
}
return super.completionFor(context, next, acceptor);
}

private completionForBlockType(
context: CompletionContext,
acceptor: CompletionAcceptor,
): MaybePromise<void> {
const blockTypes = getAllBuiltinBlocktypes(this.langiumDocumentService);
blockTypes.forEach((blockType) => {
const lspDocBuilder = new LspDocGenerator();
const markdownDoc = lspDocBuilder.generateBlockTypeDoc(blockType);
acceptor({
acceptor(context, {
label: blockType.type,
labelDetails: {
detail: ` ${blockType.inputType} ${RIGHT_ARROW_SYMBOL} ${blockType.outputType}`,
Expand All @@ -107,6 +108,7 @@ export class JayveeCompletionProvider extends DefaultCompletionProvider {
}

private completionForConstraintType(
context: CompletionContext,
acceptor: CompletionAcceptor,
): MaybePromise<void> {
const constraintTypes = getAllBuiltinConstraintTypes(
Expand All @@ -116,7 +118,7 @@ export class JayveeCompletionProvider extends DefaultCompletionProvider {
const lspDocBuilder = new LspDocGenerator();
const markdownDoc =
lspDocBuilder.generateConstraintTypeDoc(constraintType);
acceptor({
acceptor(context, {
label: constraintType.type,
labelDetails: {
detail: ` on ${constraintType.on.getName()}`,
Expand Down Expand Up @@ -144,7 +146,7 @@ export class JayveeCompletionProvider extends DefaultCompletionProvider {
parsedDocument.valuetypes.forEach((valuetypeDefinition) => {
const valuetype = createValuetype(valuetypeDefinition);
if (valuetype !== undefined && valuetype.isReferenceableByUser()) {
acceptor({
acceptor(context, {
label: valuetypeDefinition.name,
kind: CompletionItemKind.Class,
detail: `(valuetype)`,
Expand All @@ -156,6 +158,7 @@ export class JayveeCompletionProvider extends DefaultCompletionProvider {

private completionForPropertyName(
astNode: PropertyBody | PropertyAssignment,
context: CompletionContext,
acceptor: CompletionAcceptor,
) {
let container: BlockDefinition | ConstraintDefinition;
Expand Down Expand Up @@ -187,7 +190,7 @@ export class JayveeCompletionProvider extends DefaultCompletionProvider {
wrapper,
propertyNames,
propertyKind,
).forEach(acceptor);
).forEach((item) => acceptor(context, item));
}
}

Expand Down
Loading
Loading