protected abstract Task OnDefinitionFoundWorkerAsync(DefinitionItem definition);
private void BW_WORK_GetAllItem(object sender, DoWorkEventArgs e) { this._vacationActuelle = GetVacationName(DateTime.Now); this._jourSemaineActuel = jourAujoudhuiFrancais(); BackgroundWorker worker = sender as BackgroundWorker; Dictionary<string, object> arg = new Dictionary<string, object>(); arg.Add("@heureFinVacationActuelle", GetHeureLimiteVacation("fin")); arg.Add("@heureDebutVacationActuelle", GetHeureLimiteVacation("début")); arg.Add("@jourVacationActuelle", _jourSemaineActuel); int ageOldConsigne = -1 * Properties.Settings.Default.minimumAgeBeforeHideConsigne; SqlDataReader Reader = ConnectorSqlServer.ExecCommandSql(@"SELECT * FROM ( SELECT documents.idDocument AS idItem, tachesjournalieres.titreAction AS titreItem, CONVERT(DATETIME, CONCAT(CONVERT(VARCHAR, GETDATE(), 111),' ',CONVERT(VARCHAR, tachesjournalieres.heureApplication, 108)), 120) AS debutItem, NULL AS finItem, NULL AS refItem FROM documents JOIN tachesjournalieres ON documents.idDocument = tachesjournalieres.idDocument WHERE (CONVERT(DATETIME, CONCAT(CONVERT(VARCHAR, GETDATE(), 111),' ',CONVERT(VARCHAR, tachesjournalieres.heureApplication, 108)), 120) < @heureFinVacationActuelle AND CONVERT(DATETIME, CONCAT(CONVERT(VARCHAR, GETDATE(), 111),' ',CONVERT(VARCHAR, tachesjournalieres.heureApplication, 108)), 120) >= @heureDebutVacationActuelle) AND CHARINDEX(@jourVacationActuelle,tachesjournalieres.jourApplication) > 0 AND (tachesjournalieres.dateExpiration IS NULL OR tachesjournalieres.dateExpiration >= CONVERT(date, GETDATE())) UNION ALL SELECT documents.idDocument AS idItem, consignes.objetConsigne AS titreItem, consignes.debut AS debutItem, consignes.fin AS finItem, consignes.referenceConsigne AS refItem FROM documents JOIN consignes ON documents.idDocument = consignes.idDocument WHERE consignes.debut < @heureFinVacationActuelle AND (consignes.fin > @heureDebutVacationActuelle OR consignes.fin IS NULL) ) AS tbl ORDER BY CASE WHEN (refItem IS NULL) THEN 1 WHEN (refItem IS NOT NULL) THEN CASE WHEN ((finItem IS NULL) OR (finItem > CONVERT(DATETIME, '9999-12-31 23:59:59', 120))) AND (debutItem <= DATEADD(day, " + ageOldConsigne + @", @heureDebutVacationActuelle)) THEN 3 ELSE 2 END END ASC, CASE WHEN refItem IS NULL THEN debutItem END ASC, CASE WHEN refItem IS NOT NULL THEN debutItem END DESC, refItem DESC", arg); this._hasCollapsedItems = false; _indexItemCollapsable.Clear(); while (Reader != null && Reader.Read()) { DefinitionItem retour = new DefinitionItem(); retour.id = TablesBdd.GetDBBigInt("idItem", Reader); retour.titre = TablesBdd.GetDBString("titreItem", Reader); retour.debut = TablesBdd.GetDBDateTime("debutItem", Reader); retour.refConsigne = TablesBdd.GetDBString("refItem", Reader); if (!String.IsNullOrEmpty(retour.refConsigne)) { retour.fin = TablesBdd.GetDBDateTime("finItem", Reader); } else { retour.fin = retour.debut.AddHours(1); } //Mise en pause du thread pendant 1ms pour la mise à jour des autres threads System.Threading.Thread.Sleep(0); worker.ReportProgress(0, retour); } ConnectorSqlServer.Close(Reader); }
/// <summary> /// Provides an extension point that allows for other workspace layers to add additional /// results to the results found by the FindReferences engine. /// </summary> public virtual DefinitionItem GetThirdPartyDefinitionItem( Solution solution, DefinitionItem definitionItem, CancellationToken cancellationToken) { return(null); }
private static async Task <DefinitionItem> ToDefinitionItemAsync( this ISymbol definition, Project project, bool includeHiddenLocations, bool includeClassifiedSpans, FindReferencesSearchOptions options, CancellationToken cancellationToken) { // Ensure we're working with the original definition for the symbol. I.e. When we're // creating definition items, we want to create them for types like Dictionary<TKey,TValue> // not some random instantiation of that type. // // This ensures that the type will both display properly to the user, as well as ensuring // that we can accurately resolve the type later on when we try to navigate to it. if (!definition.IsTupleField()) { // In an earlier implementation of the compiler APIs, tuples and tuple fields symbols were definitions // We pretend this is still the case definition = definition.OriginalDefinition; } var displayParts = definition.ToDisplayParts(GetFormat(definition)).ToTaggedText(); var nameDisplayParts = definition.ToDisplayParts(s_namePartsFormat).ToTaggedText(); var tags = GlyphTags.GetTags(definition.GetGlyph()); var displayIfNoReferences = definition.ShouldShowWithNoReferenceLocations( options, showMetadataSymbolsWithoutReferences: false); using var sourceLocationsDisposer = ArrayBuilder <DocumentSpan> .GetInstance(out var sourceLocations); var properties = GetProperties(definition); var displayableProperties = AbstractReferenceFinder.GetAdditionalFindUsagesProperties(definition); // If it's a namespace, don't create any normal location. Namespaces // come from many different sources, but we'll only show a single // root definition node for it. That node won't be navigable. if (definition.Kind != SymbolKind.Namespace) { foreach (var location in definition.Locations) { if (location.IsInMetadata) { return(DefinitionItem.CreateMetadataDefinition( tags, displayParts, nameDisplayParts, project, definition, properties, displayIfNoReferences)); } else if (location.IsInSource) { if (!location.IsVisibleSourceLocation() && !includeHiddenLocations) { continue; } var document = project.Solution.GetDocument(location.SourceTree); if (document != null) { var documentLocation = !includeClassifiedSpans ? new DocumentSpan(document, location.SourceSpan) : await ClassifiedSpansAndHighlightSpanFactory.GetClassifiedDocumentSpanAsync( document, location.SourceSpan, cancellationToken).ConfigureAwait(false); sourceLocations.Add(documentLocation); } } } } if (sourceLocations.Count == 0) { // If we got no definition locations, then create a sentinel one // that we can display but which will not allow navigation. return(DefinitionItem.CreateNonNavigableItem( tags, displayParts, DefinitionItem.GetOriginationParts(definition), properties, displayIfNoReferences)); } return(DefinitionItem.Create( tags, displayParts, sourceLocations.ToImmutable(), nameDisplayParts, properties, displayableProperties, displayIfNoReferences)); }
public FindLiteralsProgressAdapter( IFindUsagesContext context, DefinitionItem definition) { _context = context; _definition = definition; }
public virtual Task OnDefinitionFoundAsync(DefinitionItem definition) => SpecializedTasks.EmptyTask;
public static ClassifiedTextElement GetClassifiedText(this DefinitionItem definition) => new ClassifiedTextElement(definition.DisplayParts.Select(part => new ClassifiedTextRun(part.Tag.ToClassificationTypeName(), part.Text)));
private async Task <bool> TryFindLiteralReferencesAsync( Document document, int position, IFindUsagesContext context) { var cancellationToken = context.CancellationToken; cancellationToken.ThrowIfCancellationRequested(); var syntaxTree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false); var syntaxFacts = document.GetLanguageService <ISyntaxFactsService>(); // Currently we only support FAR for numbers, strings and characters. We don't // bother with true/false/null as those are likely to have way too many results // to be useful. var token = await syntaxTree.GetTouchingTokenAsync( position, t => syntaxFacts.IsNumericLiteral(t) || syntaxFacts.IsCharacterLiteral(t) || syntaxFacts.IsStringLiteral(t), cancellationToken).ConfigureAwait(false); if (token.RawKind == 0) { return(false); } // Searching for decimals not supported currently. Our index can only store 64bits // for numeric values, and a decimal won't fit within that. var tokenValue = token.Value; if (tokenValue == null || tokenValue is decimal) { return(false); } var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); var symbol = semanticModel.GetSymbolInfo(token.Parent).Symbol ?? semanticModel.GetDeclaredSymbol(token.Parent); // Numeric labels are available in VB. In that case we want the normal FAR engine to // do the searching. For these literals we want to find symbolic results and not // numeric matches. if (symbol is ILabelSymbol) { return(false); } // Use the literal to make the title. Trim literal if it's too long. var title = syntaxFacts.ConvertToSingleLine(token.Parent).ToString(); if (title.Length >= 10) { title = title.Substring(0, 10) + "..."; } var searchTitle = string.Format(EditorFeaturesResources._0_references, title); await context.SetSearchTitleAsync(searchTitle).ConfigureAwait(false); var solution = document.Project.Solution; // There will only be one 'definition' that all matching literal reference. // So just create it now and report to the context what it is. var definition = DefinitionItem.CreateNonNavigableItem( ImmutableArray.Create(TextTags.StringLiteral), ImmutableArray.Create(new TaggedText(TextTags.Text, searchTitle))); await context.OnDefinitionFoundAsync(definition).ConfigureAwait(false); var progressAdapter = new FindLiteralsProgressAdapter(context, definition); // Now call into the underlying FAR engine to find reference. The FAR // engine will push results into the 'progress' instance passed into it. // We'll take those results, massage them, and forward them along to the // FindUsagesContext instance we were given. await SymbolFinder.FindLiteralReferencesAsync( tokenValue, Type.GetTypeCode(tokenValue.GetType()), solution, progressAdapter, cancellationToken).ConfigureAwait(false); return(true); }
public virtual IAsyncEnumerable <ExternalReferenceItem> FindReferencesByMonikerAsync(DefinitionItem definition, ImmutableArray <SymbolMoniker> monikers, CancellationToken cancellationToken) => EmptyAsyncEnumerable <ExternalReferenceItem> .Instance;