File indexing completed on 2024-04-28 04:34:23

0001 /***************************************************************************
0002  *   This file is part of KDevelop                                         *
0003  *   Copyright 2010 Niko Sams <niko.sams@gmail.com>                        *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU Library General Public License as       *
0007  *   published by the Free Software Foundation; either version 2 of the    *
0008  *   License, or (at your option) any later version.                       *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU Library General Public     *
0016  *   License along with this program; if not, write to the                 *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
0019  ***************************************************************************/
0020 
0021 #include "declarationbuilder.h"
0022 
0023 #include <interfaces/icore.h>
0024 #include <language/duchain/classdeclaration.h>
0025 
0026 #include "cssast.h"
0027 #include "../../parser/parsesession.h"
0028 #include "../../parser/editorintegrator.h"
0029 
0030 namespace Css
0031 {
0032 
0033 void DeclarationBuilder::closeDeclaration()
0034 {
0035     eventuallyAssignInternalContext();
0036     DeclarationBuilderBase::closeDeclaration();
0037 }
0038 
0039 void DeclarationBuilder::visitRuleset(RulesetAst *node)
0040 {
0041     {
0042         KDevelop::RangeInRevision range = editor()->findRange(node->selectors);
0043         KDevelop::QualifiedIdentifier id(KDevelop::Identifier(KDevelop::IndexedString(editor()->nodeToString(node->selectors))));
0044         KDevelop::DUChainWriteLocker lock(KDevelop::DUChain::lock());
0045         KDevelop::ClassDeclaration* dec = openDefinition<KDevelop::ClassDeclaration>(id, range);
0046         dec->setKind(KDevelop::Declaration::Type);
0047         dec->clearBaseClasses();
0048         dec->setClassType(KDevelop::ClassDeclarationData::Class);
0049     }
0050     DeclarationBuilderBase::visitRuleset(node);
0051     closeDeclaration();
0052 }
0053 
0054 
0055 }