MG: new expression evalution for find declaration and fixes

git-svn-id: trunk@1606 -
This commit is contained in:
lazarus 2002-04-15 10:54:13 +00:00
parent a5b5b0b875
commit 9beb5af34e
7 changed files with 858 additions and 663 deletions

View File

@ -315,10 +315,24 @@ function TCodeCompletionCodeTool.CompleteProperty(
stored <id>, default <constant>
}
type
TPropPart = (ppName,ppParamList, ppType, ppIndexWord, ppIndex, ppReadWord,
ppRead, ppWriteWord, ppWrite, ppStoredWord, ppStored,
ppImplementsWord, ppImplements, ppDefaultWord, ppDefault,
ppNoDefaultWord);
TPropPart = (ppName, // property name
ppParamList, // param list
ppType, // type identifier
ppIndexWord, // 'index'
ppIndex, // index constant
ppReadWord, // 'read'
ppRead, // read identifier
ppWriteWord, // 'write'
ppWrite, // write identifier
ppStoredWord, // 'stored'
ppStored, // stored identifier
ppImplementsWord,// 'implements'
ppImplements, // implements identifier
ppDefaultWord,// 'default' (the default value keyword,
// not the default property)
ppDefault, // default constant
ppNoDefaultWord// 'nodefault'
);
var Parts: array[TPropPart] of TAtomPosition;
@ -328,6 +342,7 @@ var Parts: array[TPropPart] of TAtomPosition;
RaiseExceptionFmt(ctsPropertySpecifierAlreadyDefined,[GetAtom]);
Parts[SpecWord]:=CurPos;
ReadNextAtom;
if AtomIsChar(';') then exit;
Result:=AtomIsWord;
if not Result then
RaiseExceptionFmt(ctsIdentExpectedButAtomFound,[GetAtom]);
@ -1641,13 +1656,14 @@ var CleanCursorPos, Indent, insertPos: integer;
Result:=false;
// find declaration of property identifier
Params.ContextNode:=CursorNode;
Params.SetIdentifier(Self,@Src[PropertyAtom.StartPos],nil);
MoveCursorToCleanPos(PropertyAtom.StartPos);
Params.SetIdentifier(Self,@Src[CurPos.StartPos],nil);
FullTopLvlName:='';
Params.OnTopLvlIdentifierFound:=@OnTopLvlIdentifierFound;
Params.Flags:=[fdfSearchInParentNodes,fdfSearchInAncestors,
fdfTopLvlResolving]
fdfTopLvlResolving,fdfFindVariable]
+fdfAllClassVisibilities;
if (not FindDeclarationOfIdentifier(Params))
if (not FindDeclarationOfIdentAtCursor(Params))
or (Params.NewNode.Desc<>ctnProperty) then exit;
PropertyContext:=CreateFindContext(Params);
// identifier is property

View File

@ -92,7 +92,7 @@ ResourceString
// find declaration
ctsUnitNotFound = 'unit not found: %s';
ctsIdentifierNotFound = 'identifier not found: %s';
ctsExprTypeIsNotVariable = 'expression type is not a variable';
ctsNoContextNodeFoundAtCursor = 'no context node found at cursor';
ctsInheritedKeywordOnlyAllowedInMethods =
'inherited keyword only allowed in methods';
ctsCircleInDefinitions = 'circle in definitions';
@ -112,6 +112,8 @@ ResourceString
ctsInterfaceSectionNotFound = 'interface section not found';
ctsUsedUnitIsNotAPascalUnit = 'used unit is not a pascal unit';
ctsDuplicateIdentifier = 'duplicate identifier: %s';
ctsQualifierExpectedButAtomFound = 'qualifier expected but %s found';
ctsIncompatibleTypesGotExpected = 'incompatibles types: expected "%s" but got "%s"';
// codecompletion
ctsPropertySpecifierAlreadyDefined = 'property specifier already defined: %s';

View File

