codetools: completeblock: check if unindented line starts new block

git-svn-id: trunk@26617 -
This commit is contained in:
mattias 2010-07-13 10:06:40 +00:00
parent 6995355e37
commit b23492619f
5 changed files with 28 additions and 16 deletions

View File

@ -661,12 +661,12 @@ type
FChangeStamp: integer;
public
// key
TargetOS: string;
TargetCPU: string;
Compiler: string;
TargetOS: string; // will be passed lowercase
TargetCPU: string; // will be passed lowercase
Compiler: string; // full file name
// values
CompilerDate: longint;
TargetCompiler: string;
TargetCompiler: string; // when Compiler is fpc, this is the real compiler (e.g. ppc386)
TargetCompilerDate: longint;
ConfigFiles: TFPCConfigFileStateList;
UnitPaths: TStrings;
@ -792,8 +792,8 @@ type
procedure Clear;
property Caches: TFPCDefinesCache read FCaches;
property CompilerFilename: string read FCompilerFilename write SetCompilerFilename;
property TargetOS: string read FTargetOS write SetTargetOS;
property TargetCPU: string read FTargetCPU write SetTargetCPU;
property TargetOS: string read FTargetOS write SetTargetOS; // case insensitive, will be passed lowercase
property TargetCPU: string read FTargetCPU write SetTargetCPU; // case insensitive, will be passed lowercase
property FPCSourceDirectory: string read FFPCSourceDirectory write SetFPCSourceDirectory;
function GetConfigCache(AutoUpdate: boolean): TFPCTargetConfigCache;
function GetSourceCache(AutoUpdate: boolean): TFPCSourceCache;
@ -6892,7 +6892,7 @@ begin
Clear;
// run fpc and parse output
if ExtraOptions<>'' then ExtraOptions:=' '+ExtraOptions;
ExtraOptions:='-T'+TargetOS+' -P'+TargetCPU;
ExtraOptions:='-T'+LowerCase(TargetOS)+' -P'+LowerCase(TargetCPU);
RunFPCVerbose(Compiler,TestFilename,CfgFiles,TargetCompiler,UnitPaths,
Defines,Undefines,ExtraOptions);
CompilerDate:=FileAgeCached(Compiler);
@ -7532,7 +7532,17 @@ end;
function TFPCDefinesCache.FindUnitToSrcCache(const CompilerFilename, TargetOS,
TargetCPU, FPCSrcDir: string; CreateIfNotExists: boolean
): TFPCUnitToSrcCache;
var
i: Integer;
begin
for i:=0 to fUnitToSrcCaches.Count-1 do begin
Result:=TFPCUnitToSrcCache(fUnitToSrcCaches[i]);
if (CompareFilenames(Result.CompilerFilename,CompilerFilename)=0)
and (SysUtils.CompareText(Result.TargetOS,TargetOS)=0)
and (SysUtils.CompareText(Result.TargetCPU,TargetCPU)=0)
and (CompareFilenames(Result.FPCSourceDirectory,FPCSrcDir)=0) then
exit;
end;
Result:=nil;
end;

View File

@ -42,7 +42,7 @@ interface
{$I codetools.inc}
{ $DEFINE VerboseGetStringConstBounds}
{$DEFINE ShowCompleteBlock}
{ $DEFINE ShowCompleteBlock}
uses
{$IFDEF MEM_CHECK}
@ -5244,6 +5244,7 @@ var
CursorInEmptyStatement: Boolean;
FromPos: LongInt;
ToPos: LongInt;
WasInCursorBlock: Boolean;
function EndBlockIsOk: boolean;
begin
@ -5326,6 +5327,7 @@ var
InCursorBlock:=(CursorBlockLvl>=0) and (CursorBlockLvl=Stack.Top)
and (not BehindCursorBlock);
WasInCursorBlock:=InCursorBlock;
// check if end of node
if (CurPos.StartPos>SrcLen) or (CurPos.StartPos>=StartNode.EndPos) then
@ -5579,12 +5581,12 @@ var
end;
// check if line start
InCursorBlock:=(CursorBlockLvl>=0) and (CursorBlockLvl=Stack.Top)
and (not BehindCursorBlock);
if LineStart and InCursorBlock then begin
// atom is in same block as cursor (not sub block)
// and first atom of a line
if LineStart and WasInCursorBlock and (not BehindCursorBlock) then begin
// atom is first atom of a line
// and atom is in same block as cursor (not sub block)
// (maybe the atom started a new sub block, but it did not close it)
// => check indent
//debugln(['CompleteStatements ',CleanPosToStr(CurPos.StartPos),' Indent=',Indent,' CursorBlockInnerIndent=',CursorBlockInnerIndent,' CursorBlockOuterIndent=',CursorBlockOuterIndent]);
if (Indent<CursorBlockInnerIndent) and (NeedCompletion=0) then begin
if CursorBlockOuterIndent<CursorBlockInnerIndent then begin
// for example:

View File

@ -2,7 +2,7 @@
This source is only used to compile and install the package.
}
unit lazcontrols;
unit LazControls;
interface

View File

@ -2,7 +2,7 @@
This source is only used to compile and install the package.
}
unit tachartlazaruspkg;
unit TAChartLazarusPkg;
interface

View File

@ -2,7 +2,7 @@
This source is only used to compile and install the package.
}
unit anchordockingdsgn;
unit AnchorDockingDsgn;
interface