stevedlawrence commented on code in PR #117: URL: https://github.com/apache/daffodil-vscode/pull/117#discussion_r889040523
########## INTELLISENSE.md: ########## @@ -0,0 +1,75 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +# Apache Daffodil VS Code Extension Intellisense README + +The "Apache Daffodil VS Code Extension" extension provides auto completion for Data Format Description Language (DFDL) schemas. + +## Set the editor to dfdl mode + + + +## Features + +Auto suggest is triggered using control space or typing the beginning characters of an item. + + +Typing one or more unique characters will further limit the results. + + +Add the schema block + + +Completing a DFDL Format Block. + + +The '>' or '/' characters are used to close and XML tag. +Typing the initial characters and one or more unique characters will further limit the results. +Use the Tab to select an item from the drop down and to exit double quotes + + +Creating self define dfdl:complextypes and dfdl:simpleTypes. + + +The tab key can be used to complete an auto-complete item within an XML tag. +After auto complete is triggered, typing the initial character or characters will limit the suggestion results. +Inside an XML tag a space or carriage return will trigger a list of context sensitive attribute suggestions. + + +Using self defined types. + + +Using xs:choice and dfdl:Discriminator. + + +Using hidden references and dfdl:inputValueCalc + + +Using dfdl:OutputValueCalc + + +More examples of using user defined types + + +Using the dfdl:Length attribute with XPath values + + +Using dfdl:assert blocks + + +Miscellaneous examples + Review Comment: We shouldn't display images that we don't control. I also wish this was more laid out more like the [VSCode intellisense page](https://code.visualstudio.com/docs/editor/intellisense). An image or two are fine for examples, but a detailed list of what completions are actually supported I think would be more useful. I find watching a bunch of gifs difficult to get an idea of what features are supported. GIFS's are also hard to keep updated as new features are added. I think this could use more text and less images. ########## build/bin.LICENSE: ########## @@ -1597,3 +1597,143 @@ licenses. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +- extension/dist/ext/extension.js + This product bundles 'moo' from the above files. + These files are available under the BSD 3-Clause License + BSD 3-Clause License + + Copyright (c) 2017, Tim Radvan (tjvr) + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +- com.google.protobuf.protobuf-java-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip + This product bundles "Protocol Buffers" from the above files. + These files are are avaiable under the License: Review Comment: Can you mention the actual liceense, I think this is 3-Clause BSD ########## build.sbt: ########## @@ -50,8 +50,10 @@ lazy val commonSettings = { lazy val ratSettings = Seq( ratLicenses := Seq( - ("MIT ", Rat.MIT_LICENSE_NAME, Rat.MIT_LICENSE_TEXT_MICROSOFT), - ("CC0 ", Rat.CREATIVE_COMMONS_LICENSE_NAME, Rat.CREATIVE_COMMONS_LICENSE_TEXT) + ("MIT ", Rat.MIT_LICENSE_NAME, Rat.MIT_LICENSE_TEXT), + ("MIT_VS ", Rat.MIT_LICENSE_NAME, Rat.MIT_VS_LICENSE_TEXT), // Licesne for code used from Vincas Stonys + ("MIT_DELTA ", Rat.MIT_LICENSE_NAME, Rat.MIT_DELTA_LICENSE_TEXT), // Licesne for code used from DeltaXML + ("CC0 ", Rat.CREATIVE_COMMONS_LICENSE_NAME, Rat.CREATIVE_COMMONS_LICENSE_TEXT) Review Comment: The first part of this tuple must be 5 characters, and should be short representation of the license. The license is not MIT_VS or MIT_DELTA, they're are just MIT. These are all MIT licenses just with slight copyright differences. That said, all the Vincas and DeltaXML code was removed and we now just depend on their extensions right? So this can just be reverted? ########## language/syntax.json: ########## @@ -0,0 +1,31 @@ +{ + "name": "dfdl", + "patterns": [ + { + "include": "#keywords" + }, + { + "include": "#strings" + } + ], + "repository": { + "keywords": { + "patterns": [{ + "name": "keyword.control.dfdl", + "match": "\\b(if|while|for|return)\\b" Review Comment: These aren't keywords in DFDL. Was this file copied and modified from somewhere else? ########## language/syntax.json: ########## @@ -0,0 +1,31 @@ +{ + "name": "dfdl", + "patterns": [ + { + "include": "#keywords" + }, + { + "include": "#strings" + } + ], + "repository": { + "keywords": { + "patterns": [{ + "name": "keyword.control.dfdl", + "match": "\\b(if|while|for|return)\\b" + }] + }, + "strings": { + "name": "string.quoted.double.dfdl", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "name": "constant.character.escape.dfdl", + "match": "\\\\." Review Comment: This is not an escape character for DFDL. ########## package.json: ########## @@ -392,6 +475,99 @@ "default": "" } } + }, + { + "type": "object", + "title": "vscode-dfdl", + "properties": { + "vscode-dfdl.enabled": { + "type": "boolean", + "default": true, + "description": "Enable syntax highlighting and status bar", + "scope": "resource" + }, + "vscode-dfdl.showPath": { + "type": "boolean", + "default": true, + "description": "Show tag path in status bar", + "scope": "resource" + }, + "vscode-dfdl.showRuler": { + "type": "boolean", + "default": true, + "description": "Show highlighted tag pair in ruler section", + "scope": "resource" + }, + "vscode-dfdl.highlightSelfClosing": { + "type": "boolean", + "default": false, + "description": "Highlight self-closing tags", + "scope": "resource" + }, + "vscode-dfdl.highlightFromContent": { + "type": "boolean", + "default": true, + "description": "Highlight matching tag from inside tag content", + "scope": "resource" + }, + "vscode-dfdl.highlightFromName": { + "type": "boolean", + "default": true, + "description": "Highlight matching tag from the tag name", + "scope": "resource" + }, + "vscode-dfdl.highlightFromAttributes": { + "type": "boolean", + "default": true, + "description": "Highlight matching tag from the tag attributes", + "scope": "resource" + }, + "vscode-dfdl.noDefaultEmptyElements": { + "type": "boolean", + "default": false, + "description": "Don't use default HTML empty elements", + "scope": "resource" + }, + "vscode-dfdl.customEmptyElements": { + "type": "array", + "default": null, + "description": "Custom empty elements in addition to the default HTML empty elements", + "scope": "resource" + }, + "vscode-dfdl.styles": { + "opening": { + "left": { + "underline": "yellow" + }, + "right": { + "surround": "#155FFA" + }, + "name": { + "highlight": "rgba(180, 20, 80, 0.3)" + } + }, + "closing": { + "full": { + "custom": { + "dark": { + "borderWidth": "0 0 1px 0", + "borderColor": "white", + "borderStyle": "solid", + "borderRadius": "4px", + "right": "10px" + }, + "light": { + "borderWidth": "0 0 1px 0", + "borderColor": "brown", + "borderStyle": "solid", + "borderRadius": "4px", + "right": "10px" + } + } + } + } + } + } Review Comment: This highlight stuff also came from one of the extensions right? Can this be reverted? ########## project/Rat.scala: ########## @@ -22,8 +22,13 @@ object Rat { lazy val excludes = Seq( // git files file(".git"), - // json files -- these ones do not support comments - file("snippets/dfdl.json"), + /** + * Can't add license headers in JSON files. + * Adding a license attribute breaks things in some of these fiels as well. Review Comment: Just to confirm, were these written from scratch or copied from something? There are some things that don't apply to DFDL that make me think it was copied. If copied, where from and what was the license? ########## src/language/providers/closeElement.ts: ########## @@ -0,0 +1,150 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as vscode from 'vscode' +import { nearestOpen } from './utils' + +export function getCloseElementProvider() { + return vscode.languages.registerCompletionItemProvider( + 'dfdl', + { + provideCompletionItems( + document: vscode.TextDocument, + position: vscode.Position + ) { + var backpos = position.with(position.line, position.character - 1) + const nearestOpenItem = nearestOpen(document, position) + const wholeLine = document + .lineAt(position) + .text.substr(0, position.character) + + if ( + wholeLine.endsWith('>') && + (wholeLine.includes('xs:element') || + nearestOpenItem.includes('element') || + wholeLine.includes('xs:group') || + nearestOpenItem.includes('group') || + wholeLine.includes('xs:sequence') || + nearestOpenItem.includes('sequence') || + wholeLine.includes('xs:simpleType') || + nearestOpenItem.includes('simpleType') || + wholeLine.includes('dfdl:defineVariable') || + nearestOpenItem.includes('Variable')) + ) { + var range = new vscode.Range(backpos, position) + vscode.window.activeTextEditor?.edit((editBuilder) => { + editBuilder.replace(range, '') + }) + if ( + wholeLine.endsWith('>') && + (wholeLine.includes('xs:element ref') || + wholeLine.includes('xs:group ref')) + ) { + vscode.window.activeTextEditor?.insertSnippet( + new vscode.SnippetString(' />\n$0'), + backpos + ) + } else if ( + wholeLine.endsWith('>') && + (wholeLine.includes('xs:element') || + nearestOpenItem.includes('element')) + ) { + vscode.window.activeTextEditor?.insertSnippet( + new vscode.SnippetString('>\n\t$0\n</xs:element>'), + backpos + ) + } else if ( + wholeLine.endsWith('>') && + (wholeLine.includes('xs:group') || + nearestOpenItem.includes('group')) + ) { + vscode.window.activeTextEditor?.insertSnippet( + new vscode.SnippetString('>\n\t$0\n</xs:group>'), + backpos + ) + } else if ( + (wholeLine.endsWith('>') && wholeLine.includes('xs:sequence')) || + nearestOpenItem.includes('sequence') + ) { + vscode.window.activeTextEditor?.insertSnippet( + new vscode.SnippetString('>\n\t$0\n</xs:sequence>'), + backpos + ) + } else if ( + (wholeLine.endsWith('>') && wholeLine.includes('xs:simpleType')) || + nearestOpenItem.includes('simpleType') + ) { + vscode.window.activeTextEditor?.insertSnippet( + new vscode.SnippetString('>\n\t$0\n</xs:simpleType>'), + backpos + ) + } else if ( + (wholeLine.endsWith('>') && + wholeLine.includes('dfdl:defineVariable')) || + nearestOpenItem.includes('defineVariable') + ) { + var startPos = document.lineAt(position).text.indexOf('<', 0) + var range = new vscode.Range(backpos, position) + vscode.window.activeTextEditor?.edit((editBuilder) => { + editBuilder.replace(range, '') + }) + vscode.window.activeTextEditor?.insertSnippet( + new vscode.SnippetString('>\n</dfdl:defineVariable>\n'), + backpos + ) + var backpos2 = position.with(position.line + 2, startPos - 2) + vscode.window.activeTextEditor?.insertSnippet( + new vscode.SnippetString('</xs:appinfo>\n'), + backpos2 + ) + var backpos3 = position.with(position.line + 3, startPos - 4) + vscode.window.activeTextEditor?.insertSnippet( + new vscode.SnippetString('</xs:annotation>$0'), + backpos3 + ) + } else if ( + (wholeLine.endsWith('>') && + wholeLine.includes('dfdl:setVariable')) || + nearestOpenItem.includes('setVariable') + ) { + var startPos = document.lineAt(position).text.indexOf('<', 0) + var range = new vscode.Range(backpos, position) + vscode.window.activeTextEditor?.edit((editBuilder) => { + editBuilder.replace(range, '') + }) + vscode.window.activeTextEditor?.insertSnippet( + new vscode.SnippetString('>\n</dfdl:setVariable>\n'), + backpos + ) + var backpos2 = position.with(position.line + 2, startPos - 2) + vscode.window.activeTextEditor?.insertSnippet( + new vscode.SnippetString('</xs:appinfo>\n'), + backpos2 + ) + var backpos3 = position.with(position.line + 3, startPos - 4) + vscode.window.activeTextEditor?.insertSnippet( + new vscode.SnippetString('</xs:annotation>$0'), + backpos3 Review Comment: A lot of duplication here. Seems like this could be cleaned up. Fine for now, but hope this is fixed in the future. ########## src/language/providers/attributeCompletion.ts: ########## @@ -0,0 +1,275 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as vscode from 'vscode' + +import { + nearestOpen, + checkBraceOpen, + lineCount, + checkLastItemOpen, + checkSequenceOpen, + checkElementOpen, + checkSimpleTypeOpen, +} from './utils' + +import { attributeCompletion } from './intellisense/attributeItems' + +function getCompletionItems( + itemsToUse: string[], + preVal: string = '', + additionalItems: string = '' +) { + let compItems: vscode.CompletionItem[] = [] + + attributeCompletion(preVal, additionalItems).items.forEach((e) => { + if (itemsToUse.includes(e.item)) { + const completionItem = new vscode.CompletionItem(e.item) + completionItem.insertText = new vscode.SnippetString(e.snippetString) + + if (e.markdownString) { + completionItem.documentation = new vscode.MarkdownString( + e.markdownString + ) + } + compItems.push(completionItem) + } + }) + + return compItems +} + +export function getAttributeCompletionProvider() { + return vscode.languages.registerCompletionItemProvider( + { language: 'dfdl' }, + { + provideCompletionItems( + document: vscode.TextDocument, + position: vscode.Position + ) { + const wholeLine = document + .lineAt(position) + .text.substr(0, position.character) + var nearestOpenItem = nearestOpen(document, position) + + if ( + !checkBraceOpen(document, position) && + !wholeLine.includes('assert') && + !nearestOpenItem.includes('none') + ) { + if (nearestOpenItem.includes('element')) { + var preVal = '' + if (!wholeLine.includes('xs:element')) { + if (lineCount(document, position) === 1) { + preVal = '\t' + } else { + preVal = '' + } + } + var additionalItems = getDefinedTypes(document) + + if ( + checkLastItemOpen(document, position) && + (wholeLine.includes('<xs:element name="') || + wholeLine.includes('<xs:element ref="') || + checkElementOpen(document, position)) + ) { + return getCompletionItems( + [ + 'dfdl:defineFormat', + 'dfdl:defineEscapeScheme', + 'type=', + 'minOccurs=', + 'maxOccurs=', + 'dfdl:occursCount=', + 'dfdl:byteOrder=', + 'dfdl:occursCountKind=', + 'dfdl:length=', + 'dfdl:lengthKind=', + 'dfdl:encoding=', + 'dfdl:alignment=', + 'dfdl:lengthUnits=', + 'dfdl:lengthPattern=', + 'dfdl:inputValueCalc=', + 'dfdl:outputValueCalc=', + 'dfdl:alignmentUnits=', + 'dfdl:terminator=', + 'dfdl:outputNewLine=', + 'dfdl:choiceBranchKey=', + 'dfdl:representation', + ], + preVal, + additionalItems + ) + } + } + + if (nearestOpenItem.includes('sequence')) { + var preVal = '' + if (!wholeLine.includes('xs:sequence')) { + if (lineCount(document, position) === 1) { + preVal = '\t' + } else { + preVal = '' + } + } + + if ( + checkLastItemOpen(document, position) && + (wholeLine.includes('<xs:sequence') || + checkSequenceOpen(document, position)) + ) { + return getCompletionItems( + [ + 'dfdl:hiddenGroupRef=', + 'dfdl:sequenceKind=', + 'dfdl:separator=', + 'dfdl:separatorPosition=', + 'dfdl:separatorSuppressionPolicy', + ], + preVal + ) + } + } + + if (wholeLine.includes('choice')) { + if (!wholeLine.includes('>')) { + return getCompletionItems([ + 'dfdl:choiceLengthKind=', + 'dfdl:choiceLength=', + 'dfdl:intiatedContent=', + 'dfdl:choiceDispatchKey=', + 'dfdl:choiceBranchKey=', + ]) + } + } + + if ( + wholeLine.includes('simpleType') || + checkSimpleTypeOpen(document, position) + ) { + if (!wholeLine.includes('>')) { + return getCompletionItems([ + 'dfdl:length=', + 'dfdl:lengthKind=', + 'dfdl:simpleType', + 'dfdl:simpleType', + 'xs:restriction', + ]) + } + } + + if (wholeLine.includes('defineVariable')) { + var preVal = '' + if (!wholeLine.includes('dfdl:defineVariable')) { + if (lineCount(document, position) === 1) { + preVal = '\t' + } else { + preVal = '' + } + } + var additionalItems = getDefinedTypes(document) + + var xmlItems = [ + { + item: 'type=', + snippetString: + preVal + + 'type="${1|xs:string,xs:decimal,xs:float,xs:double,xs:integer,xs:nonNegativeInteger,xs:int,xs:unsignedInt,xs:short,xs:unsignedShort,xs:long,xs:unsignedLong,xs:byte,xs:unsignedByte,xs:hexBinary,xs:boolean' + Review Comment: One thing to consider is this "xs" prefix isn't mandatory and some schemas use different prefixes (usually "xsd" or no prefix). Ideally this would look at the in scope namespaces an find the prefix associated with the schema prefix. Again, I won't block the merge for that, but hope those kinds of features are added in the future. ########## src/language/providers/intellisense/attributeItems.ts: ########## @@ -0,0 +1,212 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const attributeCompletion = (preVal, additionalItems) => { + return { + items: [ + { + item: 'dfdl:defineFormat', + snippetString: + preVal + + '<dfdl:defineFormat name="$1" >\n\t$2\n</dfdl:defineFormat>\n$0', + markdownString: 'dfdl format name and configuration', + }, + { + item: 'dfdl:defineEscapeScheme', + snippetString: + preVal + + '<dfdl:defineEscapeScheme name=$1 >\n\t$0,/dfdl:defineEscapeScheme>\n', + markdownString: 'dfdl escape character definition', + }, + { + item: 'type=', + snippetString: + preVal + + 'type="${1|xs:string,xs:decimal,xs:float,xs:double,xs:integer,xs:nonNegativeInteger,xs:int,xs:unsignedInt,xs:short,xs:unsignedShort,xs:long,xs:unsignedLong,xs:byte,xs:unsignedByte,xs:hexBinary,xs:boolean' + Review Comment: This long string was somewhere else above, is it needed in both places? Ideally it would only be here. ########## build/bin.NOTICE: ########## @@ -150,3 +150,196 @@ The following NOTICE information applies to binary components distributed with t Portions of this code are derived from classes placed in the public domain by Arbortext on 10 Apr 2000. See: http://www.arbortext.com/customer_support/updates_and_technical_notes/catalogs/docs/README.htm + +- extension/dist/ext/extension.js + Copyright 2014 gRPC authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +- com.typesafe.akka.akka-http-core_<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip +- com.typesafe.akka.akka-http-_<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip +- com.typesafe.akka.akka-http-parsing_<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip + Akka HTTP + ========= + + The source code is Akka HTTP is hosted at https://github.com/akka/akka-http. + + This software is licensed under the Apache 2 license, quoted below. + + Copyright 2009-2021 Lightbend Inc. [https://www.lightbend.com] + + Licensed under the Apache License, Version 2.0 (the "License"); you may not + use this file except in compliance with the License. You may obtain a copy of + the License at + + [http://www.apache.org/licenses/LICENSE-2.0] + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + License for the specific language governing permissions and limitations under + the License. + + Also, please refer to each `licenses/LICENSE.<component>.txt` file for the license + terms of the components that this product depends on. + + ------------------------------------------------------------------------------- + This product contains a modified version of 'HPACK', a Java implementation of + the HTTP/2 HPACK algorithm written by Twitter. It can be obtained at: + + * LICENSE: + * licenses/LICENSE.hpack.txt (Apache License 2.0) + * HOMEPAGE: + * https://github.com/twitter/hpack + +- io.grpc.grpc-api-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip +- io.grpc.grpc-context-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip +- io.grpc.grpc-core-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip +- io.grpc.grpc-netty-shaded-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip +- io.grpc.grpc-stub-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip + Copyright 2014 The gRPC Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + ----------------------------------------------------------------------- + + This product contains a modified portion of 'OkHttp', an open source + HTTP & SPDY client for Android and Java applications, which can be obtained + at: + + * LICENSE: + * okhttp/third_party/okhttp/LICENSE (Apache License 2.0) + * HOMEPAGE: + * https://github.com/square/okhttp + * LOCATION_IN_GRPC: + * okhttp/third_party/okhttp + + This product contains a modified portion of 'Envoy', an open source + cloud-native high-performance edge/middle/service proxy, which can be + obtained at: + + * LICENSE: + * xds/third_party/envoy/LICENSE (Apache License 2.0) + * NOTICE: + * xds/third_party/envoy/NOTICE + * HOMEPAGE: + * https://www.envoyproxy.io + * LOCATION_IN_GRPC: + * xds/third_party/envoy + + This product contains a modified portion of 'protoc-gen-validate (PGV)', + an open source protoc plugin to generate polyglot message validators, + which can be obtained at: + + * LICENSE: + * xds/third_party/protoc-gen-validate/LICENSE (Apache License 2.0) + * NOTICE: + * xds/third_party/protoc-gen-validate/NOTICE + * HOMEPAGE: + * https://github.com/envoyproxy/protoc-gen-validate + * LOCATION_IN_GRPC: + * xds/third_party/protoc-gen-validate + + This product contains a modified portion of 'udpa', + an open source universal data plane API, which can be obtained at: + + * LICENSE: + * xds/third_party/udpa/LICENSE (Apache License 2.0) + * HOMEPAGE: + * https://github.com/cncf/udpa + * LOCATION_IN_GRPC: + * xds/third_party/udpa + +- io.perfmark.perfmark-api-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip + Copyright 2019 Google LLC + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + ----------------------------------------------------------------------- + + This product contains a modified portion of 'Catapult', an open source + Trace Event viewer for Chome, Linux, and Android applications, which can + be obtained at: + + * LICENSE: + * traceviewer/src/main/resources/io/perfmark/traceviewer/third_party/catapult/LICENSE (New BSD License) + * HOMEPAGE: + * https://github.com/catapult-project/catapult + + This product contains a modified portion of 'Polymer', a library for Web + Components, which can be obtained at: + * LICENSE: + * traceviewer/src/main/resources/io/perfmark/traceviewer/third_party/polymer/LICENSE (New BSD License) + * HOMEPAGE: + * https://github.com/Polymer/polymer Review Comment: Ugh, there are some really bad habits. I don't know where people got the idea to put all this stuff in the NOTICE file, but it's very wrong and makes this all very bloated. ########## package.json: ########## @@ -23,26 +23,37 @@ "url": "https://github.com/apache/daffodil-vscode/issues" }, "scripts": { + "omega-edit-download": "tsc -p ./ && node -e 'require(\"./out/omega_edit/download.js\").downloadServer()'", Review Comment: There was mention of hash verification? Does any one have any thoughts on if that's needed? The yarn.lock file essentially does that for npm dependencies. I don't think we do if for scala dependencies, but I'm not sure if maven deps can change once uploaded. I imagine if we are going to download files from github that we do not control, that we may want to have some kind of verification that it hasn't changed since we last downloaded it. ########## package.json: ########## @@ -186,18 +228,59 @@ "category": "Daffodil Debug", "enablement": "!inDebugMode", "icon": "$(debug-configure)" + }, + { + "command": "toggle.experimental", + "title": "Enable Experimental Features", + "category": "Daffodil Debug" + }, + { + "command": "highlight-matching-tag.jumpToMatchingTag", + "title": "Jump to matching tag", + "category": "Highlight Matching Tag" + }, + { + "command": "highlight-matching-tag.selectPairContents", + "title": "Select contents of matching tag pair", + "category": "Highlight Matching Tag" + }, Review Comment: Aren't these highlight matching tag things from one of the extensions we no longer include and just depend on? Can they be removed now? ########## build/bin.LICENSE: ########## @@ -1597,3 +1597,143 @@ licenses. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +- extension/dist/ext/extension.js + This product bundles 'moo' from the above files. + These files are available under the BSD 3-Clause License + BSD 3-Clause License + + Copyright (c) 2017, Tim Radvan (tjvr) + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +- com.google.protobuf.protobuf-java-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip + This product bundles "Protocol Buffers" from the above files. + These files are are avaiable under the License: + Copyright 2008 Google Inc. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + Code generated by the Protocol Buffer compiler is owned by the owner + of the input file used when generating it. This code is not + standalone and requires a support library to be linked with it. This + support library is itself covered by the above license. + +- org.codehaus.mojo.animal-sniffer-annotations-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip + This product bundles "MojoHaus AnimalSniffer" from the above files. + These files are are avaiable under the MIT License: + The MIT License + + Copyright (c) 2009 codehaus.org. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +- org.ow2.asm.asm-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip +- org.ow2.asm.asm-analysis-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip +- org.ow2.asm.asm-commons-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip +- org.ow2.asm.asm-tree-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip +- org.ow2.asm.asm-util-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip + This product bundle "ow2-asm" from the above files. Review Comment: Same here, please mention the license name. Makes it easier to quickly scan and see what all the license are. ########## package.json: ########## @@ -23,26 +23,37 @@ "url": "https://github.com/apache/daffodil-vscode/issues" }, "scripts": { + "omega-edit-download": "tsc -p ./ && node -e 'require(\"./out/omega_edit/download.js\").downloadServer()'", "vscode:prepublish": "yarn run package-ext", "precompile": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts", - "compile": "tsc -p ./", + "compile": "tsc -p ./ && node out/omega_edit/download.js", "lint": "yarn run prettier src -c", - "watch": "webpack --watch --devtool nosources-source-map --info-verbosity verbose --config ./build/extension.webpack.config.js", + "watch": "yarn omega-edit-download && webpack --watch --devtool nosources-source-map --config ./build/extension.webpack.config.js", "watch2": "tsc -watch -p ./", "package": "vsce package", "publish": "vsce publish", "package-ext": "webpack --mode production --config ./build/extension.webpack.config.js", "pretest": "yarn run compile", "test": "node node_modules/mocha/bin/_mocha -u tdd --timeout 999999 --colors ./out/tests", "sbt": "sbt universal:packageBin", - "pre-build": "mv LICENSE tmp.LICENSE && mv NOTICE tmp.NOTICE && cp build/bin.LICENSE LICENSE && cp build/bin.NOTICE NOTICE", + "pre-build": "run-script-os", + "pre-build:default": "mv LICENSE tmp.LICENSE && mv NOTICE tmp.NOTICE && cp build/bin.LICENSE LICENSE && cp build/bin.NOTICE NOTICE", + "pre-build:windows": "move LICENSE tmp.LICENSE && move NOTICE tmp.NOTICE && copy build/bin.LICENSE LICENSE && copy build/bin.NOTICE NOTICE", "build": "yarn pre-build && yarn sbt && yarn install && yarn compile && yarn package && yarn post-build", - "post-build": "rm -rf NOTICE LICENSE && mv tmp.LICENSE LICENSE && mv tmp.NOTICE NOTICE" + "post-build": "run-script-os", + "post-build:default": "rm NOTICE && rm LICENSE && mv tmp.LICENSE LICENSE && mv tmp.NOTICE NOTICE", + "post-build:windows": "del /q NOTICE && del /q LICENSE && move tmp.LICENSE LICENSE && move tmp.NOTICE NOTICE" }, "dependencies": { + "@grpc/grpc-js": "1.5.4", + "@types/moo": "^0.5.5", "await-notify": "1.0.1", "child_process": "^1.0.2", + "google-protobuf": "^3.19.4", "hexy": "^0.3.1", + "moo": "^0.5.1", + "omega-edit": "0.9.8", + "run-script-os": "^1.1.6", Review Comment: We shouldn't use ^, we should use specific versions. ########## build/bin.NOTICE: ########## @@ -150,3 +150,196 @@ The following NOTICE information applies to binary components distributed with t Portions of this code are derived from classes placed in the public domain by Arbortext on 10 Apr 2000. See: http://www.arbortext.com/customer_support/updates_and_technical_notes/catalogs/docs/README.htm + +- extension/dist/ext/extension.js + Copyright 2014 gRPC authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +- com.typesafe.akka.akka-http-core_<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip +- com.typesafe.akka.akka-http-_<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip +- com.typesafe.akka.akka-http-parsing_<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip + Akka HTTP + ========= + + The source code is Akka HTTP is hosted at https://github.com/akka/akka-http. + + This software is licensed under the Apache 2 license, quoted below. + + Copyright 2009-2021 Lightbend Inc. [https://www.lightbend.com] + + Licensed under the Apache License, Version 2.0 (the "License"); you may not + use this file except in compliance with the License. You may obtain a copy of + the License at + + [http://www.apache.org/licenses/LICENSE-2.0] + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + License for the specific language governing permissions and limitations under + the License. + + Also, please refer to each `licenses/LICENSE.<component>.txt` file for the license + terms of the components that this product depends on. + + ------------------------------------------------------------------------------- + This product contains a modified version of 'HPACK', a Java implementation of + the HTTP/2 HPACK algorithm written by Twitter. It can be obtained at: + + * LICENSE: + * licenses/LICENSE.hpack.txt (Apache License 2.0) + * HOMEPAGE: + * https://github.com/twitter/hpack + +- io.grpc.grpc-api-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip +- io.grpc.grpc-context-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip +- io.grpc.grpc-core-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip +- io.grpc.grpc-netty-shaded-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip +- io.grpc.grpc-stub-<VERSION>.jar in omega-edit-scala-server-<VERSION>.zip Review Comment: Can this be combined with the grpc mentioned for extensions.js above? ########## src/language/dfdl.ts: ########## @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as vscode from 'vscode' +import * as fs from 'fs' +import { getElementCompletionProvider } from './providers/elementCompletion' +import { getAttributeCompletionProvider } from './providers/attributeCompletion' +import { getCloseElementProvider } from './providers/closeElement' +import { getCloseElementSlashProvider } from './providers/closeElementSlash' +import { getEndSingleBraceProvider } from './providers/endSingleBrace' + +export function activate(context: vscode.ExtensionContext) { + let dfdlFormat = fs + .readFileSync( + context.asAbsolutePath( + './src/language/providers/intellisense/DFDLGeneralFormat.dfdl.xsdf' + ) + ) + .toLocaleString() + + context.subscriptions.push( + getElementCompletionProvider(dfdlFormat), Review Comment: There are no elements defined in DFDLGeneralFormat.dfdl.xsd--the only thing define in ther are defineFormats. ########## src/language/dfdl.ts: ########## @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as vscode from 'vscode' +import * as fs from 'fs' +import { getElementCompletionProvider } from './providers/elementCompletion' +import { getAttributeCompletionProvider } from './providers/attributeCompletion' +import { getCloseElementProvider } from './providers/closeElement' +import { getCloseElementSlashProvider } from './providers/closeElementSlash' +import { getEndSingleBraceProvider } from './providers/endSingleBrace' + +export function activate(context: vscode.ExtensionContext) { + let dfdlFormat = fs + .readFileSync( + context.asAbsolutePath( + './src/language/providers/intellisense/DFDLGeneralFormat.dfdl.xsdf' Review Comment: Can this just read the file from the daffodil-lib jar? That way if we ever update Daffodil with a different version of the file then this updates automatically, and we don't have to keep this file in sync with Daffodil? ########## language/syntaxes/dfdl.tmLanguage.json: ########## @@ -0,0 +1,387 @@ +{ + "information_for_contributors": [ + "This file has been converted from https://github.com/atom/language-xml/blob/master/grammars/xml.cson", + "If you want to provide a fix or improvement, please create a pull request against the original repository.", + "Once accepted there, we are happy to receive an update request." + ], + "version": "https://github.com/atom/language-xml/commit/7bc75dfe779ad5b35d9bf4013d9181864358cb49", + "name": "dfdl", + "scopeName": "text.xml.dfdl.xsd", + "patterns": [ + { + "begin": "(<\\?)\\s*([-_a-zA-Z0-9]+)", + "captures": { + "1": { + "name": "punctuation.definition.tag.xml" + }, + "2": { + "name": "entity.name.tag.xml" + } + }, + "end": "(\\?>)", + "name": "meta.tag.preprocessor.xml", + "patterns": [ + { + "match": " ([a-zA-Z-]+)", + "name": "entity.other.attribute-name.xml" + }, + { + "include": "#doublequotedString" + }, + { + "include": "#singlequotedString" + } + ] + }, + { + "begin": "(<!)(DOCTYPE)\\s+([:a-zA-Z_][:a-zA-Z0-9_.-]*)", + "captures": { + "1": { + "name": "punctuation.definition.tag.xml" + }, + "2": { + "name": "keyword.other.doctype.xml" + }, + "3": { + "name": "variable.language.documentroot.xml" + } + }, + "end": "\\s*(>)", + "name": "meta.tag.sgml.doctype.xml", + "patterns": [ + { + "include": "#internalSubset" + } + ] + }, + { + "include": "#comments" + }, + { + "begin": "(<)((?:([-_a-zA-Z0-9]+)(:))?([-_a-zA-Z0-9:]+))(?=(\\s[^>]*)?></\\2>)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.xml" + }, + "2": { + "name": "entity.name.tag.xml" + }, + "3": { + "name": "entity.name.tag.namespace.xml" + }, + "4": { + "name": "punctuation.separator.namespace.xml" + }, + "5": { + "name": "entity.name.tag.localname.xml" + } + }, + "end": "(>)(</)((?:([-_a-zA-Z0-9]+)(:))?([-_a-zA-Z0-9:]+))(>)", + "endCaptures": { + "1": { + "name": "punctuation.definition.tag.xml" + }, + "2": { + "name": "punctuation.definition.tag.xml" + }, + "3": { + "name": "entity.name.tag.xml" + }, + "4": { + "name": "entity.name.tag.namespace.xml" + }, + "5": { + "name": "punctuation.separator.namespace.xml" + }, + "6": { + "name": "entity.name.tag.localname.xml" + }, + "7": { + "name": "punctuation.definition.tag.xml" + } + }, + "name": "meta.tag.no-content.xml", + "patterns": [ + { + "include": "#tagStuff" + } + ] + }, + { + "begin": "(</?)(?:([-\\w\\.]+)((:)))?([-\\w\\.:]+)", + "captures": { + "1": { + "name": "punctuation.definition.tag.xml" + }, + "2": { + "name": "entity.name.tag.namespace.xml" + }, + "3": { + "name": "entity.name.tag.xml" + }, + "4": { + "name": "punctuation.separator.namespace.xml" + }, + "5": { + "name": "entity.name.tag.localname.xml" + } + }, + "end": "(/?>)", + "name": "meta.tag.xml", + "patterns": [ + { + "include": "#tagStuff" + } + ] + }, + { + "include": "#entity" + }, + { + "include": "#bare-ampersand" + }, + { + "begin": "<%@", + "beginCaptures": { + "0": { + "name": "punctuation.section.embedded.begin.xml" + } + }, + "end": "%>", + "endCaptures": { + "0": { + "name": "punctuation.section.embedded.end.xml" + } + }, + "name": "source.java-props.embedded.xml", + "patterns": [ + { + "match": "page|include|taglib", + "name": "keyword.other.page-props.xml" + } + ] + }, + { + "begin": "<%[!=]?(?!--)", + "beginCaptures": { + "0": { + "name": "punctuation.section.embedded.begin.xml" + } + }, + "end": "(?!--)%>", + "endCaptures": { + "0": { + "name": "punctuation.section.embedded.end.xml" + } + }, + "name": "source.java.embedded.xml", + "patterns": [ + { + "include": "source.java" + } + ] + }, + { + "begin": "<!\\[CDATA\\[", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.xml" + } + }, + "end": "]]>", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.xml" + } + }, + "name": "string.unquoted.cdata.xml" + } + ], + "repository": { + "EntityDecl": { + "begin": "(<!)(ENTITY)\\s+(%\\s+)?([:a-zA-Z_][:a-zA-Z0-9_.-]*)(\\s+(?:SYSTEM|PUBLIC)\\s+)?", + "captures": { + "1": { + "name": "punctuation.definition.tag.xml" + }, + "2": { + "name": "keyword.other.entity.xml" + }, + "3": { + "name": "punctuation.definition.entity.xml" + }, + "4": { + "name": "variable.language.entity.xml" + }, + "5": { + "name": "keyword.other.entitytype.xml" + } + }, + "end": "(>)", + "patterns": [ + { + "include": "#doublequotedString" + }, + { + "include": "#singlequotedString" + } + ] + }, + "bare-ampersand": { + "match": "&", + "name": "invalid.illegal.bad-ampersand.xml" + }, + "doublequotedString": { + "begin": "(?<!\\}\\s*+)\"(?!\\s*+\\{)", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.xml" + } + }, + "end": "\"", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.xml" + } + }, + "name": "string.quoted.double.xml", + "patterns": [ + { + "include": "#entity" + }, + { + "include": "#bare-ampersand" + } + ] + }, + "entity": { + "captures": { + "1": { + "name": "punctuation.definition.constant.xml" + }, + "3": { + "name": "punctuation.definition.constant.xml" + } + }, + "match": "(&)([:a-zA-Z_][:a-zA-Z0-9_.-]*|#[0-9]+|#x[0-9a-fA-F]+)(;)", + "name": "constant.character.entity.xml" + }, + "internalSubset": { + "begin": "(\\[)", + "captures": { + "1": { + "name": "punctuation.definition.constant.xml" + } + }, + "end": "(\\])", + "name": "meta.internalsubset.xml", + "patterns": [ + { + "include": "#EntityDecl" + }, + { + "include": "#parameterEntity" + }, + { + "include": "#comments" + } + ] + }, + "parameterEntity": { + "captures": { + "1": { + "name": "punctuation.definition.constant.xml" + }, + "3": { + "name": "punctuation.definition.constant.xml" + } + }, + "match": "(%)([:a-zA-Z_][:a-zA-Z0-9_.-]*)(;)", + "name": "constant.character.parameter-entity.xml" + }, + "singlequotedString": { + "begin": "(?<!\\}\\s*+)'(?!\\s*+\\{)", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.xml" + } + }, + "end": "'", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.xml" + } + }, + "name": "string.quoted.single.xml", + "patterns": [ + { + "include": "#entity" + }, + { + "include": "#bare-ampersand" + } + ] + }, + "tagStuff": { + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.namespace.xml" + }, + "2": { + "name": "entity.other.attribute-name.xml" + }, + "3": { + "name": "punctuation.separator.namespace.xml" + }, + "4": { + "name": "entity.other.attribute-name.localname.xml" + } + }, + "match": "(?:^|\\s+)(?:([-\\w.]+)((:)))?([-\\w.:]+)\\s*=" + }, + { + "include": "#doublequotedString" + }, + { + "include": "#singlequotedString" + } + ] + }, + "comments": { + "patterns": [ + { + "begin": "<%--", + "captures": { + "0": { + "name": "punctuation.definition.comment.xml" + }, + "end": "--%>", + "name": "comment.block.xml" + } + }, + { + "begin": "<!--", + "captures": { + "0": { + "name": "punctuation.definition.comment.xml" + } + }, + "end": "-->", + "name": "comment.block.xml", + "patterns": [ + { + "begin": "--(?!>)", + "captures": { + "0": { + "name": "invalid.illegal.bad-comments-or-CDATA.xml" + } + } + } + ] + } + ] + } + } +} Review Comment: Is this file needed? Can we depend on another extension like we do with the other changes? I'm not sure exactly what this is doing, but it don't see anything DFDL specific. ########## project/Rat.scala: ########## @@ -35,7 +40,24 @@ object Rat { lazy val MIT_LICENSE_NAME = "MIT License" - lazy val MIT_LICENSE_TEXT_MICROSOFT = + lazy val MIT_VS_LICENSE_TEXT = + """ +Copyright (c) [2017] [Vincas Stonys]. +Licensed under the MIT License. See License.txt in the project root for license information. +""" + + lazy val MIT_DELTA_LICENSE_TEXT = + """ +Copyright (c) 2020 DeltaXML Ltd. and others. +All rights reserved. This program and the accompanying materials +are made available under the terms of the MIT license +which accompanies this distribution. + +Contributors: +DeltaXML Ltd. - XPath/XSLT Lexer/Syntax Highlighter +""" Review Comment: Mentioned elsewhere, but these are no longer included in our repo right? Can they be removed? ########## src/language/providers/attributeCompletion.ts: ########## @@ -0,0 +1,275 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as vscode from 'vscode' + +import { + nearestOpen, + checkBraceOpen, + lineCount, + checkLastItemOpen, + checkSequenceOpen, + checkElementOpen, + checkSimpleTypeOpen, +} from './utils' + +import { attributeCompletion } from './intellisense/attributeItems' + +function getCompletionItems( + itemsToUse: string[], + preVal: string = '', + additionalItems: string = '' +) { + let compItems: vscode.CompletionItem[] = [] + + attributeCompletion(preVal, additionalItems).items.forEach((e) => { + if (itemsToUse.includes(e.item)) { + const completionItem = new vscode.CompletionItem(e.item) + completionItem.insertText = new vscode.SnippetString(e.snippetString) + + if (e.markdownString) { + completionItem.documentation = new vscode.MarkdownString( + e.markdownString + ) + } + compItems.push(completionItem) + } + }) + + return compItems +} + +export function getAttributeCompletionProvider() { + return vscode.languages.registerCompletionItemProvider( + { language: 'dfdl' }, + { + provideCompletionItems( + document: vscode.TextDocument, + position: vscode.Position + ) { + const wholeLine = document + .lineAt(position) + .text.substr(0, position.character) + var nearestOpenItem = nearestOpen(document, position) + + if ( + !checkBraceOpen(document, position) && + !wholeLine.includes('assert') && + !nearestOpenItem.includes('none') + ) { + if (nearestOpenItem.includes('element')) { + var preVal = '' + if (!wholeLine.includes('xs:element')) { + if (lineCount(document, position) === 1) { + preVal = '\t' + } else { + preVal = '' + } + } + var additionalItems = getDefinedTypes(document) + + if ( + checkLastItemOpen(document, position) && + (wholeLine.includes('<xs:element name="') || + wholeLine.includes('<xs:element ref="') || Review Comment: I still don't understand these `wholeLine.includes` checks. The context to use for autocompletion doesn't have do with the line of text--it has to do with things like what is the name of the current tag that the cursor is inside, what are the values of it's attributes, etc. This just feels very fragile and likely to give the wrong results. It seems like instead you want something like ``` if (nearestOpenItem.includes("element)) { if (nearesOpenItem.hasAttribute("name") || nearestOpenItem.hasAttribute("ref")) { ... } } ``` A simple examle where this breaks, it's not uncommon for schemas to use "xsd" instead of "xs" (or even no prefix). In those cases looking for "xs:element" is going to fail. I wont' block this merging for this, but hope it's updated in the future to improve how it determines the appropriate context for choosing completions. ########## src/language/providers/attributeCompletion.ts: ########## @@ -0,0 +1,275 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as vscode from 'vscode' + +import { + nearestOpen, + checkBraceOpen, + lineCount, + checkLastItemOpen, + checkSequenceOpen, + checkElementOpen, + checkSimpleTypeOpen, +} from './utils' + +import { attributeCompletion } from './intellisense/attributeItems' + +function getCompletionItems( + itemsToUse: string[], + preVal: string = '', + additionalItems: string = '' +) { + let compItems: vscode.CompletionItem[] = [] + + attributeCompletion(preVal, additionalItems).items.forEach((e) => { + if (itemsToUse.includes(e.item)) { + const completionItem = new vscode.CompletionItem(e.item) + completionItem.insertText = new vscode.SnippetString(e.snippetString) + + if (e.markdownString) { + completionItem.documentation = new vscode.MarkdownString( + e.markdownString + ) + } + compItems.push(completionItem) + } + }) + + return compItems +} + +export function getAttributeCompletionProvider() { + return vscode.languages.registerCompletionItemProvider( + { language: 'dfdl' }, + { + provideCompletionItems( + document: vscode.TextDocument, + position: vscode.Position + ) { + const wholeLine = document + .lineAt(position) + .text.substr(0, position.character) + var nearestOpenItem = nearestOpen(document, position) + + if ( + !checkBraceOpen(document, position) && + !wholeLine.includes('assert') && + !nearestOpenItem.includes('none') + ) { + if (nearestOpenItem.includes('element')) { + var preVal = '' + if (!wholeLine.includes('xs:element')) { + if (lineCount(document, position) === 1) { + preVal = '\t' + } else { + preVal = '' + } + } + var additionalItems = getDefinedTypes(document) + + if ( + checkLastItemOpen(document, position) && + (wholeLine.includes('<xs:element name="') || + wholeLine.includes('<xs:element ref="') || + checkElementOpen(document, position)) + ) { + return getCompletionItems( Review Comment: I really like his update, much easier to read and get an idea what's going on. :+1: ########## src/language/providers/intellisense/attributeItems.ts: ########## @@ -0,0 +1,212 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const attributeCompletion = (preVal, additionalItems) => { + return { + items: [ + { + item: 'dfdl:defineFormat', + snippetString: + preVal + Review Comment: Is prePended to everyone of the snippetStrings? Can that be done by the caller instead? Removes a lot of duplication and coule make it so everyone one of these items fits on three lines making it easier to read. ########## src/language/providers/intellisense/attributeItems.ts: ########## @@ -0,0 +1,212 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const attributeCompletion = (preVal, additionalItems) => { + return { + items: [ + { + item: 'dfdl:defineFormat', + snippetString: + preVal + + '<dfdl:defineFormat name="$1" >\n\t$2\n</dfdl:defineFormat>\n$0', + markdownString: 'dfdl format name and configuration', + }, + { + item: 'dfdl:defineEscapeScheme', + snippetString: + preVal + + '<dfdl:defineEscapeScheme name=$1 >\n\t$0,/dfdl:defineEscapeScheme>\n', + markdownString: 'dfdl escape character definition', + }, + { + item: 'type=', + snippetString: + preVal + + 'type="${1|xs:string,xs:decimal,xs:float,xs:double,xs:integer,xs:nonNegativeInteger,xs:int,xs:unsignedInt,xs:short,xs:unsignedShort,xs:long,xs:unsignedLong,xs:byte,xs:unsignedByte,xs:hexBinary,xs:boolean' + + additionalItems + + '|}"$0', + markdownString: 'attribute to specify a simple type element type', + }, + { + item: 'minOccurs=', + snippetString: preVal + 'minOccurs="${1|0,1|}"$0', + markdownString: 'mininum number of times element will occur', + }, + { + item: 'maxOccurs=', + snippetString: preVal + 'maxOccurs="${1|0,1,unbounded|}"$0', + markdownString: 'maximum number of times element will occur', + }, + { + item: 'dfdl:occursCount=', + snippetString: preVal + 'dfdl:occursCount="$1"$0', + markdownString: + 'dfdl:occursCount property takes an expression which commonly looks in the Infoset via an expression, to obtain the count from another element.', Review Comment: Suggest not wrapping these long lines. Makes it easier to scan if everyone one of these is only three lines. ########## package.json: ########## @@ -23,26 +23,37 @@ "url": "https://github.com/apache/daffodil-vscode/issues" }, "scripts": { + "omega-edit-download": "tsc -p ./ && node -e 'require(\"./out/omega_edit/download.js\").downloadServer()'", "vscode:prepublish": "yarn run package-ext", "precompile": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts", - "compile": "tsc -p ./", + "compile": "tsc -p ./ && node out/omega_edit/download.js", Review Comment: I removed the run-script-os stuff (see below comment), and when I run `yarn build` it never downloads the omega zip file. Should this have the `require` and `downloadServer` stuff mentioned above? Or should something else depend on oemga-edit-download? ########## package.json: ########## @@ -23,26 +23,37 @@ "url": "https://github.com/apache/daffodil-vscode/issues" }, "scripts": { + "omega-edit-download": "tsc -p ./ && node -e 'require(\"./out/omega_edit/download.js\").downloadServer()'", "vscode:prepublish": "yarn run package-ext", "precompile": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts", - "compile": "tsc -p ./", + "compile": "tsc -p ./ && node out/omega_edit/download.js", "lint": "yarn run prettier src -c", - "watch": "webpack --watch --devtool nosources-source-map --info-verbosity verbose --config ./build/extension.webpack.config.js", + "watch": "yarn omega-edit-download && webpack --watch --devtool nosources-source-map --config ./build/extension.webpack.config.js", "watch2": "tsc -watch -p ./", "package": "vsce package", "publish": "vsce publish", "package-ext": "webpack --mode production --config ./build/extension.webpack.config.js", "pretest": "yarn run compile", "test": "node node_modules/mocha/bin/_mocha -u tdd --timeout 999999 --colors ./out/tests", "sbt": "sbt universal:packageBin", - "pre-build": "mv LICENSE tmp.LICENSE && mv NOTICE tmp.NOTICE && cp build/bin.LICENSE LICENSE && cp build/bin.NOTICE NOTICE", + "pre-build": "run-script-os", Review Comment: I tried to build a vsix file and got an error: ``` /bin/sh: line 1: run-script-os: command not found ``` I wonder if adding it as a dependency does not make it available as part of the build? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
