My syntax highlighting in vscode is not working - json

I have a problem with Visual Studio Code custom syntax highlighting.
I have made a extension using yo code, put it in %userprofile%/.vscode/extensions, restarted Visual Studio Code, but it's not highlighting any words, but at the bottom it says it's using my syntax highlighter.
This is my tmLanguage.json:
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "Instructions ASM",
"patterns": [
{
"include": "#keywords"
},
{
"include": "#typewords"
},
{
"include": "#strings"
},
{
"include": "#numbers"
},
{
"include": "#variables"
},
{
"include": "#comments"
},
{
"include": "#sections"
}
],
"repository": {
"keywords":{
"patterns": [
{
"name": "keyword",
"match": "(mov|xor|and|or|int|jmp|con)"
}
]
},
"typewords": {
"patterns": [
{
"name": "keyword.control",
"match": "(db|dw|dd|resb|resw|resd|eq|byte|word|doubleword)"
}
]
},
"strings": {
"patterns": [
{
"name": "string",
"match": "(\".*\")|('.')"
}
]
},
"numbers": {
"patterns": [
{
"name": "constant.numeric",
"match": "(0[xX][a-fA-F0-9]{1,8})|(\\d+)|(0[bB][0-1]{1,64})"
}
]
},
"variables": {
"patterns": [
{
"name": "variable",
"match": "$[a-zA-Z0-9_-.]{1,255}"
}
]
},
"comments": {
"patterns": [
{
"name": "comment",
"match": ";.*"
}
]
},
"sections": {
"patterns": [
{
"name": "entity.name.class",
"match": "(\\.DATA|\\.TEXT|\\.BSS)"
}
]
}
},
"scopeName": "source.1"
}
This is my package.json:
{
"name": "instruction-assembly",
"displayName": "Instruction assembly",
"description": "Code only in instructions - Assembly readable version",
"version": "0.0.1",
"engines": {
"vscode": "^1.54.0"
},
"categories": [
"Programming Languages"
],
"contributes": {
"languages": [{
"id": "instructions-asm",
"aliases": ["Instructions ASM", "instructions-asm"],
"extensions": [".1"],
"configuration": "./language-configuration.json"
}],
"grammars": [{
"language": "instructions-asm",
"scopeName": "source.1",
"path": "./syntaxes/instructions-asm.tmLanguage.json"
}]
}
}
Thanks!

Related

Unable to parse JSON data for Oracle Integration Cloud using JQ

