1 /****************************************************************************
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the tools applications of the Qt Toolkit.
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
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
46 #include "javacodemarker.h"
53 JavaCodeMarker::JavaCodeMarker()
57 JavaCodeMarker::~JavaCodeMarker()
61 bool JavaCodeMarker::recognizeCode( const QString
& /* code */ )
66 bool JavaCodeMarker::recognizeExtension( const QString
& ext
)
71 bool JavaCodeMarker::recognizeLanguage( const QString
& lang
)
73 return lang
== "Java";
76 QString
JavaCodeMarker::plainName( const Node
*node
)
81 QString
JavaCodeMarker::plainFullName( const Node
*node
, const Node
* /* relative */ )
88 fullName
.prepend( plainName(node
) );
89 if ( node
->parent() && node
->parent()->name().isEmpty() )
91 node
= node
->parent();
94 fullName
.prepend(".");
99 QString
JavaCodeMarker::markedUpCode( const QString
& code
,
100 const Node
* /* relative */,
101 const QString
& /* dirPath */ )
103 return protect( code
);
106 QString
JavaCodeMarker::markedUpSynopsis(const Node
* /* node */,
107 const Node
* /* relative */,
108 SynopsisStyle
/* style */)
113 QString
JavaCodeMarker::markedUpName( const Node
*node
)
115 return linkTag(node
, taggedNode(node
));
118 QString
JavaCodeMarker::markedUpFullName(const Node
*node
, const Node
* /* relative */ )
122 fullName
.prepend( markedUpName(node
) );
123 if ( node
->parent()->name().isEmpty() )
125 node
= node
->parent();
126 fullName
.prepend( "." );
131 QString
JavaCodeMarker::markedUpEnumValue(const QString
&enumValue
,
132 const Node
* /* relative */)
134 return protect(enumValue
);
137 QString
JavaCodeMarker::markedUpIncludes( const QStringList
& /* includes */ )
142 QString
JavaCodeMarker::functionBeginRegExp( const QString
& /* funcName */)
144 return "^x$"; // ### invalid regexp
147 QString
JavaCodeMarker::functionEndRegExp( const QString
& /* funcName */ )
152 QList
<Section
> JavaCodeMarker::sections(const InnerNode
* /* inner */, SynopsisStyle
/* style */,
155 return QList
<Section
>();
158 const Node
*JavaCodeMarker::resolveTarget(const QString
&target
, const Tree
*tree
,
159 const Node
*relative
)
161 if (target
.endsWith("()")) {
162 const FunctionNode
*func
;
163 QString funcName
= target
;
166 QStringList path
= funcName
.split('.');
167 if ((func
= tree
->findFunctionNode(path
, relative
, Tree::SearchBaseClasses
)))
169 } else if (target
.contains("#")) {
170 int hashAt
= target
.indexOf("#");
171 QString link
= target
.left(hashAt
);
172 QString ref
= target
.mid(hashAt
+ 1);
174 if (link
.isEmpty()) {
177 QStringList
path(link
);
178 node
= tree
->findNode(path
, tree
->root(), Tree::SearchBaseClasses
);
180 if (node
&& node
->isInnerNode()) {
181 const Atom
*atom
= node
->doc().body().firstAtom();
183 if (atom
->type() == Atom::Target
&& atom
->string() == ref
) {
184 Node
*parentNode
= const_cast<Node
*>(node
);
185 return new TargetNode(static_cast<InnerNode
*>(parentNode
),
192 QStringList path
= target
.split('.');
194 if ((node
= tree
->findNode(path
, relative
,
195 Tree::SearchBaseClasses
| Tree::SearchEnumValues
)))