-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UX Enhancements #160
Merged
Merged
UX Enhancements #160
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7a6747d
First step: fix #147 (CI will fail)
fdodino cd37dc9
Fix #146
fdodino 7c46839
Add info of doc
fdodino bb61364
linter fixes
fdodino f04bbc1
Fix #149 - delete/rename leaves zombies problems
fdodino 8dd72f1
Fix #121 - ms to open dynamic diagram
fdodino df4b6a5
Fix #122 - skip diagram in ts-cli
fdodino 3010480
Fix #111 - wollok icon
fdodino c7b5e1b
Fix e2e test
fdodino 43c3d75
Back to old image but better definition
fdodino 0e5f67a
Removing migrated functions
fdodino d164c8c
Add new version for wollok-ts
fdodino 11e985c
Hack to test hover
fdodino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,22 @@ | ||
import { Location, TextDocumentPositionParams } from 'vscode-languageserver' | ||
import { Environment, Method, Module, New, Node, Reference, Self, Send, Singleton, Super, is, match, when } from 'wollok-ts' | ||
import { getNodesByPosition, nodeToLocation } from '../utils/text-documents' | ||
import { logger } from '../utils/logger' | ||
|
||
export const definition = (environment: Environment) => ( | ||
textDocumentPosition: TextDocumentPositionParams | ||
): Location[] => { | ||
const cursorNodes = getNodesByPosition(environment, textDocumentPosition) | ||
const definitions = getNodeDefinition(environment)(cursorNodes.reverse()[0]) | ||
const definitions = getDefinition(environment)(cursorNodes.reverse()[0]) | ||
return definitions.map(nodeToLocation) | ||
} | ||
|
||
// WOLLOK-TS: hablar con Nahue/Ivo, para mí desde acá para abajo todo se podria migrar a wollok-ts | ||
export const getNodeDefinition = (environment: Environment) => (node: Node): Node[] => { | ||
export const getDefinition = (environment: Environment) => (node: Node): Node[] => { | ||
Check failure on line 15 in server/src/functionalities/definition.ts GitHub Actions / test (ubuntu-latest, lts/hydrogen)
|
||
try { | ||
return match(node)( | ||
when(Reference)(node => definedOrEmpty(referenceDefinition(node))), | ||
when(Send)(sendDefinitions(environment)), | ||
when(Super)(node => definedOrEmpty(superMethodDefinition(node))), | ||
when(Self)(node => definedOrEmpty(node.ancestors.find(is(Module)))) | ||
) | ||
} catch { | ||
getNodeDefinition(environment)(node) | ||
Check failure on line 17 in server/src/functionalities/definition.ts GitHub Actions / test (ubuntu-latest, lts/hydrogen)
|
||
} catch (error) { | ||
logger.error(`✘ Error in getDefinition: ${error}`, error) | ||
return [node] | ||
} | ||
} | ||
|
||
function referenceDefinition(ref: Reference<Node>): Node | undefined { | ||
return ref.target | ||
} | ||
|
||
|
||
const sendDefinitions = (environment: Environment) => (send: Send): Method[] => { | ||
try { | ||
return match(send.receiver)( | ||
when(Reference)(node => { | ||
const target = node.target | ||
return target && is(Singleton)(target) ? | ||
definedOrEmpty(target.lookupMethod(send.message, send.args.length)) | ||
: allMethodDefinitions(environment, send) | ||
}), | ||
when(New)(node => definedOrEmpty(node.instantiated.target?.lookupMethod(send.message, send.args.length))), | ||
when(Self)(_ => moduleFinderWithBackup(environment, send)( | ||
(module) => definedOrEmpty(module.lookupMethod(send.message, send.args.length)) | ||
)), | ||
) | ||
} catch { | ||
return allMethodDefinitions(environment, send) | ||
} | ||
} | ||
|
||
function superMethodDefinition(superNode: Super): Method | undefined { | ||
const currentMethod = superNode.ancestors.find(is(Method))! | ||
const module = superNode.ancestors.find(is(Module)) | ||
return module ? module.lookupMethod(currentMethod.name, superNode.args.length, { lookupStartFQN: module.fullyQualifiedName }) : undefined | ||
} | ||
|
||
function allMethodDefinitions(environment: Environment, send: Send): Method[] { | ||
const arity = send.args.length | ||
const name = send.message | ||
return environment.descendants.filter(n => | ||
is(Method)(n) && | ||
n.name === name && | ||
n.parameters.length === arity | ||
) as Method[] | ||
} | ||
|
||
|
||
// UTILS | ||
const moduleFinderWithBackup = (environment: Environment, send: Send) => (methodFinder: (module: Module) => Method[]) => { | ||
const module = send.ancestors.find(is(Module)) | ||
return module ? methodFinder(module) : allMethodDefinitions(environment, send) | ||
} | ||
|
||
function definedOrEmpty<T>(value: T | undefined): T[] { | ||
return value ? [value] : [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Por si te complicaba la def de este archivo, por las dudas dejo link a la version en svg de este icono: https://drive.google.com/drive/folders/1h_GfnEt2FdGlOD7U_b-mNBr8eBhfiM_8?usp=drive_link