本文整理汇总了C#中CodeCompletion.ExpressionVisitor.GetScopeOfExpression方法的典型用法代码示例。如果您正苦于以下问题:C# ExpressionVisitor.GetScopeOfExpression方法的具体用法?C# ExpressionVisitor.GetScopeOfExpression怎么用?C# ExpressionVisitor.GetScopeOfExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeCompletion.ExpressionVisitor
的用法示例。
在下文中一共展示了ExpressionVisitor.GetScopeOfExpression方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDescription
/// <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;
}
示例2: GetIndex
/// <summary>
/// Получить подсказку индекса
/// </summary>
public string[] GetIndex(expression expr, int line, int col)
{
if (stv.cur_scope == null) return null;
SymScope si = stv.FindScopeByLocation(line+1,col+1);//stv.cur_scope;
if (si == null)
{
si = stv.FindScopeByLocation(line,col+1);
if (si == null)
return null;
}
ExpressionVisitor ev = new ExpressionVisitor(expr, si, stv);
si = ev.GetScopeOfExpression(false,true);
return CodeCompletionController.CurrentParser.LanguageInformation.GetIndexerString(si);
}
示例3: GetName
/// <summary>
/// Получение имен после точки
/// </summary>
public SymInfo[] GetName(expression expr, string str, int line, int col, PascalABCCompiler.Parsers.KeywordKind keyword, ref SymScope root)
{
if (stv.cur_scope == null) return null;
if (col + 1 > str.Length)
col -= str.Length;
SymScope si = stv.FindScopeByLocation(line + 1, col + 1);//stv.cur_scope;
if (si == null)
{
si = stv.FindScopeByLocation(line, col + 1);
if (si == null)
return null;
}
SetCurrentUsedAssemblies();
ExpressionVisitor ev = new ExpressionVisitor(expr, si, stv);
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 = stv.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();
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;
}
示例4: GetRealization
/// <summary>
/// Получить реализацию expr
/// </summary>
public List<Position> GetRealization(expression expr, int line, int col, PascalABCCompiler.Parsers.KeywordKind keyword)
{
List<Position> poses = new List<Position>();
Position pos = new Position(); pos.line = -1; pos.column = -1;
try
{
if (stv.cur_scope == null) return poses;
SymScope ss = stv.FindScopeByLocation(line+1,col+1);//stv.cur_scope;
if (ss == null) return poses;
//if (!(expr is ident && string.Compare((expr as ident).name,ss.si.name) == 0))
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)
//if (keyword != KeywordKind.kw_proc && keyword != KeywordKind.kw_constr && keyword != KeywordKind.kw_destr)
{
ExpressionVisitor ev = new ExpressionVisitor(expr, ss, stv);
ss = ev.GetScopeOfExpression();
}
while (ss != null && ss is ProcScope && (ss as ProcScope).proc_realization != null && (ss as ProcScope).proc_realization.loc != null)
{
ProcRealization pr = (ss as ProcScope).proc_realization;
pos.line = pr.loc.begin_line_num;
pos.column = pr.loc.begin_column_num;
pos.file_name = pr.loc.doc.file_name;
poses.Add(pos);
if (on_proc) break;
//ss = (ss as ProcScope).nextProc;
ss = null;
}
}
catch (Exception e)
{
}
RestoreCurrentUsedAssemblies();
return poses;
}
示例5: GetDefinition
/// <summary>
/// Получить определение expr
/// </summary>
public List<Position> GetDefinition(expression expr, int line, int col, PascalABCCompiler.Parsers.KeywordKind keyword, bool only_check)
{
List<Position> poses = new List<Position>();
Position pos = new Position(); pos.line = -1; pos.column = -1;
try
{
if (stv.cur_scope == null) return poses;
SymScope ss = stv.FindScopeByLocation(line+1,col+1);//stv.cur_scope;
if (ss == null) return poses;
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)
//if (!((keyword == KeywordKind.kw_proc || keyword == KeywordKind.kw_constr || keyword == KeywordKind.kw_destr) && ss is ProcRealization))
{
ExpressionVisitor ev = new ExpressionVisitor(expr, ss, stv);
ss = ev.GetScopeOfExpression();
}
else
if (ss is ProcRealization)
ss = (ss as ProcRealization).def_proc;
if (ss != null)
{
if (ss.loc != null)
{
pos.line = ss.loc.begin_line_num;
pos.column = ss.loc.begin_column_num;
pos.file_name = ss.loc.doc.file_name;
poses.Add(pos);
}
else if (ss is ProcScope && (ss as ProcScope).is_constructor)
{
ss = (ss as ProcScope).declaringType;
if (ss.loc != null)
{
pos.line = ss.loc.begin_line_num;
pos.column = ss.loc.begin_column_num;
pos.file_name = ss.loc.doc.file_name;
poses.Add(pos);
}
}
else if (ss is CompiledScope)
{
pos.from_metadata = true;
pos.line = 1;
pos.column = 1;
CompiledScope cs = ss as CompiledScope;
pos.metadata_title = prepare_file_name(cs.CompiledType.Name);
pos.full_metadata_title = cs.CompiledType.FullName;
if (cs.CompiledType.IsInterface)
pos.metadata_type = MetadataType.Interface;
else if (cs.CompiledType.BaseType == typeof(Delegate) || cs.CompiledType.BaseType == typeof(MulticastDelegate))
pos.metadata_type = MetadataType.Delegate;
else if (cs.CompiledType.IsEnum)
pos.metadata_type = MetadataType.Enumeration;
else if (cs.CompiledType.IsValueType)
pos.metadata_type = MetadataType.Struct;
else
pos.metadata_type = MetadataType.Class;
if (!only_check)
{
pos.metadata = CodeCompletionController.CurrentParser.LanguageInformation.GetCompiledTypeRepresentation(cs.CompiledType, cs.CompiledType, ref pos.line, ref pos.column);
Type t = cs.CompiledType;
int lines = 0;
int ind = pos.metadata.IndexOf('\n');
pos.metadata = pos.metadata.Insert(ind + 1, get_references(t, out lines));
pos.line += lines;
}
poses.Add(pos);
}
else if (ss is CompiledFieldScope)
{
pos.from_metadata = true;
pos.line = 1;
//.........这里部分代码省略.........
示例6: GetTypes
/// <summary>
/// Выдает все типы (используется после new)
/// </summary>
public SymInfo[] GetTypes(expression expr, int line, int col, out SymInfo out_si)
{
out_si = null;
if (stv.cur_scope == null) return null;
SymScope si = stv.FindScopeByLocation(line + 1, col + 1);//stv.cur_scope;
SymInfo[] elems = null;
if (si == null) return null;
elems = si.GetNamesInAllTopScopes(true, new ExpressionVisitor(si, stv), false);
if (expr != null)
{
ExpressionVisitor ev = new ExpressionVisitor(expr, si, stv);
si = ev.GetScopeOfExpression();
if (si is TypeScope)
si = new ElementScope(si);
}
List<SymInfo> result_names = new List<SymInfo>();
if (elems == null) return null;
for (int i = 0; i < elems.Length; i++)
{
if (!elems[i].name.StartsWith("$") && (elems[i].kind == SymbolKind.Class || elems[i].kind == SymbolKind.Namespace) && elems[i].kind != SymbolKind.Interface)
{
if (expr != null && si != null && si is ElementScope &&
string.Compare(elems[i].name, (si as ElementScope).sc.si.name, true) == 0)
{
out_si = elems[i];
//out_si = new SymInfo(elems[i].name,elems[i].kind,elems[i].describe);
string s = CodeCompletionController.CurrentParser.LanguageInformation.GetSimpleDescriptionWithoutNamespace((si as ElementScope).sc as PascalABCCompiler.Parsers.ITypeScope);
if (s != out_si.name)
out_si.addit_name = s;
// if (((si as ElementScope).sc as TypeScope).TemplateArguments != null)
// {
// SymInfo tmp_si = new SymInfo(null,elems[i].kind,elems[i].describe);
// StringBuilder sb = new StringBuilder();
// string[] template_args = ((si as ElementScope).sc as TypeScope).TemplateArguments;
// sb.Append(elems[i].name);
// sb.Append('<');
// for (int j=0; j<template_args.Length; j++)
// {
// sb.Append(template_args[j]);
// if (j<template_args.Length-1)
// sb.Append(',');
// }
// sb.Append('>');
// elems[i] = tmp_si;
// out_si = tmp_si;
// }
}
result_names.Add(elems[i]);
}
}
if (out_si == null && expr != null && si != null && si is ElementScope)
{
out_si = (si as ElementScope).sc.si;
if (!out_si.name.StartsWith("$") && out_si.kind != SymbolKind.Interface)
{
out_si.name = (si as ElementScope).sc.GetFullName();
result_names.Add(out_si);
}
else
{
out_si = null;
}
}
return result_names.ToArray();
}
示例7: GetSymDefinition
/// <summary>
/// Получение описания символа
/// </summary>
public IBaseScope GetSymDefinition(expression expr, int line, int col, PascalABCCompiler.Parsers.KeywordKind keyword)
{
if (stv.cur_scope == null) return null;
SymScope ss = stv.FindScopeByLocation(line + 1, col + 1);//stv.cur_scope;
if (ss == null) return null;
bool on_proc = false;
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)
{
SetCurrentUsedAssemblies();
ExpressionVisitor ev = new ExpressionVisitor(expr, ss, stv);
ss = ev.GetScopeOfExpression();
RestoreCurrentUsedAssemblies();
}
return ss;
}