mbeckerle commented on code in PR #294:
URL: https://github.com/apache/daffodil-vscode/pull/294#discussion_r972211402


##########
src/language/providers/utils.ts:
##########
@@ -223,15 +230,16 @@ export function checkSimpleTypeOpen(
   document: vscode.TextDocument,
   position: vscode.Position
 ) {
+  const nsPrefix = getNsPrefix(document, position)
   var lineNum = position.line
   while (lineNum !== 0) {
     const wholeLine = document
       .lineAt(lineNum)
       .text.substr(0, document.lineAt(lineNum).range.end.character)
 
     if (
-      wholeLine.includes('<xs:simpleType') &&
-      !wholeLine.includes('</xs:simpleType') &&
+      wholeLine.includes('<' + nsPrefix + 'simpleType') &&

Review Comment:
   Since this is everywhere, why not define an object that can be called like
   `wholeLineElt('simpleType')`
   which does this 
   `wholeLineIncludes('<' + nsPrefix + arg)`
   So that the namespace prefix stuff is suppressed. 



##########
src/language/providers/utils.ts:
##########
@@ -283,6 +291,33 @@ export function checkSetVariableOpen(
   return false
 }
 
+export function getNsPrefix(
+  document: vscode.TextDocument,
+  position: vscode.Position
+) {
+  var initialLineNum = position.line
+  var lineNum = 0
+  while (initialLineNum !== 0 && lineNum <= initialLineNum) {
+    const lineText = document
+      .lineAt(lineNum)
+      .text.substr(0, document.lineAt(lineNum).range.end.character)
+    // returns an empty prefix value
+    if (lineText.includes('<schema')) {
+      return ''

Review Comment:
   This is fine. Basically following the lead of how the schema element is 
prefixed. 



-- 
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]

Reply via email to