List of usage examples for org.eclipse.jdt.core.dom TagElement TAG_PARAM
String TAG_PARAM
To view the source code for org.eclipse.jdt.core.dom TagElement TAG_PARAM.
Click Source Link
From source file:at.bestsolution.fxide.jdt.text.javadoc.JavaDoc2HTMLTextReader.java
License:Open Source License
private void handleTag(String tag, String tagContent) { tagContent = tagContent.trim();//from w w w .j a va 2 s. com if (TagElement.TAG_PARAM.equals(tag)) fParameters.add(tagContent); else if (TagElement.TAG_RETURN.equals(tag)) fReturn = tagContent; else if (TagElement.TAG_EXCEPTION.equals(tag)) fExceptions.add(tagContent); else if (TagElement.TAG_THROWS.equals(tag)) fExceptions.add(tagContent); else if (TagElement.TAG_AUTHOR.equals(tag)) fAuthors.add(substituteQualification(tagContent)); else if (TagElement.TAG_SEE.equals(tag)) fSees.add(substituteQualification(tagContent)); else if (TagElement.TAG_SINCE.equals(tag)) fSince.add(substituteQualification(tagContent)); else if (tagContent != null) fRest.add(new Pair(tag, tagContent)); }
From source file:at.bestsolution.fxide.jdt.text.javadoc.JavadocContentAccess2.java
License:Open Source License
private void parameterToHTML() { String elementName = fElement.getElementName(); List<TagElement> tags = fJavadoc.tags(); for (Iterator<TagElement> iter = tags.iterator(); iter.hasNext();) { TagElement tag = iter.next(); String tagName = tag.getTagName(); if (TagElement.TAG_PARAM.equals(tagName)) { List<? extends ASTNode> fragments = tag.fragments(); int size = fragments.size(); if (size > 0) { Object first = fragments.get(0); if (first instanceof SimpleName) { String name = ((SimpleName) first).getIdentifier(); if (elementName.equals(name)) { handleContentElements(fragments.subList(1, size)); return; }/*ww w .ja v a 2s. c o m*/ } else if (size > 2 && fElement instanceof ITypeParameter && first instanceof TextElement) { String firstText = ((TextElement) first).getText(); if ("<".equals(firstText)) { //$NON-NLS-1$ Object second = fragments.get(1); Object third = fragments.get(2); if (second instanceof SimpleName && third instanceof TextElement) { String name = ((SimpleName) second).getIdentifier(); String thirdText = ((TextElement) third).getText(); if (elementName.equals(name) && ">".equals(thirdText)) { //$NON-NLS-1$ handleContentElements(fragments.subList(3, size)); return; } } } } } } } if (fElement instanceof ILocalVariable) { List<String> parameterNames = initParameterNames(); int i = parameterNames.indexOf(elementName); if (i != -1) { CharSequence inheritedParamDescription = fJavadocLookup.getInheritedParamDescription(fMethod, i); handleInherited(inheritedParamDescription); } } else if (fElement instanceof ITypeParameter) { List<String> typeParameterNames = initTypeParameterNames(); int i = typeParameterNames.indexOf(elementName); if (i != -1) { CharSequence inheritedTypeParamDescription = fJavadocLookup .getInheritedTypeParamDescription(fMethod, i); handleInherited(inheritedTypeParamDescription); } } }
From source file:at.bestsolution.fxide.jdt.text.javadoc.JavadocContentAccess2.java
License:Open Source License
private void elementToHTML() { // After first loop, non-null entries in the following two lists are missing and need to be inherited: List<String> typeParameterNames = initTypeParameterNames(); List<String> parameterNames = initParameterNames(); List<String> exceptionNames = initExceptionNames(); TagElement deprecatedTag = null; TagElement start = null;/*w w w . j ava 2 s . c o m*/ List<TagElement> typeParameters = new ArrayList<>(); List<TagElement> parameters = new ArrayList<>(); TagElement returnTag = null; List<TagElement> exceptions = new ArrayList<>(); List<TagElement> versions = new ArrayList<>(); List<TagElement> authors = new ArrayList<>(); List<TagElement> sees = new ArrayList<>(); List<TagElement> since = new ArrayList<>(); List<TagElement> rest = new ArrayList<>(); List<TagElement> tags = fJavadoc.tags(); for (Iterator<TagElement> iter = tags.iterator(); iter.hasNext();) { TagElement tag = iter.next(); String tagName = tag.getTagName(); if (tagName == null) { start = tag; } else if (TagElement.TAG_PARAM.equals(tagName)) { List<? extends ASTNode> fragments = tag.fragments(); int size = fragments.size(); if (size > 0) { Object first = fragments.get(0); if (first instanceof SimpleName) { String name = ((SimpleName) first).getIdentifier(); int paramIndex = parameterNames.indexOf(name); if (paramIndex != -1) { parameterNames.set(paramIndex, null); } parameters.add(tag); } else if (size > 2 && first instanceof TextElement) { String firstText = ((TextElement) first).getText(); if ("<".equals(firstText)) { //$NON-NLS-1$ Object second = fragments.get(1); Object third = fragments.get(2); if (second instanceof SimpleName && third instanceof TextElement) { String name = ((SimpleName) second).getIdentifier(); String thirdText = ((TextElement) third).getText(); if (">".equals(thirdText)) { //$NON-NLS-1$ int paramIndex = typeParameterNames.indexOf(name); if (paramIndex != -1) { typeParameterNames.set(paramIndex, null); } typeParameters.add(tag); } } } } } } else if (TagElement.TAG_RETURN.equals(tagName)) { if (returnTag == null) returnTag = tag; // the Javadoc tool only shows the first return tag } else if (TagElement.TAG_EXCEPTION.equals(tagName) || TagElement.TAG_THROWS.equals(tagName)) { exceptions.add(tag); List<? extends ASTNode> fragments = tag.fragments(); if (fragments.size() > 0) { Object first = fragments.get(0); if (first instanceof Name) { String name = ASTNodes.getSimpleNameIdentifier((Name) first); int exceptionIndex = exceptionNames.indexOf(name); if (exceptionIndex != -1) { exceptionNames.set(exceptionIndex, null); } } } } else if (TagElement.TAG_SINCE.equals(tagName)) { since.add(tag); } else if (TagElement.TAG_VERSION.equals(tagName)) { versions.add(tag); } else if (TagElement.TAG_AUTHOR.equals(tagName)) { authors.add(tag); } else if (TagElement.TAG_SEE.equals(tagName)) { sees.add(tag); } else if (TagElement.TAG_DEPRECATED.equals(tagName)) { if (deprecatedTag == null) deprecatedTag = tag; // the Javadoc tool only shows the first deprecated tag } else { rest.add(tag); } } //TODO: @Documented annotations before header if (deprecatedTag != null) handleDeprecatedTag(deprecatedTag); if (start != null) handleContentElements(start.fragments()); else if (fMethod != null) { CharSequence inherited = fJavadocLookup.getInheritedMainDescription(fMethod); // The Javadoc tool adds "Description copied from class: ..." (only for the main description). // We don't bother doing that. handleInherited(inherited); } CharSequence[] typeParameterDescriptions = new CharSequence[typeParameterNames.size()]; boolean hasInheritedTypeParameters = inheritTypeParameterDescriptions(typeParameterNames, typeParameterDescriptions); boolean hasTypeParameters = typeParameters.size() > 0 || hasInheritedTypeParameters; CharSequence[] parameterDescriptions = new CharSequence[parameterNames.size()]; boolean hasInheritedParameters = inheritParameterDescriptions(parameterNames, parameterDescriptions); boolean hasParameters = parameters.size() > 0 || hasInheritedParameters; CharSequence returnDescription = null; if (returnTag == null && needsReturnTag()) returnDescription = fJavadocLookup.getInheritedReturnDescription(fMethod); boolean hasReturnTag = returnTag != null || returnDescription != null; CharSequence[] exceptionDescriptions = new CharSequence[exceptionNames.size()]; boolean hasInheritedExceptions = inheritExceptionDescriptions(exceptionNames, exceptionDescriptions); boolean hasExceptions = exceptions.size() > 0 || hasInheritedExceptions; if (hasParameters || hasTypeParameters || hasReturnTag || hasExceptions || versions.size() > 0 || authors.size() > 0 || since.size() > 0 || sees.size() > 0 || rest.size() > 0 || (fBuf.length() > 0 && (parameterDescriptions.length > 0 || exceptionDescriptions.length > 0))) { handleSuperMethodReferences(); fBuf.append(BLOCK_TAG_START); handleParameterTags(typeParameters, typeParameterNames, typeParameterDescriptions, true); handleParameterTags(parameters, parameterNames, parameterDescriptions, false); handleReturnTag(returnTag, returnDescription); handleExceptionTags(exceptions, exceptionNames, exceptionDescriptions); handleBlockTags(JavaDocMessages.JavaDoc2HTMLTextReader_since_section, since); handleBlockTags(JavaDocMessages.JavaDoc2HTMLTextReader_version_section, versions); handleBlockTags(JavaDocMessages.JavaDoc2HTMLTextReader_author_section, authors); handleBlockTags(JavaDocMessages.JavaDoc2HTMLTextReader_see_section, sees); handleBlockTags(rest); fBuf.append(BLOCK_TAG_END); } else if (fBuf.length() > 0) { handleSuperMethodReferences(); } }
From source file:at.bestsolution.fxide.jdt.text.javadoc.JavadocContentAccess2.java
License:Open Source License
CharSequence getInheritedTypeParamDescription(int typeParamIndex) { if (fMethod != null) { List<String> typeParameterNames = initTypeParameterNames(); if (fTypeParamDescriptions == null) { fTypeParamDescriptions = new StringBuffer[typeParameterNames.size()]; } else {/* w w w . j a v a 2 s . com*/ StringBuffer description = fTypeParamDescriptions[typeParamIndex]; if (description != null) { return description.length() > 0 ? description : null; } } StringBuffer description = new StringBuffer(); fTypeParamDescriptions[typeParamIndex] = description; fBuf = description; fLiteralContent = 0; String typeParamName = typeParameterNames.get(typeParamIndex); List<TagElement> tags = fJavadoc.tags(); for (Iterator<TagElement> iter = tags.iterator(); iter.hasNext();) { TagElement tag = iter.next(); String tagName = tag.getTagName(); if (TagElement.TAG_PARAM.equals(tagName)) { List<? extends ASTNode> fragments = tag.fragments(); if (fragments.size() > 2) { Object first = fragments.get(0); Object second = fragments.get(1); Object third = fragments.get(2); if (first instanceof TextElement && second instanceof SimpleName && third instanceof TextElement) { String firstText = ((TextElement) first).getText(); String thirdText = ((TextElement) third).getText(); if ("<".equals(firstText) && ">".equals(thirdText)) { //$NON-NLS-1$ //$NON-NLS-2$ String name = ((SimpleName) second).getIdentifier(); if (name.equals(typeParamName)) { handleContentElements(fragments.subList(3, fragments.size())); break; } } } } } } fBuf = null; return description.length() > 0 ? description : null; } return null; }
From source file:at.bestsolution.fxide.jdt.text.javadoc.JavadocContentAccess2.java
License:Open Source License
CharSequence getInheritedParamDescription(int paramIndex) throws JavaModelException { if (fMethod != null) { String[] parameterNames = fMethod.getParameterNames(); if (fParamDescriptions == null) { fParamDescriptions = new StringBuffer[parameterNames.length]; } else {//from w w w. j a v a 2 s . c o m StringBuffer description = fParamDescriptions[paramIndex]; if (description != null) { return description.length() > 0 ? description : null; } } StringBuffer description = new StringBuffer(); fParamDescriptions[paramIndex] = description; fBuf = description; fLiteralContent = 0; String paramName = parameterNames[paramIndex]; List<TagElement> tags = fJavadoc.tags(); for (Iterator<TagElement> iter = tags.iterator(); iter.hasNext();) { TagElement tag = iter.next(); String tagName = tag.getTagName(); if (TagElement.TAG_PARAM.equals(tagName)) { List<? extends ASTNode> fragments = tag.fragments(); if (fragments.size() > 0) { Object first = fragments.get(0); if (first instanceof SimpleName) { String name = ((SimpleName) first).getIdentifier(); if (name.equals(paramName)) { handleContentElements(fragments.subList(1, fragments.size())); break; } } } } } fBuf = null; return description.length() > 0 ? description : null; } return null; }
From source file:at.bestsolution.fxide.jdt.text.javadoc.JavadocContentAccess2.java
License:Open Source License
/** * Handle {@inheritDoc}.//w w w . java 2 s . c om * * @param node the node * @return <code>true</code> iff the node was an {@inheritDoc} node and has been handled */ private boolean handleInheritDoc(TagElement node) { if (!TagElement.TAG_INHERITDOC.equals(node.getTagName())) return false; try { if (fMethod == null) return false; TagElement blockTag = (TagElement) node.getParent(); String blockTagName = blockTag.getTagName(); if (blockTagName == null) { CharSequence inherited = fJavadocLookup.getInheritedMainDescription(fMethod); return handleInherited(inherited); } else if (TagElement.TAG_PARAM.equals(blockTagName)) { List<? extends ASTNode> fragments = blockTag.fragments(); int size = fragments.size(); if (size > 0) { Object first = fragments.get(0); if (first instanceof SimpleName) { String name = ((SimpleName) first).getIdentifier(); String[] parameterNames = fMethod.getParameterNames(); for (int i = 0; i < parameterNames.length; i++) { if (name.equals(parameterNames[i])) { CharSequence inherited = fJavadocLookup.getInheritedParamDescription(fMethod, i); return handleInherited(inherited); } } } else if (size > 2 && first instanceof TextElement) { String firstText = ((TextElement) first).getText(); if ("<".equals(firstText)) { //$NON-NLS-1$ Object second = fragments.get(1); Object third = fragments.get(2); if (second instanceof SimpleName && third instanceof TextElement) { String thirdText = ((TextElement) third).getText(); if (">".equals(thirdText)) { //$NON-NLS-1$ String name = ((SimpleName) second).getIdentifier(); ITypeParameter[] typeParameters = fMethod.getTypeParameters(); for (int i = 0; i < typeParameters.length; i++) { ITypeParameter typeParameter = typeParameters[i]; if (name.equals(typeParameter.getElementName())) { CharSequence inherited = fJavadocLookup .getInheritedTypeParamDescription(fMethod, i); return handleInherited(inherited); } } } } } } } } else if (TagElement.TAG_RETURN.equals(blockTagName)) { CharSequence inherited = fJavadocLookup.getInheritedReturnDescription(fMethod); return handleInherited(inherited); } else if (TagElement.TAG_THROWS.equals(blockTagName) || TagElement.TAG_EXCEPTION.equals(blockTagName)) { List<? extends ASTNode> fragments = blockTag.fragments(); if (fragments.size() > 0) { Object first = fragments.get(0); if (first instanceof Name) { String name = ASTNodes.getSimpleNameIdentifier((Name) first); CharSequence inherited = fJavadocLookup.getInheritedExceptionDescription(fMethod, name); return handleInherited(inherited); } } } } catch (JavaModelException e) { //TODO e.printStackTrace(); } return false; }
From source file:com.codenvy.ide.ext.java.server.javadoc.JavadocContentAccess2.java
License:Open Source License
private String toHTML() { fBuf = new StringBuffer(); fLiteralContent = 0;//w w w. j av a 2 s . c o m // After first loop, non-null entries in the following two lists are missing and need to be inherited: List<String> parameterNames = initParameterNames(); List<String> exceptionNames = initExceptionNames(); TagElement deprecatedTag = null; TagElement start = null; List<TagElement> parameters = new ArrayList<TagElement>(); TagElement returnTag = null; List<TagElement> exceptions = new ArrayList<TagElement>(); List<TagElement> versions = new ArrayList<TagElement>(); List<TagElement> authors = new ArrayList<TagElement>(); List<TagElement> sees = new ArrayList<TagElement>(); List<TagElement> since = new ArrayList<TagElement>(); List<TagElement> rest = new ArrayList<TagElement>(); List<TagElement> tags = fJavadoc.tags(); for (Iterator<TagElement> iter = tags.iterator(); iter.hasNext();) { TagElement tag = iter.next(); String tagName = tag.getTagName(); if (tagName == null) { start = tag; } else if (TagElement.TAG_PARAM.equals(tagName)) { parameters.add(tag); List<? extends ASTNode> fragments = tag.fragments(); if (fragments.size() > 0) { Object first = fragments.get(0); if (first instanceof SimpleName) { String name = ((SimpleName) first).getIdentifier(); int paramIndex = parameterNames.indexOf(name); if (paramIndex != -1) { parameterNames.set(paramIndex, null); } } } } else if (TagElement.TAG_RETURN.equals(tagName)) { if (returnTag == null) returnTag = tag; // the Javadoc tool only shows the first return tag } else if (TagElement.TAG_EXCEPTION.equals(tagName) || TagElement.TAG_THROWS.equals(tagName)) { exceptions.add(tag); List<? extends ASTNode> fragments = tag.fragments(); if (fragments.size() > 0) { Object first = fragments.get(0); if (first instanceof Name) { String name = ASTNodes.getSimpleNameIdentifier((Name) first); int exceptionIndex = exceptionNames.indexOf(name); if (exceptionIndex != -1) { exceptionNames.set(exceptionIndex, null); } } } } else if (TagElement.TAG_SINCE.equals(tagName)) { since.add(tag); } else if (TagElement.TAG_VERSION.equals(tagName)) { versions.add(tag); } else if (TagElement.TAG_AUTHOR.equals(tagName)) { authors.add(tag); } else if (TagElement.TAG_SEE.equals(tagName)) { sees.add(tag); } else if (TagElement.TAG_DEPRECATED.equals(tagName)) { if (deprecatedTag == null) deprecatedTag = tag; // the Javadoc tool only shows the first deprecated tag } else { rest.add(tag); } } //TODO: @Documented annotations before header if (deprecatedTag != null) handleDeprecatedTag(deprecatedTag); if (start != null) handleContentElements(start.fragments()); else if (fMethod != null) { CharSequence inherited = fJavadocLookup.getInheritedMainDescription(fMethod); // The Javadoc tool adds "Description copied from class: ..." (only for the main description). // We don't bother doing that. handleInherited(inherited); } CharSequence[] parameterDescriptions = new CharSequence[parameterNames.size()]; boolean hasInheritedParameters = inheritParameterDescriptions(parameterNames, parameterDescriptions); boolean hasParameters = parameters.size() > 0 || hasInheritedParameters; CharSequence returnDescription = null; if (returnTag == null && needsReturnTag()) returnDescription = fJavadocLookup.getInheritedReturnDescription(fMethod); boolean hasReturnTag = returnTag != null || returnDescription != null; CharSequence[] exceptionDescriptions = new CharSequence[exceptionNames.size()]; boolean hasInheritedExceptions = inheritExceptionDescriptions(exceptionNames, exceptionDescriptions); boolean hasExceptions = exceptions.size() > 0 || hasInheritedExceptions; if (hasParameters || hasReturnTag || hasExceptions || versions.size() > 0 || authors.size() > 0 || since.size() > 0 || sees.size() > 0 || rest.size() > 0 || (fBuf.length() > 0 && (parameterDescriptions.length > 0 || exceptionDescriptions.length > 0))) { handleSuperMethodReferences(); fBuf.append(BLOCK_TAG_START); handleParameterTags(parameters, parameterNames, parameterDescriptions); handleReturnTag(returnTag, returnDescription); handleExceptionTags(exceptions, exceptionNames, exceptionDescriptions); handleBlockTags(JavaDocMessages.JavaDoc2HTMLTextReader_since_section, since); handleBlockTags(JavaDocMessages.JavaDoc2HTMLTextReader_version_section, versions); handleBlockTags(JavaDocMessages.JavaDoc2HTMLTextReader_author_section, authors); handleBlockTags(JavaDocMessages.JavaDoc2HTMLTextReader_see_section, sees); handleBlockTags(rest); fBuf.append(BLOCK_TAG_END); } else if (fBuf.length() > 0) { handleSuperMethodReferences(); } String result = fBuf.toString(); fBuf = null; return result; }
From source file:com.codenvy.ide.ext.java.server.javadoc.JavadocContentAccess2.java
License:Open Source License
/** * Handle {@inheritDoc}.// w w w . j av a2s.c o m * * @param node * the node * @return <code>true</code> iff the node was an {@inheritDoc} node and has been handled */ private boolean handleInheritDoc(TagElement node) { if (!TagElement.TAG_INHERITDOC.equals(node.getTagName())) return false; try { if (fMethod == null) return false; TagElement blockTag = (TagElement) node.getParent(); String blockTagName = blockTag.getTagName(); if (blockTagName == null) { CharSequence inherited = fJavadocLookup.getInheritedMainDescription(fMethod); return handleInherited(inherited); } else if (TagElement.TAG_PARAM.equals(blockTagName)) { List<? extends ASTNode> fragments = blockTag.fragments(); if (fragments.size() > 0) { Object first = fragments.get(0); if (first instanceof SimpleName) { String name = ((SimpleName) first).getIdentifier(); String[] parameterNames = fMethod.getParameterNames(); for (int i = 0; i < parameterNames.length; i++) { if (name.equals(parameterNames[i])) { CharSequence inherited = fJavadocLookup.getInheritedParamDescription(fMethod, i); return handleInherited(inherited); } } } } } else if (TagElement.TAG_RETURN.equals(blockTagName)) { CharSequence inherited = fJavadocLookup.getInheritedReturnDescription(fMethod); return handleInherited(inherited); } else if (TagElement.TAG_THROWS.equals(blockTagName) || TagElement.TAG_EXCEPTION.equals(blockTagName)) { List<? extends ASTNode> fragments = blockTag.fragments(); if (fragments.size() > 0) { Object first = fragments.get(0); if (first instanceof Name) { String name = ASTNodes.getSimpleNameIdentifier((Name) first); CharSequence inherited = fJavadocLookup.getInheritedExceptionDescription(fMethod, name); return handleInherited(inherited); } } } } catch (JavaModelException e) { LOG.error(e.getMessage(), e); } return false; }
From source file:com.servoy.eclipse.docgenerator.generators.DocumentationDataDistilled.java
License:Open Source License
public DocumentationDataDistilled(IMemberMetaModel memberMM, TypeMetaModel typeMM, JavadocMetaModel jdoc, MetaModelHolder holder) {//from w w w. ja v a 2 s. c om Set<DocumentationWarning> warnings = memberMM.getWarnings(); String location = memberMM.getFullSignature(); boolean clean = true; ClientSupport typeCsp = typeMM.getServoyClientSupport(holder); ClientSupport csp = typeCsp == null ? ClientSupport.Default : typeCsp; texts = new ArrayList<Pair<ClientSupport, String>>(); summaries = new ArrayList<Pair<ClientSupport, String>>(); String descriptionText = ExtractorUtil.grabExactlyOne(JavadocMetaModel.TEXT_TAG, clean, jdoc, warnings, location); String mobileDescriptionText = ExtractorUtil.grabExactlyOne(TAG_MOBILEDESCRIPTION, clean, jdoc, warnings, location); List<Pair<ClientSupport, String>> txts = new ArrayList<Pair<ClientSupport, String>>(); if (mobileDescriptionText != null && mobileDescriptionText.trim().length() > 0) { txts.add(new Pair<ClientSupport, String>(ClientSupport.mc, mobileDescriptionText.trim())); csp = csp.remove(ClientSupport.mc); } if (descriptionText != null && descriptionText.trim().length() > 0) { txts.add(new Pair<ClientSupport, String>(csp, descriptionText)); } setTexts(txts); String sample = ExtractorUtil.grabExactlyOne(TAG_SAMPLE, clean, jdoc, warnings, location); String mSample = ExtractorUtil.grabExactlyOne(TAG_MOBILESAMPLE, clean, jdoc, warnings, location); ClientSupport aux = typeCsp == null ? ClientSupport.Default : typeCsp; if (mSample != null && mSample.trim().length() > 0) { // add back the "*/" mSample = Pattern.compile("\\*/").matcher(mSample).replaceAll("*/"); addSample(ClientSupport.mc, mSample); aux = aux.remove(ClientSupport.mc); } if (sample != null && sample.trim().length() > 0) { // add back the "*/" sample = Pattern.compile("\\*/").matcher(sample).replaceAll("*/"); addSample(aux, sample); } deprecatedText = ExtractorUtil.grabExactlyOne(TagElement.TAG_DEPRECATED, clean, jdoc, warnings, location); ret = ExtractorUtil.grabExactlyOne(TagElement.TAG_RETURN, clean, jdoc, warnings, location); since = ExtractorUtil.grabExactlyOne(TagElement.TAG_SINCE, clean, jdoc, warnings, location); until = ExtractorUtil.grabExactlyOne(TAG_UNTIL, clean, jdoc, warnings, location); sameAs = ExtractorUtil.grabReference(TAG_SAMEAS, jdoc, warnings, location); if (sameAs != null) { sameAs.setEnclosingType(typeMM.getName().getQualifiedName()); } cloneSample = ExtractorUtil.grabReference(TAG_SAMPLE_AS, jdoc, warnings, location); if (cloneSample != null) { cloneSample.setEnclosingType(typeMM.getName().getQualifiedName()); } cloneDescription = ExtractorUtil.grabReference(TAG_CLONEDESC, jdoc, warnings, location); if (cloneDescription != null) { cloneDescription.setEnclosingType(typeMM.getName().getQualifiedName()); } JavadocTagPart specialTag = ExtractorUtil.grabFirstTag(TAG_SPECIAL, jdoc, true, warnings, location); if (specialTag != null) { special = true; } JavadocTagPart simplifiedSignatureTag = ExtractorUtil.grabFirstTag(TAG_SIMPLIFIEDSIGNATURE, jdoc, true, warnings, location); if (simplifiedSignatureTag != null) { simplifiedSignature = true; } JavadocTagPart staticCallTag = ExtractorUtil.grabFirstTag(TAG_STATICCALL, jdoc, true, warnings, location); if (staticCallTag != null) { staticCall = true; } List<JavadocTagPart> paramTags = jdoc.findTags(TagElement.TAG_PARAM); for (JavadocTagPart paramTag : paramTags) { String paramText = paramTag.getAsString(clean); paramText = paramText.trim(); StringTokenizer st = new StringTokenizer(paramText); if (st.hasMoreTokens()) { String paramName = st.nextToken(); boolean isOptional = false; String paramDescription = null; if (st.hasMoreTokens()) { String maybeOptional = st.nextToken(); if (maybeOptional.equals(FLAG_OPTIONAL)) { isOptional = true; int idx = paramText.indexOf(FLAG_OPTIONAL); paramDescription = paramText.substring(idx + FLAG_OPTIONAL.length()).trim(); } else { paramDescription = paramText.substring(paramName.length()).trim(); } } if (paramDescription == null) { paramDescription = ""; warnings.add(new DocumentationWarning(WarningType.ParamTagWithoutContent, location, TagElement.TAG_PARAM + " tag without text: '" + paramName + "'.")); } DocumentedParameterData parData = new DocumentedParameterData(paramName, isOptional, paramDescription); parameters.add(parData); } else { warnings.add(new DocumentationWarning(WarningType.EmptyTag, location, "Empty " + TagElement.TAG_PARAM + " tag.")); } } List<JavadocTagPart> linkTags = jdoc.findTags(TagElement.TAG_LINK); for (JavadocTagPart linkTag : linkTags) { String linkText = linkTag.getAsString(clean).trim(); int idx = linkText.indexOf(' '); if (idx >= 0) { linkText = linkText.substring(0, idx); } links.add(linkText); } }
From source file:de.akra.idocit.java.services.JavadocGeneratorTest.java
License:Apache License
/** * Tests {@link JavadocGenerator#appendDocsToJavadoc(List, String, String, Javadoc)} . * //from www. j a v a2 s .co m * @throws IOException * @throws FileNotFoundException */ @SuppressWarnings("unchecked") @Test public void testGenerateJavadoc() throws FileNotFoundException, IOException { ParserOutput output = JavaTestUtils .createCompilationUnit(AllIDocItJavaTests.SOURCE_DIR + "ParsingService.java"); CompilationUnit cu = output.getCompilationUnit(); AbstractTypeDeclaration absTypeDecl = (AbstractTypeDeclaration) cu.types().get(0); AST ast = absTypeDecl.getAST(); Javadoc javadoc = ast.newJavadoc(); List<Documentation> documentations = createParamDocumentations(); JavaMethod methodParam = new JavaMethod(SignatureElement.EMPTY_SIGNATURE_ELEMENT, "Method", "Searching Operations", Numerus.SINGULAR); for (Documentation documentation : documentations) { methodParam.addDocpart(documentation); } JavadocGenerator.INSTANCE.appendDocsToJavadoc(methodParam.getDocumentations(), null, null, "Searching Operations", javadoc, new ArrayList<TagElement>(), null); JavadocGenerator.INSTANCE.appendDocsToJavadoc(methodParam.getDocumentations(), TagElement.TAG_PARAM, "person", "Searching Operations", javadoc, new ArrayList<TagElement>(), null); JavaMethod methodReturn = new JavaMethod(SignatureElement.EMPTY_SIGNATURE_ELEMENT, "Method", "Searching Operations", Numerus.SINGULAR); for (Documentation documentation : createReturnDocumentations()) { methodReturn.addDocpart(documentation); } JavadocGenerator.INSTANCE.appendDocsToJavadoc(methodReturn.getDocumentations(), TagElement.TAG_RETURN, null, "Searching Operations", javadoc, new ArrayList<TagElement>(), null); TagElement tagElement = ast.newTagElement(); tagElement.setTagName(JavadocParser.JAVADOC_TAG_THEMATICGRID); List<ASTNode> fragments = (List<ASTNode>) tagElement.fragments(); TextElement textElement = ast.newTextElement(); textElement.setText(" Searching Operations"); fragments.add(textElement); List<TagElement> tags = javadoc.tags(); tags.add(tagElement); Assert.assertEquals(EXPECTED_JAVADOC, javadoc.toString()); }