How to use line method of lang Package

Best Gauge code snippet using lang.line

lang.go

Source:lang.go Github

copy

Full Screen

1//line lang.y:22package myrmidon3import __yyfmt__ "fmt"4//line lang.y:35import (6 "github.com/marcopeereboom/gck/ast"7 "math/big"8)9var d *yylexer // being set so we don't have to type assert all the time10//line lang.y:1411type yySymType struct {12 yys int13 integer int14 number *big.Rat15 identifier string16 node ast.Node17}18const PROGRAM = 5734619const INTEGER = 5734720const IDENTIFIER = 5734821const VAR = 5734922const CONST = 5735023const FUNC = 5735124const NUMBER = 5735225const WHILE = 5735326const IF = 5735427const ELSE = 5735528const EOL = 5735629const ASSIGN = 5735730const LE = 5735831const GE = 5735932const NE = 5736033const EQ = 5736134const LT = 5736235const GT = 5736336const UMINUS = 5736437var yyToknames = []string{38 "PROGRAM",39 "INTEGER",40 "IDENTIFIER",41 "VAR",42 "CONST",43 "FUNC",44 "NUMBER",45 "WHILE",46 "IF",47 "ELSE",48 "EOL",49 "ASSIGN",50 "LE",51 "GE",52 "NE",53 "EQ",54 "LT",55 "GT",56 "'+'",57 "'-'",58 "'*'",59 "'/'",60 "UMINUS",61}62var yyStatenames = []string{}63const yyEofCode = 164const yyErrCode = 265const yyMaxDepth = 20066//line lang.y:12367//line yacctab:168var yyExca = []int{69 -1, 1,70 1, -1,71 -2, 0,72}73const yyNprod = 4074const yyPrivate = 5734475var yyTokenNames []string76var yyStates []string77const yyLast = 13778var yyAct = []int{79 20, 19, 16, 41, 70, 32, 33, 34, 35, 49,80 63, 11, 55, 56, 57, 58, 53, 54, 32, 33,81 34, 35, 10, 8, 37, 9, 12, 51, 38, 40,82 42, 42, 44, 7, 62, 45, 46, 47, 48, 36,83 50, 14, 52, 34, 35, 61, 60, 59, 32, 33,84 34, 35, 72, 31, 4, 29, 64, 65, 66, 67,85 68, 69, 22, 24, 6, 28, 1, 23, 27, 28,86 22, 24, 21, 73, 74, 23, 27, 28, 2, 3,87 25, 12, 5, 17, 15, 12, 30, 26, 25, 22,88 39, 71, 15, 12, 23, 26, 32, 33, 34, 35,89 18, 22, 39, 13, 0, 51, 23, 25, 32, 33,90 34, 35, 0, 0, 26, 0, 0, 0, 0, 25,91 0, 0, 0, 0, 0, 0, 43, 55, 56, 57,92 58, 53, 54, 32, 33, 34, 35,93}94var yyPact = []int{95 45, -1000, 45, -1000, 58, -1000, 3, -8, -5, -9,96 -2, -1000, 65, 57, -1000, -1000, 26, -1000, -1000, -1000,97 -1000, -1000, -1000, -1000, 9, 84, 84, 96, 96, -1000,98 -1000, -1000, 84, 84, 84, 84, -22, 84, -1000, -1000,99 74, -2, 111, 96, -2, 19, 19, -1000, -1000, 7,100 -17, -1000, -1000, 84, 84, 84, 84, 84, 84, -27,101 -4, 39, -1000, -1000, 86, 86, 86, 86, 86, 86,102 -1000, -1000, 53, -1000, -1000,103}104var yyPgo = []int{105 0, 41, 103, 2, 3, 100, 1, 91, 0, 83,106 79, 78, 72, 66,107}108var yyR1 = []int{109 0, 13, 11, 11, 1, 1, 1, 1, 1, 1,110 1, 2, 2, 2, 8, 12, 10, 9, 9, 5,111 6, 7, 7, 7, 4, 4, 4, 4, 4, 4,112 4, 3, 3, 3, 3, 3, 3, 3, 3, 3,113}114var yyR2 = []int{115 0, 1, 1, 2, 1, 2, 1, 1, 1, 1,116 1, 0, 1, 2, 3, 4, 7, 4, 1, 3,117 4, 0, 2, 2, 3, 3, 3, 3, 3, 3,118 3, 1, 1, 1, 2, 3, 3, 3, 3, 3,119}120var yyChk = []int{121 -1000, -13, -11, -10, 9, -10, 6, 30, 31, 30,122 31, -8, 28, -2, -1, 27, -3, -9, -5, -6,123 -8, -12, 5, 10, 6, 23, 30, 11, 12, -1,124 29, 27, 22, 23, 24, 25, 30, 15, -3, 6,125 -3, -4, -3, 30, -4, -3, -3, -3, -3, 31,126 -3, 31, -8, 20, 21, 16, 17, 18, 19, -4,127 -3, -8, 27, 27, -3, -3, -3, -3, -3, -3,128 31, -7, 13, -8, -6,129}130var yyDef = []int{131 0, -2, 1, 2, 0, 3, 0, 0, 0, 0,132 0, 16, 11, 0, 12, 4, 0, 6, 7, 8,133 9, 10, 31, 32, 33, 0, 0, 0, 0, 13,134 14, 5, 0, 0, 0, 0, 0, 0, 34, 33,135 0, 0, 0, 0, 0, 35, 36, 37, 38, 0,136 0, 39, 19, 0, 0, 0, 0, 0, 0, 0,137 0, 21, 15, 17, 24, 25, 26, 27, 28, 29,138 30, 20, 0, 22, 23,139}140var yyTok1 = []int{141 1, 3, 3, 3, 3, 3, 3, 3, 3, 3,142 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,143 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,144 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,145 30, 31, 24, 22, 3, 23, 3, 25, 3, 3,146 3, 3, 3, 3, 3, 3, 3, 3, 3, 27,147 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,148 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,149 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,150 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,151 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,152 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,153 3, 3, 3, 28, 3, 29,154}155var yyTok2 = []int{156 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,157 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,158 26,159}160var yyTok3 = []int{161 0,162}163//line yaccpar:1164/* parser for yacc output */165var yyDebug = 0166type yyLexer interface {167 Lex(lval *yySymType) int168 Error(s string)169}170const yyFlag = -1000171func yyTokname(c int) string {172 // 4 is TOKSTART above173 if c >= 4 && c-4 < len(yyToknames) {174 if yyToknames[c-4] != "" {175 return yyToknames[c-4]176 }177 }178 return __yyfmt__.Sprintf("tok-%v", c)179}180func yyStatname(s int) string {181 if s >= 0 && s < len(yyStatenames) {182 if yyStatenames[s] != "" {183 return yyStatenames[s]184 }185 }186 return __yyfmt__.Sprintf("state-%v", s)187}188func yylex1(lex yyLexer, lval *yySymType) int {189 c := 0190 char := lex.Lex(lval)191 if char <= 0 {192 c = yyTok1[0]193 goto out194 }195 if char < len(yyTok1) {196 c = yyTok1[char]197 goto out198 }199 if char >= yyPrivate {200 if char < yyPrivate+len(yyTok2) {201 c = yyTok2[char-yyPrivate]202 goto out203 }204 }205 for i := 0; i < len(yyTok3); i += 2 {206 c = yyTok3[i+0]207 if c == char {208 c = yyTok3[i+1]209 goto out210 }211 }212out:213 if c == 0 {214 c = yyTok2[1] /* unknown char */215 }216 if yyDebug >= 3 {217 __yyfmt__.Printf("lex %s(%d)\n", yyTokname(c), uint(char))218 }219 return c220}221func yyParse(yylex yyLexer) int {222 var yyn int223 var yylval yySymType224 var yyVAL yySymType225 yyS := make([]yySymType, yyMaxDepth)226 Nerrs := 0 /* number of errors */227 Errflag := 0 /* error recovery flag */228 yystate := 0229 yychar := -1230 yyp := -1231 goto yystack232ret0:233 return 0234ret1:235 return 1236yystack:237 /* put a state and value onto the stack */238 if yyDebug >= 4 {239 __yyfmt__.Printf("char %v in %v\n", yyTokname(yychar), yyStatname(yystate))240 }241 yyp++242 if yyp >= len(yyS) {243 nyys := make([]yySymType, len(yyS)*2)244 copy(nyys, yyS)245 yyS = nyys246 }247 yyS[yyp] = yyVAL248 yyS[yyp].yys = yystate249yynewstate:250 yyn = yyPact[yystate]251 if yyn <= yyFlag {252 goto yydefault /* simple state */253 }254 if yychar < 0 {255 yychar = yylex1(yylex, &yylval)256 }257 yyn += yychar258 if yyn < 0 || yyn >= yyLast {259 goto yydefault260 }261 yyn = yyAct[yyn]262 if yyChk[yyn] == yychar { /* valid shift */263 yychar = -1264 yyVAL = yylval265 yystate = yyn266 if Errflag > 0 {267 Errflag--268 }269 goto yystack270 }271yydefault:272 /* default state action */273 yyn = yyDef[yystate]274 if yyn == -2 {275 if yychar < 0 {276 yychar = yylex1(yylex, &yylval)277 }278 /* look through exception table */279 xi := 0280 for {281 if yyExca[xi+0] == -1 && yyExca[xi+1] == yystate {282 break283 }284 xi += 2285 }286 for xi += 2; ; xi += 2 {287 yyn = yyExca[xi+0]288 if yyn < 0 || yyn == yychar {289 break290 }291 }292 yyn = yyExca[xi+1]293 if yyn < 0 {294 goto ret0295 }296 }297 if yyn == 0 {298 /* error ... attempt to resume parsing */299 switch Errflag {300 case 0: /* brand new error */301 yylex.Error("syntax error")302 Nerrs++303 if yyDebug >= 1 {304 __yyfmt__.Printf("%s", yyStatname(yystate))305 __yyfmt__.Printf(" saw %s\n", yyTokname(yychar))306 }307 fallthrough308 case 1, 2: /* incompletely recovered error ... try again */309 Errflag = 3310 /* find a state where "error" is a legal shift action */311 for yyp >= 0 {312 yyn = yyPact[yyS[yyp].yys] + yyErrCode313 if yyn >= 0 && yyn < yyLast {314 yystate = yyAct[yyn] /* simulate a shift of "error" */315 if yyChk[yystate] == yyErrCode {316 goto yystack317 }318 }319 /* the current p has no shift on "error", pop stack */320 if yyDebug >= 2 {321 __yyfmt__.Printf("error recovery pops state %d\n", yyS[yyp].yys)322 }323 yyp--324 }325 /* there is no state on the stack with an error shift ... abort */326 goto ret1327 case 3: /* no shift yet; clobber input char */328 if yyDebug >= 2 {329 __yyfmt__.Printf("error recovery discards %s\n", yyTokname(yychar))330 }331 if yychar == yyEofCode {332 goto ret1333 }334 yychar = -1335 goto yynewstate /* try again in the same state */336 }337 }338 /* reduction by production yyn */339 if yyDebug >= 2 {340 __yyfmt__.Printf("reduce %v in:\n\t%v\n", yyn, yyStatname(yystate))341 }342 yynt := yyn343 yypt := yyp344 _ = yypt // guard against "declared and not used"345 yyp -= yyR2[yyn]346 yyVAL = yyS[yyp+1]347 /* consult goto table to find next state */348 yyn = yyR1[yyn]349 yyg := yyPgo[yyn]350 yyj := yyg + yyS[yyp].yys + 1351 if yyj >= yyLast {352 yystate = yyAct[yyg]353 } else {354 yystate = yyAct[yyj]355 if yyChk[yystate] != -yyn {356 yystate = yyAct[yyg]357 }358 }359 // dummy call; replaced with literal code360 switch yynt {361 case 1:362 //line lang.y:49363 {364 d.tree = yyS[yypt-0].node365 }366 case 2:367 //line lang.y:53368 {369 yyVAL.node = yyS[yypt-0].node370 }371 case 3:372 //line lang.y:54373 {374 yyVAL.node = ast.NewOperand(d.d(), ast.Eos, yyS[yypt-1].node, yyS[yypt-0].node)375 }376 case 4:377 //line lang.y:58378 {379 yyVAL.node = ast.NewOperand(d.d(), ast.Eos)380 }381 case 5:382 //line lang.y:59383 {384 yyVAL.node = yyS[yypt-1].node385 }386 case 6:387 //line lang.y:60388 {389 yyVAL.node = yyS[yypt-0].node390 }391 case 7:392 //line lang.y:61393 {394 yyVAL.node = yyS[yypt-0].node395 }396 case 8:397 //line lang.y:62398 {399 yyVAL.node = yyS[yypt-0].node400 }401 case 9:402 //line lang.y:63403 {404 yyVAL.node = yyS[yypt-0].node405 }406 case 10:407 //line lang.y:64408 {409 yyVAL.node = yyS[yypt-0].node410 }411 case 11:412 //line lang.y:68413 {414 yyVAL.node = ast.NewOperand(d.d(), ast.Eos)415 }416 case 12:417 //line lang.y:69418 {419 yyVAL.node = yyS[yypt-0].node420 }421 case 13:422 //line lang.y:70423 {424 yyVAL.node = ast.NewOperand(d.d(), ast.Eos, yyS[yypt-1].node, yyS[yypt-0].node)425 }426 case 14:427 //line lang.y:74428 {429 yyVAL.node = yyS[yypt-1].node430 }431 case 15:432 //line lang.y:78433 {434 yyVAL.node = ast.NewOperand(d.d(), ast.FunctionCall, ast.NewIdentifier(nil, yyS[yypt-3].identifier))435 }436 case 16:437 //line lang.y:82438 {439 yyVAL.node = ast.NewOperand(d.d(), ast.Function, ast.NewIdentifier(nil, yyS[yypt-5].identifier), yyS[yypt-0].node)440 }441 case 17:442 //line lang.y:86443 {444 yyVAL.node = ast.NewOperand(d.d(), ast.Assign, ast.NewIdentifier(nil, yyS[yypt-3].identifier), yyS[yypt-1].node)445 }446 case 18:447 //line lang.y:87448 {449 yyVAL.node = yyS[yypt-0].node450 }451 case 19:452 //line lang.y:91453 {454 yyVAL.node = ast.NewOperand(d.d(), ast.While, yyS[yypt-1].node, yyS[yypt-0].node)455 }456 case 20:457 //line lang.y:94458 {459 yyVAL.node = ast.NewOperand(d.d(), ast.If, yyS[yypt-2].node, yyS[yypt-1].node, yyS[yypt-0].node)460 }461 case 21:462 //line lang.y:97463 {464 yyVAL.node = ast.NewOperand(d.d(), ast.Eos)465 }466 case 22:467 //line lang.y:98468 {469 yyVAL.node = yyS[yypt-0].node470 }471 case 23:472 //line lang.y:99473 {474 yyVAL.node = yyS[yypt-0].node475 }476 case 24:477 //line lang.y:103478 {479 yyVAL.node = ast.NewOperand(d.d(), ast.Lt, yyS[yypt-2].node, yyS[yypt-0].node)480 }481 case 25:482 //line lang.y:104483 {484 yyVAL.node = ast.NewOperand(d.d(), ast.Gt, yyS[yypt-2].node, yyS[yypt-0].node)485 }486 case 26:487 //line lang.y:105488 {489 yyVAL.node = ast.NewOperand(d.d(), ast.Le, yyS[yypt-2].node, yyS[yypt-0].node)490 }491 case 27:492 //line lang.y:106493 {494 yyVAL.node = ast.NewOperand(d.d(), ast.Ge, yyS[yypt-2].node, yyS[yypt-0].node)495 }496 case 28:497 //line lang.y:107498 {499 yyVAL.node = ast.NewOperand(d.d(), ast.Ne, yyS[yypt-2].node, yyS[yypt-0].node)500 }501 case 29:502 //line lang.y:108503 {504 yyVAL.node = ast.NewOperand(d.d(), ast.Eq, yyS[yypt-2].node, yyS[yypt-0].node)505 }506 case 30:507 //line lang.y:109508 {509 yyVAL.node = yyS[yypt-1].node510 }511 case 31:512 //line lang.y:113513 {514 yyVAL.node = ast.NewInteger(d.d(), yyS[yypt-0].integer)515 }516 case 32:517 //line lang.y:114518 {519 yyVAL.node = ast.NewNumber(d.d(), yyS[yypt-0].number)520 }521 case 33:522 //line lang.y:115523 {524 yyVAL.node = ast.NewIdentifier(d.d(), yyS[yypt-0].identifier)525 }526 case 34:527 //line lang.y:116528 {529 yyVAL.node = ast.NewOperand(d.d(), ast.Uminus, yyS[yypt-0].node)530 }531 case 35:532 //line lang.y:117533 {534 yyVAL.node = ast.NewOperand(d.d(), ast.Add, yyS[yypt-2].node, yyS[yypt-0].node)535 }536 case 36:537 //line lang.y:118538 {539 yyVAL.node = ast.NewOperand(d.d(), ast.Sub, yyS[yypt-2].node, yyS[yypt-0].node)540 }541 case 37:542 //line lang.y:119543 {544 yyVAL.node = ast.NewOperand(d.d(), ast.Mul, yyS[yypt-2].node, yyS[yypt-0].node)545 }546 case 38:547 //line lang.y:120548 {549 yyVAL.node = ast.NewOperand(d.d(), ast.Div, yyS[yypt-2].node, yyS[yypt-0].node)550 }551 case 39:552 //line lang.y:121553 {554 yyVAL.node = yyS[yypt-1].node555 }556 }557 goto yystack /* stack new state and value */558}...

