codetools: class completion: add missing property semicolons

git-svn-id: trunk@20691 -
This commit is contained in:
mattias 2009-06-21 13:03:25 +00:00
parent bf9c4b2db9
commit 782c9cf39c
2 changed files with 37 additions and 25 deletions

View File

@ -4592,8 +4592,8 @@ var AccessParam, AccessParamPrefix, CleanAccessFunc, AccessFunc,
procedure ReadOptionalSpecifiers;
begin
while (CurPos.StartPos<PropNode.EndPos)
and (not (CurPos.Flag in [cafSemicolon,cafEnd])) do begin
while (CurPos.StartPos<PropNode.EndPos) do begin
if (CurPos.Flag in [cafSemicolon,cafEnd]) then break;
if UpAtomIs('STORED') then begin
ReadSimpleSpec(ppStoredWord,ppStored);
end else if UpAtomIs('DEFAULT') then begin
@ -4626,8 +4626,6 @@ var AccessParam, AccessParamPrefix, CleanAccessFunc, AccessFunc,
end else
RaiseExceptionFmt(ctsStrExpectedButAtomFound,[';',GetAtom]);
end;
if (CurPos.StartPos>PropNode.EndPos) then
RaiseException('Reparsing error (Complete Property)');
end;
procedure CompleteReadSpecifier;
@ -4960,6 +4958,15 @@ var AccessParam, AccessParamPrefix, CleanAccessFunc, AccessFunc,
end;
end;
procedure CompleteSemicolon;
begin
if (PropNode.EndPos<=SrcLen) and (Src[PropNode.EndPos-1]<>';') then begin
InsertPos:=PropNode.EndPos;
if CompleteProperties then
ASourceChangeCache.Replace(gtNone,gtNone,InsertPos,InsertPos,';');
end;
end;
begin
Result:=false;
InitCompleteProperty;
@ -4995,6 +5002,7 @@ begin
CompleteReadSpecifier;
CompleteWriteSpecifier;
CompleteStoredSpecifier;
CompleteSemicolon;
Result:=true;
end;

View File

@ -201,6 +201,7 @@ type
function ReadTilTypeOfProperty(PropertyNode: TCodeTreeNode): boolean;
procedure ReadGUID;
procedure ReadClassInheritance(CreateChildNodes: boolean);
function WordIsPropertyEnd: boolean;
public
CurSection: TCodeTreeNodeDesc;
@ -1950,8 +1951,6 @@ function TPascalParserTool.KeyWordFuncClassProperty: boolean;
SaveRaiseExceptionFmt(ctsSemicolonAfterPropSpecMissing,[s,GetAtom]);
end;
var
p: PChar;
begin
if not (CurNode.Desc in (AllClassBaseSections+[ctnClassInterface])) then
RaiseIdentExpectedButAtomFound;
@ -1971,25 +1970,7 @@ begin
case CurPos.Flag of
cafSemicolon: break;
cafEnd: break;
cafWord:
begin
p:=@Src[CurPos.StartPos];
case UpChars[p^] of
'C': if UpAtomIs('CLASS') then break;
'F': if UpAtomIs('FUNCTION') then break;
'P':
case UpChars[p[1]] of
'R':
case UpChars[p[2]] of
'I': if UpAtomIs('PRIVATE') then break;
'O': if UpAtomIs('PROTECTED') or UpAtomIs('PROCEDURE') then break;
end;
'U': if UpAtomIs('PUBLIC') or UpAtomIs('PUBLISHED') then break;
end;
'T': if UpAtomIs('TYPE') then break;
'V': if UpAtomIs('VAR') then break;
end;
end;
cafWord: if WordIsPropertyEnd then break;
end;
ReadNextAtom;
end;
@ -4326,6 +4307,29 @@ begin
end;
end;
function TPascalParserTool.WordIsPropertyEnd: boolean;
var
p: PChar;
begin
p:=@Src[CurPos.StartPos];
case UpChars[p^] of
'C': if UpAtomIs('CLASS') then exit(true);
'F': if UpAtomIs('FUNCTION') then exit(true);
'P':
case UpChars[p[1]] of
'R':
case UpChars[p[2]] of
'I': if UpAtomIs('PRIVATE') then exit(true);
'O': if UpAtomIs('PROTECTED') or UpAtomIs('PROCEDURE') then exit(true);
end;
'U': if UpAtomIs('PUBLIC') or UpAtomIs('PUBLISHED') then exit(true);
end;
'T': if UpAtomIs('TYPE') then exit(true);
'V': if UpAtomIs('VAR') then exit(true);
end;
Result:=false;
end;
procedure TPascalParserTool.ValidateToolDependencies;
begin