Beispiel #1
0
        public FileInfo FindModule(int pos, CodeDocument doc)
        {
            var sym   = GetNameInfo(pos, doc);
            var unit  = doc != null ? doc.Unit : null;
            var frame = unit != null ? ((CompiledUnit)unit).CodeFrame : null;

            if (sym != null && ((ElaVariableFlags)sym.Flags).Set(ElaVariableFlags.Module) &&
                frame != null && frame.References.ContainsKey(sym.Name))
            {
                var mod = frame.References[sym.Name];
                var rr  = new ElaReferenceResolver {
                    App = app
                };
                var refUnit = rr.Resolve(new Reference(new CompiledUnit(doc, frame), mod), ElaReferenceResolver.NoBuild);

                if (refUnit != null)
                {
                    return(((CompiledUnit)refUnit).Document.FileInfo);
                }
            }

            return(null);
        }
Beispiel #2
0
        private void ListModuleMembers(CodeDocument doc, int pos)
        {
            var sym   = GetNameInfo(pos, doc);
            var unit  = doc != null ? doc.Unit : null;
            var frame = unit != null ? ((CompiledUnit)unit).CodeFrame : null;

            if (sym != null && ((ElaVariableFlags)sym.Flags).Set(ElaVariableFlags.Module) &&
                frame != null && frame.References.ContainsKey(sym.Name))
            {
                var mod = frame.References[sym.Name];
                var rr  = new ElaReferenceResolver {
                    App = app
                };
                var refUnit = rr.Resolve(new Reference(new CompiledUnit(doc, frame), mod));

                if (refUnit != null)
                {
                    var sb   = new StringBuilder();
                    var list = new List <AutocompleteSymbol>();

                    foreach (var cn in ((CompiledUnit)refUnit).CodeFrame.GlobalScope.EnumerateVars()
                             .Where(v => !v.Value.VariableFlags.Set(ElaVariableFlags.Module) &&
                                    !v.Value.VariableFlags.Set(ElaVariableFlags.Private) &&
                                    v.Key[0] != '$'))
                    {
                        list.Add(new AutocompleteSymbol(cn.Key,
                                                        cn.Value.VariableFlags.Set(ElaVariableFlags.Module) ? AutocompleteSymbolType.Module :
                                                        cn.Value.VariableFlags.Set(ElaVariableFlags.TypeFun) ? AutocompleteSymbolType.Type :
                                                        cn.Value.VariableFlags.Set(ElaVariableFlags.ClassFun) ? AutocompleteSymbolType.Member :
                                                        AutocompleteSymbolType.Variable));
                    }

                    list = list.OrderBy(c => c.Name).ToList();
                    app.GetService <IAutocompleteService>().ShowAutocomplete(list);
                }
            }
        }