MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / ParseToIdentifies

Method ParseToIdentifies

CodeFormatCore/src/Diagnostic/Spell/Util.cpp:68–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68std::vector<Word> text::ParseToIdentifies(std::string_view text) {
69 std::vector<Word> words;
70 if (text.length() < 3) {
71 return words;
72 }
73
74 // give up check long string
75 if (text.front() == '\'' || text.front() == '\"') {
76 text = text.substr(1, text.size() - 2);
77 } else {
78 return words;
79 }
80
81 TextReader reader(text);
82
83 while (true) {
84 switch (Lex(reader)) {
85 case TextType::Unknown: {
86 words.clear();
87 goto endLoop;
88 }
89 case TextType::Identify: {
90 auto range = reader.GetTokenRange();
91 if (range.Length > 3) {
92 range.StartOffset++;
93 words.emplace_back(range, reader.GetSaveText());
94 }
95 break;
96 }
97 case TextType::Ignore: {
98 break;
99 }
100 default:// end
101 {
102 goto endLoop;
103 }
104 }
105 }
106endLoop:
107 return words;
108}
109
110text::TextType text::Lex(TextReader &reader) {
111 reader.ResetBuffer();

Callers

nothing calls this directly

Calls 5

frontMethod · 0.80
GetSaveTextMethod · 0.80
sizeMethod · 0.45
clearMethod · 0.45
GetTokenRangeMethod · 0.45

Tested by

no test coverage detected