Lines Matching +full:- +full:- +full:user +full:- +full:token

1 //===-- ClangHighlighter.cpp ----------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
25 bool ClangHighlighter::isKeyword(llvm::StringRef token) const { in isKeyword()
26 return keywords.contains(token); in isKeyword()
34 /// Determines which style should be applied to the given token.
37 /// \param token
38 /// The current token.
40 /// The string in the source code the token represents.
45 /// passed by reference and will be updated if the current token starts
48 /// The ColorStyle that should be applied to the token.
51 const clang::Token &token, llvm::StringRef tok_str, in determineClangStyle() argument
55 if (token.is(tok::comment)) { in determineClangStyle()
59 } else if (in_pp_directive || token.getKind() == tok::hash) { in determineClangStyle()
64 } else if (tok::isStringLiteral(token.getKind())) in determineClangStyle()
66 else if (tok::isLiteral(token.getKind())) in determineClangStyle()
71 switch (token.getKind()) { in determineClangStyle()
172 FileID FID = SM.createFileID(buf->getMemBufferRef()); in Highlight()
182 Lexer lex(FID, buf->getMemBufferRef(), SM, Opts); in Highlight()
189 // True once we actually lexed the user provided line. in Highlight()
192 // True if we already highlighted the token under the cursor, false otherwise. in Highlight()
194 Token token; in Highlight() local
197 // Returns true if this is the last token we get from the lexer. in Highlight()
198 exit = lex.LexFromRawLexer(token); in Highlight()
202 SM.getSpellingLineNumber(token.getLocation(), &invalid); in Highlight()
213 unsigned start = SM.getSpellingColumnNumber(token.getLocation(), &invalid); in Highlight()
217 --start; in Highlight()
220 if (token.isAnnotation()) in Highlight()
223 // Extract the token string from our source code. in Highlight()
224 llvm::StringRef tok_str = line.substr(start, token.getLength()); in Highlight()
226 // If the token is just an empty string, we can skip all the work below. in Highlight()
230 // If the cursor is inside this token, we have to apply the 'selected' in Highlight()
231 // highlight style before applying the actual token color. in Highlight()
234 auto end = start + token.getLength(); in Highlight()
241 // See how we are supposed to highlight this token. in Highlight()
243 determineClangStyle(*this, token, tok_str, options, in_pp_directive); in Highlight()
253 // user the normal line and pretend we don't know how to highlight it. In in Highlight()
257 assert(false && "We couldn't find the user line in the input file?"); in Highlight()