本文整理汇总了C#中IProjectFile.GetSolution方法的典型用法代码示例。如果您正苦于以下问题:C# IProjectFile.GetSolution方法的具体用法?C# IProjectFile.GetSolution怎么用?C# IProjectFile.GetSolution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProjectFile
的用法示例。
在下文中一共展示了IProjectFile.GetSolution方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessProjectItem
///<returns>
///True if further search is not needed
///</returns>
///
public bool ProcessProjectItem(IProjectFile projectItem)
{
IFile psiFile = PsiManager.GetInstance(projectItem.GetSolution()).GetPsiFile(projectItem);
if (psiFile != null)
{
return this.ProcessElement(psiFile);
}
return false;
}
示例2: GetXmlFile
protected static IXmlFile GetXmlFile(IProjectFile projectFile)
{
if (projectFile == null)
{
return null;
}
PsiManager manager = PsiManager.GetInstance(projectFile.GetSolution());
if (!manager.IsCommitted(projectFile))
{
return null;
}
return (manager.GetPsiFile(projectFile) as IXmlFile);
}
示例3: GetLineCount
/// <summary>
/// Gets the count of lines for the IProjectFile provided.
/// </summary>
/// <param name="projectFile">
/// The project file to use.
/// </param>
/// <returns>
/// An integer of the line count for the file.
/// </returns>
public static JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine> GetLineCount(IProjectFile projectFile)
{
ISolution solution = projectFile.GetSolution();
IDocument document = DocumentManager.GetInstance(solution).GetOrCreateDocument(projectFile);
JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine> lineCount;
using (ReadLockCookie.Create())
{
lineCount = document.GetLineCount();
}
return lineCount;
}
示例4: GetTextRange
/// <summary>
/// Gets a TextRange for the ReSharper line number provided.
/// </summary>
/// <param name="projectFile">
/// The project file to use.
/// </param>
/// <param name="resharperLineNumber">
/// These are zero based.
/// </param>
/// <returns>
/// A TextRange covering the line number specified.
/// </returns>
public static JB::JetBrains.Util.TextRange GetTextRange(
IProjectFile projectFile, JB::JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine> resharperLineNumber)
{
using (ReadLockCookie.Create())
{
ISolution solution = projectFile.GetSolution();
if (solution == null)
{
return new JB::JetBrains.Util.TextRange();
}
IDocument document = DocumentManager.GetInstance(solution).GetOrCreateDocument(projectFile);
return GetTextRangeForLineNumber(document, resharperLineNumber);
}
}
示例5: Execute
/// <summary>
/// Executes <see cref="styleCopCore"/> within the <see cref="OnViolationEncountered"/>.
/// </summary>
/// <remarks>
/// Violations are raised as events, handled by <see cref="IProjectFile"/>.
/// </remarks>
/// <param name="projectFile">
/// <see cref="StyleCopStageProcess"/>representing the file currently being parsed by ReSharper.
/// </param>
/// <param name="document">
/// The document being checked.
/// </param>
public void Execute(IProjectFile projectFile, IDocument document)
{
StyleCopTrace.In(projectFile, document);
if (projectFile == null)
{
return;
}
this.Initialize();
this.violationHighlights.Clear();
if (!this.styleCopSettings.SkipAnalysisForDocument(projectFile))
{
FileHeader fileHeader = new FileHeader(Utils.GetCSharpFile(projectFile.GetSolution(), document));
if (!fileHeader.UnStyled && StyleCopReferenceHelper.EnsureStyleCopIsLoaded())
{
this.file = projectFile;
this.document = document;
this.RunStyleCop(document);
}
}
StyleCopTrace.Out();
}
示例6: Process
/// <summary>
/// Process clean-up on file.
/// </summary>
/// <param name="projectFile">
/// The project file to process.
/// </param>
/// <param name="range">
/// The range marker to process.
/// </param>
/// <param name="profile">
/// The code cleanup settings to use.
/// </param>
/// <param name="canIncrementalUpdate">
/// Determines whether we can incrementally update.
/// </param>
/// <param name="progressIndicator">
/// The progress indicator.
/// </param>
public void Process(
IProjectFile projectFile,
IPsiRangeMarker range,
CodeCleanupProfile profile,
out bool canIncrementalUpdate,
JB::JetBrains.Application.Progress.IProgressIndicator progressIndicator)
{
StyleCopTrace.In(projectFile, range, profile, progressIndicator);
canIncrementalUpdate = true;
if (projectFile == null)
{
return;
}
if (!this.IsAvailable(projectFile))
{
return;
}
ISolution solution = projectFile.GetSolution();
PsiManagerImpl psiManager = PsiManagerImpl.GetInstance(solution);
ICSharpFile file = psiManager.GetPsiFile(projectFile, PsiLanguageType.GetByProjectFile(projectFile)) as ICSharpFile;
if (file == null)
{
return;
}
DocumentationOptions documentationOptions = profile.GetSetting(DocumentationDescriptor);
LayoutOptions layoutOptions = profile.GetSetting(LayoutDescriptor);
MaintainabilityOptions maintainabilityOptions = profile.GetSetting(MaintainabilityDescriptor);
OrderingOptions orderingOptions = profile.GetSetting(OrderingDescriptor);
ReadabilityOptions readabilityOptions = profile.GetSetting(ReadabilityDescriptor);
SpacingOptions spacingOptions = profile.GetSetting(SpacingDescriptor);
// Process the file for all the different Code Cleanups we have here
// we do them in a very specific order. Do not change it.
new ReadabilityRules().Execute(readabilityOptions, file);
new MaintainabilityRules().Execute(maintainabilityOptions, file);
new DocumentationRules().Execute(documentationOptions, file);
new LayoutRules().Execute(layoutOptions, file);
new SpacingRules().Execute(spacingOptions, file);
new OrderingRules().Execute(orderingOptions, file);
StyleCopTrace.Out();
}
示例7: InternalProcess
/// <summary>
/// Processes all the cleanup.
/// </summary>
/// <param name="projectFile">
/// The project file to clean.
/// </param>
/// <param name="file">
/// The PSI file to clean.
/// </param>
private void InternalProcess(IProjectFile projectFile, ICSharpFile file)
{
// Process the file for all the different Code Cleanups we have here
// we do them in a very specific order. Do not change it.
Lifetimes.Using(
lifetime =>
{
StyleCopApiPool apiPool = projectFile.GetSolution().GetComponent<StyleCopApiPool>();
Settings settings = apiPool.GetInstance(lifetime).Settings.GetSettings(projectFile);
ReadabilityRules.ExecuteAll(file, settings);
MaintainabilityRules.ExecuteAll(file, settings);
DocumentationRules.ExecuteAll(file, settings);
LayoutRules.ExecuteAll(file, settings);
SpacingRules.ExecuteAll(file, settings);
OrderingRules.ExecuteAll(file, settings);
});
}
示例8: ProcessProjectItem
public bool ProcessProjectItem(IProjectFile projectItem) {
IFile psiFile = PsiManager.GetInstance(projectItem.GetSolution()).GetPsiFile(projectItem);
return ((psiFile != null) && ProcessElement(psiFile));
}
示例9: GetRelatedFiles
public IEnumerable<Tuple<IProjectFile, string, IProjectFile>> GetRelatedFiles(IProjectFile projectFile)
{
var typeNamesInFile = GetTypeNamesDefinedInFile(projectFile).ToList();
var candidateTypeNames = GetTypeCandidates(typeNamesInFile);
// Look for the candidate types in the solution.
var solution = projectFile.GetSolution();
var candidateTypes = new List<IClrDeclaredElement>();
foreach (var candidateTypeName in candidateTypeNames)
{
var types = FindType(solution, candidateTypeName);
candidateTypes.AddRange(types);
}
// Get the source files for each of the candidate types.
var sourceFiles = new List<IPsiSourceFile>();
foreach (var type in candidateTypes)
{
var sourceFilesForCandidateType = type.GetSourceFiles();
sourceFiles.AddRange(sourceFilesForCandidateType);
}
var elementCollector = new RecursiveElementCollector<ITypeDeclaration>();
foreach (var psiSourceFile in sourceFiles)
foreach (var file in psiSourceFile.EnumerateDominantPsiFiles())
elementCollector.ProcessElement(file);
var elements = elementCollector.GetResults();
var projectFiles = elements.Select(declaration => declaration.GetSourceFile().ToProjectFile());
var thisProjectName = projectFile.GetProject()?.Name;
var rval = new List<Tuple<IProjectFile, string, IProjectFile>>();
foreach (var file in projectFiles.OfType<ProjectFileImpl>().Distinct(pf => pf.Location.FullPath))
{
// Remove all extensions (e.g.: .xaml.cs).
var fn = file.Name;
var dotPos = fn.IndexOf('.');
if (dotPos != -1)
{
fn = fn.Substring(0, dotPos);
}
var display = fn.EndsWith("ViewModel") ? "ViewModel" : "View";
var projectName = file.GetProject()?.Name;
if (projectName != null &&
!string.Equals(thisProjectName, projectName, StringComparison.OrdinalIgnoreCase))
{
display += $" (in {projectName})";
}
var tuple = Tuple.Create((IProjectFile)file, display, projectFile);
rval.Add(tuple);
}
return rval;
}
示例10: VisitProjectFile
public override void VisitProjectFile(IProjectFile projectFile)
{
if (currentIndicator.IsCanceled)
throw new ProcessCancelledException();
base.VisitProjectFile(projectFile);
this.currentIndicator.CurrentItemText = ResourcesMessages.GetScanningFile(projectFile.Name);
IFile file = PsiManager.GetInstance(projectFile.GetSolution()).GetPsiFile(projectFile);
if (file != null)
{
new AllNonQualifiedReferencesResolver().ProcessFile(file);
UnusedModulesProcessor processor = new UnusedModulesProcessor(candidates);
file.ProcessDescendants(processor);
}
currentIndicator.Advance(1);
}
示例11: GetCSharpFile
/// <summary>
/// Gets the ICSharpFile for the given project File.
/// </summary>
/// <param name="projectFile">
/// The projectFile to use.
/// </param>
/// <returns>
/// An ICSharpFile for the projectFile.
/// </returns>
public static ICSharpFile GetCSharpFile(IProjectFile projectFile)
{
if (projectFile == null)
{
return null;
}
using (ReadLockCookie.Create())
{
PsiManager psiManager = PsiManager.GetInstance(projectFile.GetSolution());
if (psiManager == null)
{
return null;
}
return psiManager.GetPsiFile(projectFile, PsiLanguageType.GetByProjectFile(projectFile)) as ICSharpFile;
}
}
示例12: OpenTextControl
protected ITextControl OpenTextControl(IProjectFile projectFile, int? caretOffset = null)
{
ITextControl openProjectFile = EditorManager.GetInstance(projectFile.GetSolution()).OpenProjectFile(projectFile, true);
return openProjectFile;
}