Compare commits

...

5 Commits

Author SHA1 Message Date
Adrien Prokopowicz
2701c6e0ab
Merge branch 'master' of gitlab.com:gambas/gambas into exclamation-mark-completion 2017-08-12 11:16:54 +02:00
Adrien Prokopowicz
a3607fe370
[DEVELOPMENT ENVIRONMENT]
* BUG: Fixed completion of the "!" operator.
2017-08-04 17:19:14 +02:00
Adrien Prokopowicz
2dc5b05463
Merge branch 'master' of gitlab.com:prokopyl/gambas into fix-nested-withs 2017-08-03 15:09:27 +02:00
Adrien Prokopowicz
a2dae4d6c1
[DEVELOPMENT ENVIRONMENT]
* NEW: Added support for nested WITH expressions in code completion.
2017-08-03 15:02:33 +02:00
Adrien Prokopowicz
c75311bb86
[COMPILER]
* BUG: The WITH's expression is now evaluated before entering the WITH's scope.
2017-08-01 00:54:18 +02:00
2 changed files with 43 additions and 15 deletions

View File

@ -969,7 +969,7 @@ Public Sub Editors_KeyPress()
$bCheckSignature = True
Else If InStr("(),[]", Key.Text) Then
Else If InStr("(),[]!", Key.Text) Then
$bCheckSignature = True
@ -1631,6 +1631,8 @@ Private Sub GetSymbolWith(aExpr As String[], aType As Integer[], Optional iInd A
Dim iLine As Integer
Dim aWith As String[]
Dim aWithType As Integer[]
Dim aWithNested As String[]
Dim aWithTypeNested As Integer[]
Dim iLevel As Integer
Dim iAssign As Integer
@ -1655,6 +1657,22 @@ Private Sub GetSymbolWith(aExpr As String[], aType As Integer[], Optional iInd A
Endif
Next
' Nested WITHs
If Left$(aWith[0]) = "." Then
If Not aWithNested Then 'Lazy buffer allocations
aWithNested = New String[]
aWithTypeNested = New Integer[]
Endif
aWithNested.Insert(aWith, 0)
aWithTypeNested.Insert(aWithType, 0)
Continue
Endif
If aWithNested Then
aWith.Insert(aWithNested)
aWithType.Insert(aWithTypeNested)
Endif
aExpr.Insert(aWith, iInd)
aType.Insert(aWithType, iInd)
Return
@ -1709,7 +1727,7 @@ Private Sub GetExpressionStart(aExpr As String[], aType As Integer[]) As Integer
Endif
bLastSymbol = False
Continue
Else If sPattern = "." Then
Else If sPattern = "." Or sPattern = "!" Then
bLastSymbol = False
Continue
Else If IsTypeSymbol(sPattern, aType[iInd]) Then
@ -1831,7 +1849,7 @@ Public Function GetExpressionType(aExpr As String[], aType As Integer[], bPointA
sType = $hSymbol.Type ' A method cannot return static classes
$bLastStatic = False
Endif
Else If sPattern = "]" Then
Else If sPattern = "]" Or sPattern = "!" Then
If Not sType Then ' Array constructor operator [ ... ]
Return
@ -1962,13 +1980,19 @@ Public Sub CheckCompletion(sMode As String)
$bCheckSignature = True
sWord = $hCompletion.GetWord(sLine, $hEditor.Column - 1)
If Right(sLine) <> "." And If Len(sLine) > Len(sWord) And If Mid$(sLine, Len(sLine) - Len(sWord), 1) = "." Then
iPos = $hEditor.Column
$hEditor.Goto($hEditor.Column - String.Len(sWord) - 2, $hEditor.Line)
CheckCompletion(".")
FCompletion.SetText(sWord)
$hEditor.Goto(iPos, $hEditor.Line)
Return
If Right(sLine) <> "." And If Len(sLine) > Len(sWord) Then
Select Case Mid$(sLine, Len(sLine) - Len(sWord), 1)
Case "."
iPos = $hEditor.Column
$hEditor.Goto($hEditor.Column - String.Len(sWord) - 2, $hEditor.Line)
CheckCompletion(".")
FCompletion.SetText(sWord)
$hEditor.Goto(iPos, $hEditor.Line)
Return
Case "!" 'Do not trigger completion form for index shortcut
$hCompletion.Hide
Return
End Select
Endif
If Len(sWord) >= 3 Then
@ -2002,6 +2026,7 @@ Private Function GetExpressionSignature(aExpr As String[], aType As Integer[]) A
Dim sPattern As String
Dim sType As String
Dim bNew As Boolean
Dim bIndexShortcutEnded As Boolean
$hSymbol = Null
$iArgSignature = 0
@ -2027,6 +2052,10 @@ Private Function GetExpressionSignature(aExpr As String[], aType As Integer[]) A
Break
Else If sPattern = "," Then
Inc $iArgSignature
Else If sPattern = "." Or sPattern = "=" Then
bIndexShortcutEnded = True
Else If sPattern = "!" And bIndexShortcutEnded = False
Break
Endif
Next
@ -2049,7 +2078,7 @@ Private Function GetExpressionSignature(aExpr As String[], aType As Integer[]) A
Else
Try $hSymbol = Project.Documentation.GetClassSymbols(sType)["_call"]
Endif
Else If sPattern = "[" Then
Else If sPattern = "[" Or sPattern = "!" Then
$hSymbol = Null
Try $hSymbol = Project.Documentation.GetClassSymbols(sType)["_get"]
Endif

View File

@ -1200,15 +1200,14 @@ void TRANS_label(void)
void TRANS_with(void)
{
control_enter(RS_WITH);
if (!TRANS_affectation(TRUE))
TRANS_expression(FALSE);
if (!TRANS_affectation(TRUE))
TRANS_expression(FALSE);
control_enter(RS_WITH);
CODE_pop_ctrl(current_ctrl->local);
}
void TRANS_use_with(void)
{
TRANS_CTRL *ctrl_inner = control_get_inner_with();