Skip to content

Commit

Permalink
feat: формирование описаний
Browse files Browse the repository at this point in the history
  • Loading branch information
alkoleft committed Jan 10, 2025
1 parent cbeadb8 commit 74bd482
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/bsl/features/completionItemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { scopeProvider } from '../scopeProvider';

const completionItemProvider: languages.CompletionItemProvider = {
triggerCharacters: ['.', '"', ' ', '&'],
provideCompletionItems(model: editor.ITextModel, position: Position): languages.ProviderResult<languages.CompletionList> {

provideCompletionItems(model: editor.ITextModel, position: Position): languages.ProviderResult<languages.CompletionList> {
const scope = scopeProvider.resolveScope(model, position)

console.debug('completion scope: ', scope)

if (scope === undefined) {
return undefined
}
Expand Down
8 changes: 8 additions & 0 deletions src/bsl/features/documentationRender.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { MethodSignature, Symbol } from "../../scope";

export function signatureLabel(signature: MethodSignature) {
return signature.params.map(p => p.name + ':' + p.type).join(', ')
}
export function signatureDocumentation(method: Symbol, signature: MethodSignature) {
return signature.description === '' ? method.description : signature.description
}
7 changes: 4 additions & 3 deletions src/bsl/features/signatureHelpProvider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { editor, languages, Position, CancellationToken } from 'monaco-editor'
import { scopeProvider } from '../scopeProvider'
import { Symbol, PlatformMethodSymbol, SymbolType } from '../../scope'
import { signatureDocumentation, signatureLabel } from './documentationRender'

const signatureHelpProvider: languages.SignatureHelpProvider = {
signatureHelpRetriggerCharacters: ['(', ','],
Expand Down Expand Up @@ -29,7 +30,6 @@ const signatureHelpProvider: languages.SignatureHelpProvider = {
} else {
return undefined
}

},
}

Expand All @@ -41,8 +41,9 @@ function methodSignature(symbol: Symbol): languages.SignatureInformation[] {
if (isPlatformMethod(symbol)) {
return symbol.signatures.map(s => {
return {
label: s.description === '' ? symbol.name : s.description,
documentation: s.description === '' ? symbol.description : s.description, activeParameter: 0,
label: signatureLabel(s),
documentation: signatureDocumentation(symbol, s),
activeParameter: 0,
parameters: s.params.map(p => {
return {
label: p.name,
Expand Down
4 changes: 2 additions & 2 deletions src/bsl/scopeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ const scopeProvider = {
return currentMember(tokensSequence, scope, position.lineNumber, word)
},
currentMethod(model: editor.ITextModel, position: Position): Symbol | undefined {
console.debug('Get current method')
console.debug('current word', model.getWordUntilPosition(position)?.word)

console.debug('current symbol')
const tokensSequence = tokensProvider.findMethod(model, position)

console.debug('tokensSequence: ', tokensSequence)

if (tokensSequence === undefined) {
return undefined
}
Expand Down

0 comments on commit 74bd482

Please sign in to comment.