com.sun.javadoc.Doc.position()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(237)

本文整理了Java中com.sun.javadoc.Doc.position()方法的一些代码示例,展示了Doc.position()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Doc.position()方法的具体详情如下:
包路径:com.sun.javadoc.Doc
类名称:Doc
方法名:position

Doc.position介绍

[英]Return the source position of the first line of the corresponding declaration, or null if no position is available. A default constructor returns null because it has no location in the source file.
[中]返回相应声明第一行的源位置,如果没有可用位置,则返回null。默认构造函数返回null,因为它在源文件中没有位置。

代码示例

代码示例来源:origin: konsoletyper/teavm-javac

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public SourcePosition position() {
  5. return holder.position();
  6. }
  7. }

代码示例来源:origin: uk.org.retep.doclet/core

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public SourcePosition position() {
  5. return holder.position();
  6. }
  7. }

代码示例来源:origin: com.github.linkeer8802/api-resolver-core

  1. private static Tag[] getTag(Doc doc, String name, boolean check) {
  2. Tag[] tags = doc.tags(name);
  3. if (check && tags.length <= 0) {
  4. throw new IllegalStateException("api doc:Tag[@"+name+"] must requied in position: " + doc.position());
  5. }
  6. if (tags.length <= 0) {
  7. return null;
  8. } else {
  9. return tags;
  10. }
  11. }

代码示例来源:origin: konsoletyper/teavm-javac

  1. /**
  2. * Given a <code>Doc</code>, return an anchor name for it.
  3. *
  4. * @param d the <code>Doc</code> to check.
  5. * @return the name of the anchor.
  6. */
  7. public static String getAnchorName(Doc d) {
  8. return "line." + d.position().line();
  9. }
  10. }

代码示例来源:origin: uk.org.retep.doclet/core

  1. /**
  2. * Given a <code>Doc</code>, return an anchor name for it.
  3. * @param d the <code>Doc</code> to check.
  4. * @return the name of the anchor.
  5. */
  6. public static String getAnchorName(Doc d) {
  7. return "line." + d.position().line();
  8. }
  9. }

代码示例来源:origin: broadgsa/gatk

  1. private boolean isUpToDate() {
  2. if (outFile == null)
  3. return false;
  4. final long outFileMillis = outFile.lastModified();
  5. if (outFileMillis == 0L) {
  6. return false;
  7. }
  8. for (final Doc doc: allDocs) {
  9. final File docFile = doc.position() == null ? null : doc.position().file();
  10. if (docFile != null && docFile.lastModified() > outFileMillis) {
  11. rootDoc.printNotice("At least one item is out of date: " + docFile.getAbsolutePath());
  12. return false;
  13. }
  14. }
  15. return true;
  16. }

代码示例来源:origin: de.unkrig.commons/commons-doclet

  1. /**
  2. * Verifies that the named block tag exists exactly <b>once</b>, and returns it.
  3. */
  4. public static Tag
  5. requiredTag(Doc doc, String tagName, DocErrorReporter docErrorReporter) {
  6. Tag[] tags = doc.tags(tagName);
  7. if (tags.length == 0) {
  8. docErrorReporter.printError(doc.position(), "'" + tagName + "' is missing");
  9. }
  10. if (tags.length > 1) {
  11. docErrorReporter.printError(doc.position(), "'" + tagName + "' must appear only once");
  12. }
  13. return tags[0];
  14. }
  15. }

代码示例来源:origin: de.unkrig/de-unkrig-commons

  1. /**
  2. * Verifies that the named block tag exists exactly <b>once</b>, and returns it.
  3. */
  4. public static Tag
  5. requiredTag(Doc doc, String tagName, DocErrorReporter docErrorReporter) {
  6. Tag[] tags = doc.tags(tagName);
  7. if (tags.length == 0) {
  8. docErrorReporter.printError(doc.position(), "'" + tagName + "' is missing");
  9. }
  10. if (tags.length > 1) {
  11. docErrorReporter.printError(doc.position(), "'" + tagName + "' must appear only once");
  12. }
  13. return tags[0];
  14. }
  15. }

代码示例来源:origin: girtel/Net2Plan

  1. private IAlgorithm getAlgorithmAssociatedToTag (Tag tag)
  2. {
  3. File javaFileObject = tag.holder ().position ().file();
  4. String theClassName = "";
  5. while (!javaFileObject.getName ().equals("net2plan"))
  6. {
  7. theClassName = javaFileObject.getName () + "." + theClassName;
  8. if (javaFileObject.getParentFile() == null) break; else javaFileObject = javaFileObject.getParentFile();
  9. }
  10. theClassName = "com.net2plan." + theClassName;
  11. theClassName = theClassName.substring(0 , theClassName.length ()-6); //without .java
  12. IAlgorithm alg = null;
  13. try
  14. {
  15. Class algorithmClass = Taglet_Description.class.getClassLoader().loadClass(theClassName);
  16. if (!IAlgorithm.class.isAssignableFrom(algorithmClass)) return null; // not an algorithm
  17. alg = (IAlgorithm) algorithmClass.getConstructor().newInstance();
  18. } catch (Exception e)
  19. {
  20. e.printStackTrace();
  21. throw new RuntimeException ("Unexpected exception trying to load class of '" + theClassName + "'");
  22. }
  23. return alg;
  24. }

代码示例来源:origin: uk.org.retep.doclet/core

  1. /**
  2. * Given an array of <code>Doc</code>s, add to the given <code>HashMap</code> the
  3. * line numbers and anchors that should be inserted in the output at those lines.
  4. * @param docs the array of <code>Doc</code>s to add anchors for.
  5. * @param hash the <code>HashMap</code> to add to.
  6. */
  7. protected static void addToHash(Doc[] docs, HashMap<Integer,String> hash) {
  8. if(docs == null) {
  9. return;
  10. }
  11. for(int i = 0; i < docs.length; i++) {
  12. hash.put(docs[i].position().line(), getAnchor(docs[i]));
  13. }
  14. }

代码示例来源:origin: girtel/Net2Plan

  1. private Object getAlgorithmAssociatedToTag (Tag tag)
  2. {
  3. File javaFileObject = tag.holder ().position ().file();
  4. String theClassName = "";
  5. while (!javaFileObject.getName ().equals("net2plan"))
  6. {
  7. theClassName = javaFileObject.getName () + "." + theClassName;
  8. if (javaFileObject.getParentFile() == null) break; else javaFileObject = javaFileObject.getParentFile();
  9. }
  10. theClassName = "com.net2plan." + theClassName;
  11. theClassName = theClassName.substring(0 , theClassName.length ()-6); //without .java
  12. Object alg = null;
  13. try
  14. {
  15. Class algorithmClass = Taglet_Description.class.getClassLoader().loadClass(theClassName);
  16. if (IAlgorithm.class.isAssignableFrom(algorithmClass)) return (IAlgorithm) algorithmClass.getConstructor().newInstance();
  17. if (IReport.class.isAssignableFrom(algorithmClass)) return (IReport)algorithmClass.getConstructor().newInstance();
  18. if (IEventGenerator.class.isAssignableFrom(algorithmClass)) return (IEventGenerator)algorithmClass.getConstructor().newInstance();
  19. if (IEventProcessor.class.isAssignableFrom(algorithmClass)) return (IEventProcessor)algorithmClass.getConstructor().newInstance();
  20. return null;
  21. } catch (Exception e)
  22. {
  23. e.printStackTrace();
  24. throw new RuntimeException ("Unexpected exception trying to load class of '" + theClassName + "'");
  25. }
  26. }

代码示例来源:origin: de.unkrig.commons/commons-doclet

  1. /**
  2. * Verifies that the named block tag exists at most <b>once</b>, and returns it.
  3. *
  4. * @return {@code null} iff the tag does not exist
  5. */
  6. @Nullable public static Tag
  7. optionalTag(Doc doc, String tagName, DocErrorReporter docErrorReporter) {
  8. Tag[] tags = doc.tags(tagName);
  9. if (tags.length == 0) return null;
  10. if (tags.length > 1) {
  11. docErrorReporter.printError(doc.position(), "'" + tagName + "' must appear at most once");
  12. }
  13. return tags[0];
  14. }

代码示例来源:origin: de.unkrig/de-unkrig-commons

  1. /**
  2. * Verifies that the named block tag exists at most <b>once</b>, and returns it.
  3. *
  4. * @return {@code null} iff the tag does not exist
  5. */
  6. @Nullable public static Tag
  7. optionalTag(Doc doc, String tagName, DocErrorReporter docErrorReporter) {
  8. Tag[] tags = doc.tags(tagName);
  9. if (tags.length == 0) return null;
  10. if (tags.length > 1) {
  11. docErrorReporter.printError(doc.position(), "'" + tagName + "' must appear at most once");
  12. }
  13. return tags[0];
  14. }

