MCPcopy Create free account
hub / github.com/KDE/kdevelop / runSession

Method runSession

plugins/clang/tests/clang-parser.cpp:62–102  ·  view source on GitHub ↗

* actually run the parse session */

Source from the content-addressed store, hash-verified

60 * actually run the parse session
61 */
62 void runSession()
63 {
64 if (!m_session.unit()) {
65 qerr << "failed to parse code" << Qt::endl;
66 }
67 if (m_printTokens) {
68 CXTranslationUnit TU = m_session.unit();
69 auto cursor = clang_getTranslationUnitCursor(TU);
70 CXSourceRange range = clang_getCursorExtent(cursor);
71 const ClangTokens tokens(TU, range);
72 for (CXToken token : tokens) {
73 CXString spelling = clang_getTokenSpelling(TU, token);
74 qout << "token= " << clang_getCString(spelling) << Qt::endl;
75 clang_disposeString(spelling);
76 }
77 }
78
79 if (!m_session.unit()) {
80 qerr << "no AST tree could be generated" << Qt::endl;
81 exit(255);
82 return;
83 }
84
85 qout << "AST tree successfully generated" << Qt::endl;
86 auto file = m_session.mainFile();
87
88 if (m_printAst) {
89 DebugVisitor visitor(&m_session);
90 visitor.visit(m_session.unit(), file);
91 }
92
93 const auto problems = m_session.problemsForFile(file);
94 if (!problems.isEmpty()) {
95 qerr << "\nproblems encountered during parsing:" << Qt::endl;
96 for (const ProblemPointer& problem : problems) {
97 qerr << problem->toString() << Qt::endl;
98 }
99 } else {
100 qout << "no problems encountered during parsing" << Qt::endl;
101 }
102 }
103
104 ClangParsingEnvironment environment(const QString& fileName) const
105 {

Callers

nothing calls this directly

Calls 6

mainFileMethod · 0.80
problemsForFileMethod · 0.80
unitMethod · 0.45
visitMethod · 0.45
isEmptyMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected