@aws/lsp-codewhisperer 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +19 -0
  3. package/out/client/sigv4/codewhisperer.d.ts +3 -0
  4. package/out/client/sigv4/codewhisperer.js +14 -0
  5. package/out/client/sigv4/codewhisperer.js.map +1 -0
  6. package/out/client/sigv4/service.json +346 -0
  7. package/out/client/token/bearer-token-service.json +1627 -0
  8. package/out/client/token/codewhisperer.d.ts +14 -0
  9. package/out/client/token/codewhisperer.js +23 -0
  10. package/out/client/token/codewhisperer.js.map +1 -0
  11. package/out/index.d.ts +2 -0
  12. package/out/index.js +19 -0
  13. package/out/index.js.map +1 -0
  14. package/out/language-server/auto-trigger/autoTrigger.d.ts +38 -0
  15. package/out/language-server/auto-trigger/autoTrigger.js +119 -0
  16. package/out/language-server/auto-trigger/autoTrigger.js.map +1 -0
  17. package/out/language-server/auto-trigger/autoTrigger.test.d.ts +1 -0
  18. package/out/language-server/auto-trigger/autoTrigger.test.js +82 -0
  19. package/out/language-server/auto-trigger/autoTrigger.test.js.map +1 -0
  20. package/out/language-server/auto-trigger/coefficients.json +405 -0
  21. package/out/language-server/codeWhispererSecurityScanServer.d.ts +4 -0
  22. package/out/language-server/codeWhispererSecurityScanServer.js +76 -0
  23. package/out/language-server/codeWhispererSecurityScanServer.js.map +1 -0
  24. package/out/language-server/codeWhispererServer.d.ts +7 -0
  25. package/out/language-server/codeWhispererServer.js +425 -0
  26. package/out/language-server/codeWhispererServer.js.map +1 -0
  27. package/out/language-server/codeWhispererServer.test.d.ts +1 -0
  28. package/out/language-server/codeWhispererServer.test.js +1218 -0
  29. package/out/language-server/codeWhispererServer.test.js.map +1 -0
  30. package/out/language-server/codeWhispererService.d.ts +84 -0
  31. package/out/language-server/codeWhispererService.js +168 -0
  32. package/out/language-server/codeWhispererService.js.map +1 -0
  33. package/out/language-server/dependencyGraph/commonUtil.d.ts +2 -0
  34. package/out/language-server/dependencyGraph/commonUtil.js +20 -0
  35. package/out/language-server/dependencyGraph/commonUtil.js.map +1 -0
  36. package/out/language-server/dependencyGraph/constants.d.ts +2 -0
  37. package/out/language-server/dependencyGraph/constants.js +6 -0
  38. package/out/language-server/dependencyGraph/constants.js.map +1 -0
  39. package/out/language-server/dependencyGraph/csharpDependencyGraph.d.ts +27 -0
  40. package/out/language-server/dependencyGraph/csharpDependencyGraph.js +145 -0
  41. package/out/language-server/dependencyGraph/csharpDependencyGraph.js.map +1 -0
  42. package/out/language-server/dependencyGraph/csharpDependencyGraph.test.d.ts +1 -0
  43. package/out/language-server/dependencyGraph/csharpDependencyGraph.test.js +341 -0
  44. package/out/language-server/dependencyGraph/csharpDependencyGraph.test.js.map +1 -0
  45. package/out/language-server/dependencyGraph/dependencyGraph.d.ts +125 -0
  46. package/out/language-server/dependencyGraph/dependencyGraph.js +152 -0
  47. package/out/language-server/dependencyGraph/dependencyGraph.js.map +1 -0
  48. package/out/language-server/dependencyGraph/dependencyGraphFactory.d.ts +15 -0
  49. package/out/language-server/dependencyGraph/dependencyGraphFactory.js +22 -0
  50. package/out/language-server/dependencyGraph/dependencyGraphFactory.js.map +1 -0
  51. package/out/language-server/languageDetection.d.ts +3 -0
  52. package/out/language-server/languageDetection.js +56 -0
  53. package/out/language-server/languageDetection.js.map +1 -0
  54. package/out/language-server/mergeRightUtils.d.ts +6 -0
  55. package/out/language-server/mergeRightUtils.js +37 -0
  56. package/out/language-server/mergeRightUtils.js.map +1 -0
  57. package/out/language-server/mergeRightUtils.test.d.ts +1 -0
  58. package/out/language-server/mergeRightUtils.test.js +53 -0
  59. package/out/language-server/mergeRightUtils.test.js.map +1 -0
  60. package/out/language-server/proxy-server.d.ts +2 -0
  61. package/out/language-server/proxy-server.js +35 -0
  62. package/out/language-server/proxy-server.js.map +1 -0
  63. package/out/language-server/securityScan/securityScanHandler.d.ts +17 -0
  64. package/out/language-server/securityScan/securityScanHandler.js +139 -0
  65. package/out/language-server/securityScan/securityScanHandler.js.map +1 -0
  66. package/out/language-server/securityScan/securityScanHandler.test.d.ts +1 -0
  67. package/out/language-server/securityScan/securityScanHandler.test.js +170 -0
  68. package/out/language-server/securityScan/securityScanHandler.test.js.map +1 -0
  69. package/out/language-server/securityScan/types.d.ts +49 -0
  70. package/out/language-server/securityScan/types.js +3 -0
  71. package/out/language-server/securityScan/types.js.map +1 -0
  72. package/out/language-server/session/sessionManager.d.ts +91 -0
  73. package/out/language-server/session/sessionManager.js +234 -0
  74. package/out/language-server/session/sessionManager.js.map +1 -0
  75. package/out/language-server/session/sessionManager.test.d.ts +1 -0
  76. package/out/language-server/session/sessionManager.test.js +584 -0
  77. package/out/language-server/session/sessionManager.test.js.map +1 -0
  78. package/out/language-server/telemetry/codePercentage.d.ts +17 -0
  79. package/out/language-server/telemetry/codePercentage.js +82 -0
  80. package/out/language-server/telemetry/codePercentage.js.map +1 -0
  81. package/out/language-server/telemetry/codePercentage.test.d.ts +1 -0
  82. package/out/language-server/telemetry/codePercentage.test.js +85 -0
  83. package/out/language-server/telemetry/codePercentage.test.js.map +1 -0
  84. package/out/language-server/telemetry/types.d.ts +68 -0
  85. package/out/language-server/telemetry/types.js +3 -0
  86. package/out/language-server/telemetry/types.js.map +1 -0
  87. package/out/language-server/telemetry/userTriggerDecision.test.d.ts +1 -0
  88. package/out/language-server/telemetry/userTriggerDecision.test.js +946 -0
  89. package/out/language-server/telemetry/userTriggerDecision.test.js.map +1 -0
  90. package/out/language-server/telemetry.test.d.ts +1 -0
  91. package/out/language-server/telemetry.test.js +96 -0
  92. package/out/language-server/telemetry.test.js.map +1 -0
  93. package/out/language-server/testUtils.d.ts +69 -0
  94. package/out/language-server/testUtils.js +90 -0
  95. package/out/language-server/testUtils.js.map +1 -0
  96. package/out/language-server/utils.d.ts +6 -0
  97. package/out/language-server/utils.js +31 -0
  98. package/out/language-server/utils.js.map +1 -0
  99. package/package.json +53 -0
  100. package/script/generateServiceClient.ts +242 -0
