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

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

本文整理了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

/**
   * {@inheritDoc}
   */
  public SourcePosition position() {
    return holder.position();
  }
}

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

/**
   * {@inheritDoc}
   */
  public SourcePosition position() {
    return holder.position();
  }
}

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

private static Tag[] getTag(Doc doc, String name, boolean check) {
  
  Tag[] tags = doc.tags(name);
  
  if (check && tags.length <= 0) {
    throw new IllegalStateException("api doc:Tag[@"+name+"] must requied in position: " + doc.position());
  } 
  
  if (tags.length <= 0) {
    return null;
  } else {
    return tags;
  }
}

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

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

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

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

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

private boolean isUpToDate() {
  if (outFile == null)
    return false;
  final long outFileMillis = outFile.lastModified();
  if (outFileMillis == 0L) {
    return false;
  }
  for (final Doc doc: allDocs) {
    final File docFile = doc.position() == null ? null : doc.position().file();
    if (docFile != null && docFile.lastModified() > outFileMillis) {
      rootDoc.printNotice("At least one item is out of date: " + docFile.getAbsolutePath());
      return false;
    }
  }
  return true;
}

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

/**
   * Verifies that the named block tag exists exactly <b>once</b>, and returns it.
   */
  public static Tag
  requiredTag(Doc doc, String tagName, DocErrorReporter docErrorReporter)  {

    Tag[] tags = doc.tags(tagName);

    if (tags.length == 0) {
      docErrorReporter.printError(doc.position(), "'" + tagName + "' is missing");
    }

    if (tags.length > 1) {
      docErrorReporter.printError(doc.position(), "'" + tagName + "' must appear only once");
    }

    return tags[0];
  }
}

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

/**
   * Verifies that the named block tag exists exactly <b>once</b>, and returns it.
   */
  public static Tag
  requiredTag(Doc doc, String tagName, DocErrorReporter docErrorReporter)  {

    Tag[] tags = doc.tags(tagName);

    if (tags.length == 0) {
      docErrorReporter.printError(doc.position(), "'" + tagName + "' is missing");
    }

    if (tags.length > 1) {
      docErrorReporter.printError(doc.position(), "'" + tagName + "' must appear only once");
    }

    return tags[0];
  }
}

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

private IAlgorithm getAlgorithmAssociatedToTag (Tag tag)
{
  File javaFileObject = tag.holder ().position ().file();
  String theClassName = ""; 
  while (!javaFileObject.getName ().equals("net2plan"))
  {
    theClassName = javaFileObject.getName () + "." + theClassName;
    if (javaFileObject.getParentFile() == null) break; else javaFileObject = javaFileObject.getParentFile();
  }
  theClassName = "com.net2plan." + theClassName;
  theClassName = theClassName.substring(0 , theClassName.length ()-6); //without .java
  
  IAlgorithm alg = null;
 try 
 { 
  Class algorithmClass = Taglet_Description.class.getClassLoader().loadClass(theClassName); 
   if (!IAlgorithm.class.isAssignableFrom(algorithmClass)) return null; // not an algorithm
   alg = (IAlgorithm) algorithmClass.getConstructor().newInstance();
 } catch (Exception e)
   {
     e.printStackTrace();
     throw new RuntimeException ("Unexpected exception trying to load class of '" + theClassName + "'");
   }
 return alg;
}

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

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

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

private Object getAlgorithmAssociatedToTag (Tag tag)
{
  File javaFileObject = tag.holder ().position ().file();
  String theClassName = ""; 
  while (!javaFileObject.getName ().equals("net2plan"))
  {
    theClassName = javaFileObject.getName () + "." + theClassName;
    if (javaFileObject.getParentFile() == null) break; else javaFileObject = javaFileObject.getParentFile();
  }
  theClassName = "com.net2plan." + theClassName;
  theClassName = theClassName.substring(0 , theClassName.length ()-6); //without .java
  
  Object alg = null;
 try 
 { 
  Class algorithmClass = Taglet_Description.class.getClassLoader().loadClass(theClassName); 
   if (IAlgorithm.class.isAssignableFrom(algorithmClass)) return (IAlgorithm) algorithmClass.getConstructor().newInstance(); 
   if (IReport.class.isAssignableFrom(algorithmClass)) return (IReport)algorithmClass.getConstructor().newInstance();
   if (IEventGenerator.class.isAssignableFrom(algorithmClass)) return (IEventGenerator)algorithmClass.getConstructor().newInstance();
   if (IEventProcessor.class.isAssignableFrom(algorithmClass)) return (IEventProcessor)algorithmClass.getConstructor().newInstance();
   return null;
 } catch (Exception e)
   {
     e.printStackTrace();
     throw new RuntimeException ("Unexpected exception trying to load class of '" + theClassName + "'");
   }
}

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

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

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

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

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

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

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

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

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

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

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

