本文整理汇总了C#中IProgressIndicator类的典型用法代码示例。如果您正苦于以下问题:C# IProgressIndicator类的具体用法?C# IProgressIndicator怎么用?C# IProgressIndicator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IProgressIndicator类属于命名空间,在下文中一共展示了IProgressIndicator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecutePsiTransaction
protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
{
var factory = CSharpElementFactory.GetInstance(_statement);
var valueType = GuessValueType(_dictionary) ?? "var";
var valueVariableName = SuggestVariableName(_statement, "value");
var valueReference = factory.CreateReferenceExpression(valueVariableName);
var valueDeclaration = factory.CreateStatement("$0 $1;", valueType, valueVariableName);
var newCondition = factory.CreateExpression("$0.TryGetValue($1, out $2)", _dictionary, _key, valueReference);
using (_statement.CreateWriteLock())
{
_dictionaryAccess.Where(x => x.IsValid()).ForEach(e => ModificationUtil.ReplaceChild(e, valueReference));
ModificationUtil.ReplaceChild(_matchedElement, newCondition);
if (_statement.Parent is IBlock)
{
ModificationUtil.AddChildBefore(_statement, valueDeclaration);
}
else
{
_statement.ReplaceBy(factory.CreateBlock("{$0$1}", valueDeclaration, _statement));
}
}
return null;
}
示例2: ExecutePsiTransaction
/// <summary>
/// Executes QuickFix or ContextAction. Returns post-execute method.
/// </summary>
/// <returns>
/// Action to execute after document and PSI transaction finish. Use to open TextControls, navigate caret, etc.
/// </returns>
protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution,
IProgressIndicator progress)
{
this.highlighting.PropertyDeclaration.AccessorDeclarations.First(o => o.Kind == AccessorKind.SETTER).SetAccessRights(AccessRights.PRIVATE);
return null;
}
开发者ID:Testeroids,项目名称:Testeroids.ReSharper.Plugins,代码行数:13,代码来源:MakePropertySetterPrivateQuickFix.cs
示例3: ExecutePsiTransaction
protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
{
var factory = CSharpElementFactory.GetInstance(_literalExpression);
var newExpr = factory.CreateExpressionAsIs(_replacement);
_literalExpression.ReplaceBy(newExpr);
return null;
}
示例4: ExecutePsiTransaction
protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
{
var block = myProvider.GetSelectedElement<IBlock>().NotNull();
var statements = block.GetStatementsRange(myProvider.SelectedTreeRange).Statements;
var invocation = ExtractInvocation(statements[0]).NotNull();
for (int i = 1; i < statements.Count - 1; i++)
{
var nextInvocation = ExtractInvocation(statements[i]).NotNull();
invocation = MergeInvocations(invocation, nextInvocation);
}
var lastDeclaredVariable = ExtractDeclaredVariableName(statements[statements.Count - 2]);
var lastInvocationUse =
FindLastInvocationUse(statements[statements.Count - 1], lastDeclaredVariable.Name).NotNull();
var lastInvocation = lastInvocationUse.GetContainingNode<IInvocationExpression>().NotNull();
MergeInvocations(invocation, lastInvocation);
for (int i = 0; i < statements.Count - 1; i++)
{
block.RemoveStatement((ICSharpStatement) statements[i]);
}
var lastStatementCoords = DocumentHelper.GetPositionAfterStatement(statements[statements.Count - 1], myProvider.Document);
return textControl =>
{
textControl.Selection.RemoveSelection(false);
textControl.Caret.MoveTo(lastStatementCoords, CaretVisualPlacement.DontScrollIfVisible);
};
}
示例5: ExecutePsiTransaction
protected sealed override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
{
Debug.Assert(attributesOwnerDeclaration != null);
Debug.Assert(createAttributeFactory != null);
try
{
using (WriteLockCookie.Create())
{
var factory = CSharpElementFactory.GetInstance(provider.PsiModule);
var attribute = createAttributeFactory(factory);
Debug.Assert(attribute != null);
attributesOwnerDeclaration.AddAttributeAfter(attribute, attributeToRemove);
if (attributeToRemove != null)
{
attributesOwnerDeclaration.RemoveAttribute(attributeToRemove);
}
ContextActionUtils.FormatWithDefaultProfile(attribute);
}
return _ => { };
}
finally
{
attributeToRemove = null;
createAttributeFactory = null;
attributesOwnerDeclaration = null;
}
}
示例6: StringExtractor
public StringExtractor(string text, IProgressIndicator progressIndicator)
: base(progressIndicator)
{
m_Text = text;
ProgressIndicator = progressIndicator;
ProgressIndicator.Maximum = m_Text.Length;
}
示例7: Process
public void Process(IPsiSourceFile sourceFile, IRangeMarker rangeMarker, CodeCleanupProfile profile, IProgressIndicator progressIndicator)
{
var file = sourceFile.GetNonInjectedPsiFile<CSharpLanguage>();
if (file == null)
return;
if (!profile.GetSetting(DescriptorInstance))
return;
CSharpElementFactory elementFactory = CSharpElementFactory.GetInstance(sourceFile.PsiModule);
file.GetPsiServices().PsiManager.DoTransaction(
() =>
{
using (_shellLocks.UsingWriteLock())
file.ProcessChildren<IExpression>(
expression =>
{
ConstantValue value = expression.ConstantValue;
if (value.IsInteger() && Convert.ToInt32(value.Value) == int.MaxValue)
ModificationUtil.ReplaceChild(expression, elementFactory.CreateExpression("int.MaxValue"));
}
);
},
"Code cleanup");
}
示例8: ExecutePsiTransaction
protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
{
if (_invocationExpression.ArgumentList.Arguments.Count == 4)
{
_invocationExpression.RemoveArgument(_invocationExpression.ArgumentList.Arguments[3]);
var argument = Provider.ElementFactory.CreateArgument(ParameterKind.VALUE, Provider.ElementFactory.CreateExpression("false"));
_invocationExpression.AddArgumentAfter(argument, _invocationExpression.ArgumentList.Arguments[2]);
}
else
{
if (_invocationExpression.ArgumentList.Arguments.Count == 1)
{
var argument = Provider.ElementFactory.CreateArgument(ParameterKind.VALUE, Provider.ElementFactory.CreateExpression("default($0)", PropertyDeclaration.Type));
_invocationExpression.AddArgumentAfter(argument, _invocationExpression.ArgumentList.Arguments[0]);
}
if (_invocationExpression.ArgumentList.Arguments.Count == 2)
{
var argument = Provider.ElementFactory.CreateArgument(ParameterKind.VALUE, Provider.ElementFactory.CreateExpression("null"));
_invocationExpression.AddArgumentAfter(argument, _invocationExpression.ArgumentList.Arguments[1]);
}
if (_invocationExpression.ArgumentList.Arguments.Count == 3)
{
var argument = Provider.ElementFactory.CreateArgument(ParameterKind.VALUE, Provider.ElementFactory.CreateExpression("false"));
_invocationExpression.AddArgumentAfter(argument, _invocationExpression.ArgumentList.Arguments[2]);
}
}
return null;
}
示例9: ExecutePsiTransaction
/// <summary>
/// Executes QuickFix or ContextAction. Returns post-execute method.
/// </summary>
/// <param name="solution">The solution.</param>
/// <param name="progress">The progress.</param>
/// <returns>Action to execute after document and PSI transaction finish. Use to open TextControls, navigate caret, etc.</returns>
protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
{
var model = this.GetModel();
if (model == null)
{
return null;
}
var function = model.Method;
if (function != null)
{
function.SetAbstract(true);
function.SetVirtual(false);
function.SetBody(null);
}
var property = model.Property;
if (property != null)
{
property.SetAbstract(true);
property.SetVirtual(false);
foreach (var accessor in property.AccessorDeclarations)
{
accessor.SetBody(null);
}
}
model.Class.SetAbstract(true);
return null;
}
示例10: ConvertMethods
private bool ConvertMethods(IProgressIndicator pi)
{
if (base.NewMembers == null) return false;
const int totalWorkUnits = 3;
pi.Start(totalWorkUnits);
var myWorkflow = Workflow as SharedToExtensionWorkflow;
if (myWorkflow != null)
Methods = base.NewMembers.OfType<IMethod>().ToList();
using (var progressIndicator = pi.CreateSubProgress(1.0))
FindUsages(progressIndicator);
var isSharedToExtension = (this.Direction == SharedToExtensionWorkflow.WorkflowDirection.SharedToExtension);
this.Methods.ForEachWithProgress(pi.CreateSubProgress(1.0), "",
method => {
this.Constructors[method.PresentationLanguage].MakeFirstPrameterThis(method, isSharedToExtension, this.Driver);
method.GetPsiServices().Caches.Update();
});
if (isSharedToExtension)
using (var progressIndicator = pi.CreateSubProgress(1.0))
MakeCallExtension(progressIndicator);
else
using (var progressIndicator = pi.CreateSubProgress(1.0))
MakeCallShared(progressIndicator);
return true;
}
示例11: ExecutePsiTransaction
/// <summary>
/// Executes QuickFix or ContextAction. Returns post-execute method.
/// </summary>
/// <returns>
/// Action to execute after document and PSI transaction finish. Use to open TextControls, navigate caret, etc.
/// </returns>
protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution,
IProgressIndicator progress)
{
var declaration = this.highlight.GetEstablishmentMethodDeclaration();
declaration.SetSealed(true);
return null;
}
开发者ID:Testeroids,项目名称:Testeroids.ReSharper.Plugins,代码行数:13,代码来源:EnforceSealedEstablismentMethodsQuickFix.cs
示例12: ExecutePsiTransaction
protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
{
var exceptionDeclaration =
(IClassDeclaration)_highlighting.ExceptionClass.GetDeclarations().FirstOrDefault();
Contract.Assert(exceptionDeclaration != null);
using (var workflow = GeneratorWorkflowFactory.CreateWorkflowWithoutTextControl(
GeneratorStandardKinds.Constructor,
exceptionDeclaration,
exceptionDeclaration))
{
Contract.Assert(workflow != null);
var ctors = workflow.Context.ProvidedElements
.OfType<GeneratorDeclaredElement<IConstructor>>()
.Where(ge => _missedConstructorPredicate(ge.DeclaredElement))
.ToList();
Contract.Assert(ctors.Count != 0);
workflow.Context.InputElements.Clear();
workflow.Context.InputElements.AddRange(ctors);
workflow.BuildOptions();
workflow.Generate("Generate missing constructor", NullProgressIndicator.Instance);
}
return null;
}
示例13: ExecutePsiTransaction
protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
{
if (_highlighting.ObjectCreationExpression.Initializer != null)
{
return textControl =>
JetBrains.UI.Application.ShellComponentsEx.Tooltips(Shell.Instance.Components)
.Show("Not supported for object initializers", l => (IPopupWindowContext)new TextControlPopupWindowContext(l, textControl, Shell.Instance.GetComponent<IShellLocks>(), Shell.Instance.GetComponent<IActionManager>()));
}
var psiModule = _highlighting.ObjectCreationExpression.GetPsiModule();
var factory = CSharpElementFactory.GetInstance(psiModule);
var activatorType = TypeFactory.CreateTypeByCLRName("System.Activator", psiModule);
var typeType = TypeFactory.CreateTypeByCLRName("System.Type", psiModule);
var intefaceType = TypeFactory.CreateTypeByCLRName(_highlighting.InterfaceTypeName, psiModule);
var statement = factory.CreateExpression("($3)$0.CreateInstance($1.GetTypeFromCLSID(typeof($2).GUID))",
activatorType.GetTypeElement(),
typeType.GetTypeElement(),
_highlighting.CoClassTypeElement,
intefaceType
);
var containingDeclarationStatement = _highlighting.ObjectCreationExpression.GetContainingStatement() as IDeclarationStatement;
if (containingDeclarationStatement != null && containingDeclarationStatement.Declaration.Declarators.Count == 1)
{
containingDeclarationStatement.Declaration.Declarators[0].SetTypeOrVar(intefaceType);
}
_highlighting.ObjectCreationExpression.ReplaceBy(statement);
return null;
}
示例14: PostExecute
public override bool PostExecute(IProgressIndicator pi)
{
try
{
if (!base.PostExecute(pi)) return false;
RunnerFileWatcher.Path = Solution.SolutionFilePath.Directory.FullPath;
RunnerFileWatcher.OnFileChange(f =>
ObjectFactory.NewRenameStep
(
f.FeatureFileFromRunner(),
InitialName,
InitialStageExecuter.NewName
)
.Execute());
}
catch (Exception e)
{
MessageBox.ShowInfo(e.ToString());
}
return true;
}
示例15: ExecutePsiTransaction
protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
{
ITypeDeclaration typeDeclaration = GetTargetTypeDeclaration(_highlighting.DeclaredTypeUsage);
if (typeDeclaration == null)
return null;
MemberSignature signature = CreateTransformTextSignature(typeDeclaration);
TypeTarget target = CreateTarget(typeDeclaration);
var context = new CreateMethodDeclarationContext {
AccessRights = AccessRights.PUBLIC,
ExecuteTemplateOverMemberBody = false,
ExecuteTemplateOverName = false,
ExecuteTemplateOverParameters = false,
ExecuteTemplateOverReturnType = false,
IsAbstract = true,
IsStatic = false,
MethodSignatures = new[] { signature },
MethodName = T4CSharpCodeGenerator.TransformTextMethodName,
SourceReferenceExpressionReference = null,
Target = target,
};
IntentionResult intentionResult = MethodDeclarationBuilder.Create(context);
intentionResult.ExecuteTemplate();
return null;
}