source: trunk/tools/qdoc3/javacodemarker.cpp@ 814

Last change on this file since 814 was 651, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.2 sources.

File size: 5.8 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the tools applications of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
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** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
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
51QT_BEGIN_NAMESPACE
52
53JavaCodeMarker::JavaCodeMarker()
54{
55}
56
57JavaCodeMarker::~JavaCodeMarker()
58{
59}
60
61bool JavaCodeMarker::recognizeCode( const QString& /* code */ )
62{
63 return true;
64}
65
66bool JavaCodeMarker::recognizeExtension( const QString& ext )
67{
68 return ext == "java";
69}
70
71bool JavaCodeMarker::recognizeLanguage( const QString& lang )
72{
73 return lang == "Java";
74}
75
76QString JavaCodeMarker::plainName( const Node *node )
77{
78 return node->name();
79}
80
81QString 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
99QString JavaCodeMarker::markedUpCode( const QString& code,
100 const Node * /* relative */,
101 const QString& /* dirPath */ )
102{
103 return protect( code );
104}
105
106QString JavaCodeMarker::markedUpSynopsis(const Node * /* node */,
107 const Node * /* relative */,
108 SynopsisStyle /* style */)
109{
110 return QString();
111}
112
113QString JavaCodeMarker::markedUpName( const Node *node )
114{
115 return linkTag(node, taggedNode(node));
116}
117
118QString 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
131QString JavaCodeMarker::markedUpEnumValue(const QString &enumValue,
132 const Node * /* relative */)
133{
134 return protect(enumValue);
135}
136
137QString JavaCodeMarker::markedUpIncludes( const QStringList& /* includes */ )
138{
139 return QString();
140}
141
142QString JavaCodeMarker::functionBeginRegExp( const QString& /* funcName */)
143{
144 return "^x$"; // ### invalid regexp
145}
146
147QString JavaCodeMarker::functionEndRegExp( const QString& /* funcName */ )
148{
149 return "^}";
150}
151
152QList<Section> JavaCodeMarker::sections(const InnerNode * /* inner */, SynopsisStyle /* style */,
153 Status /* status */)
154{
155 return QList<Section>();
156}
157
158const Node *JavaCodeMarker::resolveTarget(const QString &target, const Tree *tree,
159 const Node *relative)
160{
161 if (target.endsWith("()")) {
162 const FunctionNode *func;
163 QString funcName = target;
164 funcName.chop(2);
165
166 QStringList path = funcName.split('.');
167 if ((func = tree->findFunctionNode(path, relative, Tree::SearchBaseClasses)))
168 return func;
169 } else if (target.contains("#")) {
170 int hashAt = target.indexOf("#");
171 QString link = target.left(hashAt);
172 QString ref = target.mid(hashAt + 1);
173 const Node *node;
174 if (link.isEmpty()) {
175 node = relative;
176 } else {
177 QStringList path(link);
178 node = tree->findNode(path, tree->root(), Tree::SearchBaseClasses);
179 }
180 if (node && node->isInnerNode()) {
181 const Atom *atom = node->doc().body().firstAtom();
182 while (atom) {
183 if (atom->type() == Atom::Target && atom->string() == ref) {
184 Node *parentNode = const_cast<Node *>(node);
185 return new TargetNode(static_cast<InnerNode*>(parentNode),
186 ref);
187 }
188 atom = atom->next();
189 }
190 }
191 } else {
192 QStringList path = target.split('.');
193 const Node *node;
194 if ((node = tree->findNode(path, relative,
195 Tree::SearchBaseClasses | Tree::SearchEnumValues)))
196 return node;
197 }
198 return 0;
199}
200
201QT_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.