2013-07-08 2 views
4

clang의 코드 완성 부분이 구현 된 방법에 대한 숨겨진 문서가 있습니까? 지금까지 알아 낸 점은 특별한 토큰 (tok :: code_completion)이 렉서에 주입되어 파서에서 처리된다는 것입니다. 그러한 토큰을 관찰 한 후에 파서는 가능한 완성 문자열을 채울 수 있습니다.clang 코드 완성 - 구현 디자인

이해가 잘 못되는 것 :
호출 된 기능이 현재 컨텍스트에서 사용할 수있는 변수를 삽입 할 수 있다고 결정하면. 그러한 사건은 어떻게 처리됩니까?

struct FooBar { 
    void foo() { 
     ba<<code completion here>> 
    } 
    void bar() { 
    } 
}; 

파서가 표시되지 않지만이를 호출 할 수 있습니다.

답변

4

구조체 내부에서 메서드 정의를 파싱 할 때 일반적으로 발생하는 문제이며 코드 완성과 관련이 없습니다. 어쨌든,이 경우에는 파서에 특수 처리가 있습니다.이 경우는 the ParseCXXInlineMethods.cpp file에서 찾을 수 있습니다.

/// ParseCXXInlineMethodDef - We parsed and verified that the specified 
/// Declarator is a well formed C++ inline method definition. Now lex its body 
/// and store its tokens for parsing after the C++ class is complete. 
Parser::DeclPtrTy 
Parser::ParseCXXInlineMethodDef(... 

그리고 후, 메소드 정의 구문 분석 코드 : 주석에서

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(... 

따라서 렉서 생성 된 토큰은 나머지 한 후 구문 분석 클래스의

+0

답변 해 주셔서 감사합니다. – Daniel