This is an archive of the discontinued LLVM Phabricator instance.

[mlir][PDLL] Add code completion to the PDLL language server
ClosedPublic

Authored by rriddle on Mar 13 2022, 12:47 AM.

Details

Summary

This commit adds code completion support to the language server,
and initially supports providing completions for: Member access,
attributes/constraint/dialect/operation names, and pattern metadata.

Diff Detail

Event Timeline

rriddle created this revision.Mar 13 2022, 12:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 13 2022, 12:47 AM
rriddle requested review of this revision.Mar 13 2022, 12:47 AM
rriddle updated this revision to Diff 415001.Mar 13 2022, 10:16 PM
rriddle edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Mar 16 2022, 12:39 AM
jpienaar accepted this revision.Mar 16 2022, 8:01 PM
jpienaar added inline comments.
mlir/lib/Tools/PDLL/Parser/Lexer.h
40

This feels special as a token, well even more special than the other markers. Why does it need to be a Token kind?

mlir/lib/Tools/PDLL/Parser/Parser.cpp
255

This seems unrelated to the main change here.

1664

Why an unconditional failure?

mlir/lib/Tools/lsp-server-support/Protocol.h
671

Is this a standard enum? Could we point to the origin? (url to doc)

mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
608

You use .str() on some conversions from twine but not on others,

658

Why `c++ ?

711

of type ?

rriddle updated this revision to Diff 416681.Mar 19 2022, 3:37 AM
rriddle marked 7 inline comments as done.
rriddle added inline comments.Mar 19 2022, 3:38 AM
mlir/lib/Tools/PDLL/Parser/Lexer.h
40

It's a marker token for when we've reached a code completion location. It doesn't have to be a token, but it's more natural (and less complex) to be one. The modeling here is also kept similar to how this is done in other projects, e.g. this is how clang handles completion as well.

mlir/lib/Tools/PDLL/Parser/Parser.cpp
255

It's used during code completion to provide more accurate completions for the current context.

1664

We just return failure from any completion point to stop parsing. Added a comment.

mlir/lib/Tools/lsp-server-support/Protocol.h
671

Yes, it's from the LSP specification. All of the enums/structs/etc. in this file are based on the specification (and have the same naming). The header comment contains a link to the spec (updated the link in the header given that the location of the spec has changed).

mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
608

This should be fixed now.

658

It provides a nicer presentation of the C++ class of the result's constraint (provides syntax highlighting).