Skip to content
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

Arrays of objects are not split up in the yaml outline #106

Closed
nicholas-devlin opened this issue Jul 30, 2018 · 6 comments
Closed

Arrays of objects are not split up in the yaml outline #106

nicholas-devlin opened this issue Jul 30, 2018 · 6 comments
Milestone

Comments

@nicholas-devlin
Copy link

Here is an example image: https://cl.ly/0d3J3r3R202l

The text:

init_config:
  
instances:
  - name:  words
    url:   http://localhost:8080/
    http_response_status_code: 200
    timeout: 5
    skip_event: true
    tags:
      - name:words
      - type:app
      - env:prod
  - name:  words2
    url:   http://localhost:8081/
    http_response_status_code: 200
    timeout: 5
    skip_event: true
    tags:
      - name:words2
      - type:app
      - env:prod

instances just appearing as an array with a bunch of duplicate values. http://yaml-online-parser.appspot.com/ seems to correctly parse this as:

{
  "instances": [
    {
      "http_response_status_code": 200, 
      "name": "erights http://localhost:8080/", 
      "timeout": 5, 
      "tags": [
        "name:erights", 
        "type:app", 
        "env:prod"
      ], 
      "url": "http://localhost:8080/", 
      "skip_event": true
    }, 
    {
      "http_response_status_code": 200, 
      "name": "erights http://localhost:8080/", 
      "timeout": 5, 
      "tags": [
        "name:erights", 
        "type:app", 
        "env:prod"
      ], 
      "url": "http://localhost:8080/", 
      "skip_event": true
    }
  ], 
  "init_config": null
}
@JPinkney
Copy link
Contributor

The only way to get the behavior I think you're wanting is to wrap the object document symbols in an object symbol with name Object[0] ... Object[N] though currently the results are consistent with the JSON language server.

@nicholas-devlin
Copy link
Author

Okay so the underlying parser for this project and that site I linked are different? It doesn't have the ability to tell which values are grouped together in an array?

@JPinkney
Copy link
Contributor

It doesn't have the ability to tell which values are grouped together in an array?

It does; thats not the problem. The outline view in VSCode is just getting the document symbols and showing them in a hierarchical way. Its just the only way to achieve this result (as far as I know) is returning a symbol information node that would be the root of the object but I can look into it more.

@nicholas-devlin
Copy link
Author

okay, so since there isn't like a strictly defined object name for each element, it's just smashing each object's values together. In order to get what I'm looking for I'd have to make some kind of dummy object for each element of the array to get it represented in the hierarchy. that seems a bit wasteful, and I don't think I'd change my code just to get it to display prettier there.

I feel like just having the object symbol with no name and a dropdown would be a fine workaround and still be pretty clear. But not sure what would be best.

@JPinkney
Copy link
Contributor

In order to get what I'm looking for I'd have to make some kind of dummy object for each element of the array to get it represented in the hierarchy

That would have to be done on this extensions side not on your side.

I feel like just having the object symbol with no name and a dropdown would be a fine workaround and still be pretty clear.

Perhaps that could work. Though i'm not entirely sure if the language server protocol states whether or not the text should be empty strings or not. Additionally, the regular document symbols (ctrl+shift+o for me on VSCode i'm not sure if thats the default or not though) would just have an empty text field for those objects which wouldn't be really helpful. I'll play around with it and see.

@JPinkney
Copy link
Contributor

This should work now as we've implemented hierarchical document symbols.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants