1 /*
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 
17 #include "NamedType.h"
18 
19 namespace android {
20 
NamedType(const char * localName,const Location & loc)21 NamedType::NamedType(const char *localName, const Location &loc)
22     : mLocalName(localName), mLocation(loc) {
23 }
24 
isNamedType() const25 bool NamedType::isNamedType() const {
26     return true;
27 }
28 
setFullName(const FQName & fullName)29 void NamedType::setFullName(const FQName &fullName) {
30     mFullName = fullName;
31 }
32 
addNamedTypesToSet(std::set<const FQName> & set) const33 void NamedType::addNamedTypesToSet(std::set<const FQName> &set) const {
34     set.insert(mFullName);
35 }
36 
fqName() const37 const FQName &NamedType::fqName() const {
38     return mFullName;
39 }
40 
localName() const41 std::string NamedType::localName() const {
42     return mLocalName;
43 }
44 
fullName() const45 std::string NamedType::fullName() const {
46     return mFullName.cppName();
47 }
48 
partialCppName() const49 std::string NamedType::partialCppName() const {
50     return mFullName.cppLocalName();
51 }
52 
fullJavaName() const53 std::string NamedType::fullJavaName() const {
54     return mFullName.javaName();
55 }
56 
location() const57 const Location &NamedType::location() const {
58     return mLocation;
59 }
60 
emitDump(Formatter & out,const std::string & streamName,const std::string & name) const61 void 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 
68 }  // namespace android
69 
70