コード例 #1
0
		public SymScope GetUnit(string FileName)
		{
			try
			{
				root_scope = unit_cache[FileName] as SymScope;
				if (root_scope != null) return root_scope;
				unit_name = System.IO.Path.GetFileNameWithoutExtension(FileName);
				this.readDebugInfo = true;
				this.FileName = FileName;
				if (!File.Exists(FileName)) return null;
            	dir = System.IO.Path.GetDirectoryName(FileName);
            	fs = new FileStream(FileName, FileMode.Open, FileAccess.Read);
            	br = new BinaryReader(fs);
            	ReadPCUHeader();
            	root_scope = new InterfaceUnitScope(new SymInfo(unit_name, SymbolKind.Namespace,unit_name),null);
            	unit_cache[FileName] = root_scope;
            	cur_scope = root_scope;
            	AddReferencedAssemblies();
            	ReadInterfacePart();
            	fs.Close();
			}
			catch (Exception e)
			{
				fs.Close();
				return root_scope;
			}
            return root_scope;
		}
コード例 #2
0
ファイル: DomConverter.cs プロジェクト: Slav76/pascalabcnet
 /// <summary>
 /// Получение имен после точки
 /// </summary>
 public SymInfo[] GetName(expression expr, string str, int line, int col, PascalABCCompiler.Parsers.KeywordKind keyword, ref SymScope root)
 {
     if (visitor.cur_scope == null) return null;
     if (col + 1 > str.Length)
         col -= str.Length;
     SymScope si = visitor.FindScopeByLocation(line + 1, col + 1);//stv.cur_scope;
     if (si == null)
     {
         si = visitor.FindScopeByLocation(line, col + 1);
         if (si == null)
             return null;
     }
     SetCurrentUsedAssemblies();
     ExpressionVisitor ev = new ExpressionVisitor(expr, si, visitor);
     si = ev.GetScopeOfExpression(true, false);
     root = si;
     if (si is ElementScope) root = (si as ElementScope).sc;
     else if (si is ProcScope) root = (si as ProcScope).return_type;
     if (si != null)
     {
         if (!(si is TypeScope) && !(si is NamespaceScope))
         {
             SymInfo[] syms = si.GetNamesAsInObject(ev);
             SymInfo[] ext_syms = null;
             if (si is ElementScope)
                 ext_syms = visitor.cur_scope.GetSymInfosForExtensionMethods((si as ElementScope).sc as TypeScope);
             List<SymInfo> lst = new List<SymInfo>();
             lst.AddRange(syms);
             if (ext_syms != null)
                 lst.AddRange(ext_syms);
             RestoreCurrentUsedAssemblies();
             List<SymInfo> lst_to_remove = new List<SymInfo>();
             foreach (SymInfo si2 in lst)
                 if (si2.name.StartsWith("operator"))
                     lst_to_remove.Add(si2);
             foreach (SymInfo si2 in lst_to_remove)
                 lst.Remove(si2);
             return lst.ToArray();
         }
         else
         {
             if (si is TypeScope)
             {
                 RestoreCurrentUsedAssemblies();
                 return (si as TypeScope).GetNames(ev, keyword, false);
             }
             else
             {
                 if (ev.entry_scope.InUsesRange(line + 1, col + 1))
                     keyword = PascalABCCompiler.Parsers.KeywordKind.Uses;
                 RestoreCurrentUsedAssemblies();
                 return (si as NamespaceScope).GetNames(ev, keyword);
             }
         }
     }
     RestoreCurrentUsedAssemblies();
     return null;
 }
コード例 #3
0
			public ComboBoxItem(SymScope item, string text, int iconIndex, bool isInCurrentPart, bool is_global)
			{
				this.item = item;
				if (item != null)
				pos = item.GetPosition();
				this.text = text;
				this.iconIndex = iconIndex;
				this.isInCurrentPart = true;
				this.is_global = is_global;
			}
コード例 #4
0
		public static void LoadWithSources(SymScope unit, string fileName)
		{
			if (ht[unit] != null) return;
            string xml_loc = CodeCompletionTools.XmlDoc.LookupLocalizedXmlDocForUnitWithSources(fileName, CodeCompletionController.currentLanguageISO);
			if (xml_loc != null)
			{
                CodeCompletionTools.XmlDoc xdoc = CodeCompletionTools.XmlDoc.Load(xml_loc, Environment.GetEnvironmentVariable("TEMP"), false);
				ht[unit] = xdoc;
			}
		}
