protected override void Start() { base.Start(); image = GetComponent <Image>(); rectTransform = GetComponent <RectTransform>(); rectTransform.sizeDelta = new Vector2(knobSmall.texture.width * 0.5f, knobSmall.texture.height * 0.5f); // Add hover event hoverHandler = GetComponent <HoverHandler>(); hoverHandler.OnHover += OnPointerHover; // Add drag and click events EventTrigger trigger = GetComponent <EventTrigger>(); EventTrigger.Entry drag = new EventTrigger.Entry { eventID = EventTriggerType.Drag }; drag.callback.AddListener((data) => { OnDragDelegate((PointerEventData)data); }); trigger.triggers.Add(drag); EventTrigger.Entry click = new EventTrigger.Entry { eventID = EventTriggerType.PointerClick }; click.callback.AddListener((data) => { OnClickDelegate((PointerEventData)data); }); trigger.triggers.Add(click); mapController = ComponentManager.Instance.Get <MapController>(); }
// // Unity Methods // private void Start() { hoverHandler = GetComponent <HoverHandler>(); // Initialize listeners deleteButton.onClick.AddListener(OnDeleteClick); hoverHandler.OnHover += OnPointerHover; }
// // Unity Methods // private void Start() { rectTransform = GetComponent <RectTransform>(); planningTool = ComponentManager.Instance.Get <PlanningTool>(); // Add hover event hoverHandler = GetComponent <HoverHandler>(); hoverHandler.OnHover += OnPointerHover; }
public string GetLabel(bool markdown) { string typeName = "define"; if (CodeType != null) { typeName = CodeType.Name; } return(HoverHandler.Sectioned(typeName + " " + Name, null)); }
public string GetLabel(bool markdown) { string name = ReturnType?.Name ?? "define" + " " + Name; if (markdown) { return(HoverHandler.Sectioned(name, null)); } else { return(name); } }
// // Unity Methods // private void Start() { // Get components var componentManager = ComponentManager.Instance; dialogManager = componentManager.Get <ModalDialogManager>(); hoverHandler = GetComponent <HoverHandler>(); // Initialize listeners editButton.onClick.AddListener(() => AskForSavedScaleName(LocalizationManager.Instance.Get("Rename Saved Location"), entryName)); deleteButton.onClick.AddListener(OnDeleteClick); hoverHandler.OnHover += OnPointerHover; }
public string GetLabel(bool markdown) { string name = (CodeType?.GetName() ?? "define") + " " + Name; if (markdown) { return(HoverHandler.Sectioned(name, null)); } else { return(name); } }
private void LoadUnit() { CloseUnit(); Window.btn_unit_exit.Click += UnitButtonExit; Window.btn_unit_link.Click += LinkClick; Window.btn_unit_order_cancel.Click += OrderCanel; Window.lbl_unit_location.MouseLeftButtonUp += LocationClick; HoverHandler.AddHover(Window.lbl_unit_location); Window.lbl_unit_commander.MouseLeftButtonUp += CommanderClick; HoverHandler.AddHover(Window.lbl_unit_commander); Window.img_unit_commander.MouseLeftButtonUp += CommanderClick; }
public string GetLabel(bool markdown) { string typeName = "define"; if (CodeType != null) { typeName = CodeType.GetName(); } if (markdown) { return(HoverHandler.Sectioned(typeName + " " + Name, Documentation?.ToString(true))); } else { return(typeName + " " + Name); } }
public void Init(Zone zone) { DisplayedZone = zone; ButtonHandler Handler = new ButtonHandler(ButtonHandler.LeftClick, (x, y) => { }, (handler, mousePos) => { InputController.Instance.UnRegisterHandler(handler); var tileCoordinate = MapManager.Instance.GetTilePositionFromPosition(mousePos); if (DisplayedZone.Contains(tileCoordinate)) { ZoneDisplayManager.Instance.OnZoneSelected(this); } }); InputController.Instance.RegisterHandler(Handler); HoverHandler = new ConditionalHoverHandler( //warmups (x, y) => { }, (x, y) => {}, //start (x, y) => { //reverse the fill and outline colors _fill.GetComponent <Renderer>().material.SetColor(_fillColorShaderProperty, _OutlineColor); _outline.GetComponent <Renderer>().material.SetColor(_outlineColorShaderProperty, _FillColor); }, (x, y) => {}, //end (x, y) => { _fill.GetComponent <Renderer>().material.SetColor(_fillColorShaderProperty, _FillColor); _outline.GetComponent <Renderer>().material.SetColor(_outlineColorShaderProperty, _OutlineColor); }, //condition for when hovering should trigger (x) => { Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); var tileCoordinate = MapManager.Instance.GetTilePositionFromPosition(mousePosition); return(DisplayedZone.Contains(tileCoordinate)); }, .1f); InputController.Instance.RegisterHandler(HoverHandler); ContextMenuHandler = new ButtonHandler(ButtonHandler.RightClick, // Down (handler, position) => { }, // Up (handler, position) => { ContextMenuManager.Instance.CreateContextMenu(new Vector3(position.x, position.y, 0), this); }); InputController.Instance.RegisterHandler(ContextMenuHandler); }
public virtual string GetLabel(bool markdown) { string typeName = "define"; if (CodeType != null) { typeName = CodeType.Name; } if (markdown) { return(HoverHandler.Sectioned(typeName + " " + Name, Documentation)); } else { return(typeName + " " + Name); } }
// Start is called before the first frame update void Start() { returnColors = new Dictionary <Vector2Int, Color>(); HoverHandler handler = new HoverHandler((x, y) => { HighlightTile(y); }, (x, y) => { var prevMousePosition = y; var currMousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); //dont return the tile if the cursor is still on the same tile if (_map.GetTilePositionFromPosition(prevMousePosition) != _map.GetTilePositionFromPosition(currMousePosition)) { ReturnTile(y); } }, (x, y) => { }, (x, y) => { }, (x, y) => { }); InputController.Instance.RegisterHandler(handler); _map = MapManager.Instance; _map.RegisterOnMapRerenderCallback(OnMapRerender); }
private Task Initialize(Extensions.LanguageServer.Server.ILanguageServer server, InitializeParams initializeParams) { CreateCompositionHost(initializeParams); // TODO: Make it easier to resolve handlers from MEF (without having to add more attributes to the services if we can help it) var workspace = _compositionHost.GetExport <OmniSharpWorkspace>(); _compositionHost.GetExport <DiagnosticEventForwarder>().IsEnabled = true; foreach (var handler in TextDocumentSyncHandler.Enumerate(_handlers, workspace) .Concat(DefinitionHandler.Enumerate(_handlers)) .Concat(HoverHandler.Enumerate(_handlers)) .Concat(CompletionHandler.Enumerate(_handlers)) .Concat(SignatureHelpHandler.Enumerate(_handlers)) .Concat(RenameHandler.Enumerate(_handlers)) .Concat(DocumentSymbolHandler.Enumerate(_handlers))) { server.AddHandlers(handler); } return(Task.CompletedTask); }
private Task Initialize(InitializeParams initializeParams) { CreateCompositionHost(initializeParams); // TODO: Make it easier to resolve handlers from MEF (without having to add more attributes to the services if we can help it) var workspace = _compositionHost.GetExport <OmniSharpWorkspace>(); _server.AddHandlers(TextDocumentSyncHandler.Enumerate(_handlers, workspace)); _server.AddHandlers(DefinitionHandler.Enumerate(_handlers)); _server.AddHandlers(HoverHandler.Enumerate(_handlers)); _server.AddHandlers(CompletionHandler.Enumerate(_handlers)); _server.AddHandlers(SignatureHelpHandler.Enumerate(_handlers)); _server.AddHandlers(RenameHandler.Enumerate(_handlers)); _server.AddHandlers(DocumentSymbolHandler.Enumerate(_handlers)); _server.LogMessage(new LogMessageParams() { Message = "Added handlers... waiting for initialize...", Type = MessageType.Log }); return(Task.CompletedTask); }
private void Start() { // Get Components image = GetComponent <Image>(); rectTransform = GetComponent <RectTransform>(); mapViewArea = ComponentManager.Instance.Get <MapViewArea>(); inspectorTool = ComponentManager.Instance.Get <InspectorTool>(); areaInspectorPanel = inspectorTool.areaInspectorPanel; rectTransform.sizeDelta = new Vector2(inspectionDelete.texture.width * 0.5f, inspectionDelete.texture.height * 0.5f); // Add hover event hoverHandler = GetComponent <HoverHandler>(); hoverHandler.OnHover += OnPointerHover; // Add click event EventTrigger trigger = GetComponent <EventTrigger>(); EventTrigger.Entry click = new EventTrigger.Entry(); click.eventID = EventTriggerType.PointerClick; click.callback.AddListener((data) => { areaInspectorPanel.OnRemoveAreaInspection(areaInfo); }); trigger.triggers.Add(click); }
public string GetLabel(bool markdown) => HoverHandler.GetLabel(DoesReturnValue ? ReturnType?.Name ?? "define" : "void", Name, Parameters, markdown, Documentation);
public string GetLabel(bool markdown) => HoverHandler.GetLabel(!IsValue ? null : ReturnType?.Name ?? "define", Name, Parameters, markdown, Wiki?.Description);
public string GetLabel(bool markdown) => HoverHandler.GetLabel("new " + Type.Name, Parameters, markdown, Documentation);
public string GetLabel(bool markdown) => HoverHandler.GetLabel(ReturnType, Name, Parameters, markdown, null);
public void OpenUnit(Unit unit) { CloseUnit(); Window.gui_grid.Children.Add(Window.gui_grid_unit_left); #region Parents Window.panel_unit_parents.Children.Clear(); Unit parent = unit.Parent; List <UIElement> parents = new List <UIElement>(); int c = 0; while (true) { if (parent == null) { break; } Window.btn_unit_parent.Content = parent.Name; Button btn = (Button)SubWindow.CopyFrom(Window.btn_unit_parent); btn.Click += ParentClick; btn.Tag = parent; parents.Add(btn); parent = parent.Parent; c++; } parents.Reverse(); foreach (UIElement element in parents) { Window.panel_unit_parents.Children.Add(element); } #endregion #region Top Window.img_unit_commander.Source = Images.IconPerson; Window.lbl_unit_commander.Content = "Kein Befehlshaber"; Window.img_unit_main_size.Source = unit.Symbol; Window.img_unit_main_counter.Source = unit.IconCounter; Window.lbl_unit_name.Content = unit.Name; Window.lbl_unit_amount.Content = unit.CurStrength; Window.proBar_unit_org.Maximum = unit.MaxOrganisation; Window.proBar_unit_org.Value = unit.CurOrganisation; Window.proBar_unit_org.ToolTip = unit.CurOrganisation + " / " + unit.MaxOrganisation; Window.proBar_unit_strenght.Maximum = unit.MaxStrength; Window.proBar_unit_strenght.Value = unit.CurStrength; Window.proBar_unit_strenght.ToolTip = unit.CurStrength + " / " + unit.MaxStrength; if (unit.Commander != null) { Window.img_unit_commander.Source = unit.Commander.Image; Window.img_unit_commander.Tag = unit.Commander; Window.lbl_unit_commander.Content = unit.Commander.Name; Window.lbl_unit_commander.Tag = unit.Commander; } #endregion #region Center Window.lbl_unit_location.Content = unit.Location.Name; Window.lbl_unit_location.Tag = unit.Location; if (unit.IsLinked) { Window.btn_unit_link.Content = "Link-Out"; } else { Window.btn_unit_link.Content = "Linkup"; } Window.btn_unit_link.Tag = unit; Window.btn_unit_link.IsEnabled = true; if (unit.Parent == null || unit.Parent.LocationID != unit.LocationID) { Window.btn_unit_link.IsEnabled = false; } //- Orders Window.lbl_unit_order.Content = "Kein Befehl"; if (unit.Orders.Count != 0) { Order order = unit.Orders[0]; Window.lbl_unit_order.Content = order.OrderText; Window.btn_unit_order_cancel.Tag = unit; } #endregion #region LocalUnits Window.panel_unit_localunits.Children.Clear(); Window.lbl_unit_localunit_count.Content = unit.LocalUnits.Count; foreach (Unit local_unit in unit.LocalUnits) { Window.img_localunit_counter.Source = local_unit.IconCounter; Window.img_localunit_size.Source = local_unit.Symbol; Window.lbl_localunit_name.Content = local_unit.Name; Window.lbl_localunit_size.Content = local_unit.CurStrength; Window.proBar_localunit_org.Maximum = local_unit.MaxOrganisation; Window.proBar_localunit_org.Value = local_unit.CurOrganisation; Window.proBar_localunit_strenght.Maximum = local_unit.MaxStrength; Window.proBar_localunit_strenght.Value = local_unit.CurStrength; Border sub = (Border)SubWindow.CopyFrom(Window.border_localunit_vorlage); HoverHandler.AddHover(sub); Window.panel_unit_localunits.Children.Add(sub); } #endregion #region SubUnits Window.panel_unit_subunits.Children.Clear(); Window.lbl_unit_subunit_count.Content = unit.SubUnits.Count; int subunits_amount = 0; foreach (Unit sub_unit in unit.SubUnits) { //- Mark other Units in Unit SubUnitBorders.Add(sub_unit); if (sub_unit.BorderParent != null) { sub_unit.BorderParent.Background = ColorHandler.ColorFromRGB("10-10-220"); } Window.img_subunit_counter.Source = sub_unit.IconCounter; Window.img_subunit_size.Source = sub_unit.Symbol; Window.lbl_subunit_name.Content = sub_unit.Name; Window.lbl_subunit_size.Content = sub_unit.CurStrength; Window.proBar_subunit_org.Maximum = sub_unit.MaxOrganisation; Window.proBar_subunit_org.Value = sub_unit.CurOrganisation; Window.proBar_subunit_strenght.Maximum = sub_unit.MaxStrength; Window.proBar_subunit_strenght.Value = sub_unit.CurStrength; Window.lbl_subunit_commander.Content = "Kein Befehlshaber"; if (sub_unit.Commander != null) { Window.lbl_subunit_commander.Content = sub_unit.Commander.Name; } subunits_amount += sub_unit.CurStrength; Border sub = (Border)SubWindow.CopyFrom(Window.border_unit_vorlage); sub.Tag = sub_unit; sub.MouseLeftButtonUp += SubUnitClick; HoverHandler.AddHover(sub); Window.panel_unit_subunits.Children.Add(sub); } Window.lbl_unit_subunit_amount.Content = subunits_amount; #endregion //- Parent if (unit.Parent != null && unit.Parent.BorderParent != null) { unit.Parent.BorderParent.Background = ColorHandler.ColorFromRGB("20-220-20"); SubUnitParten = unit.Parent; } }
public string GetLabel(bool markdown) => HoverHandler.Sectioned((ReturnType?.Name ?? "define") + " " + Name, null);
/// <summary>Calls a type from the specified document range.</summary> /// <param name="parseInfo">The script that the type was called from.</param> /// <param name="callRange">The range of the call.</param> public virtual void Call(ParseInfo parseInfo, DocRange callRange) { parseInfo.TranslateInfo.Types.CallType(this); parseInfo.Script.AddHover(callRange, HoverHandler.Sectioned(Kind + " " + Name, Description)); parseInfo.Script.AddToken(callRange, TokenType, TokenModifiers.ToArray()); }
public string GetLabel(bool markdown) => HoverHandler.GetLabel(!DoesReturnValue ? null : CodeType?.Name ?? "define", Name, Parameters, markdown, Documentation);
protected void UnRegisterHoverHandler(HoverHandler handler) { _hoverHandlers.Remove(handler); }
// Hover protected void RegisterHoverHandler(HoverHandler handler) { _hoverHandlers.Add(handler); }
public string GetLabel(bool markdown) => HoverHandler.GetLabel(ReturnType, Name, Parameters, markdown, Wiki?.Description);
public string GetLabel(bool markdown) => HoverHandler.GetLabel(ReturnType, Name, Parameters, markdown, Documentation.HasString ? Documentation.String : Documentation.MarkupContent.Value);
/// <summary> /// Generates the LSIF content for a single document. /// </summary> /// <returns>The ID of the outputted Document vertex.</returns> /// <remarks> /// The high level algorithm here is we are going to walk across each token, produce a <see cref="Graph.Range"/> for that token's span, /// bind that token, and then link up the various features. So we'll link that range to the symbols it defines or references, /// will link it to results like Quick Info, and more. This method has a <paramref name="topLevelSymbolsResultSetTracker"/> that /// lets us link symbols across files, and will only talk about "top level" symbols that aren't things like locals that can't /// leak outside a file. /// </remarks> private static Id <Graph.LsifDocument> GenerateForDocument( SemanticModel semanticModel, HostLanguageServices languageServices, OptionSet options, IResultSetTracker topLevelSymbolsResultSetTracker, ILsifJsonWriter lsifJsonWriter, IdFactory idFactory) { var syntaxTree = semanticModel.SyntaxTree; var sourceText = semanticModel.SyntaxTree.GetText(); var syntaxFactsService = languageServices.GetRequiredService <ISyntaxFactsService>(); var semanticFactsService = languageServices.GetRequiredService <ISemanticFactsService>(); string?contentBase64Encoded = null; // TODO: move to checking the enum member mentioned in https://github.com/dotnet/roslyn/issues/49326 when that // is implemented. In the mean time, we'll use a heuristic of the path being a relative path as a way to indicate // this is a source generated file. if (!PathUtilities.IsAbsolute(syntaxTree.FilePath)) { var text = semanticModel.SyntaxTree.GetText(); // We always use UTF-8 encoding when writing out file contents, as that's expected by LSIF implementations. // TODO: when we move to .NET Core, is there a way to reduce allocatios here? contentBase64Encoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(text.ToString())); } var documentVertex = new Graph.LsifDocument(new Uri(syntaxTree.FilePath, UriKind.RelativeOrAbsolute), GetLanguageKind(semanticModel.Language), contentBase64Encoded, idFactory); lsifJsonWriter.Write(documentVertex); lsifJsonWriter.Write(new Event(Event.EventKind.Begin, documentVertex.GetId(), idFactory)); // As we are processing this file, we are going to encounter symbols that have a shared resultSet with other documents like types // or methods. We're also going to encounter locals that never leave this document. We don't want those locals being held by // the topLevelSymbolsResultSetTracker, so we'll make another tracker for document local symbols, and then have a delegating // one that picks the correct one of the two. var documentLocalSymbolsResultSetTracker = new SymbolHoldingResultSetTracker(lsifJsonWriter, semanticModel.Compilation, idFactory); var symbolResultsTracker = new DelegatingResultSetTracker(symbol => { if (symbol.Kind == SymbolKind.Local || symbol.Kind == SymbolKind.RangeVariable || symbol.Kind == SymbolKind.Label) { // These symbols can go in the document local one because they can't escape methods return(documentLocalSymbolsResultSetTracker); } else if (symbol.ContainingType != null && symbol.DeclaredAccessibility == Accessibility.Private && symbol.ContainingType.Locations.Length == 1) { // This is a private member in a class that isn't partial, so it can't escape the file return(documentLocalSymbolsResultSetTracker); } else { return(topLevelSymbolsResultSetTracker); } }); // We will walk the file token-by-token, making a range for each one and then attaching information for it var rangeVertices = new List <Id <Graph.Range> >(); foreach (var syntaxToken in syntaxTree.GetRoot().DescendantTokens(descendIntoTrivia: true)) { // We'll only create the Range vertex once it's needed, but any number of bits of code might create it first, // so we'll just make it Lazy. var lazyRangeVertex = new Lazy <Graph.Range>(() => { var rangeVertex = Graph.Range.FromTextSpan(syntaxToken.Span, sourceText, idFactory); lsifJsonWriter.Write(rangeVertex); rangeVertices.Add(rangeVertex.GetId()); return(rangeVertex); }, LazyThreadSafetyMode.None); var declaredSymbol = semanticFactsService.GetDeclaredSymbol(semanticModel, syntaxToken, CancellationToken.None); ISymbol?referencedSymbol = null; if (syntaxFactsService.IsBindableToken(syntaxToken)) { var bindableParent = syntaxFactsService.TryGetBindableParent(syntaxToken); if (bindableParent != null) { var symbolInfo = semanticModel.GetSymbolInfo(bindableParent); if (symbolInfo.Symbol != null && IncludeSymbolInReferences(symbolInfo.Symbol)) { referencedSymbol = symbolInfo.Symbol; } } } if (declaredSymbol != null || referencedSymbol != null) { // For now, we will link the range to the original definition, preferring the definition, as this is the symbol // that would be used if we invoke a feature on this range. This is analogous to the logic in // SymbolFinder.FindSymbolAtPositionAsync where if a token is both a reference and definition we'll prefer the // definition. Once we start supporting hover we'll have to remove the "original definition" part of this, since // since we show different contents for different constructed types there. var symbolForLinkedResultSet = (declaredSymbol ?? referencedSymbol) !.OriginalDefinition; var symbolForLinkedResultSetId = symbolResultsTracker.GetResultSetIdForSymbol(symbolForLinkedResultSet); lsifJsonWriter.Write(Edge.Create("next", lazyRangeVertex.Value.GetId(), symbolForLinkedResultSetId, idFactory)); if (declaredSymbol != null) { var definitionResultsId = symbolResultsTracker.GetResultIdForSymbol(declaredSymbol, Methods.TextDocumentDefinitionName, () => new DefinitionResult(idFactory)); lsifJsonWriter.Write(new Item(definitionResultsId.As <DefinitionResult, Vertex>(), lazyRangeVertex.Value.GetId(), documentVertex.GetId(), idFactory)); } if (referencedSymbol != null) { // Create the link from the references back to this range. Note: this range can be reference to a // symbol but the range can point a different symbol's resultSet. This can happen if the token is // both a definition of a symbol (where we will point to the definition) but also a reference to some // other symbol. var referenceResultsId = symbolResultsTracker.GetResultIdForSymbol(referencedSymbol.OriginalDefinition, Methods.TextDocumentReferencesName, () => new ReferenceResult(idFactory)); lsifJsonWriter.Write(new Item(referenceResultsId.As <ReferenceResult, Vertex>(), lazyRangeVertex.Value.GetId(), documentVertex.GetId(), idFactory, property: "references")); } // Write hover information for the symbol, if edge has not already been added. // 'textDocument/hover' edge goes from the symbol ResultSet vertex to the hover result // See https://github.com/Microsoft/language-server-protocol/blob/main/indexFormat/specification.md#resultset for an example. if (symbolResultsTracker.ResultSetNeedsInformationalEdgeAdded(symbolForLinkedResultSet, Methods.TextDocumentHoverName)) { // TODO: Can we avoid the WaitAndGetResult_CanCallOnBackground call by adding a sync method to compute hover? var hover = HoverHandler.GetHoverAsync(semanticModel, syntaxToken.SpanStart, languageServices, CancellationToken.None).WaitAndGetResult_CanCallOnBackground(CancellationToken.None); if (hover != null) { var hoverResult = new HoverResult(hover, idFactory); lsifJsonWriter.Write(hoverResult); lsifJsonWriter.Write(Edge.Create(Methods.TextDocumentHoverName, symbolForLinkedResultSetId, hoverResult.GetId(), idFactory)); } } } } lsifJsonWriter.Write(Edge.Create("contains", documentVertex.GetId(), rangeVertices, idFactory)); // Write the folding ranges for the document. var foldingRanges = FoldingRangesHandler.GetFoldingRanges(syntaxTree, languageServices, options, isMetadataAsSource: false, CancellationToken.None); var foldingRangeResult = new FoldingRangeResult(foldingRanges, idFactory); lsifJsonWriter.Write(foldingRangeResult); lsifJsonWriter.Write(Edge.Create(Methods.TextDocumentFoldingRangeName, documentVertex.GetId(), foldingRangeResult.GetId(), idFactory)); lsifJsonWriter.Write(new Event(Event.EventKind.End, documentVertex.GetId(), idFactory)); return(documentVertex.GetId()); }
public string GetLabel(bool markdown) => HoverHandler.GetLabel(!doesReturnValue ? null : ReturnType?.Name ?? "define", Name, Parameters, markdown, null);
public string GetLabel(bool markdown) => HoverHandler.GetLabel(CustomMethodType == CustomMethodType.Action ? null : ReturnType?.Name ?? "define", Name, Parameters, markdown, Documentation);