Rules_CS.txt added

T1->T2 for Func<T1,T2> in intellisense
T->() for Action<T> in intellisense
This commit is contained in:
Бондарев Иван 2015-05-17 10:38:48 +02:00
parent 49d0b31228
commit b3ec12b2c7
3 changed files with 264 additions and 33 deletions

View file

@ -81,20 +81,33 @@ namespace CodeCompletion
}
if (ret_tn != null && ret_tn is ElementScope && (ret_tn as ElementScope).sc is ProcType)
{
if (by_dot) if (((ret_tn as ElementScope).sc as ProcType).target.return_type != null) ret_tn = new ElementScope(((ret_tn as ElementScope).sc as ProcType).target.return_type);
else ret_tn = null;
if (by_dot)
if (((ret_tn as ElementScope).sc as ProcType).target.return_type != null)
ret_tn = new ElementScope(((ret_tn as ElementScope).sc as ProcType).target.return_type);
else
ret_tn = null;
}
else if (ret_tn != null && ret_tn is ElementScope && (ret_tn as ElementScope).sc is ProcScope)
{
if (by_dot) if (((ret_tn as ElementScope).sc as ProcScope).return_type != null) ret_tn = new ElementScope(((ret_tn as ElementScope).sc as ProcScope).return_type);
else ret_tn = null;
if (by_dot)
if (((ret_tn as ElementScope).sc as ProcScope).return_type != null)
ret_tn = new ElementScope(((ret_tn as ElementScope).sc as ProcScope).return_type);
else
ret_tn = null;
}
else if (ret_tn != null && ret_tn is ProcScope)
if ((ret_tn as ProcScope).return_type == null)
{
if (by_dot) ret_tn = null;
}
else if (by_dot) ret_tn = new ElementScope((ret_tn as ProcScope).return_type);
else if (ret_tn != null && ret_tn is ElementScope && (ret_tn as ElementScope).sc is CompiledScope && ((ret_tn as ElementScope).sc as CompiledScope).CompiledType.BaseType == typeof(MulticastDelegate))
{
ProcScope invoke_meth = ((ret_tn as ElementScope).sc as CompiledScope).FindNameOnlyInThisType("Invoke") as ProcScope;
if (invoke_meth != null)
ret_tn = new ElementScope(invoke_meth.return_type);
}
else if (ret_tn != null && ret_tn is ProcScope)
if ((ret_tn as ProcScope).return_type == null)
{
if (by_dot) ret_tn = null;
}
else if (by_dot)
ret_tn = new ElementScope((ret_tn as ProcScope).return_type);
//else ret_scope = (ret_scope as ElementScope).sc as ProcScope;
return ret_tn;
@ -133,6 +146,14 @@ namespace CodeCompletion
}
else if (ret_names[i] is ProcScope)
proces.Add(ret_names[i] as ProcScope);
else if (ret_names[i] is ElementScope && (ret_names[i] as ElementScope).sc is CompiledScope)
{
//ProcType pt = new ProcType();
CompiledScope cs = (ret_names[i] as ElementScope).sc as CompiledScope;
ProcScope ps = cs.FindNameOnlyInThisType("Invoke") as ProcScope;
if (ps != null)
proces.Add(ps);
}
}
return proces;
}
@ -842,9 +863,9 @@ namespace CodeCompletion
ret_names.Clear();
search_all = true;
_method_call.dereferencing_value.visit(this);
search_all = false;
search_all = false;
SymScope[] names = ret_names.ToArray();
if (names.Length > 0 && names[0] is ElementScope && (names[0] as ElementScope).sc is ProcType)
if (names.Length > 0 && names[0] is ElementScope && ((names[0] as ElementScope).sc is ProcType || (names[0] as ElementScope).sc is CompiledScope))
{
ret_tn = names[0];
return;

View file

@ -999,25 +999,48 @@ namespace PascalABCCompiler.Parsers
protected virtual string GetSimpleDescriptionForCompiledType(ICompiledTypeScope scope)
{
string s = GetFullTypeName(scope.CompiledType);
ITypeScope[] instances = scope.GenericInstances;
if (instances != null && instances.Length > 0)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
int ind = s.IndexOf('<');
if (ind != -1) sb.Append(s.Substring(0,ind));
else
sb.Append(s);
sb.Append('<');
for (int i=0; i<instances.Length; i++)
{
sb.Append(GetSimpleDescriptionWithoutNamespace(instances[i]));
if (i < instances.Length - 1) sb.Append(',');
}
sb.Append('>');
s = sb.ToString();
}
return s;
if (scope.CompiledType.FullName == "System.Func`2")
{
ITypeScope[] instances = scope.GenericInstances;
if (instances != null && instances.Length == 2)
{
return GetSimpleDescriptionWithoutNamespace(instances[0]) + "->" + GetSimpleDescriptionWithoutNamespace(instances[1]);
}
else
return "T->T1";
}
else if (scope.CompiledType.FullName == "System.Action`1")
{
ITypeScope[] instances = scope.GenericInstances;
if (instances != null && instances.Length == 1)
{
return GetSimpleDescriptionWithoutNamespace(instances[0]) + "->()";
}
else
return "T->()";
}
else
{
string s = GetFullTypeName(scope.CompiledType);
ITypeScope[] instances = scope.GenericInstances;
if (instances != null && instances.Length > 0)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
int ind = s.IndexOf('<');
if (ind != -1) sb.Append(s.Substring(0, ind));
else
sb.Append(s);
sb.Append('<');
for (int i = 0; i < instances.Length; i++)
{
sb.Append(GetSimpleDescriptionWithoutNamespace(instances[i]));
if (i < instances.Length - 1) sb.Append(',');
}
sb.Append('>');
s = sb.ToString();
}
return s;
}
}
protected virtual string GetDescriptionForArray(IArrayScope scope)
@ -1441,8 +1464,11 @@ namespace PascalABCCompiler.Parsers
sb.Append(GetShortTypeName(scope.CompiledMethod.DeclaringType));
else
sb.Append(GetShortTypeName(scope.CompiledMethod.GetParameters()[0].ParameterType));
sb.Append(".");
sb.Append(scope.Name);
if (scope.Name != "Invoke")
{
sb.Append(".");
sb.Append(scope.Name);
}
if (scope.CompiledMethod.GetGenericArguments().Length > 0)
{
Type[] tt = scope.CompiledMethod.GetGenericArguments();

184
bin/Rules_CS.txt Normal file
View file

@ -0,0 +1,184 @@
@namespace ::
$namespace *BW name *BlockBegin *BlockBody
${ *BlockBegin *BlockBody *BlockBody
$public *BW $class *BW name *BlockBegin *BlockBody
${ *BlockBegin
body
*BlockEnd *BlockBody $}
*BlockEnd *BlockBody $}
@class ::
access_modifier_type *BW $class *BW name *BlockBegin *BlockBody
${
*BlockBegin
body
*BlockEnd
*BlockBody $}
@struct ::
access_modifier_type *BW $struct *BW name *BlockBegin *BlockBody
${
*BlockBegin
body
*BlockEnd
*BlockBody $}
@function ::
$public *BW $static *BW type *BW name $( parameters $) *BlockBegin *BlockBody
${
*BlockBegin
body
*BlockEnd
*BlockBody $}
@return ::
$return *BW expr
@array_indexing ::
expr $[ expr $]
@function_call ::
name $( parameters $)
@comp_method_call ::
expr $. name $( parameters $)
@comp_stat_method_call ::
name $( parameters $)
@comm_stat_method_call ::
type $. name $( parameters $)
@type_of ::
$typeof $( type $)
@if ::
$if $( parameters $)
body
@if_else ::
$if $( parameters $)
body *BlockBegin *BlockBody
$else *BlockBegin *BlockBody
body
@for ::
$for $( body $)
body
@while ::
$while $( body $)
body
@repeat ::
$do
*BlockBegin *BlockBody
${
*BlockBegin
body
*BlockEnd
*BlockBody $}
$while $( parameters $)
@namespace_var ::
$public *BW $static *BW type *BW name
@var ::
type *BW name
@var_init ::
type *BW name $= body
@const ::
$public *BW $const *BW type *BW name
@statements ::
body
@statements_nested :: *BlockBegin *BlockBody
${
*BlockBegin
body
*BlockEnd
*BlockBody $}
@binop_assign ::
expr *BW $= *BW expr
@binop_add ::
expr *BW $+ *BW expr
@binop_subtract ::
expr *BW $- *BW expr
@binop_mult ::
expr *BW $* *BW expr
@binop_div ::
expr $/ expr
@unop_plus ::
$+ expr
@unop_minus ::
$- expr
@binop_mod ::
expr $% expr
@binop_eq ::
expr *BW $== *BW expr
@binop_gr ::
expr *BW $> *BW expr
@binop_sm ::
expr *BW $< *BW expr
@binop_greq ::
expr *BW $>= *BW expr
@binop_smeq ::
expr *BW $<= *BW expr
@binop_and ::
expr *BW $&& *BW expr
@binop_or ::
expr *BW $|| *BW expr
@binop_xor ::
expr $^ expr
@unop_inc ::
$++ expr
@unop_dec ::
$-- expr
@unop_unmin ::
$- $( expr $)
@unop_not ::
$! expr
@binop_shl ::
expr $<< expr
@binop_shr ::
expr $>> expr
@constructor_call ::
$new *BW type $( parameters $)
@var_locblock ::
name
@variable_reference ::
name
@locvariable_reference ::
name