Sublime Text custom autocomplete hierarchy - autocomplete

Im using a .sublime-completions file to write my custom autocomplete code:
{
"scope": "source.python",
"completions":
[
"logic",
"True",
"False",
"Object"
]
}
But I'm missing a way of creating a hierarchy, like this:
{
"scope": "source.python",
"completions":
[
"logic",
"True",
"False",
"Object":
[
"worldPosition",
"applyForce",
"name",
"delete"
]
]
}
Does this feature exists? Is there a way to create it?

Related

How do I use an extended definition and not allow additional properties in a way that is compatible with multiple validators (JSON schema draft 7)?

I am creating a strict validator for a complex JSON file and want to re-use various definitions in order to keep the schema manageable and easier to update.
According to the documentation it is necessary to use allOf to extend a definition to add more properties. This is exactly what I've done, but I find that without use of additionalProperties set to false validation doesn't prevent arbitrary other properties being added.
The following massively cut-down schema demonstrates what I'm doing:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://example.com/schema/2021/02/example.json",
"description": "This schema demonstrates how VSCode's JSON schema mechanism fails with allOf used to extend a definition",
"definitions": {
"valueProvider": {
"type": "object",
"properties": {
"example": {
"type": "string"
},
"alternative": {
"type": "string"
}
},
"oneOf": [
{
"required": [
"example"
]
},
{
"required": [
"alternative"
]
}
]
},
"selector": {
"type": "object",
"allOf": [
{
"$ref": "#/definitions/valueProvider"
},
{
"required": [
"operator",
"value"
],
"properties": {
"operator": {
"type": "string",
"enum": [
"IsNull",
"Equals",
"NotEquals",
"Greater",
"GreaterOrEquals",
"Less",
"LessOrEquals"
]
},
"value": {
"type": "string"
}
}
}
],
"additionalProperties": false
}
},
"properties": {
"show": {
"properties": {
"name": {
"type": "string"
},
"selector": {
"description": "This property does not function correctly in VSCode",
"allOf": [
{
"$ref": "#/definitions/selector"
},
{
"additionalProperties": false
}
]
}
},
"additionalProperties": false
}
}
}
This works a treat in IntelliJ IDEA's JSON editor (2020.3.2 ultimate edition) when editing JSON against this schema (using a schema mapping). For example, the file ex-fail.json's content of:
{
"show": {
"name": "a",
"selector": {
"example": "a",
"operator": "IsNull",
"value": "false",
"d": "a"
}
}
}
Is correctly validated, simply highlighting "d" as not allowed, thus:
However, when I use the very same schema and JSON file with VSCode (1.53.2) with vanilla configuration (except for a schema mapping) VSCode erroneously marks "example", "operator", "value" and "d" as not allowed. It looks like this in the VSCode editor:
If I remove the additionalProperties definition from the show.selector property, both IDEA and VSCode indicate that all is well, including allowing the "d" property - in doing this I can simplify that property definition to:
"selector": {
"description": "This property does not function correctly in VSCode",
"$ref": "#/definitions/selector"
}
What can I do to the schema to support both IDEA and VSCode whilst disallowing additional properties where they should not appear?
PS: The schema mapping in VSCode is simply along the lines of:
{
"json.schemas": [
{
"fileMatch": [
"*/config/ex-*.json"
],
"url": "file:///C:/my/path/to/example-schema.json"
}
]
}
You cannot do what you ask with JSON Schema draft-07 or prior.
The reason is, when $ref is used in a schema object, all other properties MUST be ignored.
An object schema with a "$ref" property MUST be interpreted as a
"$ref" reference. The value of the "$ref" property MUST be a URI
Reference. Resolved against the current URI base, it identifies the
URI of a schema to use. All other properties in a "$ref" object MUST
be ignored.
https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-01#section-8.3
We changed this to not be the case for draft 2019-09.
It sounds like VSCode is merging the properties in applicators upwards to the nearest schema object (which is wrong), and IntelliJ IDEA is doing something similar but in a different way (which is also wrong).
The correct validation result for your schema and instance is VALID. See the live demo here: https://jsonschema.dev/s/C6ent
additionalProperties relies on the values of properties and patternProperties within the SAME schema object. It cannot "see through" applicators such as $ref and allOf.
For draft 2019-09, we added unevaluatedProperties, which CAN "see through" applicator keywords (although it's a little more complex than that).
Update:
After reviewing your update, sadly the same is still true.
One approach makes it sort of possible but involves some duplication, and only works when you control the schemas you are referencing.
You would need to redefine your selector property like this...
"selector": {
"description": "This property did not function correctly in VSCode",
"allOf": [
{
"$ref": "#/definitions/selector"
},
{
"properties": {
"operator": true,
"value": true,
"example": true,
"alternative": true
},
"additionalProperties": false
}
]
}
The values of a property object are schema values, and booleans are valid schemas. You don't need (or want to) deal with their validation here, only say these are the allowed ones, followed by no additionalProperties.
You'll also need to remove the additionalProperties: false from your definition of selector, as that is preventing ALL properties (which I now guess is why you saw that issue in one of the editors).
It involves some duplication, but is the only way I'm aware of that you can do this for draft-07 or previous. As I said, not a problem for draft 2019-09 or above due to new kewords.
additionalProperties is problematic because it depends on the properties and patternProperties. The result is that "additionalProperties": false effectively blocks schema composition. #Relequestual showed one alternative approach, here is another approach that is a little less verbose, but still requires duplication of property names.
draft-06 and up
{
"allOf": [{ "$ref": "#/definitions/base" }],
"properties": {
"bar": { "type": "number" }
},
"propertyNames": { "enum": ["foo", "bar"] },
"definitions": {
"base": {
"properties": {
"foo": { "type": "string" }
}
}
}
}

How to request reload for TYPO3 extension field using mask

How do I request a reload for a TYPO3 extension field that is the trigger for a display condition of an other field in the mask.json.
"tx_mask_foobarfield": {
"config": {
"type": "select",
"renderType": "selectSingle",
"size": "",
"default": "foo",
"onChange" : "reload",
"items": [
[
"Foo",
"foo"
],
[
"Bar",
"bar"
]
],
"foreign_table": "",
"foreign_table_where": "",
"fileFolder": "",
"fileFolder_extList": "",
"fileFolder_recursions": "",
"maxitems": "",
"autoSizeMax": ""
},
"exclude": "0",
"key": "some_key"
},
I tried a couple of things but all references I could find tell me just about the way to do it in TCA.
I think you have the "onChange": "reload" on the wrong level.
From documentation it should be a direct successor of the fieldname (sibling to config)

Can alerts be added to a Grafana Panel on a dashboard using API?

There is a Grafana dashboard with a panel inside it. Is it possible to add (or define) an API?
To create new alerts or modify them you need to update the dashboard json that contains the alerts. Use dashboard API and edit particular panel alert section. You need to define an alert there. For example:
"alert": {
"conditions": [
{
"type": "query",
"query": {
"params": [
"A",
"5m",
"now"
]
},
"reducer": {
"type": "avg",
"params": []
},
"evaluator": {
"type": "gt",
"params": [
null
]
},
"operator": {
"type": "and"
}
}
],

Multiselect in Impresspages Plugin Options

How may I use a multiselect field in the Impresspages Plugin options. Something like this:
{
"label": "Social Nets",
"name": "socialNets",
"type": "select",
"multiple": "multiple",
"default": "",
"values": ["", "facebook", "twitter", "pintrest"]
}
Of course, the field above "multiple" doesn't work in this code snip. So, how to implement it in the plugin options json file?
You can use "Checkboxes" field type
"options": [
{
"label": "XXX",
"name": "xxx",
"type": "Checkboxes",
"values": ["option1", "option2", "options3", "option4"]
}
]
There is no such option implemented in the core of the system. Meaning, there's no such field type as 'multiselect'. You can check how other fields are implemented and extend the core, create pull-request and we'll add it in next release.

ContextBroker Vectors UPDATE with unchanged value causes ONCHANGE subscription notification

I have a JSON formatted as this one:
{
"contextElements": [
{
"type": "environment",
"isPattern": "false",
"id": "labMax",
"attributes": [
{
"name": "users",
"type": "vector",
"value": [{"userId":"0001", "status":"0"},{"userId":"0002", "status":"0"}]
},
{
"name": "rooms",
"type": "vector",
"value": [{"room1": [ {"id":"room1"}, {"owner":"1"}]},{"id":"room2"}, {"owner":"2"}]
},
{
"name": "sensors",
"type": "vector",
"value": [
{"sensor1": [ {"id":"1"}, {"location":"room1"},{"value":"11"},{"status":"ok"}]},
{"sensor2": [ {"id":"2"}, {"location":"room1"},{"value":"22"},{"status":"update"}]}
]
}
]
}
],
"updateAction": "APPEND"
}
I have also a subscription ONCHANGE on the attribute "sensors" and when I update it, without changing any value inside the vector, it causes a notification. Probably this is a wrong behaviour because a subscriber should be only notified when a value changes. On the other side, if I use strings or integer as attributes values, it works correctly.
Up to Orion 0.16.0 at least, this is a known behaviour. An issue has been openend in the Orion github.com repository about it.