void ICache.MarkAsDirty(IPsiSourceFile sourceFile) { lock (lockObject) { dirtyFiles.Add(sourceFile); } }
protected static bool IsSupported(IPsiSourceFile sourceFile) { if (sourceFile == null || !sourceFile.IsValid()) return false; return sourceFile.IsLanguageSupported<AngularJsLanguage>(); }
private static void SaveInvocationData(ControlFlowElementData data, IVariableDeclaration variable, byte position, string name, int offset, IPsiSourceFile sourceFile) { data[variable] = VariableDisposeStatus.DependsOnInvocation; var invokedExpression = new InvokedExpressionData(name, offset, position, sourceFile); data.InvokedExpressions.Add(variable, invokedExpression); }
public static IList<DisposeMethodStatus> Build(IPsiSourceFile sourceFile) { var file = sourceFile.GetPsiFile<CSharpLanguage>(new DocumentRange(sourceFile.Document, 0)) as ICSharpFile; if (file == null) return null; return Build(file); }
public static CachePair Read(BinaryReader reader, IPsiSourceFile sourceFile) { IList<PsiRuleSymbol> ruleData = ReadRules(reader, sourceFile); IList<PsiOptionSymbol> optionData = ReadOptions(reader, sourceFile); return new CachePair(ruleData, optionData); }
public XXLanguageXXFile(FileStatistics statistics, IPsiSourceFile psiSourceFile, XXLanguageXXProject project) : base(null)// TODO: add statistics { _psiSourceFile = psiSourceFile; _fullName = psiSourceFile.GetLocation().FullPath; _project = project; }
public PsiOptionSymbol(string name, int offset, string value, IPsiSourceFile psiSourceFile) { myName = name; myOffset = offset; myValue = value; myPsiSourceFile = psiSourceFile; }
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"); }
public ILexerFactory GetMixedLexerFactory(IBuffer buffer, IPsiSourceFile sourceFile, PsiManager manager) { var LanguageService = RaconteurLanguage.Instance.LanguageService(); return LanguageService == null ? null : LanguageService.GetPrimaryLexerFactory(); }
internal T4Parser([NotNull] T4Environment t4Environment, [NotNull] DirectiveInfoManager directiveInfoManager, [NotNull] ILexer lexer, [CanBeNull] IPsiSourceFile sourceFile) { _t4Environment = t4Environment; _directiveInfoManager = directiveInfoManager; _lexer = lexer; _sourceFile = sourceFile; }
protected override bool IsSupported(IPsiSourceFile sourceFile) { if (sourceFile == null || !sourceFile.IsValid()) return false; return sourceFile.IsLanguageSupported<CSharpLanguage>(); }
public ITreeNode Add(IPsiSourceFile sourceFile, string text, int start, int len) { var name = text.Substring(start, len); NitraDeclaredElement declaredElement; if (!_declaredElements.TryGetValue(name.ToLower(), out declaredElement)) declaredElement = new NitraDeclaredElement(sourceFile.GetSolution(), name); if (name.Length > 0 && char.IsUpper(name[0])) { var node = new NitraDeclaration(declaredElement, sourceFile, name, start, len); declaredElement.AddDeclaration(node); _declaredElements.Add(name, declaredElement); return node; } else { List<NitraNameReference> refs; if (!_references.TryGetValue(declaredElement, out refs)) { refs = new List<NitraNameReference>(); _references.Add(declaredElement, refs); } var node = new NitraNameReference(sourceFile, name, start, len); refs.Add(node); return node; } }
public IEnumerable<RegistrationInfo> Analyze(IPsiSourceFile sourceFile) { ICSharpFile cSharpFile; #if SDK70 cSharpFile = sourceFile.GetTheOnlyPsiFile(CSharpLanguage.Instance) as ICSharpFile; #else cSharpFile = sourceFile.GetPsiFile(CSharpLanguage.Instance) as ICSharpFile; #endif if (cSharpFile == null) { return EmptyList<RegistrationInfo>.InstanceList; } var usingStatements = cSharpFile.Imports .Where(directive => !directive.ImportedSymbolName.QualifiedName.StartsWith("System")) .Select(directive => directive.ImportedSymbolName.QualifiedName).ToList(); IContainerInfo matchingContainer = GetMatchingContainer(usingStatements); if (matchingContainer == null) { return EmptyList<RegistrationInfo>.InstanceList; } ISearchDomain searchDomain = searchDomainFactory.CreateSearchDomain(sourceFile); return ScanRegistrations(matchingContainer, searchDomain); }
public ISelectedRange GetSelectedRange(IPsiSourceFile sourceFile, DocumentRange documentRange) { Pair<IT4File, IFile> pair = GetFiles(sourceFile, documentRange); IT4File t4File = pair.First; IFile codeBehindFile = pair.Second; if (t4File == null) return null; ITreeNode t4Node = t4File.FindNodeAt(documentRange); if (t4Node == null) return null; // if the current selection is inside C# code, use the C# extend selection directly if (codeBehindFile != null) { ISelectEmbracingConstructProvider codeBehindProvider = PsiShared.GetComponent<PsiProjectFileTypeCoordinator>() .GetByPrimaryPsiLanguageType(codeBehindFile.Language) .SelectNotNull(fileType => Shell.Instance.GetComponent<IProjectFileTypeServices>().TryGetService<ISelectEmbracingConstructProvider>(fileType)) .FirstOrDefault(); if (codeBehindProvider != null) { ISelectedRange codeBehindRange = codeBehindProvider.GetSelectedRange(sourceFile, documentRange); if (codeBehindRange != null) return new T4CodeBehindWrappedSelection(t4File, codeBehindRange); } } return new T4NodeSelection(t4File, t4Node); }
public NitraDeclaration(NitraDeclaredElement nitraDeclaredElement, IPsiSourceFile sourceFile, string name, int start, int len) { _sourceFile = sourceFile; DeclaredName = name; NameIdentifier = new NitraNameDeclaration(sourceFile, name, start, len); NitraDeclaredElement = nitraDeclaredElement; this.AddChild(NameIdentifier); }
// ReSharper disable once UnusedParameter.Local public T4SecondaryDocumentGenerationResult([NotNull] IPsiSourceFile sourceFile, [NotNull] string text, [NotNull] PsiLanguageType language, [NotNull] ISecondaryRangeTranslator secondaryRangeTranslator, [NotNull] ILexerFactory lexerFactory, [NotNull] T4FileDependencyManager t4FileDependencyManager, [NotNull] IEnumerable<FileSystemPath> includedFiles) : base(text, language, secondaryRangeTranslator, lexerFactory) { _sourceFile = sourceFile; _t4FileDependencyManager = t4FileDependencyManager; _includedFiles = new HashSet<FileSystemPath>(includedFiles); }
public IFileStructure Run(IDaemonProcess process, IPsiSourceFile psiSourceFile, IContextBoundSettingsStore settingsStore, IFile file) { var psiFile = file as IPsiFile; if (psiFile == null) return null; return new PsiFileStructure(psiFile, settingsStore); }
public IReferenceFactory CreateFactory(IPsiSourceFile sourceFile, IFile file) { if (sourceFile.PrimaryPsiLanguage.Is<CSharpLanguage>()) return new CSharpPropertyDataReferenceFactory(); if (sourceFile.PrimaryPsiLanguage.Is<VBLanguage>()) return new VBPropertyDataReferenceProviderFactory(); return null; }
public static DisposeCacheData Read(BinaryReader reader, IPsiSourceFile sourceFile) { var count = reader.ReadInt32(); var statuses = new List<DisposeMethodStatus>(count); for (var i = 0; i < count; i++) statuses.Add(DisposeMethodStatus.Read(reader, sourceFile)); return new DisposeCacheData(statuses); }
public override IPsiSourceFileProperties GetPsiProperties(IProjectFile projectFile, IPsiSourceFile sourceFile) { if (!projectFile.IsProjectReferencingNancyRazorViewEngine()) { return base.GetPsiProperties(projectFile, sourceFile); } return new RazorMvcPsiProjectFileProperties(projectFile, sourceFile); }
protected bool IsSupported(IPsiSourceFile sourceFile) { if (sourceFile == null || !sourceFile.IsValid()) { return false; } IPsiFile psiFile = GetPsiFile(sourceFile); return psiFile != null && psiFile.Language.Is<PsiLanguage>(); }
public IReferenceFactory CreateFactory(IPsiSourceFile sourceFile, IFile file) { if (!(file is ICSharpFile)) return null; var projectFile = sourceFile.ToProjectFile(); if (projectFile == null) return null; return new ReflectedReferenceProvider(); }
private bool IsSupported(IPsiSourceFile sourceFile) { if (sourceFile == null || !sourceFile.IsValid()) { return false; } IPsiServices psiServices = sourceFile.GetPsiServices(); IFile psiFile = psiServices.Files.GetDominantPsiFile<CSharpLanguage>(sourceFile); return psiFile != null && psiFile.Language.Is<CSharpLanguage>(); }
protected bool IsSupported(IPsiSourceFile sourceFile) { if (sourceFile == null || !sourceFile.IsValid()) { return false; } INTriplesFile file = GetNTriplesFile(sourceFile); return file != null && file.Language.Is<NTriplesLanguage>(); }
private static bool IsNancyRazorPage(IPsiSourceFile sourceFile) { var project = sourceFile.GetProject(); if (!project.IsProjectReferencingNancy() || !project.IsProjectReferencingNancyRazorViewEngine()) { return false; } string pageBaseType = WebConfigCache.GetData(sourceFile).GetRazorBasePageType(isCSharp: true); return !string.IsNullOrWhiteSpace(pageBaseType) && pageBaseType.StartsWith("Nancy.ViewEngines.Razor.NancyRazorViewBase"); }
public IReferenceFactory CreateFactory(IPsiSourceFile sourceFile, IFile file) { var project = sourceFile.GetProject(); if (project == null || !project.IsUnityProject()) return null; if (sourceFile.PrimaryPsiLanguage.Is<CSharpLanguage>()) return new UnityEventFunctionReferenceFactory(); return null; }
private T4TreeBuilder([NotNull] T4Environment t4Environment, [NotNull] DirectiveInfoManager directiveInfoManager, [NotNull] ILexer lexer, [CanBeNull] IPsiSourceFile sourceFile, [NotNull] HashSet<FileSystemPath> existingIncludePaths, [CanBeNull] ISolution solution, [CanBeNull] T4PsiModule macroResolveModule) { _t4Environment = t4Environment; _directiveInfoManager = directiveInfoManager; _builderLexer = new PsiBuilderLexer(lexer, tnt => tnt.IsWhitespace); _existingIncludePaths = existingIncludePaths; _sourceFile = sourceFile; _solution = solution; _macroResolveModule = macroResolveModule; }
public IEnumerable<RegistrationInfo> Analyze(IPsiSourceFile sourceFile) { IContainerInfo matchingContainer = GetMatchingContainer(sourceFile); if (matchingContainer == null) { return EmptyList<RegistrationInfo>.InstanceList; } ISearchDomain searchDomain = searchDomainFactory.CreateSearchDomain(sourceFile); return ScanRegistrations(matchingContainer, searchDomain); }
public void Process( IPsiSourceFile sourceFile, IRangeMarker rangeMarkerMarker, CodeCleanupProfile profile, IProgressIndicator progressIndicator) { ISolution solution = sourceFile.GetSolution(); if (!profile.GetSetting(OurDescriptor)) { return; } INTriplesFile[] files = sourceFile.GetPsiFiles<NTriplesLanguage>().Cast<INTriplesFile>().ToArray(); using (progressIndicator.SafeTotal("Reformat Psi", files.Length)) { foreach (INTriplesFile file in files) { using (IProgressIndicator pi = progressIndicator.CreateSubProgress(1)) { using (WriteLockCookie.Create()) { var languageService = file.Language.LanguageService(); Assertion.Assert(languageService != null, "languageService != null"); var formatter = languageService.CodeFormatter; Assertion.Assert(formatter != null, "formatter != null"); PsiManager.GetInstance(sourceFile.GetSolution()).DoTransaction( delegate { if (rangeMarkerMarker != null && rangeMarkerMarker.IsValid) { formatter.Format( solution, rangeMarkerMarker.DocumentRange, CodeFormatProfile.DEFAULT, true, false, pi); } else { formatter.FormatFile( file, CodeFormatProfile.DEFAULT, pi); } }, "Code cleanup"); } } } } }
public IEnumerable<RegistrationInfo> GetRegistrationsForFile(IPsiSourceFile sourceFile) { if (!((ICache)this).UpToDate(sourceFile)) { Merge(sourceFile, ProcessSourceFile(sourceFile)); } lock (lockObject) { return registrationsMap.Values; } }
private JetHashSet <IPsiSourceFile> FindIndirectIncludesTransitiveClosure([NotNull] IPsiSourceFile file) => TransitiveClosureSearcher.FindClosure(TryGetIncludes, TryGetIncluders, file);
protected override bool HighlightingPredicate(IHighlighting highlighting, IPsiSourceFile sourceFile, IContextBoundSettingsStore settingsStore) => highlighting is UnthrowableExceptionHighlighting;
public IReferenceFactory CreateFactory(IPsiSourceFile sourceFile, IFile file, IWordIndex wordIndexForChecks) { return(sourceFile.PrimaryPsiLanguage.Is <PascalLanguage>() ? new PascalReferenceFactory() : null); }
private IFile GetPsiFile(IPsiSourceFile psiSourceFile) { return(psiSourceFile.GetTheOnlyPsiFile(psiSourceFile.PrimaryPsiLanguage)); }
public override bool QuickCheckAvailability(ITextControl textControl, IPsiSourceFile projectFile) { return(projectFile.LanguageType.Is <T4ProjectFileType>()); }
public override void Drop(IPsiSourceFile sourceFile) { RemoveFromLocalCache(sourceFile); base.Drop(sourceFile); }
public IList <IDeclaration> GetDeclarationsIn(IPsiSourceFile sourceFile) { return(EmptyList <IDeclaration> .InstanceList); }
/// <summary> /// We want to add markers to the right-side stripe as well as contribute to document errors. /// </summary> /// <param name="sourceFile"> /// File that the Stripe needs to be applied to. /// </param> /// <param name="settingsStore"> /// The store to use. /// </param> /// <returns> /// A <see cref="ErrorStripeRequest"/> for the specified file. /// </returns> public ErrorStripeRequest NeedsErrorStripe(IPsiSourceFile sourceFile, IContextBoundSettingsStore settingsStore) { return(ErrorStripeRequest.STRIPE_AND_ERRORS); }
protected UnityAssetFindResult(IPsiSourceFile sourceFile, IDeclaredElement declaredElement, IHierarchyElement attachedElement) { SourceFile = sourceFile; AttachedElement = attachedElement; DeclaredElementPointer = new SourceElementPointer <IDeclaredElement>(declaredElement); }
protected override bool HighlightingPredicate(IHighlighting highlighting, IPsiSourceFile sourceFile, IContextBoundSettingsStore settingsStore) => highlighting is RedundantAssertionSuggestion;
internal static void MarkAsDirty([NotNull] this IPsiServices psiServices, [NotNull] IPsiSourceFile psiSourcefile) { psiServices.Files.MarkAsDirty(psiSourcefile); psiServices.Caches.MarkAsDirty(psiSourcefile); }
/// <summary> /// Check the error stripe indicator necessity for this stage after processing given <paramref name="sourceFile"/> /// </summary> public override ErrorStripeRequest NeedsErrorStripe(IPsiSourceFile sourceFile, IContextBoundSettingsStore settingsStore) { return(ErrorStripeRequest.NONE); }
public string GetAssetGuid(IPsiSourceFile sourceFile) { return(myAssetFilePathToGuid.TryGetValue(sourceFile.GetLocation(), out var guid) ? guid : null); }
public bool HasDeclarationsIn(IPsiSourceFile sourceFile) { return(sourceFile == myFile); }
public IList <IDeclaration> GetDeclarationsIn(IPsiSourceFile sourceFile) => SharedImplUtil.GetDeclarationsIn(this, sourceFile);
protected override bool HighlightingPredicate(IHighlighting highlighting, IPsiSourceFile sourceFile) => highlighting is ArrayWithDefaultValuesInitializationHighlighting;
private T4FileDependencyData TryGetIncludes([NotNull] IPsiSourceFile file) => Map.TryGetValue(file);
private T4ReversedFileDependencyData TryGetIncluders([NotNull] IPsiSourceFile file) => ReversedMap?.TryGetValue(file);
private IEnumerable <IPsiSourceFile> GetIncludes([NotNull] IPsiSourceFile sourceFile) => Map .TryGetValue(sourceFile) ?.Includes .Select(path => PsiFileSelector.FindMostSuitableFile(path, sourceFile));
/// <summary>Creates a secondary lexing service for code behind generated files.</summary> /// <param name="solution">The solution.</param> /// <param name="mixedLexer">The mixed lexer.</param> /// <param name="sourceFile">The source file.</param> /// <returns>An instance of <see cref="ISecondaryLexingProcess"/> used to lex the code behind file.</returns> public override ISecondaryLexingProcess CreateSecondaryLexingService( ISolution solution, MixedLexer mixedLexer, IPsiSourceFile sourceFile = null ) => new T4SecondaryLexingProcess(CSharpLanguage.Instance, mixedLexer);
protected override bool HighlightingPredicate(IHighlighting highlighting, IPsiSourceFile sourceFile) => highlighting is EmptyArrayInitializationHighlighting;
protected override bool HighlightingPredicate(IHighlighting highlighting, IPsiSourceFile psiSourceFile) { return(highlighting is SuggestionRangeHighlighting <ISentence>); }
public IList <IDeclaration> GetDeclarationsIn(IPsiSourceFile sourceFile) { return(UriIdentifierDeclaredElement.GetDeclarationsIn(sourceFile, this)); }
public static ISpellChecker GetSpellChecker(IContextBoundSettingsStore settingsStore, IPsiSourceFile resxFile, string defaultResXDictionary) { if (!resxFile.Name.ToLower().EndsWith(".resx")) { throw new ArgumentException("Should be a resx file", "resxFile"); } string[] parts = resxFile.Name.Split('.'); if (parts.Length > 2) { string dictName = parts[parts.Length - 2]; try { CultureInfo.GetCultureInfo(dictName); } catch (ArgumentException) { return(null); } if (_dictionaryCache.ContainsKey(dictName)) { return(_dictionaryCache[dictName]); } return(loadSpellChecker(settingsStore, dictName, resxFile.GetSolution())); } return(GetSpellChecker(settingsStore, resxFile.GetSolution(), defaultResXDictionary)); }
protected override IEnumerable <SpringFile> GetPsiFiles(IPsiSourceFile sourceFile) { yield return((SpringFile)sourceFile.GetDominantPsiFile <SpringLanguage>()); }
public IPsiSourceFile FindBestRoot(IPsiSourceFile include) => GraphSinkSearcher.FindClosestSink(TryGetIncluders, include);
public bool IsAvailable(IPsiSourceFile sourceFile) { return(sourceFile.LanguageType.Is <SpringProjectFileType>()); }
public T4IncludeAwareDaemonProcessVisitor([NotNull] IPsiSourceFile initialFile) { Guard = new T4IncludeGuard(); Guard.StartProcessing(initialFile.GetLocation()); }
private IEnumerable <(LocalReference owningScriptLocation, AssetMethodUsages methodData)> GetImportedAssetMethodDataFor(IPsiSourceFile psiSourceFile) { if (myImportedUnityEventDatas.TryGetValue(psiSourceFile, out var importedUnityEventData)) { foreach (var((location, unityEventName), modifiedEvents) in importedUnityEventData.UnityEventToModifiedIndex) { var script = myAssetDocumentHierarchyElementContainer.GetHierarchyElement(location, true) as IScriptComponentHierarchy; Assertion.Assert(script != null, "script != null"); var scriptType = AssetUtils.GetTypeElementFromScriptAssetGuid(mySolution, script.ScriptReference.ExternalAssetGuid); var field = scriptType?.GetMembers().FirstOrDefault(t => t is IField f && AssetUtils.GetAllNamesFor(f).Contains(unityEventName)) as IField; if (field == null) { continue; } var names = AssetUtils.GetAllNamesFor(field).ToJetHashSet(); var modifications = script.ImportUnityEventData(this, names); foreach (var index in modifiedEvents) { Assertion.Assert(index < modifications.Count, "index < modifications.Count"); var result = AssetMethodUsages.TryCreateAssetMethodFromModifications(location, unityEventName, modifications[index]); if (result != null) { yield return(location, result); } } } } }
public override void Merge(IPsiSourceFile sourceFile, object builtPart) { RemoveFromLocalCache(sourceFile); AddToLocalCache(sourceFile, builtPart as MetaFileCacheItem); base.Merge(sourceFile, builtPart); }