Ejemplo n.º 1
0
        // <div class="tip" id="fs1">val a : float<br /><br />Full name: Regression.a</div>
        public string HtmlizeChunkTooltip(int chunkId, IAnnotatedCodeChunk chunk)
        {
            var tooltipValue = chunk.TooltipValue;

            if (!string.IsNullOrWhiteSpace(chunk.ExtendedDescription))
            {
                tooltipValue = $"{tooltipValue}<br>{chunk.ExtendedDescription}";
            }

            return($"<div class='tip' id='cs{chunkId}'>{tooltipValue}</div>");
        }
        public IAnnotatedCodeChunk EnhanceChunk(IAnnotatedCodeChunk unenhancedChunk)
        {
            BuildCache();

            switch (unenhancedChunk)
            {
            case AnnotatedCodeChunk <TypeDetails> chunkWithTypeDetails:
                if (_typeInfos.ContainsKey(chunkWithTypeDetails.Details.FullName))
                {
                    return(new AnnotatedCodeChunk <ICodeDetails>
                    {
                        CodeType = chunkWithTypeDetails.CodeType,
                        LineNumber = chunkWithTypeDetails.LineNumber,
                        ExtendedDescription = _typeInfos[chunkWithTypeDetails.Details.FullName],
                        TextValue = chunkWithTypeDetails.TextValue,
                        TooltipValue = chunkWithTypeDetails.TooltipValue,
                        Details = chunkWithTypeDetails.Details
                    });
                }

                break;

            case AnnotatedCodeChunk <MethodDetails> chunkWithMethodDetails:
                if (_methodInfos.ContainsKey(chunkWithMethodDetails.Details.FullName))
                {
                    return(new AnnotatedCodeChunk <ICodeDetails>
                    {
                        CodeType = chunkWithMethodDetails.CodeType,
                        LineNumber = chunkWithMethodDetails.LineNumber,
                        ExtendedDescription = _methodInfos[chunkWithMethodDetails.Details.FullName],
                        TextValue = chunkWithMethodDetails.TextValue,
                        TooltipValue = chunkWithMethodDetails.TooltipValue,
                        Details = chunkWithMethodDetails.Details
                    });
                }

                break;
            }

            return(new AnnotatedCodeChunk <ICodeDetails>
            {
                CodeType = unenhancedChunk.CodeType,
                LineNumber = unenhancedChunk.LineNumber,
                ExtendedDescription = unenhancedChunk.ExtendedDescription,
                TextValue = unenhancedChunk.TextValue,
                TooltipValue = unenhancedChunk.TooltipValue
            });
        }
Ejemplo n.º 3
0
        public string HtmlizeChunkText(int chunkId, IAnnotatedCodeChunk chunk)
        {
            var baseValue = chunk.TextValue;

            // <span onmouseout="hideTip(event, 'fs3', 3)" onmouseover="showTip(event, 'fs3', 3)" class="t">Fit</span>
            var mouseAttributes = "";

            if (!string.IsNullOrWhiteSpace(chunk.TooltipValue))
            {
                mouseAttributes = $" onmouseout='hideTip(event, \"cs{chunkId}\")', {chunkId} onmouseover='showTip(event, \"cs{chunkId}\", {chunkId})'";
            }

            switch (chunk.CodeType)
            {
            case CodeType.Comment:
                baseValue = $"<span{mouseAttributes} class='c'>{baseValue}</span>";
                break;

            case CodeType.Operator:
                baseValue = $"<span{mouseAttributes} class='o'>{baseValue}</span>";
                break;

            case CodeType.Keyword:
                baseValue = $"<span{mouseAttributes} class='k'>{baseValue}</span>";
                break;

            case CodeType.Type:
                baseValue = $"<span{mouseAttributes} class='t'>{baseValue}</span>";
                break;

            case CodeType.Method:
                baseValue = $"<span{mouseAttributes} class='f'>{baseValue}</span>";
                break;

            default:
                if (mouseAttributes != "")
                {
                    baseValue = $"<span{mouseAttributes}>{baseValue}</span>";
                }

                break;
            }

            return(baseValue);
        }