mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-17 04:29:25 +02:00
cody: fixed uninitialized result
git-svn-id: trunk@35302 -
This commit is contained in:
parent
7cf5618863
commit
8e3577e6aa
@ -932,6 +932,7 @@ end;
|
||||
function TCodeCompletionCodeTool.CheckLocalVarForInSyntax(
|
||||
CleanCursorPos: integer; out VarNameAtom, TermAtom: TAtomPosition): boolean;
|
||||
// check for: for VarName in Term do
|
||||
{off $DEFINE VerboseForInCompletion}
|
||||
var
|
||||
InAtomEndPos: LongInt;
|
||||
begin
|
||||
@ -941,20 +942,35 @@ begin
|
||||
// find variable name
|
||||
GetIdentStartEndAtPosition(Src,CleanCursorPos,
|
||||
VarNameAtom.StartPos,VarNameAtom.EndPos);
|
||||
//debugln('TCodeCompletionCodeTool.CheckLocalVarAssignmentSyntax A ',GetAtom(VarNameAtom),' "',copy(Src,CleanCursorPos,10),'"');
|
||||
if VarNameAtom.StartPos=VarNameAtom.EndPos then exit;
|
||||
debugln('TCodeCompletionCodeTool.CheckLocalVarAssignmentSyntax A ',GetAtom(VarNameAtom),' "',copy(Src,CleanCursorPos,10),'"');
|
||||
if VarNameAtom.StartPos=VarNameAtom.EndPos then begin
|
||||
{$IFDEF VerboseForInCompletion}
|
||||
debugln('TCodeCompletionCodeTool.CheckLocalVarAssignmentSyntax no identifier at cursor ',GetAtom(VarNameAtom),' "',copy(Src,CleanCursorPos,10),'"');
|
||||
{$ENDIF}
|
||||
exit;
|
||||
end;
|
||||
MoveCursorToAtomPos(VarNameAtom);
|
||||
if AtomIsKeyWord then exit;
|
||||
|
||||
// find 'in' operator
|
||||
ReadNextAtom;
|
||||
if not UpAtomIs('IN') then exit;
|
||||
if not UpAtomIs('IN') then begin
|
||||
{$IFDEF VerboseForInCompletion}
|
||||
debugln('TCodeCompletionCodeTool.CheckLocalVarAssignmentSyntax no in keyword ',GetAtom(VarNameAtom));
|
||||
{$ENDIF}
|
||||
exit;
|
||||
end;
|
||||
InAtomEndPos:=CurPos.EndPos;
|
||||
|
||||
// find 'for' keyword
|
||||
MoveCursorToCleanPos(VarNameAtom.StartPos);
|
||||
ReadPriorAtom;
|
||||
if not UpAtomIs('FOR') then exit;
|
||||
if not UpAtomIs('FOR') then begin
|
||||
{$IFDEF VerboseForInCompletion}
|
||||
debugln('TCodeCompletionCodeTool.CheckLocalVarAssignmentSyntax no for keyword ',GetAtom);
|
||||
{$ENDIF}
|
||||
exit;
|
||||
end;
|
||||
|
||||
// find term
|
||||
MoveCursorToCleanPos(InAtomEndPos);
|
||||
@ -962,6 +978,9 @@ begin
|
||||
TermAtom.StartPos:=CurPos.StartPos;
|
||||
TermAtom.EndPos:=FindEndOfExpression(TermAtom.StartPos);
|
||||
|
||||
{$IFDEF VerboseForInCompletion}
|
||||
debugln('TCodeCompletionCodeTool.CheckLocalVarAssignmentSyntax term="',GetAtom(TermAtom),'"');
|
||||
{$ENDIF}
|
||||
Result:=TermAtom.EndPos>TermAtom.StartPos;
|
||||
end;
|
||||
|
||||
@ -1889,11 +1908,12 @@ begin
|
||||
DebugLn(' CompleteLocalVariableForIn: B CheckLocalVarForInSyntax ...');
|
||||
{$ENDIF}
|
||||
// check assignment syntax
|
||||
debugln(['TCodeCompletionCodeTool.CompleteLocalVariableForIn AAA1']);
|
||||
if not CheckLocalVarForInSyntax(CleanCursorPos,
|
||||
VarNameAtom,TermAtom)
|
||||
then
|
||||
exit;
|
||||
//DebugLn(['TCodeCompletionCodeTool.CompleteLocalVariableForIn Var=',GetAtom(VarNameAtom),' Term=',GetAtom(TermAtom)]);
|
||||
DebugLn(['TCodeCompletionCodeTool.CompleteLocalVariableForIn Var=',GetAtom(VarNameAtom),' Term=',GetAtom(TermAtom)]);
|
||||
|
||||
// search variable
|
||||
ActivateGlobalWriteLock;
|
||||
|
@ -1223,15 +1223,17 @@ var
|
||||
// returns false to abort
|
||||
var
|
||||
OwnerList: TFPList;
|
||||
AddResult: TModalResult;
|
||||
begin
|
||||
if PkgDependencyAdded then exit;
|
||||
if PkgDependencyAdded then exit(true);
|
||||
PkgDependencyAdded:=true;
|
||||
// add dependency
|
||||
OwnerList:=TFPList.Create;
|
||||
try
|
||||
OwnerList.Add(CurOwner);
|
||||
if PackageEditingInterface.AddDependencyToOwners(OwnerList,Pkg,true)<>mrOK
|
||||
then begin
|
||||
AddResult:=PackageEditingInterface.AddDependencyToOwners(OwnerList,Pkg,true);
|
||||
if AddResult=mrIgnore then exit(true);
|
||||
if AddResult<>mrOk then begin
|
||||
debugln(['TCodyIdentifiersDlg.UseIdentifier checking via AddDependencyToOwners failed for new package "'+NewGroupName+'"']);
|
||||
exit(false);
|
||||
end;
|
||||
@ -1372,7 +1374,7 @@ begin
|
||||
|
||||
debugln(['TCodyIdentifiersDlg.UseIdentifier CurOwner=',DbgSName(CurOwner),' ',NewUnitInPath]);
|
||||
if (CurOwner<>nil) and (not NewUnitInPath) then begin
|
||||
debugln(['TCodyIdentifiersDlg.UseIdentifier not in unit path, connecting ...']);
|
||||
debugln(['TCodyIdentifiersDlg.UseIdentifier not in unit path, connecting pkg="',NewGroupName,'" ...']);
|
||||
if (NewGroupName<>'') and (NewGroupName<>PackageNameFPCSrcDir) then begin
|
||||
// add dependency
|
||||
if not AddDependency then exit;
|
||||
@ -1499,31 +1501,51 @@ var
|
||||
CurUnitName: String;
|
||||
UsesNode: TCodeTreeNode;
|
||||
begin
|
||||
if (CurTool=nil) or (NewUnitFilename='') then exit;
|
||||
if (CurTool=nil) or (NewUnitFilename='') then begin
|
||||
debugln(['TCodyIdentifiersDlg.AddToUsesSection failed: no tool']);
|
||||
exit;
|
||||
end;
|
||||
UpdateTool;
|
||||
if (CurNode=nil) then exit;
|
||||
if (CurNode=nil) then begin
|
||||
debugln(['TCodyIdentifiersDlg.AddToUsesSection failed: no node']);
|
||||
exit;
|
||||
end;
|
||||
|
||||
// check if already in uses section
|
||||
NewUnitName:=ExtractFileNameOnly(NewUnitFilename);
|
||||
if CurTool.IsHiddenUsedUnit(PChar(NewUnitName)) then exit;
|
||||
if CurTool.IsHiddenUsedUnit(PChar(NewUnitName)) then begin
|
||||
debugln(['TCodyIdentifiersDlg.AddToUsesSection "',NewUnitName,'" is hidden used unit']);
|
||||
exit;
|
||||
end;
|
||||
UsesNode:=CurTool.FindMainUsesSection;
|
||||
if (UsesNode<>nil) and (CurTool.FindNameInUsesSection(UsesNode,NewUnitName)<>nil)
|
||||
then exit;
|
||||
then begin
|
||||
debugln(['TCodyIdentifiersDlg.AddToUsesSection "',NewUnitName,'" is already used in main uses section']);
|
||||
exit;
|
||||
end;
|
||||
if CurInImplementation then begin
|
||||
UsesNode:=CurTool.FindImplementationUsesSection;
|
||||
if (UsesNode<>nil) and (CurTool.FindNameInUsesSection(UsesNode,NewUnitName)<>nil)
|
||||
then exit;
|
||||
then begin
|
||||
debugln(['TCodyIdentifiersDlg.AddToUsesSection "',NewUnitName,'" is already used in implementation uses section']);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
// get unit name
|
||||
NewUnitCode:=CodeToolBoss.LoadFile(NewUnitFilename,true,false);
|
||||
if NewUnitCode=nil then exit;
|
||||
if NewUnitCode=nil then begin
|
||||
debugln(['TCodyIdentifiersDlg.AddToUsesSection failed: unable to load file "',NewUnitFilename,'"']);
|
||||
exit;
|
||||
end;
|
||||
NewUnitName:=CodeToolBoss.GetSourceName(NewUnitCode,false);
|
||||
if NewUnitName='' then
|
||||
NewUnitName:=ExtractFileNameOnly(NewUnitFilename);
|
||||
CurUnitName:=ExtractFileNameOnly(CurMainFilename);
|
||||
if CompareDottedIdentifiers(PChar(CurUnitName),PChar(NewUnitName))=0 then
|
||||
if CompareDottedIdentifiers(PChar(CurUnitName),PChar(NewUnitName))=0 then begin
|
||||
debugln(['TCodyIdentifiersDlg.AddToUsesSection same unit']);
|
||||
exit; // is the same unit
|
||||
end;
|
||||
|
||||
if (CurNode.Desc in [ctnUnit,ctnUsesSection]) then begin
|
||||
debugln(['TCodyIdentifiersDlg.AddToUsesSection identifier in uses section, not adding unit to uses section']);
|
||||
|
Loading…
Reference in New Issue
Block a user