public SyntaxToken(Kind kind, string text) { parent = null; tokenKind = kind; this.text = string.Intern(text); tokenId = -1; style = null; }
public override FGGrammar.IScanner MoveAfterLeaf(ParseTree.Leaf leaf) { var scanner = CsGrammar.Scanner.New(CsGrammar.Instance, textBuffer.formatedLines, assetPath); var result = leaf == null ? scanner : scanner.MoveAfterLeaf(leaf) ? scanner : null; if (result == null) { scanner.Delete(); } return(result); }
public IEnumerable <SnippetCompletion> EnumSnippets( SymbolDefinition context, FGGrammar.TokenSet expectedTokens, SyntaxToken tokenLeft, Scope scope) { if (tokenLeft == null || tokenLeft.parent == null || tokenLeft.parent.parent == null) { yield break; } if (tokenLeft.tokenKind != SyntaxToken.Kind.Punctuator) { yield break; } if (tokenLeft.text != "{" && tokenLeft.text != "}" && tokenLeft.text != ";") { yield break; } var bodyScope = scope as BodyScope; if (bodyScope == null) { yield break; } contextType = bodyScope.definition as TypeDefinitionBase; if (contextType == null || contextType.kind != SymbolKind.Class) { yield break; } List <SnippetCompletion> magicMethods; if (contextType.DerivesFrom(monoBehaviourType)) { magicMethods = monoBehaviourMagicMethods; } else if (contextType.DerivesFrom(scriptableWizardType)) { magicMethods = scriptableWizardMagicMethods; } else if (contextType.DerivesFrom(editorWindowType)) { magicMethods = editorWindowMagicMethods; } else if (contextType.DerivesFrom(editorType)) { magicMethods = editorMagicMethods; } else if (contextType.DerivesFrom(assetPostprocessorType)) { magicMethods = assetPostprocessorMagicMethods; } else if (contextType.DerivesFrom(scriptableObjectType)) { magicMethods = scriptableObjectMagicMethods; } else { yield break; } var baseType = contextType.BaseType(); var tempLeaf = new ParseTree.Leaf() { token = new SyntaxToken(SyntaxToken.Kind.Identifier, "") }; foreach (var magic in magicMethods) { ((IMagicMethod)magic).BaseSymbol = null; if (contextType.FindName(magic.name, -1, false) != null) { continue; } tempLeaf.token.text = magic.name; baseType.ResolveMember(tempLeaf, scope, -1, false); var baseSymbol = tempLeaf.resolvedSymbol; if (baseSymbol == null || baseSymbol.kind == SymbolKind.Error) { yield return(magic); continue; } var asMethodGroup = baseSymbol as MethodGroupDefinition; if (baseSymbol.kind != SymbolKind.MethodGroup || asMethodGroup == null) { if (!baseSymbol.IsPrivate) { ((IMagicMethod)magic).BaseSymbol = baseSymbol; } yield return(magic); continue; } bool yield = true; var magicSignature = ((IMagicMethod)magic).GetParametersString(); foreach (var baseMethod in asMethodGroup.methods) { if (baseMethod.PrintParameters(baseMethod.GetParameters(), true) == magicSignature) { if (baseMethod.IsOverride || baseMethod.IsVirtual || baseMethod.IsAbstract) { yield = false; break; } if (!baseMethod.IsPrivate) { var returnType = baseMethod.ReturnType(); if (returnType == null || returnType.kind == SymbolKind.Error) { ((IMagicMethod)magic).BaseSymbol = asMethodGroup; } else { var baseIsCoroutine = returnType.name == "IEnumerator"; var returnsVoid = baseMethod.ReturnType() == SymbolDefinition.builtInTypes_void; if (!baseIsCoroutine && !returnsVoid) { ((IMagicMethod)magic).BaseSymbol = asMethodGroup; } else { ((IMagicMethod)magic).BaseSymbol = baseMethod; } } } break; } } if (yield) { yield return(magic); } } }
public virtual FGGrammar.IScanner MoveAfterLeaf(ParseTree.Leaf leaf) { return(null); }
public override FGGrammar.IScanner MoveAfterLeaf(ParseTree.Leaf leaf) { var scanner = new CsGrammar.Scanner(CsGrammar.Instance, textBuffer.formatedLines, assetPath); return(leaf == null ? scanner : scanner.MoveAfterLeaf(leaf) ? scanner : null); }