C++ 铿锵代码完成-实现设计
是否有一些隐藏的文档是如何实现clang的代码完成部分的?到目前为止,我发现一个特殊的标记(tok::code_completion)被注入到lexer中,并在解析器中处理。在观察到这样一个标记后,解析器可以填充可能的完成字符串 我不明白的是:C++ 铿锵代码完成-实现设计,c++,compiler-construction,clang,llvm,code-completion,C++,Compiler Construction,Clang,Llvm,Code Completion,是否有一些隐藏的文档是如何实现clang的代码完成部分的?到目前为止,我发现一个特殊的标记(tok::code_completion)被注入到lexer中,并在解析器中处理。在观察到这样一个标记后,解析器可以填充可能的完成字符串 我不明白的是: 如果被调用的功能决定我们可以插入当前上下文中可用的变量。如何处理这类案件 struct FooBar { void foo() { ba<<code completion here>> }
如果被调用的功能决定我们可以插入当前上下文中可用的变量。如何处理这类案件
struct FooBar {
void foo() {
ba<<code completion here>>
}
void bar() {
}
};
struct FooBar{
void foo(){
ba<此处代码完成>
}
空条(){
}
};
解析器没有看到bar,但调用它是有效的 在我看来,当解析结构中的方法定义时,这是一个普遍的问题,而不是特定于代码完成。在任何情况下,解析器中都有专门针对这种情况的处理,您可以在中找到 从Parser::ParseCXXInlineMethodDef()上的注释中: 稍后,解析方法定义的代码:
/// ParseLexedMethodDefs - We finished parsing the member specification of a top
/// (non-nested) C++ class. Now go over the stack of lexed methods that were
/// collected during its parsing and parse them all.
void Parser::ParseLexedMethodDefs(...
因此,lexer为函数体生成的标记只在解析了类的其余部分之后才被解析
/// ParseLexedMethodDefs - We finished parsing the member specification of a top
/// (non-nested) C++ class. Now go over the stack of lexed methods that were
/// collected during its parsing and parse them all.
void Parser::ParseLexedMethodDefs(...