blob: 87c257c49d4b0dde3d4c7b02fb37b2ee1dae08c8 [file] [log] [blame]
Ben Clayton7883a0c2023-04-20 23:51:53 +00001// Copyright 2023 The Tint Authors.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
dan sinclair99181d82023-07-20 01:14:15 +000015#ifndef SRC_TINT_LANG_WGSL_AST_DIAGNOSTIC_RULE_NAME_H_
16#define SRC_TINT_LANG_WGSL_AST_DIAGNOSTIC_RULE_NAME_H_
Ben Clayton7883a0c2023-04-20 23:51:53 +000017
18#include <string>
19
dan sinclair99181d82023-07-20 01:14:15 +000020#include "src/tint/lang/wgsl/ast/node.h"
Ben Clayton7883a0c2023-04-20 23:51:53 +000021
22// Forward declarations
23namespace tint::ast {
24class Identifier;
25} // namespace tint::ast
26
27namespace tint::ast {
28
29/// A diagnostic rule name used for diagnostic directives and attributes.
dan sinclairbae54e72023-07-28 15:01:54 +000030class DiagnosticRuleName final : public Castable<DiagnosticRuleName, Node> {
Ben Clayton7883a0c2023-04-20 23:51:53 +000031 public:
32 /// Constructor
33 /// @param pid the identifier of the program that owns this node
34 /// @param nid the unique node identifier
35 /// @param src the source of this node
36 /// @param name the rule name
dan sinclair637a2fe2023-07-24 21:11:41 +000037 DiagnosticRuleName(GenerationID pid, NodeID nid, const Source& src, const Identifier* name);
Ben Clayton7883a0c2023-04-20 23:51:53 +000038
39 /// Constructor
40 /// @param pid the identifier of the program that owns this node
41 /// @param nid the unique node identifier
42 /// @param src the source of this node
43 /// @param category the rule category.
44 /// @param name the rule name
dan sinclair637a2fe2023-07-24 21:11:41 +000045 DiagnosticRuleName(GenerationID pid,
Ben Clayton7883a0c2023-04-20 23:51:53 +000046 NodeID nid,
47 const Source& src,
48 const Identifier* category,
49 const Identifier* name);
50
51 /// Clones this node and all transitive child nodes using the `CloneContext` `ctx`.
52 /// @param ctx the clone context
53 /// @return the newly cloned node
Ben Claytonae18c412023-07-29 13:00:40 +000054 const DiagnosticRuleName* Clone(CloneContext& ctx) const override;
Ben Clayton7883a0c2023-04-20 23:51:53 +000055
56 /// @return the full name of this diagnostic rule, either as `name` or `category.name`.
57 std::string String() const;
58
59 /// The diagnostic rule category (category.name)
60 Identifier const* const category = nullptr;
61
62 /// The diagnostic rule name.
63 Identifier const* const name;
64};
65
66} // namespace tint::ast
67
dan sinclair99181d82023-07-20 01:14:15 +000068#endif // SRC_TINT_LANG_WGSL_AST_DIAGNOSTIC_RULE_NAME_H_