blob: 0e88f2b96ed67addc7bf4de2b4639cf61a40ec14 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
/**
* Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Eike Stepper - initial API and implementation
*/
package org.eclipse.emf.cdo.releng.doc.article.old;
import org.eclipse.emf.cdo.releng.doc.article.old.DocumentationElement.Visitor;
import org.eclipse.emf.cdo.releng.doc.article.old.util.RefTag;
import org.eclipse.emf.cdo.releng.doc.article.old.util.SnippetTag;
import org.eclipse.emf.cdo.releng.doc.article.util.ArticleException;
import com.sun.javadoc.ClassDoc;
import com.sun.javadoc.MemberDoc;
import com.sun.javadoc.SeeTag;
import com.sun.javadoc.Tag;
import java.util.List;
/**
* @author Eike Stepper
*/
public class DocumentationResolver extends Visitor
{
public DocumentationResolver()
{
}
@Override
public void visitArticleElement(ArticleElement articleElement) throws Exception
{
List<Tag> bodyTags = articleElement.getBodyTags();
Tag[] tags = bodyTags.toArray(new Tag[bodyTags.size()]);
for (int i = 0; i < tags.length; i++)
{
Tag tag = tags[i];
if (tag instanceof SeeTag)
{
SeeTag seeTag = (SeeTag)tag;
Tag resolvedTag = resolveTag(articleElement, seeTag);
if (resolvedTag != seeTag)
{
bodyTags.set(i, resolvedTag);
}
}
}
super.visitArticleElement(articleElement);
}
private Tag resolveTag(ArticleElement articleElement, SeeTag tag)
{
Documentation documentation = articleElement.getDocumentation();
MemberDoc referencedMember = tag.referencedMember();
if (referencedMember != null)
{
ClassDoc referencedClass = referencedMember.containingClass();
if (documentation.isTutorialClass(referencedClass))
{
// Inline example method
return new SnippetTag(tag, referencedMember, false);
}
// Refer to Java method
return tag;
}
ClassDoc referencedClass = tag.referencedClass();
if (referencedClass != null)
{
if (documentation.isTutorialClass(referencedClass))
{
if (documentation.isExampleClass(referencedClass))
{
// Inline example class
return new SnippetTag(tag, referencedClass, true);
}
// Refer to tutorial section
ArticleElement target = documentation.getArticleElements().get(referencedClass);
if (target == null)
{
throw new ArticleException("Unresolved reference: " + referencedClass);
}
return new RefTag(tag, target);
}
// Refer to Java class
return tag;
}
return tag;
}
}
|