@@ -152,7 +152,7 @@ static public bool OnChar(ScintillaControl Sci, int Value, bool autoHide)
152152 return HandleFunctionCompletion ( Sci , autoHide ) ;
153153 break ;
154154 }
155- if ( word == "class" || word == " package" || word == "interface" )
155+ if ( word == "package" || Array . IndexOf ( features . typesKeywords , word ) >= 0 )
156156 return false ;
157157 // new/extends/instanceof/...
158158 if ( features . HasTypePreKey ( word ) )
@@ -161,9 +161,7 @@ static public bool OnChar(ScintillaControl Sci, int Value, bool autoHide)
161161 if ( features . hasImports && ( word == features . importKey || word == features . importKeyAlt ) )
162162 return HandleImportCompletion ( Sci , "" , autoHide ) ;
163163 // public/internal/private/protected/static
164- if ( word == features . publicKey || word == features . internalKey
165- || word == features . protectedKey || word == features . privateKey
166- || word == features . staticKey || word == features . inlineKey )
164+ if ( Array . IndexOf ( features . accessKeywords , word ) >= 0 )
167165 return HandleDeclarationCompletion ( Sci , "" , autoHide ) ;
168166 // override
169167 if ( word == features . overrideKey )
@@ -1198,8 +1196,10 @@ static private bool HandleDeclarationCompletion(ScintillaControl Sci, string tai
11981196 if ( Sci . CharAt ( position - 1 ) <= 32 ) tail = "" ;
11991197
12001198 // completion support
1201- ContextFeatures features = ASContext . Context . Features ;
1202- List < string > support = features . GetDeclarationKeywords ( Sci . GetLine ( line ) ) ;
1199+ IASContext ctx = ASContext . Context ;
1200+ ContextFeatures features = ctx . Features ;
1201+ bool insideClass = ! ctx . CurrentClass . IsVoid ( ) && ctx . CurrentClass . LineFrom < line ;
1202+ List < string > support = features . GetDeclarationKeywords ( Sci . GetLine ( line ) , insideClass ) ;
12031203 if ( support . Count == 0 ) return true ;
12041204
12051205 // current model
@@ -1211,12 +1211,16 @@ static private bool HandleDeclarationCompletion(ScintillaControl Sci, string tai
12111211 int tempLine = line - 1 ;
12121212 int tempIndent ;
12131213 string tempText ;
1214- while ( tempLine > 0 )
1214+ while ( tempLine > 0 )
12151215 {
12161216 tempText = Sci . GetLine ( tempLine ) . Trim ( ) ;
1217- if ( tempText . IndexOf ( "class" ) >= 0 || tempText . IndexOf ( "interface" ) >= 0 || tempText . IndexOf ( "enum" ) >= 0 )
1217+ if ( insideClass && IsTypeDecl ( tempText , features . typesKeywords ) )
1218+ {
1219+ tempIndent = Sci . GetLineIndentation ( tempLine ) ;
1220+ tab = tempIndent + Sci . TabWidth ;
12181221 break ;
1219- if ( tempText . Length > 0 && ( tempText . EndsWith ( "}" ) || IsDeclaration ( tempText ) ) )
1222+ }
1223+ if ( tempText . Length > 0 && ( tempText . EndsWith ( "}" ) || IsDeclaration ( tempText , features ) ) )
12201224 {
12211225 tempIndent = Sci . GetLineIndentation ( tempLine ) ;
12221226 tab = tempIndent ;
@@ -1241,20 +1245,19 @@ static private bool HandleDeclarationCompletion(ScintillaControl Sci, string tai
12411245 return true ;
12421246 }
12431247
1244- private static bool IsDeclaration ( string line )
1248+ private static bool IsTypeDecl ( string line , string [ ] typesKeywords )
12451249 {
1246- ContextFeatures features = ASContext . Context . Features ;
1247- if ( ! string . IsNullOrEmpty ( features . privateKey ) && line . StartsWith ( features . privateKey ) ) return true ;
1248- if ( ! string . IsNullOrEmpty ( features . protectedKey ) && line . StartsWith ( features . protectedKey ) ) return true ;
1249- if ( ! string . IsNullOrEmpty ( features . internalKey ) && line . StartsWith ( features . internalKey ) ) return true ;
1250- if ( ! string . IsNullOrEmpty ( features . publicKey ) && line . StartsWith ( features . publicKey ) ) return true ;
1251- if ( ! string . IsNullOrEmpty ( features . varKey ) && line . StartsWith ( features . varKey ) ) return true ;
1252- if ( ! string . IsNullOrEmpty ( features . constKey ) && line . StartsWith ( features . constKey ) ) return true ;
1253- if ( ! string . IsNullOrEmpty ( features . overrideKey ) && line . StartsWith ( features . overrideKey ) ) return true ;
1254- if ( ! string . IsNullOrEmpty ( features . inlineKey ) && line . StartsWith ( features . inlineKey ) ) return true ;
1255- if ( ! string . IsNullOrEmpty ( features . functionKey ) && line . StartsWith ( features . functionKey ) ) return true ;
1256- if ( ! string . IsNullOrEmpty ( features . staticKey ) && line . StartsWith ( features . staticKey ) ) return true ;
1257- if ( ! string . IsNullOrEmpty ( features . finalKey ) && line . StartsWith ( features . finalKey ) ) return true ;
1250+ foreach ( string keyword in typesKeywords )
1251+ if ( line . IndexOf ( keyword ) >= 0 ) return true ;
1252+ return false ;
1253+ }
1254+
1255+ private static bool IsDeclaration ( string line , ContextFeatures features )
1256+ {
1257+ foreach ( string keyword in features . accessKeywords )
1258+ if ( line . StartsWith ( keyword ) ) return true ;
1259+ foreach ( string keyword in features . declKeywords )
1260+ if ( line . StartsWith ( keyword ) ) return true ;
12581261 return false ;
12591262 }
12601263
@@ -1751,9 +1754,7 @@ static private bool HandleDotCompletion(ScintillaControl Sci, bool autoHide)
17511754
17521755 // complete keyword
17531756 string word = expr . WordBefore ;
1754- if ( word != null &&
1755- ( word == features . varKey || word == features . functionKey || word == features . constKey
1756- || word == features . getKey || word == features . setKey ) )
1757+ if ( word != null && Array . IndexOf ( features . declKeywords , word ) >= 0 )
17571758 return false ;
17581759 ClassModel argumentType = null ;
17591760 if ( dotIndex < 0 )
@@ -1927,11 +1928,7 @@ static private bool HandleDotCompletion(ScintillaControl Sci, bool autoHide)
19271928 mix . Merge ( cFile . GetSortedMembersList ( ) ) ;
19281929 mix . Merge ( ctx . GetTopLevelElements ( ) ) ;
19291930 mix . Merge ( ctx . GetVisibleExternalElements ( ) ) ;
1930- MemberList decl = new MemberList ( ) ;
1931- foreach ( string key in features . codeKeywords )
1932- decl . Add ( new MemberModel ( key , key , FlagType . Template , 0 ) ) ;
1933- decl . Sort ( ) ;
1934- mix . Merge ( decl ) ;
1931+ mix . Merge ( GetKeywords ( ) ) ;
19351932 }
19361933
19371934 // show
@@ -1953,6 +1950,30 @@ static private bool HandleDotCompletion(ScintillaControl Sci, bool autoHide)
19531950 return true ;
19541951 }
19551952
1953+ private static MemberList GetKeywords ( )
1954+ {
1955+ IASContext ctx = ASContext . Context ;
1956+ ContextFeatures features = ctx . Features ;
1957+ ClassModel cClass = ctx . CurrentClass ;
1958+ bool inClass = ! cClass . IsVoid ( ) ;
1959+
1960+ MemberList decl = new MemberList ( ) ;
1961+ if ( inClass || ! ctx . CurrentModel . haXe )
1962+ {
1963+ foreach ( string key in features . codeKeywords )
1964+ decl . Add ( new MemberModel ( key , key , FlagType . Template , 0 ) ) ;
1965+ }
1966+ if ( ! inClass )
1967+ {
1968+ foreach ( string key in features . accessKeywords )
1969+ decl . Add ( new MemberModel ( key , key , FlagType . Template , 0 ) ) ;
1970+ foreach ( string key in features . typesKeywords )
1971+ decl . Add ( new MemberModel ( key , key , FlagType . Template , 0 ) ) ;
1972+ }
1973+ decl . Sort ( ) ;
1974+ return decl ;
1975+ }
1976+
19561977 private static bool DeclarationSectionOnly ( )
19571978 {
19581979 ClassModel inClass = ASContext . Context . CurrentClass ;
0 commit comments