Skip to content

Commit

Permalink
Implement codeComplete for cling
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-penev committed Apr 30, 2024
1 parent fa4dab3 commit 0e51ef8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/Interpreter/Compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,34 @@ getSymbolAddress(const cling::Interpreter& I, llvm::StringRef IRName) {
Names.push_back(Jit.getExecutionSession().intern(IRName));
return llvm::make_error<llvm::orc::SymbolsNotFound>(Names);
}

inline void codeComplete(cling::Interpreter& I, const char* code, std::vector<std::string>& Results) {
std::vector<std::string> results;
cling::Interpreter::CompilationResult compilation_result;

compilation_result = I.codeComplete(code, std::string(code).size() + 1, results);

for (auto& r : results) {
printf("!!!%s\n", r.c_str());
//if (r.find(CC.Prefix) == 0)
Results.push_back(r);
}

/*
for (auto& r : result) {
// remove the definition at the beginning (for example [#int#])
r = std::regex_replace(r, std::regex("\\[\\#.*\\#\\]"), "");
// remove the variable name in <#type name#>
r = std::regex_replace(r, std::regex("(\\ |\\*)+(\\w+)(\\#\\>)"), "$1$3");
// remove unnecessary space at the end of <#type #>
r = std::regex_replace(r, std::regex("\\ *(\\#\\>)"), "$1");
// remove <# #> to keep only the type
r = std::regex_replace(r, std::regex("\\<\\#([^#>]*)\\#\\>"), "$1");
}
*/
//assert(false && "CodeCompletion API is not implemented yet.");
}

} // namespace compat

#endif // USE_CLING
Expand Down

0 comments on commit 0e51ef8

Please sign in to comment.