need help to parse the JSON data received from Oracle Integration Cloud. The expected output is mentioned below alongwith the command i am trying to use.
JQ command
jq '[{id: .id},{integrations: [.integrations[]|{code: .code, version: .version, dependencies: .dependencies|{connections: .connections[]|{id: .id, status: .status}}, .dependencies|{lookups: .lookups}}]}]' output.json
Error :
jq: error: syntax error, unexpected FIELD (Unix shell quoting issues?) at , line 1:
[{id: .id},{integrations: [.integrations[]|{code: .code, version: .version, dependencies: .dependencies|{connections: .connections[]|{id: .id, status: .status}}, .dependencies|{lookups: .lookups}}]}]
Note : If i run below command to fetch only connections data it works fine
jq '[{id: .id},{integrations: [.integrations[]|{code: .code, version: .version, dependencies: .dependencies|{connections: .connections[]|{id: .id, status: .status}}}]}]' output.json
Expected Output:
[
{
"id": "SAMPLE_PACKAGE"
},
{
"integrations": [
{
"code": "HELLO_INTEGRATION",
"version": "01.00.0000",
"dependencies": {
"connections": {
"id": "HELLO_WORLD1",
"status": "CONFIGURED"
}
}
},
{
"code": "HELLO_INTEGRATIO_LOOKUP",
"version": "01.00.0000",
"dependencies": {
"connections": {
"id": "HELLO_WORLD1",
"status": "CONFIGURED"
},
"lookups": {
"name": "COMMON_LOOKUP_VARIABLES",
"status": "CONFIGURED"
}
}
},
{
"code": "HI_INTEGRATION",
"version": "01.00.0000",
"dependencies": {
"connections": {
"id": "HELLO_WORLD1",
"status": "CONFIGURED"
}
}
}
]
}
]
output.json file contains
{
"bartaType": "DEVELOPED",
"countOfIntegrations": 3,
"id": "SAMPLE_PACKAGE",
"integrations": [
{
"code": "HELLO_INTEGRATION",
"dependencies": {
"connections": [
{
"id": "HELLO_WORLD1",
"lockedFlag": false,
"name": "Hello World1",
"role": "SOURCE",
"status": "CONFIGURED",
"type": "rest",
"usage": 6
}
]
},
"description": "",
"eventSubscriptionFlag": false,
"filmstrip": [
{
"code": "HELLO_WORLD1",
"iconUrl": "/images/rest/rest_icon_46.png",
"name": "Hello World1",
"role": "SOURCE",
"status": "CONFIGURED"
}
],
"id": "HELLO_INTEGRATION|01.00.0000",
"lockedFlag": false,
"name": "HELLO_INTEGRATION",
"pattern": "Orchestration",
"patternDescription": "Map Data",
"payloadTracingEnabledFlag": true,
"publishFlag": false,
"scheduleApplicable": false,
"scheduleDefined": false,
"status": "ACTIVATED",
"style": "FREEFORM",
"styleDescription": "Orchestration",
"tempCopyExists": false,
"tracingEnabledFlag": true,
"version": "01.00.0000",
"warningMsg": "ACTIVATE_PUBLISH_NO_CONN"
},
{
"code": "HELLO_INTEGRATIO_LOOKUP",
"dependencies": {
"connections": [
{
"id": "HELLO_WORLD1",
"lockedFlag": false,
"name": "Hello World1",
"role": "SOURCE",
"status": "CONFIGURED",
"type": "rest",
"usage": 6
}
],
"lookups": [
{
"lockedFlag": false,
"name": "COMMON_LOOKUP_VARIABLES",
"status": "CONFIGURED",
"usage": 1
}
]
},
"description": "",
"eventSubscriptionFlag": false,
"filmstrip": [
{
"code": "HELLO_WORLD1",
"iconUrl": "/images/rest/rest_icon_46.png",
"name": "Hello World1",
"role": "SOURCE",
"status": "CONFIGURED"
}
],
"id": "HELLO_INTEGRATIO_LOOKUP|01.00.0000",
"lockedFlag": false,
"name": "HELLO_INTEGRATION_LOOKUP",
"pattern": "Orchestration",
"patternDescription": "Map Data",
"payloadTracingEnabledFlag": true,
"publishFlag": false,
"scheduleApplicable": false,
"scheduleDefined": false,
"status": "ACTIVATED",
"style": "FREEFORM",
"styleDescription": "Orchestration",
"tempCopyExists": false,
"tracingEnabledFlag": true,
"version": "01.00.0000",
"warningMsg": "ACTIVATE_PUBLISH_NO_CONN"
},
{
"code": "HI_INTEGRATION",
"dependencies": {
"connections": [
{
"id": "HELLO_WORLD1",
"lockedFlag": false,
"name": "Hello World1",
"role": "SOURCE",
"status": "CONFIGURED",
"type": "rest",
"usage": 6
}
]
},
"description": "",
"eventSubscriptionFlag": false,
"filmstrip": [
{
"code": "HELLO_WORLD1",
"iconUrl": "/images/rest/rest_icon_46.png",
"name": "Hello World1",
"role": "SOURCE",
"status": "CONFIGURED"
}
],
"id": "HI_INTEGRATION|01.00.0000",
"lockedFlag": false,
"name": "HI_INTEGRATION",
"pattern": "Orchestration",
"patternDescription": "Map Data",
"payloadTracingEnabledFlag": true,
"publishFlag": false,
"scheduleApplicable": false,
"scheduleDefined": false,
"status": "ACTIVATED",
"style": "FREEFORM",
"styleDescription": "Orchestration",
"tempCopyExists": false,
"tracingEnabledFlag": true,
"version": "01.00.0000",
"warningMsg": "ACTIVATE_PUBLISH_NO_CONN"
}
],
"isCloneAllowed": false,
"isViewAllowed": false,
"name": "SAMPLE_PACKAGE",
"type": "DEVELOPED"
}
The problem is that the lookups key is not always present so, you cannot use the [] on it. So, instead you can use the map function and provide a default before piping to the map function like below
[
{ id: .id },
{
integrations: [
.integrations[]|{
id: .id,
code: .code,
dependencies: {
connections: (.dependencies.connections//[]|map({id,status}))[0],
lookups: (.dependencies.lookups//[]|map({name,status}))[0]
}
}
]
}
]
The (.dependencies.lookups//[]|map({name,status}))[0] has the effect of passing an empty array to the map function which results in a null value when accessing the first element.
See in action https://jqplay.org/s/zQBkHtnzOd1
The provided JQ statement works fine for single elements in the array , but incase the array contains multiple elements it only fetches the first element. Also i updated the dependencies object to capture all the arrays ( connections,lookups,certificates,libraries,integrations)
Below is the modified one. Please suggest for any better options.
[
{ id: .id },
{
integrations: [
.integrations[]|{
id: .id,
code: .code,
dependencies: {
connections: (.dependencies.connections//[]|map({id,status})),
lookups: (.dependencies.lookups//[]|map({name,status})),
certificates: (.dependencies.certificates//[]|map({id,status})),
libraries: (.dependencies.libraries//[]|map({code,status,version})),
integrations: (.dependencies.integrations//[]|map({code,version}))
}
}
]
}
]|del(..|select(.==[]))
Note: To remove the empty arrays del function is added which is giving the below output :
[
{
"id": "SAMPLE_PACKAGE"
},
{
"integrations": [
{
"id": "HELLO_INTEGRATION|01.00.0000",
"code": "HELLO_INTEGRATION",
"dependencies": {
"connections": [
{
"id": "HELLO_WORLD1",
"status": "CONFIGURED"
},
{
"id": "HELLO_WORLD2",
"status": "CONFIGURED"
}
]
}
},
{
"id": "HELLO_INTEGRATIO_LOOKUP|01.00.0000",
"code": "HELLO_INTEGRATIO_LOOKUP",
"dependencies": {
"connections": [
{
"id": "HELLO_WORLD1",
"status": "CONFIGURED"
}
],
"lookups": [
{
"name": "COMMON_LOOKUP_VARIABLES",
"status": "CONFIGURED"
}
]
}
},
{
"id": "HI_INTEGRATION|01.00.0000",
"code": "HI_INTEGRATION",
"dependencies": {
"connections": [
{
"id": "HELLO_WORLD1",
"status": "CONFIGURED"
}
]
}
}
]
}
]

Search object a element and return the element and parents

I want to make a search from object JSON but when a I found the element I want to be returned with his previous parents.
[
{
"name": "level1",
"children": [
{
"name": "level2",
"children": [
{
"name": "level3a",
"children": [
{
"name": "text",
"more": "info"
},
{
"name": "text Abc",
"more": "info"
}
]
},
{
"name": "level3b",
"children": [
{
"name": "text-C",
"more": "info"
},
{
"name": "search",
"more": "info"
}
]
},
{
"name": "level3c",
"children": [
{
"name": "info-C",
"more": "info"
},
{
"name": "search",
"more": "info"
}
]
}
]
}
]
},
{
"name": "level1",
"children": [
{
"name": "level2a",
"children": [
{
"name": "level3",
"children": [
{
"name": "text A",
"more": "info"
}
]
},
]
},
{
"name": "level2b",
"children": [
{
"name": "level3",
"children": [
{
"name": "text X",
"more": "info"
}
]
},
]
}
]
}
]
For example: if want to search "text" I want result like this
[
{
"name": "level1",
"children": [
{
"name": "level2",
"children": [
{
"name": "level3a",
"children": [
{
"name": "text",
"more": "info"
},
{
"name": "text Abc",
"more": "info"
}
]
},
{
"name": "level3b",
"children": [
{
"name": "text-C",
"more": "info"
}
]
}
]
}
]
},
{
"name": "level1",
"children": [
{
"name": "level2a",
"children": [
{
"name": "level3",
"children": [
{
"name": "text A",
"more": "info"
}
]
},
]
},
{
"name": "level2b",
"children": [
{
"name": "level3",
"children": [
{
"name": "text X",
"more": "info"
}
]
},
]
}
]
}
]
Things to considerer
only "search" in level 3 children by name property
if one o more childrens matches the search, return all of them
Basically I need to filter by the last level of object with elements matches with the search and return them with them parents.

What is wrong with this code for visual studio code highlighting?

I'm new in visual studio code language creation, and I tried to make my own syntax highlighting for my custom language using yo code. In my tmLanguge.json file, I got this code, but I don't work and it doesn't highlight anything at all. Can someone please tell me what the problem is?
When I tried it only with the "comments" object, it worked well...
Thanks
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "OP-RANDS++",
"patterns": [
{
"include": "#comments"
},
{
"include": "#numbers"
},
{
"include": "#blocks"
},
{
"include": "#basecalls"
},
{
"include": "#outin"
},
{
"include": "#defines"
},
{
"include": "#maths"
},
{
"include": "#others"
}
],
"repository": {
"comments": {
"patterns": [
{
"name":"comment",
"match": "^\u005c?.*"
}
]
},
"numbers": {
"patterns": [
{
"name": "constant.numeric",
"match": "\u005cd|\u005c\u005c\u005cd"
}
]
},
"blocks": {
"patterns": [
{
"name": "emphasis",
"match": "{|}|[|]|(|)"
}
]
},
"basecalls": {
"patterns": [
{
"name": "keyword.control",
"match": "\u005c.|\u005c|"
}
]
},
"outin": {
"patterns": [
{
"name": "entity.name.function",
"match": ";|,"
}
]
},
"defines": {
"patterns": [
{
"name": "variable.name",
"match": "~|`|^"
}
]
},
"maths": {
"patterns": [
{
"name": "keyword.operator",
"match": "+|-|*|/|%"
}
]
},
"others": {
"patterns": [
{
"name": "keyword.other",
"match": "'|$"
}
]
}
},
"scopeName": "source.opp"
}

Cloudformation template to create EMR cluster

I am trying to create EMR-5.30.1 clusters with applications such as Hadoop, livy, Spark, ZooKeeper, and Hive with the help of the CloudFormation template. But the issue is with this template is I am able the cluster with only one application from the above list of applications.
below is the CloudFormation Template
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Best Practice EMR Cluster for Spark or S3 backed Hbase",
"Parameters": {
"EMRClusterName": {
"Description": "Name of the cluster",
"Type": "String",
"Default": "emrcluster"
},
"KeyName": {
"Description": "Must be an existing Keyname",
"Type": "String",
"Default": "keyfilename"
},
"MasterInstanceType": {
"Description": "Instance type to be used for the master instance.",
"Type": "String",
"Default": "m5.xlarge"
},
"CoreInstanceType": {
"Description": "Instance type to be used for core instances.",
"Type": "String",
"Default": "m5.xlarge"
},
"NumberOfCoreInstances": {
"Description": "Must be a valid number",
"Type": "Number",
"Default": 1
},
"SubnetID": {
"Description": "Must be Valid public subnet ID",
"Default": "subnet-ee15b3e0",
"Type": "String"
},
"LogUri": {
"Description": "Must be a valid S3 URL",
"Default": "s3://aws/elasticmapreduce/",
"Type": "String"
},
"S3DataUri": {
"Description": "Must be a valid S3 bucket URL ",
"Default": "s3://aws/elasticmapreduce/",
"Type": "String"
},
"ReleaseLabel": {
"Description": "Must be a valid EMR release version",
"Default": "emr-5.30.1",
"Type": "String"
},
"Applications": {
"Description": "Please select which application will be installed on the cluster this would be either Ganglia and spark, or Ganglia and s3 backed Hbase",
"Type": "String",
"AllowedValues": [
"Spark",
"Hbase",
"Hive",
"Livy",
"ZooKeeper"
]
}
},
"Mappings": {},
"Conditions": {
"Spark": {
"Fn::Equals": [
{
"Ref": "Applications"
},
"Spark"
]
},
"Hbase": {
"Fn::Equals": [
{
"Ref": "Applications"
},
"Hbase"
]
},
"Hive": {
"Fn::Equals": [
{
"Ref": "Applications"
},
"Hive"
]
},
"Livy": {
"Fn::Equals": [
{
"Ref": "Applications"
},
"Livy"
]
},
"ZooKeeper": {
"Fn::Equals": [
{
"Ref": "Applications"
},
"ZooKeeper"
]
}
},
"Resources": {
"EMRCluster": {
"DependsOn": [
"EMRClusterServiceRole",
"EMRClusterinstanceProfileRole",
"EMRClusterinstanceProfile"
],
"Type": "AWS::EMR::Cluster",
"Properties": {
"Applications": [
{
"Name": "Ganglia"
},
{
"Fn::If": [
"Spark",
{
"Name": "Spark"
},
{
"Ref": "AWS::NoValue"
}
]
},
{
"Fn::If": [
"Hbase",
{
"Name": "Hbase"
},
{
"Ref": "AWS::NoValue"
}
]
},
{
"Fn::If": [
"Hive",
{
"Name": "Hive"
},
{
"Ref": "AWS::NoValue"
}
]
},
{
"Fn::If": [
"Livy",
{
"Name": "Livy"
},
{
"Ref": "AWS::NoValue"
}
]
},
{
"Fn::If": [
"ZooKeeper",
{
"Name": "ZooKeeper"
},
{
"Ref": "AWS::NoValue"
}
]
}
],
"Configurations": [
{
"Classification": "hbase-site",
"ConfigurationProperties": {
"hbase.rootdir":{"Ref":"S3DataUri"}
}
},
{
"Classification": "hbase",
"ConfigurationProperties": {
"hbase.emr.storageMode": "s3"
}
}
],
"Instances": {
"Ec2KeyName": {
"Ref": "KeyName"
},
"Ec2SubnetId": {
"Ref": "SubnetID"
},
"MasterInstanceGroup": {
"InstanceCount": 1,
"InstanceType": {
"Ref": "MasterInstanceType"
},
"Market": "ON_DEMAND",
"Name": "Master"
},
"CoreInstanceGroup": {
"InstanceCount": {
"Ref": "NumberOfCoreInstances"
},
"InstanceType": {
"Ref": "CoreInstanceType"
},
"Market": "ON_DEMAND",
"Name": "Core"
},
"TerminationProtected": false
},
"VisibleToAllUsers": true,
"JobFlowRole": {
"Ref": "EMRClusterinstanceProfile"
},
"ReleaseLabel": {
"Ref": "ReleaseLabel"
},
"LogUri": {
"Ref": "LogUri"
},
"Name": {
"Ref": "EMRClusterName"
},
"AutoScalingRole": "EMR_AutoScaling_DefaultRole",
"ServiceRole": {
"Ref": "EMRClusterServiceRole"
}
}
},
"EMRClusterServiceRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"elasticmapreduce.amazonaws.com"
]
},
"Action": [
"sts:AssumeRole"
]
}
]
},
"ManagedPolicyArns": [
"arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceRole"
],
"Path": "/"
}
},
"EMRClusterinstanceProfileRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"ec2.amazonaws.com"
]
},
"Action": [
"sts:AssumeRole"
]
}
]
},
"ManagedPolicyArns": [
"arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceforEC2Role"
],
"Path": "/"
}
},
"EMRClusterinstanceProfile": {
"Type": "AWS::IAM::InstanceProfile",
"Properties": {
"Path": "/",
"Roles": [
{
"Ref": "EMRClusterinstanceProfileRole"
}
]
}
}
},
"Outputs": {}
}
Also, I want to add a bootstrap script in this template as well, Can anyone please help me with the issue.
As per my knoweldge and understanding, Applications in your case should be an array like below, as mentioned in documentation
"Applications" : [ Application, ... ],
In you case, you can list applications like
"Applications" : [
{"Name" : "Spark"},
{"Name" : "Hbase"},
{"Name" : "Hive"},
{"Name" : "Livy"},
{"Name" : "Zookeeper"},
]
For more arguments other than Name to individual application dictionary , see detail here, you can pass Args, Additional_info etc
You can use following way:-
If you set "ReleaseLabel" then there is no need to mention versions of applications
"Applications": [{
"Name": "Hive"
},
{
"Name": "Presto"
},
{
"Name": "Spark"
}
]
For bootstrap:-
"BootstrapActions": [{
"Name": "setup",
"ScriptBootstrapAction": {
"Path": "s3://bucket/key/Bootstrap.sh"
}
}]
Define like this to create all applications at once.
{
"Type": "AWS::EMR::Cluster",
"Properties": {
"Applications": [
{
"Name": "Ganglia"
},
{
"Name": "Spark"
},
{
"Name": "Livy"
},
{
"Name": "ZooKeeper"
},
{
"Name": "JupyterHub"
}
]
}
}

