|
| 1 | +import type { languages } from 'monaco-editor'; |
| 2 | + |
| 3 | +export function getGeneralSuggestions(monaco: typeof import('monaco-editor'), range: any) { |
| 4 | + return [ |
| 5 | + { |
| 6 | + label: 'System.out.println', |
| 7 | + kind: monaco.languages.CompletionItemKind.Snippet, |
| 8 | + insertText: 'System.out.println(${1:message});', |
| 9 | + insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet, |
| 10 | + documentation: 'Prints a message to the standard output', |
| 11 | + range: range |
| 12 | + }, |
| 13 | + { |
| 14 | + label: 'for (int i = 0; i < n; i++)', |
| 15 | + kind: monaco.languages.CompletionItemKind.Snippet, |
| 16 | + insertText: 'for (int ${1:i} = 0; ${1:i} < ${2:n}; ${1:i}++) {\n\t$0\n}', |
| 17 | + insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet, |
| 18 | + documentation: 'Basic for loop', |
| 19 | + range: range |
| 20 | + }, |
| 21 | + { |
| 22 | + label: 'while', |
| 23 | + kind: monaco.languages.CompletionItemKind.Snippet, |
| 24 | + insertText: 'while (${1:condition}) {\n\t$0\n}', |
| 25 | + insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet, |
| 26 | + documentation: 'While loop', |
| 27 | + range: range |
| 28 | + }, |
| 29 | + { |
| 30 | + label: 'if', |
| 31 | + kind: monaco.languages.CompletionItemKind.Snippet, |
| 32 | + insertText: 'if (${1:condition}) {\n\t$0\n}', |
| 33 | + insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet, |
| 34 | + documentation: 'If statement', |
| 35 | + range: range |
| 36 | + }, |
| 37 | + { |
| 38 | + label: 'ArrayList', |
| 39 | + kind: monaco.languages.CompletionItemKind.Snippet, |
| 40 | + insertText: 'ArrayList<${1:type}> ${2:list} = new ArrayList<>();', |
| 41 | + insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet, |
| 42 | + documentation: 'Creates an ArrayList', |
| 43 | + range: range |
| 44 | + }, |
| 45 | + { |
| 46 | + label: 'HashMap', |
| 47 | + kind: monaco.languages.CompletionItemKind.Snippet, |
| 48 | + insertText: 'HashMap<${1:K}, ${2:V}> ${3:map} = new HashMap<>();', |
| 49 | + insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet, |
| 50 | + documentation: 'Creates a HashMap', |
| 51 | + range: range |
| 52 | + }, |
| 53 | + { |
| 54 | + label: 'HashSet', |
| 55 | + kind: monaco.languages.CompletionItemKind.Snippet, |
| 56 | + insertText: 'HashSet<${1:type}> ${2:set} = new HashSet<>();', |
| 57 | + insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet, |
| 58 | + documentation: 'Creates a HashSet', |
| 59 | + range: range |
| 60 | + }, |
| 61 | + // 可以继续添加更多通用提示 |
| 62 | + ]; |
| 63 | +} |
0 commit comments