mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 20:19:24 +02:00
MG: new expression evalution for find declaration and fixes
git-svn-id: trunk@1606 -
This commit is contained in:
parent
a5b5b0b875
commit
9beb5af34e
@ -315,10 +315,24 @@ function TCodeCompletionCodeTool.CompleteProperty(
|
|||||||
stored <id>, default <constant>
|
stored <id>, default <constant>
|
||||||
}
|
}
|
||||||
type
|
type
|
||||||
TPropPart = (ppName,ppParamList, ppType, ppIndexWord, ppIndex, ppReadWord,
|
TPropPart = (ppName, // property name
|
||||||
ppRead, ppWriteWord, ppWrite, ppStoredWord, ppStored,
|
ppParamList, // param list
|
||||||
ppImplementsWord, ppImplements, ppDefaultWord, ppDefault,
|
ppType, // type identifier
|
||||||
ppNoDefaultWord);
|
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;
|
var Parts: array[TPropPart] of TAtomPosition;
|
||||||
|
|
||||||
@ -328,6 +342,7 @@ var Parts: array[TPropPart] of TAtomPosition;
|
|||||||
RaiseExceptionFmt(ctsPropertySpecifierAlreadyDefined,[GetAtom]);
|
RaiseExceptionFmt(ctsPropertySpecifierAlreadyDefined,[GetAtom]);
|
||||||
Parts[SpecWord]:=CurPos;
|
Parts[SpecWord]:=CurPos;
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
|
if AtomIsChar(';') then exit;
|
||||||
Result:=AtomIsWord;
|
Result:=AtomIsWord;
|
||||||
if not Result then
|
if not Result then
|
||||||
RaiseExceptionFmt(ctsIdentExpectedButAtomFound,[GetAtom]);
|
RaiseExceptionFmt(ctsIdentExpectedButAtomFound,[GetAtom]);
|
||||||
@ -1641,13 +1656,14 @@ var CleanCursorPos, Indent, insertPos: integer;
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
// find declaration of property identifier
|
// find declaration of property identifier
|
||||||
Params.ContextNode:=CursorNode;
|
Params.ContextNode:=CursorNode;
|
||||||
Params.SetIdentifier(Self,@Src[PropertyAtom.StartPos],nil);
|
MoveCursorToCleanPos(PropertyAtom.StartPos);
|
||||||
|
Params.SetIdentifier(Self,@Src[CurPos.StartPos],nil);
|
||||||
FullTopLvlName:='';
|
FullTopLvlName:='';
|
||||||
Params.OnTopLvlIdentifierFound:=@OnTopLvlIdentifierFound;
|
Params.OnTopLvlIdentifierFound:=@OnTopLvlIdentifierFound;
|
||||||
Params.Flags:=[fdfSearchInParentNodes,fdfSearchInAncestors,
|
Params.Flags:=[fdfSearchInParentNodes,fdfSearchInAncestors,
|
||||||
fdfTopLvlResolving]
|
fdfTopLvlResolving,fdfFindVariable]
|
||||||
+fdfAllClassVisibilities;
|
+fdfAllClassVisibilities;
|
||||||
if (not FindDeclarationOfIdentifier(Params))
|
if (not FindDeclarationOfIdentAtCursor(Params))
|
||||||
or (Params.NewNode.Desc<>ctnProperty) then exit;
|
or (Params.NewNode.Desc<>ctnProperty) then exit;
|
||||||
PropertyContext:=CreateFindContext(Params);
|
PropertyContext:=CreateFindContext(Params);
|
||||||
// identifier is property
|
// identifier is property
|
||||||
|
@ -92,7 +92,7 @@ ResourceString
|
|||||||
// find declaration
|
// find declaration
|
||||||
ctsUnitNotFound = 'unit not found: %s';
|
ctsUnitNotFound = 'unit not found: %s';
|
||||||
ctsIdentifierNotFound = 'identifier not found: %s';
|
ctsIdentifierNotFound = 'identifier not found: %s';
|
||||||
ctsExprTypeIsNotVariable = 'expression type is not a variable';
|
ctsNoContextNodeFoundAtCursor = 'no context node found at cursor';
|
||||||
ctsInheritedKeywordOnlyAllowedInMethods =
|
ctsInheritedKeywordOnlyAllowedInMethods =
|
||||||
'inherited keyword only allowed in methods';
|
'inherited keyword only allowed in methods';
|
||||||
ctsCircleInDefinitions = 'circle in definitions';
|
ctsCircleInDefinitions = 'circle in definitions';
|
||||||
@ -112,6 +112,8 @@ ResourceString
|
|||||||
ctsInterfaceSectionNotFound = 'interface section not found';
|
ctsInterfaceSectionNotFound = 'interface section not found';
|
||||||
ctsUsedUnitIsNotAPascalUnit = 'used unit is not a pascal unit';
|
ctsUsedUnitIsNotAPascalUnit = 'used unit is not a pascal unit';
|
||||||
ctsDuplicateIdentifier = 'duplicate identifier: %s';
|
ctsDuplicateIdentifier = 'duplicate identifier: %s';
|
||||||
|
ctsQualifierExpectedButAtomFound = 'qualifier expected but %s found';
|
||||||
|
ctsIncompatibleTypesGotExpected = 'incompatibles types: expected "%s" but got "%s"';
|
||||||
|
|
||||||
// codecompletion
|
// codecompletion
|
||||||
ctsPropertySpecifierAlreadyDefined = 'property specifier already defined: %s';
|
ctsPropertySpecifierAlreadyDefined = 'property specifier already defined: %s';
|
||||||
|
@ -131,7 +131,7 @@ const
|
|||||||
ctnProcedureType,ctnSetType,ctnRangeType,ctnEnumerationType,
|
ctnProcedureType,ctnSetType,ctnRangeType,ctnEnumerationType,
|
||||||
ctnEnumIdentifier,ctnLabelType,ctnTypeType,ctnFileType,ctnPointerType,
|
ctnEnumIdentifier,ctnLabelType,ctnTypeType,ctnFileType,ctnPointerType,
|
||||||
ctnClassOfType,ctnVariantType];
|
ctnClassOfType,ctnVariantType];
|
||||||
AllPasclStatements = [ctnBeginBlock,ctnWithStatement,ctnCaseStatement];
|
AllPascalStatements = [ctnBeginBlock,ctnWithStatement,ctnCaseStatement];
|
||||||
AllSourceTypes =
|
AllSourceTypes =
|
||||||
[ctnProgram,ctnPackage,ctnLibrary,ctnUnit];
|
[ctnProgram,ctnPackage,ctnLibrary,ctnUnit];
|
||||||
AllUsableSourceTypes =
|
AllUsableSourceTypes =
|
||||||
@ -175,6 +175,7 @@ type
|
|||||||
function Prior: TCodeTreeNode;
|
function Prior: TCodeTreeNode;
|
||||||
function HasAsParent(Node: TCodeTreeNode): boolean;
|
function HasAsParent(Node: TCodeTreeNode): boolean;
|
||||||
function HasParentOfType(ParentDesc: TCodeTreeNodeDesc): boolean;
|
function HasParentOfType(ParentDesc: TCodeTreeNodeDesc): boolean;
|
||||||
|
function GetNodeOfType(ADesc: TCodeTreeNodeDesc): TCodeTreeNode;
|
||||||
function DescAsString: string;
|
function DescAsString: string;
|
||||||
procedure Clear;
|
procedure Clear;
|
||||||
constructor Create;
|
constructor Create;
|
||||||
@ -424,6 +425,14 @@ begin
|
|||||||
Result:=ANode<>nil;
|
Result:=ANode<>nil;
|
||||||
end;
|
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;
|
function TCodeTreeNode.DescAsString: string;
|
||||||
begin
|
begin
|
||||||
Result:=NodeDescriptionAsString(Desc);
|
Result:=NodeDescriptionAsString(Desc);
|
||||||
|
@ -127,7 +127,7 @@ type
|
|||||||
function IsPCharInSrc(ACleanPos: PChar): boolean;
|
function IsPCharInSrc(ACleanPos: PChar): boolean;
|
||||||
function ReadTilSection(SectionType: TCodeTreeNodeDesc): boolean;
|
function ReadTilSection(SectionType: TCodeTreeNodeDesc): boolean;
|
||||||
function ReadTilBracketClose(ExceptionOnNotFound: boolean): boolean;
|
function ReadTilBracketClose(ExceptionOnNotFound: boolean): boolean;
|
||||||
function ReadBackTilBracketClose(ExceptionOnNotFound: boolean): boolean;
|
function ReadBackTilBracketOpen(ExceptionOnNotFound: boolean): boolean;
|
||||||
function DoAtom: boolean; virtual;
|
function DoAtom: boolean; virtual;
|
||||||
procedure ReadNextAtom;
|
procedure ReadNextAtom;
|
||||||
procedure UndoReadNextAtom;
|
procedure UndoReadNextAtom;
|
||||||
@ -1156,7 +1156,7 @@ begin
|
|||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomCodeTool.ReadBackTilBracketClose(
|
function TCustomCodeTool.ReadBackTilBracketOpen(
|
||||||
ExceptionOnNotFound: boolean): boolean;
|
ExceptionOnNotFound: boolean): boolean;
|
||||||
// reads code brackets (not comment brackets)
|
// reads code brackets (not comment brackets)
|
||||||
var CloseBracket, AntiCloseBracket: char;
|
var CloseBracket, AntiCloseBracket: char;
|
||||||
@ -1186,7 +1186,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if (AtomIsChar(')')) or (AtomIsChar(']')) then begin
|
if (AtomIsChar(')')) or (AtomIsChar(']')) then begin
|
||||||
if not ReadBackTilBracketClose(ExceptionOnNotFound) then exit;
|
if not ReadBackTilBracketOpen(ExceptionOnNotFound) then exit;
|
||||||
end;
|
end;
|
||||||
until false;
|
until false;
|
||||||
Result:=true;
|
Result:=true;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -806,6 +806,8 @@ function TPascalParserTool.KeyWordFuncClassVarTypeSet: boolean;
|
|||||||
set of (MyEnummy4 := 4 , MyEnummy5);
|
set of (MyEnummy4 := 4 , MyEnummy5);
|
||||||
}
|
}
|
||||||
begin
|
begin
|
||||||
|
CreateChildNode;
|
||||||
|
CurNode.Desc:=ctnSetType;
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
if not UpAtomIs('OF') then
|
if not UpAtomIs('OF') then
|
||||||
SaveRaiseExceptionFmt(ctsStrExpectedButAtomFound,['"of"',GetAtom]);
|
SaveRaiseExceptionFmt(ctsStrExpectedButAtomFound,['"of"',GetAtom]);
|
||||||
@ -817,6 +819,8 @@ begin
|
|||||||
else if AtomIsChar('(') then
|
else if AtomIsChar('(') then
|
||||||
// set of ()
|
// set of ()
|
||||||
ReadTilBracketClose(true);
|
ReadTilBracketClose(true);
|
||||||
|
CurNode.EndPos:=CurPos.EndPos;
|
||||||
|
EndChildNode;
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -3449,7 +3453,7 @@ begin
|
|||||||
RaiseLastError;
|
RaiseLastError;
|
||||||
// check if cursor is in interface
|
// check if cursor is in interface
|
||||||
Dummy:=CaretToCleanPos(CursorPos, CleanCursorPos);
|
Dummy:=CaretToCleanPos(CursorPos, CleanCursorPos);
|
||||||
if (Dummy in [0,-1]) then
|
if (Dummy=0) or (Dummy=-1) then
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
BuildTree(TreeRange=trInterface);
|
BuildTree(TreeRange=trInterface);
|
||||||
|
@ -1395,10 +1395,10 @@ begin
|
|||||||
dec(CurPos.StartPos);
|
dec(CurPos.StartPos);
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
Result:=ReadBackTilBracketClose(false);
|
Result:=ReadBackTilBracketOpen(false);
|
||||||
end;
|
end;
|
||||||
end else if OpenBracket=']' then begin
|
end else if OpenBracket=']' then begin
|
||||||
Result:=ReadBackTilBracketClose(false);
|
Result:=ReadBackTilBracketOpen(false);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user