From e1dcfde2004b8bd3d6824a54f1dc36f4e73fbf78 Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 18 May 2018 07:31:39 +0000 Subject: [PATCH] codetools: identifier completion: list pas2js default units git-svn-id: trunk@57952 - --- components/codetools/basiccodetools.pas | 6 +- components/codetools/definetemplates.pas | 6 + components/codetools/identcompletiontool.pas | 28 ++-- components/codetools/linkscanner.pas | 138 ++++++++++--------- 4 files changed, 103 insertions(+), 75 deletions(-) diff --git a/components/codetools/basiccodetools.pas b/components/codetools/basiccodetools.pas index 22bcd3fb84..80878ee3a3 100644 --- a/components/codetools/basiccodetools.pas +++ b/components/codetools/basiccodetools.pas @@ -5873,11 +5873,9 @@ begin if not IsDottedIdentifier(UnitName) then exit; FileAndNameSpaceFits(UnitName, FileNameFits, NameSpaceFits); if FileNameFits then - AddToTreeOfUnitFiles(TreeOfUnitFiles,FileName,UnitName, - KeepDoubles); + AddToTreeOfUnitFiles(TreeOfUnitFiles,FileName,UnitName,KeepDoubles); if NameSpaceFits then - AddToTreeOfNamespaces(TreeOfNamespaces,UnitName,NameSpacePath, - KeepDoubles) + AddToTreeOfNamespaces(TreeOfNamespaces,UnitName,NameSpacePath,KeepDoubles) end; function GatherUnitFiles(const BaseDir, SearchPath, Extensions, diff --git a/components/codetools/definetemplates.pas b/components/codetools/definetemplates.pas index c20c6674ae..1578aa5e16 100644 --- a/components/codetools/definetemplates.pas +++ b/components/codetools/definetemplates.pas @@ -9037,6 +9037,7 @@ var InfoTypes: TFPCInfoTypes; BaseDir: String; FullFilename: String; + e: PStringToStringItem; begin OldOptions:=TPCTargetConfigCache.Create(nil); CfgFiles:=nil; @@ -9114,6 +9115,11 @@ begin end; // gather all units and include files in search paths GatherUnitsInSearchPaths(UnitPaths,IncludePaths,OnProgress,Units,Includes,true); + //if Kind=pcPas2js then begin + // debugln(['TPCTargetConfigCache.Update Units:']); + // for e in Units do + // debugln([' ',E^.Name,' ',E^.Value]); + //end; if (UnitPaths.Count=0) then begin if CTConsoleVerbosity>=-1 then debugln(['Warning: [TPCTargetConfigCache.Update] no unit paths: ',Compiler,' ',ExtraOptions]); diff --git a/components/codetools/identcompletiontool.pas b/components/codetools/identcompletiontool.pas index 440d13380d..1613735d0c 100644 --- a/components/codetools/identcompletiontool.pas +++ b/components/codetools/identcompletiontool.pas @@ -43,6 +43,7 @@ interface { $DEFINE ShowFilteredIdents} { $DEFINE ShowHistory} { $DEFINE VerboseCodeContext} +{ $DEFINE VerboseICGatherUnitNames} uses {$IFDEF MEM_CHECK} @@ -1620,21 +1621,30 @@ begin // search in unitpath FIDTTreeOfUnitFiles_CaseInsensitive := true; FIDTTreeOfUnitFiles_NamespacePath := NameSpacePath; - UnitExt:='pp;pas;ppu'; + {$IFDEF VerboseICGatherUnitNames} + FIDTTreeOfUnitFiles:=TAVLTree.Create(@CompareUnitFileInfos); + {$ENDIF} + + UnitExt:=PascalCompilerUnitExt[Scanner.PascalCompiler]; if Scanner.CompilerMode=cmMacPas then UnitExt:=UnitExt+';p'; GatherUnitFiles(BaseDir,UnitPath,UnitExt,NameSpacePath,false,true,FIDTTreeOfUnitFiles, FIDTTreeOfNamespaces); - //debugln(['TIdentCompletionTool.GatherUnitnames UnitPath ',FIDTTreeOfUnitFiles.Count]); + {$IFDEF VerboseICGatherUnitNames} + debugln(['TIdentCompletionTool.GatherUnitnames UnitPath ',FIDTTreeOfUnitFiles.Count]); + {$ENDIF} // search in srcpath - SrcExt:='pp;pas'; + SrcExt:=PascalCompilerSrcExt[Scanner.PascalCompiler]; if Scanner.CompilerMode=cmMacPas then SrcExt:=SrcExt+';p'; GatherUnitFiles(BaseDir,SrcPath,SrcExt,NameSpacePath,false,true,FIDTTreeOfUnitFiles, FIDTTreeOfNamespaces); - //debugln(['TIdentCompletionTool.GatherUnitnames Plus SrcPath ',FIDTTreeOfUnitFiles.Count]); - // add unitlinks - if Scanner.PascalCompiler=pcFPC then - GatherUnitsFromSet; - //debugln(['TIdentCompletionTool.GatherUnitnames Plus FPC units ',FIDTTreeOfUnitFiles.Count]); + {$IFDEF VerboseICGatherUnitNames} + debugln(['TIdentCompletionTool.GatherUnitnames Plus SrcPath ',FIDTTreeOfUnitFiles.Count]); + {$ENDIF} + // add default units + GatherUnitsFromSet; + {$IFDEF VerboseICGatherUnitNames} + debugln(['TIdentCompletionTool.GatherUnitnames Plus FPC units ',FIDTTreeOfUnitFiles.Count]); + {$ENDIF} // create list if FIDTTreeOfUnitFiles<>nil then begin @@ -1652,8 +1662,10 @@ begin 0,nil,nil,ctnUnit, PChar(UnitFileInfo.FileUnitName), UnitFileInfo.IdentifierStartInUnitName); if NewItem.IdentifierStartInUnitName < 1 then NewItem.IdentifierStartInUnitName := 1; + {$IFDEF VerboseICGatherUnitNames} //debugln(['TIdentCompletionTool.GatherUnitnames Add ',UnitFileInfo.FileUnitName,' NewCount=',CurrentIdentifierList]); CurrentIdentifierList.Add(NewItem); + {$ENDIF} end; end; if FIDTTreeOfNamespaces<>nil then diff --git a/components/codetools/linkscanner.pas b/components/codetools/linkscanner.pas index 1b39e50abe..c2231941ab 100644 --- a/components/codetools/linkscanner.pas +++ b/components/codetools/linkscanner.pas @@ -160,6 +160,21 @@ type cmISO, cmExtPas ); +const + // upper case + CompilerModeNames: array[TCompilerMode] of string=( + 'FPC', + 'DELPHI', + 'DELPHIUNICODE', + 'GPC', + 'TP', + 'OBJFPC', + 'MACPAS', + 'ISO', + 'EXTPAS' + ); +type + { TCompilerModeSwitch - see fpc/compiler/globtype.pas tmodeswitch } TCompilerModeSwitch = ( //cms_FPC,cms_ObjFPC,cms_Delphi,cms_TP7,cms_Mac,cms_ISO,cms_ExtPas, @@ -250,6 +265,50 @@ const ); cmAllModesWithGeneric = [cmDELPHI,cmDELPHIUNICODE,cmOBJFPC]; + // upper case (see fpc/compiler/globtype.pas modeswitchstr ) + CompilerModeSwitchNames: array[TCompilerModeSwitch] of string=( + 'POINTERARITHMETICS', + 'CLASS', + 'OBJPAS', + 'RESULT', + 'PCHARTOSTRING', + 'CVAR', + 'NESTEDCOMMENTS', + 'CLASSICPROCVARS', + 'MACPROCVARS', + 'REPEATFORWARD', + 'POINTERTOPROCVAR', + 'AUTODEREF', + 'INITFINAL', + 'ANSISTRINGS', + 'OUT', + 'DEFAULTPARAMETERS', + 'HINTDIRECTIVE', + 'DUPLICATELOCALS', + 'PROPERTIES', + 'ALLOWINLINE', + 'EXCEPTIONS', + 'OBJECTIVEC1', + 'OBJECTIVEC2', + 'NESTEDPROCVARS', + 'NONLOCALGOTO', + 'ADVANCEDRECORDS', + 'ISOUNARYMINUS', + 'SYSTEMCODEPAGE', + 'FINALFIELDS', + 'UNICODESTRINGS', + 'TYPEHELPERS', + 'CBLOCKS', + 'ISOIO', + 'ISOPROGRAMPARAS', + 'ISOMOD', + 'PREFIXEDATTRIBUTES', + 'EXTERNALCLASS', + 'IGNOREATTRIBUTES', + 'IGNOREINTERFACES' + ); + + type // see fpcsrc/compiler/globtype.pas toptimizerswitch TOptimizerSwitch = ( @@ -282,7 +341,22 @@ type pcFPC, pcDelphi, pcPas2js); - +const + // upper case + PascalCompilerNames: array[TPascalCompiler] of string=( + 'FPC', 'DELPHI', 'PAS2JS' + ); + PascalCompilerUnitExt: array[TPascalCompiler] of string = ( + 'pp;pas;ppu', // + p if TCompilerMode=cmMacPas + 'pas;dcu', + 'pas;pp;pcu;pju' + ); + PascalCompilerSrcExt: array[TPascalCompiler] of string = ( + 'pp;pas', // + p if TCompilerMode=cmMacPas + 'pas', + 'pas;pp' + ); + type TLSSkippingDirective = ( lssdNone, @@ -780,68 +854,6 @@ type function NewPSourceChangeStep: PSourceChangeStep; end; -const - // upper case - CompilerModeNames: array[TCompilerMode] of string=( - 'FPC', - 'DELPHI', - 'DELPHIUNICODE', - 'GPC', - 'TP', - 'OBJFPC', - 'MACPAS', - 'ISO', - 'EXTPAS' - ); - - // upper case (see fpc/compiler/globtype.pas modeswitchstr ) - CompilerModeSwitchNames: array[TCompilerModeSwitch] of string=( - 'POINTERARITHMETICS', - 'CLASS', - 'OBJPAS', - 'RESULT', - 'PCHARTOSTRING', - 'CVAR', - 'NESTEDCOMMENTS', - 'CLASSICPROCVARS', - 'MACPROCVARS', - 'REPEATFORWARD', - 'POINTERTOPROCVAR', - 'AUTODEREF', - 'INITFINAL', - 'ANSISTRINGS', - 'OUT', - 'DEFAULTPARAMETERS', - 'HINTDIRECTIVE', - 'DUPLICATELOCALS', - 'PROPERTIES', - 'ALLOWINLINE', - 'EXCEPTIONS', - 'OBJECTIVEC1', - 'OBJECTIVEC2', - 'NESTEDPROCVARS', - 'NONLOCALGOTO', - 'ADVANCEDRECORDS', - 'ISOUNARYMINUS', - 'SYSTEMCODEPAGE', - 'FINALFIELDS', - 'UNICODESTRINGS', - 'TYPEHELPERS', - 'CBLOCKS', - 'ISOIO', - 'ISOPROGRAMPARAS', - 'ISOMOD', - 'PREFIXEDATTRIBUTES', - 'EXTERNALCLASS', - 'IGNOREATTRIBUTES', - 'IGNOREINTERFACES' - ); - - // upper case - PascalCompilerNames: array[TPascalCompiler] of string=( - 'FPC', 'DELPHI', 'PAS2JS' - ); - const DirectiveSequenceName: array [TSequenceDirective] of string = ('SCOPEDENUMS');