コード例 #5
0
		public SymScope GetScopeOfExpression(bool by_dot, bool on_bracket)
		{
			if (expr is const_node && !(expr is string_const) && !(expr is char_const) && !(expr is bool_const))
				return null;
			this.on_bracket = on_bracket;
			try
			{
				expr.visit(this);
			}
			catch (Exception e)
			{
				returned_scope = null;
			}
			if (returned_scope != null && returned_scope is ElementScope && (returned_scope as ElementScope).sc is ProcType)
			{
				if (by_dot) 
                    if (((returned_scope as ElementScope).sc as ProcType).target.return_type != null) 
                        returned_scope = new ElementScope(((returned_scope as ElementScope).sc as ProcType).target.return_type);
					else 
                        returned_scope = null;
			}
			else if (returned_scope != null && returned_scope is ElementScope && (returned_scope as ElementScope).sc is ProcScope)
			{
                ProcScope ps = (returned_scope as ElementScope).sc as ProcScope;
                TypeScope return_type = ps.return_type;
                if (ps.is_constructor)
                    return_type = ps.declaringType;
                if (by_dot) 
                    if (return_type != null) 
                        returned_scope = new ElementScope(return_type);
					else 
                        returned_scope = null;
			}
            else if (returned_scope != null && returned_scope is ElementScope && (returned_scope as ElementScope).sc is CompiledScope && ((returned_scope as ElementScope).sc as CompiledScope).CompiledType.BaseType == typeof(MulticastDelegate))
            {
                ProcScope invoke_meth = ((returned_scope as ElementScope).sc as CompiledScope).FindNameOnlyInThisType("Invoke") as ProcScope;
                if (invoke_meth != null)
                    returned_scope = new ElementScope(invoke_meth.return_type);
            }
            else if (returned_scope != null && returned_scope is ProcScope)
            {
                ProcScope ps = returned_scope as ProcScope;
                TypeScope return_type = ps.return_type;
                if (ps.is_constructor)
                    return_type = ps.declaringType;
                if (return_type == null)
                {
                    if (by_dot) returned_scope = null;
                }
                else if (by_dot)
                    returned_scope = new ElementScope(return_type);
            }
			return returned_scope;
		}
コード例 #6
0
		public SymScope GetScopeOfExpression()
		{
			if (expr is const_node && !(expr is string_const) && !(expr is char_const) && !(expr is bool_const))
				return null;
			if (mouse_hover && (expr is typeof_operator || expr is sizeof_operator))
				return null;
			try
			{
				expr.visit(this);
			}
			catch(Exception e)
			{
				returned_scope = null;
			}
			if (returned_scope != null && returned_scope is ElementScope && (returned_scope as ElementScope).sc is ProcScope)
			{
				if ((returned_scope as ElementScope).si.kind == SymbolKind.Delegate)
					returned_scope = (returned_scope as ElementScope).sc;
			}
				//else ret_scope = (ret_scope as ElementScope).sc as ProcScope;
			return returned_scope;
		}
コード例 #7
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 public BlockScope(SymScope topScope)
 {
     this.topScope = topScope;
     this.si = new SymInfo("$block_scope", SymbolKind.Block, "$block_scope");
     this.members = new List<SymScope>();
 }
コード例 #8
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 public override void AddName(string name, SymScope sc)
 {
     if (members == null) members = new List<SymScope>();
     base.AddName(name, sc);
 }
コード例 #9
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 public void AddUsedUnit(SymScope unit)
 {
     used_units.Add(unit);
 }
コード例 #10
0
		public static void AddDescribeToComplete(SymScope value)
		{
			if (value is TypeScope) AddDescribeToComplete(value as TypeScope);
			else if (value is ProcScope) AddDescribeToComplete(value as ProcScope);
			else if (value is ElementScope) AddDescribeToComplete(value as ElementScope);
			else if (value is InterfaceUnitScope) AddDescribeToComplete(value as InterfaceUnitScope);
		}
