本文整理汇总了C#中ISolution.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# ISolution.GetComponent方法的具体用法?C# ISolution.GetComponent怎么用?C# ISolution.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISolution
的用法示例。
在下文中一共展示了ISolution.GetComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public void Execute(ISolution solution, ITextControl textControl)
{
if (!MethodDeclaration.IsValid())
{
return;
}
var containingFile = MethodDeclaration.GetContainingFile();
var psiModule = MethodDeclaration.GetPsiModule();
var elementFactory = CSharpElementFactory.GetInstance(psiModule);
var declared = MethodDeclaration.DeclaredElement;
if (declared != null)
{
var newName = declared.ShortName + "Async";
var refactoringService = solution.GetComponent<RenameRefactoringService>();
var suggests = new List<string> {newName};
SearchDomainFactory searchDomainFactory = solution.GetComponent<SearchDomainFactory>();
var workflow = (IRefactoringWorkflow)new MethodRenameWorkflow(suggests, solution.GetComponent<IShellLocks>(), searchDomainFactory, refactoringService, solution, "TypoRename");
var renames = RenameRefactoringService.Instance.CreateAtomicRenames(declared, newName, true).ToList();
// var workflow = RenameFromContexts.InitFromNameChanges(solution, renames);
// workflow.CreateRefactoring();
Lifetimes.Using(lifetime => RefactoringActionUtil.ExecuteRefactoring(solution.GetComponent<IActionManager>().DataContexts.CreateOnSelection(lifetime, DataRules.AddRule("DoTypoRenameWorkflow", DataConstants.SOLUTION, solution)), workflow));
}
}
示例2: Execute
public void Execute(ISolution solution, ITextControl textControl)
{
if (!_literalExpression.IsValid())
return;
IFile containingFile = _literalExpression.GetContainingFile();
CSharpElementFactory elementFactory = CSharpElementFactory.GetInstance(_literalExpression.GetPsiModule());
IExpression newExpression = null;
_literalExpression.GetPsiServices().PsiManager.DoTransaction(
() =>
{
using (solution.GetComponent<IShellLocks>().UsingWriteLock())
newExpression = ModificationUtil.ReplaceChild(
_literalExpression, elementFactory.CreateExpression("System.Int16.MaxValue"));
}, GetType().Name);
if (newExpression != null)
{
IRangeMarker marker = newExpression.GetDocumentRange().CreateRangeMarker(solution.GetComponent<DocumentManager>());
containingFile.OptimizeImportsAndRefs(
marker, false, true, NullProgressIndicator.Instance);
}
}
示例3: ExecutePsiTransaction
protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
{
var unitTestSessionManager = solution.GetComponent<IUnitTestSessionManager>();
var element = MethodRunnerElement.GetInstance(solution.GetComponent<MethodRunnerProvider>(), myClassDeclaration.GetClrName().FullName, myMethodDeclaration.DeclaredName, myClassDeclaration.IsStatic, myMethodDeclaration.IsStatic);
var sessionView = unitTestSessionManager.CreateSession();
sessionView.RunAll(solution.GetComponent<ProcessHostProvider>());
return null;
}
示例4: DoTransaction
private static IJavaScriptTreeNode DoTransaction(ISolution solution, JavaScriptElementFactory elementFactory,
Func<JavaScriptElementFactory, IJavaScriptTreeNode> addMethod)
{
IJavaScriptTreeNode newExpression;
using (solution.GetComponent<IShellLocks>().UsingWriteLock())
{
newExpression = addMethod(elementFactory);
}
return newExpression;
}
示例5: Execute
public void Execute(ISolution solution, ITextControl textControl)
{
try
{
if (!_literalExpression.IsValid())
{
return;
}
var psiModule = _literalExpression.GetPsiModule();
var psiManager = _literalExpression.GetPsiServices().PsiManager;
var containingFile = _literalExpression.GetContainingFile();
var csharpFile = containingFile as ICSharpFile;
var elementFactory = CSharpElementFactory.GetInstance(psiModule);
IExpression newExpression = null;
psiManager.DoTransaction(
() =>
{
using (solution.GetComponent<IShellLocks>().UsingWriteLock())
{
var replacementExpression =
elementFactory.CreateExpression(_literalExpression.GetText() + ".AsObservable()");
newExpression = ModificationUtil.ReplaceChild(_literalExpression, replacementExpression);
EnsureNamespaceExists(csharpFile, elementFactory);
}
}, GetType().Name);
if (newExpression != null)
{
var marker = newExpression.GetDocumentRange().CreateRangeMarker(solution.GetComponent<DocumentManager>());
containingFile.OptimizeImportsAndRefs(marker, false, true, NullProgressIndicator.Instance);
}
}
catch (Exception exn)
{
Debug.WriteLine("Failed AsObservableBulbItem, exception message - '{0}'", exn.Message);
}
}
示例6: Execute
public void Execute(ISolution solution, ITextControl textControl)
{
if (!MethodDeclaration.IsValid())
{
return;
}
var declared = MethodDeclaration.DeclaredElement;
if (declared != null)
{
var suggests = AsyncMethodNameSuggestions.Get(MethodDeclaration);
var workflow =
(IRefactoringWorkflow)
new MethodRenameWorkflow(suggests, solution.GetComponent<RenameRefactoringService>(), solution, "AsyncSuffixMethodRename");
Lifetimes.Using(lifetime =>
{
var dataRules = DataRules.AddRule("DoAsyncMethodRenameWorkflow", ProjectModelDataConstants.SOLUTION, solution);
var dataContext = solution.GetComponent<IActionManager>().DataContexts.CreateOnSelection(lifetime, dataRules);
RefactoringActionUtil.ExecuteRefactoring(dataContext, workflow);
});
}
}
示例7: ExecuteTransactionInner
/// <summary>
/// The execute transaction inner.
/// </summary>
/// <param name="solution">
/// The solution.
/// </param>
/// <param name="textControl">
/// The text control.
/// </param>
public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
{
ICSharpFile file = Utils.GetCSharpFile(solution, textControl);
Lifetimes.Using(
lifetime =>
{
StyleCopApi api = solution.GetComponent<StyleCopApiPool>().GetInstance(lifetime);
Settings settings = api.Settings.GetSettings(file.GetSourceFile().ToProjectFile());
// Fixes SA1208, SA1209, SA1210, SA1211
OrderingRules.ExecuteAll(file, settings);
});
}
示例8: Execute
public void Execute(ISolution solution, ITextControl textControl)
{
if (!_literalExpression.IsValid())
return;
var containingFile = _literalExpression.GetContainingFile();
var psiModule = _literalExpression.GetPsiModule();
var elementFactory = CSharpElementFactory.GetInstance(psiModule);
IExpression newExpression = null;
_literalExpression.GetPsiServices().Transactions.Execute(GetType().Name, () =>
{
using (solution.GetComponent<IShellLocks>().UsingWriteLock())
newExpression = ModificationUtil.ReplaceChild(
_literalExpression.Task, elementFactory.CreateExpression("$0.ConfigureAwait($1)", _literalExpression.Task,
elementFactory.CreateExpressionByConstantValue(CSharpConstantValueFactory.CreateBoolValue(_value, psiModule))));
});
if (newExpression != null)
{
IRangeMarker marker = newExpression.GetDocumentRange().CreateRangeMarker(solution.GetComponent<DocumentManager>());
containingFile.OptimizeImportsAndRefs(marker, false, true, NullProgressIndicator.Instance);
}
}
示例9: YouTrackPowerToyOptionsPage
public YouTrackPowerToyOptionsPage(IOptionsDialog optionsDialog, ISolution solution)
{
this.solution = solution;
if (this.solution != null)
{
InitializeComponent();
this.youTrackSettings = solution.GetComponent<YouTrackSettings>();
this.youTrackSettingsControl = new YouTrackSettingsControl(this.youTrackSettings);
this.Controls.Add(this.youTrackSettingsControl);
}
else
{
Controls.Add(JetBrains.UI.Options.Helpers.Controls.CreateNoSolutionCueBanner());
//Controls.Add(new RichTextLabel("You need to have an open solution to access these settings"));
}
}
示例10: ExploreSolution
public void ExploreSolution(ISolution solution, UnitTestElementConsumer consumer)
{
TestCache component;
try
{
component = solution.GetComponent<TestCache>();
}
catch
{
return;
}
component.ReanalyzeDirtyFiles();
foreach (var element in from e in component.UnitTestElements
where e.State.IsValid() && (e.Provider is KarmaTestProvider)
select e)
{
consumer(element);
}
}
示例11: ExecuteTransactionInner
/// <inheritdoc />
public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
{
ICSharpFile file = Utils.GetCSharpFile(solution, textControl);
Lifetimes.Using(
lifetime =>
{
StyleCopApi api = solution.GetComponent<StyleCopApiPool>().GetInstance(lifetime);
var settings = api.Settings.GetSettings(file.GetSourceFile().ToProjectFile());
// this covers the issue that constants (and maybe others) return the class if called as GetContainingElement<IDeclaration>)
IDeclaration declaration = Utils.GetTypeClosestToTextControl<IDeclaration>(solution, textControl);
if (declaration != null)
{
DocumentationRules.CheckDeclarationDocumentation(file, declaration, settings);
}
});
}
示例12: ExecutePsiTransaction
protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
{
if (!expression.IsValid())
return null;
IFile containingFile = expression.GetContainingFile();
JavaScriptElementFactory elementFactory = JavaScriptElementFactory.GetInstance(expression.GetPsiModule(), JavaScriptLanguage.Instance);
IJavaScriptTreeNode newExpression = null;
Func<JavaScriptElementFactory, IJavaScriptTreeNode> addMethod = AddUseStrict;
expression.GetPsiServices().PsiManager.DoTransaction(
() =>
{
newExpression = DoTransaction(solution, elementFactory, addMethod);
}, GetType().Name);
if (newExpression != null)
{
IRangeMarker marker = newExpression.GetDocumentRange().CreateRangeMarker(solution.GetComponent<DocumentManager>());
containingFile.OptimizeImportsAndRefs(marker, false, true, NullProgressIndicator.Instance);
}
return null;
}
示例13: GetCache
protected NTriplesCache GetCache(ISolution solution)
{
// always perform unscoped search
return solution.GetComponent<NTriplesCache>();
}
示例14: ExecutePsiTransaction
/// <summary>
/// Performs the QuickFix, ensures the file is both writable and creates a transaction.
/// </summary>
/// <param name="solution">
/// Current Solution.
/// </param>
/// <param name="progress">
/// Progress Indicator for the fix.
/// </param>
/// <returns>
/// The execute transaction.
/// </returns>
protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, JetBrains.Application.Progress.IProgressIndicator progress)
{
return delegate(ITextControl textControl)
{
solution.GetComponent<DocumentManagerOperations>().SaveAllDocuments();
using (solution.GetComponent<DocumentTransactionManager>().CreateTransactionCookie(JetBrains.Util.DefaultAction.Commit, "action name"))
{
var services = solution.GetPsiServices();
services.Transactions.Execute(
"Code cleanup",
() => services.Locks.ExecuteWithWriteLock(() => { ExecuteTransactionInner(solution, textControl); }));
}
};
}
示例15: Execute
public void Execute(ISolution solution, ITextControl textControl)
{
try
{
var psiManager = _expression.GetPsiServices().PsiManager;
var sourceFile = _expression.GetSourceFile();
if (sourceFile == null)
{
// What not source file!
return;
}
var psiFile = sourceFile.GetNonInjectedPsiFile<CSharpLanguage>();
if (psiFile == null)
{
// It's not a CSharp file...
return;
}
var expressions = new List<IInvocationExpression>();
psiFile.ProcessChildren<IInvocationExpression>(expressions.Add);
var index = expressions.FindIndex(c => c == _expression);
var previousIndex = index + 1;
if (previousIndex > (expressions.Count - 1))
{
// There isn't a previous invocation expression...
return;
}
var previousExpression = expressions[previousIndex];
var firstChild = previousExpression.FirstChild;
if (firstChild == null)
{
return;
}
var arugmentList = previousExpression.Children<IArgumentList>().SingleOrDefault();
if (arugmentList == null)
{
return;
}
var containingFile = _expression.GetContainingFile();
var elementFactory = CSharpElementFactory.GetInstance(sourceFile.PsiModule);
IExpression newExpression = null;
psiManager.DoTransaction(
() =>
{
using (solution.GetComponent<IShellLocks>().UsingWriteLock())
{
var preText = firstChild.GetText();
var arugmentListText = arugmentList.GetText();
var lastSelectIndex = preText.LastIndexOf(Constants.SelectMethodName,
StringComparison.Ordinal);
var formattedPreText = preText.Remove(lastSelectIndex, Constants.SelectMethodName.Length)
.Insert(lastSelectIndex, Constants.SelectManyMethodName);
var replacementExpressionText = string.Format(ReplacementTextFormat, formattedPreText,
arugmentListText);
var replacementExpression = elementFactory.CreateExpression(replacementExpressionText);
newExpression = ModificationUtil.ReplaceChild(_expression, replacementExpression);
}
}, GetType().Name);
if (newExpression != null)
{
var marker =
newExpression.GetDocumentRange().CreateRangeMarker(solution.GetComponent<DocumentManager>());
containingFile.OptimizeImportsAndRefs(marker, false, true, NullProgressIndicator.Instance);
}
}
catch (Exception exn)
{
Debug.WriteLine("Failed SelectAndMergeBulbItem, exception message - '{0}'", exn.Message);
}
}