Lines Matching refs:Code
2282 std::string replaceCRLF(const std::string &Code) { in replaceCRLF() argument
2287 Pos = Code.find("\r\n", LastPos); in replaceCRLF()
2293 NewCode += Code.substr(LastPos); in replaceCRLF()
2296 NewCode += Code.substr(LastPos, Pos - LastPos) + "\n"; in replaceCRLF()
2313 StringRef Code, tooling::Replacements &Replaces, in sortCppIncludes() argument
2389 if (replaceCRLF(result) == replaceCRLF(std::string(Code.substr( in sortCppIncludes()
2410 tooling::Replacements sortCppIncludes(const FormatStyle &Style, StringRef Code, in sortCppIncludes() argument
2415 unsigned Prev = llvm::StringSwitch<size_t>(Code) in sortCppIncludes()
2436 auto Pos = Code.find('\n', SearchFrom); in sortCppIncludes()
2438 Code.substr(Prev, (Pos != StringRef::npos ? Pos : Code.size()) - Prev); in sortCppIncludes()
2467 sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Code, in sortCppIncludes()
2476 if (Pos == StringRef::npos || Pos + 1 == Code.size()) in sortCppIncludes()
2484 sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Code, Replaces, in sortCppIncludes()
2515 StringRef Code, tooling::Replacements &Replaces) { in sortJavaImports() argument
2570 if (replaceCRLF(result) == replaceCRLF(std::string(Code.substr( in sortJavaImports()
2591 tooling::Replacements sortJavaImports(const FormatStyle &Style, StringRef Code, in sortJavaImports() argument
2605 auto Pos = Code.find('\n', SearchFrom); in sortJavaImports()
2607 Code.substr(Prev, (Pos != StringRef::npos ? Pos : Code.size()) - Prev); in sortJavaImports()
2635 if (Pos == StringRef::npos || Pos + 1 == Code.size()) in sortJavaImports()
2640 sortJavaImports(Style, ImportsInBlock, Ranges, FileName, Code, Replaces); in sortJavaImports()
2644 bool isMpegTS(StringRef Code) { in isMpegTS() argument
2648 return Code.size() > 188 && Code[0] == 0x47 && Code[188] == 0x47; in isMpegTS()
2651 bool isLikelyXml(StringRef Code) { return Code.ltrim().startswith("<"); } in isLikelyXml() argument
2653 tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code, in sortIncludes() argument
2659 if (isLikelyXml(Code)) in sortIncludes()
2662 isMpegTS(Code)) in sortIncludes()
2665 return sortJavaScriptImports(Style, Code, Ranges, FileName); in sortIncludes()
2667 return sortJavaImports(Style, Code, Ranges, FileName, Replaces); in sortIncludes()
2668 sortCppIncludes(Style, Code, Ranges, FileName, Replaces, Cursor); in sortIncludes()
2674 processReplacements(T ProcessFunc, StringRef Code, in processReplacements() argument
2680 auto NewCode = applyAllReplacements(Code, Replaces); in processReplacements()
2693 formatReplacements(StringRef Code, const tooling::Replacements &Replaces, in formatReplacements() argument
2697 auto SortIncludes = [](const FormatStyle &Style, StringRef Code, in formatReplacements()
2700 return sortIncludes(Style, Code, Ranges, FileName); in formatReplacements()
2703 processReplacements(SortIncludes, Code, Replaces, Style); in formatReplacements()
2709 auto Reformat = [](const FormatStyle &Style, StringRef Code, in formatReplacements() argument
2712 return reformat(Style, Code, Ranges, FileName); in formatReplacements()
2714 return processReplacements(Reformat, Code, *SortedReplaces, Style); in formatReplacements()
2731 fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces, in fixCppIncludeInsertions() argument
2758 tooling::HeaderIncludes Includes(FileName, Code, Style.IncludeStyle); in fixCppIncludeInsertions()
2803 cleanupAroundReplacements(StringRef Code, const tooling::Replacements &Replaces, in cleanupAroundReplacements() argument
2807 auto Cleanup = [](const FormatStyle &Style, StringRef Code, in cleanupAroundReplacements()
2810 return cleanup(Style, Code, Ranges, FileName); in cleanupAroundReplacements()
2814 fixCppIncludeInsertions(Code, Replaces, Style); in cleanupAroundReplacements()
2815 return processReplacements(Cleanup, Code, NewReplaces, Style); in cleanupAroundReplacements()
2820 reformat(const FormatStyle &Style, StringRef Code, in reformat() argument
2827 if (isLikelyXml(Code)) in reformat()
2829 if (Expanded.Language == FormatStyle::LK_JavaScript && isMpegTS(Code)) in reformat()
2834 std::vector<tooling::Range> Ranges(1, tooling::Range(0, Code.size())); in reformat()
2836 std::make_unique<Environment>(Code, FileName, Ranges, FirstStartColumn, in reformat()
2844 if (applyAllReplacements(Code, Replaces)) { in reformat()
2885 std::make_unique<Environment>(Code, FileName, Ranges, FirstStartColumn, in reformat()
2893 CurrentCode ? StringRef(*CurrentCode) : Code, PassFixes.first); in reformat()
2911 tooling::Replacements reformat(const FormatStyle &Style, StringRef Code, in reformat() argument
2915 return internal::reformat(Style, Code, Ranges, in reformat()
2922 tooling::Replacements cleanup(const FormatStyle &Style, StringRef Code, in cleanup() argument
2928 return Cleaner(Environment(Code, FileName, Ranges), Style).process().first; in cleanup()
2931 tooling::Replacements reformat(const FormatStyle &Style, StringRef Code, in reformat() argument
2935 auto Result = reformat(Style, Code, Ranges, FileName, &Status); in reformat()
2942 StringRef Code, in fixNamespaceEndComments() argument
2945 return NamespaceEndCommentsFixer(Environment(Code, FileName, Ranges), Style) in fixNamespaceEndComments()
2951 StringRef Code, in sortUsingDeclarations() argument
2954 return UsingDeclarationsSorter(Environment(Code, FileName, Ranges), Style) in sortUsingDeclarations()
3022 FormatStyle::LanguageKind guessLanguage(StringRef FileName, StringRef Code) { in guessLanguage() argument
3030 Environment Env(Code, NonEmptyFileName, /*Ranges=*/{}); in guessLanguage()
3046 StringRef Code, llvm::vfs::FileSystem *FS, in getStyle() argument
3051 FormatStyle Style = getLLVMStyle(guessLanguage(FileName, Code)); in getStyle()