FileDistance.cpp
Format.cpp
FS.cpp
- FormattedString.cpp
FuzzyMatch.cpp
GlobalCompilationDatabase.cpp
Headers.cpp
#include "ClangdLSPServer.h"
#include "Diagnostics.h"
#include "DraftStore.h"
-#include "FormattedString.h"
#include "GlobalCompilationDatabase.h"
#include "Protocol.h"
#include "SemanticHighlighting.h"
#include "CodeComplete.h"
#include "FindSymbols.h"
#include "Format.h"
-#include "FormattedString.h"
#include "HeaderSourceSwitch.h"
#include "Headers.h"
#include "ParsedAST.h"
#include "refactor/Rename.h"
#include "refactor/Tweak.h"
#include "support/Logger.h"
+#include "support/Markup.h"
#include "support/Trace.h"
#include "clang/Format/Format.h"
#include "clang/Frontend/CompilerInstance.h"
#include "../clang-tidy/ClangTidyOptions.h"
#include "CodeComplete.h"
-#include "FormattedString.h"
#include "GlobalCompilationDatabase.h"
#include "Hover.h"
#include "Protocol.h"
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETE_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETE_H
-#include "FormattedString.h"
#include "Headers.h"
#include "Protocol.h"
#include "Quality.h"
#include "index/Symbol.h"
#include "index/SymbolOrigin.h"
#include "support/Logger.h"
+#include "support/Markup.h"
#include "support/Path.h"
#include "clang/Sema/CodeCompleteConsumer.h"
#include "clang/Sema/CodeCompleteOptions.h"
#include "AST.h"
#include "CodeCompletionStrings.h"
#include "FindTarget.h"
-#include "FormattedString.h"
#include "ParsedAST.h"
#include "Selection.h"
#include "SourceCode.h"
#include "index/SymbolCollector.h"
#include "support/Logger.h"
+#include "support/Markup.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTTypeTraits.h"
#include "clang/AST/Decl.h"
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_HOVER_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_HOVER_H
-#include "FormattedString.h"
#include "ParsedAST.h"
#include "Protocol.h"
+#include "support/Markup.h"
#include "clang/Index/IndexSymbol.h"
namespace clang {
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_XREFS_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_XREFS_H
-#include "FormattedString.h"
#include "Protocol.h"
#include "SourceCode.h"
#include "index/Index.h"
Context.cpp
FSProvider.cpp
Logger.cpp
+ Markup.cpp
Shutdown.cpp
Threading.cpp
Trace.cpp
-//===--- FormattedString.cpp --------------------------------*- C++-*------===//
+//===--- Markup.cpp -----------------------------------------*- C++-*------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#include "FormattedString.h"
-#include "clang/Basic/CharInfo.h"
+#include "support/Markup.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
namespace clang {
namespace clangd {
namespace markup {
-
namespace {
+/// Like std::isspace but for "C" locale.
+/// FIXME: move to StringExtras?
+bool isSpace(char C) {
+ return C == ' ' || C == '\f' || C == '\n' || C == '\r' || C == '\t' ||
+ C == '\v';
+}
+
// Is <contents a plausible start to an HTML tag?
// Contents may not be the rest of the line, but it's the rest of the plain
// text, so we expect to see at least the tag name.
.drop_while([](char C) {
return llvm::isAlnum(C) || C == '-' || C == '_' || C == ':';
})
- .drop_while(isWhitespace);
+ .drop_while(isSpace);
// The rest of the tag consists of attributes, which have restrictive names.
// If we hit '=', all bets are off (attribute values can contain anything).
for (; !Contents.empty(); Contents = Contents.drop_front()) {
- if (llvm::isAlnum(Contents.front()) || isWhitespace(Contents.front()))
+ if (llvm::isAlnum(Contents.front()) || isSpace(Contents.front()))
continue;
if (Contents.front() == '>' || Contents.startswith("/>"))
return true; // May close the tag.
// a markdown grammar construct.
bool needsLeadingEscape(char C, llvm::StringRef Before, llvm::StringRef After,
bool StartsLine) {
- assert(Before.take_while(isWhitespace).empty());
+ assert(Before.take_while(isSpace).empty());
auto RulerLength = [&]() -> /*Length*/ unsigned {
if (!StartsLine || !Before.empty())
return false;
(After.empty() || After.startswith(" "));
};
auto SpaceSurrounds = [&]() {
- return (After.empty() || isWhitespace(After.front())) &&
- (Before.empty() || isWhitespace(Before.back()));
+ return (After.empty() || isSpace(After.front())) &&
+ (Before.empty() || isSpace(Before.back()));
};
auto WordSurrounds = [&]() {
return (!After.empty() && llvm::isAlnum(After.front())) &&
Chunk &C = Chunks.back();
C.Contents = std::move(Norm);
C.Kind = Chunk::PlainText;
- C.SpaceBefore = isWhitespace(Text.front());
- C.SpaceAfter = isWhitespace(Text.back());
+ C.SpaceBefore = isSpace(Text.front());
+ C.SpaceAfter = isSpace(Text.back());
return *this;
}
-//===--- FormattedString.h ----------------------------------*- C++-*------===//
+//===--- Markup.h -------------------------------------------*- C++-*------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
//
//===----------------------------------------------------------------------===//
//
-// A simple intermediate representation of formatted text that could be
-// converted to plaintext or markdown.
+// A model of formatted text that can be rendered to plaintext or markdown.
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FORMATTEDSTRING_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FORMATTEDSTRING_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_MARKUP_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_MARKUP_H
#include "llvm/Support/raw_ostream.h"
#include <cstddef>
FileIndexTests.cpp
FindSymbolsTests.cpp
FindTargetTests.cpp
- FormattedStringTests.cpp
FormatTests.cpp
FSTests.cpp
FuzzyMatchTests.cpp
support/CancellationTests.cpp
support/ContextTests.cpp
support/FunctionTests.cpp
+ support/MarkupTests.cpp
support/ThreadingTests.cpp
support/TraceTests.cpp
-//===-- FormattedStringTests.cpp ------------------------------------------===//
+//===-- MarkupTests.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#include "FormattedString.h"
+#include "support/Markup.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/raw_ostream.h"