public void AddUsing (UsingNamespace un, bool forceAppend = false) { bool isPlayScript = compSourceFile != null && compSourceFile.SourceFile != null && compSourceFile.SourceFile.FileType == Mono.CSharpPs.SourceFileType.PlayScript; if (DeclarationFound && !forceAppend && !isPlayScript){ Compiler.Report.Error (1529, un.Location, "A using clause must precede all other namespace elements except extern alias declarations"); } if (clauses == null) clauses = new List<UsingNamespace> (); clauses.Add (un); }
public override void Visit (UsingNamespace un) { var ud = new UsingDeclaration (); var loc = LocationsBag.GetLocations (un); ud.AddChild (new CSharpTokenNode (Convert (un.Location), UsingDeclaration.UsingKeywordRole), UsingDeclaration.UsingKeywordRole); if (un.NamespaceExpression != null) ud.AddChild (ConvertToType (un.NamespaceExpression), UsingDeclaration.ImportRole); if (loc != null) ud.AddChild (new CSharpTokenNode (Convert (loc [0]), Roles.Semicolon), Roles.Semicolon); AddToNamespace (ud); }
public virtual void Visit (UsingNamespace un) { }
void case_18() #line 468 "cs-parser.jay" { var un = new UsingNamespace ((ATypeNameExpression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop])); current_namespace.AddUsing (un); lbag.AddLocation (un, GetLocation (yyVals[0+yyTop])); }
void case_37() #line 695 "ps-parser.jay" { /* Close the private package namespace (if it's active)*/ if (current_namespace == private_namespace) { if (private_namespace.Containers.Count > 0) { prev_namespace.AddTypeContainer(private_namespace); var priv_un = new UsingNamespace ( private_namespace.NS.MakeTypeNameExpression(GetLocation(yyVals[-10+yyTop])), GetLocation (yyVals[-10+yyTop])); prev_namespace.AddUsing(priv_un, true); } current_container = current_namespace = prev_namespace.Parent; prev_namespace = private_namespace = null; } /* lbag.AddLocation (current_container, GetLocation ($2), GetLocation ($6), GetLocation ($11));*/ }
void case_34() #line 629 "ps-parser.jay" { Attributes attrs = (Attributes) yyVals[-3+yyTop]; var name = yyVals[0+yyTop] as MemberName; if (name == null) { name = new MemberName(RootNs); } if (attrs != null) { bool valid_global_attrs = true; if ((current_namespace.DeclarationFound || current_namespace != file)) { valid_global_attrs = false; } else { foreach (var a in attrs.Attrs) { if (a.ExplicitTarget == "assembly" || a.ExplicitTarget == "module") continue; valid_global_attrs = false; break; } } if (!valid_global_attrs) report.Error (1671, name.Location, "A namespace declaration cannot have modifiers or attributes"); } module.AddAttributes (attrs, current_namespace); /* Close the private package namespace (if it's active)*/ if (current_namespace == private_namespace) { if (private_namespace.Containers.Count > 0) { prev_namespace.AddTypeContainer(private_namespace); var priv_un = new UsingNamespace ( private_namespace.NS.MakeTypeNameExpression(GetLocation(yyVals[-3+yyTop])), GetLocation (yyVals[-3+yyTop])); prev_namespace.AddUsing(priv_un, true); } current_container = current_namespace = prev_namespace.Parent; prev_namespace = private_namespace = null; } var ns = new NamespaceContainer (name, current_namespace); current_namespace.AddTypeContainer (ns); current_container = current_namespace = ns; var un = new UsingNamespace (new SimpleName (RootNs, GetLocation (yyVals[-3+yyTop])), GetLocation (yyVals[-3+yyTop])); current_namespace.AddUsing(un, true); }
void case_29() #line 577 "ps-parser.jay" { if (is_config_enabled) { var un = new UsingNamespace ((ATypeNameExpression) yyVals[-3+yyTop], GetLocation (yyVals[-4+yyTop])); current_namespace.AddUsing (un); lbag.AddLocation (un, GetLocation (yyVals[0+yyTop])); Lexer.AllowAutoSemiAfterToken(Token.DOT_STAR, false); } }