@ -131,7 +131,7 @@ const
ctnProcedureType,ctnSetType,ctnRangeType,ctnEnumerationType,
ctnEnumIdentifier,ctnLabelType,ctnTypeType,ctnFileType,ctnPointerType,
ctnClassOfType,ctnVariantType];
AllPasclStatements = [ctnBeginBlock,ctnWithStatement,ctnCaseStatement];
AllPascalStatements = [ctnBeginBlock,ctnWithStatement,ctnCaseStatement];
AllSourceTypes =
[ctnProgram,ctnPackage,ctnLibrary,ctnUnit];
AllUsableSourceTypes =
@ -175,6 +175,7 @@ type
function Prior: TCodeTreeNode;
function HasAsParent(Node: TCodeTreeNode): boolean;
function HasParentOfType(ParentDesc: TCodeTreeNodeDesc): boolean;
function GetNodeOfType(ADesc: TCodeTreeNodeDesc): TCodeTreeNode;
function DescAsString: string;
procedure Clear;
constructor Create;
@ -424,6 +425,14 @@ begin
Result:=ANode<>nil;
end;
function TCodeTreeNode.GetNodeOfType(ADesc: TCodeTreeNodeDesc
): TCodeTreeNode;
begin
Result:=Self;
while (Result<>nil) and (Result.Desc<>ADesc) do
Result:=Result.Parent;
end;
function TCodeTreeNode.DescAsString: string;
begin
Result:=NodeDescriptionAsString(Desc);

View File

@ -127,7 +127,7 @@ type
function IsPCharInSrc(ACleanPos: PChar): boolean;
function ReadTilSection(SectionType: TCodeTreeNodeDesc): boolean;
function ReadTilBracketClose(ExceptionOnNotFound: boolean): boolean;
function ReadBackTilBracketClose(ExceptionOnNotFound: boolean): boolean;
function ReadBackTilBracketOpen(ExceptionOnNotFound: boolean): boolean;
function DoAtom: boolean; virtual;
procedure ReadNextAtom;
procedure UndoReadNextAtom;
@ -1156,7 +1156,7 @@ begin
Result:=true;
end;
function TCustomCodeTool.ReadBackTilBracketClose(
function TCustomCodeTool.ReadBackTilBracketOpen(
ExceptionOnNotFound: boolean): boolean;
// reads code brackets (not comment brackets)
var CloseBracket, AntiCloseBracket: char;
@ -1186,7 +1186,7 @@ begin
exit;
end;
if (AtomIsChar(')')) or (AtomIsChar(']')) then begin
if not ReadBackTilBracketClose(ExceptionOnNotFound) then exit;
if not ReadBackTilBracketOpen(ExceptionOnNotFound) then exit;
end;
until false;
Result:=true;

File diff suppressed because it is too large Load Diff

View File

@ -806,6 +806,8 @@ function TPascalParserTool.KeyWordFuncClassVarTypeSet: boolean;
set of (MyEnummy4 := 4 , MyEnummy5);
}
begin
CreateChildNode;
CurNode.Desc:=ctnSetType;
ReadNextAtom;
if not UpAtomIs('OF') then
SaveRaiseExceptionFmt(ctsStrExpectedButAtomFound,['"of"',GetAtom]);
@ -817,6 +819,8 @@ begin
else if AtomIsChar('(') then
// set of ()
ReadTilBracketClose(true);
CurNode.EndPos:=CurPos.EndPos;
EndChildNode;
Result:=true;
end;
@ -3449,7 +3453,7 @@ begin
RaiseLastError;
// check if cursor is in interface
Dummy:=CaretToCleanPos(CursorPos, CleanCursorPos);
if (Dummy in [0,-1]) then
if (Dummy=0) or (Dummy=-1) then
exit;
end;
BuildTree(TreeRange=trInterface);

View File

@ -1395,10 +1395,10 @@ begin
dec(CurPos.StartPos);
end;
end else begin
Result:=ReadBackTilBracketClose(false);
Result:=ReadBackTilBracketOpen(false);
end;
end else if OpenBracket=']' then begin
Result:=ReadBackTilBracketClose(false);
Result:=ReadBackTilBracketOpen(false);
end;
end;