创建大纲和摘要来注册语言

问题描述 投票:0回答:1

我正在尝试更新我的语言的注册,并且根据新规范,我需要定义大纲视图和摘要视图

这里是 pico dsl 的示例项目文件在这里语言规范(我假设)在这里

module lang::pico::LanguageServer

import util::LanguageServer;
import util::IDEServices;
import ParseTree;
import util::Reflective;
import lang::pico::\syntax::Main;
import IO;

// a minimal implementation of a DSL in rascal
// users can add support for more advanced features
set[LanguageService] picoContributions() = {
    parser(parser(#start[Program])), // register the parser function for the Pico language
    outliner(picoOutliner),
    summarizer(picoSummarizer, providesImplementations = false)
  };


// we build a simple outline based on the grammar
list[DocumentSymbol] picoOutliner(start[Program] input)
  = [symbol("<input.src>", DocumentSymbolKind::\file(), input.src, children=[
      *[symbol("<var.id>", \variable(), var.src) | /IdType var := input]
  ])];

// normally you would import the typechecker and run it here
// for brevity we've inlined the implementation here
Summary picoSummarizer(loc l, start[Program] input) {
    rel[str, loc] defs = {<"<var.id>", var.src> | /IdType var  := input};
    rel[loc, str] uses = {<id.src, "<id>"> | /Id id := input};
    rel[loc, str] docs = {<var.src, "*variable* <var>"> | /IdType var := input};


    return summary(l,
        messages = {<src, error("<id> is not defined", src)> | <src, id> <- uses, id notin defs<0>},
        references = (uses o defs)<1,0>,
        definitions = uses o defs,
        documentation = (uses o defs) o docs
    );
}

// run this from a REPL while developing the DSL
int main() {
    // we register a new language to Rascal's LSP multiplexer
    // the multiplexer starts a new evaluator and loads this module and function
    registerLanguage(
        language(
            pathConfig(srcs=[|project://pico-dsl-lsp/src/main/rascal|]),
            "Pico", // name of the language
            "pico", // extension
            "lang::pico::LanguageServer", // module to import
            "picoContributions"
        )
    );
    return 0;
}

我正在尝试为我的语言构建一个 Outliner 和 Summarizer(AST 这里)。

data Pipeline
    = pipeline(
    Alphabet alphabet,
    Options options,
    list[Module] modules,
    list[Constraint] constraints,
    list[Handler] handlers
    );
 
data Alphabet
    = alphabet(
    list[SymbolInfo] symbols);

这是到目前为止我所拥有的大纲,我无法找到有关其结构的更多文档:

list[DocumentSymbol] ldOutliner(start[Pipeline] pipeline) {
    return [
        symbol("Pipeline", DocumentSymbolKind::Namespace, pipeline.src, children=[
            *[symbol("Alphabet"
            
                {...}
            ]
        ])
    ];
}

另外,贡献样式定义如下,现在如何定义样式?

Contribution STYLE =
  categories
  (
    (
      "Name" : {bold()},
      "String" : {foregroundColor(color("purple"))},
      "Boolean" : {foregroundColor(color("DarkRed"))},
      "ColorCode" : {foregroundColor(color("Violet"))},
      "Character" :{foregroundColor(color("dimgray"))},
      "ConstraintKeywords" :{foregroundColor(color("Olive"))},
      "Integer" : {foregroundColor(color("orange")), bold()}
    )
    );

如有任何帮助,我们将不胜感激,谢谢!

rascal
1个回答
0
投票
  • DocumentSymbolKind 构造函数缺少新的大纲工具
    ()
    。这使得它成为对函数的引用而不是数据类型的实例。可能是这个错误打印在与您正在查看的视图不同的视图中!
  • LSP 轮廓比我们在 Eclipse 中的轮廓要有限得多,另一方面,为了可用性,所有轮廓现在看起来都一样,行为也一样。
  • 我们也失去了定义或拥有语法类别的能力,从 eclipse IMP 到 VScode,但是,现在 theming 工作得很好,你将免费拥有一个暗模式 DSL 🤓 这意味着注册类别的贡献根本不存在不再了。
© www.soinside.com 2019 - 2024. All rights reserved.