Skip to content
This repository has been archived by the owner on Aug 29, 2021. It is now read-only.

Highlight #34

Closed
wants to merge 9 commits into from
Closed

Highlight #34

wants to merge 9 commits into from

Conversation

Yurihaia
Copy link
Contributor

No description provided.

@Yurihaia Yurihaia requested a review from Levertion June 23, 2018 15:47
@@ -0,0 +1,20 @@
import { SubAction } from "../types";

export interface HighlightScope {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably go into src/types.ts

export function actionFromScope(scope: HighlightScope): SubAction {
return {
data: scope,
high: scope.end,
Copy link
Owner

@Levertion Levertion Jun 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If start and end are included in the SubAction, why are they in HighlightScope. Wouldn't it be better for this function to be something like:

export function createHighlight(scopes: string[], // Or HighlightInnner if we want to support additional properties
    low:number,
    high: number
): SubAction {return {type:"highlight",data: scopes, low, high};}

Copy link
Owner

@Levertion Levertion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. Still a few issues that need dealing with.

it("should return the correct highlight data", () => {
const reader = new StringReader("test");
const out = literalArgumentParser.parse(reader, properties);
assert.deepStrictEqual(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we need a better way of managing testing actions: actions should be tested inside each test, not as a seperate test. Maybe an AssertActions type which takes over numActions in assertReturn. Additionally assertReturn's signature should use the object pattern, because there are two many arguments. If you don't mind, I could do that in this branch.

src/types.ts Outdated
export type SubAction =
| SubActionBase<"hover", string>
| SubActionBase<"format", string>;
| SubActionBase<"format", string>
| SubActionBase<"highlight", HighlightScope>;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind alphabetising these (I know they weren't alphabetical previously)

```

## Various scopes

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number of scopes here seems very complicated. You might also want to see microsoft/language-server-protocol#124. Having read through the arguments there, I have realised that it's probably better if the server sends highlighting, because we can then send it for each line (This is only better for our server)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, we might want to only support a more simple highlighting method initially until microsoft/language-server-protocol#18 is resolved, which seems to be proceeding in microsoft/vscode-languageserver-node#367. We don't want to make a massively complex system which becomes deprecated in a few weeks.

Copy link
Owner

@Levertion Levertion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better, but still needs some changes

It might even be better not to include a custom highlighting solution, and certainly not a complex one.

i.e. we should emulate the highlighting from vanilla until the upstream changes are passed.

However, we certainly should have a better highlighting system than vanilla eventually.

scopes: [
{
line: number,
scopes: string[]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So when the client recieves this request, it should highlight each occurance of a line number in every open document in the correct colours for the scopes?

How does that make any sense?

Surely we need to send ranges with scopes

```

## Various scopes

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, we might want to only support a more simple highlighting method initially until microsoft/language-server-protocol#18 is resolved, which seems to be proceeding in microsoft/vscode-languageserver-node#367. We don't want to make a massively complex system which becomes deprecated in a few weeks.

@@ -19,6 +19,13 @@ const parser: Parser = {
if (reader.string.substring(begin, end) === literal) {
reader.cursor = end;
if (reader.peek() === " " || !reader.canRead()) {
helper.addActions(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This being an action is actually quite awkward, because if there is ambiguity, then what should happen? Text can only be highlighted in one colour.

Additionally, what about in the case of failures. Do we include the mangled scopes. What about if parsing one thing failed with some highlighting, but something else suceeded. How do we prioritise the values.
Maybe helper.merge could manage this if the merge argument fails, but that would make helper.merge O(n) of actions.

scopes: ["argument", "literal"],
start: begin
})
);
return helper.succeed();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be updated to helper.addActions(...).suceed()

@Yurihaia Yurihaia closed this Jul 12, 2018
@Yurihaia Yurihaia deleted the highlight branch July 12, 2018 02:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants