internal override void RemoveChild(Node child) { if (_token_ == child) { _token_ = null; return; } }
public void SetToken(TDot node) { if (_token_ != null) { _token_.Parent(null); } if (node != null) { if (node.Parent() != null) { node.Parent().RemoveChild(node); } node.Parent(this); } _token_ = node; }
public ADotDotType( TDot _token_ ) { SetToken(_token_); }
public virtual void CaseTDot(TDot node) { DefaultCase(node); }
private bool ExtractMatchData(bool spacePressed = false) { currentRebuildData.targetEnrichments = new List<EnrichmentDescription>(); currentRebuildData.targetStructs = new List<StructDescription>(); currentRebuildData.namespacePrefixes = new List<NamespaceDescription>(); currentRebuildData.suggestArrayLength = false; currentRebuildData.onlySuggestVariablesInsideMethods = false; currentRebuildData.onlySuggestMethods = false; currentRebuildData.onlySuggestInitKeywords = false; currentRebuildData.onlySuggestDelegates = false; currentRebuildData.isDelegateInvoke = false; currentRebuildData.staticStructs = new List<StructDescription>(); currentRebuildData.isDynamicArray = false; currentRebuildData.targetTypedefs = new List<TypedefDescription>(); string text = currentEditor.GetTextWithin(new TextPoint(0, 0), currentEditor.caret.Position); //Last typed character must be an identifier letter or a . if (!spacePressed) if (text.Length == 0 || !(text[text.Length - 1] == '.' || text[text.Length - 1] == '>' || Util.IsIdentifierLetter(text[text.Length - 1]) || /*text[text.Length - 1] == '#' ||*/ text[text.Length - 1] > 0xFF)) return false; Lexer lexer = new Lexer(new StringReader(text)); List<Token> tokens = new List<Token>(); Token token, lastToken = null; bool inString = false; bool inEnum = false; while (true) { try { token = lexer.Next(); if (token is EOF) break; } catch (Exception err) { continue; } lastToken = token; if (token is TEnum) inEnum = true; if (token is TRBrace) inEnum = false; //We can be in a string if there was an unclosed " on this line if (token is TUnknown && token.Text == "\"" || token.Text == "'") inString = true; if (token is TWhiteSpace) { if (token.Text == "\n") inString = false; continue; } //If this is true, we have an open block comment with no end, so we're in a comment if (token is TCommentBegin) return false; if (token is TArrow) token = new TDot("."); tokens.Add(token); } if (inString) return false; if (inEnum) return false; if (spacePressed && (lastToken == null || !(lastToken is TDot || lastToken is TIdentifier))) tokens.Add(new TIdentifier("")); //The last entered token can either be an identifier, a dot, or a line comment token = tokens[tokens.Count - 1]; tokens.RemoveAt(tokens.Count - 1); if (token is TEndOfLineComment) return false; //Remove all other comments for (int i = 0; i < tokens.Count; i++) { if (tokens[i] is TTraditionalComment || tokens[i] is TEndOfLineComment || tokens[i] is TDocumentationComment) { tokens.RemoveAt(i); i--; } } //Set the current search text if (token is TDot) currentRebuildData.caseSensitiveMatchText = currentRebuildData.matchText = ""; else { currentRebuildData.matchText = token.Text.ToLower(); currentRebuildData.caseSensitiveMatchText = token.Text; } //If this token is a dot, or the previous is a dot, find the type of whats before the dot if (token is TIdentifier && tokens.Count > 0 && tokens[tokens.Count - 1] is TDot) { token = tokens[tokens.Count - 1]; tokens.RemoveAt(tokens.Count - 1); } bool isGlobal = false; if (token is TDot) { List<MethodDescription> delegateTargets; ExtractTargetType(text, out currentRebuildData.targetStructs, out currentRebuildData.targetEnrichments, out currentRebuildData.namespacePrefixes, out currentRebuildData.isDelegateInvoke, out currentRebuildData.staticStructs, out currentRebuildData.isGlobal, out delegateTargets, out currentRebuildData.isDynamicArray); /*MethodDescription methodDescription; currentRebuildData.targetStruct = GetTargetStruct(token, tokens, out isGlobal, out currentRebuildData.suggestArrayLength, out currentRebuildData.namespacePrefix, out currentRebuildData.isDelegateInvoke, out methodDescription, out currentRebuildData.staticStruct);*/ if (currentRebuildData.isDelegateInvoke) { currentRebuildData.suggestTypes = false; currentRebuildData.suggestVariables = false; currentRebuildData.suggestKeywords = false; return true; } if (tokens.Count > 2 && tokens[tokens.Count - 1] is TLt && (tokens[tokens.Count - 2] is TAsyncInvoke || tokens[tokens.Count - 2] is TSyncInvoke)) { currentRebuildData.onlySuggestMethods = true; } if (currentRebuildData.targetStructs.Count > 0 || currentRebuildData.staticStructs.Count > 0 || currentRebuildData.targetEnrichments.Count > 0 || currentRebuildData.suggestArrayLength) { currentRebuildData.suggestTypes = false; currentRebuildData.suggestVariables = true; currentRebuildData.suggestKeywords = false; return true; } if (currentRebuildData.isGlobal) { if (currentRebuildData.namespacePrefixes.Count > 0) //tokens.Clear(); { currentRebuildData.suggestKeywords = false; currentRebuildData.suggestTypes = true; currentRebuildData.suggestVariables = true; return true; } else { currentRebuildData.suggestKeywords = true; currentRebuildData.suggestTypes = true; currentRebuildData.suggestVariables = false; return true; } } if (currentRebuildData.namespacePrefixes.Count > 0) { currentRebuildData.suggestKeywords = false; currentRebuildData.suggestTypes = true; currentRebuildData.suggestVariables = true; return true; } if (currentRebuildData.isDynamicArray) return true; return false; } if (isGlobal || token is TIdentifier) { //Ensure that we are writing a type, expression or keyword /* * If no previous: decl * If previous was a string, and the one before that was include: includeDecl -> decl * If previous was a { } or a ;: stm -> stm, block->stm, fieldDecl->decl, structDecl->decl * If previous was a , + - * / % ! < > = == <= >= != += -= *= /= %= ( & | ^ && || << >> ): rightHandSide, methodParams, if -> stm */ if (tokens.Count == 0) { currentRebuildData.suggestKeywords = true; currentRebuildData.suggestTypes = true; currentRebuildData.suggestVariables = false; return true; } token = tokens[tokens.Count - 1]; tokens.RemoveAt(tokens.Count - 1); if (token is TIdentifier && tokens.Count > 0 && (tokens[tokens.Count - 1] is TNamespace || tokens[tokens.Count - 1] is TUsing)) { currentRebuildData.suggestKeywords = true; currentRebuildData.suggestTypes = true; currentRebuildData.suggestVariables = false; return true; } if (token is TStringLiteral) { if (tokens.Count == 0) return false; token = tokens[tokens.Count - 1]; tokens.RemoveAt(tokens.Count - 1); if (token is TInclude) { currentRebuildData.suggestKeywords = true; currentRebuildData.suggestTypes = true; currentRebuildData.suggestVariables = false; return true; } return false; } if (token is TLt && tokens.Count > 0 && (tokens[tokens.Count - 1] is TSyncInvoke || tokens[tokens.Count - 1] is TSyncInvoke)) { currentRebuildData.suggestKeywords = false; currentRebuildData.suggestTypes = false; currentRebuildData.suggestVariables = true; currentRebuildData.onlySuggestMethods = true; return true; } if (token is TLt && tokens.Count > 0 && (tokens[tokens.Count - 1] is TDelegate)) { currentRebuildData.suggestKeywords = false; currentRebuildData.suggestTypes = false; currentRebuildData.suggestVariables = false; currentRebuildData.onlySuggestMethods = false; currentRebuildData.onlySuggestDelegates = true; return true; } if (token is TNew) { currentRebuildData.suggestKeywords = false; currentRebuildData.suggestTypes = true; currentRebuildData.suggestVariables = false; return true; } { //locals can be declared as const <type> name.. if (token is TConst) { currentRebuildData.suggestKeywords = false; currentRebuildData.suggestTypes = true; currentRebuildData.suggestVariables = false; return true; } if (token is TNative || token is TStatic) { currentRebuildData.suggestKeywords = false; currentRebuildData.suggestTypes = true; currentRebuildData.suggestVariables = false; return true; } if (token is TReturn) { currentRebuildData.suggestKeywords = false; currentRebuildData.suggestTypes = false; currentRebuildData.suggestVariables = true; return true; } //Check last letter in previous token switch (token.Text[token.Text.Length - 1]) { case '{'://y y y case '}': case ';': case ':': currentRebuildData.onlySuggestVariablesInsideMethods = true; currentRebuildData.suggestKeywords = true; currentRebuildData.suggestTypes = true; currentRebuildData.suggestVariables = true; return true; case ','://n y y case '(': case '[': case '<': currentRebuildData.suggestKeywords = false; currentRebuildData.suggestTypes = true; currentRebuildData.suggestVariables = true; return true; case '+'://n n y case '-': case '*': case '/': case '%': case '!': case '>': case '=': case '&': case '|': case '^': case '?': case ')': currentRebuildData.suggestKeywords = false; currentRebuildData.suggestTypes = true; currentRebuildData.suggestVariables = true; return true; } return false; } } else { //Token was not a dot or identifier //Could for example be if the current token is a number return false; } }
public override void CaseTDot(TDot node) { index = 61; }