提交 08d4f343 编写于 作者: D Dustin Campbell

Change internal property name from IsScript to IsScriptCommandLineParser

上级 b74c5293
...@@ -18,12 +18,12 @@ namespace Microsoft.CodeAnalysis.CSharp ...@@ -18,12 +18,12 @@ namespace Microsoft.CodeAnalysis.CSharp
public class CSharpCommandLineParser : CommandLineParser public class CSharpCommandLineParser : CommandLineParser
{ {
public static CSharpCommandLineParser Default { get; } = new CSharpCommandLineParser(); public static CSharpCommandLineParser Default { get; } = new CSharpCommandLineParser();
public static CSharpCommandLineParser Script { get; } = new CSharpCommandLineParser(isScript: true); public static CSharpCommandLineParser Script { get; } = new CSharpCommandLineParser(isScriptCommandLineParser: true);
private readonly static char[] s_quoteOrEquals = new[] { '"', '=' }; private readonly static char[] s_quoteOrEquals = new[] { '"', '=' };
internal CSharpCommandLineParser(bool isScript = false) internal CSharpCommandLineParser(bool isScriptCommandLineParser = false)
: base(CSharp.MessageProvider.Instance, isScript) : base(CSharp.MessageProvider.Instance, isScriptCommandLineParser)
{ {
} }
...@@ -47,8 +47,8 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas ...@@ -47,8 +47,8 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
{ {
List<Diagnostic> diagnostics = new List<Diagnostic>(); List<Diagnostic> diagnostics = new List<Diagnostic>();
List<string> flattenedArgs = new List<string>(); List<string> flattenedArgs = new List<string>();
List<string> scriptArgs = IsScript ? new List<string>() : null; List<string> scriptArgs = IsScriptCommandLineParser ? new List<string>() : null;
List<string> responsePaths = IsScript ? new List<string>() : null; List<string> responsePaths = IsScriptCommandLineParser ? new List<string>() : null;
FlattenArgs(args, diagnostics, flattenedArgs, scriptArgs, baseDirectory, responsePaths); FlattenArgs(args, diagnostics, flattenedArgs, scriptArgs, baseDirectory, responsePaths);
string appConfigPath = null; string appConfigPath = null;
...@@ -65,7 +65,7 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas ...@@ -65,7 +65,7 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
DebugInformationFormat debugInformationFormat = PathUtilities.IsUnixLikePlatform ? DebugInformationFormat.PortablePdb : DebugInformationFormat.Pdb; DebugInformationFormat debugInformationFormat = PathUtilities.IsUnixLikePlatform ? DebugInformationFormat.PortablePdb : DebugInformationFormat.Pdb;
bool debugPlus = false; bool debugPlus = false;
string pdbPath = null; string pdbPath = null;
bool noStdLib = IsScript; // don't add mscorlib from sdk dir when running scripts bool noStdLib = IsScriptCommandLineParser; // don't add mscorlib from sdk dir when running scripts
string outputDirectory = baseDirectory; string outputDirectory = baseDirectory;
ImmutableArray<KeyValuePair<string, string>> pathMap = ImmutableArray<KeyValuePair<string, string>>.Empty; ImmutableArray<KeyValuePair<string, string>> pathMap = ImmutableArray<KeyValuePair<string, string>>.Empty;
string outputFileName = null; string outputFileName = null;
...@@ -129,7 +129,7 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas ...@@ -129,7 +129,7 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
// Process ruleset files first so that diagnostic severity settings specified on the command line via // Process ruleset files first so that diagnostic severity settings specified on the command line via
// /nowarn and /warnaserror can override diagnostic severity settings specified in the ruleset file. // /nowarn and /warnaserror can override diagnostic severity settings specified in the ruleset file.
if (!IsScript) if (!IsScriptCommandLineParser)
{ {
foreach (string arg in flattenedArgs) foreach (string arg in flattenedArgs)
{ {
...@@ -207,7 +207,7 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas ...@@ -207,7 +207,7 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
#endif #endif
} }
if (IsScript) if (IsScriptCommandLineParser)
{ {
switch (name) switch (name)
{ {
...@@ -1193,7 +1193,7 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas ...@@ -1193,7 +1193,7 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
AddDiagnostic(diagnostics, diagnosticOptions, ErrorCode.ERR_NoNetModuleOutputWhenRefOutOrRefOnly); AddDiagnostic(diagnostics, diagnosticOptions, ErrorCode.ERR_NoNetModuleOutputWhenRefOutOrRefOnly);
} }
if (!IsScript && !sourceFilesSpecified && (outputKind.IsNetModule() || !resourcesOrModulesSpecified)) if (!IsScriptCommandLineParser && !sourceFilesSpecified && (outputKind.IsNetModule() || !resourcesOrModulesSpecified))
{ {
AddDiagnostic(diagnostics, diagnosticOptions, ErrorCode.WRN_NoSources); AddDiagnostic(diagnostics, diagnosticOptions, ErrorCode.WRN_NoSources);
} }
...@@ -1261,7 +1261,7 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas ...@@ -1261,7 +1261,7 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
languageVersion: languageVersion, languageVersion: languageVersion,
preprocessorSymbols: defines.ToImmutableAndFree(), preprocessorSymbols: defines.ToImmutableAndFree(),
documentationMode: parseDocumentationComments ? DocumentationMode.Diagnose : DocumentationMode.None, documentationMode: parseDocumentationComments ? DocumentationMode.Diagnose : DocumentationMode.None,
kind: IsScript ? SourceCodeKind.Script : SourceCodeKind.Regular, kind: IsScriptCommandLineParser ? SourceCodeKind.Script : SourceCodeKind.Regular,
features: parsedFeatures features: parsedFeatures
); );
...@@ -1318,8 +1318,8 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas ...@@ -1318,8 +1318,8 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
return new CSharpCommandLineArguments return new CSharpCommandLineArguments
{ {
IsScriptRunner = IsScript, IsScriptRunner = IsScriptCommandLineParser,
InteractiveMode = interactiveMode || IsScript && sourceFiles.Count == 0, InteractiveMode = interactiveMode || IsScriptCommandLineParser && sourceFiles.Count == 0,
BaseDirectory = baseDirectory, BaseDirectory = baseDirectory,
PathMap = pathMap, PathMap = pathMap,
Errors = diagnostics.AsImmutable(), Errors = diagnostics.AsImmutable(),
...@@ -1432,7 +1432,7 @@ private static string GetWin32Setting(string arg, string value, List<Diagnostic> ...@@ -1432,7 +1432,7 @@ private static string GetWin32Setting(string arg, string value, List<Diagnostic>
// names from the files containing their entrypoints and libraries derive their names from // names from the files containing their entrypoints and libraries derive their names from
// their first input files. // their first input files.
if (!IsScript && !sourceFilesSpecified) if (!IsScriptCommandLineParser && !sourceFilesSpecified)
{ {
AddDiagnostic(diagnostics, ErrorCode.ERR_OutputNeedsName); AddDiagnostic(diagnostics, ErrorCode.ERR_OutputNeedsName);
simpleName = null; simpleName = null;
...@@ -1466,7 +1466,7 @@ private static string GetWin32Setting(string arg, string value, List<Diagnostic> ...@@ -1466,7 +1466,7 @@ private static string GetWin32Setting(string arg, string value, List<Diagnostic>
if (outputKind.IsNetModule()) if (outputKind.IsNetModule())
{ {
Debug.Assert(!IsScript); Debug.Assert(!IsScriptCommandLineParser);
compilationName = moduleAssemblyName; compilationName = moduleAssemblyName;
} }
...@@ -1508,7 +1508,7 @@ private ImmutableArray<string> BuildSearchPaths(string sdkDirectoryOpt, List<str ...@@ -1508,7 +1508,7 @@ private ImmutableArray<string> BuildSearchPaths(string sdkDirectoryOpt, List<str
// with references relative to csi.exe (e.g. System.ValueTuple.dll). // with references relative to csi.exe (e.g. System.ValueTuple.dll).
if (responsePathsOpt != null) if (responsePathsOpt != null)
{ {
Debug.Assert(IsScript); Debug.Assert(IsScriptCommandLineParser);
builder.AddRange(responsePathsOpt); builder.AddRange(responsePathsOpt);
} }
......
...@@ -17,14 +17,14 @@ namespace Microsoft.CodeAnalysis ...@@ -17,14 +17,14 @@ namespace Microsoft.CodeAnalysis
public abstract class CommandLineParser public abstract class CommandLineParser
{ {
private readonly CommonMessageProvider _messageProvider; private readonly CommonMessageProvider _messageProvider;
internal readonly bool IsScript; internal readonly bool IsScriptCommandLineParser;
private static readonly char[] s_searchPatternTrimChars = new char[] { '\t', '\n', '\v', '\f', '\r', ' ', '\x0085', '\x00a0' }; private static readonly char[] s_searchPatternTrimChars = new char[] { '\t', '\n', '\v', '\f', '\r', ' ', '\x0085', '\x00a0' };
internal CommandLineParser(CommonMessageProvider messageProvider, bool isScript) internal CommandLineParser(CommonMessageProvider messageProvider, bool isScriptCommandLineParser)
{ {
Debug.Assert(messageProvider != null); Debug.Assert(messageProvider != null);
_messageProvider = messageProvider; _messageProvider = messageProvider;
IsScript = isScript; IsScriptCommandLineParser = isScriptCommandLineParser;
} }
internal CommonMessageProvider MessageProvider internal CommonMessageProvider MessageProvider
...@@ -793,7 +793,7 @@ private CommandLineSourceFile ToCommandLineSourceFile(string resolvedPath) ...@@ -793,7 +793,7 @@ private CommandLineSourceFile ToCommandLineSourceFile(string resolvedPath)
string extension = PathUtilities.GetExtension(resolvedPath); string extension = PathUtilities.GetExtension(resolvedPath);
bool isScriptFile; bool isScriptFile;
if (IsScript) if (IsScriptCommandLineParser)
{ {
isScriptFile = !string.Equals(extension, RegularFileExtension, StringComparison.OrdinalIgnoreCase); isScriptFile = !string.Equals(extension, RegularFileExtension, StringComparison.OrdinalIgnoreCase);
} }
...@@ -809,7 +809,7 @@ private CommandLineSourceFile ToCommandLineSourceFile(string resolvedPath) ...@@ -809,7 +809,7 @@ private CommandLineSourceFile ToCommandLineSourceFile(string resolvedPath)
internal IEnumerable<CommandLineSourceFile> ParseFileArgument(string arg, string baseDirectory, IList<Diagnostic> errors) internal IEnumerable<CommandLineSourceFile> ParseFileArgument(string arg, string baseDirectory, IList<Diagnostic> errors)
{ {
Debug.Assert(IsScript || !arg.StartsWith("-", StringComparison.Ordinal) && !arg.StartsWith("@", StringComparison.Ordinal)); Debug.Assert(IsScriptCommandLineParser || !arg.StartsWith("-", StringComparison.Ordinal) && !arg.StartsWith("@", StringComparison.Ordinal));
// We remove all doubles quotes from a file name. So that, for example: // We remove all doubles quotes from a file name. So that, for example:
// "Path With Spaces"\goo.cs // "Path With Spaces"\goo.cs
......
...@@ -25,14 +25,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic ...@@ -25,14 +25,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
''' <summary> ''' <summary>
''' Gets the current interactive command line parser. ''' Gets the current interactive command line parser.
''' </summary> ''' </summary>
Public Shared ReadOnly Property Script As New VisualBasicCommandLineParser(isScript:=True) Public Shared ReadOnly Property Script As New VisualBasicCommandLineParser(isScriptCommandLineParser:=True)
''' <summary> ''' <summary>
''' Creates a new command line parser. ''' Creates a new command line parser.
''' </summary> ''' </summary>
''' <param name="isScript">An optional parameter indicating whether to create a interactive command line parser.</param> ''' <param name="isScriptCommandLineParser">An optional parameter indicating whether to create a interactive command line parser.</param>
Friend Sub New(Optional isScript As Boolean = False) Friend Sub New(Optional isScriptCommandLineParser As Boolean = False)
MyBase.New(VisualBasic.MessageProvider.Instance, isScript) MyBase.New(VisualBasic.MessageProvider.Instance, isScriptCommandLineParser)
End Sub End Sub
Private Const s_win32Manifest As String = "win32manifest" Private Const s_win32Manifest As String = "win32manifest"
...@@ -76,7 +76,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic ...@@ -76,7 +76,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim diagnostics As List(Of Diagnostic) = New List(Of Diagnostic)() Dim diagnostics As List(Of Diagnostic) = New List(Of Diagnostic)()
Dim flattenedArgs As List(Of String) = New List(Of String)() Dim flattenedArgs As List(Of String) = New List(Of String)()
Dim scriptArgs As List(Of String) = If(IsScript, New List(Of String)(), Nothing) Dim scriptArgs As List(Of String) = If(IsScriptCommandLineParser, New List(Of String)(), Nothing)
' normalized paths to directories containing response files: ' normalized paths to directories containing response files:
Dim responsePaths As New List(Of String) Dim responsePaths As New List(Of String)
...@@ -163,7 +163,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic ...@@ -163,7 +163,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' Process ruleset files first so that diagnostic severity settings specified on the command line via ' Process ruleset files first so that diagnostic severity settings specified on the command line via
' /nowarn and /warnaserror can override diagnostic severity settings specified in the ruleset file. ' /nowarn and /warnaserror can override diagnostic severity settings specified in the ruleset file.
If Not IsScript Then If Not IsScriptCommandLineParser Then
For Each arg In flattenedArgs For Each arg In flattenedArgs
Dim name As String = Nothing Dim name As String = Nothing
Dim value As String = Nothing Dim value As String = Nothing
...@@ -418,7 +418,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic ...@@ -418,7 +418,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
#End If #End If
End Select End Select
If IsScript Then If IsScriptCommandLineParser Then
Select Case name Select Case name
Case "i", "i+" Case "i", "i+"
If value IsNot Nothing Then If value IsNot Nothing Then
...@@ -1205,7 +1205,7 @@ lVbRuntimePlus: ...@@ -1205,7 +1205,7 @@ lVbRuntimePlus:
AddDiagnostic(diagnostics, ERRID.ERR_NoNetModuleOutputWhenRefOutOrRefOnly) AddDiagnostic(diagnostics, ERRID.ERR_NoNetModuleOutputWhenRefOutOrRefOnly)
End If End If
If Not IsScript AndAlso Not hasSourceFiles AndAlso managedResources.IsEmpty() Then If Not IsScriptCommandLineParser AndAlso Not hasSourceFiles AndAlso managedResources.IsEmpty() Then
' VB displays help when there is nothing specified on the command line ' VB displays help when there is nothing specified on the command line
If flattenedArgs.Any Then If flattenedArgs.Any Then
AddDiagnostic(diagnostics, ERRID.ERR_NoSources) AddDiagnostic(diagnostics, ERRID.ERR_NoSources)
...@@ -1300,7 +1300,7 @@ lVbRuntimePlus: ...@@ -1300,7 +1300,7 @@ lVbRuntimePlus:
Dim compilationName As String = Nothing Dim compilationName As String = Nothing
GetCompilationAndModuleNames(diagnostics, outputKind, sourceFiles, moduleAssemblyName, outputFileName, moduleName, compilationName) GetCompilationAndModuleNames(diagnostics, outputKind, sourceFiles, moduleAssemblyName, outputFileName, moduleName, compilationName)
If Not IsScript AndAlso If Not IsScriptCommandLineParser AndAlso
Not hasSourceFiles AndAlso Not hasSourceFiles AndAlso
Not managedResources.IsEmpty() AndAlso Not managedResources.IsEmpty() AndAlso
outputFileName = Nothing AndAlso outputFileName = Nothing AndAlso
...@@ -1312,7 +1312,7 @@ lVbRuntimePlus: ...@@ -1312,7 +1312,7 @@ lVbRuntimePlus:
Dim parseOptions = New VisualBasicParseOptions( Dim parseOptions = New VisualBasicParseOptions(
languageVersion:=languageVersion, languageVersion:=languageVersion,
documentationMode:=If(parseDocumentationComments, DocumentationMode.Diagnose, DocumentationMode.None), documentationMode:=If(parseDocumentationComments, DocumentationMode.Diagnose, DocumentationMode.None),
kind:=If(IsScript, SourceCodeKind.Script, SourceCodeKind.Regular), kind:=If(IsScriptCommandLineParser, SourceCodeKind.Script, SourceCodeKind.Regular),
preprocessorSymbols:=AddPredefinedPreprocessorSymbols(outputKind, defines.AsImmutableOrEmpty()), preprocessorSymbols:=AddPredefinedPreprocessorSymbols(outputKind, defines.AsImmutableOrEmpty()),
features:=parsedFeatures) features:=parsedFeatures)
...@@ -1369,11 +1369,11 @@ lVbRuntimePlus: ...@@ -1369,11 +1369,11 @@ lVbRuntimePlus:
' Enable interactive mode if either `\i` option is passed in or no arguments are specified (`vbi`, `vbi script.vbx \i`). ' Enable interactive mode if either `\i` option is passed in or no arguments are specified (`vbi`, `vbi script.vbx \i`).
' If the script is passed without the `\i` option simply execute the script (`vbi script.vbx`). ' If the script is passed without the `\i` option simply execute the script (`vbi script.vbx`).
interactiveMode = interactiveMode Or (IsScript AndAlso sourceFiles.Count = 0) interactiveMode = interactiveMode Or (IsScriptCommandLineParser AndAlso sourceFiles.Count = 0)
Return New VisualBasicCommandLineArguments With Return New VisualBasicCommandLineArguments With
{ {
.IsScriptRunner = IsScript, .IsScriptRunner = IsScriptCommandLineParser,
.InteractiveMode = interactiveMode, .InteractiveMode = interactiveMode,
.BaseDirectory = baseDirectory, .BaseDirectory = baseDirectory,
.Errors = diagnostics.AsImmutable(), .Errors = diagnostics.AsImmutable(),
...@@ -2240,7 +2240,7 @@ lVbRuntimePlus: ...@@ -2240,7 +2240,7 @@ lVbRuntimePlus:
End If End If
If kind.IsNetModule() Then If kind.IsNetModule() Then
Debug.Assert(Not IsScript) Debug.Assert(Not IsScriptCommandLineParser)
compilationName = moduleAssemblyName compilationName = moduleAssemblyName
Else Else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册