You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2023/01/20 15:24:32 UTC
[GitHub] [daffodil-vscode] rt320 opened a new pull request, #429: Modifications to try to ensure intellisense offers relevant
rt320 opened a new pull request, #429:
URL: https://github.com/apache/daffodil-vscode/pull/429
suggestions when there are multiple tags on a single line and
when one or more end tags have been removed
-Logic was introduced to determine if multiple tags are on a
single line
-The nearestOpen funtion was modified to take in to account
multiple tags on a single line
-The logic for closeElement and cloesElementSlash was modified to
supply the end tag for previous items whether on a single line
or multiple lines where the end tag is missing or has been
deleted. The triggers '/' or '>' should now provide end tags if
they are missing
Closes #309
--
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: commits-unsubscribe@daffodil.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [daffodil-vscode] stevedlawrence commented on pull request #429: Modifications to try to ensure intellisense offers relevant
Posted by "stevedlawrence (via GitHub)" <gi...@apache.org>.
stevedlawrence commented on PR #429:
URL: https://github.com/apache/daffodil-vscode/pull/429#issuecomment-1402336564
What issue is this resolving? The ticket mentions #309, but that's a pull request and not an issue. Do you mean #165?
As to this change, I have trouble following the logic with all the nested if statemens, which makes me think this might not be best approach. We've been okay with it so far, but it's honestly too much to follow and ensure that we're doing the right thing, and as things get even more complex I don't see this approach being maintainable.
I think maybe a new algorithm is really needed to figure the correct context for autocompletion instead of just a bunch of if-statements. If you want to have a phone call or email thread to discuss some alternative approaches I'm happy to do so.
--
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: commits-unsubscribe@daffodil.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [daffodil-vscode] scholarsmate commented on pull request #429: Modifications to try to ensure intellisense offers relevant
Posted by "scholarsmate (via GitHub)" <gi...@apache.org>.
scholarsmate commented on PR #429:
URL: https://github.com/apache/daffodil-vscode/pull/429#issuecomment-1402281705
@stevedlawrence, can you review this please? Thanks!
--
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: commits-unsubscribe@daffodil.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [daffodil-vscode] rt320 closed pull request #429: Modifications to try to ensure intellisense offers relevant
Posted by "rt320 (via GitHub)" <gi...@apache.org>.
rt320 closed pull request #429: Modifications to try to ensure intellisense offers relevant
URL: https://github.com/apache/daffodil-vscode/pull/429
--
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: commits-unsubscribe@daffodil.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [daffodil-vscode] rt320 commented on pull request #429: Modifications to try to ensure intellisense offers relevant
Posted by "rt320 (via GitHub)" <gi...@apache.org>.
rt320 commented on PR #429:
URL: https://github.com/apache/daffodil-vscode/pull/429#issuecomment-1435125579
Code fixes will be present in a new PR
--
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: commits-unsubscribe@daffodil.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [daffodil-vscode] scholarsmate commented on a diff in pull request #429: Modifications to try to ensure intellisense offers relevant
Posted by "scholarsmate (via GitHub)" <gi...@apache.org>.
scholarsmate commented on code in PR #429:
URL: https://github.com/apache/daffodil-vscode/pull/429#discussion_r1084043427
##########
src/language/providers/closeElement.ts:
##########
@@ -27,98 +32,207 @@ export function getCloseElementProvider() {
position: vscode.Position
) {
var backpos = position.with(position.line, position.character - 1)
+ var backpos3 = position.with(position.line, position.character - 3)
Review Comment:
We should be using either `let` for mutable variables or `const` for immutable variables.
--
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: commits-unsubscribe@daffodil.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [daffodil-vscode] scholarsmate commented on a diff in pull request #429: Modifications to try to ensure intellisense offers relevant
Posted by "scholarsmate (via GitHub)" <gi...@apache.org>.
scholarsmate commented on code in PR #429:
URL: https://github.com/apache/daffodil-vscode/pull/429#discussion_r1084047215
##########
src/language/providers/closeElement.ts:
##########
@@ -27,98 +32,207 @@ export function getCloseElementProvider() {
position: vscode.Position
) {
var backpos = position.with(position.line, position.character - 1)
+ var backpos3 = position.with(position.line, position.character - 3)
const nsPrefix = getXsdNsPrefix(document, position)
const nearestOpenItem = nearestOpen(document, position)
const triggerText = document
.lineAt(position)
.text.substring(0, position.character)
+ var itemsOnLine = getItemsOnLineCount(triggerText)
if (
- !triggerText.includes('</') &&
triggerText.endsWith('>') &&
- (triggerText.includes('<' + nsPrefix + 'element') ||
- nearestOpenItem.includes('element') ||
- triggerText.includes('<' + nsPrefix + 'group') ||
- nearestOpenItem.includes('group') ||
- triggerText.includes('<' + nsPrefix + 'sequence') ||
- nearestOpenItem.includes('sequence') ||
- triggerText.includes('<' + nsPrefix + 'simpleType') ||
- nearestOpenItem.includes('simpleType') ||
- triggerText.includes('<' + nsPrefix + 'choice') ||
- nearestOpenItem.includes('choice') ||
- triggerText.includes('dfdl:defineVariable') ||
- nearestOpenItem.includes('Variable'))
+ ((triggerText.includes('<' + nsPrefix + 'element') &&
+ nearestOpenItem.includes('element')) ||
+ (triggerText.includes('<' + nsPrefix + 'group') &&
+ nearestOpenItem.includes('group')) ||
+ (triggerText.includes('<' + nsPrefix + 'sequence') &&
+ nearestOpenItem.includes('sequence')) ||
+ (triggerText.includes('<' + nsPrefix + 'simpleType') &&
+ nearestOpenItem.includes('simpleType')) ||
+ (triggerText.includes('<' + nsPrefix + 'choice') &&
+ nearestOpenItem.includes('choice')) ||
+ (triggerText.includes('dfdl:defineVariable') &&
+ nearestOpenItem.includes('Variable')) ||
+ itemsOnLine == 0)
) {
var range = new vscode.Range(backpos, position)
vscode.window.activeTextEditor?.edit((editBuilder) => {
editBuilder.replace(range, '')
})
- if (
- triggerText.endsWith('>') &&
- (triggerText.includes('<' + nsPrefix + 'element ref') ||
- triggerText.includes('<' + nsPrefix + 'group ref'))
- ) {
- insertSnippet(' />\n$0', backpos)
- } else if (
- triggerText.endsWith('>') &&
- (triggerText.includes('<' + nsPrefix + 'element') ||
- nearestOpenItem.includes('element'))
- ) {
- insertSnippet('>\n\t$0\n</' + nsPrefix + 'element>', backpos)
- } else if (
- triggerText.endsWith('>') &&
- (triggerText.includes('<' + nsPrefix + 'group') ||
- nearestOpenItem.includes('group'))
- ) {
- insertSnippet('>\n\t$0\n</' + nsPrefix + 'group>', backpos)
- } else if (
- (triggerText.endsWith('>') &&
- triggerText.includes('<' + nsPrefix + 'sequence')) ||
- nearestOpenItem.includes('sequence')
- ) {
- insertSnippet('>\n\t$0\n</' + nsPrefix + 'sequence>', backpos)
- } else if (
- (triggerText.endsWith('>') &&
- triggerText.includes('<' + nsPrefix + 'choice')) ||
- nearestOpenItem.includes('choice')
- ) {
- insertSnippet('>\n\t$0\n</' + nsPrefix + 'choice>', backpos)
- } else if (
- (triggerText.endsWith('>') &&
- triggerText.includes('<' + nsPrefix + 'simpleType')) ||
- nearestOpenItem.includes('simpleType')
- ) {
- insertSnippet('>\n\t$0\n</' + nsPrefix + 'simpleType>', backpos)
- } else if (
- (triggerText.endsWith('>') &&
- triggerText.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, '')
- })
- insertSnippet('>\n</dfdl:defineVariable>\n', backpos)
- var backpos2 = position.with(position.line + 2, startPos - 2)
- insertSnippet('</<' + nsPrefix + 'appinfo>\n', backpos2)
- var backpos3 = position.with(position.line + 3, startPos - 4)
- insertSnippet('</<' + nsPrefix + 'annotation>$0', backpos3)
- } else if (
- (triggerText.endsWith('>') &&
- triggerText.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, '')
- })
- insertSnippet('>\n</dfdl:setVariable>\n', backpos)
- var backpos2 = position.with(position.line + 2, startPos - 2)
- insertSnippet('</' + nsPrefix + 'appinfo>\n', backpos2)
- var backpos3 = position.with(position.line + 3, startPos - 4)
- insertSnippet('</' + nsPrefix + 'annotation>$0', backpos3)
+ if (itemsOnLine == 1 || itemsOnLine == 0) {
+ if (!triggerText.includes('</')) {
+ if (itemsOnLine == 0) {
+ insertSnippet(
+ '</' + nsPrefix + nearestOpenItem + '>$0',
+ backpos3
+ )
+ } else {
+ if (
+ triggerText.endsWith('>') &&
+ (triggerText.includes('<' + nsPrefix + 'element ref') ||
+ triggerText.includes('<' + nsPrefix + 'group ref'))
+ ) {
+ insertSnippet(' />\n$0', backpos)
+ } else if (
+ triggerText.endsWith('>') &&
+ triggerText.includes('<' + nsPrefix + 'element') &&
+ nearestOpenItem.includes('element')
+ ) {
+ insertSnippet('>\n\t$0\n</' + nsPrefix + 'element>', backpos)
+ } else if (
+ triggerText.endsWith('>') &&
+ triggerText.includes('<' + nsPrefix + 'group') &&
+ nearestOpenItem.includes('group')
+ ) {
+ insertSnippet('>\n\t$0\n</' + nsPrefix + 'group>', backpos)
+ } else if (
+ triggerText.endsWith('>') &&
+ triggerText.includes('<' + nsPrefix + 'sequence') &&
+ nearestOpenItem.includes('sequence')
+ ) {
+ insertSnippet('>\n\t$0\n</' + nsPrefix + 'sequence>', backpos)
+ } else if (
+ triggerText.endsWith('>') &&
+ triggerText.includes('<' + nsPrefix + 'choice') &&
+ nearestOpenItem.includes('choice')
+ ) {
+ insertSnippet('>\n\t$0\n</' + nsPrefix + 'choice>', backpos)
+ } else if (
+ triggerText.endsWith('>') &&
+ triggerText.includes('<' + nsPrefix + 'simpleType') &&
+ nearestOpenItem.includes('simpleType')
+ ) {
+ insertSnippet(
+ '>\n\t$0\n</' + nsPrefix + 'simpleType>',
+ backpos
+ )
+ } else if (
+ triggerText.endsWith('>') &&
+ triggerText.includes('dfdl:defineVariable') &&
+ nearestOpenItem.includes('defineVariable')
+ ) {
+ var startPos = document.lineAt(position).text.indexOf('<', 0)
Review Comment:
Many / All of the `var` in here should be `const`.
--
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: commits-unsubscribe@daffodil.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [daffodil-vscode] scholarsmate commented on a diff in pull request #429: Modifications to try to ensure intellisense offers relevant
Posted by "scholarsmate (via GitHub)" <gi...@apache.org>.
scholarsmate commented on code in PR #429:
URL: https://github.com/apache/daffodil-vscode/pull/429#discussion_r1084057660
##########
src/language/providers/utils.ts:
##########
@@ -312,10 +528,13 @@ export function checkBraceOpen(
const triggerText = document.lineAt(lineNum).text
//.text.substring(0, document.lineAt(lineNum).range.end.character)
+ if (!triggerText.includes('{')) {
+ return false
+ }
if (
triggerText.includes('"{') &&
triggerText.includes('}"') &&
- triggerText.includes('..') &&
+ (triggerText.includes('..') || triggerText.includes('.')) &&
Review Comment:
This can be simplified to just `triggerText.includes('.')`.
--
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: commits-unsubscribe@daffodil.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [daffodil-vscode] scholarsmate commented on a diff in pull request #429: Modifications to try to ensure intellisense offers relevant
Posted by "scholarsmate (via GitHub)" <gi...@apache.org>.
scholarsmate commented on code in PR #429:
URL: https://github.com/apache/daffodil-vscode/pull/429#discussion_r1084054887
##########
src/language/providers/utils.ts:
##########
@@ -160,7 +274,7 @@ export function checkElementOpen(
triggerText.includes('<' + nsPrefix + 'element') &&
!triggerText.includes('</' + nsPrefix + 'element') &&
!triggerText.includes('/>') &&
- !triggerText.includes('>')
+ !triggerText.includes('/element>')
Review Comment:
Is this right?
--
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: commits-unsubscribe@daffodil.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org