private Statement ProcessUsingStatement(UsingNode node) { UsingStatement statement = new UsingStatement(); statement.AddGuard((VariableDeclarationStatement)ProcessVariableDeclarationStatement((VariableDeclarationNode)node.Guard)); statement.AddBody(BuildStatement((StatementNode)node.Body)); return(statement); }
protected override void VisitUsingNode(UsingNode node) { AppendIndentation(); Append("using "); Append(node.NamespaceName); Append(";"); AppendLineEnding(); base.VisitUsingNode(node); }
public override void Visit(UsingNode node) { if (node.IsStatic) { helpers.Add(node.Name); } else { usings.Add(node.Name); } }
private void AnalyzeUsing(UsingNode usingNode) { for (NameSpaceDefinition nameSpace = Parser.RootNameSpace; usingNode.NextUsing != null; usingNode = usingNode.NextUsing) { if (!nameSpace.IsContainNameSpace(usingNode.Name)) { return; //TODO:报错 未找到命名空间名 } usingNode.NameSpace = nameSpace.GetNameSpaceDefinition(usingNode.Name); } }
protected override void VisitUsingNode(UsingNode node) { if (node == null) { return; } AppendIndentation(); Append("using "); Append(node.Namespace); AppendEndOfStatement(); if (this.settings.BlankLine.Using) { AppendLine(); } base.VisitUsingNode(node); }
private void PrepareUsings(UsingCache cache, UsingNode node) { if (node == null) { return; } if (cache.IsUsingNamespace(node)) { return; } if (string.IsNullOrWhiteSpace(node.Namespace)) { return; } cache.Map[node.Namespace] = node; }
private void ParseUsing() { List <UsingNode> references = FilesReferences[_lexer.FileIndex]; Token s = _lexer.Eat(TokenType.Identifer); //TODO:使用Match函数报错 if (_lexer.MatchNow("=")) { FilesAliases[_lexer.FileIndex].Add(s.Content, ParseDefinitionSpecifier()); return; } references.Add(_syntaxFactory.GetUsingNode(s, null)); UsingNode last = references.Last(); while (_lexer.Match(".")) { _lexer.MatchNext(TokenType.Identifer); //TODO:使用Match函数报错 last.AddAfter(_lexer.Eat(TokenType.Identifer), _syntaxFactory); last = last.NextUsing; } _lexer.MatchNow(";"); //TODO:使用Match函数报错 }
protected bool Equals(UsingNode other) { return string.Equals(VariableName, other.VariableName) && Equals(Expression, other.Expression) && Equals(Body, other.Body); }
internal UsingNode GetUsingNode(Token content, UsingNode previousUsing) { return(new UsingNode(content, previousUsing)); }
private static string[] GenerateCode() { Type painterInterface = PainterType == PAINTER_TYPE_GEOMETRY_TEXTURE ? typeof(IGTexturePainter) : PainterType == PAINTER_TYPE_FOLIAGE ? typeof(IGFoliagePainter) : PainterType == PAINTER_TYPE_OBJECT ? typeof(IGObjectPainter) : null; //Declare it TypeDeclaration d = new TypeDeclaration.Builder() .SetAccessModifier(AccessModifier.PUBLIC) .SetIsStatic(false) .SetInheritance(Inheritance.DEFAULT) .SetScope(Scope.CLASS) .SetName(PainterName.RemoveSpecialCharacters()) .SetInterfaces(painterInterface) .Build(); //Import regularly used namespaces, just call a Using(...) if you need more UsingNode un = new UsingNode() .Using("UnityEngine") .Using("System.Collections") .Using("System.Collections.Generic") .Using("Pinwheel.Griffin") .Using("Pinwheel.Griffin.PaintTool"); //Import the base class namespace to simplify its name in the declaration string if (d.baseClass != null) { un.Using(d.baseClass.Namespace); } //The same for interfaces if (d.implementedInterface.HasElement()) { for (int i = 0; i < d.implementedInterface.Count; ++i) { un.Using(d.implementedInterface[i].Namespace); } } //Give it a hint to determine type names TypeAlias.SetUsingNode(un); List <string> code = new List <string>(); //Implement the type TypeNode tn = new TypeNode() .Declare(d) .Implement(code); //Put the new type into the namespace //NamespaceNode nn = new NamespaceNode() // .SetName("CustomPainter") // .SetTypes(tn); //Put everything into a script ScriptNode sn = new ScriptNode() .SetCompilationDirective("GRIFFIN") .SetUsing(un) //.SetNamespace(nn) .SetTypes(tn); //also set type in case namespace is empty //Now make the code look awesome CodeFormatter formatter = new CodeFormatter(); formatter.addSpaceAfterUsings = true; formatter.addSpaceBetweenMethods = true; formatter.bracketStyle = CodeFormatter.OpenCurlyBracketStyle.NewLine; string[] script = formatter.Format(sn); return(script); //phew... }
public ScriptNode SetUsing(UsingNode u) { usingNode = u; return(this); }
private static string[] GenerateCode() { //Declare it TypeDeclaration d = new TypeDeclaration.Builder() .SetAccessModifier(AccessModifier.PUBLIC) .SetIsStatic(true) .SetInheritance(Inheritance.DEFAULT) .SetScope(Scope.CLASS) .SetName(ExtensionName.RemoveSpecialCharacters()) .Build(); //Import regularly used namespaces, just call a Using(...) if you need more UsingNode un = new UsingNode() .Using("UnityEngine") .Using("System.Collections") .Using("System.Collections.Generic") .Using("UnityEditor"); //Import the base class namespace to simplify its name in the declaration string if (d.baseClass != null) { un.Using(d.baseClass.Namespace); } //The same for interfaces if (d.implementedInterface.HasElement()) { for (int i = 0; i < d.implementedInterface.Count; ++i) { un.Using(d.implementedInterface[i].Namespace); } } //Give it a hint to determine type names TypeAlias.SetUsingNode(un); List <string> code = new List <string>(); //add basic function for an extension code.Add(GetExtensionNameCode()); code.Add(GetPublisherNameCode()); code.Add(GetDescriptionCode()); code.Add(GetVersionCode()); code.Add(GetOpenUserGuideCode()); code.Add(GetOpenSupportLinkCode()); code.Add(GetButtonMethodCode()); code.Add(GetOnGUICode()); //Implement the type TypeNode tn = new TypeNode() .Declare(d) .Implement(code); //Put the new type into the namespace NamespaceNode nn = new NamespaceNode() .SetName(string.Format("{0}.GriffinExtension", PublisherName.RemoveSpecialCharacters())) .SetTypes(tn); //Put everything into a script ScriptNode sn = new ScriptNode() .SetCompilationDirective("GRIFFIN && UNITY_EDITOR") .SetUsing(un) .SetNamespace(nn) .SetTypes(tn); //also set type in case namespace is empty //Now make the code look awesome CodeFormatter formatter = new CodeFormatter(); formatter.addSpaceAfterUsings = true; formatter.addSpaceBetweenMethods = true; formatter.bracketStyle = CodeFormatter.OpenCurlyBracketStyle.NewLine; string[] script = formatter.Format(sn); return(script); //phew... }
/// <summary> /// using_header = "using" [ identifier "=" ] line_expr "do" /// </summary> private UsingNode parseUsingHeader() { if (!check(LexemType.Using)) return null; var node = new UsingNode(); if (peek(LexemType.Identifier, LexemType.Assign)) { node.VariableName = getValue(); skip(); } node.Expression = ensure(parseLineExpr, ParserMessages.ExpressionExpected); ensure(LexemType.Do, ParserMessages.SymbolExpected, "do"); return node; }
protected virtual void VisitUsingNode(UsingNode node) { }
/// <summary> /// Give a hint to determine if the namespace should be included in type name or not /// </summary> /// <param name="un"></param> public static void SetUsingNode(UsingNode un) { usingNode = un; }
public string Visit(UsingNode node) => ASTHelper.PrintToken(node.Token) + ASTHelper.PrintValue(node.Name);
public virtual void Visit(UsingNode node) { }