本文整理汇总了C#中IStatement类的典型用法代码示例。如果您正苦于以下问题:C# IStatement类的具体用法?C# IStatement怎么用?C# IStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IStatement类属于命名空间,在下文中一共展示了IStatement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestTryCombine
public static void TestTryCombine([PexAssumeUnderTest] StatementLoopOverGroupItems target, IStatement statement)
{
var canComb = target.TryCombineStatement(statement, null);
Assert.IsNotNull(statement, "Second statement null should cause a failure");
var allSame = target.CodeItUp().Zip(statement.CodeItUp(), (f, s) => f == s).All(t => t);
Assert.IsTrue(allSame == canComb || target.Statements.Count() == 0, "not expected combination!");
}
示例2: CanHandle
/// <summary>Determines whether this instance can handle the specified statement.</summary>
/// <param name="statement">The statement.</param>
/// <returns><c>true</c> if this instance can handle the specified statement; otherwise, <c>false</c>.</returns>
public override bool CanHandle(IStatement statement)
{
var ifStatement = statement as IIfStatement;
if (ifStatement == null)
{
return false;
}
var referenceExpression = ifStatement.Condition as IReferenceExpression;
if (referenceExpression == null)
{
return false;
}
var resolveResult = referenceExpression.Reference.Resolve();
if (!resolveResult.IsValid())
{
return false;
}
var declaredElement = resolveResult.DeclaredElement as ITypeMember;
if (declaredElement == null)
{
return false;
}
return true;
}
开发者ID:JakobChristensen,项目名称:Resharper.PredictiveCodeSuggestions,代码行数:31,代码来源:IfInvocationAnalyzer.cs
示例3: TestTryCombine
public static void TestTryCombine([PexAssumeUnderTest] StatementRecordPairValues target, IStatement statement)
{
var canComb = target.TryCombineStatement(statement, null);
Assert.IsNotNull(statement, "Second statement null should cause a failure");
var allSame = target.CodeItUp().Zip(statement.CodeItUp(), (f, s) => f == s).All(t => t);
Assert.AreEqual(allSame, canComb, "not expected combination!");
}
示例4: CanHandle
/// <summary>Determines whether this instance can handle the specified statement.</summary>
/// <param name="statement">The statement.</param>
/// <returns><c>true</c> if this instance can handle the specified statement; otherwise, <c>false</c>.</returns>
public override bool CanHandle(IStatement statement)
{
var ifStatement = statement as IIfStatement;
if (ifStatement == null)
{
return false;
}
var equalityExpression = ifStatement.Condition as IEqualityExpression;
if (equalityExpression == null)
{
return false;
}
var operand = equalityExpression.RightOperand;
if (operand == null)
{
return false;
}
if (operand.GetText() == "null")
{
return true;
}
operand = equalityExpression.LeftOperand;
if (operand == null)
{
return false;
}
return operand.GetText() == "null";
}
示例5: FindCurrentCaretContext
public static ISyntaxRegion FindCurrentCaretContext(IEditorData editor,
ref IBlockNode currentScope,
out IStatement currentStatement,
out bool isInsideNonCodeSegment)
{
isInsideNonCodeSegment = false;
currentStatement = null;
if(currentScope == null)
currentScope = DResolver.SearchBlockAt (editor.SyntaxTree, editor.CaretLocation, out currentStatement);
if (currentScope == null)
return null;
BlockStatement blockStmt;
// Always skip lambdas as they're too quirky for accurate scope calculation // ISSUE: May be other anon symbols too?
var dm = currentScope as DMethod;
if (dm != null && (dm.SpecialType & DMethod.MethodType.Lambda) != 0)
currentScope = dm.Parent as IBlockNode;
if (currentScope is DMethod &&
(blockStmt = (currentScope as DMethod).GetSubBlockAt (editor.CaretLocation)) != null) {
blockStmt.UpdateBlockPartly (editor, out isInsideNonCodeSegment);
currentScope = DResolver.SearchBlockAt (currentScope, editor.CaretLocation, out currentStatement);
}else {
while (currentScope is DMethod)
currentScope = currentScope.Parent as IBlockNode;
if (currentScope == null)
return null;
(currentScope as DBlockNode).UpdateBlockPartly (editor, out isInsideNonCodeSegment);
currentScope = DResolver.SearchBlockAt (currentScope, editor.CaretLocation, out currentStatement);
}
return currentScope;
}
示例6: Handle
/// <summary>Handles the specified statement.</summary>
/// <param name="statement">The statement.</param>
/// <param name="scope">The scope.</param>
/// <returns>Returns the string.</returns>
public override StatementDescriptor Handle(IStatement statement, AutoTemplateScope scope)
{
var tryStatement = statement as ITryStatement;
if (tryStatement == null)
{
return null;
}
var result = new StatementDescriptor(scope)
{
Template = string.Format("try {{ $END$ }}")
};
foreach (var catchClause in tryStatement.Catches)
{
var type = catchClause.ExceptionType;
if (type == null)
{
result.Template += " catch { }";
continue;
}
var typeName = type.GetLongPresentableName(tryStatement.Language);
result.Template += string.Format(" catch ({0}) {{ }}", typeName);
}
return result;
}
示例7: Handle
/// <summary>Handles the specified statement.</summary>
/// <param name="statement">The statement.</param>
/// <param name="scope">The scope.</param>
/// <returns>Returns the string.</returns>
public override StatementDescriptor Handle(IStatement statement, AutoTemplateScope scope)
{
var returnStatement = statement as IReturnStatement;
if (returnStatement == null)
{
return null;
}
var value = returnStatement.Value;
if (value == null)
{
return new StatementDescriptor(scope)
{
Template = "return;"
};
}
var expressionDescriptor = ExpressionTemplateBuilder.Handle(value, scope.ScopeParameters);
if (expressionDescriptor == null)
{
return null;
}
return new StatementDescriptor(scope, string.Format("return {0}", expressionDescriptor.Template), expressionDescriptor.TemplateVariables);
}
示例8: Handle
/// <summary>Handles the specified statement.</summary>
/// <param name="statement">The statement.</param>
/// <returns>Returns the I enumerable.</returns>
public override AutoTemplateScope Handle(IStatement statement)
{
var expressionStatement = statement as IExpressionStatement;
if (expressionStatement == null)
{
return null;
}
var assignmentExpression = expressionStatement.Expression as IAssignmentExpression;
if (assignmentExpression == null)
{
return null;
}
var scopeParameters = new Dictionary<string, string>();
if (!HandleAssignment(assignmentExpression, scopeParameters))
{
return null;
}
string variableType;
if (!scopeParameters.TryGetValue("FullName", out variableType))
{
variableType = "(unknown variable)";
}
var key = string.Format("After variable of type \"{0}\"", variableType);
return new AutoTemplateScope(statement, key, scopeParameters);
}
示例9: FirstStatementIsIteratorCreation
private static IMethodBody/*?*/ FirstStatementIsIteratorCreation(IMetadataHost host, ISourceMethodBody possibleIterator, INameTable nameTable, IStatement statement) {
ICreateObjectInstance createObjectInstance = GetICreateObjectInstance(statement);
if (createObjectInstance == null) {
// If the first statement in the method body is not the creation of iterator closure, return a dummy.
// Possible corner case not handled: a local is used to hold the constant value for the initial state of the closure.
return null;
}
ITypeReference closureType/*?*/ = createObjectInstance.MethodToCall.ContainingType;
ITypeReference unspecializedClosureType = ContractHelper.Unspecialized(closureType);
if (!AttributeHelper.Contains(unspecializedClosureType.Attributes, host.PlatformType.SystemRuntimeCompilerServicesCompilerGeneratedAttribute))
return null;
INestedTypeReference closureTypeAsNestedTypeReference = unspecializedClosureType as INestedTypeReference;
if (closureTypeAsNestedTypeReference == null) return null;
ITypeReference unspecializedClosureContainingType = ContractHelper.Unspecialized(closureTypeAsNestedTypeReference.ContainingType);
if (closureType != null && TypeHelper.TypesAreEquivalent(possibleIterator.MethodDefinition.ContainingTypeDefinition, unspecializedClosureContainingType)) {
IName MoveNextName = nameTable.GetNameFor("MoveNext");
foreach (ITypeDefinitionMember member in closureType.ResolvedType.GetMembersNamed(MoveNextName, false)) {
IMethodDefinition moveNext = member as IMethodDefinition;
if (moveNext != null) {
ISpecializedMethodDefinition moveNextGeneric = moveNext as ISpecializedMethodDefinition;
if (moveNextGeneric != null)
moveNext = moveNextGeneric.UnspecializedVersion.ResolvedMethod;
return moveNext.Body;
}
}
}
return null;
}
示例10: Insert
public Task Insert(IStatement statement)
{
_queriesWaitingInLineSemaphore.Wait(); // Since the dataset does not fit in memory, we limit the pending queries count
var taskCompletionSource = new TaskCompletionSource<RowSet>();
_insertionQueue.Post(new PendingInsert { Statement = statement, Completion = taskCompletionSource });
return taskCompletionSource.Task;
}
示例11: MemberCompletionProvider
public MemberCompletionProvider(ICompletionDataGenerator cdg, ISyntaxRegion sr, IBlockNode b, IStatement stmt)
: base(cdg)
{
AccessExpression = sr;
ScopedBlock = b;
ScopedStatement = stmt;
}
示例12: ForStatement
public ForStatement(IExpression initialization, IExpression condition, IExpression step, IStatement statement)
: base(statement)
{
this.initialization = initialization;
this.condition = condition;
this.step = step;
}
示例13: AddStatement
public void AddStatement(IStatement statement)
{
if (statement == null)
throw new ArgumentNullException("statement");
statements.Add(statement);
}
示例14: ProcedureSql
/// <summary>
/// Constructor
/// </summary>
/// <param name="statement">The statement.</param>
/// <param name="sqlStatement"></param>
/// <param name="scope"></param>
public ProcedureSql(IScope scope, string sqlStatement, IStatement statement)
{
_sqlStatement = sqlStatement;
_statement = statement;
_dataExchangeFactory = scope.DataExchangeFactory;
}
示例15: ContextFrame
public ContextFrame(ResolutionContext ctxt, IBlockNode b, IStatement stmt = null)
{
this.ctxt = ctxt;
declarationCondititons = new ConditionalCompilation.ConditionSet(ctxt.CompilationEnvironment);
Set(b,stmt);
}