Lines Matching defs:Code
3047 std::string replaceCRLF(const std::string &Code) {
3052 Pos = Code.find("\r\n", LastPos);
3058 NewCode += Code.substr(LastPos);
3061 NewCode += Code.substr(LastPos, Pos - LastPos) + "\n";
3078 StringRef Code, tooling::Replacements &Replaces,
3159 if (replaceCRLF(result) == replaceCRLF(std::string(Code.substr(
3176 tooling::Replacements sortCppIncludes(const FormatStyle &Style, StringRef Code,
3181 unsigned Prev = llvm::StringSwitch<size_t>(Code)
3207 auto Pos = Code.find('\n', SearchFrom);
3209 Code.substr(Prev, (Pos != StringRef::npos ? Pos : Code.size()) - Prev);
3233 Pos = Code.find("*/", SearchFrom + 2);
3252 Pos = Code.find("*/", SearchFrom);
3253 Line = Code.substr(
3254 Prev, (Pos != StringRef::npos ? Pos + 2 : Code.size()) - Prev);
3266 sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Code,
3275 if (Pos == StringRef::npos || Pos + 1 == Code.size())
3283 sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Code, Replaces,
3314 StringRef Code, tooling::Replacements &Replaces) {
3371 if (replaceCRLF(result) == replaceCRLF(std::string(Code.substr(
3393 tooling::Replacements sortJavaImports(const FormatStyle &Style, StringRef Code,
3407 auto Pos = Code.find('\n', SearchFrom);
3409 Code.substr(Prev, (Pos != StringRef::npos ? Pos : Code.size()) - Prev);
3436 if (Pos == StringRef::npos || Pos + 1 == Code.size())
3441 sortJavaImports(Style, ImportsInBlock, Ranges, FileName, Code, Replaces);
3445 bool isMpegTS(StringRef Code) {
3449 return Code.size() > 188 && Code[0] == 0x47 && Code[188] == 0x47;
3452 bool isLikelyXml(StringRef Code) { return Code.ltrim().starts_with("<"); }
3454 tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
3460 if (isLikelyXml(Code))
3463 isMpegTS(Code)) {
3467 return sortJavaScriptImports(Style, Code, Ranges, FileName);
3469 return sortJavaImports(Style, Code, Ranges, FileName, Replaces);
3470 sortCppIncludes(Style, Code, Ranges, FileName, Replaces, Cursor);
3476 processReplacements(T ProcessFunc, StringRef Code,
3482 auto NewCode = applyAllReplacements(Code, Replaces);
3495 formatReplacements(StringRef Code, const tooling::Replacements &Replaces,
3499 auto SortIncludes = [](const FormatStyle &Style, StringRef Code,
3502 return sortIncludes(Style, Code, Ranges, FileName);
3505 processReplacements(SortIncludes, Code, Replaces, Style);
3511 auto Reformat = [](const FormatStyle &Style, StringRef Code,
3514 return reformat(Style, Code, Ranges, FileName);
3516 return processReplacements(Reformat, Code, *SortedReplaces, Style);
3533 fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces,
3560 tooling::HeaderIncludes Includes(FileName, Code, Style.IncludeStyle);
3605 cleanupAroundReplacements(StringRef Code, const tooling::Replacements &Replaces,
3609 auto Cleanup = [](const FormatStyle &Style, StringRef Code,
3612 return cleanup(Style, Code, Ranges, FileName);
3616 fixCppIncludeInsertions(Code, Replaces, Style);
3617 return cantFail(processReplacements(Cleanup, Code, NewReplaces, Style));
3622 reformat(const FormatStyle &Style, StringRef Code,
3645 if (isLikelyXml(Code))
3647 if (Expanded.Language == FormatStyle::LK_JavaScript && isMpegTS(Code))
3652 std::vector<tooling::Range> Ranges(1, tooling::Range(0, Code.size()));
3653 auto Env = Environment::make(Code, FileName, Ranges, FirstStartColumn,
3664 if (applyAllReplacements(Code, Replaces))
3669 auto Env = Environment::make(Code, FileName, Ranges, FirstStartColumn,
3770 CurrentCode ? StringRef(*CurrentCode) : Code, PassFixes.first);
3792 StringRef OriginalCode = Code.substr(Fix.getOffset(), Fix.getLength());
3808 tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
3812 return internal::reformat(Style, Code, Ranges,
3819 tooling::Replacements cleanup(const FormatStyle &Style, StringRef Code,
3825 auto Env = Environment::make(Code, FileName, Ranges);
3831 tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
3835 auto Result = reformat(Style, Code, Ranges, FileName, &Status);
3842 StringRef Code,
3845 auto Env = Environment::make(Code, FileName, Ranges);
3852 StringRef Code,
3855 auto Env = Environment::make(Code, FileName, Ranges);
3944 FormatStyle::LanguageKind guessLanguage(StringRef FileName, StringRef Code) {
3950 if (!Code.empty() && (Extension.empty() || Extension == ".h")) {
3952 Environment Env(Code, NonEmptyFileName, /*Ranges=*/{});
3983 StringRef FallbackStyleName, StringRef Code,
3987 FormatStyle Style = getLLVMStyle(guessLanguage(FileName, Code));