mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-27 10:40:10 +01:00
Continuing with #3070. Just a dir and file rename (mostly removing prefixes, although for parse_tree_fuzzer and parse_tree_file_test I'm dropping "tree" instead of "parse"). Everything in the parse dir should be marked as a move.
31 lines
1.0 KiB
C++
31 lines
1.0 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#ifndef CARBON_TOOLCHAIN_PARSE_TREE_NODE_LOCATION_TRANSLATOR_H_
|
|
#define CARBON_TOOLCHAIN_PARSE_TREE_NODE_LOCATION_TRANSLATOR_H_
|
|
|
|
#include "toolchain/parse/tree.h"
|
|
|
|
namespace Carbon::Parse {
|
|
|
|
class NodeLocationTranslator : public DiagnosticLocationTranslator<Node> {
|
|
public:
|
|
explicit NodeLocationTranslator(const Lex::TokenizedBuffer* tokens,
|
|
const Tree* parse_tree)
|
|
: token_translator_(tokens), parse_tree_(parse_tree) {}
|
|
|
|
// Map the given token into a diagnostic location.
|
|
auto GetLocation(Node node) -> DiagnosticLocation override {
|
|
return token_translator_.GetLocation(parse_tree_->node_token(node));
|
|
}
|
|
|
|
private:
|
|
Lex::TokenLocationTranslator token_translator_;
|
|
const Tree* parse_tree_;
|
|
};
|
|
|
|
} // namespace Carbon::Parse
|
|
|
|
#endif // CARBON_TOOLCHAIN_PARSE_TREE_NODE_LOCATION_TRANSLATOR_H_
|