Changeset View
Changeset View
Standalone View
Standalone View
clang-tools-extra/clangd/Hover.cpp
//===--- Hover.cpp - Information about code at the cursor location --------===// | //===--- Hover.cpp - Information about code at the cursor location --------===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#include "Hover.h" | #include "Hover.h" | ||||
#include "AST.h" | #include "AST.h" | ||||
#include "CodeCompletionStrings.h" | #include "CodeCompletionStrings.h" | ||||
#include "Config.h" | |||||
#include "FindTarget.h" | #include "FindTarget.h" | ||||
#include "ParsedAST.h" | #include "ParsedAST.h" | ||||
#include "Selection.h" | #include "Selection.h" | ||||
#include "SourceCode.h" | #include "SourceCode.h" | ||||
#include "index/SymbolCollector.h" | #include "index/SymbolCollector.h" | ||||
#include "support/Logger.h" | #include "support/Logger.h" | ||||
#include "support/Markup.h" | #include "support/Markup.h" | ||||
#include "clang/AST/ASTContext.h" | #include "clang/AST/ASTContext.h" | ||||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | HoverInfo::PrintedType printType(QualType QT, ASTContext &ASTCtx, | ||||
// This isn't very idiomatic, so don't attempt it for complex cases, including | // This isn't very idiomatic, so don't attempt it for complex cases, including | ||||
// pointers/references, template specializations, etc. | // pointers/references, template specializations, etc. | ||||
if (!QT.isNull() && !QT.hasQualifiers() && PP.SuppressTagKeyword) { | if (!QT.isNull() && !QT.hasQualifiers() && PP.SuppressTagKeyword) { | ||||
if (auto *TT = llvm::dyn_cast<TagType>(QT.getTypePtr())) | if (auto *TT = llvm::dyn_cast<TagType>(QT.getTypePtr())) | ||||
OS << TT->getDecl()->getKindName() << " "; | OS << TT->getDecl()->getKindName() << " "; | ||||
} | } | ||||
QT.print(OS, PP); | QT.print(OS, PP); | ||||
OS.flush(); | OS.flush(); | ||||
if (!QT.isNull()) { | |||||
const Config &Cfg = Config::current(); | |||||
if (!QT.isNull() && Cfg.Hover.AKAPrint) { | |||||
bool ShouldAKA = false; | bool ShouldAKA = false; | ||||
QualType DesugaredTy = clang::desugarForDiagnostic(ASTCtx, QT, ShouldAKA); | QualType DesugaredTy = clang::desugarForDiagnostic(ASTCtx, QT, ShouldAKA); | ||||
if (ShouldAKA) | if (ShouldAKA) | ||||
Result.AKA = DesugaredTy.getAsString(PP); | Result.AKA = DesugaredTy.getAsString(PP); | ||||
} | } | ||||
return Result; | return Result; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,090 Lines • Show Last 20 Lines |