List of usage examples for org.eclipse.jdt.core.dom TagElement TAG_VERSION
String TAG_VERSION
To view the source code for org.eclipse.jdt.core.dom TagElement TAG_VERSION.
Click Source Link
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;//from ww w.j av a 2 s.c om 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: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 2s. c om // 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:de.akra.idocit.java.services.JavaInterfaceParserTest.java
License:Apache License
/** * Creates the expected {@link JavaInterfaceArtifact} for the source * AllIDocItJavaTests.SOURCE_DIR + "JavaInterfaceParser.java". * /* w w w .j a v a2s .c o m*/ * @param fileName * The file name of the source file. * @param cu * The {@link CompilationUnit} of the source file. * @return {@link JavaInterfaceArtifact} * @throws JavaModelException */ @SuppressWarnings("unchecked") private JavaInterfaceArtifact createExpectedArtifact(String fileName, CompilationUnit cu) throws JavaModelException { Addressee developer = DescribedItemUtils.findAddressee("Developer"); JavaInterfaceArtifact artifact = new JavaInterfaceArtifact(SignatureElement.EMPTY_SIGNATURE_ELEMENT, CATEGORY_ARTIFACT, cu, Numerus.SINGULAR); artifact.setIdentifier(fileName); ICompilationUnit icu = (ICompilationUnit) cu.getJavaElement(); artifact.setOriginalDocument(icu.getSource()); AST ast = AST.newAST(AST.JLS3); /* * Interface */ JavaInterface jInterface = new JavaInterface(artifact, CATEGORY_CLASS, Numerus.SINGULAR); jInterface.setIdentifier("JavaInterfaceParser"); jInterface.setQualifiedIdentifier("JavaInterfaceParser"); jInterface.addDocpart(makeDocumentation(developer, null, "<p><b>This is a test class used in JUnit test!!</b></p>The parser parses Java Interfaces, Classes and Enumerations and maps the structure to the iDocIt structure.")); artifact.addInterface(jInterface); List<TagElement> tags = new ArrayList<TagElement>(); TagElement tag = ast.newTagElement(); tag.setTagName(TagElement.TAG_AUTHOR); TextElement textElem = ast.newTextElement(); textElem.setText(" Dirk Meier-Eickhoff"); tag.fragments().add(textElem); tags.add(tag); tag = ast.newTagElement(); tag.setTagName(TagElement.TAG_SINCE); textElem = ast.newTextElement(); textElem.setText(" 0.0.1"); tag.fragments().add(textElem); tags.add(tag); tag = ast.newTagElement(); tag.setTagName(TagElement.TAG_VERSION); textElem = ast.newTextElement(); textElem.setText(" 0.0.1"); tag.fragments().add(textElem); tags.add(tag); jInterface.setAdditionalTags(tags); List<JavaMethod> methods = new ArrayList<JavaMethod>(); jInterface.setOperations(methods); /* * Constructor */ JavaMethod method = new JavaMethod(jInterface, CATEGORY_CONSTRUCTOR, ThematicGridConstants.THEMATIC_GRID_DEFAULT_NAME, Numerus.SINGULAR); method.setIdentifier("JavaInterfaceParser"); method.setQualifiedIdentifier("JavaInterfaceParser"); method.addDocpart(makeDocumentation(developer, null, "This is the constructor.")); methods.add(method); /* * Constructor -> input params */ JavaParameters inputParams = new JavaParameters(method, CATEGORY_PARAMETERS, Numerus.SINGULAR, false); inputParams.setIdentifier(StringUtils.EMPTY); inputParams.setQualifiedIdentifier(StringUtils.EMPTY); method.setInputParameters(inputParams); JavaParameter param = new JavaParameter(inputParams, Numerus.SINGULAR, false); param.setIdentifier("compilationUnit"); param.setQualifiedIdentifier("compilationUnit"); param.setDataTypeName("CompilationUnit"); param.setQualifiedDataTypeName("CompilationUnit"); param.setSignatureElementPath("compilationUnit:CompilationUnit"); param.addDocpart(makeDocumentation(developer, "compilationUnit:CompilationUnit", "The {@link CompilationUnit} that should be parsed & checked.")); inputParams.addParameter(param); param = new JavaParameter(inputParams, Numerus.SINGULAR, false); param.setIdentifier("artifactName"); param.setQualifiedIdentifier("artifactName"); param.setDataTypeName("String"); param.setQualifiedDataTypeName("String"); param.setSignatureElementPath("artifactName:String"); param.addDocpart(makeDocumentation(developer, "artifactName:String", "The name for the CompilationUnit (in general the Java source file).")); inputParams.addParameter(param); param = new JavaParameter(inputParams, Numerus.SINGULAR, false); param.setIdentifier("delimiters"); param.setQualifiedIdentifier("delimiters"); param.setDataTypeName("Delimiters"); param.setQualifiedDataTypeName("Delimiters"); param.setSignatureElementPath("delimiters:Delimiters"); param.addDocpart(makeDocumentation(developer, "delimiters:Delimiters", "The {@link Delimiters} for creating paths.")); inputParams.addParameter(param); /* * Method */ method = new JavaMethod(jInterface, CATEGORY_METHOD, ThematicGridConstants.THEMATIC_GRID_DEFAULT_NAME, Numerus.SINGULAR); method.setIdentifier("parse"); method.setQualifiedIdentifier("parse"); method.addDocpart(makeDocumentation(developer, null, "Parses the {@link CompilationUnit} <code>compilationUnit</code> (Java source file) and converts it to a {@link JavaInterfaceArtifact}. (Read {@link JavaInterfaceArtifact#copy(de.akra.idocit.common.structure.SignatureElement)})")); tags = new ArrayList<TagElement>(); tag = ast.newTagElement(); tag.setTagName(TagElement.TAG_SEE); SimpleName name = ast.newSimpleName("JavaModelException"); tag.fragments().add(name); tags.add(tag); tag = ast.newTagElement(); tag.setTagName(TagElement.TAG_SEE); MethodRef mRef = ast.newMethodRef(); mRef.setName(ast.newSimpleName("parse")); MethodRefParameter mRefParam = ast.newMethodRefParameter(); mRefParam.setType(ast.newPrimitiveType(PrimitiveType.INT)); mRef.parameters().add(mRefParam); mRefParam = ast.newMethodRefParameter(); mRefParam.setType(ast.newSimpleType(ast.newName("String"))); mRef.parameters().add(mRefParam); tag.fragments().add(mRef); tags.add(tag); tag = ast.newTagElement(); tag.setTagName(TagElement.TAG_AUTHOR); textElem = ast.newTextElement(); textElem.setText(" Dirk Meier-Eickhoff"); tag.fragments().add(textElem); tags.add(tag); tag = ast.newTagElement(); tag.setTagName(TagElement.TAG_SINCE); textElem = ast.newTextElement(); textElem.setText(" 0.0.1"); tag.fragments().add(textElem); tags.add(tag); tag = ast.newTagElement(); tag.setTagName(TagElement.TAG_VERSION); textElem = ast.newTextElement(); textElem.setText(" 0.0.4"); tag.fragments().add(textElem); tags.add(tag); method.setAdditionalTags(tags); methods.add(method); /* * Method -> input params */ inputParams = new JavaParameters(method, CATEGORY_PARAMETERS, Numerus.SINGULAR, false); inputParams.setIdentifier(StringUtils.EMPTY); inputParams.setQualifiedIdentifier(StringUtils.EMPTY); method.setInputParameters(inputParams); param = new JavaParameter(inputParams, Numerus.SINGULAR, false); param.setIdentifier("anyNumber"); param.setQualifiedIdentifier("anyNumber"); param.setDataTypeName("int"); param.setQualifiedDataTypeName("int"); param.setSignatureElementPath("anyNumber:int"); param.addDocpart(makeDocumentation(developer, "anyNumber:int", "This is only any number.")); inputParams.addParameter(param); param = new JavaParameter(inputParams, Numerus.SINGULAR, false); param.setIdentifier("anyString"); param.setQualifiedIdentifier("anyString"); param.setDataTypeName("String"); param.setQualifiedDataTypeName("String"); param.setSignatureElementPath("anyString:String"); param.addDocpart(makeDocumentation(developer, "anyString:String", "This is only any simple String. {@literal This Is A Literal}.")); inputParams.addParameter(param); param = new JavaParameter(inputParams, Numerus.PLURAL, false); param.setIdentifier("names"); param.setQualifiedIdentifier("names"); param.setDataTypeName("List<String>"); param.setQualifiedDataTypeName("List<String>"); param.setSignatureElementPath("names:List<String>"); param.addDocpart(makeDocumentation(developer, "names:List<String>", "The list of names")); inputParams.addParameter(param); /* * Method -> output param */ JavaParameters outputParam = new JavaParameters(method, CATEGORY_RETURN_TYPE, Numerus.SINGULAR, false); outputParam.setIdentifier(StringUtils.EMPTY); outputParam.setQualifiedIdentifier(StringUtils.EMPTY); method.setOutputParameters(outputParam); param = new JavaParameter(outputParam, Numerus.SINGULAR, true); param.setIdentifier("InterfaceArtifact"); param.setQualifiedIdentifier("InterfaceArtifact"); param.setDataTypeName("InterfaceArtifact"); param.setQualifiedDataTypeName("InterfaceArtifact"); param.setSignatureElementPath("InterfaceArtifact:InterfaceArtifact"); param.addDocpart(makeDocumentation(developer, "InterfaceArtifact:InterfaceArtifact", "a new {@link JavaInterfaceArtifact}.")); outputParam.addParameter(param); /* * Method -> exceptions */ List<JavaParameters> exceptionList = new ArrayList<JavaParameters>(); method.setExceptions(exceptionList); JavaParameters exceptions = new JavaParameters(method, CATEGORY_THROWS, Numerus.SINGULAR, false); exceptions.setIdentifier(StringUtils.EMPTY); exceptions.setQualifiedIdentifier(StringUtils.EMPTY); exceptionList.add(exceptions); param = new JavaParameter(exceptions, Numerus.SINGULAR, false); param.setIdentifier("JavaModelException"); param.setQualifiedIdentifier("JavaModelException"); param.setDataTypeName("JavaModelException"); param.setQualifiedDataTypeName("JavaModelException"); param.setSignatureElementPath("JavaModelException:JavaModelException"); param.addDocpart(makeDocumentation(developer, "JavaModelException:JavaModelException", "if an error occurs by getting the source code from ICompilationUnit.")); exceptions.addParameter(param); param = new JavaParameter(exceptions, Numerus.SINGULAR, false); param.setIdentifier("SAXException"); param.setQualifiedIdentifier("SAXException"); param.setDataTypeName("SAXException"); param.setQualifiedDataTypeName("SAXException"); param.setSignatureElementPath("SAXException:SAXException"); param.addDocpart(makeDocumentation(developer, "SAXException:SAXException", StringUtils.EMPTY)); exceptions.addParameter(param); param = new JavaParameter(exceptions, Numerus.SINGULAR, false); param.setIdentifier("IOException"); param.setQualifiedIdentifier("IOException"); param.setDataTypeName("IOException"); param.setQualifiedDataTypeName("IOException"); param.setSignatureElementPath("IOException:IOException"); param.addDocpart(makeDocumentation(developer, "IOException:IOException", StringUtils.EMPTY)); exceptions.addParameter(param); param = new JavaParameter(exceptions, Numerus.SINGULAR, false); param.setIdentifier("ParserConfigurationException"); param.setQualifiedIdentifier("ParserConfigurationException"); param.setDataTypeName("ParserConfigurationException"); param.setQualifiedDataTypeName("ParserConfigurationException"); param.setSignatureElementPath("ParserConfigurationException:ParserConfigurationException"); param.addDocpart(makeDocumentation(developer, "ParserConfigurationException:ParserConfigurationException", StringUtils.EMPTY)); exceptions.addParameter(param); return artifact; }
From source file:org.eclim.plugin.jdt.command.doc.CommentCommand.java
License:Open Source License
/** * Comment a type declaration./* ww w.j a v a 2 s . c om*/ * * @param src The source file. * @param javadoc The Javadoc. * @param element The IJavaElement. * @param isNew true if there was no previous javadoc for this element. */ private void commentType(ICompilationUnit src, Javadoc javadoc, IJavaElement element, boolean isNew) throws Exception { if (element.getParent().getElementType() == IJavaElement.COMPILATION_UNIT) { @SuppressWarnings("unchecked") List<TagElement> tags = javadoc.tags(); IProject project = element.getJavaProject().getProject(); if (isNew) { addTag(javadoc, tags.size(), null, null); addTag(javadoc, tags.size(), null, null); addTag(javadoc, tags.size(), TagElement.TAG_AUTHOR, getAuthor(project)); String version = getPreferences().getValue(project, "org.eclim.java.doc.version"); if (version != null && !StringUtils.EMPTY.equals(version.trim())) { version = StringUtils.replace(version, "\\$", "$"); addTag(javadoc, tags.size(), TagElement.TAG_VERSION, version); } } else { // check if author tag exists. int index = -1; String author = getAuthor(project); for (int ii = 0; ii < tags.size(); ii++) { TagElement tag = (TagElement) tags.get(ii); if (TagElement.TAG_AUTHOR.equals(tag.getTagName())) { String authorText = tag.fragments().size() > 0 ? ((TextElement) tag.fragments().get(0)).getText() : null; // check if author tag is the same. if (authorText != null && author.trim().equals(authorText.trim())) { index = -1; break; } index = ii + 1; } else if (tag.getTagName() != null) { if (index == -1) { index = ii; } } } // insert author tag if it doesn't exist. if (index > -1) { TagElement authorTag = javadoc.getAST().newTagElement(); TextElement authorText = javadoc.getAST().newTextElement(); authorText.setText(author); authorTag.setTagName(TagElement.TAG_AUTHOR); @SuppressWarnings("unchecked") List<ASTNode> fragments = authorTag.fragments(); fragments.add(authorText); tags.add(index, authorTag); } // add the version tag if it doesn't exist. boolean versionExists = false; for (int ii = 0; ii < tags.size(); ii++) { TagElement tag = (TagElement) tags.get(ii); if (TagElement.TAG_VERSION.equals(tag.getTagName())) { versionExists = true; break; } } if (!versionExists) { String version = getPreferences().getValue(project, "org.eclim.java.doc.version"); version = StringUtils.replace(version, "\\$", "$"); addTag(javadoc, tags.size(), TagElement.TAG_VERSION, version); } } } else { commentOther(src, javadoc, element, isNew); } }
From source file:org.eclipse.xtext.xbase.ui.hover.XbaseHoverDocumentationProvider.java
License:Open Source License
public String computeDocumentation(EObject object) { buffer = new StringBuffer(); context = object;/*from w ww . ja v a 2s.co m*/ fLiteralContent = 0; List<String> parameterNames = initParameterNames(); Map<String, URI> exceptionNamesToURI = initExceptionNamesToURI(); addAnnotations(object); getDocumentationWithPrefix(object); Javadoc javadoc = getJavaDoc(); if (javadoc == null) return buffer.toString(); 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>(); @SuppressWarnings("unchecked") List<TagElement> tags = javadoc.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); @SuppressWarnings("unchecked") 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); @SuppressWarnings("unchecked") List<? extends ASTNode> fragments = tag.fragments(); if (fragments.size() > 0) { Object first = fragments.get(0); if (first instanceof Name) { @SuppressWarnings("restriction") String name = org.eclipse.jdt.internal.corext.dom.ASTNodes .getSimpleNameIdentifier((Name) first); if (exceptionNamesToURI.containsKey(name)) { exceptionNamesToURI.put(name, 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); } } boolean hasParameters = parameters.size() > 0; boolean hasReturnTag = returnTag != null; boolean hasExceptions = exceptions.size() > 0; if (deprecatedTag != null) handleDeprecatedTag(deprecatedTag); if (start != null) { @SuppressWarnings("unchecked") List<ASTNode> fragments = start.fragments(); handleContentElements(fragments); } if (hasParameters || hasReturnTag || hasExceptions || versions.size() > 0 || authors.size() > 0 || since.size() > 0 || sees.size() > 0 || rest.size() > 0 || (buffer.length() > 0) && (parameterNames.size() > 0 || exceptionNamesToURI.size() > 0)) { handleSuperMethodReferences(object); buffer.append(BLOCK_TAG_START); handleParameters(object, parameters, parameterNames); handleReturnTag(returnTag); handleExceptionTags(exceptions, exceptionNamesToURI); handleBlockTags("Since:", since); handleBlockTags("Version:", versions); handleBlockTags("Author:", authors); handleBlockTags("See Also:", sees); handleBlockTags(rest); buffer.append(BLOCK_TAG_END); } else if (buffer.length() > 0) { handleSuperMethodReferences(object); } String result = buffer.toString(); buffer = null; rawJavaDoc = null; context = null; return result; }
From source file:org.summer.dsl.xbase.ui.hover.XbaseHoverDocumentationProvider.java
License:Open Source License
public String computeDocumentation(EObject object) { buffer = new StringBuffer(); context = object;/*from w w w.j a v a 2s .co m*/ fLiteralContent = 0; List<String> parameterNames = initParameterNames(); Map<String, URI> exceptionNamesToURI = initExceptionNamesToURI(); addAnnotations(object); getDocumentationWithPrefix(object); Javadoc javadoc = getJavaDoc(); if (javadoc == null) return ""; 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>(); @SuppressWarnings("unchecked") List<TagElement> tags = javadoc.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); @SuppressWarnings("unchecked") 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); @SuppressWarnings("unchecked") 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); if (exceptionNamesToURI.containsKey(name)) { exceptionNamesToURI.put(name, 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); } } boolean hasParameters = parameters.size() > 0; boolean hasReturnTag = returnTag != null; boolean hasExceptions = exceptions.size() > 0; if (deprecatedTag != null) handleDeprecatedTag(deprecatedTag); if (start != null) { @SuppressWarnings("unchecked") List<ASTNode> fragments = start.fragments(); handleContentElements(fragments); } if (hasParameters || hasReturnTag || hasExceptions || versions.size() > 0 || authors.size() > 0 || since.size() > 0 || sees.size() > 0 || rest.size() > 0 || (buffer.length() > 0) && (parameterNames.size() > 0 || exceptionNamesToURI.size() > 0)) { handleSuperMethodReferences(object); buffer.append(BLOCK_TAG_START); handleParameters(object, parameters, parameterNames); handleReturnTag(returnTag); handleExceptionTags(exceptions, exceptionNamesToURI); handleBlockTags("Since:", since); handleBlockTags("Version:", versions); handleBlockTags("Author:", authors); handleBlockTags("See Also:", sees); handleBlockTags(rest); buffer.append(BLOCK_TAG_END); } else if (buffer.length() > 0) { handleSuperMethodReferences(object); } String result = buffer.toString(); buffer = null; rawJavaDoc = null; context = null; return result; }