Ejemplo n.º 1
0
 return Object.keys(response.statements!).map((k: any) => {
   const eqClass = response.statements![k];
   const title = eqClass.title;
   const item = CompletionItem.create(`[${title}]`);
   item.textEdit = TextEdit.replace(range, `[${title}]`);
   item.kind = CompletionItemKind.Variable;
   item.detail = IEquivalenceClass.getCanonicalMemberText(eqClass);
   return item;
 });
Ejemplo n.º 2
0
export const generateMarkdownForStatement = (
  eqClass: IEquivalenceClass,
  response: IArgdownResponse
): string => {
  const explicitRelations = eqClass.relations || [];
  const implicitRelations = deriveImplicitRelations(
    eqClass,
    response.statements!,
    response.arguments!
  );
  let explicitRelationsStr = "";
  for (let relation of explicitRelations) {
    if (relation.to!.type === ArgdownTypes.INFERENCE) {
      //we can not refer directly to inferences, only to arguments (undercuts will only appear in implicit relations)
      continue;
    }
    explicitRelationsStr += generateArgdownRelationStringFromRelation(
      relation,
      eqClass
    );
  }
  let implicitRelationsStr = "";
  if (implicitRelations.length > 0) {
    implicitRelationsStr = "\n  // implicit relations derived from pcs";
    for (let relation of implicitRelations) {
      if (relation.to!.type === ArgdownTypes.INFERENCE) {
        //we can not refer directly to inferences, only to arguments (undercuts will only appear in implicit relations)
        continue;
      }

      implicitRelationsStr += generateArgdownRelationStringFromRelation(
        relation,
        eqClass
      );
    }
  }

  let text = IEquivalenceClass.getCanonicalMemberText(eqClass);
  if (text) {
    text = ": " + text;
  } else {
    text = "";
  }
  return `
\`\`\`argdown
[${eqClass.title}]${text}${explicitRelationsStr}${implicitRelationsStr}${caveat}
\`\`\``;
};
Ejemplo n.º 3
0
 public async getRangeOfMapNode(
   doc: vscode.TextDocument,
   config: ArgdownPreviewConfiguration,
   id: string
 ): Promise<vscode.Range> {
   const argdownConfig = config.argdownConfig;
   const input = doc.getText();
   const request: IArgdownRequest = {
     ...argdownConfig,
     input: input,
     process: ["parse-input", "build-model", "build-map", "colorize"],
     throwExceptions: true
   };
   const response = await argdown.runAsync(request);
   const node = this.findNodeInMapNodeTree(
     response.map!.nodes,
     (n: any) => n.id === id
   );
   if (node && node.type === ArgdownTypes.ARGUMENT_MAP_NODE) {
     const argument = response.arguments![node.title!];
     const desc = IArgument.getCanonicalMember(argument);
     if (desc) {
       return new vscode.Range(
         (desc.startLine || 1) - 1,
         (desc.startColumn || 1) - 1,
         (desc.endLine || 1) - 1,
         desc.endColumn || 1
       );
     }
   } else if (node && node.type === ArgdownTypes.STATEMENT_MAP_NODE) {
     const eqClass = response.statements![node.title!];
     const statement = IEquivalenceClass.getCanonicalMember(eqClass);
     if (statement) {
       return new vscode.Range(
         (statement.startLine || 1) - 1,
         (statement.startColumn || 1) - 1,
         (statement.endLine || 1) - 1,
         statement.endColumn || 1
       );
     }
   }
   return new vscode.Range(0, 0, 0, 0);
 }