Full Screen

Full Screen

Data_inputs.go

Source:Data_inputs.go Github

copy

Full Screen

...19const (20 naturalWindowPct = 0.7521 minNatural = 5022 curatedDistance = 2023 lineLogSize = 2024)25var (26 lineLogs = make(map[lang.Language]*lru.Cache)27 logMutex = new(sync.RWMutex)28)29// Reset clears all state30func Reset() {31 logMutex.Lock()32 defer logMutex.Unlock()33 for _, v := range lineLogs {34 v.Purge()35 }36}37// ResetLanguage clears state, which belongs to a given language38func ResetLanguage(language lang.Language) {39 logMutex.Lock()40 defer logMutex.Unlock()41 for k, v := range lineLogs {42 if k == language {43 v.Purge()44 }45 }46}47// Global contains resources that are specific to a file, but are not tied to a specific Buffer (i.e. file contents)48type Global struct {49 UserID int6450 MachineID string51 FilePath string52 Models *lexicalmodels.Models53 EditorEvents []*component.EditorEvent54 Product licensing.ProductGetter55}56type pathLine struct {57 language lang.Language58 path string59 line int60 tokens []lexer.Token61}62func newPathLine(raw, path string, line int, langLexer lexer.Lexer) (pathLine, error) {63 lexed, err := langLexer.Lex([]byte(raw))64 if err != nil {65 return pathLine{}, err66 }67 if len(lexed) > 0 && langLexer.IsType(lexer.EOF, lexed[len(lexed)-1]) {68 lexed = lexed[:len(lexed)-1]69 }70 return pathLine{71 language: lang.FromFilename(path),72 path: path,73 line: line,74 tokens: lexed,75 }, nil76}77func (pl pathLine) key() string {78 return pl.path + "#L" + strconv.Itoa(pl.line)79}80// Inputs encapsulates parsed/analyzed inputs to a Provider81type Inputs struct {82 data.SelectedBuffer83 Model lexicalmodels.ModelBase84 Lexer lexer.Lexer85 Tokens []lexer.Token86 PrecededBySpace bool87 LineContext []lexer.Token88 LastTokenIdx int89 PredictInputs predict.Inputs90 LangGroup lexicalv0.LangGroup91}92// NewInputs computes inputs from a SelectedBuffer93func NewInputs(ctx kitectx.Context, g Global, b data.SelectedBuffer, allowValueMutation bool) (Inputs, error) {94 originalLang := lang.FromFilename(g.FilePath)95 inputLang := lexicalmodels.LanguageGroupDeprecated(originalLang)96 var model lexicalmodels.ModelBase97 var langGroup lexicalv0.LangGroup98 switch {99 case lexicalv0.MiscLangsGroup.Contains(originalLang):100 model = g.Models.TextMiscGroup101 langGroup = lexicalv0.MiscLangsGroup102 case lexicalv0.WebGroup.Contains(originalLang):103 model = g.Models.TextWebGroup104 langGroup = lexicalv0.WebGroup105 case lexicalv0.JavaPlusPlusGroup.Contains(originalLang):106 model = g.Models.TextJavaGroup107 langGroup = lexicalv0.JavaPlusPlusGroup108 case lexicalv0.CStyleGroup.Contains(originalLang):109 model = g.Models.TextCGroup110 langGroup = lexicalv0.CStyleGroup111 default:112 return Inputs{}, errors.Errorf("unsupported language: %s, %s", inputLang.Name(), g.FilePath)113 }114 langLexer := model.GetLexer()115 tokens, err := lexicalv0.LexSelectedBuffer(b, originalLang, langLexer)116 if err != nil {117 return Inputs{}, err118 }119 cursorContext, err := lexicalv0.FindContext(b, tokens, langLexer)120 if err != nil {121 return Inputs{}, err122 }123 lines, err := encodeEvents(langLexer, g.EditorEvents)124 if err != nil {125 return Inputs{}, err126 }127 updateLog(lines)128 raw, number := extractLine(b.Text(), b.Selection.End)129 line, err := newPathLine(raw, g.FilePath, number, langLexer)130 if err != nil {131 return Inputs{}, err132 }133 curateContextLang := langLexer.Lang()134 if curateContextLang == lang.Text {135 curateContextLang = originalLang136 }137 predictInputs := predict.Inputs{138 FilePath: g.FilePath,139 Prefix: cursorContext.Prefix,140 Tokens: tokens,141 Buffer: b,142 CursorTokenIdx: cursorContext.LastTokenIdx + 1,143 RandomSeed: randSeed(b),144 Events: curateContext(line, curateContextLang),145 }146 inputs := Inputs{147 SelectedBuffer: b,148 Model: model,149 Lexer: langLexer,150 Tokens: tokens,151 PrecededBySpace: cursorContext.PrecededBySpace,152 LineContext: cursorContext.LineContext,153 LastTokenIdx: cursorContext.LastTokenIdx,154 PredictInputs: predictInputs,155 LangGroup: langGroup,156 }157 return inputs, nil158}159func encodeEvents(langLexer lexer.Lexer, events []*component.EditorEvent) ([]pathLine, error) {160 var lines []pathLine161 for _, event := range events {162 for _, selection := range event.Selections {163 raw, number := extractLines(event.Text, int(selection.Start), int(selection.End))164 for i := range raw {165 line, err := newPathLine(raw[i], event.Filename, number[i], langLexer)166 if err != nil {167 return nil, err168 }169 lines = append(lines, line)170 }171 }172 }173 return lines, nil174}175func updateLog(lines []pathLine) {176 logMutex.Lock()177 defer logMutex.Unlock()178 for _, line := range lines {179 lineLog, ok := lineLogs[line.language]180 if !ok {181 var err error182 lineLog, err = lru.New(lineLogSize)183 if err != nil {184 log.Fatal(err)185 }186 lineLogs[line.language] = lineLog187 }188 lineLog.Add(line.key(), line)189 }190}191func curateContext(current pathLine, language lang.Language) []predict.EditorEvent {192 logMutex.RLock()193 defer logMutex.RUnlock()194 lineLog, ok := lineLogs[language]195 if !ok {196 return nil197 }198 var curated []predict.EditorEvent199 for _, key := range lineLog.Keys() {200 peeked, ok := lineLog.Peek(key)201 if !ok {202 continue203 }204 line := peeked.(pathLine)205 if useLine(line, current) {206 curated = append(curated, predict.EditorEvent{Tokens: line.tokens})207 }208 }209 return curated210}211func useLine(line, current pathLine) bool {212 if line.language != current.language {213 return false214 }215 if line.path != current.path {216 return true217 }218 if line.line > current.line {219 return true220 }221 if line.line < current.line-curatedDistance {222 return true223 }224 return false225}226func extractLines(text string, start, end int) ([]string, []int) {227 lo := strings.Count(text[:start], "\n")228 hi := strings.Count(text[:end], "\n")229 split := strings.Split(text, "\n")230 var lines []string231 var numbers []int232 for number := lo; number <= hi; number++ {233 // NOTE: In some cases, curating context works better when234 // lines have an automatic semicolon appended to them.235 // It seems complicated to figure out the best treatment236 // for various cases in different languages,237 // so instead we add a new line to the raw code and hope the238 // encoder does something reasonable in most cases.239 lines = append(lines, split[number]+"\n")240 numbers = append(numbers, number)241 }242 return lines, numbers243}244func extractLine(text string, end int) (string, int) {245 number := strings.Count(text[:end], "\n")246 line := strings.Split(text, "\n")[number] + "\n"247 return line, number248}249func randSeed(sb data.SelectedBuffer) int64 {250 // We take the lower 63 bits of the hash of a partial buffer.251 // We use a partial buffer that does not contain the cursor line.252 // This way the seed doesn't change on every keystroke.253 beforeCursor := data.Selection{254 Begin: 0,255 End: sb.Selection.Begin,256 }257 textBeforeCursor := sb.Buffer.TextAt(beforeCursor)258 cut := strings.LastIndex(textBeforeCursor, "\n") + 1259 partialBuffer := data.NewBuffer(textBeforeCursor[:cut])260 return int64((^uint64(1 << 63)) & partialBuffer.Hash().Hash64())261}...

Full Screen

Full Screen

line

Using AI Code Generation

copy

Full Screen

1lang line = new lang();2line.line();3lang square = new lang();4square.square();5lang triangle = new lang();6triangle.triangle();7lang rectangle = new lang();8rectangle.rectangle();9lang circle = new lang();10circle.circle();11lang cube = new lang();12cube.cube();13lang parallelogram = new lang();14parallelogram.parallelogram();15lang sphere = new lang();16sphere.sphere();17lang cylinder = new lang();18cylinder.cylinder();19lang cone = new lang();20cone.cone();21lang pyramid = new lang();22pyramid.pyramid();23lang prism = new lang();24prism.prism();25lang cylinder = new lang();26cylinder.cylinder();27lang cone = new lang();28cone.cone();29lang pyramid = new lang();30pyramid.pyramid();31lang prism = new lang();32prism.prism();33lang cylinder = new lang();34cylinder.cylinder();35lang cone = new lang();36cone.cone();37lang pyramid = new lang();38pyramid.pyramid();39lang prism = new lang();40prism.prism();41lang cylinder = new lang();42cylinder.cylinder();43lang cone = new lang();44cone.cone();45lang pyramid = new lang();46pyramid.pyramid();47lang prism = new lang();48prism.prism();49}

Full Screen

Full Screen

line

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println("Hello World")4}5import "fmt"6func main() {7 fmt.Println("Hello World")8}9import "fmt"10func main() {11 fmt.Println("Hello World")12}13import "fmt"14func main() {15 fmt.Println("Hello World")16}17import "fmt"18func main() {19 fmt.Println("Hello World")20}21import "fmt"22func main() {23 fmt.Println("Hello World")24}25import "fmt"26func main() {27 fmt.Println("Hello World")28}29import "fmt"30func main() {31 fmt.Println("Hello World")32}33import "fmt"34func main() {35 fmt.Println("Hello World")36}37import "fmt"38func main() {39 fmt.Println("Hello World")40}41import "fmt"42func main() {43 fmt.Println("Hello World")44}45import "fmt"46func main() {47 fmt.Println("Hello World")48}49import "fmt"50func main() {51 fmt.Println("Hello World")52}53import "fmt"54func main() {55 fmt.Println("Hello World")56}

Full Screen

Full Screen

line

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3fmt.Println("Hello World")4}5import "fmt"6func main() {7fmt.Println("Hello World")8}9import "fmt"10func main() {11fmt.Println("Hello World")12}13import "fmt"14func main() {15fmt.Println("Hello World")16}17import "fmt"18func main() {19fmt.Println("Hello World")20}21import "fmt"22func main() {23fmt.Println("Hello World")24}25import "fmt"26func main() {27fmt.Println("Hello World")28}29import "fmt"30func main() {31fmt.Println("Hello World")32}33import "fmt"34func main() {35fmt.Println("Hello World")36}37import "fmt"38func main() {39fmt.Println("Hello World")40}41import "fmt"42func main() {43fmt.Println("Hello World")44}45import "fmt"46func main() {47fmt.Println("Hello World")

Full Screen

Full Screen

line

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(lang.Line())4}5func Line() string {6}7import "testing"8func TestLine(t *testing.T) {9 if Line() != "Hello, World!" {10 t.Errorf("Line() = %q, want %q", Line(), "Hello, World!")11 }12}13--- PASS: TestLine (0.00s)14--- PASS: TestLine (0.00s)15--- PASS: TestLine (0.00s)16--- PASS: TestLine (0.00s)17--- PASS: TestLine (0.00s)18--- PASS: TestLine (0.00s)19--- PASS: TestLine (0.00s)20--- PASS: TestLine (0.00s)21--- PASS: TestLine (0.00s)

Full Screen

Full Screen

line

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 l.Set(1, 2, 3, 4)4 fmt.Println(l.Length())5}6import (7func main() {8 l.Set(1, 2, 3, 4)9 fmt.Println(l.Length())10}11type Line struct {12}13func (l Line) Length() float64 {14}15func (l *Line) Set(x1, y1, x2, y2 float64) {16}

Full Screen

Full Screen

line

Using AI Code Generation

copy

Full Screen

1import "fmt"2import "lang"3func main() {4 fmt.Println(lang.Line())5}6func Line() string {7}

Full Screen

Full Screen

line

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(strings.Count(s, "o"))4}5func Count(s, sep string) int6import (7func main() {8 fmt.Println(strings.Count(s, "l"))9}10import (11func main() {12 fmt.Println(strings.Count(s, "Hello"))13}14import (15func main() {16 fmt.Println(strings.Count(s, "World"))17}18import (19func main() {20 fmt.Println(strings.Count(s, "Hello, World!"))21}22import (23func main() {

Full Screen

Full Screen

line

Using AI Code Generation

copy

Full Screen

1lang.PrintLine("Hello World")2lang.PrintLine("Hello World")3lang.PrintLine("Hello World")4lang.PrintLine("Hello World")5lang.PrintLine("Hello World")6lang.PrintLine("Hello World")7lang.PrintLine("Hello World")8lang.PrintLine("Hello World")9lang.PrintLine("Hello World")10lang.PrintLine("Hello World")11lang.PrintLine("Hello World")12lang.PrintLine("Hello World")13lang.PrintLine("Hello World")14lang.PrintLine("

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Gauge automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful