Skip to content

Vs code editor templates#55

Draft
3ga01 wants to merge 3 commits intomasterfrom
vs-code-editor-templates
Draft

Vs code editor templates#55
3ga01 wants to merge 3 commits intomasterfrom
vs-code-editor-templates

Conversation

@3ga01
Copy link
Contributor

@3ga01 3ga01 commented Jul 2, 2023

No description provided.

3ga01 added 2 commits July 2, 2023 14:40
Signed-off-by: Emmanuel Mireku Omari <omariemmanuel91@gmail.com>
@steve-hickman-epistimis
Copy link
Contributor

One thing that would be helpful for the code review would be a video recording of you using these to show that they work. Also, the PR description should include a test plan (e.g. how to get the snippets properly installed, what someone should to to verify that they work, etc.)

In general, developers should always make it as easy as possible for reviewers to do the review job. Assume that a reviewer has a lot of other things to do (almost certainly true) and may not have enough context know what to look for (likely true). The more you can do to make the reviewer's job easy/ efficient, the faster the review will be completed.

Copy link
Contributor

@steve-hickman-epistimis steve-hickman-epistimis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some things to address:

  1. $0 is the final tabstop. Always insert $0 where you want the cursor to end up. Otherwise it will be placed at the end of the snippet content. It is better to be explicit about this. There are many cases where we want the cursor to be somewhere other than after all the snippet content (e.g. any container like DataModel, CDM, LDM, PDM, ...)
  2. Make sure that tab stop indentation is appropriate.
  3. Make sure to associate these snippets with just the .uddl, .face, .privacy file extensions (See https://code.visualstudio.com/docs/languages/identifiers)

It is possible to 'daisy chain' snippets together. What I mean is this: Each tab stop can trigger another snippet by simply making the snippet name one of the value choices at that point. If so, when a user picks the snippet name and hits CTRL-Space, it will automatically insert the content of that snippet so the user can keep going. The user should have the choice of picking nothing if it is possible to stop data entry at that point.
See examples here, here or here.
Note that the snippet names are different from keyword names to make sure that you can insert just the keyword if you want to. This is particularly valuable at the last tab stop but can be used anywhere. Note also that using this approach at the $0 tabstop is easy because you don't need to come back the original snippet. If you do need to come back to the original snippet it gets more complicated.

Optional content should also be addressed in the snippets. For example, a ConceptualEntity has the option of specializing another ConceptualEntity. The : should only be there if the ConceptualEntity specializes - once the user is finished with the snippet the ConceptualEntity should be syntactically correct both when it specializes and when it doesn't.

Optional elements can be addressed in several ways:

  1. Transformation: See examples here
  2. Subchoices: See links above.

Also - this should become part of a Langium/JS VS Code extension we already have once it lands. Consider looking at Langium (https://langium.org/docs/). A logical next step would be to add scoping to the VS Code support. @papiasharmin has been working on some JS/TS and is somewhat familiar with Langium as a result. She might have some perspective.

"prefix": "ccquery",
"body": [
"ccquery ${1:name} '${2:description}'{,"
,"isUnion",
Copy link
Contributor

@steve-hickman-epistimis steve-hickman-epistimis Jul 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'isUnion' is an option. It would be nice if this displays as an option rather than just getting inserted. If the other option is a single space (" ") or comment ("/..../"), it should create a drop down choice that has no semantic consequence. Or just making it a tab stop with a default value of 'isUnion' will give the user the option of deleting the value before moving on. The goal is to make sure the user knows this is an option and then picks the value desired. Otherwise, users could tab past this without realizing its impact.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll look into it

"prefix": "pcquery",
"body": [
"pquery ${1:name} '${2:description}' -> ${3:LogicalQuery}{"
,"isUnion"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See prior comment about isUnion on ConceptualCompositeQuery.

"prefix": "lcquery",
"body": [
"lquery ${2:name} '$3{description}' -> ${4:ConceptualCompositeQuery}{"
,"isUnion"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See prior comment about isUnion on ConceptualCompositeQuery.

"prefix": "lquery",
"body": [
"lquery ${2:name} '$3{description}' -> ${4:ConceptualQuery}{"
,"spec: '${5specification}'"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5specification -> 5:specification

"prefix": "dm",
"body": [
"dm: ${1:name} '${2:description}' {",
"${3:}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to do proper indentation. For example, line 6 should be indented 1 tab (2 spaces) compared to line 5 above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll work on it

"prefix": "cdm",
"body": [
"cdm ${1:name} '${2:description}' {",
"\t$3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you indent correctly.

"ConceptualComposition": {
"prefix": "composition",
"body": [
"${1:type} ${2:rolename}[ ${3:lowerBound} : ${4:upperBound}]","'${5:description}' : ${ConceptualCharacteristic};\n"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${ConceptualCharacteristic} -> ${6:ConceptualCharacteristic}

"prefix": "dm",
"body": [
"dm: ${1:name} '${2:description}' {",
"${3:}",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kindly correct me, if I am wrong, don't we need to add the attributes conceptualDataModel, logicalDataModel and PlatfromDataModel inside ${3:}?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be added as a list with the option to select one

"ConceptualQueryComposition":{
"prefix": "cqcomp",
"body": [
"${1:ConceptualView} ${2:rolename};\n"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why ${1:ConceptualView} instead of ${1:type}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConceptualView to alert the user that it takes a ConceptualView type

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested these with a version of VS code that has the UDDL / FACE VS Code extension (.vsix) installed? (Available here ). If not, do so - it may be that the Java content assist will kick in and provide the list of ConceptualViews available to cross reference.

"};\n"
],
"description": "A conceptual Participant is the mechanism that allows a conceptual Association to be constructed between two or more conceptual Entities."
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConceptualParticipantPathNode and ConceptualCharacteristicPathNode are not declared.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be some elements where there is no advantage to having a snippet. These two are examples of that. The syntax for these is just a single character followed by a cross reference. Snippets have value when there are multiple fields to fill in.

],
"description": "A StandardMeasurementSystem is used to represent an open, referenced measurement system without requiring the detailed modeling of the measurement system. The reference should be unambiguous and allows for full comprehension of the underlying measurement system."
},
"landmark":{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

landmark -> LogicalLandmark

,"}\n"
],
"description": " A MeasurementSystemAxis establishes additional properties for a CoordinateSystemAxis including units and value types. "
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is LogicalReferencePoint not declared intentionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no!!
missed it.
It will be added

,"};\n"
],
"description": " A MeasurementAxis optionally establishes constraints for a MeasurementSystemAxis and may optionally override its default units and value types. "
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is LogicalMeasurementAttribute not declared intentionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as LogicalReferencePoint

"ldouble ${1:name} '${2:description}' -> ${3:LogicalAbstractMeasurement};\n"
],
"description": " A LongDouble is a real data type that represents an IEEE extended double precision floating- point number (having a signed fraction of at least 64 bits and an exponent of at least 15 bits) "
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PlatformFixed is not declared

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as LogicalReferencePoint

"prefix": "cassoc",
"scope": "com.epistimis.uddl.Uddl.ConceptualBasisEntity",
"body": [
"cassoc ${1:name} '${2:description}' : ${3:ConceptualEntity} {",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like we are mentioning all key of each property, like name, description, lowerbound, upperbound etc, then why it is ${3:ConceptualEntity} and not ${3:specializes}.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as ConceptualView

"${1:type} ${2:rolename}[${3:lowerBound} : ${4:upperBound}]",
"'${5:description}' : ${6:ConceptualCharacteristic}{",
"src: [${7:sourceLowerBound} : ${8:sourceUpperBound}] ",
"path: ${8:ConceptualPathNode}",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path: ${8:ConceptualPathNode}" -> path: ${9:ConceptualPathNode}",

"description": "A CoordinateSystem is a system which uses one or more coordinates to uniquely determine the position of a point in an N-dimensional space. The coordinate system is comprised of multiple CoordinateSystemAxis which completely span the space. Coordinates are quantified relative to the CoordinateSystemAxis. It is not required that the dimensions be ordered or continuous."
},
"LogicalCoordinateSystemAxis":{
"prefix": "coordAxis",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why prefix is "coordAxis" not "csa"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be csa

"LogicalValueTypeUnit":{
"prefix": "vtu",
"body": [
"vtu ${1:valueType} ${2:unit}{"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name and description attribute is missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They will be added

,"'${4:description}';\n"
],
"description": " A FixedLengthStringConstraint specifies a defined set of meaningful values for a String of a specific fixed length. The “length” attribute defines the fixed length, an integer value greater than 0."
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LogicalEnumerationConstraint is not defined.

"LogicalQuery":{
"prefix": "lquery",
"body": [
"lquery ${2:name} '$3{description}' -> ${4:ConceptualQuery}{"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$3{description} or ${3:description}

"PlatformCharArray":{
"prefix": "pcarray",
"body": [
"char[${4:maxLength}] ${1:name} '${2:description}' -> ${3:LogicalAbstractMeasurement};\n"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[${4:maxLength}] or [${4:Length}]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be length

"float ${1:name} '${2:description}' -> ${3:LogicalAbstractMeasurement};\n"
],
"description": "A Float is a real data type that represents an IEEE single precision floating-point number. "
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

platformFixed is not defined.

"PlatformStructMember":{
"prefix": "pstructmember",
"body": [
" ${1:PlatformDataType} '${2:rolename}'(${4:precision}) -> ${3:LogicalMeasurementAttribute};\n"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{1:PlatformDataType} or {1:type}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be PlatfomDataType

"prefix": "pquery",
"body": [
"pquery ${1:name} '${2:description}' -> ${3:LogicalQuery}{"
,"spec: '${5:specification}'"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'${5:specification}' -> '${4:specification}'

"ConceptualDomain": {
"prefix": "domain",
"body": [
"domain ${1:name} '${2:description}';\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be consistent about spacing: Compare line 40 to line 47. The ; at the end of line 40 has a preceding

"};\n"
],
"description": "A conceptual Participant is the mechanism that allows a conceptual Association to be constructed between two or more conceptual Entities."
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be some elements where there is no advantage to having a snippet. These two are examples of that. The syntax for these is just a single character followed by a cross reference. Snippets have value when there are multiple fields to fill in.

"ConceptualQueryComposition":{
"prefix": "cqcomp",
"body": [
"${1:ConceptualView} ${2:rolename};\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested these with a version of VS code that has the UDDL / FACE VS Code extension (.vsix) installed? (Available here ). If not, do so - it may be that the Java content assist will kick in and provide the list of ConceptualViews available to cross reference.

@steve-hickman-epistimis steve-hickman-epistimis marked this pull request as draft October 22, 2023 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants