codetools: fixed CleanPosIsInComment

git-svn-id: trunk@16545 -
This commit is contained in:
mattias 2008-09-11 14:24:36 +00:00
parent e4e3f88979
commit c2a3f47f4d
4 changed files with 11 additions and 3 deletions

View File

@ -1324,6 +1324,7 @@ begin
if (fsfFindMainDeclaration in SearchSmartFlags) if (fsfFindMainDeclaration in SearchSmartFlags)
and CleanPosIsDeclarationIdentifier(CleanCursorPos,CursorNode) and CleanPosIsDeclarationIdentifier(CleanCursorPos,CursorNode)
then begin then begin
//DebugLn(['TFindDeclarationTool.FindDeclaration CleanPosIsDeclarationIdentifier']);
NewTool:=Self; NewTool:=Self;
NewNode:=CursorNode; NewNode:=CursorNode;
CleanCursorPos:=GetIdentStartPosition(Src,CleanCursorPos); CleanCursorPos:=GetIdentStartPosition(Src,CleanCursorPos);
@ -1340,6 +1341,7 @@ begin
and IsIncludeDirectiveAtPos(CleanCursorPos,CleanPosInFront,NewPos.Code) and IsIncludeDirectiveAtPos(CleanCursorPos,CleanPosInFront,NewPos.Code)
then begin then begin
// include directive // include directive
//DebugLn(['TFindDeclarationTool.FindDeclaration IsIncludeDirectiveAtPos']);
NewPos.X:=1; NewPos.X:=1;
NewPos.Y:=1; NewPos.Y:=1;
NewTopLine:=1; NewTopLine:=1;
@ -1357,6 +1359,7 @@ begin
if (not IsDirtySrcValid) if (not IsDirtySrcValid)
and (CursorNode.Desc=ctnUsesSection) then begin and (CursorNode.Desc=ctnUsesSection) then begin
// in uses section // in uses section
//DebugLn(['TFindDeclarationTool.FindDeclaration IsUsesSection']);
Result:=FindDeclarationInUsesSection(CursorNode,CleanCursorPos, Result:=FindDeclarationInUsesSection(CursorNode,CleanCursorPos,
NewPos,NewTopLine); NewPos,NewTopLine);
NewNode:=nil; NewNode:=nil;
@ -2027,8 +2030,10 @@ begin
SrcLink:=Scanner.Links[LinkIndex+1]; SrcLink:=Scanner.Links[LinkIndex+1];
if (SrcLink.Code=nil) or (SrcLink.Code=Scanner.Links[LinkIndex].Code) then if (SrcLink.Code=nil) or (SrcLink.Code=Scanner.Links[LinkIndex].Code) then
exit; exit;
//DebugLn(['TFindDeclarationTool.IsIncludeDirectiveAtPos CleanPos=',CleanPos,' CleanCodePosInFront=',CleanCodePosInFront,' ',copy(Src,CleanCodePosInFront,10)]);
if CleanPosIsInComment(CleanPos,CleanCodePosInFront,CommentStart,CommentEnd) if CleanPosIsInComment(CleanPos,CleanCodePosInFront,CommentStart,CommentEnd)
and (CommentEnd=SrcLink.CleanedPos) then begin and (CommentEnd=SrcLink.CleanedPos) then begin
//DebugLn(['TFindDeclarationTool.IsIncludeDirectiveAtPos CommentStart=',CommentStart,' CommentEnd=',CommentEnd,' ',copy(Src,CommentStart,CommentEnd-CommentStart)]);
IncludeCode:=TCodeBuffer(SrcLink.Code); IncludeCode:=TCodeBuffer(SrcLink.Code);
Result:=true; Result:=true;
exit; exit;

View File

@ -189,6 +189,7 @@ begin
repeat repeat
ReadNextAtom; ReadNextAtom;
if CurPos.StartPos>CleanPos then begin if CurPos.StartPos>CleanPos then begin
//DebugLn(['TPascalReaderTool.CleanPosIsInComment ',GetATom,' StartPos=',CurPos.StartPos,' CleanPos=',CleanPos]);
// CleanPos between two atoms -> parse space between for comments // CleanPos between two atoms -> parse space between for comments
CommentStart:=CleanCodePosInFront; CommentStart:=CleanCodePosInFront;
CommentEnd:=CurPos.StartPos; CommentEnd:=CurPos.StartPos;
@ -252,6 +253,8 @@ begin
break; break;
end; end;
end; end;
// CleanPos not in a comment
exit;
end else if CurPos.EndPos>CleanPos then begin end else if CurPos.EndPos>CleanPos then begin
// CleanPos not in a comment // CleanPos not in a comment
exit; exit;

View File

@ -12355,6 +12355,7 @@ begin
writeln('[TMainIDE.DoFindDeclarationAtCaret] ************'); writeln('[TMainIDE.DoFindDeclarationAtCaret] ************');
{$ENDIF} {$ENDIF}
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.DoFindDeclarationAtCaret A');{$ENDIF} {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.DoFindDeclarationAtCaret A');{$ENDIF}
//DebugLn(['TMainIDE.DoFindDeclarationAtCaret LogCaretXY=',dbgs(LogCaretXY),' SynEdit.Log=',dbgs(ActiveSrcEdit.EditorComponent.LogicalCaretXY),' SynEdit.Caret=',dbgs(ActiveSrcEdit.EditorComponent.CaretXY)]);
if CodeToolBoss.FindDeclaration(ActiveUnitInfo.Source, if CodeToolBoss.FindDeclaration(ActiveUnitInfo.Source,
LogCaretXY.X,LogCaretXY.Y, LogCaretXY.X,LogCaretXY.Y,
NewSource,NewX,NewY,NewTopLine) then NewSource,NewX,NewY,NewTopLine) then

View File

@ -750,8 +750,7 @@ type
read FOnAddJumpPoint write FOnAddJumpPoint; read FOnAddJumpPoint write FOnAddJumpPoint;
property OnCloseClicked: TOnCloseSrcEditor property OnCloseClicked: TOnCloseSrcEditor
read FOnCloseClicked write FOnCloseClicked; read FOnCloseClicked write FOnCloseClicked;
property OnClickLink: TMouseEvent property OnClickLink: TMouseEvent read FOnClickLink write FOnClickLink;
read FOnClickLink write FOnClickLink;
property OnDeleteLastJumpPoint: TNotifyEvent property OnDeleteLastJumpPoint: TNotifyEvent
read FOnDeleteLastJumpPoint write FOnDeleteLastJumpPoint; read FOnDeleteLastJumpPoint write FOnDeleteLastJumpPoint;
property OnEditorVisibleChanged: TNotifyEvent property OnEditorVisibleChanged: TNotifyEvent
@ -2667,7 +2666,7 @@ end;
procedure TSourceEditor.EditorClickLink(Sender: TObject; Button: TMouseButton; procedure TSourceEditor.EditorClickLink(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer); Shift: TShiftState; X, Y: Integer);
begin begin
DebugLn(['TSourceEditor.EditorClickLink ']); DebugLn(['TSourceEditor.EditorClickLink ',X,',',Y]);
if Assigned(OnClickLink) then if Assigned(OnClickLink) then
OnClickLink(Sender, Button, Shift, X,Y); OnClickLink(Sender, Button, Shift, X,Y);
end; end;