Skip to content

Conversation

@glennsarti
Copy link
Contributor

@glennsarti glennsarti commented Jan 18, 2019

The Puppet language introduced Puppet Tasks and Plans as part of
Puppet 5.4.0 [1]. A special parsing switch --tasks was
introduced which changes the behaviour of the Puppet parser, that
is switching it into "tasks" mode. Unfortunately this switch is
global to all Puppet parsing therefore to dynamically switch it
like we do in Editor Services, this required a global mutex to be
used.

Note that this commit does not add Puppet Tasks/Plans intellisense
but merely allows the standard manifest providers (completion,
validation etc.) to actually function instead of silently failing

This commit;

  • Modifies the Puppet parser, via monkey patching, to implement a
    "singleton" parsing method that dynamically, and safely, switch
    the parsing mode on a per request basis
  • Modifies the Document Store to detect whether a File URI is a
    Puppet Task/Plan based on the relative path of the file versus
    the module root.
  • Modifies the various providers to call the parsing helper in the
    correct mode
  • Modifies the Message Router to detect whether a file is a Puppet
    Task/Plan and then sets the appropriate mode when calling the
    manifest providers (completion, validation etc.)

[1] https://puppet.com/docs/bolt/1.x/writing_plans.html#concept-4485

Fixes #24


  • Extend parsing to dynamically switch Puppet[:tasks]
  • Add tests for parsing plan files

Completion Provider

  • Extend manifest completion provider to understand plan files
  • Add tests for completing plan files

Definition Provider

  • Extend manifest definition provider to understand plan files
  • Add tests for defining plan files

Document Symbol Provider

  • Extend manifest doc. symbol provider to understand plan files
  • Add tests for symbol-extracting plan files

Hover Provider

  • Extend manifest hover provider to understand plan files
  • Add tests for hovering in plan files

Validation Provider

  • modify Validation parsing to dynamically switch Puppet[:tasks]
  • Extend validation provider to understand plan files
  • Add tests for validating plan files

@glennsarti
Copy link
Contributor Author

glennsarti commented Jan 20, 2019

Extracting and using the bolt metadata may be another PR. The scope is creepin'

@glennsarti glennsarti changed the title {WIP} (GH_24) Allow parsing in tasks mode {WIP} (GH-24) Allow parsing in tasks mode Jan 20, 2019
Previously the parser helper was silently failing to parse documents
that had the cursor at line 0, char 0. This was due to the
removal based methods trying to remove characters at the beginning
of the document.  This commit modifies the helper to ignore these
parsing attempts if the cursor is at line 0, char 0.
@glennsarti glennsarti added this to the 0.18.0 milestone Jan 20, 2019
@glennsarti glennsarti changed the title {WIP} (GH-24) Allow parsing in tasks mode (GH-24) Allow parsing in tasks mode Jan 21, 2019
@glennsarti glennsarti added enhancement New feature or request Language Server labels Jan 21, 2019
@jpogran jpogran self-requested a review January 24, 2019 15:09
@jpogran
Copy link
Contributor

jpogran commented Jan 24, 2019

With the puppetlabs-reboot module I still get a syntax error:

image

Environment:

VSCode:

[master ≡ +0 ~1 -0 !] ~\src\lingua-pupuli\vscode
01-24 18:39:27 21> code -v
1.30.2
61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8
x64

Puppet: v6.0.2 from PDK 1.7.1

Repro steps:

  1. Set editor-compontents.json
[master ≡ +0 ~1 -0 !] ~\src\lingua-pupuli\vscode
01-24 18:35:25 16> git diff
diff --git a/editor-components.json b/editor-components.json
index 013dbfe..c3c0b19 100644
--- a/editor-components.json
+++ b/editor-components.json
@@ -1,6 +1,8 @@
 {
   "editor-services": {
-    "release": "0.17.0"
+    "githubuser": "glennsarti",
+    "githubrepo": "puppet-editor-services",
+    "githubref": "gh-24-parseplans"
   },
   "editor-syntax": {
     "release": "1.3.0"
  1. Pull latest
master ≡ +0 ~1 -0 !] ~\src\lingua-pupuli\vscode
01-24 18:35:29 17> npm run vscode:prepublish

> puppet-vscode@0.15.1 vscode:prepublish C:\Users\james\src\lingua-pupuli\vscode
> node node_modules/gulp/bin/gulp.js build

[18:36:55] Using gulpfile ~\src\lingua-pupuli\vscode\gulpfile.js
[18:36:55] Starting 'build'...
[18:36:55] Starting 'clean'...
[18:36:55] Finished 'clean' after 118 ms
[18:36:55] Starting 'vendor'...
[18:36:55] Starting 'vendor_editor_services'...
[18:36:57] Finished 'vendor_editor_services' after 1.11 s
[18:36:57] Starting 'vendor_editor_syntax'...
[18:36:57] Finished 'vendor_editor_syntax' after 251 ms
[18:36:57] Finished 'vendor' after 1.37 s
[18:36:57] Starting 'compile_typescript'...
[18:36:59] Finished 'compile_typescript' after 2.65 s
[18:36:59] Finished 'build' after 4.15 s
  1. Launch Extension Debug host with puppetlabs-reboot

@glennsarti
Copy link
Contributor Author

Repro'd. Try to figure out what's gone south ...

@glennsarti
Copy link
Contributor Author

Found it...URI escaping was breaking my path checking.

@glennsarti
Copy link
Contributor Author

glennsarti commented Jan 25, 2019

Fixed. Had to rework the URIHelper.

.... and CI blew up :-)

The Puppet language introduced Puppet Tasks and Plans as part of
Puppet 5.4.0 [1].  A special parsing switch `--tasks` was
introduced which changes the behaviour of the Puppet parser, that
is switching it into "tasks" mode.  Unfortunately this switch is
global to all Puppet parsing therefore to dynamically switch it
like we do in Editor Services, this required a global mutex to be
used.

Note that this commit does not add Puppet Tasks/Plans intellisense
but merely allows the standard manifest providers (completion,
validation etc.) to actually function instead of silently failing

This commit;
* Modifies the Puppet parser, via monkey patching, to implement a
  "singleton" parsing method that dynamically, and safely, switch
  the parsing mode on a per request basis
* Modifies the Document Store to detect whether a File URI is a
  Puppet Task/Plan based on the relative path of the file versus
  the module root.
* Modifies the various providers to call the parsing helper in the
  correct mode
* Modifies the Message Router to detect whether a file is a Puppet
  Task/Plan and then sets the appropriate mode when calling the
  manifest providers (completion, validation etc.)

[1] https://puppet.com/docs/bolt/1.x/writing_plans.html#concept-4485
This commit updates two minor violations that appeared as part of
robocop 0.63.1.
@jpogran
Copy link
Contributor

jpogran commented Jan 25, 2019

Confirmed working with previous setup:

image

@jpogran
Copy link
Contributor

jpogran commented Jan 25, 2019

We'll have to add documentation in the vscode readme about what to expect. For example, we no longer throw errors, but the advanced features are not implemented yet. WIP, etc

@jpogran jpogran merged commit 99fce1d into puppetlabs:master Jan 25, 2019
@glennsarti glennsarti deleted the gh-24-parseplans branch February 8, 2019 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants