diff options
| author | Yong He <yonghe@outlook.com> | 2022-06-16 01:50:43 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-16 01:50:43 -0700 |
| commit | 241def9c7619c437aad1bb620be8891e61707d8d (patch) | |
| tree | d412a108bcd4bc9e52e0d6bf230b16d90df632d2 /source/slang/slang-parser.cpp | |
| parent | 23f567323e36a14e0649899b5b8811312d7ea9fd (diff) | |
Language server: document symbols (#2287)
* Language Server: Document Symbol outline.
* Fix highlighting of extension decls.
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-parser.cpp')
| -rw-r--r-- | source/slang/slang-parser.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp index aaf175812..c8a990ab1 100644 --- a/source/slang/slang-parser.cpp +++ b/source/slang/slang-parser.cpp @@ -2889,7 +2889,6 @@ namespace Slang decl->targetType = parser->ParseTypeExp(); parseOptionalInheritanceClause(parser, decl); parseDeclBody(parser, decl); - return decl; } @@ -3199,9 +3198,14 @@ namespace Slang if( parser->tokenReader.peekTokenType() == TokenType::LBrace ) { decl->body = parser->parseBlockStatement(); + if (auto block = as<BlockStmt>(decl->body)) + { + decl->closingSourceLoc = block->closingSourceLoc; + } } else { + decl->closingSourceLoc = parser->tokenReader.peekLoc(); parser->ReadToken(TokenType::Semicolon); } @@ -3216,14 +3220,18 @@ namespace Slang if( AdvanceIf(parser, TokenType::LBrace) ) { // We want to parse nested "accessor" declarations - while( !AdvanceIfMatch(parser, MatchedTokenType::CurlyBraces) ) + Token closingToken; + while (!AdvanceIfMatch(parser, MatchedTokenType::CurlyBraces, &closingToken)) { auto accessor = parseAccessorDecl(parser); AddMember(decl, accessor); } + decl->closingSourceLoc = closingToken.loc; } else { + decl->closingSourceLoc = parser->tokenReader.peekLoc(); + parser->ReadToken(TokenType::Semicolon); // empty body should be treated like `{ get; }` @@ -3970,8 +3978,8 @@ namespace Slang { parseOptionalInheritanceClause(parser, decl); parser->ReadToken(TokenType::LBrace); - - while(!AdvanceIfMatch(parser, MatchedTokenType::CurlyBraces)) + Token closingToken; + while (!AdvanceIfMatch(parser, MatchedTokenType::CurlyBraces, &closingToken)) { EnumCaseDecl* caseDecl = parseEnumCaseDecl(parser); AddMember(decl, caseDecl); @@ -3981,6 +3989,7 @@ namespace Slang parser->ReadToken(TokenType::Comma); } + decl->closingSourceLoc = closingToken.loc; return decl; }); } |
