private static IEnumerable <Run> GetSymbolLocation(DeclarationSymbol symbol) { if (symbol == null) { return(new Run[0]); } var declaration = symbol.FirstDeclarationOrDefault; var sourceSnapshot = declaration?.Source; var newLine = Environment.NewLine; if (sourceSnapshot != null && sourceSnapshot != SourceSnapshot.Default && sourceSnapshot.File != null && declaration.Location != null) { var filename = Path.GetFileName(sourceSnapshot.File.FullName); var location = declaration.Location.StartLineColumn; return(new [] { new Run(newLine + filename + ":" + location.Line + newLine + newLine) { Foreground = LocationColor }, CreateAccentRun("F12"), CreateRun(" go to declaration "), CreateAccentRun("(Ctrl + Click)") }); } return(new Run[0]); }
private void TrySelectTextForSymbol(DeclarationSymbol symbol, TreeViewItem tvi) { if (symbol != null) { var declarations = symbol.GetDeclarationsUntyped().ToList(); if (declarations.Count == 1) { SelectText(declarations[0]); } else if (declarations.Count > 1) { if (!tvi.IsExpanded) { tvi.IsExpanded = true; } foreach (TreeViewItem subItem in tvi.Items) { var decls = subItem.Tag as IEnumerable <Declaration>; if (decls != null) { subItem.IsExpanded = true; subItem.IsSelected = true; foreach (TreeViewItem subSubItem in tvi.Items) { subSubItem.BringIntoView(); } break; } } } } }
protected Model([NotNull] DeclarationSymbol symbol, ModelType modelType) : this( modelType, symbol.Id, symbol.FirstDeclarationOrDefault.Location, symbol.Name, symbol.FirstDeclarationOrDefault.Location.Source.File.FullName) { }
protected SuiteRelatable([NotNull] DeclarationSymbol symbol, ModelType modelType) : base( modelType, symbol.Id, symbol.FirstDeclarationOrDefault.Location, symbol.Name, symbol.FirstDeclarationOrDefault.Location.Source.File.FullName) { }
public static DeclarationSymbol SpanToSymbol(IList <object> quickInfoContent, NSpan span, IAst ast, out bool foundSomething) { var cts = new CancellationTokenSource(); DeclarationSymbol symbol = null; var visitor = new CollectSymbolsAndRefsInSpanAstVisitor(cts.Token, span); visitor.Visit(ast); foreach (var rf in visitor.Refs) { if (rf.IsAmbiguous) { var foundHint = false; foreach (var ambiguity in rf.Ambiguities) { var hint = SymbolToHint(ambiguity); if (hint != null) { quickInfoContent.Add(hint); symbol = ambiguity; foundHint = true; break; } } if (foundHint) { break; } } else if (rf.IsSymbolEvaluated) { var hint = SymbolToHint(rf.Symbol); if (hint != null) { quickInfoContent.Add(hint); symbol = rf.Symbol; break; } } } foundSomething = visitor.Refs.Count > 0 || visitor.Names.Count > 0; return(symbol); }
private static Run GetSymbolType(DeclarationSymbol symbol) { if (symbol is FunctionParameterSymbol) { return(CreateRun("(parameter) ")); } if (symbol is FunctionSymbol) { return(CreateRun("(mixin) ")); } if (symbol is TypeSymbol) { return(CreateRun("(type) ")); } if (symbol is Member.PropertySymbol) { return(CreateRun("(property) ")); } if (symbol is GlobalDeclaration.VariableSymbol) { return(CreateRun("(variable) ")); } return(new Run()); }
private static object SymbolToHint(DeclarationSymbol symbol) { if (symbol == null) { return(""); } var textBlock = new TextBlock(); var inlines = textBlock.Inlines; var functionSymbol = symbol as FunctionSymbol; if (functionSymbol != null && functionSymbol.IsParametersEvaluated) { inlines.Add(GetSymbolType(symbol)); var parameters = functionSymbol.Parameters.MakeCompletionList(""); var parameterRuns = parameters.OfType <FunctionParameterSymbol>() .SelectMany(GetParameterHintString) .ToList(); inlines.Add(CreateAccentRun(functionSymbol.Name)); inlines.Add(CreateAccentRun("(")); for (int i = 0; i < parameterRuns.Count; i++) { inlines.Add(parameterRuns[i]); if (i < parameterRuns.Count - 1) { inlines.Add(CreateRun(", ")); } } inlines.Add(CreateAccentRun(")")); inlines.AddRange(GetSymbolLocation(functionSymbol)); return(textBlock); } var variableSymbol = symbol as GlobalDeclaration.VariableSymbol; if (variableSymbol != null && variableSymbol.Value.HasValue) { var declaration = variableSymbol.FirstDeclarationOrDefault; if (declaration != null) { inlines.Add(GetSymbolType(symbol)); inlines.Add(CreateRun(declaration.Location.GetText())); inlines.AddRange(GetSymbolLocation(functionSymbol)); return(textBlock); } return(""); } if (symbol.IsFullNameEvaluated) { inlines.Add(GetSymbolType(symbol)); inlines.Add(CreateRun(symbol.FullName)); inlines.AddRange(GetSymbolLocation(symbol)); return(textBlock); } return(null); }
protected ScenarioBaseModel([NotNull] DeclarationSymbol symbol, ModelType modelType) : base(symbol, modelType) { }
protected PlatformBase([NotNull] DeclarationSymbol symbol, ModelType modelType) : base(symbol, modelType) { }
public static MyCompletion FromSymbol(DeclarationSymbol symbol, IAst[] stack) { var completionType = CompletionType.Normal; var imageSource = ClassImage; var name = symbol.Name; if (name.Contains('.')) { name = name.Split('.').Last(); } if (symbol is TypeSymbol) { completionType = CompletionType.Node; imageSource = ClassImage; } else if (symbol is GlobalDeclaration.ContentFunctionSymbol) { var fun = (GlobalDeclaration.ContentFunctionSymbol)symbol; completionType = fun.Parameters.MakeCompletionList("").Any() ? CompletionType.ContentFunctionRefWithParams : CompletionType.ContentFunctionRef; imageSource = ComponentImage; } else if (symbol is GlobalDeclaration.TypeFunctionSymbol) { var fun = (GlobalDeclaration.TypeFunctionSymbol)symbol; completionType = fun.Parameters.MakeCompletionList("").Any() ? CompletionType.TypeFunctionRefWithParams : CompletionType.TypeFunctionRef; imageSource = ComponentImage; } else if (symbol is Member.PropertySymbol) { var fullName = symbol.FullName; if (fullName.StartsWith("System.Windows.Media.Brushes") || fullName.StartsWith("Windows.UI.Colors")) { imageSource = ColorWheelImage; } else { imageSource = PropertyImage; } completionType = CompletionType.Property; } else if (symbol is VariableRefSymbol) { name = "$" + name; imageSource = ReferenceImage; } else if (symbol is Member.MethodSymbol) { imageSource = MethodImage; } else if (symbol is Member.EventSymbol) { imageSource = EventImage; } else if (symbol is Member.FieldSymbol) { imageSource = FieldImage; } else if (symbol is EnumMemberSymbol) { imageSource = EnumItemImage; } if (symbol is GlobalDeclaration.TypeFunctionSymbol) { name = "@" + name; } else if (symbol is GlobalDeclaration.ContentFunctionSymbol) { name = "#" + name; } return(new MyCompletion(name, name, symbol.FullName, imageSource, "", completionType, symbol, stack)); }
private void TrySelectTextForSymbol(DeclarationSymbol symbol, TreeViewItem tvi) { if (symbol != null) { var declarations = symbol.GetDeclarationsUntyped().ToList(); if (declarations.Count == 1) SelectText(declarations[0]); else if (declarations.Count > 1) { if (!tvi.IsExpanded) tvi.IsExpanded = true; foreach (TreeViewItem subItem in tvi.Items) { var decls = subItem.Tag as IEnumerable<Declaration>; if (decls != null) { subItem.IsExpanded = true; subItem.IsSelected = true; foreach (TreeViewItem subSubItem in tvi.Items) subSubItem.BringIntoView(); break; } } } } }
protected DeploymentBaseModel([NotNull] DeclarationSymbol symbol, ModelType modelType) : base(symbol, modelType) { }
public ValueModel(DeclarationSymbol symbol, ParsedValue <string> value) : this(symbol.GetSource(), value) { }
protected CurryingApplicableDeployment([NotNull] DeclarationSymbol symbol, ModelType modelType) : base(symbol, modelType) { }
private bool IsSpecialSymbol(DeclarationSymbol symbol) { return(symbol.Name.StartsWith("$")); }
public static SourceSnapshot GetSource(this DeclarationSymbol symbol) { return(symbol.FirstDeclarationOrDefault.Location.Source); }
protected ProductBaseModel([NotNull] DeclarationSymbol symbol, ModelType modelType) : base(symbol, modelType) { }
public MyCompletion(string displayText, string insertionText, string description, ImageSource iconSource, string iconAutomationText, CompletionType completionType, DeclarationSymbol symbol, IAst[] stack) : base(displayText, insertionText, description, iconSource, iconAutomationText) { _stack = stack; CompletionType = completionType; Symbol = symbol; }