Skip to content

Commit

Permalink
refactoring reference highlighter
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Jan 1, 2025
1 parent 660f3ff commit 161e5a4
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions packages/client/src/highlighter/tokenProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,14 @@ function processNode(node: Node, textDocument: string[], context: NodeContext[])
),
when(Variable)(resultForReference),
when(Reference)(node => {
//node.variable
//node.value
//TODO: Si previamente hay un campo del mismo nombre no se toma
//TODO: los parametros o propiedades se toman como nuevas referencias
if(node.name == 'wollok.lang.Closure'
|| node.name == 'wollok.lang.List'
|| node.name == 'wollok.lang.Set')
return nullHighlighting

const referencia = context.find(currentNode => currentNode.name === node.name)
if (referencia){
const pl = generatePlotterForNode(node)
pl.tokenType = tokenTypeObj[referencia.type]
return { result: pl, references: undefined } //no agrego informacion
const reference = context.find(currentNode => currentNode.name === node.name)
if (reference){
return { result: [
{
...generatePlotterForNode(node),
tokenType: tokenTypeObj[reference.type]
},
], references: undefined }
}
return nullHighlighting
}),
Expand Down Expand Up @@ -181,24 +175,23 @@ function processNode(node: Node, textDocument: string[], context: NodeContext[])
}
}),
when(Send)(node => {
const currentKeyboard = keywords[node.kind]
const symbols = keywords[node.kind]
const { line, column, word } = getLine(node, textDocument)
if(currentKeyboard && currentKeyboard.includes(node.message)){
if(node.message == 'negate'){//es la forma alternativa del simbolo '!'
const idx_negate = word.indexOf('!')
const col_offset: number= idx_negate == -1? word.indexOf('not'): idx_negate
const plotKeyboard = plotter({
if (symbols?.includes(node.message)){

if (node.message == 'negate') {
const operator = word.indexOf('!') == -1 ? 'not' : '!'
const columnOffset = word.indexOf(operator)
return dropSingleReference(plotter({
ln: line,
col: column + col_offset,
len: idx_negate == -1? 3: 1,
}, node.kind)
return dropSingleReference(plotKeyboard)
col: column + columnOffset,
len: operator.length,
}, node.kind))
}
const col = column + word.indexOf(node.message)
const plotKeyboard = plotter({ ln: line, col, len: node.message.length }, node.kind)
return dropSingleReference(plotKeyboard)
}
//if(keywords.Send.includes(node.message)) return null_case
const col = column + word.indexOf(node.message)
return {
result: [plotter({ ln: line, col, len: node.message.length }, 'Method')], //node.kind)
Expand Down

0 comments on commit 161e5a4

Please sign in to comment.