-
Notifications
You must be signed in to change notification settings - Fork 686
autoimport completions #1553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
autoimport completions #1553
Changes from all commits
d108e2e
e450fbf
2159797
fd072cf
f28767b
1f582ed
9eac6f1
98404fb
8b8adb4
b13ee93
357432a
f0f88dc
7a44815
e84c1fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ func getIndentationForNodeWorker( | |
if useActualIndentation { | ||
// check if current node is a list item - if yes, take indentation from it | ||
var firstListChild *ast.Node | ||
containerList := getContainingList(current, sourceFile) | ||
containerList := GetContainingList(current, sourceFile) | ||
if containerList != nil { | ||
firstListChild = core.FirstOrNil(containerList.Nodes) | ||
} | ||
|
@@ -139,7 +139,7 @@ func getActualIndentationForListItem(node *ast.Node, sourceFile *ast.SourceFile, | |
// VariableDeclarationList has no wrapping tokens | ||
return -1 | ||
} | ||
containingList := getContainingList(node, sourceFile) | ||
containingList := GetContainingList(node, sourceFile) | ||
if containingList != nil { | ||
index := core.FindIndex(containingList.Nodes, func(e *ast.Node) bool { return e == node }) | ||
if index != -1 { | ||
|
@@ -196,10 +196,10 @@ func deriveActualIndentationFromList(list *ast.NodeList, index int, sourceFile * | |
|
||
func findColumnForFirstNonWhitespaceCharacterInLine(line int, char int, sourceFile *ast.SourceFile, options *FormatCodeSettings) int { | ||
lineStart := scanner.GetPositionOfLineAndCharacter(sourceFile, line, 0) | ||
return findFirstNonWhitespaceColumn(lineStart, lineStart+char, sourceFile, options) | ||
return FindFirstNonWhitespaceColumn(lineStart, lineStart+char, sourceFile, options) | ||
} | ||
|
||
func findFirstNonWhitespaceColumn(startPos int, endPos int, sourceFile *ast.SourceFile, options *FormatCodeSettings) int { | ||
func FindFirstNonWhitespaceColumn(startPos int, endPos int, sourceFile *ast.SourceFile, options *FormatCodeSettings) int { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am suspicious of this function, given it appears to return the column in terms of runes? I'm not sure it walks the chars correctly either, hmm... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what I was writing when I first went "wait, do we work in runes or in byte offsets for columns? Looks inconsistent right now". Both ways look wrong to some part of the stack around here because of that inconsistency. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think we need everything to be UTF-8 byte offsets, until they hit the LS and get converted based on the client preferences. The only exception might be symbol baselines (UTF-16 compat?), source maps, and maybe the API, and maybe printed diagnostics? (That's a lot of exceptions...) Related, #1578 |
||
_, col := findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options) | ||
return col | ||
} | ||
|
@@ -249,7 +249,7 @@ func getStartLineAndCharacterForNode(n *ast.Node, sourceFile *ast.SourceFile) (l | |
return scanner.GetLineAndCharacterOfPosition(sourceFile, scanner.GetTokenPosOfNode(n, sourceFile, false)) | ||
} | ||
|
||
func getContainingList(node *ast.Node, sourceFile *ast.SourceFile) *ast.NodeList { | ||
func GetContainingList(node *ast.Node, sourceFile *ast.SourceFile) *ast.NodeList { | ||
if node.Parent == nil { | ||
return nil | ||
} | ||
|
@@ -348,7 +348,7 @@ func getVisualListRange(node *ast.Node, list core.TextRange, sourceFile *ast.Sou | |
} | ||
|
||
func getContainingListOrParentStart(parent *ast.Node, child *ast.Node, sourceFile *ast.SourceFile) (line int, character int) { | ||
containingList := getContainingList(child, sourceFile) | ||
containingList := GetContainingList(child, sourceFile) | ||
var startPos int | ||
if containingList != nil { | ||
startPos = containingList.Loc.Pos() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know this func existed; I wonder if it's general enough to use for sig help. (No action needed, just opining)