1
2 /**
3 * Copyright (c) 2025 Huawei Device Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "refactors/refactor_types.h"
18
19 namespace ark::es2panda::lsp {
20
Refactor(const Refactor & other)21 Refactor::Refactor(const Refactor &other)
22 {
23 kinds_.insert(kinds_.end(), other.kinds_.begin(), other.kinds_.end());
24 }
25
operator =(const Refactor & other)26 Refactor &Refactor::operator=(const Refactor &other)
27 {
28 kinds_.insert(kinds_.end(), other.kinds_.begin(), other.kinds_.end());
29 return *this;
30 }
31
operator =(Refactor && other)32 Refactor &Refactor::operator=(Refactor &&other)
33 {
34 kinds_.insert(kinds_.end(), other.kinds_.begin(), other.kinds_.end());
35 return *this;
36 }
37
Refactor(Refactor && other)38 Refactor::Refactor(Refactor &&other)
39 {
40 kinds_.insert(kinds_.end(), other.kinds_.begin(), other.kinds_.end());
41 }
42
IsKind(const std::string & kind) const43 bool Refactor::IsKind(const std::string &kind) const
44 {
45 for (const std::string &rKind : kinds_) {
46 if (rKind.substr(0, kind.length()) == kind) {
47 return true;
48 }
49 }
50 return false;
51 }
52
AddKind(const std::string & kind)53 void Refactor::AddKind(const std::string &kind)
54 {
55 kinds_.push_back(kind);
56 }
57
58 } // namespace ark::es2panda::lsp