示例#1
0
 public static string GetDescription(int pos, string content, int line, int col, string FileName, DomConverter dc, PascalABCCompiler.Parsers.Controller controller)
 {
     string expr_without_brackets = null;
     PascalABCCompiler.Parsers.KeywordKind keyw;
     var expr = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.FindExpressionFromAnyPosition(pos, content, line, col, out keyw, out expr_without_brackets);
     if (expr == null)
       expr = expr_without_brackets;
     var errors = new List<PascalABCCompiler.Errors.Error>();
     var tree = controller.GetExpression("test" + Path.GetExtension(FileName), expr, errors);
     var desc = dc.GetDescription(tree, FileName, expr_without_brackets, controller, line, col, keyw, false);
     return desc;
 }
 /// <summary>
 /// Получить описание элемента при наведении мышью
 /// </summary>
 public string GetDescription(expression expr, string FileName, string expr_without_brackets, PascalABCCompiler.Parsers.Controller parser, int line, int col, PascalABCCompiler.Parsers.KeywordKind keyword, bool header)
 {
 	if (stv.cur_scope == null) return null;
 	SymScope ss = stv.FindScopeByLocation(line+1,col+1);//stv.cur_scope;
 	if (ss == null) return null;
 	if (!header && ss.IsInScope(ss.head_loc,line+1,col+1))
 	{
 		List<PascalABCCompiler.Errors.Error> Errors = new List<PascalABCCompiler.Errors.Error>();
 		expr = parser.GetExpression("test"+Path.GetExtension(FileName), expr_without_brackets, Errors);
 		if (expr == null || Errors.Count > 0)
 			return null;
 	}
 	bool on_proc = false;
     SetCurrentUsedAssemblies();
 	if (keyword == PascalABCCompiler.Parsers.KeywordKind.Function || keyword == PascalABCCompiler.Parsers.KeywordKind.Constructor || keyword == PascalABCCompiler.Parsers.KeywordKind.Destructor)
 	{
 		if (ss is ProcRealization)
 		{
 			if (expr is ident)
 			{
 				if ((expr as ident).name == (ss as ProcRealization).def_proc.si.name) on_proc = true;
 			}
 			else on_proc = true;
 		}
 		else if (ss is ProcScope)
 		{
 			if (expr is ident)
 			{
 				if ((expr as ident).name == (ss as ProcScope).si.name) on_proc = true;
 			}
 			else on_proc = true;
 		}
 	}
 	//if (!((keyword == KeywordKind.kw_proc || keyword == KeywordKind.kw_constr || keyword == KeywordKind.kw_destr) && ss is ProcScope))
 	if (!on_proc)
 	{
 		ExpressionVisitor ev = new ExpressionVisitor(expr, ss, stv);
 		ev.mouse_hover = true;
 		ss = ev.GetScopeOfExpression();
 	}
 	if (ss != null && ss.si != null) 
 	{
 		try
 		{
             if (ss.si.has_doc != true)
                 if (ss is CompiledScope)
                     ss.AddDocumentation(AssemblyDocCache.GetDocumentation((ss as CompiledScope).ctn));
                 else if (ss is CompiledMethodScope)
                     ss.AddDocumentation(AssemblyDocCache.GetDocumentation((ss as CompiledMethodScope).mi));
                 else if (ss is CompiledPropertyScope)
                     ss.AddDocumentation(AssemblyDocCache.GetDocumentation((ss as CompiledPropertyScope).pi));
                 else if (ss is CompiledFieldScope)
                     ss.AddDocumentation(AssemblyDocCache.GetDocumentation((ss as CompiledFieldScope).fi));
                 else if (ss is CompiledEventScope)
                     ss.AddDocumentation(AssemblyDocCache.GetDocumentation((ss as CompiledEventScope).ei));
                 else if (ss is CompiledConstructorScope)
                     ss.AddDocumentation(AssemblyDocCache.GetDocumentation((ss as CompiledConstructorScope).mi));
                 else if (ss is NamespaceScope)
                     ss.AddDocumentation(AssemblyDocCache.GetDocumentationForNamespace((ss as NamespaceScope).name));
                 else if (ss is TypeScope)
                     ss.AddDocumentation(UnitDocCache.GetDocumentation(ss as TypeScope));
                 else if (ss is ProcScope)
                     ss.AddDocumentation(UnitDocCache.GetDocumentation(ss as ProcScope));
                 else if (ss is InterfaceUnitScope)
                     ss.AddDocumentation(UnitDocCache.GetDocumentation(ss as InterfaceUnitScope));
                 else if (ss is ElementScope && string.IsNullOrEmpty(ss.si.description) && (ss as ElementScope).sc is TypeScope)
                     ss.si.description = (ss as ElementScope).sc.Description;
 		}
 		catch (Exception e)
 		{
 			
 		}
         RestoreCurrentUsedAssemblies();
         string description = ss.si.description;
         if (description != null)
             description = description.Replace("!#","");
 		return description;
 	}
     RestoreCurrentUsedAssemblies();
 	return null;
 }