Exemple #1
0
  /**
   * Generate a URL for a reference to a binding.
   *
   * @param nb the referenced binding
   * @param path the path containing the reference, or null if there was an error
   */
  private String toURL(NBinding nb, String path) {
    Def def = nb.getSignatureNode();
    if (def == null) {
      return null;
    }
    if (nb.isBuiltin()) {
      return def.getURL();
    }

    if (def.isModule()) {
      return toModuleUrl(nb);
    }

    String anchor = "#" + nb.getQname();
    if (nb.getFirstFile().equals(path)) {
      return anchor;
    }

    String destPath = def.getFile();
    try {
      String relpath = destPath.substring(rootPath.length());
      return Util.joinPath(outDir.getAbsolutePath(), relpath) + ".html" + anchor;
    } catch (Exception x) {
      System.err.println("path problem:  dest=" + destPath + ", root=" + rootPath + ": " + x);
      return null;
    }
  }
Exemple #2
0
 /** Create name anchors for definition sites. */
 private void processDefs(NBinding nb) {
   Def def = nb.getSignatureNode();
   if (def == null || def.isURL()) {
     return;
   }
   StyleRun style = new StyleRun(StyleRun.Type.ANCHOR, def.start(), def.length());
   style.message = nb.getQname();
   style.url = nb.getQname();
   addFileStyle(def.getFile(), style);
 }
Exemple #3
0
  /**
   * Add additional highlighting styles based on information not evident from the AST.
   *
   * @param def the binding's main definition node
   * @param b the binding
   */
  private void addSemanticStyles(NBinding nb) {
    Def def = nb.getSignatureNode();
    if (def == null || !def.isName()) {
      return;
    }

    boolean isConst = CONSTANT.matcher(def.getName()).matches();
    switch (nb.getKind()) {
      case SCOPE:
        if (isConst) {
          addSemanticStyle(def, StyleRun.Type.CONSTANT);
        }
        break;
      case VARIABLE:
        addSemanticStyle(def, isConst ? StyleRun.Type.CONSTANT : StyleRun.Type.IDENTIFIER);
        break;
      case PARAMETER:
        addSemanticStyle(def, StyleRun.Type.PARAMETER);
        break;
      case CLASS:
        addSemanticStyle(def, StyleRun.Type.TYPE_NAME);
        break;
    }
  }
Exemple #4
0
 private void addSemanticStyle(Def def, StyleRun.Type type) {
   String path = def.getFile();
   if (path != null) {
     addFileStyle(path, new StyleRun(type, def.start(), def.length()));
   }
 }