List of usage examples for org.eclipse.jdt.core.dom TagElement TAG_SINCE
String TAG_SINCE
To view the source code for org.eclipse.jdt.core.dom TagElement TAG_SINCE.
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();/* w ww .j a v a 2s. co m*/ 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 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 w w w . ja va2 s.co 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:com.codenvy.ide.ext.java.server.javadoc.JavadocContentAccess2.java
License:Open Source License
private String toHTML() { fBuf = new StringBuffer(); fLiteralContent = 0;//from ww w. java 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.servoy.eclipse.docgenerator.generators.DocumentationDataDistilled.java
License:Open Source License
public DocumentationDataDistilled(IMemberMetaModel memberMM, TypeMetaModel typeMM, JavadocMetaModel jdoc, MetaModelHolder holder) {//from ww w . j a va 2s. co m 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.JavaInterfaceParserTest.java
License:Apache License
/** * Creates the expected {@link JavaInterfaceArtifact} for the source * AllIDocItJavaTests.SOURCE_DIR + "JavaInterfaceParser.java". * /*ww w . j a v a 2s. c om*/ * @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.eclipse.pde.api.tools.internal.builder.SinceTagChecker.java
License:Open Source License
/** * Processes a javadoc tag//from w ww .j av a 2s . co m * * @param bodyDeclaration */ private void processJavadoc(BodyDeclaration bodyDeclaration) { Javadoc javadoc = bodyDeclaration.getJavadoc(); boolean found = false; if (javadoc != null) { this.bits |= HAS_JAVA_DOC; List<TagElement> tags = javadoc.tags(); for (TagElement element : tags) { String tagName = element.getTagName(); if (TagElement.TAG_SINCE.equals(tagName)) { // @since is present // check if valid found = true; List<ASTNode> fragments = element.fragments(); if (fragments.size() >= 1) { ASTNode fragment = fragments.get(0); if (fragment.getNodeType() == ASTNode.TEXT_ELEMENT) { this.sinceVersion = ((TextElement) fragment).getText(); } } else { this.sinceVersion = Util.EMPTY_STRING; } break; } } if (!found) { this.bits |= MISSING; } } else { this.bits |= HAS_NO_COMMENT; } }
From source file:org.eclipse.pde.api.tools.ui.internal.markers.UpdateSinceTagOperation.java
License:Open Source License
public void run(IProgressMonitor monitor) { if (monitor != null && monitor.isCanceled()) { return;/*from w w w.j a v a 2 s . c o m*/ } if (monitor != null) { monitor.beginTask(MarkerMessages.UpdateSinceTagOperation_title, 3); } // retrieve the AST node compilation unit try { Integer charStartAttribute = (Integer) this.fMarker.getAttribute(IMarker.CHAR_START); int intValue = charStartAttribute.intValue(); IJavaElement javaElement = null; IJavaElement handleElement = null; if (intValue > 0) { IResource resource = this.fMarker.getResource(); javaElement = JavaCore.create(resource); } else { // this is a case where the marker is reported against the // MANIFEST.MF file String handle = (String) fMarker.getAttribute(IApiMarkerConstants.MARKER_ATTR_HANDLE_ID); if (handle != null) { handleElement = JavaCore.create(handle); } if (handleElement != null && handleElement.exists()) { javaElement = handleElement.getAncestor(IJavaElement.COMPILATION_UNIT); } } if (javaElement != null && javaElement.getElementType() == IJavaElement.COMPILATION_UNIT) { ICompilationUnit compilationUnit = (ICompilationUnit) javaElement; if (!compilationUnit.isWorkingCopy()) { // open an editor of the corresponding unit to "show" the // quickfix change JavaUI.openInEditor(compilationUnit); } ASTParser parser = ASTParser.newParser(AST.JLS8); parser.setSource(compilationUnit); if (intValue <= 0) { // try to use the name range of the corresponding element if (handleElement instanceof IMember) { IMember member = (IMember) handleElement; ISourceRange range = member.getNameRange(); if (range != null) { intValue = range.getOffset(); } else { range = member.getSourceRange(); if (range != null && range.getOffset() > 0) { intValue = range.getOffset(); } else { return; } } } else { return; } } parser.setFocalPosition(intValue); parser.setResolveBindings(true); Map<String, String> options = compilationUnit.getJavaProject().getOptions(true); options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); parser.setCompilerOptions(options); final CompilationUnit unit = (CompilationUnit) parser.createAST(new NullProgressMonitor()); BodyDeclaration node = null; NodeFinder nodeFinder = new NodeFinder(intValue); unit.accept(nodeFinder); if (monitor != null) { monitor.worked(1); } node = nodeFinder.getNode(); if (node != null) { unit.recordModifications(); AST ast = unit.getAST(); ASTRewrite rewrite = ASTRewrite.create(ast); if (IApiProblem.SINCE_TAG_MISSING == this.sinceTagType) { Javadoc docnode = node.getJavadoc(); if (docnode == null) { docnode = ast.newJavadoc(); // we do not want to create a new empty Javadoc node // in // the AST if there are no missing tags rewrite.set(node, node.getJavadocProperty(), docnode, null); } else { List<TagElement> tags = docnode.tags(); boolean found = false; loop: for (Iterator<TagElement> iterator = tags.iterator(); iterator.hasNext();) { TagElement element = iterator.next(); String tagName = element.getTagName(); if (TagElement.TAG_SINCE.equals(tagName)) { found = true; break loop; } } if (found) { return; } } ListRewrite lrewrite = rewrite.getListRewrite(docnode, Javadoc.TAGS_PROPERTY); // check the existing tags list TagElement newtag = ast.newTagElement(); newtag.setTagName(TagElement.TAG_SINCE); TextElement textElement = ast.newTextElement(); textElement.setText(this.sinceTagVersion); newtag.fragments().add(textElement); lrewrite.insertLast(newtag, null); } else { Javadoc docnode = node.getJavadoc(); List<TagElement> tags = docnode.tags(); TagElement sinceTag = null; for (Iterator<TagElement> iterator = tags.iterator(); iterator.hasNext();) { TagElement tagElement = iterator.next(); if (TagElement.TAG_SINCE.equals(tagElement.getTagName())) { sinceTag = tagElement; break; } } if (sinceTag != null) { List<TextElement> fragments = sinceTag.fragments(); if (fragments.size() >= 1) { TextElement textElement = fragments.get(0); StringBuffer buffer = new StringBuffer(); buffer.append(' ').append(this.sinceTagVersion); rewrite.set(textElement, TextElement.TEXT_PROPERTY, String.valueOf(buffer), null); } else { ListRewrite lrewrite = rewrite.getListRewrite(docnode, Javadoc.TAGS_PROPERTY); // check the existing tags list TagElement newtag = ast.newTagElement(); newtag.setTagName(TagElement.TAG_SINCE); TextElement textElement = ast.newTextElement(); textElement.setText(this.sinceTagVersion); newtag.fragments().add(textElement); lrewrite.replace(sinceTag, newtag, null); } } } try { if (monitor != null) { monitor.worked(1); } TextEdit edit = rewrite.rewriteAST(); compilationUnit.applyTextEdit(edit, monitor); if (monitor != null) { monitor.worked(1); } } finally { compilationUnit.reconcile(ICompilationUnit.NO_AST, false /* * don * 't * force * problem * detection */, null /* * use * primary * owner */, null /* * no * progress * monitor */); } } } } catch (CoreException e) { ApiUIPlugin.log(e); } finally { if (monitor != null) { monitor.done(); } } }
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 ww w . ja v a2 s .c om 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.moe.natjgen.XcodeFullDocumentation.java
License:Apache License
public Javadoc getJavaDoc(ASTRewrite rewrite, ArrayList<CalleeArgument> args) { Javadoc doc = rewrite.getAST().newJavadoc(); addTag(doc, rewrite, null, "<h1>Abstract:</h1>\n" + prettyString(Abstract)); if (Discussion != null) { addTag(doc, rewrite, null, "<h1>Discussion:</h1>\n" + prettyString(Discussion)); }//from ww w .j av a 2 s. co m // @code addTag(doc, rewrite, TagElement.TAG_CODE, prettyString(Declaration)); // @param if (args.size() == ParameterNames.size()) { for (int i = 0; i < ParameterNames.size(); ++i) { addTag(doc, rewrite, TagElement.TAG_PARAM, args.get(i).getName() + " " + prettyString(ParameterDescriptions.get(i))); } } else { for (int i = 0; i < ParameterNames.size(); ++i) { addTag(doc, rewrite, TagElement.TAG_PARAM, ParameterNames.get(i) + " " + prettyString(ParameterDescriptions.get(i))); } } // @return addTag(doc, rewrite, TagElement.TAG_RETURN, prettyString(ResultDescription)); // @since for (int i = 0; i < Availabilities.size(); ++i) { addTag(doc, rewrite, TagElement.TAG_SINCE, prettyString(Availabilities.get(i))); } return doc; }
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;/*ww w . j a v a2s . c o 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; }