@@ -0,0 +1,14 @@
1
+ import { AWSError } from 'aws-sdk';
2
+ import { ServiceConfigurationOptions } from 'aws-sdk/lib/service';
3
+ import CodeWhispererClient = require('./codewhispererbearertokenclient');
4
+ interface RequestExtras {
5
+ readonly service: AWS.Service;
6
+ readonly operation: string;
7
+ readonly params?: any;
8
+ }
9
+ type RequestListener = (request: AWS.Request<any, AWSError> & RequestExtras) => void;
10
+ export interface CodeWhispererTokenClientConfigurationOptions extends ServiceConfigurationOptions {
11
+ onRequestSetup?: RequestListener | RequestListener[];
12
+ }
13
+ export declare function createCodeWhispererTokenClient(options: CodeWhispererTokenClientConfigurationOptions): CodeWhispererClient;
14
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCodeWhispererTokenClient = void 0;
4
+ const aws_sdk_1 = require("aws-sdk");
5
+ const apiConfig = require('./bearer-token-service.json');
6
+ function createCodeWhispererTokenClient(options) {
7
+ return createService(options);
8
+ }
9
+ exports.createCodeWhispererTokenClient = createCodeWhispererTokenClient;
10
+ function createService(options) {
11
+ const onRequest = options?.onRequestSetup ?? [];
12
+ const listeners = Array.isArray(onRequest) ? onRequest : [onRequest];
13
+ const opt = { ...options };
14
+ delete opt.onRequestSetup;
15
+ const client = new aws_sdk_1.Service({ apiConfig, ...options });
16
+ const originalClient = client.setupRequestListeners.bind(client);
17
+ client.setupRequestListeners = (request) => {
18
+ originalClient(request);
19
+ listeners.forEach(l => l(request));
20
+ };
21
+ return client;
22
+ }
23
+ //# sourceMappingURL=codewhisperer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codewhisperer.js","sourceRoot":"","sources":["../../../src/client/token/codewhisperer.ts"],"names":[],"mappings":";;;AAAA,qCAAoD;AAEpD,MAAM,SAAS,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAA;AAmBxD,SAAgB,8BAA8B,CAC1C,OAAqD;IAErD,OAAO,aAAa,CAAC,OAAO,CAAwB,CAAA;AACxD,CAAC;AAJD,wEAIC;AAED,SAAS,aAAa,CAAC,OAAqD;IACxE,MAAM,SAAS,GAAG,OAAO,EAAE,cAAc,IAAI,EAAE,CAAA;IAC/C,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IACpE,MAAM,GAAG,GAAG,EAAE,GAAG,OAAO,EAAE,CAAA;IAC1B,OAAO,GAAG,CAAC,cAAc,CAAA;IAEzB,MAAM,MAAM,GAAG,IAAI,iBAAO,CAAC,EAAE,SAAS,EAAE,GAAG,OAAO,EAAS,CAAC,CAAA;IAC5D,MAAM,cAAc,GAAG,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAEhE,MAAM,CAAC,qBAAqB,GAAG,CAAC,OAA+B,EAAE,EAAE;QAC/D,cAAc,CAAC,OAAO,CAAC,CAAA;QACvB,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAqD,CAAC,CAAC,CAAA;IACpF,CAAC,CAAA;IAED,OAAO,MAAM,CAAA;AACjB,CAAC"}
package/out/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './language-server/codeWhispererSecurityScanServer';
2
+ export * from './language-server/codeWhispererServer';
package/out/index.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./language-server/codeWhispererSecurityScanServer"), exports);
18
+ __exportStar(require("./language-server/codeWhispererServer"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oFAAiE;AACjE,wEAAqD"}
@@ -0,0 +1,38 @@
1
+ import { FileContext } from '../codeWhispererService';
2
+ export type CodewhispererTriggerType = 'AutoTrigger' | 'OnDemand';
3
+ export type CodewhispererAutomatedTriggerType = 'SpecialCharacters' | 'Enter' | 'Classifier';
4
+ /**
5
+ * Determine the trigger type based on the file context. Currently supports special cases for Special Characters and Enter keys,
6
+ * as determined by the File Context. For regular typing or undetermined triggers, the Classifier trigger type is used.
7
+ *
8
+ * This is a helper function that can be used since in LSP we don't have the actual keypress events. So we don't know
9
+ * (exactly) whether a position was reached through for instance inserting a new line or backspacing the next line.
10
+ *
11
+ * @param fileContext The file with left and right context based on the invocation position
12
+ * @returns The TriggerType
13
+ */
14
+ export declare const triggerType: (fileContext: FileContext) => CodewhispererAutomatedTriggerType;
15
+ /**
16
+ * Parameters to the auto trigger. Contains all information to make a decision.
17
+ */
18
+ type AutoTriggerParams = {
19
+ fileContext: FileContext;
20
+ char: string;
21
+ triggerType: string;
22
+ os: string;
23
+ previousDecision: string;
24
+ ide: string;
25
+ lineNum: number;
26
+ };
27
+ /**
28
+ * Auto Trigger to determine whether a keystroke or edit should trigger a recommendation invocation.
29
+ * It uses information about the file, the position, the last entered character, the environment,
30
+ * and previous recommendation decisions from the user to determine whether a new recommendation
31
+ * should be shown. The auto-trigger is not stateful and does not keep track of past invocations.
32
+ */
33
+ export declare const autoTrigger: ({ fileContext, char, triggerType, os, previousDecision, ide, lineNum, }: AutoTriggerParams) => {
34
+ shouldTrigger: boolean;
35
+ classifierResult: number;
36
+ classifierThreshold: number;
37
+ };
38
+ export {};
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.autoTrigger = exports.triggerType = void 0;
4
+ const typedCoefficients = require("./coefficients.json");
5
+ /**
6
+ * Add a string indexer to each category coefficient so we can accept string inputs
7
+ * from consumers while maintaining type safety inside the auto-trigger
8
+ * (and prevent accidental deletions and typos in the json file for non-category coefficients)
9
+ */
10
+ const coefficients = typedCoefficients;
11
+ // The threshold to trigger an auto-trigger based on the sigmoid of the result
12
+ const TRIGGER_THRESHOLD = 0.43;
13
+ // The sigmoid function to clamp the auto-trigger result to the (0, 1) range
14
+ const sigmoid = (x) => {
15
+ return 1 / (1 + Math.exp(-x));
16
+ };
17
+ // Check if a character or a single character insertion (sometimes expanded to matching character for brackets)
18
+ // are special characters. This could be expanded if more languages with other special characters are supported.
19
+ const isSpecialCharacter = (char) => ['(', '()', '[', '[]', '{', '{}', ':'].includes(char);
20
+ /**
21
+ * Determine the trigger type based on the file context. Currently supports special cases for Special Characters and Enter keys,
22
+ * as determined by the File Context. For regular typing or undetermined triggers, the Classifier trigger type is used.
23
+ *
24
+ * This is a helper function that can be used since in LSP we don't have the actual keypress events. So we don't know
25
+ * (exactly) whether a position was reached through for instance inserting a new line or backspacing the next line.
26
+ *
27
+ * @param fileContext The file with left and right context based on the invocation position
28
+ * @returns The TriggerType
29
+ */
30
+ const triggerType = (fileContext) => {
31
+ const trimmedLeftContext = fileContext.leftFileContent.trimEnd();
32
+ if (isSpecialCharacter(trimmedLeftContext.at(-1) || '')) {
33
+ return 'SpecialCharacters';
34
+ }
35
+ const lastCRLF = fileContext.leftFileContent.lastIndexOf('\r\n');
36
+ if (lastCRLF >= 0 && fileContext.leftFileContent.substring(lastCRLF + 2).trim() === '') {
37
+ return 'Enter';
38
+ }
39
+ const lastLF = fileContext.leftFileContent.lastIndexOf('\n');
40
+ if (lastLF >= 0 && fileContext.leftFileContent.substring(lastLF + 2).trim() === '') {
41
+ return 'Enter';
42
+ }
43
+ return 'Classifier';
44
+ };
45
+ exports.triggerType = triggerType;
46
+ // Normalize values based on minn and maxx values in the coefficients.
47
+ const normalize = (val, field) => (val - typedCoefficients.minn[field]) / (typedCoefficients.maxx[field] - typedCoefficients.minn[field]);
48
+ /**
49
+ * Auto Trigger to determine whether a keystroke or edit should trigger a recommendation invocation.
50
+ * It uses information about the file, the position, the last entered character, the environment,
51
+ * and previous recommendation decisions from the user to determine whether a new recommendation
52
+ * should be shown. The auto-trigger is not stateful and does not keep track of past invocations.
53
+ */
54
+ const autoTrigger = ({ fileContext, char, triggerType, os, previousDecision, ide, lineNum, }) => {
55
+ const leftContextLines = fileContext.leftFileContent.split(/\r?\n/);
56
+ const leftContextAtCurrentLine = leftContextLines[leftContextLines.length - 1];
57
+ const tokens = leftContextAtCurrentLine.trim().split(' ');
58
+ const lastToken = tokens[tokens.length - 1];
59
+ const keyword = lastToken?.length > 1 ? lastToken : '';
60
+ const lengthOfLeftCurrent = leftContextLines[leftContextLines.length - 1].length;
61
+ const lengthOfLeftPrev = leftContextLines[leftContextLines.length - 2]?.length ?? 0;
62
+ const lengthOfRight = fileContext.rightFileContent.trim().length;
63
+ const triggerTypeCoefficient = coefficients.triggerTypeCoefficient[triggerType] ?? 0;
64
+ const osCoefficient = coefficients.osCoefficient[os] ?? 0;
65
+ const charCoefficient = coefficients.charCoefficient[char] ?? 0;
66
+ const keyWordCoefficient = coefficients.charCoefficient[keyword] ?? 0;
67
+ const languageCoefficient = coefficients.languageCoefficient[fileContext.programmingLanguage.languageName] ?? 0;
68
+ let previousDecisionCoefficient = 0;
69
+ if (previousDecision === 'Accept') {
70
+ previousDecisionCoefficient = coefficients.prevDecisionAcceptCoefficient;
71
+ }
72
+ else if (previousDecision === 'Reject') {
73
+ previousDecisionCoefficient = coefficients.prevDecisionRejectCoefficient;
74
+ }
75
+ else if (previousDecision === 'Discard' || previousDecision === 'Empty') {
76
+ previousDecisionCoefficient = coefficients.prevDecisionOtherCoefficient;
77
+ }
78
+ const ideCoefficient = coefficients.ideCoefficient[ide] ?? 0;
79
+ let leftContextLengthCoefficient = 0;
80
+ if (fileContext.leftFileContent.length >= 0 && fileContext.leftFileContent.length < 5) {
81
+ leftContextLengthCoefficient = coefficients.lengthLeft0To5Coefficient;
82
+ }
83
+ else if (fileContext.leftFileContent.length >= 5 && fileContext.leftFileContent.length < 10) {
84
+ leftContextLengthCoefficient = coefficients.lengthLeft5To10Coefficient;
85
+ }
86
+ else if (fileContext.leftFileContent.length >= 10 && fileContext.leftFileContent.length < 20) {
87
+ leftContextLengthCoefficient = coefficients.lengthLeft10To20Coefficient;
88
+ }
89
+ else if (fileContext.leftFileContent.length >= 20 && fileContext.leftFileContent.length < 30) {
90
+ leftContextLengthCoefficient = coefficients.lengthLeft20To30Coefficient;
91
+ }
92
+ else if (fileContext.leftFileContent.length >= 30 && fileContext.leftFileContent.length < 40) {
93
+ leftContextLengthCoefficient = coefficients.lengthLeft30To40Coefficient;
94
+ }
95
+ else if (fileContext.leftFileContent.length >= 40 && fileContext.leftFileContent.length < 50) {
96
+ leftContextLengthCoefficient = coefficients.lengthLeft40To50Coefficient;
97
+ }
98
+ const classifierResult = coefficients.lengthOfRightCoefficient * normalize(lengthOfRight, 'lenRight') +
99
+ coefficients.lengthOfLeftCurrentCoefficient * normalize(lengthOfLeftCurrent, 'lenLeftCur') +
100
+ coefficients.lengthOfLeftPrevCoefficient * normalize(lengthOfLeftPrev, 'lenLeftPrev') +
101
+ coefficients.lineNumCoefficient * normalize(lineNum, 'lineNum') +
102
+ osCoefficient +
103
+ triggerTypeCoefficient +
104
+ charCoefficient +
105
+ keyWordCoefficient +
106
+ ideCoefficient +
107
+ coefficients.intercept +
108
+ previousDecisionCoefficient +
109
+ languageCoefficient +
110
+ leftContextLengthCoefficient;
111
+ const shouldTrigger = sigmoid(classifierResult) > TRIGGER_THRESHOLD;
112
+ return {
113
+ shouldTrigger,
114
+ classifierResult,
115
+ classifierThreshold: TRIGGER_THRESHOLD,
116
+ };
117
+ };
118
+ exports.autoTrigger = autoTrigger;
119
+ //# sourceMappingURL=autoTrigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autoTrigger.js","sourceRoot":"","sources":["../../../src/language-server/auto-trigger/autoTrigger.ts"],"names":[],"mappings":";;;AACA,yDAAyD;AAOzD;;;;GAIG;AACH,MAAM,YAAY,GAAiB,iBAAiC,CAAA;AAEpE,8EAA8E;AAC9E,MAAM,iBAAiB,GAAG,IAAI,CAAA;AAE9B,4EAA4E;AAC5E,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE;IAC1B,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACjC,CAAC,CAAA;AAED,+GAA+G;AAC/G,gHAAgH;AAChH,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;AAQlG;;;;;;;;;GASG;AACI,MAAM,WAAW,GAAG,CAAC,WAAwB,EAAqC,EAAE;IACvF,MAAM,kBAAkB,GAAG,WAAW,CAAC,eAAe,CAAC,OAAO,EAAE,CAAA;IAChE,IAAI,kBAAkB,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QACtD,OAAO,mBAAmB,CAAA;IAC9B,CAAC;IAED,MAAM,QAAQ,GAAG,WAAW,CAAC,eAAe,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IAChE,IAAI,QAAQ,IAAI,CAAC,IAAI,WAAW,CAAC,eAAe,CAAC,SAAS,CAAC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AC1F,YAAY,CAAC,2BAA2B,GAAG,SAAS,CAAC,gBAAgB,EAAE,aAAa,CAAC;QACrF,YAAY,CAAC,kBAAkB,GAAG,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC;QAC/D,aAAa;QACb,sBAAsB;QACtB,eAAe;QACf,kBAAkB;QAClB,cAAc;QACd,YAAY,CAAC,SAAS;QACtB,2BAA2B;QAC3B,mBAAmB;QACnB,4BAA4B,CAAA;IAEhC,MAAM,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC,GAAG,iBAAiB,CAAA;IAEnE,OAAO;QACH,aAAa;QACb,gBAAgB;QAChB,mBAAmB,EAAE,iBAAiB;KACzC,CAAA;AACL,CAAC,CAAA;AA/EY,QAAA,WAAW,eA+EvB"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const assert = require("assert");
4
+ const autoTrigger_1 = require("./autoTrigger");
5
+ describe('Auto Trigger', async () => {
6
+ describe('Get Trigger Type', async () => {
7
+ const HELLO_WORLD_IN_CSHARP = `class HelloWorld
8
+ {
9
+ 🐵static void Main(🐶)
10
+ {
11
+ Console.🦊WriteLine("Hello World!");
12
+ 🐱
13
+ }
14
+ }
15
+ `;
16
+ it('returns SpecialCharacters trigger after brackets with newline', async () => {
17
+ const context = HELLO_WORLD_IN_CSHARP.split('🐵');
18
+ const fileContext = {
19
+ filename: 'test.cs',
20
+ leftFileContent: context[0],
21
+ rightFileContent: context[1],
22
+ programmingLanguage: {
23
+ languageName: 'csharp',
24
+ },
25
+ };
26
+ const trigger = (0, autoTrigger_1.triggerType)(fileContext);
27
+ assert.equal(trigger, 'SpecialCharacters');
28
+ });
29
+ it('returns SpecialCharacters trigger after parenthesis', async () => {
30
+ const context = HELLO_WORLD_IN_CSHARP.split('🐶');
31
+ const fileContext = {
32
+ filename: 'test.cs',
33
+ leftFileContent: context[0],
34
+ rightFileContent: context[1],
35
+ programmingLanguage: {
36
+ languageName: 'csharp',
37
+ },
38
+ };
39
+ const trigger = (0, autoTrigger_1.triggerType)(fileContext);
40
+ assert.equal(trigger, 'SpecialCharacters');
41
+ });
42
+ it('returns Classifier trigger after regular typing', async () => {
43
+ const context = HELLO_WORLD_IN_CSHARP.split('🦊');
44
+ const fileContext = {
45
+ filename: 'test.cs',
46
+ leftFileContent: context[0],
47
+ rightFileContent: context[1],
48
+ programmingLanguage: {
49
+ languageName: 'csharp',
50
+ },
51
+ };
52
+ const trigger = (0, autoTrigger_1.triggerType)(fileContext);
53
+ assert.equal(trigger, 'Classifier');
54
+ });
55
+ it('returns Enter trigger after newline with some indentation', async () => {
56
+ const context = HELLO_WORLD_IN_CSHARP.split('🐱');
57
+ const fileContext = {
58
+ filename: 'test.cs',
59
+ leftFileContent: context[0],
60
+ rightFileContent: context[1],
61
+ programmingLanguage: {
62
+ languageName: 'csharp',
63
+ },
64
+ };
65
+ const trigger = (0, autoTrigger_1.triggerType)(fileContext);
66
+ assert.equal(trigger, 'Enter');
67
+ });
68
+ it('returns Classifier trigger for empty file', async () => {
69
+ const fileContext = {
70
+ filename: 'test.cs',
71
+ leftFileContent: '',
72
+ rightFileContent: '',
73
+ programmingLanguage: {
74
+ languageName: 'csharp',
75
+ },
76
+ };
77
+ const trigger = (0, autoTrigger_1.triggerType)(fileContext);
78
+ assert.equal(trigger, 'Classifier');
79
+ });
80
+ });
81
+ });
82
+ //# sourceMappingURL=autoTrigger.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autoTrigger.test.js","sourceRoot":"","sources":["../../../src/language-server/auto-trigger/autoTrigger.test.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AAEjC,+CAA2C;AAE3C,QAAQ,CAAC,cAAc,EAAE,KAAK,IAAI,EAAE;IAChC,QAAQ,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;QACpC,MAAM,qBAAqB,GAAG;;;;;;;;CAQrC,CAAA;QAEO,EAAE,CAAC,+DAA+D,EAAE,KAAK,IAAI,EAA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