diff --git a/src/Compilers/CSharp/Portable/Syntax/Syntax.xml b/src/Compilers/CSharp/Portable/Syntax/Syntax.xml index 8b789ff763534..e6bfffd647e61 100644 --- a/src/Compilers/CSharp/Portable/Syntax/Syntax.xml +++ b/src/Compilers/CSharp/Portable/Syntax/Syntax.xml @@ -1121,7 +1121,7 @@ - + Declaration representing the variable declared in an out parameter. @@ -1793,6 +1793,7 @@ + @@ -1809,26 +1810,10 @@ - - - - - - - - - - - - - - - - + - + - @@ -1852,6 +1837,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1859,6 +1901,7 @@ + @@ -2035,6 +2078,7 @@ + @@ -2051,30 +2095,68 @@ - - + + - - + + + + + + + + + + + + + + + + + + + + Gets the identifier. - - + - - + + - + + + + + + + + + + + + + + + + + + + + diff --git a/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/AbstractFileWriter.cs b/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/AbstractFileWriter.cs index fb34d3c23de61..daba4c34b176d 100644 --- a/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/AbstractFileWriter.cs +++ b/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/AbstractFileWriter.cs @@ -110,11 +110,6 @@ protected static string OverrideOrNewModifier(Field field) return IsOverride(field) ? "override " : IsNew(field) ? "new " : ""; } - protected static string AccessibilityModifier(Field field) - { - return IsInternal(field) ? "internal" : "public"; - } - protected static bool CanBeField(Field field) { return field.Type != "SyntaxToken" && !IsAnyList(field.Type) && !IsOverride(field) && !IsNew(field); @@ -209,11 +204,6 @@ protected static bool IsOverride(Field f) return f.Override != null && string.Compare(f.Override, "true", true) == 0; } - protected static bool IsInternal(Field f) - { - return f.Internal != null && string.Compare(f.Internal, "true", true) == 0; - } - protected static bool IsNew(Field f) { return f.New != null && string.Compare(f.New, "true", true) == 0; diff --git a/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/Model/Field.cs b/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/Model/Field.cs index ad70811615c75..450c1fa815e99 100644 --- a/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/Model/Field.cs +++ b/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/Model/Field.cs @@ -22,9 +22,6 @@ public class Field [XmlAttribute] public string New; - [XmlAttribute] - public string Internal; - [XmlElement(ElementName = "Kind", Type = typeof(Kind))] public List Kinds; diff --git a/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/Model/Node.cs b/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/Model/Node.cs index 74c34c4f52307..be693a9bd8cc2 100644 --- a/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/Model/Node.cs +++ b/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/Model/Node.cs @@ -13,20 +13,6 @@ public class Node : TreeType [XmlAttribute] public string Errors; - /// - /// Even if the Node only has optional or struct fields, don't treat it as AutoCreatable. - /// Don't introduce a factory method with no arguments. - /// - [XmlAttribute] - public bool AvoidAutoCreation = false; - - /// - /// The factory method with all the fields should be internal. The corresponding Update method as well. - /// Other factory methods are not generated and have to be written by hand. - /// - [XmlAttribute] - public bool InternalFactory = false; - [XmlElement(ElementName = "Kind", Type = typeof(Kind))] public List Kinds; diff --git a/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/SourceWriter.cs b/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/SourceWriter.cs index e8b44de5076b2..d0ebd27edbd41 100644 --- a/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/SourceWriter.cs +++ b/src/Tools/Source/CompilerGeneratorTools/Source/CSharpSyntaxGenerator/SourceWriter.cs @@ -907,7 +907,7 @@ private void WriteRedType(TreeType node) var fieldType = field.Type == "SyntaxList" ? "SyntaxTokenList" : field.Type; WriteLine(); WriteComment(field.PropertyComment, " "); - WriteLine(" {0} abstract {1}{2} {3} {{ get; }}", AccessibilityModifier(field), (IsNew(field) ? "new " : ""), fieldType, field.Name); + WriteLine(" {0} abstract {1}{2} {3} {{ get; }}", "public", (IsNew(field) ? "new " : ""), fieldType, field.Name); } } @@ -916,7 +916,7 @@ private void WriteRedType(TreeType node) var field = valueFields[i]; WriteLine(); WriteComment(field.PropertyComment, " "); - WriteLine(" {0} abstract {1}{2} {3} {{ get; }}", AccessibilityModifier(field), (IsNew(field) ? "new " : ""), field.Type, field.Name); + WriteLine(" {0} abstract {1}{2} {3} {{ get; }}", "public", (IsNew(field) ? "new " : ""), field.Type, field.Name); } WriteLine(" }"); @@ -964,7 +964,7 @@ private void WriteRedType(TreeType node) if (field.Type == "SyntaxToken") { WriteComment(field.PropertyComment, " "); - WriteLine(" {0} {1}{2} {3} ", AccessibilityModifier(field), OverrideOrNewModifier(field), field.Type, field.Name); + WriteLine(" {0} {1}{2} {3} ", "public", OverrideOrNewModifier(field), field.Type, field.Name); WriteLine(" {"); if (IsOptional(field)) { @@ -986,7 +986,7 @@ private void WriteRedType(TreeType node) else if (field.Type == "SyntaxList") { WriteComment(field.PropertyComment, " "); - WriteLine(" {0} {1}SyntaxTokenList {2} ", AccessibilityModifier(field), OverrideOrNewModifier(field), field.Name); + WriteLine(" {0} {1}SyntaxTokenList {2} ", "public", OverrideOrNewModifier(field), field.Name); WriteLine(" {"); WriteLine(" get"); WriteLine(" {"); @@ -1001,7 +1001,7 @@ private void WriteRedType(TreeType node) else { WriteComment(field.PropertyComment, " "); - WriteLine(" {0} {1}{2} {3} ", AccessibilityModifier(field), OverrideOrNewModifier(field), field.Type, field.Name); + WriteLine(" {0} {1}{2} {3} ", "public", OverrideOrNewModifier(field), field.Type, field.Name); WriteLine(" {"); WriteLine(" get"); WriteLine(" {"); @@ -1044,7 +1044,7 @@ private void WriteRedType(TreeType node) var field = valueFields[i]; WriteComment(field.PropertyComment, " "); WriteLine(" {0} {1}{2} {3} {{ get {{ return ((Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.{4})this.Green).{3}; }} }}", - AccessibilityModifier(field), OverrideOrNewModifier(field), field.Type, field.Name, node.Name + "public", OverrideOrNewModifier(field), field.Type, field.Name, node.Name ); WriteLine(); } @@ -1184,7 +1184,7 @@ private void WriteRedVisitor(bool genericArgument, bool genericResult) private void WriteRedUpdateMethod(Node node) { WriteLine(); - Write(" {0} {1} Update(", (node.Fields.Any(f => IsInternal(f)) || node.InternalFactory) ? "internal" : "public", node.Name); + Write(" {0} {1} Update(", "public", node.Name); // parameters for (int f = 0; f < node.Fields.Count; f++) @@ -1283,7 +1283,7 @@ private void WriteRedSetters(Node node) var type = this.GetRedPropertyType(field); WriteLine(); - WriteLine(" {0} {1} With{2}({3} {4})", AccessibilityModifier(field), node.Name, StripPost(field.Name, "Opt"), type, CamelCase(field.Name)); + WriteLine(" {0} {1} With{2}({3} {4})", "public", node.Name, StripPost(field.Name, "Opt"), type, CamelCase(field.Name)); WriteLine(" {"); // call update inside each setter @@ -1322,7 +1322,7 @@ private void WriteRedListHelperMethods(Node node) else { Node referencedNode = GetNode(field.Type); - if (referencedNode != null && !referencedNode.AvoidAutoCreation && (!IsOptional(field) || RequiredFactoryArgumentCount(referencedNode) == 0)) + if (referencedNode != null && (!IsOptional(field) || RequiredFactoryArgumentCount(referencedNode) == 0)) { // look for list members... for (int rf = 0; rf < referencedNode.Fields.Count; rf++) @@ -1448,14 +1448,10 @@ private void WriteRedFactories() { var node = nodes[i]; this.WriteRedFactory(node); - - if (!node.InternalFactory) - { - this.WriteRedFactoryWithNoAutoCreatableTokens(node); - this.WriteRedMinimalFactory(node); - this.WriteRedMinimalFactory(node, withStringNames: true); - this.WriteKindConverters(node); - } + this.WriteRedFactoryWithNoAutoCreatableTokens(node); + this.WriteRedMinimalFactory(node); + this.WriteRedMinimalFactory(node, withStringNames: true); + this.WriteKindConverters(node); } WriteLine(" }"); @@ -1476,7 +1472,7 @@ private bool IsAutoCreatableToken(Node node, Field field) private bool IsAutoCreatableNode(Node node, Field field) { var referencedNode = GetNode(field.Type); - return (referencedNode != null && !referencedNode.AvoidAutoCreation && RequiredFactoryArgumentCount(referencedNode) == 0); + return (referencedNode != null && RequiredFactoryArgumentCount(referencedNode) == 0); } private bool IsRequiredFactoryField(Node node, Field field) @@ -1536,7 +1532,7 @@ private void WriteRedFactory(Node nd) WriteComment(string.Format("Creates a new {0} instance.", nd.Name), " "); - Write(" {0} static {1} {2}(", (nd.Fields.Any(f => IsInternal(f)) || nd.InternalFactory) ? "internal" : "public", nd.Name, StripPost(nd.Name, "Syntax")); + Write(" {0} static {1} {2}(", "public", nd.Name, StripPost(nd.Name, "Syntax")); WriteRedFactoryParameters(nd); WriteLine(")"); @@ -1746,7 +1742,7 @@ private void WriteRedFactoryWithNoAutoCreatableTokens(Node nd) this.WriteLine(); WriteComment(string.Format("Creates a new {0} instance.", nd.Name), " "); - Write(" {0} static {1} {2}(", factoryWithNoAutoCreatableTokenFields.Any(f => IsInternal(f)) ? "internal" : "public", nd.Name, StripPost(nd.Name, "Syntax")); + Write(" {0} static {1} {2}(", "public", nd.Name, StripPost(nd.Name, "Syntax")); bool hasPreviousParameter = false; if (nd.Kinds.Count > 1) @@ -1867,7 +1863,7 @@ private void WriteRedMinimalFactory(Node nd, bool withStringNames = false) this.WriteLine(); WriteComment(string.Format("Creates a new {0} instance.", nd.Name), " "); - Write(" {0} static {1} {2}(", minimalFactoryfields.Any(f => IsInternal(f)) ? "internal" : "public", nd.Name, StripPost(nd.Name, "Syntax")); + Write(" {0} static {1} {2}(", "public", nd.Name, StripPost(nd.Name, "Syntax")); bool hasPreviousParameter = false; if (nd.Kinds.Count > 1)