~ubuntu-branches/ubuntu/quantal/kdevelop-php/quantal-proposed

« back to all changes in this revision

Viewing changes to duchain/predeclarationbuilder.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fathi Boudra
  • Date: 2010-02-17 22:20:31 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100217222031-72jf3coqvofhv4q5
Tags: 1.0.0~beta3-1
* New upstream release.
* Remove 01_kdevelop-plugin_php_branch_pull_r1076222.diff - stolen upstream.
* Update debian/control:
  - bump build dependencies (debhelper, pkg-kde-tools, kdevplatform-dev).
  - bump Standards-Version to 3.8.4 (no changes needed).
* Update debian/rules: enable parallel build (pass --parallel option to dh).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *   This file is part of KDevelop                                         *
3
 
 *   Copyright 2008 Milian Wolff <mail@milianw.de>                         *
4
 
 *                                                                         *
5
 
 *   This program is free software; you can redistribute it and/or modify  *
6
 
 *   it under the terms of the GNU Library General Public License as       *
7
 
 *   published by the Free Software Foundation; either version 2 of the    *
8
 
 *   License, or (at your option) any later version.                       *
9
 
 *                                                                         *
10
 
 *   This program is distributed in the hope that it will be useful,       *
11
 
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13
 
 *   GNU General Public License for more details.                          *
14
 
 *                                                                         *
15
 
 *   You should have received a copy of the GNU Library General Public     *
16
 
 *   License along with this program; if not, write to the                 *
17
 
 *   Free Software Foundation, Inc.,                                       *
18
 
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19
 
 ***************************************************************************/
20
 
 
21
 
#include "predeclarationbuilder.h"
22
 
 
23
 
#include <QByteArray>
24
 
 
25
 
#include <ktexteditor/smartrange.h>
26
 
#include <ktexteditor/smartinterface.h>
27
 
 
28
 
#include <language/duchain/stringhelpers.h>
29
 
#include <language/duchain/types/functiontype.h>
30
 
 
31
 
#include <klocalizedstring.h>
32
 
 
33
 
#include "phpast.h"
34
 
#include "parsesession.h"
35
 
#include "helper.h"
36
 
#include "classdeclaration.h"
37
 
#include "functiondeclaration.h"
38
 
#include "variabledeclaration.h"
39
 
#include "structuretype.h"
40
 
 
41
 
using namespace KTextEditor;
42
 
using namespace KDevelop;
43
 
 
44
 
namespace Php
45
 
{
46
 
 
47
 
PreDeclarationBuilder::~PreDeclarationBuilder()
48
 
{
49
 
}
50
 
 
51
 
void PreDeclarationBuilder::visitClassDeclarationStatement(ClassDeclarationStatementAst * node)
52
 
{
53
 
    setComment(formatComment(node, editor()));
54
 
    {
55
 
        IdentifierPair ids = identifierPairForNode(node->className);
56
 
        DUChainWriteLocker lock(DUChain::lock());
57
 
        ClassDeclaration* dec = openDefinition<ClassDeclaration>(ids.second, editorFindRange(node->className, node->className));
58
 
        dec->setPrettyName(ids.first);
59
 
        dec->setKind(KDevelop::Declaration::Type);
60
 
        dec->clearBaseClasses();
61
 
        dec->setClassType(ClassDeclarationData::Class);
62
 
        if (node->modifier) {
63
 
            switch (node->modifier->modifier) {
64
 
            case NormalClass:
65
 
                dec->setClassModifier(ClassDeclarationData::None);
66
 
                break;
67
 
            case FinalClass:
68
 
                dec->setClassModifier(ClassDeclarationData::Final);
69
 
                break;
70
 
            case AbstractClass:
71
 
                dec->setClassModifier(ClassDeclarationData::Abstract);
72
 
                break;
73
 
            }
74
 
        } else {
75
 
            dec->setClassModifier(ClassDeclarationData::None);
76
 
        }
77
 
 
78
 
        // build the type as well, to make this declaration usable
79
 
        StructureType::Ptr type(new StructureType());
80
 
        type->setPrettyName(ids.first);
81
 
        type->setDeclaration(dec);
82
 
        dec->setType(type);
83
 
 
84
 
        m_types->insert(node->className->string, dec);
85
 
    }
86
 
 
87
 
    PreDeclarationBuilderBase::visitClassDeclarationStatement(node);
88
 
 
89
 
    closeDeclaration();
90
 
}
91
 
 
92
 
void PreDeclarationBuilder::visitInterfaceDeclarationStatement(InterfaceDeclarationStatementAst *node)
93
 
{
94
 
    setComment(formatComment(node, editor()));
95
 
    {
96
 
        IdentifierPair ids = identifierPairForNode(node->interfaceName);
97
 
        DUChainWriteLocker lock(DUChain::lock());
98
 
        ClassDeclaration* dec = openDefinition<ClassDeclaration>(ids.second, editorFindRange(node->interfaceName, node->interfaceName));
99
 
        dec->setPrettyName(ids.first);
100
 
        dec->setKind(KDevelop::Declaration::Type);
101
 
        dec->clearBaseClasses();
102
 
        dec->setClassType(ClassDeclarationData::Interface);
103
 
 
104
 
        // build the type as well, to make this declaration usable
105
 
        StructureType::Ptr type(new StructureType());
106
 
        type->setPrettyName(ids.first);
107
 
        type->setDeclaration(dec);
108
 
        dec->setType(type);
109
 
 
110
 
        m_types->insert(node->interfaceName->string, dec);
111
 
    }
112
 
 
113
 
    PreDeclarationBuilderBase::visitInterfaceDeclarationStatement(node);
114
 
 
115
 
    closeDeclaration();
116
 
}
117
 
 
118
 
void PreDeclarationBuilder::visitClassVariable(ClassVariableAst* node)
119
 
{
120
 
    m_upcomingClassVariables->append(identifierForNode(node->variable));
121
 
}
122
 
 
123
 
void PreDeclarationBuilder::visitFunctionDeclarationStatement(FunctionDeclarationStatementAst* node)
124
 
{
125
 
    setComment(formatComment(node, editor()));
126
 
    {
127
 
        IdentifierPair ids = identifierPairForNode(node->functionName);
128
 
        DUChainWriteLocker lock(DUChain::lock());
129
 
        FunctionDeclaration *dec = openDefinition<FunctionDeclaration>(ids.second, editorFindRange(node->functionName, node->functionName));
130
 
        dec->setPrettyName(ids.first);
131
 
        dec->setKind(Declaration::Type);
132
 
        dec->clearDefaultParameters();
133
 
 
134
 
        FunctionType::Ptr type = FunctionType::Ptr(new FunctionType());
135
 
 
136
 
        dec->setType(type);
137
 
 
138
 
        m_functions->insert(node->functionName->string, dec);
139
 
    }
140
 
 
141
 
    PreDeclarationBuilderBase::visitFunctionDeclarationStatement(node);
142
 
 
143
 
    closeDeclaration();
144
 
}
145
 
 
146
 
void PreDeclarationBuilder::closeContext()
147
 
{
148
 
    // we don't want to cleanup here, see DeclarationBuilder::closeContext()
149
 
    setCompilingContexts(false);
150
 
    PreDeclarationBuilderBase::closeContext();
151
 
    setCompilingContexts(true);
152
 
}
153
 
 
154
 
}