/// <summary> /// ON events /// </summary> /// <param name="pars"></param> public void Visit(ParsedOnStatement pars) { // To code explorer PushToCodeExplorer( GetExplorerListNode("ON events", CodeExplorerIconType.OnEvent), new OnEventCodeItem { DisplayText = pars.Name, Flags = pars.Flags, SubText = null, DocumentOwner = pars.FilePath, GoToLine = pars.Line, GoToColumn = pars.Column }); }
/// <summary> /// ON events /// </summary> /// <param name="pars"></param> public void Visit(ParsedOnStatement pars) { // check lenght of block pars.TooLongForAppbuilder = HasTooMuchChar(pars.Line, pars.EndBlockLine); // To code explorer _parsedExplorerItemsList.Add(new CodeExplorerItem { DisplayText = pars.Name, Branch = CodeExplorerBranch.OnEvent, Flag = AddExternalFlag(pars.TooLongForAppbuilder ? CodeExplorerFlag.IsTooLong : 0), DocumentOwner = pars.FilePath, GoToLine = pars.Line, GoToColumn = pars.Column, SubString = SetExternalInclude(pars.TooLongForAppbuilder ? BlockTooLongString + " (+" + NbExtraCharBetweenLines(pars.Line, pars.EndBlockLine) + ")" : null) }); }
/// <summary> /// Creates parsed item for ON CHOOSE OF XXX events /// (choose or anything else) /// </summary> /// <param name="onToken"></param> /// <returns></returns> private void CreateParsedOnEvent(Token onToken) { // info we will extract from the current statement : var widgetList = new StringBuilder(); var eventList = new StringBuilder(); int state = 0; do { var token = PeekAt(1); // next token if (token is TokenEos) break; if (token is TokenComment) continue; switch (state) { case 0: // matching event type if (!(token is TokenWord) && !(token is TokenString)) break; eventList.Append((eventList.Length == 0 ? "" : ", ") + GetTokenStrippedValue(token)); state++; break; case 1: // matching "of" if (token is TokenSymbol && token.Value.Equals(",")) { state--; break; } if (!(token is TokenWord)) break; if (token.Value.EqualsCi("anywhere")) { // we match anywhere, need to return to match a block start widgetList.Append("anywhere"); var new1 = new ParsedOnStatement(eventList + " " + widgetList, onToken, eventList.ToString(), widgetList.ToString()); AddParsedItem(new1); _context.Scope = new1; return; } // if not anywhere, we expect an "of" if (token.Value.EqualsCi("of")) { state++; break; } // otherwise, return return; case 2: // matching widget name if (token is TokenWord || token is TokenInclude || token is TokenString) { widgetList.Append((widgetList.Length == 0 ? "" : ", ") + GetTokenStrippedValue(token)); // we can match several widget name separated by a comma or resume to next state var nextNonSpace = PeekAtNextNonSpace(1); if (!(nextNonSpace is TokenSymbol && nextNonSpace.Value.Equals(","))) state++; } break; case 3: // matching "or", create another parsed item, otherwise leave to match a block start if (!(token is TokenWord)) break; var new2 = new ParsedOnStatement(eventList + " " + widgetList, onToken, eventList.ToString(), widgetList.ToString()); AddParsedItem(new2); _context.Scope = new2; if (token.Value.EqualsCi("or")) { state = 0; widgetList.Clear(); eventList.Clear(); } else return; break; } } while (MoveNext()); }