/**
   * {@inheritDoc}
   */
  public Content getTagletOutput(Tag tag, TagletWriter writer) {
    FieldDoc field = getFieldDoc(
      writer.configuration(), tag, tag.text());
    if (field == null) {
      if (tag.text().isEmpty()) {
        //Invalid use of @value
        writer.getMsgRetriever().warning(tag.holder().position(),
            "doclet.value_tag_invalid_use");
      } else {
        //Reference is unknown.
        writer.getMsgRetriever().warning(tag.holder().position(),
            "doclet.value_tag_invalid_reference", tag.text());
      }
    } else if (field.constantValue() != null) {
      return writer.valueTagOutput(field,
        field.constantValueExpression(),
        ! field.equals(tag.holder()));
    } else {
      //Referenced field is not a constant.
      writer.getMsgRetriever().warning(tag.holder().position(),
        "doclet.value_tag_invalid_constant", field.name());
    }
    return writer.getOutputInstance();
  }
}

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

/**
   * {@inheritDoc}
   */
  public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) {
    Type returnType = ((MethodDoc) holder).returnType();
    Tag[] tags = holder.tags(name);

    //Make sure we are not using @return tag on method with void return type.
    if (returnType.isPrimitive() && returnType.typeName().equals("void")) {
      if (tags.length > 0) {
        writer.getMsgRetriever().warning(holder.position(),
          "doclet.Return_tag_on_void_method");
      }
      return null;
    }
    //Inherit @return tag if necessary.
    if (tags.length == 0) {
      DocFinder.Output inheritedDoc =
        DocFinder.search(new DocFinder.Input((MethodDoc) holder, this));
      tags = inheritedDoc.holderTag == null ? tags : new Tag[] {inheritedDoc.holderTag};
    }
    return tags.length > 0 ? writer.returnTagOutput(tags[0]) : null;
  }
}

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

/**
   * {@inheritDoc}
   */
  public Content getTagletOutput(Doc holder, TagletWriter writer) {
    Type returnType = ((MethodDoc) holder).returnType();
    Tag[] tags = holder.tags(name);

    //Make sure we are not using @return tag on method with void return type.
    if (returnType.isPrimitive() && returnType.typeName().equals("void")) {
      if (tags.length > 0) {
        writer.getMsgRetriever().warning(holder.position(),
          "doclet.Return_tag_on_void_method");
      }
      return null;
    }
    //Inherit @return tag if necessary.
    if (tags.length == 0) {
      DocFinder.Output inheritedDoc =
        DocFinder.search(new DocFinder.Input((MethodDoc) holder, this));
      tags = inheritedDoc.holderTag == null ? tags : new Tag[] {inheritedDoc.holderTag};
    }
    return tags.length > 0 ? writer.returnTagOutput(tags[0]) : null;
  }
}

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

/**
   * {@inheritDoc}
   */
  public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
    FieldDoc field = getFieldDoc(
      writer.configuration(), tag, tag.text());
    if (field == null) {
      //Reference is unknown.
      writer.getMsgRetriever().warning(tag.holder().position(),
        "doclet.value_tag_invalid_reference", tag.text());
    } else if (field.constantValue() != null) {
      return writer.valueTagOutput(field,
        Util.escapeHtmlChars(field.constantValueExpression()),
        ! field.equals(tag.holder()));
    } else {
      //Referenced field is not a constant.
      writer.getMsgRetriever().warning(tag.holder().position(),
        "doclet.value_tag_invalid_constant", field.name());
    }
    return writer.getOutputInstance();
  }
}

相关文章