Path: blob/main/contrib/llvm-project/clang/lib/Format/AffectedRangeManager.h
35233 views
//===--- AffectedRangeManager.h - Format C++ code ---------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7///8/// \file9/// AffectedRangeManager class manages affected ranges in the code.10///11//===----------------------------------------------------------------------===//1213#ifndef LLVM_CLANG_LIB_FORMAT_AFFECTEDRANGEMANAGER_H14#define LLVM_CLANG_LIB_FORMAT_AFFECTEDRANGEMANAGER_H1516#include "clang/Basic/SourceManager.h"1718namespace clang {19namespace format {2021struct FormatToken;22class AnnotatedLine;2324class AffectedRangeManager {25public:26AffectedRangeManager(const SourceManager &SourceMgr,27const ArrayRef<CharSourceRange> Ranges)28: SourceMgr(SourceMgr), Ranges(Ranges.begin(), Ranges.end()) {}2930// Determines which lines are affected by the SourceRanges given as input.31// Returns \c true if at least one line in \p Lines or one of their32// children is affected.33bool computeAffectedLines(SmallVectorImpl<AnnotatedLine *> &Lines);3435// Returns true if 'Range' intersects with one of the input ranges.36bool affectsCharSourceRange(const CharSourceRange &Range);3738private:39// Returns true if the range from 'First' to 'Last' intersects with one of the40// input ranges.41bool affectsTokenRange(const FormatToken &First, const FormatToken &Last,42bool IncludeLeadingNewlines);4344// Returns true if one of the input ranges intersect the leading empty lines45// before 'Tok'.46bool affectsLeadingEmptyLines(const FormatToken &Tok);4748// Marks all lines between I and E as well as all their children as affected.49void markAllAsAffected(SmallVectorImpl<AnnotatedLine *>::iterator I,50SmallVectorImpl<AnnotatedLine *>::iterator E);5152// Determines whether 'Line' is affected by the SourceRanges given as input.53// Returns \c true if line or one if its children is affected.54bool nonPPLineAffected(AnnotatedLine *Line, const AnnotatedLine *PreviousLine,55SmallVectorImpl<AnnotatedLine *> &Lines);5657const SourceManager &SourceMgr;58const SmallVector<CharSourceRange, 8> Ranges;59};6061} // namespace format62} // namespace clang6364#endif // LLVM_CLANG_LIB_FORMAT_AFFECTEDRANGEMANAGER_H656667