codetools: identifier completion: $codepage parameter

git-svn-id: trunk@47806 -
This commit is contained in:
mattias 2015-02-15 15:22:24 +00:00
parent 87c3c117f1
commit 3ea49cce88
2 changed files with 28 additions and 4 deletions

View File

@ -393,7 +393,7 @@ type
const FoundContext: TFindContext): TIdentifierFoundResult; const FoundContext: TFindContext): TIdentifierFoundResult;
procedure AddCollectionContext(Tool: TFindDeclarationTool; procedure AddCollectionContext(Tool: TFindDeclarationTool;
Node: TCodeTreeNode); Node: TCodeTreeNode);
function IsInCompilerDirective(CursorPos: TCodeXYPosition): boolean; function CheckCursorInCompilerDirective(CursorPos: TCodeXYPosition): boolean;
procedure AddCompilerDirectiveMacros(Directive: string); procedure AddCompilerDirectiveMacros(Directive: string);
public public
function GatherAvailableUnitNames(const CursorPos: TCodeXYPosition; function GatherAvailableUnitNames(const CursorPos: TCodeXYPosition;
@ -2076,7 +2076,7 @@ begin
//DebugLn('TIdentCompletionTool.AddCollectionContext ',Node.DescAsString,' ',ExtractNode(Node,[])); //DebugLn('TIdentCompletionTool.AddCollectionContext ',Node.DescAsString,' ',ExtractNode(Node,[]));
end; end;
function TIdentCompletionTool.IsInCompilerDirective(CursorPos: TCodeXYPosition function TIdentCompletionTool.CheckCursorInCompilerDirective(CursorPos: TCodeXYPosition
): boolean; ): boolean;
var var
Line: String; Line: String;
@ -2107,6 +2107,7 @@ begin
or ((CursorPos.X>=InnerStart) and (InnerStart<=length(Line)) or ((CursorPos.X>=InnerStart) and (InnerStart<=length(Line))
and (CursorPos.X<=InnerStart+GetIdentLen(@Line[InnerStart]))) and (CursorPos.X<=InnerStart+GetIdentLen(@Line[InnerStart])))
then begin then begin
// at start of directive
AddKeyWord('Align'); AddKeyWord('Align');
AddKeyWord('AlignAssertions'); AddKeyWord('AlignAssertions');
AddKeyWord('AsmMode'); AddKeyWord('AsmMode');
@ -2189,6 +2190,7 @@ begin
AddKeyWord('WritableConst'); AddKeyWord('WritableConst');
AddKeyWord('ZeroBasedStrings'); AddKeyWord('ZeroBasedStrings');
end else if InnerStart<=length(Line) then begin end else if InnerStart<=length(Line) then begin
// in parameter of directive
Directive:=lowercase(GetIdentifier(@Line[InnerStart])); Directive:=lowercase(GetIdentifier(@Line[InnerStart]));
if (Directive='ifdef') if (Directive='ifdef')
or (Directive='ifndef') or (Directive='ifndef')
@ -2244,6 +2246,28 @@ begin
AddKeyWord('FPCTargetCPU'); AddKeyWord('FPCTargetCPU');
AddKeyWord('FPCVersion'); AddKeyWord('FPCVersion');
AddKeyWord('Time'); AddKeyWord('Time');
end else if (Directive='codepage') then begin
// see fpcsrc/compiler/widestr.pas
AddKeyWord('UTF8');
AddKeyWord('cp1250');
AddKeyWord('cp1251');
AddKeyWord('cp1252');
AddKeyWord('cp1253');
AddKeyWord('cp1254');
AddKeyWord('cp1255');
AddKeyWord('cp1256');
AddKeyWord('cp1257');
AddKeyWord('cp1258');
AddKeyWord('cp437');
AddKeyWord('cp646');
AddKeyWord('cp850');
AddKeyWord('cp852');
AddKeyWord('cp856');
AddKeyWord('cp866');
AddKeyWord('cp874');
AddKeyWord('cp8859_1');
AddKeyWord('cp8859_2');
AddKeyWord('cp8859_5');
end; end;
end; end;
exit; exit;
@ -2430,7 +2454,7 @@ begin
try try
InitCollectIdentifiers(CursorPos,IdentifierList); InitCollectIdentifiers(CursorPos,IdentifierList);
IdentStartXY:=FindIdentifierStartPos(CursorPos); IdentStartXY:=FindIdentifierStartPos(CursorPos);
if IsInCompilerDirective(IdentStartXY) then exit(true); if CheckCursorInCompilerDirective(IdentStartXY) then exit(true);
ParseSourceTillCollectionStart(IdentStartXY,CleanCursorPos,CursorNode, ParseSourceTillCollectionStart(IdentStartXY,CleanCursorPos,CursorNode,
IdentStartPos,IdentEndPos); IdentStartPos,IdentEndPos);

View File

@ -4027,7 +4027,7 @@ begin
// do no write the unit output directory // do no write the unit output directory
// it is not needed because it is the location of the Makefile.compiled // it is not needed because it is the location of the Makefile.compiled
s:=s+' '+SwitchPathDelims(CreateRelativePath(APackage.GetSrcFilename,APackage.Directory),pdsUnix); s:=s+' '+SwitchPathDelims(CreateRelativePath(APackage.GetSrcFilename,APackage.Directory),pdsUnix);
//debugln(['TLazPackageGraph.WriteMakefileCompiled IncPath="',IncPath,'" UnitPath="',UnitPath,'" Custom="',OtherOptions,'"']); debugln(['TLazPackageGraph.WriteMakefileCompiled IncPath="',IncPath,'" UnitPath="',UnitPath,'" Custom="',OtherOptions,'" Makefile.compiled="',TargetCompiledFile,'"']);
XMLConfig.SetValue('Params/Value',s); XMLConfig.SetValue('Params/Value',s);
if XMLConfig.Modified then begin if XMLConfig.Modified then begin
InvalidateFileStateCache; InvalidateFileStateCache;