Added doc/uri property option for newAndEmitBuiltin.
Reviewers: fromberger, #core_team
Subscribers: fromberger, #core_team
@@ -116,8 +116,12 @@ public class KytheEntrySets {
/** Returns (and emits) a new builtin node. */
public EntrySet newBuiltinAndEmit(String name) {
- EntrySet node =
- emitAndReturn(
+ return newBuiltinAndEmit(name, Optional.<String>fromNullable(null));
+ }
+
+ /** Returns (and emits) a new builtin node. */
+ public EntrySet newBuiltinAndEmit(String name, Optional<String> docUri) {
+ EntrySet.Builder nodeBuilder =
newNode(NodeKind.TBUILTIN)
.setSignature(getBuiltinSignature(name))
.setProperty(
@@ -125,8 +129,11 @@ public class KytheEntrySets {
MarkedSource.newBuilder()
.setPreText(name)
.setKind(MarkedSource.Kind.IDENTIFIER)
- .build()));
- return node;
+ .build());
+ if (docUri.isPresent()) {
+ setDocumentUriProperty(nodeBuilder, docUri.get());
+ }
+ return emitAndReturn(nodeBuilder);
}
/**
@@ -323,6 +330,13 @@ public class KytheEntrySets {
return String.format("%s#builtin", name);
}
+ /**
+ * Sets the document URI property for the specified node builder.
+ */
+ protected static EntrySet.Builder setDocumentUriProperty(EntrySet.Builder builder, String docUri) {
+ return builder.setProperty("doc/uri", docUri);
+ }
+
/** {@link EntrySet.Builder} for Kythe nodes. */
public static class NodeBuilder extends EntrySet.Builder {
private static final String NODE_KIND_LABEL = "node/kind";
