From fa3cda85f50db026817f128cdc85156afa24c3ea Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 23 Jan 2006 10:37:40 +0000 Subject: [PATCH] added debugging for clipboard git-svn-id: trunk@8603 - --- components/codetools/codecompletiontool.pas | 11 +++++++++-- components/codetools/customcodetool.pas | 4 ++-- components/codetools/finddeclarationtool.pas | 13 ++++++++++++- lcl/interfaces/gtk/gtkproc.inc | 2 +- lcl/interfaces/gtk/gtkwinapi.inc | 4 +++- packager/pkgmanager.pas | 1 - 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/components/codetools/codecompletiontool.pas b/components/codetools/codecompletiontool.pas index dc2836a7f9..5dc81995a3 100644 --- a/components/codetools/codecompletiontool.pas +++ b/components/codetools/codecompletiontool.pas @@ -866,6 +866,7 @@ var ParameterNode: TCodeTreeNode; TypeNode: TCodeTreeNode; NewType: String; + IgnorePos: TCodePosition; begin Result:=false; @@ -915,7 +916,13 @@ begin Params.SetIdentifier(Self,@Src[ProcNameAtom.StartPos],nil); Params.Flags:=fdfGlobals+[fdfSearchInParentNodes,fdfSearchInAncestors, fdfFindVariable,fdfIgnoreCurContextNode]; - if not FindIdentifierInContext(Params) then exit; + CleanPosToCodePos(VarNameAtom.StartPos,IgnorePos); + IgnoreErrorAfter:=IgnorePos; + try + if not FindDeclarationOfIdentAtCursor(Params) then exit; + finally + ClearIgnoreErrorAfter; + end; NewType:=''; if Params.NewNode<>nil then begin ParameterNode:=Params.NewCodeTool.FindNthParameterNode(Params.NewNode, @@ -938,7 +945,7 @@ begin end; //DebugLn(' CompleteLocalVariableAsParameter Dont know: ',Params.NewNode.DescAsString); end; - + if NewType='' then begin exit; end; diff --git a/components/codetools/customcodetool.pas b/components/codetools/customcodetool.pas index 5be10cbc2c..1b127c8f15 100644 --- a/components/codetools/customcodetool.pas +++ b/components/codetools/customcodetool.pas @@ -194,7 +194,7 @@ type // 1=CursorPos beyond scanned code //-2=X,Y beyond source function CleanPosToCodePos(CleanPos: integer; - var CodePos:TCodePosition): boolean; // true=ok, false=invalid CleanPos + out CodePos:TCodePosition): boolean; // true=ok, false=invalid CleanPos function CleanPosToCaret(CleanPos: integer; var Caret:TCodeXYPosition): boolean; // true=ok, false=invalid CleanPos function CleanPosToCaretAndTopLine(CleanPos: integer; @@ -2045,7 +2045,7 @@ begin end; function TCustomCodeTool.CleanPosToCodePos(CleanPos: integer; - var CodePos: TCodePosition): boolean; + out CodePos: TCodePosition): boolean; var ACode: pointer; begin diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index 0b6a7dada6..75430d4ddb 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -6630,7 +6630,9 @@ function TFindDeclarationTool.CreateParamExprListFromStatement( var ExprType: TExpressionType; BracketClose: char; ExprStartPos, ExprEndPos: integer; - + CurIgnoreErrorAfterPos: Integer; + OldFlags: TFindDeclarationFlags; + procedure RaiseBracketNotFound; begin RaiseExceptionFmt(ctsStrExpectedButAtomFound,[BracketClose,GetAtom]); @@ -6650,6 +6652,11 @@ begin BracketClose:=']' else BracketClose:=#0; + if IgnoreErrorAfterValid then + CurIgnoreErrorAfterPos:=IgnoreErrorAfterCleanedPos + else + CurIgnoreErrorAfterPos:=-1; + OldFlags:=Params.Flags; if BracketClose<>#0 then begin // read parameter list ReadNextAtom; @@ -6670,6 +6677,9 @@ begin until false; ExprEndPos:=CurPos.StartPos; // find expression type + if (CurIgnoreErrorAfterPos>=ExprStartPos) then + Params.Flags:=Params.Flags-[fdfExceptionOnNotFound]; + //DebugLn('TFindDeclarationTool.CreateParamExprListFromStatement CurIgnoreErrorAfterPos=',dbgs(CurIgnoreErrorAfterPos),' ExprStartPos=',dbgs(ExprStartPos)); ExprType:=FindExpressionResultType(Params,ExprStartPos,ExprEndPos); // add expression type to list Result.Add(ExprType); @@ -6682,6 +6692,7 @@ begin end; end; end; + Params.Flags:=OldFlags; {$IFDEF ShowExprEval} DebugLn('[TFindDeclarationTool.CreateParamExprListFromStatement] END ', 'ParamCount=',dbgs(Result.Count),' "',copy(Src,StartPos,40),'"'); diff --git a/lcl/interfaces/gtk/gtkproc.inc b/lcl/interfaces/gtk/gtkproc.inc index 190b10509a..f9baa877d1 100644 --- a/lcl/interfaces/gtk/gtkproc.inc +++ b/lcl/interfaces/gtk/gtkproc.inc @@ -6468,7 +6468,7 @@ begin FillChar(Result,SizeOf(TGtkSelectionData),0); if (ClipboardWidget=nil) or (FormatID=0) or (ClipboardTypeAtoms[ClipboardType]=0) then exit; - + TimeID:=1000; repeat repeat diff --git a/lcl/interfaces/gtk/gtkwinapi.inc b/lcl/interfaces/gtk/gtkwinapi.inc index b7d9f6bae6..bbfb45f9d6 100644 --- a/lcl/interfaces/gtk/gtkwinapi.inc +++ b/lcl/interfaces/gtk/gtkwinapi.inc @@ -296,6 +296,7 @@ var FormatAtom, FormatTry: Cardinal; var a: integer; AllID: cardinal; begin + //DebugLn('IsFormatSupported Format=',dbgs(Format),' SupportedCnt=',dbgs(SupportedCnt)); if Format=0 then begin Result:=false; exit; @@ -307,7 +308,7 @@ var FormatAtom, FormatTry: Cardinal; {DebugLn('IsFormatSupported A ',Dbgs(SelData.Selection), ' ',HexStr(Cardinal(ClipboardTypeAtoms[ClipboardType]),8), ' SelData.Target='+dbgs(SelData.Target),' AllID='+dbgs(AllID), - ' SelData.TheType='+dbgs(SelData.TheType),' '+dbgs(gdk_atom_intern('ATOM',0)), + ' SelData.TheType='+dbgs(SelData.TheType)+' ATOM='+dbgs(gdk_atom_intern('ATOM',0))+' Name="'+gdk_atom_name(SelData.TheType)+'"', ' SelData.Length='+dbgs(SelData.Length), ' SelData.Format='+dbgs(SelData.Format) );} @@ -319,6 +320,7 @@ var FormatAtom, FormatTry: Cardinal; end; SupportedCnt:=SelData.Length div (SelData.Format shr 3); SupportedFormats:=PGdkAtom(SelData.Data); + //DebugLn('IsFormatSupported SupportedCnt=',dbgs(SupportedCnt)); {a:=SupportedCnt-1; while (a>=0) do begin diff --git a/packager/pkgmanager.pas b/packager/pkgmanager.pas index 6ba24480d8..bd0ca7cbb3 100644 --- a/packager/pkgmanager.pas +++ b/packager/pkgmanager.pas @@ -2146,7 +2146,6 @@ end; procedure TPkgManager.AddUnitToProjectMainUsesSection(AProject: TProject; const AnUnitName, AnUnitInFilename: string); begin - DumpStack; // add unit to project main source file if (pfMainUnitHasUsesSectionForAllUnits in AProject.Flags) and (AProject.MainUnitInfo<>nil) then begin