コード例 #11
0
		void ChangeInternal()
		{
			bool first_comp;
			CodeCompletion.DomConverter dconv=null;
			bool tmp = true;
            while (true)
            {
                first_comp = false;
                if (this.Visible)
                    try
                    {
                        if (currentCompilationUnit == null && textAreaControl.FileName != null)
                        {
                            dconv = (CodeCompletion.DomConverter)CodeCompletion.CodeCompletionController.comp_modules[textAreaControl.FileName];
                            if (dconv != null && dconv.is_compiled)
                            {
                                currentCompilationUnit = dconv.stv.entry_scope;
                                first_comp = true;
                            }
                            if (clicked || tmp)
                            {
                                FillClassComboBox(true);
                                //clicked = false;
                                tmp = false;
                            }
                        }
                        if (currentCompilationUnit != null && (clicked || first_comp))
                        {
                            dconv = (CodeCompletion.DomConverter)CodeCompletion.CodeCompletionController.comp_modules[textAreaControl.FileName];
                            if (dconv != null && dconv.is_compiled)
                            {
                                currentCompilationUnit = dconv.stv.entry_scope;
                                FillClassComboBox(true);
                            }

                            //FillMembersComboBox();
                            //UpdateClassComboBox();
                            //UpdateMembersComboBox();
                        }
                        //lock(clicked)
                        {
                            clicked = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        //MessageService.ShowError(ex);
                    }
                Thread.Sleep(300);
            }
		}
コード例 #12
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 public override bool IsEqual(SymScope ts)
 {
     if (ts is CompiledEventScope && (ts as CompiledEventScope).ei == this.ei) return true;
     return false;
 }
コード例 #13
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 public InterfaceUnitScope(SymInfo si, SymScope topScope)
     : base(si, topScope)
 {
     UnitDocCache.AddDescribeToComplete(this);
     this.symbol_table = new Hashtable(StringComparer.CurrentCultureIgnoreCase);
     si.description = this.ToString();
 }
コード例 #14
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 public virtual bool IsChildScopeOf(SymScope ss)
 {
     return false;
 }
コード例 #15
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 public override bool IsEqual(SymScope ts)
 {
     if (ts is CompiledFieldScope && (ts as CompiledFieldScope).fi == this.fi) return true;
     return false;
 }
コード例 #16
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 public override bool IsEqual(SymScope ts)
 {
     CompiledScope cs = ts as CompiledScope;
     if (cs == null)
         if (ts is TypeSynonim) return this.IsEqual((ts as TypeSynonim).actType);
         else return false;
     return this.ctn == cs.ctn;
 }
コード例 #17
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 public virtual bool IsEqual(SymScope ts)
 {
     return this == ts;
 }
コード例 #18
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 public override void AddName(string name, SymScope sc)
 {
     /*if (name != null)
     ht[name] = sc;*/
     sc.si.name = name;
     if (members == null)
         members = new List<SymScope>();
     members.Add(sc);
 }
コード例 #19
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 public override bool IsEqual(SymScope ts)
 {
     return string.Compare(this.si.name, ts.si.name, true) == 0;
 }
コード例 #20
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 public override bool IsEqual(SymScope ts)
 {
     if (ts is CompiledPropertyScope && (ts as CompiledPropertyScope).pi == this.pi) return true;
     return false;
 }
コード例 #21
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 public virtual void AddName(string name, SymScope sc)
 {
     //ht[name] = sc;
     sc.si.name = name;
     members.Add(sc);
 }
コード例 #22
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 public override bool IsEqual(SymScope ts)
 {
     CompiledConstructorScope cms = ts as CompiledConstructorScope;
     if (cms == null) return false;
     if (cms.mi == this.mi) return true;
     if (cms.nextProc != null) return IsEqual(cms.nextProc);
     return false;
 }
コード例 #23
0
		protected override void Dispose(bool disposing)
		{
			if (disposing) {
				this.textAreaControl.ActiveTextAreaControl.Caret.PositionChanged -= new EventHandler(CaretPositionChanged);
				this.membersComboBox.Dispose();
				this.classComboBox.Dispose();
				this.currentCompilationUnit = null;
				th.Abort();
			}
			base.Dispose(disposing);
		}
コード例 #24
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 public override bool IsChildScopeOf(SymScope ss)
 {
     if (ss == null || !(ss is TypeScope))
         return false;
     TypeScope ts = this;
     while (ts.baseScope != null)
         if (ts.baseScope == ss)
             return true;
         else ts = ts.baseScope;
     return false;
 }
コード例 #25
0
 void GetClassMembers(SymScope ss, ArrayList items)
 {
     if (ss != null && ss.members != null)
     {
         ArrayList meths = new ArrayList();
         ArrayList fields = new ArrayList();
         ArrayList events = new ArrayList();
         ArrayList vars = new ArrayList();
         ArrayList props = new ArrayList();
         ArrayList consts = new ArrayList();
         foreach (SymScope el in ss.members)
             //if (el.si.kind == SymbolKind.Method || el.si.kind == SymbolKind.Constant || el.si.kind == SymbolKind.Variable || el.si.kind == SymbolKind.Event || el.si.kind == SymbolKind.Field
             //|| el.si.kind == SymbolKind.Property)
             if (el.GetPosition().file_name != null)
             {
                 ComboBoxItem cbi = new ComboBoxItem(el, el.GetDescriptionWithoutDoc(), CodeCompletionProvider.ImagesProvider.GetPictureNum(el.si), true, false);
                 switch (el.si.kind)
                 {
                     case SymbolKind.Method: meths.Add(cbi); break;
                     case SymbolKind.Field: fields.Add(cbi); break;
                     case SymbolKind.Property: props.Add(cbi); break;
                     case SymbolKind.Variable: vars.Add(cbi); break;
                     case SymbolKind.Event: events.Add(cbi); break;
                     case SymbolKind.Constant: consts.Add(cbi); break;
                 }
                 //items.Add(new ComboBoxItem(el,el.GetDescriptionWithoutDoc(),CodeCompletionProvider.ImagesProvider.GetPictureNum(el.si),true));
             }
         meths.Sort(new Comparer(System.Globalization.CultureInfo.InvariantCulture));
         items.AddRange(meths);
         props.Sort(new Comparer(System.Globalization.CultureInfo.InvariantCulture));
         items.AddRange(props);
         fields.Sort(new Comparer(System.Globalization.CultureInfo.InvariantCulture));
         items.AddRange(fields);
         vars.Sort(new Comparer(System.Globalization.CultureInfo.InvariantCulture));
         items.AddRange(vars);
         consts.Sort(new Comparer(System.Globalization.CultureInfo.InvariantCulture));
         items.AddRange(consts);
         events.Sort(new Comparer(System.Globalization.CultureInfo.InvariantCulture));
         items.AddRange(events);
     }
 }
コード例 #26
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 public WithScope(SymScope topScope)
 {
     this.topScope = topScope;
     this.si = new SymInfo("$with_block", SymbolKind.Block, "$with_block");
 }
コード例 #27
0
		public static string GetDocumentation(SymScope unit, string descr)
		{
			try
			{
                CodeCompletionTools.XmlDoc xdoc = (CodeCompletionTools.XmlDoc)ht[unit];
				if (xdoc != null)
				{
					string s = GetNormalHint(xdoc.GetDocumentation(descr,false));
					return s;
				}
			}
			catch(Exception e)
			{
				
			}
			return "";
		}
コード例 #28
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 public void AddWithScope(SymScope ss, bool is_type)
 {
     with_scopes.Add(new TypeScopeDesc(ss, is_type));
 }
コード例 #29
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 public TypeScopeDesc(SymScope ss, bool is_type)
 {
     this.ss = ss;
     this.is_type = is_type;
 }
コード例 #30
0
ファイル: SymTable.cs プロジェクト: Slav76/pascalabcnet
 //dlja sravnivanija tipov
 public override bool IsEqual(SymScope ts)
 {
     bool eq = this == ts as TypeScope;
     if (ts is NullTypeScope && this.kind == SymbolKind.Class)
         return true;
     if (eq)
         return true;
     TypeScope typ = ts as TypeScope;
     if ((typ is TemplateParameterScope || typ is UnknownScope) && this is TemplateParameterScope)
         return string.Compare(this.si.name, typ.si.name, true) == 0;
     if (this.original_type != null && typ.original_type != null)
     {
         if (this.original_type.IsEqual(typ.original_type) && this.instances.Count == typ.instances.Count)
         {
             for (int i = 0; i < this.instances.Count; i++)
             {
                 if (!this.instances[i].IsEqual(typ.instances[i]))
                     return false;
                 if (typ.instances[i] is UnknownScope && this.instances[i] is TemplateParameterScope)
                     typ.instances[i] = this.instances[i];
             }
             return true;
         }
         else
             return false;
     }
     else
         return false;
 }