本文整理汇总了C#中ISolution.GetPsiServices方法的典型用法代码示例。如果您正苦于以下问题:C# ISolution.GetPsiServices方法的具体用法?C# ISolution.GetPsiServices怎么用?C# ISolution.GetPsiServices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISolution
的用法示例。
在下文中一共展示了ISolution.GetPsiServices方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AfterCompletion
protected override sealed void AfterCompletion(
ITextControl textControl, ISolution solution, Suffix suffix,
TextRange resultRange, string targetText, int caretOffset)
{
solution.GetPsiServices().CommitAllDocuments();
var expressions = TextControlToPsi
.GetSelectedElements<ICSharpExpression>(solution, textControl.Document, resultRange);
foreach (var expression in expressions)
{
AcceptExpression(textControl, solution, resultRange, expression);
break;
}
}
示例2: Build
public IContextActionDataProvider Build(ISolution solution, ITextControl textControl)
{
if (!solution.GetPsiServices().Caches.IsIdle.Value)
{
return null;
}
IPsiSourceFile psiSourceFile = textControl.Document.GetPsiSourceFile(solution);
if (psiSourceFile == null || !psiSourceFile.IsValid())
{
return null;
}
var file =
psiSourceFile.GetPsiFile<NTriplesLanguage>(new DocumentRange(textControl.Document, textControl.Caret.Offset())) as
INTriplesFile;
if (file == null || !file.IsValid() || !file.Language.Is<NTriplesLanguage>())
{
return null;
}
return new NTriplesContextActionDataProvider(solution, textControl, file);
}
示例3: 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); }));
}
};
}
示例4: Accept
public void Accept(
ITextControl textControl, TextRange nameRange,
LookupItemInsertType insertType, Suffix suffix,
ISolution solution, bool keepCaretStill)
{
// find target expression after code completion
var expressionRange = myExpressionRange.Range;
if (myWasReparsed)
{
textControl.Document.ReplaceText(nameRange, "__");
solution.GetPsiServices().CommitAllDocuments();
nameRange = TextRange.FromLength(nameRange.StartOffset, 2);
}
var expression = (ICSharpExpression) FindMarkedNode(
solution, textControl, expressionRange, nameRange, typeof(ICSharpExpression));
if (expression == null)
{
// still can be parsed as IReferenceName
var referenceName = (IReferenceName) FindMarkedNode(
solution, textControl, expressionRange, nameRange, typeof(IReferenceName));
if (referenceName == null) return;
// reparse IReferenceName as ICSharpExpression
var factory = CSharpElementFactory.GetInstance(referenceName.GetPsiModule(), false);
expression = factory.CreateExpression(referenceName.GetText());
}
// take required component while tree is valid
var psiModule = expression.GetPsiModule();
var reference = FindMarkedNode(
solution, textControl, myReferenceRange.Range, nameRange, myReferenceType);
// Razor.{caret} case
if (reference == expression && myWasReparsed)
{
var parentReference = reference.Parent as IReferenceExpression;
if (parentReference != null && parentReference.NameIdentifier.Name == "__")
reference = parentReference;
}
// calculate textual range to remove
var replaceRange = CalculateRangeToRemove(nameRange, expression, reference);
// fix "x > 0.if" to "x > 0"
ICSharpExpression expressionCopy;
if (reference != null && expression.Contains(reference))
{
expressionCopy = FixExpression(expression, reference);
}
else
{
expressionCopy = expression.IsPhysical() ? expression.Copy(expression) : expression;
}
Assertion.Assert(!expressionCopy.IsPhysical(), "expressionCopy is physical");
ExpandPostfix(
textControl, suffix, solution,
replaceRange, psiModule, expressionCopy);
}
示例5: GetPrimaryMembers
private IEnumerable<NTriplesFileMemberData> GetPrimaryMembers(ISolution solution)
{
var cache = solution.GetComponent<NTriplesCache>();
//var subjects = cache.GetImportantSubjects().ToArray();
var symbolsByFile = cache.GetAllUriIdentifierSymbolsByFile();
var services = solution.GetPsiServices();
foreach (var symbols in symbolsByFile)
{
var file = symbols.Key;
var sourceFile = file.GetPsiFile(NTriplesLanguage.Instance, new DocumentRange(file.Document, 0));
foreach (var symbol in symbols.Value)
{
var uriIdentifier = new UriIdentifierDeclaredElement(
sourceFile, symbol.Namespace, symbol.LocalName, symbol.Info, services, true);
yield return new NTriplesFileMemberData(uriIdentifier, ContainerDisplayStyle.NoContainer);
}
}
}
示例6: NarrowSearchDomain
private ISearchDomain NarrowSearchDomain(ISolution solution, IEnumerable<string> words, IEnumerable<string> extendedWords, ISearchDomain domain)
{
List<string> allWords = words.ToList();
List<string> allExtendedWords = extendedWords.ToList();
if (domain.IsEmpty || allWords.IsEmpty())
return domain;
IWordIndex wordIndex = solution.GetPsiServices().CacheManager.WordIndex;
var jetHashSet1 = new JetHashSet<IPsiSourceFile>(wordIndex.GetFilesContainingWord(allWords.First()), null);
foreach (string word in allWords.Skip(1))
jetHashSet1.IntersectWith(wordIndex.GetFilesContainingWord(word));
if (allExtendedWords.Any())
{
var jetHashSet2 = new JetHashSet<IPsiSourceFile>(null);
using (JetHashSet<IPsiSourceFile>.ElementEnumerator enumerator = jetHashSet1.GetEnumerator())
{
while (enumerator.MoveNext())
{
IPsiSourceFile file = enumerator.Current;
if (allExtendedWords.Any(word => wordIndex.CanContainWord(file, word)))
jetHashSet2.Add(file);
}
}
jetHashSet1 = jetHashSet2;
}
return domain.Intersect(searchDomainFactory.CreateSearchDomain(jetHashSet1));
}
示例7: FindType
private static List<IClrDeclaredElement> FindType(ISolution solution, string typeToFind)
{
ISymbolScope declarationsCache = solution.GetPsiServices().Symbols
.GetSymbolScope(LibrarySymbolScope.FULL, false);
List<IClrDeclaredElement> results = declarationsCache.GetElementsByShortName(typeToFind).ToList();
return results;
}
示例8: ExecutePsiTransaction
/// <inheritdoc/>
protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
{
return textControl =>
{
using (solution.GetComponent<DocumentTransactionManager>()
.CreateTransactionCookie(DefaultAction.Commit, "action name"))
{
var services = solution.GetPsiServices();
services.Transactions.Execute(
"Code cleanup",
() => services.Locks.ExecuteWithWriteLock(() =>
{
ICSharpTypeAndNamespaceHolderDeclaration holder = _highlighting.TypeAndNamespaceHolder;
Fixes.FixOrder(holder, _highlighting.Config);
Fixes.FixSpacing(holder, _highlighting.Config);
}));
}
};
}