author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 18 Aug 2010 10:37:55 +0300 | |
changeset 33 | 3e2da88830cd |
parent 18 | 2f34d5167611 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the tools applications of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
/* |
|
43 |
javacodemarker.cpp |
|
44 |
*/ |
|
45 |
||
46 |
#include "javacodemarker.h" |
|
47 |
#include "node.h" |
|
48 |
#include "text.h" |
|
49 |
#include "tree.h" |
|
50 |
||
51 |
QT_BEGIN_NAMESPACE |
|
52 |
||
53 |
JavaCodeMarker::JavaCodeMarker() |
|
54 |
{ |
|
55 |
} |
|
56 |
||
57 |
JavaCodeMarker::~JavaCodeMarker() |
|
58 |
{ |
|
59 |
} |
|
60 |
||
61 |
bool JavaCodeMarker::recognizeCode( const QString& /* code */ ) |
|
62 |
{ |
|
63 |
return true; |
|
64 |
} |
|
65 |
||
66 |
bool JavaCodeMarker::recognizeExtension( const QString& ext ) |
|
67 |
{ |
|
68 |
return ext == "java"; |
|
69 |
} |
|
70 |
||
71 |
bool JavaCodeMarker::recognizeLanguage( const QString& lang ) |
|
72 |
{ |
|
73 |
return lang == "Java"; |
|
74 |
} |
|
75 |
||
76 |
QString JavaCodeMarker::plainName( const Node *node ) |
|
77 |
{ |
|
78 |
return node->name(); |
|
79 |
} |
|
80 |
||
81 |
QString JavaCodeMarker::plainFullName( const Node *node, const Node * /* relative */ ) |
|
82 |
{ |
|
83 |
if (!node) |
|
84 |
return QString(); |
|
85 |
||
86 |
QString fullName; |
|
87 |
for ( ;; ) { |
|
88 |
fullName.prepend( plainName(node) ); |
|
89 |
if ( node->parent() && node->parent()->name().isEmpty() ) |
|
90 |
break; |
|
91 |
node = node->parent(); |
|
92 |
if (!node) |
|
93 |
break; |
|
94 |
fullName.prepend("."); |
|
95 |
} |
|
96 |
return fullName; |
|
97 |
} |
|
98 |
||
99 |
QString JavaCodeMarker::markedUpCode( const QString& code, |
|
100 |
const Node * /* relative */, |
|
101 |
const QString& /* dirPath */ ) |
|
102 |
{ |
|
103 |
return protect( code ); |
|
104 |
} |
|
105 |
||
106 |
QString JavaCodeMarker::markedUpSynopsis(const Node * /* node */, |
|
107 |
const Node * /* relative */, |
|
108 |
SynopsisStyle /* style */) |
|
109 |
{ |
|
110 |
return QString(); |
|
111 |
} |
|
112 |
||
113 |
QString JavaCodeMarker::markedUpName( const Node *node ) |
|
114 |
{ |
|
115 |
return linkTag(node, taggedNode(node)); |
|
116 |
} |
|
117 |
||
118 |
QString JavaCodeMarker::markedUpFullName(const Node *node, const Node * /* relative */ ) |
|
119 |
{ |
|
120 |
QString fullName; |
|
121 |
for ( ;; ) { |
|
122 |
fullName.prepend( markedUpName(node) ); |
|
123 |
if ( node->parent()->name().isEmpty() ) |
|
124 |
break; |
|
125 |
node = node->parent(); |
|
126 |
fullName.prepend( "." ); |
|
127 |
} |
|
128 |
return fullName; |
|
129 |
} |
|
130 |
||
131 |
QString JavaCodeMarker::markedUpEnumValue(const QString &enumValue, |
|
132 |
const Node * /* relative */) |
|
133 |
{ |
|
134 |
return protect(enumValue); |
|
135 |
} |
|
136 |
||
137 |
QString JavaCodeMarker::markedUpIncludes( const QStringList& /* includes */ ) |
|
138 |
{ |
|
139 |
return QString(); |
|
140 |
} |
|
141 |
||
142 |
QString JavaCodeMarker::functionBeginRegExp( const QString& /* funcName */) |
|
143 |
{ |
|
144 |
return "^x$"; // ### invalid regexp |
|
145 |
} |
|
146 |
||
147 |
QString JavaCodeMarker::functionEndRegExp( const QString& /* funcName */ ) |
|
148 |
{ |
|
149 |
return "^}"; |
|
150 |
} |
|
151 |
||
152 |
QList<Section> JavaCodeMarker::sections(const InnerNode * /* inner */, SynopsisStyle /* style */, |
|
153 |
Status /* status */) |
|
154 |
{ |
|
155 |
return QList<Section>(); |
|
156 |
} |
|
157 |
||
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
158 |
const Node *JavaCodeMarker::resolveTarget(const QString &target, |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
159 |
const Tree *tree, |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
160 |
const Node *relative, |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
161 |
const Node* /* self */) |
0 | 162 |
{ |
163 |
if (target.endsWith("()")) { |
|
164 |
const FunctionNode *func; |
|
165 |
QString funcName = target; |
|
166 |
funcName.chop(2); |
|
167 |
||
168 |
QStringList path = funcName.split('.'); |
|
169 |
if ((func = tree->findFunctionNode(path, relative, Tree::SearchBaseClasses))) |
|
170 |
return func; |
|
171 |
} else if (target.contains("#")) { |
|
172 |
int hashAt = target.indexOf("#"); |
|
173 |
QString link = target.left(hashAt); |
|
174 |
QString ref = target.mid(hashAt + 1); |
|
175 |
const Node *node; |
|
176 |
if (link.isEmpty()) { |
|
177 |
node = relative; |
|
178 |
} else { |
|
179 |
QStringList path(link); |
|
180 |
node = tree->findNode(path, tree->root(), Tree::SearchBaseClasses); |
|
181 |
} |
|
182 |
if (node && node->isInnerNode()) { |
|
183 |
const Atom *atom = node->doc().body().firstAtom(); |
|
184 |
while (atom) { |
|
185 |
if (atom->type() == Atom::Target && atom->string() == ref) { |
|
186 |
Node *parentNode = const_cast<Node *>(node); |
|
187 |
return new TargetNode(static_cast<InnerNode*>(parentNode), |
|
188 |
ref); |
|
189 |
} |
|
190 |
atom = atom->next(); |
|
191 |
} |
|
192 |
} |
|
193 |
} else { |
|
194 |
QStringList path = target.split('.'); |
|
195 |
const Node *node; |
|
196 |
if ((node = tree->findNode(path, relative, |
|
197 |
Tree::SearchBaseClasses | Tree::SearchEnumValues))) |
|
198 |
return node; |
|
199 |
} |
|
200 |
return 0; |
|
201 |
} |
|
202 |
||
203 |
QT_END_NAMESPACE |