Commit 2ef79dca authored by Roberto Raggi's avatar Roberto Raggi

Obsoleted.

parent ab83dcd8
This diff is collapsed.
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
/* This file is part of KDevelop
Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
Copyright (C) 2005 Trolltech AS
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef BINDER_H
#define BINDER_H
#include "default_visitor.h"
#include "cppcodemodel.h"
#include "type_compiler.h"
#include "name_compiler.h"
#include "declarator_compiler.h"
class TokenStream;
class LocationManager;
class Control;
struct NameSymbol;
class Binder: protected DefaultVisitor
{
public:
Binder(CppCodeModel *__model, LocationManager &__location, Control *__control = 0);
virtual ~Binder();
inline TokenStream *tokenStream() const { return _M_token_stream; }
inline CppCodeModel *model() const { return _M_model; }
ScopeModelItem *currentScope();
void run(AST *node, const QString &filename);
protected:
virtual void visitAccessSpecifier(AccessSpecifierAST *);
virtual void visitClassSpecifier(ClassSpecifierAST *);
virtual void visitEnumSpecifier(EnumSpecifierAST *);
virtual void visitEnumerator(EnumeratorAST *);
virtual void visitFunctionDefinition(FunctionDefinitionAST *);
virtual void visitLinkageSpecification(LinkageSpecificationAST *);
virtual void visitNamespace(NamespaceAST *);
virtual void visitSimpleDeclaration(SimpleDeclarationAST *);
virtual void visitTemplateDeclaration(TemplateDeclarationAST *);
virtual void visitTypedef(TypedefAST *);
virtual void visitUsing(UsingAST *);
virtual void visitUsingDirective(UsingDirectiveAST *);
private:
ScopeModelItem *findScope(const QString &name) const;
ScopeModelItem *resolveScope(NameAST *id, ScopeModelItem *scope);
int decode_token(std::size_t index) const;
const NameSymbol *decode_symbol(std::size_t index) const;
CodeModel::AccessPolicy decode_access_policy(std::size_t index) const;
CodeModel::ClassType decode_class_type(std::size_t index) const;
CodeModel::FunctionType changeCurrentFunctionType(CodeModel::FunctionType functionType);
CodeModel::AccessPolicy changeCurrentAccess(CodeModel::AccessPolicy accessPolicy);
NamespaceModelItem *changeCurrentNamespace(NamespaceModelItem *item);
CppClassModelItem *changeCurrentClass(CppClassModelItem *item);
CppFunctionDefinitionModelItem *changeCurrentFunction(CppFunctionDefinitionModelItem *item);
TemplateParameterList changeTemplateParameters(TemplateParameterList templateParameters);
void declare_symbol(SimpleDeclarationAST *node, InitDeclaratorAST *init_declarator);
void applyStorageSpecifiers(const ListNode<std::size_t> *storage_specifiers, MemberModelItem *item);
void applyFunctionSpecifiers(const ListNode<std::size_t> *it, FunctionModelItem *item);
void updateFileAndItemPosition(CodeModelItem *item, AST *node);
TemplateParameterList copyTemplateParameters(const TemplateParameterList &in) const;
private:
CppCodeModel *_M_model;
LocationManager &_M_location;
TokenStream *_M_token_stream;
Control *_M_control;
CodeModel::FunctionType _M_current_function_type;
CodeModel::AccessPolicy _M_current_access;
CppFileModelItem *_M_current_file;
NamespaceModelItem *_M_current_namespace;
CppClassModelItem *_M_current_class;
CppFunctionDefinitionModelItem *_M_current_function;
CppEnumModelItem *_M_current_enum;
TemplateParameterList _M_current_template_parameters;
QHash<QString, ScopeModelItem *> _M_known_scopes;
protected:
TypeCompiler type_cc;
NameCompiler name_cc;
DeclaratorCompiler decl_cc;
};
#endif // BINDER_H
// kate: space-indent on; indent-width 2; replace-tabs on;
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
/* This file is part of KDevelop
Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "class_compiler.h"
#include "lexer.h"
#include "binder.h"
ClassCompiler::ClassCompiler(Binder *binder)
: _M_binder (binder),
_M_token_stream(binder->tokenStream ()),
name_cc(_M_binder),
type_cc(_M_binder)
{
}
ClassCompiler::~ClassCompiler()
{
}
void ClassCompiler::run(ClassSpecifierAST *node)
{
name_cc.run(node->name);
_M_name = name_cc.qualifiedName();
_M_base_classes.clear();
visit(node);
}
void ClassCompiler::visitClassSpecifier(ClassSpecifierAST *node)
{
visit(node->base_clause);
}
void ClassCompiler::visitBaseSpecifier(BaseSpecifierAST *node)
{
name_cc.run(node->name);
QString name = name_cc.qualifiedName();
if (! name.isEmpty())
_M_base_classes.append(name);
}
// kate: space-indent on; indent-width 2; replace-tabs on;
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
/* This file is part of KDevelop
Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef CLASS_COMPILER_H
#define CLASS_COMPILER_H
#include <QtCore/qglobal.h>
#include <QtCore/QStringList>
#include "default_visitor.h"
#include "name_compiler.h"
#include "type_compiler.h"
class TokenStream;
class Binder;
class ClassCompiler: protected DefaultVisitor
{
public:
ClassCompiler(Binder *binder);
virtual ~ClassCompiler();
inline QString name() const { return _M_name; }
inline QStringList baseClasses() const { return _M_base_classes; }
void run(ClassSpecifierAST *node);
protected:
virtual void visitClassSpecifier(ClassSpecifierAST *node);
virtual void visitBaseSpecifier(BaseSpecifierAST *node);
private:
Binder *_M_binder;
TokenStream *_M_token_stream;
QString _M_name;
QStringList _M_base_classes;
NameCompiler name_cc;
TypeCompiler type_cc;
};
#endif // CLASS_COMPILER_H
// kate: space-indent on; indent-width 2; replace-tabs on;
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
/* This file is part of KDevelop
Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "codemodel_finder.h"
#include "cppcodemodel.h"
#include "binder.h"
CodeModelFinder::CodeModelFinder(CppCodeModel *model, Binder *binder)
: _M_model(model),
_M_binder (binder),
name_cc(_M_binder)
{
}
CodeModelFinder::~CodeModelFinder()
{
}
QString CodeModelFinder::resolveScope(NameAST *name, ScopeModelItem *scope, bool *ok)
{
Q_ASSERT(scope != 0);
_M_ok = true;
_M_current_scope = scope->qualifiedName();
visit(name);
*ok = _M_ok;
return _M_current_scope;
}
void CodeModelFinder::visitName(NameAST *node)
{
visitNodes(this, node->qualified_names);
}
void CodeModelFinder::visitUnqualifiedName(UnqualifiedNameAST *node)
{
if (!_M_ok)
return;
if (!_M_current_scope.isEmpty())
_M_current_scope += QLatin1String("::");
name_cc.run(node);
_M_current_scope += name_cc.qualifiedName();
if (!_M_model->hasScope(_M_current_scope))
_M_ok = false;
}
// kate: space-indent on; indent-width 2; replace-tabs on;
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
/* This file is part of KDevelop
Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef CODEMODEL_FINDER_H
#define CODEMODEL_FINDER_H
#include "default_visitor.h"
#include "name_compiler.h"
class Binder;
class CppCodeModel;
class ScopeModelItem;
class CodeModelFinder: protected DefaultVisitor
{
public:
CodeModelFinder(CppCodeModel *model, Binder *binder);
virtual ~CodeModelFinder();
QString resolveScope(NameAST *name, ScopeModelItem *scope, bool *ok);
inline CppCodeModel *model() const { return _M_model; }
protected:
virtual void visitName(NameAST *node);
virtual void visitUnqualifiedName(UnqualifiedNameAST *node);
private:
CppCodeModel *_M_model;
Binder *_M_binder;
NameCompiler name_cc;
bool _M_ok;
QString _M_current_scope;
};
#endif // CODEMODEL_FINDER_H
// kate: space-indent on; indent-width 2; replace-tabs on;
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
/* This file is part of KDevelop
Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "compiler_utils.h"
#include "type_compiler.h"
#include "name_compiler.h"
#include "declarator_compiler.h"
#include "ast.h"
#include "binder.h"
TypeInfo *CompilerUtils::typeDescription(TypeSpecifierAST *type_specifier, DeclaratorAST *declarator, Binder *binder)
{
TypeCompiler type_cc (binder);
DeclaratorCompiler decl_cc (binder);
type_cc.run (type_specifier);
decl_cc.run (declarator);
TypeInfo *typeInfo = new TypeInfo();
typeInfo->setQualifiedName (type_cc.qualifiedName ());
typeInfo->setConstant (type_cc.isConstant ());
typeInfo->setVolatile (type_cc.isVolatile ());
typeInfo->setReference (decl_cc.isReference ());
typeInfo->setIndirections (decl_cc.indirection ());
typeInfo->setArrayElements (decl_cc.arrayElements ());
return typeInfo;
}
// kate: space-indent on; indent-width 2; replace-tabs on;
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met: