blob: cb6556c6be55f55445120f152264f3916c4050c6 [file] [log] [blame]
Andreas Huber1aec3972016-08-26 09:26:32 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
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
Andreas Huberc9410c72016-07-28 12:18:40 -070017#include "NamedType.h"
18
19namespace android {
20
Yifan Honga4b53d02016-10-31 17:29:10 -070021NamedType::NamedType(const char *localName, const Location &loc)
22 : mLocalName(localName), mLocation(loc) {
Andreas Huber9ed827c2016-08-22 12:31:13 -070023}
Andreas Huber31629bc2016-08-03 09:06:40 -070024
Andreas Huber39fa7182016-08-19 14:27:33 -070025bool NamedType::isNamedType() const {
26 return true;
27}
28
Andreas Huber31629bc2016-08-03 09:06:40 -070029void NamedType::setFullName(const FQName &fullName) {
30 mFullName = fullName;
Andreas Huberc9410c72016-07-28 12:18:40 -070031}
32
Steven Moreland979e0992016-09-07 09:18:08 -070033void NamedType::addNamedTypesToSet(std::set<const FQName> &set) const {
34 set.insert(mFullName);
35}
36
Andreas Huberbfd76212016-08-09 11:12:16 -070037const FQName &NamedType::fqName() const {
38 return mFullName;
39}
40
Andreas Huber0e00de42016-08-03 09:56:02 -070041std::string NamedType::localName() const {
Andreas Huber31629bc2016-08-03 09:06:40 -070042 return mLocalName;
43}
44
45std::string NamedType::fullName() const {
Andreas Huber0e00de42016-08-03 09:56:02 -070046 return mFullName.cppName();
Andreas Huberc9410c72016-07-28 12:18:40 -070047}
48
Steven Moreland979e0992016-09-07 09:18:08 -070049std::string NamedType::partialCppName() const {
50 return mFullName.cppLocalName();
51}
52
Andreas Huber2831d512016-08-15 09:33:47 -070053std::string NamedType::fullJavaName() const {
54 return mFullName.javaName();
55}
56
Yifan Honga4b53d02016-10-31 17:29:10 -070057const Location &NamedType::location() const {
58 return mLocation;
59}
60
Yifan Hongf5cc2f72017-01-04 18:02:34 -080061void NamedType::emitDump(
62 Formatter &out,
63 const std::string &streamName,
64 const std::string &name) const {
65 emitDumpWithMethod(out, streamName, fqName().cppNamespace() + "::toString", name);
66}
67
Andreas Huberc9410c72016-07-28 12:18:40 -070068} // namespace android
69