代码示例来源:origin: uk.org.retep.doclet/core

  1. doc.position(),
  2. configuration.getText(
  3. "doclet.malformed_html_link_tag", text ) );

代码示例来源:origin: konsoletyper/teavm-javac

  1. doc.position(),
  2. configuration.getText("doclet.malformed_html_link_tag", text));
  3. break;

代码示例来源:origin: ch.raffael.pegdown-doclet/pegdown-doclet

  1. printError(doc.position(), e.getMessage());

代码示例来源:origin: konsoletyper/teavm-javac

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public Content getTagletOutput(Tag tag, TagletWriter writer) {
  5. FieldDoc field = getFieldDoc(
  6. writer.configuration(), tag, tag.text());
  7. if (field == null) {
  8. if (tag.text().isEmpty()) {
  9. //Invalid use of @value
  10. writer.getMsgRetriever().warning(tag.holder().position(),
  11. "doclet.value_tag_invalid_use");
  12. } else {
  13. //Reference is unknown.
  14. writer.getMsgRetriever().warning(tag.holder().position(),
  15. "doclet.value_tag_invalid_reference", tag.text());
  16. }
  17. } else if (field.constantValue() != null) {
  18. return writer.valueTagOutput(field,
  19. field.constantValueExpression(),
  20. ! field.equals(tag.holder()));
  21. } else {
  22. //Referenced field is not a constant.
  23. writer.getMsgRetriever().warning(tag.holder().position(),
  24. "doclet.value_tag_invalid_constant", field.name());
  25. }
  26. return writer.getOutputInstance();
  27. }
  28. }

代码示例来源:origin: uk.org.retep.doclet/core

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) {
  5. Type returnType = ((MethodDoc) holder).returnType();
  6. Tag[] tags = holder.tags(name);
  7. //Make sure we are not using @return tag on method with void return type.
  8. if (returnType.isPrimitive() && returnType.typeName().equals("void")) {
  9. if (tags.length > 0) {
  10. writer.getMsgRetriever().warning(holder.position(),
  11. "doclet.Return_tag_on_void_method");
  12. }
  13. return null;
  14. }
  15. //Inherit @return tag if necessary.
  16. if (tags.length == 0) {
  17. DocFinder.Output inheritedDoc =
  18. DocFinder.search(new DocFinder.Input((MethodDoc) holder, this));
  19. tags = inheritedDoc.holderTag == null ? tags : new Tag[] {inheritedDoc.holderTag};
  20. }
  21. return tags.length > 0 ? writer.returnTagOutput(tags[0]) : null;
  22. }
  23. }

代码示例来源:origin: konsoletyper/teavm-javac

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public Content getTagletOutput(Doc holder, TagletWriter writer) {
  5. Type returnType = ((MethodDoc) holder).returnType();
  6. Tag[] tags = holder.tags(name);
  7. //Make sure we are not using @return tag on method with void return type.
  8. if (returnType.isPrimitive() && returnType.typeName().equals("void")) {
  9. if (tags.length > 0) {
  10. writer.getMsgRetriever().warning(holder.position(),
  11. "doclet.Return_tag_on_void_method");
  12. }
  13. return null;
  14. }
  15. //Inherit @return tag if necessary.
  16. if (tags.length == 0) {
  17. DocFinder.Output inheritedDoc =
  18. DocFinder.search(new DocFinder.Input((MethodDoc) holder, this));
  19. tags = inheritedDoc.holderTag == null ? tags : new Tag[] {inheritedDoc.holderTag};
  20. }
  21. return tags.length > 0 ? writer.returnTagOutput(tags[0]) : null;
  22. }
  23. }

代码示例来源:origin: uk.org.retep.doclet/core

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
  5. FieldDoc field = getFieldDoc(
  6. writer.configuration(), tag, tag.text());
  7. if (field == null) {
  8. //Reference is unknown.
  9. writer.getMsgRetriever().warning(tag.holder().position(),
  10. "doclet.value_tag_invalid_reference", tag.text());
  11. } else if (field.constantValue() != null) {
  12. return writer.valueTagOutput(field,
  13. Util.escapeHtmlChars(field.constantValueExpression()),
  14. ! field.equals(tag.holder()));
  15. } else {
  16. //Referenced field is not a constant.
  17. writer.getMsgRetriever().warning(tag.holder().position(),
  18. "doclet.value_tag_invalid_constant", field.name());
  19. }
  20. return writer.getOutputInstance();
  21. }
  22. }

相关文章