From 769e59e0cf2be26b3ab1faa8e9fe6b5df942df40 Mon Sep 17 00:00:00 2001 From: dilin-MS Date: Thu, 30 Apr 2020 15:07:20 +0800 Subject: [PATCH] fix(auto-completion): remove NodeKind Enum --- .../digitalTwinCompletionItemProvider.ts | 16 ++++++++-------- src/intelliSense/digitalTwinGraph.ts | 7 ------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/intelliSense/digitalTwinCompletionItemProvider.ts b/src/intelliSense/digitalTwinCompletionItemProvider.ts index 3e9d2c3..c7aa16a 100644 --- a/src/intelliSense/digitalTwinCompletionItemProvider.ts +++ b/src/intelliSense/digitalTwinCompletionItemProvider.ts @@ -5,7 +5,7 @@ import * as parser from "jsonc-parser"; import * as vscode from "vscode"; import { Constants } from "../common/constants"; import { DigitalTwinConstants } from "./digitalTwinConstants"; -import { ClassNode, Literal, NodeType, PropertyNode } from "./digitalTwinGraph"; +import { ClassNode, Literal, PropertyNode } from "./digitalTwinGraph"; import { IntelliSenseUtility, JsonNodeType, ModelContent, PropertyPair } from "./intelliSenseUtility"; import { LANGUAGE_CODE } from "./languageCode"; @@ -93,7 +93,7 @@ export class DigitalTwinCompletionItemProvider id: "dummy-language-code", name: Constants.EMPTY_STRING, nodeKind: Constants.EMPTY_STRING, - type: NodeType.LangString, + type: Literal.LangString, constraint: {}, }; for (const code of LANGUAGE_CODE) { @@ -204,16 +204,15 @@ export class DigitalTwinCompletionItemProvider } else if (typeClassNode && IntelliSenseUtility.isObverseClass(typeClassNode) && !isLanguageString) { value = "{$1}"; } else { - const type: string = IntelliSenseUtility.resolveTypeName(propertyNode.type).toLowerCase(); - switch (type) { - case NodeType.Boolean: + switch (propertyNode.type) { + case Literal.Boolean: value = "${1:false}"; break; - case NodeType.Integer: + case Literal.Integer: value = "${1:0}"; break; - case NodeType.String: - case NodeType.LangString: + case Literal.String: + case Literal.LangString: value = '"$1"'; break; } @@ -250,6 +249,7 @@ export class DigitalTwinCompletionItemProvider id: "dummy-id", name: DigitalTwinConstants.ID, nodeKind: Constants.EMPTY_STRING, + type: Literal.String, constraint: {}, }; suggestions.push({ diff --git a/src/intelliSense/digitalTwinGraph.ts b/src/intelliSense/digitalTwinGraph.ts index b49ed86..9805580 100644 --- a/src/intelliSense/digitalTwinGraph.ts +++ b/src/intelliSense/digitalTwinGraph.ts @@ -34,13 +34,6 @@ export interface PropertyNode { constraint: ConstraintNode; } -export enum NodeType { - String = "string", - Boolean = "boolean", - Integer = "integer", - LangString = "langstring", -} - /** * Constraint node of DigitalTwin graph */