-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
add "id" to ContributedTaskConfiguration interface #7670
Conversation
* ID of the provided/detected task. | ||
* This field is not supposed to be used in `tasks.json`. | ||
*/ | ||
readonly id: string; |
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.
Hi @RomanNikitenko , does this change look OK to you?
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.
Hello, Liang!
Yes, it looks good to me.
If I understand correctly, we need these changes (run a task by id
instead of by source
and label
) to have more reliable way of matching a task for running.
Right?
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.
yes. the label of detected tasks can be customized by the user so it would be easier to use id instead.
- all detected tasks are associated with unique IDs (https://github.com/eclipse-theia/theia/blob/bda9ff9d4cf15b28b5ffc2e984f11834adfc8f33/packages/plugin-ext/src/plugin/types-impl.ts#L1786-L1800). This pull request adds the "id" property to the ContributedTaskConfiguration interface. - fixes #7514 Signed-off-by: Liang Huang <[email protected]>
6324664
to
caf6fc5
Compare
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.
Tested for npm
build
and clean
tasks, it works well for me!
For tsc
tasks I have problems:
But looks like it's due to: #7684
@@ -66,6 +66,16 @@ export class ProvidedTaskConfigurations { | |||
} | |||
} | |||
|
|||
async getTaskById(id: string): Promise<TaskConfiguration | undefined> { |
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.
Looking at the code, I don't think this is going to work: when we cache tasks, two contributed tasks that have the same scope and the same label will overwrite one another: the id does not factor into the key at all.
Generally, we should have a conversation about what it means for two tasks (configurations/customizations) to be the same. Shooting from the hip in this area will haunt us in the long run, IMO. A simple test I run is this: I have an extension that contributes two tasks that are identical: They still both show up when doing a "run task". |
See also: #7446 (comment) |
I agree with @tsmaeder I see the same for VS Code extensions APIs: #7681 (comment) |
At the moment there is At the same time I guess for these case we should reconsider way how @elaihau @akosyakov @tsmaeder wdyt? |
@RomanNikitenko public runXXX methods on TaskService go through different execution paths, sometimes, so we'd have to be careful when refactoring this. Generally, I think you're right: it does not make sense when we already have a task in hand to "throw it away" and do another lookup via scope and label (I don't think source should come into this, but that's a different topic). |
I meant At this step we are trying to get a configuration for running by
We don't have a config: |
Thanks for the comments !
@RomanNikitenko |
I think someone should look at VS Code as a reference implementation and trace how IDs are computed and used there for different kind of tasks, then we should add tests that it works in the same way.
I am not entirely sure about it. I see that we cache provided tasks. Is it correct? Should not we collect them each time when a user want to run or a VS Code extensions wants to fetch? There is no an event saying that now provided tasks are invalid. Our cache can be invalid anytime. |
@@ -111,6 +121,13 @@ export class ProvidedTaskConfigurations { | |||
return matchedTask; | |||
} | |||
|
|||
/** checks if the config is a detected / contributed task */ | |||
isDetectedTask(task: TaskCustomization | TaskConfiguration | TaskCustomization): task is ContributedTaskConfiguration { |
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.
We should be consistent with naming. Either call them provided, detected or contributed. But please not mix.
For user-configured tasks, we detect changes via notifications. For contributed tasks, we have to assume some scope of validity: otherwise we'd have to constantly refetch tasks from providers. |
I did some investigation with a vscode extension.
|
@elaihau Is there a way to turn your investigation in tests, similarly how it was done for launch configurations: https://github.com/akosyakov/vscode-launch/blob/master/src/test/extension.test.ts Think about different variables which can affect results of Look at source code as well. VS Code have |
@akosyakov Thank you for the guidance ! I think i would be able to translate what i described above into tests for |
Whatever suits you. But I don't see a point to write code If we don't know what is the proper behaviour. For a start just creating a VS Code extension testing
You don't need a VS Code extension to extract and test |
Thank you all for the feedback. |
all detected tasks are associated with unique IDs (
theia/packages/plugin-ext/src/plugin/types-impl.ts
Lines 1786 to 1800 in bda9ff9
fixes Tasks dependency resolution does not work as in VS Code #7514
Signed-off-by: Liang Huang [email protected]
How to test
This is what I added to my
tasks.json
:Review checklist