Lines Matching defs:Cursor
164 // Cursor visitor.
175 /// \brief Visit the given cursor and, if requested by the visitor,
178 /// \param Cursor the cursor to visit.
181 /// that this cursor is within the region of interest.
185 bool CursorVisitor::Visit(CXCursor Cursor, bool CheckedRegionOfInterest) {
186 if (clang_isInvalid(Cursor.kind))
189 if (clang_isDeclaration(Cursor.kind)) {
190 const Decl *D = getCursorDecl(Cursor);
192 assert(0 && "Invalid declaration cursor");
202 // If we have a range of interest, and this cursor doesn't intersect with it,
205 SourceRange Range = getRawCursorExtent(Cursor);
210 switch (Visitor(Cursor, Parent, ClientData)) {
218 bool ret = VisitChildren(Cursor);
220 if (PostChildrenVisitor(Cursor, ClientData))
479 /// \brief Visit the children of the given cursor.
483 bool CursorVisitor::VisitChildren(CXCursor Cursor) {
484 if (clang_isReference(Cursor.kind) &&
485 Cursor.kind != CXCursor_CXXBaseSpecifier) {
490 // Set the Parent field to Cursor, then back to its old value once we're
492 SetParentRAII SetParent(Parent, StmtParent, Cursor);
494 if (clang_isDeclaration(Cursor.kind)) {
495 Decl *D = const_cast<Decl *>(getCursorDecl(Cursor));
502 if (clang_isStatement(Cursor.kind)) {
503 if (const Stmt *S = getCursorStmt(Cursor))
509 if (clang_isExpression(Cursor.kind)) {
510 if (const Expr *E = getCursorExpr(Cursor))
516 if (clang_isTranslationUnit(Cursor.kind)) {
517 CXTranslationUnit TU = getCursorTU(Cursor);
545 if (Cursor.kind == CXCursor_CXXBaseSpecifier) {
546 if (const CXXBaseSpecifier *Base = getCursorCXXBaseSpecifier(Cursor)) {
553 if (Cursor.kind == CXCursor_IBOutletCollectionAttr) {
555 cast<IBOutletCollectionAttr>(cxcursor::getCursorAttr(Cursor));
564 // expansion cursor for that token.
566 if (Cursor.kind == CXCursor_MacroDefinition &&
570 getMacroInfo(cxcursor::getCursorMacroDefinition(Cursor), TU);
591 Optional<bool> CursorVisitor::shouldVisitCursor(CXCursor Cursor) {
593 SourceRange Range = getFullCursorExtent(Cursor, AU->getSourceManager());
626 CXCursor Cursor = MakeCXCursor(D, TU, RegionOfInterest);
640 if (Cursor.kind == CXCursor_ObjCInterfaceDecl) {
643 Cursor = MakeCursorObjCClassRef(ID, ID->getLocation(), TU);
645 } else if (Cursor.kind == CXCursor_ObjCProtocolDecl) {
648 Cursor = MakeCursorObjCProtocolRef(PD, PD->getLocation(), TU);
651 const Optional<bool> &V = shouldVisitCursor(Cursor);
656 if (Visit(Cursor, true))
1007 CXCursor Cursor = MakeCXCursor(*I, TU, RegionOfInterest);
1008 const Optional<bool> &V = shouldVisitCursor(Cursor);
1013 if (Visit(Cursor, true))
1246 // range matches up with a reference cursor. Visit the appropriate reference
1247 // cursor.
2586 // Update the current cursor.
2587 CXCursor Cursor = MakeCXCursor(S, StmtParent, TU, RegionOfInterest);
2588 if (!IsInRegionOfInterest(Cursor))
2590 switch (Visitor(Cursor, Parent, ClientData)) {
2595 WL.push_back(PostChildrenVisit(nullptr, Cursor));
3488 (^CXCursorVisitorBlock)(CXCursor cursor, CXCursor parent);
3490 static enum CXChildVisitResult visitWithBlock(CXCursor cursor, CXCursor parent,
3493 return block(cursor, parent);
3507 static enum CXChildVisitResult visitWithBlock(CXCursor cursor, CXCursor parent,
3510 return block->invoke(block, cursor, parent);
3789 // Default handling, give the location of the cursor.
4294 static enum CXChildVisitResult GetCursorVisitor(CXCursor cursor,
4301 // token is so use the actual cursor, don't replace it with a macro expansion
4302 // cursor.
4303 if (cursor.kind == CXCursor_MacroExpansion && Data->PointsAtMacroArgExpansion)
4306 if (clang_isDeclaration(cursor.kind)) {
4309 = dyn_cast_or_null<ObjCMethodDecl>(getCursorDecl(cursor))) {
4314 = dyn_cast_or_null<ObjCInterfaceDecl>(getCursorDecl(cursor))) {
4320 // 'Foo' even though the cursor location was at 'Foo'.
4332 = dyn_cast_or_null<DeclaratorDecl>(getCursorDecl(cursor))) {
4339 // 'Foo' even though the cursor location was at 'Foo'.
4345 = dyn_cast_or_null<ObjCPropertyImplDecl>(getCursorDecl(cursor))) {
4352 // 'Foo' even though the cursor location was at 'Foo'.
4359 if (clang_isExpression(cursor.kind) &&
4362 // Avoid having the cursor of an expression replace the declaration cursor
4366 // MyCXXClass foo; // Make sure pointing at 'foo' returns a VarDecl cursor.
4373 // If our current best cursor is the construction of a temporary object,
4374 // don't replace that cursor with a type reference, because we want
4378 cursor.kind == CXCursor_TypeRef) {
4379 // Keep the cursor pointing at CXXTemporaryObjectExpr but also mark it
4385 *BestCursor = cursor;
4456 // Clear out the "FirstInDeclGroup" part in a declaration cursor, since we
4678 // the token under the cursor.
4795 /// \brief Retrieves the "raw" cursor extent, which is then extended to include
4952 // We would prefer to enumerate all non-reference cursor kinds here.
4953 llvm_unreachable("Unhandled reference cursor kind");
5189 int clang_Cursor_getObjCSelectorIndex(CXCursor cursor) {
5190 return cxcursor::getSelectorIdentifierIndexAndLoc(cursor).first;
5212 CXCursor clang_getOverloadedDecl(CXCursor cursor, unsigned index) {
5213 if (cursor
5216 if (index >= clang_getNumOverloadedDecls(cursor))
5219 CXTranslationUnit TU = getCursorTU(cursor);
5220 OverloadedDeclRefStorage Storage = getCursorOverloadedDeclRef(cursor).first;
5526 static enum CXChildVisitResult AnnotateTokensVisitor(CXCursor cursor,
5529 static bool AnnotateTokensPostChildrenVisitor(CXCursor cursor,
5544 CXCursor Cursor;
5592 enum CXChildVisitResult Visit(CXCursor cursor, CXCursor parent);
5593 bool postVisitChildren(CXCursor cursor);
5614 static inline void updateCursorAnnotation(CXCursor &Cursor,
5616 if (clang_isInvalid(updateC.kind) || !clang_isInvalid(Cursor.kind))
5618 Cursor = updateC;
5621 /// \brief It annotates and advances tokens with a cursor until the comparison
5622 //// between the cursor location and the source range is the same as
5625 /// Pass RangeBefore to annotate tokens with a cursor until a range is reached.
5686 AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) {
5687 SourceRange cursorRange = getRawCursorExtent(cursor);
5693 if (cursor
5695 = dyn_cast_or_null<ObjCPropertyDecl>(getCursorDecl(cursor)))
5699 else if (cursor.kind == CXCursor_ObjCInstanceMethodDecl ||
5700 cursor.kind == CXCursor_ObjCClassMethodDecl) {
5702 = dyn_cast_or_null<ObjCMethodDecl>(getCursorDecl(cursor))) {
5716 else if (cursor.kind == CXCursor_CXXMethod) {
5718 = dyn_cast_or_null<CXXMethodDecl>(getCursorDecl(cursor))) {
5724 else if (cursor.kind == CXCursor_StructDecl ||
5725 cursor.kind == CXCursor_ClassDecl ||
5726 cursor.kind == CXCursor_ClassTemplate ||
5727 cursor.kind == CXCursor_ClassTemplatePartialSpecialization) {
5728 if (const Decl *D = getCursorDecl(cursor))
5735 if (cursor.kind == CXCursor_ObjCInstanceMethodDecl &&
5739 if (clang_isPreprocessing(cursor.kind)) {
5773 if (cursor.kind == CXCursor_MacroExpansion) {
5775 Cursors[I] = cursor;
5781 Cursors[I] = cursor;
5799 const enum CXCursorKind cursorK = clang_getCursorKind(cursor);
5804 clang_isAttribute(cursor.kind))
5809 // Avoid having the cursor of an expression "overwrite" the annotation of the
5813 // MyCXXClass foo; // Make sure we don't annotate 'foo' as a CallExpr cursor.
5815 const Expr *E = getCursorExpr(cursor);
5816 if (const Decl *D = getCursorParentDecl(cursor)) {
5834 Info.Cursor = cursor;
5843 bool AnnotateTokensWorker::postVisitChildren(CXCursor cursor) {
5847 if (!clang_equalCursors(Info.Cursor, cursor))
5854 // Scan the tokens that are at the end of the cursor, but are not captured
5856 annotateAndAdvanceTokens(cursor, RangeOverlap, cursorRange);
5858 // Scan the tokens that are at the beginning of the cursor, but are not
5864 Cursors[I] = cursor;
5868 // encountered the attribute cursor.
5869 if (clang_isAttribute(cursor.kind))
5876 static enum CXChildVisitResult AnnotateTokensVisitor(CXCursor cursor,
5879 return static_cast<AnnotateTokensWorker*>(client_data)->Visit(cursor, parent);
5882 static bool AnnotateTokensPostChildrenVisitor(CXCursor cursor,
5885 postVisitChildren(cursor);
5904 CXChildVisitResult visit(CXCursor cursor, CXCursor parent) {
5905 if (cursor.kind != CXCursor_MacroExpansion)
5908 SourceRange macroRange = getCursorMacroExpansion(cursor).getSourceRange();
5959 MarkMacroArgTokensVisitorDelegate(CXCursor cursor, CXCursor parent,
5961 return static_cast<MarkMacroArgTokensVisitor*>(client_data)->visit(cursor,
6036 // #undefs, to provide specific cursor kinds for those.
6079 CXCursor Cursor =
6083 updateCursorAnnotation(Cursors[TokIdx], Cursor);
6139 // a specific cursor.
6225 // Any token we don't specifically annotate will have a NULL cursor.
6247 // Operations for querying linkage of a cursor.
6251 CXLinkageKind clang_getCursorLinkage(CXCursor cursor) {
6252 if (!clang_isDeclaration(cursor.kind))
6255 const Decl *D = cxcursor::getCursorDecl(cursor);
6270 // Operations for querying language of a cursor.
6346 enum CXAvailabilityKind clang_getCursorAvailability(CXCursor cursor) {
6347 if (clang_isDeclaration(cursor.kind))
6348 if (const Decl *D = cxcursor::getCursorDecl(cursor))
6435 int clang_getCursorPlatformAvailability(CXCursor cursor,
6451 if (!clang_isDeclaration(cursor.kind))
6454 const Decl *D = cxcursor::getCursorDecl(cursor);
6471 CXLanguageKind clang_getCursorLanguage(CXCursor cursor) {
6472 if (clang_isDeclaration(cursor.kind))
6473 return getDeclLanguage(cxcursor::getCursorDecl(cursor));
6478 /// \brief If the given cursor is the "templated" declaration
6530 CXCursor clang_getCursorSemanticParent(CXCursor cursor) {
6531 if (clang_isDeclaration(cursor.kind)) {
6532 if (const Decl *D = getCursorDecl(cursor)) {
6538 getCursorTU(cursor));
6542 if (clang_isStatement(cursor.kind) || clang_isExpression(cursor.kind)) {
6543 if (const Decl *D = getCursorDecl(cursor))
6544 return MakeCXCursor(D, getCursorTU(cursor));
6550 CXCursor clang_getCursorLexicalParent(CXCursor cursor) {
6551 if (clang_isDeclaration(cursor.kind)) {
6552 if (const Decl *D = getCursorDecl(cursor)) {
6558 getCursorTU(cursor));
6567 CXFile clang_getIncludedFile(CXCursor cursor) {
6568 if (cursor.kind != CXCursor_InclusionDirective)
6571 const InclusionDirective *ID = getCursorInclusionDirective(cursor);
7258 Logger &cxindex::Logger::operator<<(CXCursor cursor) {
7259 CXString cursorName = clang_getCursorDisplayName(cursor);
7260 *this << cursorName << "@" << clang_getCursorLocation(cursor);