本文整理汇总了C#中UsingStatementSyntax类的典型用法代码示例。如果您正苦于以下问题:C# UsingStatementSyntax类的具体用法?C# UsingStatementSyntax怎么用?C# UsingStatementSyntax使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UsingStatementSyntax类属于命名空间,在下文中一共展示了UsingStatementSyntax类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AddSequencePoint
internal static BoundStatement AddSequencePoint(UsingStatementSyntax usingSyntax, BoundStatement rewrittenStatement)
{
int start = usingSyntax.Span.Start;
int end = usingSyntax.CloseParenToken.Span.End;
TextSpan span = TextSpan.FromBounds(start, end);
return new BoundSequencePointWithSpan(usingSyntax, rewrittenStatement, span);
}
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:7,代码来源:LocalRewriter_SequencePoints.cs
示例2: Start
public LockChecks Start(SyntaxNodeAnalysisContext AnalysisContext,DiagnosticDescriptor rule)
{
this.analysisContext = AnalysisContext;
this.usingStatement = (UsingStatementSyntax)analysisContext.Node;
this.rule = rule;
reportedIssue = false;
return this;
}
开发者ID:peterstevens130561,项目名称:sonarlint-vs,代码行数:8,代码来源:LockChecks.cs
示例3: VisitUsingStatement
public sealed override void VisitUsingStatement(UsingStatementSyntax node)
{
if (node.Expression != null)
{
_builder.Add(node);
}
base.VisitUsingStatement(node);
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:9,代码来源:LocalVariableDeclaratorsCollector.cs
示例4: UsingStatementTranslation
public UsingStatementTranslation(UsingStatementSyntax syntax, SyntaxTranslation parent) : base(syntax, parent)
{
Declaration = syntax.Declaration.Get<VariableDeclarationTranslation>(this);
Expression = syntax.Expression.Get<ExpressionTranslation>(this);
Statement = syntax.Statement.Get<StatementTranslation>(this);
//if(Expression != null)
//{
// throw new Exception("only support Declaration");
//}
}
开发者ID:asthomas,项目名称:TypescriptSyntaxPaste,代码行数:11,代码来源:UsingStatementTranslation.cs
示例5: VisitUsingStatement
public override void VisitUsingStatement(UsingStatementSyntax node)
{
var tokens = new List<SyntaxToken>();
if (node.Declaration != null)
{
tokens.AddRange(node.Declaration.Variables.Select(v => v.Identifier));
}
tracker.AddIdentifiers(tokens);
Visit(node.Statement);
tracker.RemoveIdentifiers(tokens);
}
开发者ID:EkardNT,项目名称:Roslyn,代码行数:13,代码来源:LocalConflictVisitor.cs
示例6: UsingStatement
public static string UsingStatement(UsingStatementSyntax statement)
{
var output = SyntaxNode(statement.Declaration) + ";" + NewLine;
output += Block((BlockSyntax)statement.Statement, false);
//Swift calls deinit when you make a variable nil
output += string.Join("",
statement.Declaration.Variables.Select(variable => variable.Identifier.Text + " = nil;" + NewLine));
return output;
}
开发者ID:UIKit0,项目名称:SharpSwift,代码行数:13,代码来源:StatementSyntaxParser.cs
示例7: Go
public static void Go(OutputWriter writer, UsingStatementSyntax usingStatement)
{
var expression = usingStatement.Expression;
writer.WriteLine("//using block ... " + usingStatement.Declaration);
writer.OpenBrace();
//Ensure the using statement is a local variable - we can't deal with things we can't reliably repeat in the finally block
var resource = Utility.TryGetIdentifier(expression);
// if (resource == null)
// throw new Exception("Using statements must reference a local variable. " + Utility.Descriptor(usingStatement));
var variables = new SeparatedSyntaxList<VariableDeclaratorSyntax>();//.Select(o => o.Identifier.ValueText);
if (usingStatement.Declaration != null)
{
Core.Write(writer, usingStatement.Declaration);
variables = usingStatement.Declaration.Variables;
}
writer.WriteLine("try");
Core.WriteStatementAsBlock(writer, usingStatement.Statement);
writer.WriteLine("finally");
writer.OpenBrace();
foreach (var variable in variables)
{
var typeInfo = TypeProcessor.GetTypeInfo(usingStatement.Declaration.Type);
if (!typeInfo.Type.IsValueType)
writer.WriteLine("if(" + variable.Identifier.Text + " !is null)");
else if (typeInfo.Type.Name == "Nullable")
writer.WriteLine("if(" + variable.Identifier.Text + ".HasValue)");
writer.WriteLine(variable.Identifier.Text + ".Dispose(cast(IDisposable)null);");
}
if (resource != null)
{
writer.WriteLine("if(" + resource + " !is null)");
writer.WriteLine(resource + ".Dispose(cast(IDisposable)null);");
}
writer.CloseBrace();
writer.CloseBrace();
}
开发者ID:mortezabarzkar,项目名称:SharpNative,代码行数:42,代码来源:WriteUsingStatement.cs
示例8: HandleUsingStatement
static CodeAction HandleUsingStatement(Document document, Microsoft.CodeAnalysis.Text.TextSpan span, SyntaxNode root, UsingStatementSyntax usingStatement, VariableDeclaratorSyntax variable)
{
return CodeActionFactory.Create(
span,
DiagnosticSeverity.Info,
"Iterate via 'foreach'",
ct =>
{
ForEachStatementSyntax foreachStmt = BuildForeach(SyntaxFactory.IdentifierName(variable.Identifier));
var innerBlock = usingStatement.Statement.EnsureBlock();
var newBlock = innerBlock.WithStatements(innerBlock.Statements.Insert(0, foreachStmt)).WithAdditionalAnnotations(Formatter.Annotation);
var newUsing = usingStatement.WithStatement(newBlock);
var newRoot = root.ReplaceNode(usingStatement, newUsing.WithTrailingTrivia(usingStatement.GetTrailingTrivia()));
return Task.FromResult(document.WithSyntaxRoot(newRoot));
}
);
}
开发者ID:alecor191,项目名称:RefactoringEssentials,代码行数:20,代码来源:IterateViaForeachAction.cs
示例9: Initialize
public override void Initialize(AnalysisContext context)
{
context.RegisterSyntaxNodeActionInNonGenerated(
(System.Action<SyntaxNodeAnalysisContext>) ( c =>
{
reportedIssue = false;
analysisContext = (SyntaxNodeAnalysisContext)c;
usingStatement = (UsingStatementSyntax)c.Node;
var lockChecks = new LockChecks();
lockChecks.Start(c, Rule);
if (!lockChecks.isLock())
{
return;
}
SyntaxNode block = lockChecks.GetUsingBlock(ref c);
lockChecks.LockCheckinSimpleMemberAccess(block);
/* IfStatementSyntax firstIfStatement = lockChecks.GetFirstIfStatementInUsingBlock(block);
lockChecks.CheckExpressionIsNotLockApplied(firstIfStatement);
SyntaxNode ifAppliedNode = lockChecks.CheckIfStatementNotEmpty(firstIfStatement);
lockChecks.CheckReturnOrThrow( ifAppliedNode);
if (!"false".Equals((string)((ReturnStatementSyntax)returnStatement).Expression.ToString()))
{
var diagnostic = Diagnostic.Create(Rule, returnStatement.GetLocation(), "does not return literal false");
c.ReportDiagnostic(diagnostic);
return;
}
*/
}),
SyntaxKind.UsingStatement
);
}
开发者ID:peterstevens130561,项目名称:sonarlint-vs,代码行数:39,代码来源:ReadAndWriteLockApplied.cs
示例10: VisitUsingStatement
public override SyntaxNode VisitUsingStatement(UsingStatementSyntax node)
{
this.AppendCompileIssue(node, IssueType.Error, IssueId.UsingNotSupport);
return node;
}
开发者ID:rexzh,项目名称:SharpJs,代码行数:5,代码来源:Rewriter_BasicStructure.cs
示例11: UsingStatementBinder
public UsingStatementBinder(Binder enclosing, UsingStatementSyntax syntax)
: base(enclosing)
{
_syntax = syntax;
}
开发者ID:Rookieek,项目名称:roslyn,代码行数:5,代码来源:UsingStatementBinder.cs
示例12: HandleUsingStatement
/// <summary>
/// Handles the given using statement.
/// </summary>
/// <param name="stmt">Statement</param>
/// <param name="successor">Successor</param>
private void HandleUsingStatement(UsingStatementSyntax stmt, ControlFlowGraphNode successor)
{
this.SyntaxNodes.Add(stmt.Declaration);
this.IsJumpNode = true;
var usingNode = new ControlFlowGraphNode(this.Summary);
this.ISuccessors.Add(usingNode);
usingNode.IPredecessors.Add(this);
if (stmt.Statement is BlockSyntax)
{
usingNode.Construct((stmt.Statement as BlockSyntax).Statements, 0, false, successor);
}
else
{
usingNode.Construct(new SyntaxList<StatementSyntax> { stmt.Statement }, 0, false, successor);
}
}
开发者ID:jerickmsft,项目名称:PSharp,代码行数:23,代码来源:ControlFlowGraphNode.cs
示例13: InferTypeInUsingStatement
private IEnumerable<ITypeSymbol> InferTypeInUsingStatement(UsingStatementSyntax usingStatement, SyntaxToken? previousToken = null)
{
// If we have a position, it has to be after "using("
if (previousToken.HasValue && previousToken.Value != usingStatement.OpenParenToken)
{
return SpecializedCollections.EmptyEnumerable<ITypeSymbol>();
}
return SpecializedCollections.SingletonEnumerable(this.Compilation.GetSpecialType(SpecialType.System_IDisposable));
}
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:10,代码来源:CSharpTypeInferenceService.TypeInferrer.cs
示例14: VisitUsingStatement
public void VisitUsingStatement(UsingStatementSyntax node)
{
if (node == null)
throw new ArgumentNullException("node");
node.Validate();
WriteLeadingTrivia(node);
_writer.WriteIndent();
_writer.WriteKeyword(PrinterKeyword.Using);
if (_writer.Configuration.Spaces.BeforeParentheses.UsingParentheses)
_writer.WriteSpace();
_writer.WriteSyntax(Syntax.OpenParen);
if (_writer.Configuration.Spaces.WithinParentheses.UsingParentheses)
_writer.WriteSpace();
if (node.Expression != null)
node.Expression.Accept(this);
if (node.Declaration != null)
node.Declaration.Accept(this);
if (_writer.Configuration.Spaces.WithinParentheses.UsingParentheses)
_writer.WriteSpace();
_writer.WriteSyntax(Syntax.CloseParen);
if (
_writer.Configuration.Other.Other.IndentNestedUsingStatements &&
node.Statement is UsingStatementSyntax
) {
_writer.WriteLine();
node.Statement.Accept(this);
}
else
{
VisitBlockStatement(node.Statement);
}
WriteTrailingTrivia(node);
}
开发者ID:modulexcite,项目名称:CSharpSyntax,代码行数:44,代码来源:SyntaxPrinter.cs
示例15: UsingStatementBinder
public UsingStatementBinder(MethodSymbol owner, Binder enclosing, UsingStatementSyntax syntax)
: base(owner, enclosing)
{
this.syntax = syntax;
this.expressionHandler = syntax.Expression == null ? null : new LockOrUsingStatementExpressionHandler(syntax.Expression, this);
}
开发者ID:riversky,项目名称:roslyn,代码行数:6,代码来源:UsingStatementBinder.cs
示例16: BindUsingStatement
private BoundStatement BindUsingStatement(UsingStatementSyntax node, DiagnosticBag diagnostics)
{
var usingBinder = this.GetBinder(node);
Debug.Assert(usingBinder != null);
return usingBinder.BindUsingStatementParts(diagnostics, usingBinder);
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:6,代码来源:Binder_Statements.cs
示例17: VisitUsingStatement
public override void VisitUsingStatement(UsingStatementSyntax node)
{
if (node.Declaration != null)
{
AddVariableExpressions(node.Declaration.Variables, _expressions);
}
AddExpressionTerms(node.Expression, _expressions);
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:9,代码来源:CSharpProximityExpressionsService.RelevantExpressionsCollector.cs
示例18: AreEquivalentActiveStatements
private static bool AreEquivalentActiveStatements(UsingStatementSyntax oldNode, UsingStatementSyntax newNode)
{
// only check the expression/declaration, edits in the body are allowed:
return AreEquivalentIgnoringLambdaBodies(
(SyntaxNode)oldNode.Declaration ?? oldNode.Expression,
(SyntaxNode)newNode.Declaration ?? newNode.Expression);
}
开发者ID:GeertVL,项目名称:roslyn,代码行数:7,代码来源:CSharpEditAndContinueAnalyzer.cs
示例19: VisitUsingStatement
public override void VisitUsingStatement(UsingStatementSyntax node)
{
Debug.Assert((object)_containingMemberOrLambda == _enclosing.ContainingMemberOrLambda);
var usingBinder = new UsingStatementBinder(_enclosing, node);
AddToMap(node, usingBinder);
ExpressionSyntax expressionSyntax = node.Expression;
VariableDeclarationSyntax declarationSyntax = node.Declaration;
Debug.Assert((expressionSyntax == null) ^ (declarationSyntax == null)); // Can't have both or neither.
if (expressionSyntax != null)
{
Visit(expressionSyntax, usingBinder);
}
else
{
foreach (VariableDeclaratorSyntax declarator in declarationSyntax.Variables)
{
Visit(declarator, usingBinder);
}
}
VisitPossibleEmbeddedStatement(node.Statement, usingBinder);
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:25,代码来源:LocalBinderFactory.cs
示例20: VisitUsingStatementDeclarations
protected override void VisitUsingStatementDeclarations(UsingStatementSyntax node)
{
// Expecting one synthesized local for using statement with no explicit declaration.
if (node.Declaration == null)
{
Debug.Assert(node.Expression != null);
TryGetSlotIndex(SynthesizedLocalKind.Using);
this.offset++;
}
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:11,代码来源:CSharpDefinitionMap.LocalVisitors.cs
注:本文中的UsingStatementSyntax类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论