Changeset View
Changeset View
Standalone View
Standalone View
languages/clang/util/clangutils.h
Show All 22 Lines | |||||
23 | #define CLANGUTILS_H | 23 | #define CLANGUTILS_H | ||
24 | 24 | | |||
25 | #include <util/path.h> | 25 | #include <util/path.h> | ||
26 | 26 | | |||
27 | #include <KTextEditor/View> | 27 | #include <KTextEditor/View> | ||
28 | 28 | | |||
29 | #include <clang-c/Index.h> | 29 | #include <clang-c/Index.h> | ||
30 | 30 | | |||
31 | #include "clangprivateexport.h" | ||||
32 | | ||||
31 | namespace KDevelop { | 33 | namespace KDevelop { | ||
32 | class IndexedString; | 34 | class IndexedString; | ||
33 | } | 35 | } | ||
34 | 36 | | |||
35 | namespace ClangUtils | 37 | namespace ClangUtils | ||
36 | { | 38 | { | ||
37 | /** | 39 | /** | ||
38 | * Finds the most specific CXCursor which applies to the the specified line and column | 40 | * Finds the most specific CXCursor which applies to the the specified line and column | ||
Show All 36 Lines | |||||
75 | * Given a cursor and destination context, returns the string representing the | 77 | * Given a cursor and destination context, returns the string representing the | ||
76 | * cursor's scope at its current location. | 78 | * cursor's scope at its current location. | ||
77 | * | 79 | * | ||
78 | * @param cursor The cursor to examine | 80 | * @param cursor The cursor to examine | ||
79 | * @param context The destination context from which the cursor should be referenced. | 81 | * @param context The destination context from which the cursor should be referenced. | ||
80 | * By default this will be set to the cursors lexical parent. | 82 | * By default this will be set to the cursors lexical parent. | ||
81 | * @return the cursor's scope as a string | 83 | * @return the cursor's scope as a string | ||
82 | */ | 84 | */ | ||
83 | QString getScope(CXCursor cursor, CXCursor context = clang_getNullCursor()); | 85 | KDEVCLANGPRIVATE_EXPORT QString getScope(CXCursor cursor, CXCursor context = clang_getNullCursor()); | ||
84 | 86 | | |||
85 | /** | 87 | /** | ||
86 | * Given a cursor representing some sort of function, returns its signature. The | 88 | * Given a cursor representing some sort of function, returns its signature. The | ||
87 | * effect of this function when passed a non-function cursor is undefined. | 89 | * effect of this function when passed a non-function cursor is undefined. | ||
88 | * | 90 | * | ||
89 | * @param cursor The cursor to work with | 91 | * @param cursor The cursor to work with | ||
90 | * @param scope The scope of the cursor (e.g. "SomeNS::SomeClass") | 92 | * @param scope The scope of the cursor (e.g. "SomeNS::SomeClass") | ||
91 | * @return A QString of the function's signature | 93 | * @return A QString of the function's signature | ||
92 | */ | 94 | */ | ||
93 | QString getCursorSignature(CXCursor cursor, const QString& scope, const QVector<QString>& defaultArgs = QVector<QString>()); | 95 | QString getCursorSignature(CXCursor cursor, const QString& scope, const QVector<QString>& defaultArgs = QVector<QString>()); | ||
94 | 96 | | |||
95 | /** | 97 | /** | ||
96 | * Given a cursor representing the template argument list, return a | 98 | * Given a cursor representing the template argument list, return a | ||
97 | * list of the argument types. | 99 | * list of the argument types. | ||
98 | * | 100 | * | ||
99 | * @param cursor The cursor to work with | 101 | * @param cursor The cursor to work with | ||
100 | * @return A QStringList of the template's arguments | 102 | * @return A QStringList of the template's arguments | ||
101 | */ | 103 | */ | ||
102 | QStringList templateArgumentTypes(CXCursor cursor); | 104 | KDEVCLANGPRIVATE_EXPORT QStringList templateArgumentTypes(CXCursor cursor); | ||
103 | 105 | | |||
104 | /** | 106 | /** | ||
105 | * Extract the raw contents of the range @p range | 107 | * Extract the raw contents of the range @p range | ||
106 | * | 108 | * | ||
107 | * @note This will return the exact textual representation of the code, | 109 | * @note This will return the exact textual representation of the code, | ||
108 | * no whitespace stripped, etc. | 110 | * no whitespace stripped, etc. | ||
109 | * | 111 | * | ||
110 | * TODO: It would better if we'd be able to just memcpy parts of the file buffer | 112 | * TODO: It would better if we'd be able to just memcpy parts of the file buffer | ||
111 | * that's stored inside Clang (cf. llvm::MemoryBuffer for files), but libclang | 113 | * that's stored inside Clang (cf. llvm::MemoryBuffer for files), but libclang | ||
112 | * doesn't offer API for that. This implementation here is a lot more expensive. | 114 | * doesn't offer API for that. This implementation here is a lot more expensive. | ||
113 | * | 115 | * | ||
114 | * @param unit Translation unit this range is part of | 116 | * @param unit Translation unit this range is part of | ||
115 | */ | 117 | */ | ||
116 | QByteArray getRawContents(CXTranslationUnit unit, CXSourceRange range); | 118 | KDEVCLANGPRIVATE_EXPORT QByteArray getRawContents(CXTranslationUnit unit, CXSourceRange range); | ||
117 | 119 | | |||
118 | /** | 120 | /** | ||
119 | * @brief Return true if file @p file1 and file @p file2 are equal | 121 | * @brief Return true if file @p file1 and file @p file2 are equal | ||
120 | * | 122 | * | ||
121 | * @see clang_File_isEqual | 123 | * @see clang_File_isEqual | ||
122 | */ | 124 | */ | ||
123 | inline bool isFileEqual(CXFile file1, CXFile file2) | 125 | inline bool isFileEqual(CXFile file1, CXFile file2) | ||
124 | { | 126 | { | ||
Show All 22 Lines | 134 | #endif | |||
147 | * Extract the range of the path-spec inside the include-directive in line @p line | 149 | * Extract the range of the path-spec inside the include-directive in line @p line | ||
148 | * | 150 | * | ||
149 | * Example: line = "#include <vector>" => returns {0, 10, 0, 16} | 151 | * Example: line = "#include <vector>" => returns {0, 10, 0, 16} | ||
150 | * | 152 | * | ||
151 | * @param originalRange This is the range that the resulting range will be based on | 153 | * @param originalRange This is the range that the resulting range will be based on | ||
152 | * | 154 | * | ||
153 | * @return Range pointing to the path-spec of the include or invalid range if there is no #include directive on the line. | 155 | * @return Range pointing to the path-spec of the include or invalid range if there is no #include directive on the line. | ||
154 | */ | 156 | */ | ||
155 | KTextEditor::Range rangeForIncludePathSpec(const QString& line, const KTextEditor::Range& originalRange = KTextEditor::Range()); | 157 | KDEVCLANGPRIVATE_EXPORT KTextEditor::Range rangeForIncludePathSpec(const QString& line, const KTextEditor::Range& originalRange = KTextEditor::Range()); | ||
156 | 158 | | |||
157 | enum SpecialQtAttributes { | 159 | enum SpecialQtAttributes { | ||
158 | NoQtAttribute, | 160 | NoQtAttribute, | ||
159 | QtSignalAttribute, | 161 | QtSignalAttribute, | ||
160 | QtSlotAttribute | 162 | QtSlotAttribute | ||
161 | }; | 163 | }; | ||
162 | /** | 164 | /** | ||
163 | * Given a cursor representing a CXXmethod | 165 | * Given a cursor representing a CXXmethod | ||
164 | */ | 166 | */ | ||
165 | SpecialQtAttributes specialQtAttributes(CXCursor cursor); | 167 | SpecialQtAttributes specialQtAttributes(CXCursor cursor); | ||
166 | }; | 168 | }; | ||
167 | 169 | | |||
168 | #endif // CLANGUTILS_H | 170 | #endif // CLANGUTILS_H |