Reading hierarchy of a JSON using value

I want to get the hierarchy of a JSON using a value. For example: In below JSON for value "Medical record number" , the desired information is "resource->identifier->type->coding->display" . IS their any inbuilt function to do so.
The one way to look for opening and ending braces to locate nodes. Any other efficient way ?
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"fullUrl": "Patient/996-756-495-101",
"resource": {
"resourceType": "Patient",
"id": "996-756-495-101",
"identifier": [
{
"type": {
"coding": [
{
"system": "http://hl7.org/fhir/v2/0203",
"code": "MR",
"display": "Medical record number"
}
]
},
"system": "https://www.lumc.nl",
"value": "996-756-495-101"
}
],
"name": [
{
"use": "usual",
"family": [
"Levin_4"
],
"given": [
"Henry_4"
]
}
],
"gender": "male",
"birthDate": "1932-09-24",
"maritalStatus": {
"coding": [
{}
]
},
"managingOrganization": {
"reference": "Organization/12"
}
},
"request": {
"method": "POST",
"url": "Patient",
"ifNoneExist": "identifier=https://www.lumc.nl|996-756-495-101"
}
},
{
"fullUrl": "FamilyMemberHistory/d42ebf70-5c89-11db-b0de-0800200c9a66",
"resource": {
"resourceType": "FamilyMemberHistory",
"id": "d42ebf70-5c89-11db-b0de-0800200c9a66",
"patient": {
"reference": "Patient/996-756-495-101"
},
"status": "Partial",
"relationship": {
"coding": [
{
"system": "http://hl7.org/fhir/ValueSet/v3-FamilyMember",
"code": "FTH",
"display": "Father"
}
],
"text": "Father"
},
"gender": "male",
"bornDate": "1912",
"deceasedBoolean": true
},
"request": {
"method": "POST",
"url": "FamilyMemberHistory"
}
},
{
"fullUrl": "FamilyMemberHistory/a13c6160-5c8b-11db-b0de-0800200c9a66",
"resource": {
"resourceType": "FamilyMemberHistory",
"id": "a13c6160-5c8b-11db-b0de-0800200c9a66",
"patient": {
"reference": "Patient/996-756-495-101"
},
"status": "Partial",
"relationship": {
"coding": [
{
"system": "http://hl7.org/fhir/ValueSet/v3-FamilyMember",
"code": "MTH",
"display": "Mother"
}
],
"text": "Mother"
},
"gender": "female",
"bornDate": "1912",
"deceasedBoolean": false
},
"request": {
"method": "POST",
"url": "FamilyMemberHistory"
}
}
]
}