lokdialog: convert the show sheet dialog to async exec
[LibreOffice.git] / idlc / source / astdeclaration.cxx
blob064cc324480cd532dc4bb2d02bd18029eb730f68
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <astdeclaration.hxx>
21 #include <astscope.hxx>
22 #include <rtl/strbuf.hxx>
23 #include <osl/diagnose.h>
25 static OString sGlobal("::");
27 static OString convertName(const OString& name)
29 OStringBuffer nameBuffer(name.getLength()+1);
30 sal_Int32 nIndex = 0;
33 OString token( name.getToken( 0, ':', nIndex ) );
34 if( !token.isEmpty() )
36 nameBuffer.append('/');
37 nameBuffer.append( token );
39 } while( nIndex != -1 );
40 return nameBuffer.makeStringAndClear();
43 AstDeclaration::AstDeclaration(NodeType type, const OString& name, AstScope* pScope)
44 : m_localName(name)
45 , m_pScope(pScope)
46 , m_nodeType(type)
47 , m_bImported(false)
48 , m_bInMainFile(false)
49 , m_bPredefined(false)
50 , m_lineNumber(0)
52 if ( m_pScope )
54 AstDeclaration* pDecl = scopeAsDecl(m_pScope);
55 if (pDecl)
57 m_scopedName = pDecl->getScopedName();
58 if (!m_scopedName.isEmpty())
59 m_scopedName += sGlobal;
60 m_scopedName += m_localName;
62 } else
64 m_scopedName = m_localName;
66 m_fullName = convertName(m_scopedName);
68 if ( idlc()->getFileName() == idlc()->getRealFileName() )
70 m_fileName = idlc()->getMainFileName();
71 m_bInMainFile = true;
72 } else
74 m_fileName = idlc()->getFileName();
75 m_bImported = true;
78 m_documentation = idlc()->processDocumentation();
80 m_bPublished = idlc()->isPublished();
84 AstDeclaration::~AstDeclaration()
89 void AstDeclaration::setPredefined(bool bPredefined)
91 m_bPredefined = bPredefined;
92 if ( m_bPredefined )
94 m_fileName.clear();
95 m_bInMainFile = false;
99 bool AstDeclaration::isType() const {
100 switch (m_nodeType) {
101 case NT_interface:
102 case NT_instantiated_struct:
103 case NT_enum:
104 case NT_sequence:
105 case NT_typedef:
106 case NT_predefined:
107 case NT_type_parameter:
108 return true;
110 default:
111 OSL_ASSERT(m_nodeType != NT_struct); // see AstStruct::isType
112 return false;
116 bool AstDeclaration::hasAncestor(AstDeclaration* pDecl)
118 if (this == pDecl)
119 return true;
120 if ( !m_pScope )
121 return false;
122 return scopeAsDecl(m_pScope)->hasAncestor(pDecl);
125 bool AstDeclaration::dump(RegistryKey& rKey)
127 AstScope* pScope = declAsScope(this);
128 bool bRet = true;
130 if ( pScope )
132 DeclList::const_iterator iter = pScope->getIteratorBegin();
133 DeclList::const_iterator end = pScope->getIteratorEnd();
134 AstDeclaration* pDecl = nullptr;
135 while ( iter != end && bRet)
137 pDecl = *iter;
138 if ( pDecl->isInMainfile() )
140 switch ( pDecl->getNodeType() )
142 case NT_module:
143 case NT_constants:
144 case NT_interface:
145 case NT_struct:
146 case NT_exception:
147 case NT_enum:
148 case NT_typedef:
149 case NT_service:
150 case NT_singleton:
151 bRet = pDecl->dump(rKey);
152 break;
153 default:
154 break;
158 ++iter;
161 return bRet;
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */