protected override NativeXAnalyzingResult Calculate(string input) { NativeXAnalyzingResult result = new NativeXAnalyzingResult(); result.IdTokens = new Dictionary<int, List<CodeToken>>(); List<CodeToken> tokens = NativeXCodeParser.Tokenize(input.ToCharArray()); int lastRow = -1; List<CodeToken> lastLines = null; for (int i = 0; i < tokens.Count; i++) { CodeToken token = tokens[i]; if (token.Id == NativeXTokenizer.IdToken) { int row = token.Start.row; if (row != lastRow) { lastLines = new List<CodeToken>(); result.IdTokens.Add(row, lastLines); lastRow = row; } lastLines.Add(token); } } int currentToken = 0; bool parseSuccess = false; result.Unit = NativeXCodeParser.ParseUnit(tokens, ref currentToken, ref parseSuccess); if (result.Unit != null) { result.Unit.BuildScope(null); } result.Unit.OwningScope.ExtraScopes = this.headers.PredifinedHeaders.Select(u => u.OwningScope).ToArray(); return result; }
public override Token getToken() { CodeToken token = new CodeToken(); token.setValue(sbCode.ToString()); token.setType(TokenType.Code); return(token); }
private void InjectId(ref CodeToken token) { if (Array.BinarySearch(NormalKeywords, token.Value) >= 0) { token.Id = NormalKeywordToken; } else if (Array.BinarySearch(TypedKeywords, token.Value) >= 0) { token.Id = TypeKeywordToken; } }
public string AddCode(CodeTokenType type, int clientId, string userName, string scope) { using (var entities = IdentityServerConfigurationContext.Get()) { var code = Guid.NewGuid().ToString("N"); var refreshToken = new CodeToken { Type = (int)type, Code = code, ClientId = clientId, Scope = scope, UserName = userName, TimeStamp = DateTime.UtcNow }; entities.CodeTokens.Add(refreshToken); entities.SaveChanges(); return code; } }
public virtual string OnGetSimpleTooltip(TextPosition pos) { if (this.EditingObserverExtension.AnalyzingResult == null || this.EditingObserverExtension.AnalyzingResult.Unit == null) { return(null); } NativeXNode node = this.EditingObserverExtension.AnalyzingResult.Unit.FindDeepest <NativeXNode>(pos); NativeXNode hint = null; { NativeXReferenceExpression exp = node as NativeXReferenceExpression; if (exp != null && exp.Scope != null) { hint = (NativeXNode)exp.Scope.Find(exp.ReferencedName); goto SHOW_HINT; } } { NativeXReferenceType type = node as NativeXReferenceType; if (type != null && type.Scope != null) { hint = (NativeXNode)type.Scope.Find(type.ReferencedName); goto SHOW_HINT; } } { NativeXConceptReference concept = node as NativeXConceptReference; if (concept != null && concept.Scope != null) { hint = (NativeXNode)concept.Scope.Find(concept.ReferenceName); goto SHOW_HINT; } } { NativeXInstanciatedExpression exp = node as NativeXInstanciatedExpression; if (exp != null && exp.Scope != null) { hint = (NativeXNode)exp.Scope.Find(exp.ReferencedName); goto SHOW_HINT; } } { NativeXInstanceFunctionExpression exp = node as NativeXInstanceFunctionExpression; if (exp != null && exp.Scope != null && exp.ConceptName != null) { hint = (NativeXNode)exp.Scope.Find(exp.ConceptName.ReferenceName); goto SHOW_HINT; } } { NativeXInstanceDeclaration inst = node as NativeXInstanceDeclaration; if (inst != null && inst.Scope != null && inst.ConceptName != null) { if (this.EditingObserverExtension.AnalyzingResult.IdTokens.ContainsKey(pos.row)) { CodeToken token = this.EditingObserverExtension.AnalyzingResult.IdTokens[pos.row].Where(t => t.Start <= pos && pos <= t.End).FirstOrDefault(); if (token.Value == inst.ConceptName.ReferenceName) { hint = (NativeXNode)inst.Scope.Find(inst.ConceptName.ReferenceName); } } } } { NativeXGenericConstraint genecons = node as NativeXGenericConstraint; if (genecons != null && genecons.Scope != null && genecons.ConceptName != null) { if (this.EditingObserverExtension.AnalyzingResult.IdTokens.ContainsKey(pos.row)) { CodeToken token = this.EditingObserverExtension.AnalyzingResult.IdTokens[pos.row].Where(t => t.Start <= pos && pos <= t.End).FirstOrDefault(); if (token.Value == genecons.ConceptName.ReferenceName) { hint = (NativeXNode)genecons.Scope.Find(genecons.ConceptName.ReferenceName); } } } } SHOW_HINT: if (hint != null) { NativeXFunctionDeclaration function = hint as NativeXFunctionDeclaration; TextPosition start, end; if (function == null) { start = hint.Start; end = hint.End; } else { start = hint.Start; end = function.Statement == null ? function.End : function.Statement.Start; } if (start < end) { start = this.Callback.TextEditorBox.Controller.Normalize(start); end = this.Callback.TextEditorBox.Controller.Normalize(end); string text = this.Callback.TextEditorBox.TextProvider.GetString(start, end); if (!string.IsNullOrWhiteSpace(text)) { return(text); } } } return(null); }
public SSExpression(CodeToken tok, SSExpression parent) { this.Token = tok; this.Parent = parent; this.Children = new List <SSExpression>(6); }