aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/vendor/golang.org/x/tools/internal/lsp/fuzzy/input.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2022-08-04 10:12:28 -0700
committerMatthew Dempsky <mdempsky@google.com>2022-08-04 10:12:28 -0700
commitd558507db42d600e5ad82748bda0cb91df57b97d (patch)
tree169457500d42144774eb68c5ab2ef70ad67aa673 /src/cmd/vendor/golang.org/x/tools/internal/lsp/fuzzy/input.go
parentc9f2150cfb3c1db87f6434f727c25403d985a6e4 (diff)
parent85d87b9c7507628144db51bd1e7e80cc3afed128 (diff)
downloadgo-dev.unified.tar.gz
go-dev.unified.zip
[dev.unified] all: merge master (85d87b9) into dev.unifieddev.unified
Merge List: + 2022-08-04 85d87b9c75 all: update vendored golang.org/x dependencies for Go 1.20 development + 2022-08-04 fb1bfd4d37 all: remove pre-Go 1.17 workarounds + 2022-08-04 44ff9bff0c runtime: clean up panic and deadlock lock ranks + 2022-08-04 f42dc0de74 runtime: make the lock rank DAG make more sense + 2022-08-04 d29a0282e9 runtime: add mayAcquire annotation for finlock + 2022-08-04 c5be4ed7df runtime: add missing trace lock edges + 2022-08-04 2b8a9a484f runtime: generate the lock ranking from a DAG description + 2022-08-04 ddfd639408 runtime: delete unused lock ranks + 2022-08-04 426ea5702b internal/dag: add a Graph type and make node order deterministic + 2022-08-04 d37cc9a8cd go/build, internal/dag: lift DAG parser into an internal package + 2022-08-04 ab0a94c6d3 cmd/dist: require Go 1.17 for building Go + 2022-08-04 1e3c19f3fe runtime: support riscv64 SV57 mode + 2022-08-03 f28fa952b5 make.bat, make.rc: show bootstrap toolchain version + 2022-08-03 87384801dc cmd/asm: update package doc to describe "-p" option + 2022-08-03 c6a2dada0d net: disable TestIPv6WriteMsgUDPAddrPortTargetAddrIPVersion [sic] on DragonflyBSD + 2022-08-02 29b9a328d2 runtime: trivial replacements of g in remaining files + 2022-08-02 c647264619 runtime: trivial replacements of g in signal_unix.go + 2022-08-02 399f50c9d7 runtime: tricky replacements of g in traceback.go + 2022-08-02 4509e951ec runtime: tricky replacements of g in proc.go + 2022-08-02 4400238ec8 runtime: trivial replacements of _g_ in remaining files + 2022-08-02 5999a28de8 runtime: trivial replacements of _g_ in os files + 2022-08-02 0e18cf6d09 runtime: trivial replacements of _g_ in GC files + 2022-08-02 4358a53a97 runtime: trivial replacements of _g_ in proc.go + 2022-08-02 b486518964 runtime: tricky replacements of _g_ in os3_solaris.go + 2022-08-02 54a0ab3f7b runtime: tricky replacements of _g_ in os3_plan9.go + 2022-08-02 4240ff764b runtime: tricky replacements of _g_ in signal_windows.go + 2022-08-02 8666d89ca8 runtime: tricky replacements of _g_ in signal_unix.go + 2022-08-02 74cee276fe runtime: tricky replacements of _g_ in trace.go + 2022-08-02 222799fde6 runtime: tricky replacements of _g_ in mgc.go + 2022-08-02 e9d7f54a1a runtime: tricky replacements of _g_ in proc.go + 2022-08-02 5e8d261918 runtime: rename _p_ to pp + 2022-08-02 0ad2ec6596 runtime: clean up dopanic_m + 2022-08-02 7e952962df runtime: clean up canpanic + 2022-08-02 9dbc0f3556 runtime: fix outdated g.m comment in traceback.go + 2022-08-02 d723df76da internal/goversion: update Version to 1.20 + 2022-08-02 1b7e71e8ae all: disable tests that fail on Alpine + 2022-08-01 f2a9f3e2e0 test: improve generic type assertion test + 2022-08-01 27038b70f8 cmd/compile: fix wrong dict pass condition for type assertions + 2022-08-01 e99f53fed9 doc: move Go 1.19 release notes to x/website + 2022-08-01 8b13a073a1 doc: mention removal of cmd/compile's -importmap and -installsuffix flags + 2022-08-01 e95fd4c238 doc/go1.19: fix typo: EM_LONGARCH -> EM_LOONGARCH + 2022-08-01 dee3efd9f8 doc/go1.19: fix a few links that were missing trailing slashes + 2022-07-30 f32519e5fb runtime: fix typos + 2022-07-29 9a2001a8cc cmd/dist: always pass -short=true with -quick + 2022-07-28 5c8ec89cb5 doc/go1.19: minor adjustments and links + 2022-07-28 417be37048 doc/go1.19: improve the loong64 release notes + 2022-07-28 027855e8d8 os/exec: add GODEBUG setting to opt out of ErrDot changes Change-Id: Idc0fbe93978c0dff7600b90a2c3ecc067fd9f5f2
Diffstat (limited to 'src/cmd/vendor/golang.org/x/tools/internal/lsp/fuzzy/input.go')
-rw-r--r--src/cmd/vendor/golang.org/x/tools/internal/lsp/fuzzy/input.go183
1 files changed, 0 insertions, 183 deletions
diff --git a/src/cmd/vendor/golang.org/x/tools/internal/lsp/fuzzy/input.go b/src/cmd/vendor/golang.org/x/tools/internal/lsp/fuzzy/input.go
deleted file mode 100644
index c1038163f1..0000000000
--- a/src/cmd/vendor/golang.org/x/tools/internal/lsp/fuzzy/input.go
+++ /dev/null
@@ -1,183 +0,0 @@
-// Copyright 2019 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package fuzzy
-
-import (
- "unicode"
-)
-
-// RuneRole specifies the role of a rune in the context of an input.
-type RuneRole byte
-
-const (
- // RNone specifies a rune without any role in the input (i.e., whitespace/non-ASCII).
- RNone RuneRole = iota
- // RSep specifies a rune with the role of segment separator.
- RSep
- // RTail specifies a rune which is a lower-case tail in a word in the input.
- RTail
- // RUCTail specifies a rune which is an upper-case tail in a word in the input.
- RUCTail
- // RHead specifies a rune which is the first character in a word in the input.
- RHead
-)
-
-// RuneRoles detects the roles of each byte rune in an input string and stores it in the output
-// slice. The rune role depends on the input type. Stops when it parsed all the runes in the string
-// or when it filled the output. If output is nil, then it gets created.
-func RuneRoles(candidate []byte, reuse []RuneRole) []RuneRole {
- var output []RuneRole
- if cap(reuse) < len(candidate) {
- output = make([]RuneRole, 0, len(candidate))
- } else {
- output = reuse[:0]
- }
-
- prev, prev2 := rtNone, rtNone
- for i := 0; i < len(candidate); i++ {
- r := rune(candidate[i])
-
- role := RNone
-
- curr := rtLower
- if candidate[i] <= unicode.MaxASCII {
- curr = runeType(rt[candidate[i]] - '0')
- }
-
- if curr == rtLower {
- if prev == rtNone || prev == rtPunct {
- role = RHead
- } else {
- role = RTail
- }
- } else if curr == rtUpper {
- role = RHead
-
- if prev == rtUpper {
- // This and previous characters are both upper case.
-
- if i+1 == len(candidate) {
- // This is last character, previous was also uppercase -> this is UCTail
- // i.e., (current char is C): aBC / BC / ABC
- role = RUCTail
- }
- }
- } else if curr == rtPunct {
- switch r {
- case '.', ':':
- role = RSep
- }
- }
- if curr != rtLower {
- if i > 1 && output[i-1] == RHead && prev2 == rtUpper && (output[i-2] == RHead || output[i-2] == RUCTail) {
- // The previous two characters were uppercase. The current one is not a lower case, so the
- // previous one can't be a HEAD. Make it a UCTail.
- // i.e., (last char is current char - B must be a UCTail): ABC / ZABC / AB.
- output[i-1] = RUCTail
- }
- }
-
- output = append(output, role)
- prev2 = prev
- prev = curr
- }
- return output
-}
-
-type runeType byte
-
-const (
- rtNone runeType = iota
- rtPunct
- rtLower
- rtUpper
-)
-
-const rt = "00000000000000000000000000000000000000000000001122222222221000000333333333333333333333333330000002222222222222222222222222200000"
-
-// LastSegment returns the substring representing the last segment from the input, where each
-// byte has an associated RuneRole in the roles slice. This makes sense only for inputs of Symbol
-// or Filename type.
-func LastSegment(input string, roles []RuneRole) string {
- // Exclude ending separators.
- end := len(input) - 1
- for end >= 0 && roles[end] == RSep {
- end--
- }
- if end < 0 {
- return ""
- }
-
- start := end - 1
- for start >= 0 && roles[start] != RSep {
- start--
- }
-
- return input[start+1 : end+1]
-}
-
-// fromChunks copies string chunks into the given buffer.
-func fromChunks(chunks []string, buffer []byte) []byte {
- ii := 0
- for _, chunk := range chunks {
- for i := 0; i < len(chunk); i++ {
- if ii >= cap(buffer) {
- break
- }
- buffer[ii] = chunk[i]
- ii++
- }
- }
- return buffer[:ii]
-}
-
-// toLower transforms the input string to lower case, which is stored in the output byte slice.
-// The lower casing considers only ASCII values - non ASCII values are left unmodified.
-// Stops when parsed all input or when it filled the output slice. If output is nil, then it gets
-// created.
-func toLower(input []byte, reuse []byte) []byte {
- output := reuse
- if cap(reuse) < len(input) {
- output = make([]byte, len(input))
- }
-
- for i := 0; i < len(input); i++ {
- r := rune(input[i])
- if input[i] <= unicode.MaxASCII {
- if 'A' <= r && r <= 'Z' {
- r += 'a' - 'A'
- }
- }
- output[i] = byte(r)
- }
- return output[:len(input)]
-}
-
-// WordConsumer defines a consumer for a word delimited by the [start,end) byte offsets in an input
-// (start is inclusive, end is exclusive).
-type WordConsumer func(start, end int)
-
-// Words find word delimiters in an input based on its bytes' mappings to rune roles. The offset
-// delimiters for each word are fed to the provided consumer function.
-func Words(roles []RuneRole, consume WordConsumer) {
- var wordStart int
- for i, r := range roles {
- switch r {
- case RUCTail, RTail:
- case RHead, RNone, RSep:
- if i != wordStart {
- consume(wordStart, i)
- }
- wordStart = i
- if r != RHead {
- // Skip this character.
- wordStart = i + 1
- }
- }
- }
- if wordStart != len(roles) {
- consume(wordStart, len(roles))
- }
-}