• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
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  */
15 
16 #include "ast/ast_sequenceable_type.h"
17 #include "util/autoptr.h"
18 #include "util/string_builder.h"
19 
20 namespace OHOS {
21 namespace Idl {
SetNamespace(ASTNamespace * nspace)22 void ASTSequenceableType::SetNamespace(ASTNamespace* nspace)
23 {
24     ASTType::SetNamespace(nspace);
25     if (namespace_ != nullptr) {
26         namespace_->AddSequenceable(this);
27     }
28 }
29 
GetSignature()30 String ASTSequenceableType::GetSignature()
31 {
32     String fullName = namespace_ != nullptr ?
33             namespace_->ToString() + name_ : name_;
34     return "L" + fullName.Replace('.', '/') + ";";
35 }
36 
IsSequenceableType()37 bool ASTSequenceableType::IsSequenceableType()
38 {
39     return true;
40 }
41 
ToString()42 String ASTSequenceableType::ToString()
43 {
44     return name_;
45 }
46 
Dump(const String & prefix)47 String ASTSequenceableType::Dump(const String& prefix)
48 {
49     StringBuilder sb;
50 
51     sb.Append(prefix).Append("sequenceable ");
52     if (namespace_ != nullptr) {
53         sb.Append(namespace_->ToString());
54     }
55     sb.Append(name_);
56     sb.Append(";\n");
57 
58     return sb.ToString();
59 }
60 } // namespace Idl
61 } // namespace OHOS
62