refactored the symbol expander as an ICESingleService

This commit is contained in:
Basile Burg 2016-03-21 20:51:10 +01:00
parent 51f653267c
commit 5ad5e406de
10 changed files with 129 additions and 84 deletions

View File

@ -5,8 +5,8 @@ unit ce_dmdwrap;
interface interface
uses uses
classes, sysutils, process, asyncprocess, ce_common, classes, sysutils, process, asyncprocess,
ce_processes, ce_interfaces; ce_common, ce_processes, ce_interfaces;
(* (*
@ -29,9 +29,11 @@ type
fOnChange: TNotifyEvent; fOnChange: TNotifyEvent;
procedure doChanged; procedure doChanged;
protected protected
fSymStringExpander: ICESymStringExpander;
property onChange: TNotifyEvent read fOnChange write fOnChange; property onChange: TNotifyEvent read fOnChange write fOnChange;
public public
procedure getOpts(aList: TStrings; base: TOptsGroup = nil); virtual; abstract; procedure getOpts(aList: TStrings; base: TOptsGroup = nil); virtual; abstract;
constructor create; virtual;
end; end;
(***************************************************************************** (*****************************************************************************
@ -94,7 +96,7 @@ type
property showHiddenAlloc: boolean read fVgc write setVgc default false; property showHiddenAlloc: boolean read fVgc write setVgc default false;
property showColumnsNumber: boolean read fCol write setCol default false; property showColumnsNumber: boolean read fCol write setCol default false;
public public
constructor create; constructor create; override;
procedure assign(aValue: TPersistent); override; procedure assign(aValue: TPersistent); override;
procedure getOpts(aList: TStrings; base: TOptsGroup = nil); override; procedure getOpts(aList: TStrings; base: TOptsGroup = nil); override;
end; end;
@ -156,7 +158,7 @@ type
//TODO-cmaintenace: remove deprecated props after next rlz //TODO-cmaintenace: remove deprecated props after next rlz
property generateStackFrame: boolean write setGenStack stored false; deprecated; property generateStackFrame: boolean write setGenStack stored false; deprecated;
public public
constructor create; constructor create; override;
destructor destroy; override; destructor destroy; override;
procedure assign(aValue: TPersistent); override; procedure assign(aValue: TPersistent); override;
procedure getOpts(aList: TStrings; base: TOptsGroup = nil); override; procedure getOpts(aList: TStrings; base: TOptsGroup = nil); override;
@ -195,7 +197,7 @@ type
property codeviewDexts: boolean write setGenInfos stored false; deprecated; property codeviewDexts: boolean write setGenInfos stored false; deprecated;
property codeviewCformat: boolean write setDbgC stored false; deprecated; property codeviewCformat: boolean write setDbgC stored false; deprecated;
public public
constructor create; constructor create; override;
destructor destroy; override; destructor destroy; override;
procedure assign(aValue: TPersistent); override; procedure assign(aValue: TPersistent); override;
procedure getOpts(aList: TStrings;base: TOptsGroup = nil); override; procedure getOpts(aList: TStrings;base: TOptsGroup = nil); override;
@ -230,7 +232,7 @@ type
property importStringPaths: TStringList read fImpStr write setImpt; property importStringPaths: TStringList read fImpStr write setImpt;
property forceExtension: boolean read fForceExt write setForceExt default false; property forceExtension: boolean read fForceExt write setForceExt default false;
public public
constructor create; constructor create; override;
destructor destroy; override; destructor destroy; override;
procedure assign(aValue: TPersistent); override; procedure assign(aValue: TPersistent); override;
procedure getOpts(aList: TStrings; base: TOptsGroup = nil); override; procedure getOpts(aList: TStrings; base: TOptsGroup = nil); override;
@ -249,7 +251,7 @@ type
property coverage: boolean read fCov write setCov default false; property coverage: boolean read fCov write setCov default false;
property customOptions: TStringList read fCustom write setCustom; property customOptions: TStringList read fCustom write setCustom;
public public
constructor create; constructor create; override;
destructor destroy; override; destructor destroy; override;
procedure assign(aValue: TPersistent); override; procedure assign(aValue: TPersistent); override;
procedure getOpts(aList: TStrings; base: TOptsGroup = nil); override; procedure getOpts(aList: TStrings; base: TOptsGroup = nil); override;
@ -281,7 +283,7 @@ type
property showWindow: TShowWindowOptions read fShowWin write setShowWin default swoNone; property showWindow: TShowWindowOptions read fShowWin write setShowWin default swoNone;
property simpleCommands: TStringList read fCommands write setCommands; property simpleCommands: TStringList read fCommands write setCommands;
public public
constructor create; constructor create; override;
destructor destroy; override; destructor destroy; override;
procedure assign(source: TPersistent); override; procedure assign(source: TPersistent); override;
procedure getOpts(aList: TStrings; base: TOptsGroup = nil); override; procedure getOpts(aList: TStrings; base: TOptsGroup = nil); override;
@ -324,6 +326,7 @@ type
*) *)
TCompilerConfiguration = class(TCollectionItem) TCompilerConfiguration = class(TCollectionItem)
private private
fSymStringExpander: ICESymStringExpander;
fName: string; fName: string;
fOnChanged: TNotifyEvent; fOnChanged: TNotifyEvent;
fDocOpts: TDocOpts; fDocOpts: TDocOpts;
@ -376,8 +379,10 @@ type
implementation implementation
uses constructor TOptsGroup.create;
ce_symstring; begin
fSymStringExpander := getSymStringExpander;
end;
procedure TOptsGroup.doChanged; procedure TOptsGroup.doChanged;
begin begin
@ -396,9 +401,9 @@ begin
if fGenJson then if fGenJson then
aList.Add('-X'); aList.Add('-X');
if fDocDir <> '' then if fDocDir <> '' then
aList.Add('-Dd' + symbolExpander.get(fDocDir)); aList.Add('-Dd' + fSymStringExpander.expand(fDocDir));
if fJsonFname <> '' then if fJsonFname <> '' then
aList.Add('-Xf' + symbolExpander.get(fJsonFname)); aList.Add('-Xf' + fSymStringExpander.expand(fJsonFname));
end else end else
begin begin
baseopt := TDocOpts(base); baseopt := TDocOpts(base);
@ -407,17 +412,17 @@ begin
if baseopt.fGenJson or fGenJson then if baseopt.fGenJson or fGenJson then
aList.Add('-X'); aList.Add('-X');
if (baseopt.fDocDir <> '') and (fDocDir <> '') then if (baseopt.fDocDir <> '') and (fDocDir <> '') then
aList.Add('-Dd' + symbolExpander.get(fDocDir)) aList.Add('-Dd' + fSymStringExpander.expand(fDocDir))
else if (fDocDir <> '') then else if (fDocDir <> '') then
aList.Add('-Dd' + symbolExpander.get(fDocDir)) aList.Add('-Dd' + fSymStringExpander.expand(fDocDir))
else if (baseopt.fDocDir <> '') then else if (baseopt.fDocDir <> '') then
aList.Add('-Dd' + symbolExpander.get(baseopt.fDocDir)); aList.Add('-Dd' + fSymStringExpander.expand(baseopt.fDocDir));
if (baseopt.fJsonFname <> '') and (fJsonFname <> '') then if (baseopt.fJsonFname <> '') and (fJsonFname <> '') then
aList.Add('-Xf' + symbolExpander.get(fJsonFname)) aList.Add('-Xf' + fSymStringExpander.expand(fJsonFname))
else if fJsonFname <> '' then else if fJsonFname <> '' then
aList.Add('-Xf' + symbolExpander.get(fJsonFname)) aList.Add('-Xf' + fSymStringExpander.expand(fJsonFname))
else if (baseopt.fJsonFname <> '') then else if (baseopt.fJsonFname <> '') then
aList.Add('-Dd' + symbolExpander.get(baseopt.fJsonFname)); aList.Add('-Dd' + fSymStringExpander.expand(baseopt.fJsonFname));
end; end;
end; end;
@ -489,6 +494,7 @@ end;
{$REGION TMsgOpts --------------------------------------------------------------} {$REGION TMsgOpts --------------------------------------------------------------}
constructor TMsgOpts.create; constructor TMsgOpts.create;
begin begin
inherited;
fDepHandling := TDepHandling.warning; fDepHandling := TDepHandling.warning;
fWarnings := true; fWarnings := true;
end; end;
@ -607,6 +613,7 @@ end;
{$REGION TOutputOpts -----------------------------------------------------------} {$REGION TOutputOpts -----------------------------------------------------------}
constructor TOutputOpts.create; constructor TOutputOpts.create;
begin begin
inherited;
fVerIds := TStringList.Create; fVerIds := TStringList.Create;
fBoundsCheck := safeOnly; fBoundsCheck := safeOnly;
end; end;
@ -816,6 +823,7 @@ end;
{$REGION TDebugOpts ------------------------------------------------------------} {$REGION TDebugOpts ------------------------------------------------------------}
constructor TDebugOpts.create; constructor TDebugOpts.create;
begin begin
inherited;
fDbgIdents := TStringList.Create; fDbgIdents := TStringList.Create;
end; end;
@ -944,6 +952,7 @@ end;
{$REGION TPathsOpts ------------------------------------------------------------} {$REGION TPathsOpts ------------------------------------------------------------}
constructor TPathsOpts.create; constructor TPathsOpts.create;
begin begin
inherited;
fExtraSrcs := TStringList.Create; fExtraSrcs := TStringList.Create;
fImpMod := TStringList.Create; fImpMod := TStringList.Create;
fImpStr := TStringList.Create; fImpStr := TStringList.Create;
@ -979,7 +988,7 @@ begin
begin begin
if isStringDisabled(str) then if isStringDisabled(str) then
continue; continue;
sym := symbolExpander.get(str); sym := fSymStringExpander.expand(str);
if not listAsteriskPath(sym, aList, exts) then if not listAsteriskPath(sym, aList, exts) then
aList.Add(sym); aList.Add(sym);
end; end;
@ -987,13 +996,13 @@ begin
exts.Free; exts.Free;
end; end;
for str in fImpMod do if not isStringDisabled(str) then for str in fImpMod do if not isStringDisabled(str) then
aList.Add('-I'+ symbolExpander.get(str)); aList.Add('-I'+ fSymStringExpander.expand(str));
for str in fImpStr do if not isStringDisabled(str) then for str in fImpStr do if not isStringDisabled(str) then
aList.Add('-J'+ symbolExpander.get(str)); aList.Add('-J'+ fSymStringExpander.expand(str));
if fFname <> '' then if fFname <> '' then
aList.Add('-of' + symbolExpander.get(fFname)); aList.Add('-of' + fSymStringExpander.expand(fFname));
if fObjDir <> '' then if fObjDir <> '' then
aList.Add('-od' + symbolExpander.get(fObjDir)); aList.Add('-od' + fSymStringExpander.expand(fObjDir));
end else end else
begin begin
baseopt := TPathsOpts(base); baseopt := TPathsOpts(base);
@ -1006,7 +1015,7 @@ begin
begin begin
if isStringDisabled(str) then if isStringDisabled(str) then
continue; continue;
sym := symbolExpander.get(str); sym := fSymStringExpander.expand(str);
if not listAsteriskPath(sym, aList, exts) then if not listAsteriskPath(sym, aList, exts) then
aList.Add(sym); aList.Add(sym);
end; end;
@ -1017,22 +1026,22 @@ begin
if fImpMod.Count = 0 then rightList := baseopt.fImpMod if fImpMod.Count = 0 then rightList := baseopt.fImpMod
else rightList := fImpMod; else rightList := fImpMod;
for str in rightList do if not isStringDisabled(str) then for str in rightList do if not isStringDisabled(str) then
aList.Add('-I'+ symbolExpander.get(str)); aList.Add('-I'+ fSymStringExpander.expand(str));
// //
if fImpStr.Count = 0 then rightList := baseopt.fImpStr if fImpStr.Count = 0 then rightList := baseopt.fImpStr
else rightList := fImpStr; else rightList := fImpStr;
for str in rightList do if not isStringDisabled(str) then for str in rightList do if not isStringDisabled(str) then
aList.Add('-J'+ symbolExpander.get(str)); aList.Add('-J'+ fSymStringExpander.expand(str));
// //
str := ''; str := '';
if fFname <> '' then str := fFname else if fFname <> '' then str := fFname else
if baseopt.fFname <> '' then str := baseopt.fFname; if baseopt.fFname <> '' then str := baseopt.fFname;
if str.isNotEmpty then aList.Add('-of' + symbolExpander.get(str)); if str.isNotEmpty then aList.Add('-of' + fSymStringExpander.expand(str));
// //
str := ''; str := '';
if fObjDir <> '' then str := fObjDir else if fObjDir <> '' then str := fObjDir else
if baseopt.fObjDir <> '' then str := baseopt.fObjDir; if baseopt.fObjDir <> '' then str := baseopt.fObjDir;
if str.isNotEmpty then aList.Add('-od' + symbolExpander.get(str)); if str.isNotEmpty then aList.Add('-od' + fSymStringExpander.expand(str));
end; end;
end; end;
@ -1118,6 +1127,7 @@ end;
{$REGION TOtherOpts ------------------------------------------------------------} {$REGION TOtherOpts ------------------------------------------------------------}
constructor TOtherOpts.create; constructor TOtherOpts.create;
begin begin
inherited;
fCustom := TStringList.Create; fCustom := TStringList.Create;
end; end;
@ -1163,7 +1173,7 @@ begin
str2 := '-' + str1 str2 := '-' + str1
else else
str2 := str1; str2 := str1;
aList.AddText(symbolExpander.get(str2)); aList.AddText(fSymStringExpander.expand(str2));
end; end;
if fCov then aList.Add('-cov'); if fCov then aList.Add('-cov');
end else end else
@ -1179,7 +1189,7 @@ begin
str2 := '-' + str1 str2 := '-' + str1
else else
str2 := str1; str2 := str1;
aList.AddText(symbolExpander.get(str2)); aList.AddText(fSymStringExpander.expand(str2));
end; end;
if baseopt.fCov or fCov then aList.Add('-cov'); if baseopt.fCov or fCov then aList.Add('-cov');
end; end;
@ -1195,6 +1205,7 @@ end;
{$REGION TCustomProcOptions ----------------------------------------------------} {$REGION TCustomProcOptions ----------------------------------------------------}
constructor TCustomProcOptions.create; constructor TCustomProcOptions.create;
begin begin
inherited;
fParameters := TStringList.Create; fParameters := TStringList.Create;
fCommands := TStringList.Create; fCommands := TStringList.Create;
end; end;
@ -1230,7 +1241,7 @@ procedure TCustomProcOptions.setProcess(var aProcess: TProcess);
begin begin
//TODO-cNativeProjects: adapt TCustomProcOptions.setProcess to base/override system //TODO-cNativeProjects: adapt TCustomProcOptions.setProcess to base/override system
aProcess.Parameters.Clear; aProcess.Parameters.Clear;
aProcess.Parameters.AddText(symbolExpander.get(Parameters.Text)); aProcess.Parameters.AddText(fSymStringExpander.expand(Parameters.Text));
aProcess.Executable := fExecutable; aProcess.Executable := fExecutable;
aProcess.ShowWindow := fShowWin; aProcess.ShowWindow := fShowWin;
aProcess.Options := fOptions; aProcess.Options := fOptions;
@ -1241,7 +1252,7 @@ end;
procedure TCustomProcOptions.setProcess(var aProcess: TAsyncProcess); procedure TCustomProcOptions.setProcess(var aProcess: TAsyncProcess);
begin begin
aProcess.Parameters.Clear; aProcess.Parameters.Clear;
aProcess.Parameters.AddText(symbolExpander.get(Parameters.Text)); aProcess.Parameters.AddText(fSymStringExpander.expand(Parameters.Text));
aProcess.Executable := fExecutable; aProcess.Executable := fExecutable;
aProcess.ShowWindow := fShowWin; aProcess.ShowWindow := fShowWin;
aProcess.Options := fOptions; aProcess.Options := fOptions;
@ -1252,7 +1263,7 @@ end;
procedure TCustomProcOptions.setProcess(var aProcess: TCheckedAsyncProcess); procedure TCustomProcOptions.setProcess(var aProcess: TCheckedAsyncProcess);
begin begin
aProcess.Parameters.Clear; aProcess.Parameters.Clear;
aProcess.Parameters.AddText(symbolExpander.get(Parameters.Text)); aProcess.Parameters.AddText(fSymStringExpander.expand(Parameters.Text));
aProcess.Executable := fExecutable; aProcess.Executable := fExecutable;
aProcess.ShowWindow := fShowWin; aProcess.ShowWindow := fShowWin;
aProcess.Options := fOptions; aProcess.Options := fOptions;
@ -1263,7 +1274,7 @@ end;
procedure TCustomProcOptions.setProcess(var aProcess: TCEProcess); procedure TCustomProcOptions.setProcess(var aProcess: TCEProcess);
begin begin
aProcess.Parameters.Clear; aProcess.Parameters.Clear;
aProcess.Parameters.AddText(symbolExpander.get(Parameters.Text)); aProcess.Parameters.AddText(fSymStringExpander.expand(Parameters.Text));
aProcess.Executable := fExecutable; aProcess.Executable := fExecutable;
aProcess.ShowWindow := fShowWin; aProcess.ShowWindow := fShowWin;
aProcess.Options := fOptions; aProcess.Options := fOptions;
@ -1317,6 +1328,8 @@ constructor TCompilerConfiguration.create(aCollection: TCollection);
begin begin
inherited create(aCollection); inherited create(aCollection);
fSymStringExpander:= getSymStringExpander;
fDocOpts := TDocOpts.create; fDocOpts := TDocOpts.create;
fDebugOpts := TDebugOpts.create; fDebugOpts := TDebugOpts.create;
fMsgOpts := TMsgOpts.create; fMsgOpts := TMsgOpts.create;
@ -1414,7 +1427,7 @@ begin
end; end;
if fe and nme.isNotEmpty then if fe and nme.isNotEmpty then
begin begin
nme := symbolExpander.get(nme); nme := fSymStringExpander.expand(nme);
ext := nme.extractFileExt; ext := nme.extractFileExt;
nme := '-of' + nme; nme := '-of' + nme;
i := aList.IndexOf(nme); i := aList.IndexOf(nme);

View File

@ -293,6 +293,16 @@ type
(**
* Single service related to the expansion of Coedit "symbolic strings".
*)
ICESymStringExpander = interface(ICESingleService)
// expand all the symbols <IDENT> in value in result.
function expand(const value: string): string;
end;
{ {
subject primitives: subject primitives:
@ -323,9 +333,10 @@ type
Service getters: Service getters:
} }
function getMessageDisplay(var obj: ICEMessagesDisplay): ICEMessagesDisplay; function getMessageDisplay(var obj: ICEMessagesDisplay): ICEMessagesDisplay;
function getMessageDisplay: ICEMessagesDisplay; overload; function getMessageDisplay: ICEMessagesDisplay;
function getprocInputHandler: ICEProcInputHandler; overload; function getprocInputHandler: ICEProcInputHandler;
function getMultiDocHandler: ICEMultiDocHandler; overload; function getMultiDocHandler: ICEMultiDocHandler;
function getSymStringExpander: ICESymStringExpander;
implementation implementation
@ -450,6 +461,11 @@ function getMultiDocHandler: ICEMultiDocHandler;
begin begin
exit(EntitiesConnector.getSingleService('ICEMultiDocHandler') as ICEMultiDocHandler); exit(EntitiesConnector.getSingleService('ICEMultiDocHandler') as ICEMultiDocHandler);
end; end;
function getSymStringExpander: ICESymStringExpander;
begin
exit(EntitiesConnector.getSingleService('ICESymStringExpander') as ICESymStringExpander);
end;
{$ENDREGION} {$ENDREGION}
end. end.

View File

@ -200,6 +200,7 @@ type
private private
fSymStringExpander: ICESymStringExpander;
fCovModUt: boolean; fCovModUt: boolean;
fDoc: TCESynMemo; fDoc: TCESynMemo;
fFirstTimeCoedit: boolean; fFirstTimeCoedit: boolean;
@ -427,7 +428,7 @@ implementation
{$R *.lfm} {$R *.lfm}
uses uses
SynMacroRecorder, ce_symstring, ce_dcd; SynMacroRecorder, ce_dcd;
{$REGION TCEApplicationOptions ------------------------------------------------------} {$REGION TCEApplicationOptions ------------------------------------------------------}
constructor TCEApplicationOptions.Create(AOwner: TComponent); constructor TCEApplicationOptions.Create(AOwner: TComponent);
@ -777,6 +778,7 @@ begin
// //
updateMainMenuProviders; updateMainMenuProviders;
EntitiesConnector.forceUpdate; EntitiesConnector.forceUpdate;
fSymStringExpander:= getSymStringExpander;
// //
getCMdParams; getCMdParams;
if fNativeProject.isNil then if fNativeProject.isNil then
@ -1949,7 +1951,7 @@ begin
if ( i > 18) then if ( i > 18) then
begin begin
if firstlineFlags.upperCase[1..17] = '#!RUNNABLE-FLAGS:' then if firstlineFlags.upperCase[1..17] = '#!RUNNABLE-FLAGS:' then
firstlineFlags := symbolExpander.get(firstlineFlags[18..i]) firstlineFlags := fSymStringExpander.expand(firstlineFlags[18..i])
else firstlineFlags:= ''; else firstlineFlags:= '';
end else firstlineFlags:= ''; end else firstlineFlags:= '';
@ -2016,7 +2018,7 @@ begin
if runArgs.isNotEmpty then if runArgs.isNotEmpty then
begin begin
lst.Clear; lst.Clear;
CommandToList(symbolExpander.get(runArgs), lst); CommandToList(fSymStringExpander.expand(runArgs), lst);
fRunProc.Parameters.AddStrings(lst); fRunProc.Parameters.AddStrings(lst);
end; end;
fRunProc.Executable := fname + exeExt; fRunProc.Executable := fname + exeExt;

View File

@ -8,8 +8,8 @@ uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls, Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls,
EditBtn, lcltype, ce_widget, ActnList, Menus, clipbrd, AnchorDocking, math, EditBtn, lcltype, ce_widget, ActnList, Menus, clipbrd, AnchorDocking, math,
TreeFilterEdit, Buttons, process, GraphType, fgl, TreeFilterEdit, Buttons, process, GraphType, fgl,
ce_writableComponent, ce_common, ce_synmemo, ce_dlangutils, ce_interfaces, ce_writableComponent, ce_common, ce_synmemo, ce_interfaces, ce_observer,
ce_observer, ce_symstring, ce_processes, ce_sharedres, ce_stringrange; ce_processes, ce_sharedres, ce_stringrange;
type type
@ -105,6 +105,7 @@ type
fToDemangle: TStringList; fToDemangle: TStringList;
fToDemangleObjs: TFPList; fToDemangleObjs: TFPList;
fFiltering: boolean; fFiltering: boolean;
fSymStringExpander: ICESymStringExpander;
function itemShouldBeVisible(item: TTreeNode; aCtxt: TCEAppMessageCtxt): boolean; function itemShouldBeVisible(item: TTreeNode; aCtxt: TCEAppMessageCtxt): boolean;
procedure demanglerOutput(sender: TObject); procedure demanglerOutput(sender: TObject);
procedure filterMessages(aCtxt: TCEAppMessageCtxt); procedure filterMessages(aCtxt: TCEAppMessageCtxt);
@ -150,6 +151,10 @@ type
procedure optionedEvent(anEvent: TOptionEditorEvent); procedure optionedEvent(anEvent: TOptionEditorEvent);
function optionedOptionsModified: boolean; function optionedOptionsModified: boolean;
// //
function openFileFromDmdMessage(const aMessage: string): boolean;
function getLineFromMessage(const aMessage: string): TPoint;
function guessMessageKind(const aMessg: string): TCEAppMessageKind;
//
function singleServiceName: string; function singleServiceName: string;
procedure message(const aValue: string; aData: Pointer; aCtxt: TCEAppMessageCtxt; aKind: TCEAppMessageKind); procedure message(const aValue: string; aData: Pointer; aCtxt: TCEAppMessageCtxt; aKind: TCEAppMessageKind);
procedure clearbyContext(aCtxt: TCEAppMessageCtxt); procedure clearbyContext(aCtxt: TCEAppMessageCtxt);
@ -176,10 +181,6 @@ type
destructor destroy; override; destructor destroy; override;
end; end;
function guessMessageKind(const aMessg: string): TCEAppMessageKind;
function getLineFromMessage(const aMessage: string): TPoint;
function openFileFromDmdMessage(const aMessage: string): boolean;
implementation implementation
{$R *.lfm} {$R *.lfm}
@ -260,6 +261,7 @@ var
begin begin
fMaxMessCnt := 500; fMaxMessCnt := 500;
fCtxt := amcAll; fCtxt := amcAll;
fSymStringExpander:= getSymStringExpander;
// //
fActAutoSel := TAction.Create(self); fActAutoSel := TAction.Create(self);
fActAutoSel.Caption := 'Auto select message category'; fActAutoSel.Caption := 'Auto select message category';
@ -973,7 +975,7 @@ begin
list.EndUpdate; list.EndUpdate;
end; end;
function guessMessageKind(const aMessg: string): TCEAppMessageKind; function TCEMessagesWidget.guessMessageKind(const aMessg: string): TCEAppMessageKind;
var var
idt: string; idt: string;
rng: TStringRange; rng: TStringRange;
@ -1013,7 +1015,7 @@ begin
end; end;
end; end;
function getLineFromMessage(const aMessage: string): TPoint; function TCEMessagesWidget.getLineFromMessage(const aMessage: string): TPoint;
var var
rng: TStringRange; rng: TStringRange;
lne: string; lne: string;
@ -1031,7 +1033,7 @@ begin
result.x := strToIntDef(col, -1); result.x := strToIntDef(col, -1);
end; end;
function openFileFromDmdMessage(const aMessage: string): boolean; function TCEMessagesWidget.openFileFromDmdMessage(const aMessage: string): boolean;
var var
i: integer = 0; i: integer = 0;
ident: string = ''; ident: string = '';
@ -1063,13 +1065,13 @@ begin
exit(true); exit(true);
end; end;
// if fname relative to native project path or project filed 'root' // if fname relative to native project path or project filed 'root'
absName := expandFilenameEx(symbolExpander.get('<CPP>') + DirectorySeparator, ident); absName := expandFilenameEx(fSymStringExpander.expand('<CPP>') + DirectorySeparator, ident);
if absName.fileExists then if absName.fileExists then
begin begin
getMultiDocHandler.openDocument(absName); getMultiDocHandler.openDocument(absName);
exit(true); exit(true);
end; end;
absName := expandFilenameEx(symbolExpander.get('<CPR>') + DirectorySeparator, ident); absName := expandFilenameEx(fSymStringExpander.expand('<CPR>') + DirectorySeparator, ident);
if absName.fileExists then if absName.fileExists then
begin begin
getMultiDocHandler.openDocument(absName); getMultiDocHandler.openDocument(absName);

View File

@ -45,6 +45,7 @@ type
fCanBeRun: boolean; fCanBeRun: boolean;
fBaseConfig: TCompilerConfiguration; fBaseConfig: TCompilerConfiguration;
fCompiled: boolean; fCompiled: boolean;
fSymStringExpander: ICESymStringExpander;
procedure updateOutFilename; procedure updateOutFilename;
procedure doChanged; procedure doChanged;
procedure getBaseConfig; procedure getBaseConfig;
@ -127,7 +128,7 @@ type
implementation implementation
uses uses
controls, dialogs, ce_symstring, ce_libman, ce_dcd; controls, dialogs, ce_libman, ce_dcd;
var var
NativeProjectCompilerFilename: string = 'dmd'; NativeProjectCompilerFilename: string = 'dmd';
@ -136,6 +137,7 @@ var
constructor TCENativeProject.create(aOwner: TComponent); constructor TCENativeProject.create(aOwner: TComponent);
begin begin
inherited create(aOwner); inherited create(aOwner);
fSymStringExpander := getSymStringExpander;
// //
fRunnerOldCwd := GetCurrentDirUTF8; fRunnerOldCwd := GetCurrentDirUTF8;
fProjectSubject := TCEProjectSubject.create; fProjectSubject := TCEProjectSubject.create;
@ -403,7 +405,7 @@ begin
// prepares the exclusions // prepares the exclusions
for i := 0 to currentConfiguration.pathsOptions.exclusions.Count-1 do for i := 0 to currentConfiguration.pathsOptions.exclusions.Count-1 do
begin begin
str := symbolExpander.get(currentConfiguration.pathsOptions.exclusions[i]); str := fSymStringExpander.expand(currentConfiguration.pathsOptions.exclusions[i]);
exc.Add(str) exc.Add(str)
end; end;
// sources // sources
@ -620,7 +622,7 @@ begin
// field is specified // field is specified
if fOutputFilename.isNotEmpty then if fOutputFilename.isNotEmpty then
begin begin
fOutputFilename := symbolExpander.get(fOutputFilename); fOutputFilename := fSymStringExpander.expand(fOutputFilename);
fOutputFilename := expandFilenameEx(fBasePath, fOutputFilename); fOutputFilename := expandFilenameEx(fBasePath, fOutputFilename);
{$IFDEF WINDOWS} {$IFDEF WINDOWS}
// field is specified without ext or with a dot in the name. // field is specified without ext or with a dot in the name.
@ -666,7 +668,7 @@ begin
// //
for i := 0 to processInfo.simpleCommands.Count-1 do for i := 0 to processInfo.simpleCommands.Count-1 do
begin begin
pname := symbolExpander.get(processInfo.simpleCommands[i]); pname := fSymStringExpander.expand(processInfo.simpleCommands[i]);
proc := TProcess.Create(nil); proc := TProcess.Create(nil);
lst := TStringList.Create; lst := TStringList.Create;
try try
@ -689,7 +691,7 @@ begin
exit(false); exit(false);
end; end;
// //
pname := symbolExpander.get(processInfo.executable); pname := fSymStringExpander.expand(processInfo.executable);
if (not exeInSysPath(pname)) and pname.isNotEmpty then if (not exeInSysPath(pname)) and pname.isNotEmpty then
exit(false) exit(false)
else if pname.isEmpty then else if pname.isEmpty then
@ -701,11 +703,11 @@ begin
proc.Executable := exeFullName(pname); proc.Executable := exeFullName(pname);
j := proc.Parameters.Count-1; j := proc.Parameters.Count-1;
for i:= 0 to j do for i:= 0 to j do
proc.Parameters.AddText(symbolExpander.get(proc.Parameters[i])); proc.Parameters.AddText(fSymStringExpander.expand(proc.Parameters[i]));
for i:= 0 to j do for i:= 0 to j do
proc.Parameters.Delete(0); proc.Parameters.Delete(0);
if proc.CurrentDirectory.isNotEmpty then if proc.CurrentDirectory.isNotEmpty then
proc.CurrentDirectory := symbolExpander.get(proc.CurrentDirectory); proc.CurrentDirectory := fSymStringExpander.expand(proc.CurrentDirectory);
// else cwd is set to project dir in compile() // else cwd is set to project dir in compile()
ensureNoPipeIfWait(proc); ensureNoPipeIfWait(proc);
proc.Execute; proc.Execute;
@ -799,7 +801,7 @@ begin
i := 1; i := 1;
repeat repeat
prm := ExtractDelimited(i, runArgs, [' ']); prm := ExtractDelimited(i, runArgs, [' ']);
prm := symbolExpander.get(prm); prm := fSymStringExpander.expand(prm);
if prm.isNotEmpty then if prm.isNotEmpty then
fRunner.Parameters.AddText(prm); fRunner.Parameters.AddText(prm);
Inc(i); Inc(i);

View File

@ -26,6 +26,7 @@ type
fMruPos: Integer; fMruPos: Integer;
fMru: TCEMRUList; fMru: TCEMRUList;
fProc: TProcess; fProc: TProcess;
fSymStringExpander: ICESymStringExpander;
procedure sendInput; procedure sendInput;
// //
function singleServiceName: string; function singleServiceName: string;
@ -41,7 +42,7 @@ implementation
{$R *.lfm} {$R *.lfm}
uses uses
ce_symstring, LCLType; LCLType;
const const
OptsFname = 'procinput.txt'; OptsFname = 'procinput.txt';
@ -52,6 +53,7 @@ var
fname: string; fname: string;
begin begin
inherited; inherited;
fSymStringExpander:= getSymStringExpander;
fMru := TCEMRUList.Create; fMru := TCEMRUList.Create;
fMru.maxCount := 25; fMru.maxCount := 25;
EntitiesConnector.addSingleService(self); EntitiesConnector.addSingleService(self);
@ -123,7 +125,7 @@ begin
fMru.Insert(0,txtInp.Text); fMru.Insert(0,txtInp.Text);
fMruPos := 0; fMruPos := 0;
if txtInp.Text <> '' then if txtInp.Text <> '' then
inp := symbolExpander.get(txtInp.Text) + lineEnding inp := fSymStringExpander.expand(txtInp.Text) + lineEnding
else else
inp := txtInp.Text + lineEnding; inp := txtInp.Text + lineEnding;
fProc.Input.Write(inp[1], inp.length); fProc.Input.Write(inp[1], inp.length);

View File

@ -42,6 +42,7 @@ type
fImpsNode, fInclNode: TTreeNode; fImpsNode, fInclNode: TTreeNode;
fXtraNode: TTreeNode; fXtraNode: TTreeNode;
fLastFileOrFolder: string; fLastFileOrFolder: string;
fSymStringExpander: ICESymStringExpander;
procedure actUpdate(sender: TObject); procedure actUpdate(sender: TObject);
procedure TreeDblClick(sender: TObject); procedure TreeDblClick(sender: TObject);
procedure actOpenFileExecute(sender: TObject); procedure actOpenFileExecute(sender: TObject);
@ -65,12 +66,11 @@ type
implementation implementation
{$R *.lfm} {$R *.lfm}
uses
ce_symstring;
{$REGION Standard Comp/Obj------------------------------------------------------} {$REGION Standard Comp/Obj------------------------------------------------------}
constructor TCEProjectInspectWidget.create(aOwner: TComponent); constructor TCEProjectInspectWidget.create(aOwner: TComponent);
begin begin
fSymStringExpander:= getSymStringExpander;
//
fActOpenFile := TAction.Create(self); fActOpenFile := TAction.Create(self);
fActOpenFile.Caption := 'Open file in editor'; fActOpenFile.Caption := 'Open file in editor';
fActOpenFile.OnExecute := @actOpenFileExecute; fActOpenFile.OnExecute := @actOpenFileExecute;
@ -447,7 +447,7 @@ begin
if str.isEmpty then if str.isEmpty then
continue; continue;
fold := expandFilenameEx(fProject.basePath, str); fold := expandFilenameEx(fProject.basePath, str);
fold := symbolExpander.get(fold); fold := fSymStringExpander.expand(fold);
itm := Tree.Items.AddChild(fImpsNode, fold); itm := Tree.Items.AddChild(fImpsNode, fold);
itm.ImageIndex := 5; itm.ImageIndex := 5;
itm.SelectedIndex := 5; itm.SelectedIndex := 5;
@ -459,7 +459,7 @@ begin
if str.isEmpty then if str.isEmpty then
continue; continue;
fold := expandFilenameEx(fProject.basePath, str); fold := expandFilenameEx(fProject.basePath, str);
fold := symbolExpander.get(fold); fold := fSymStringExpander.expand(fold);
itm := Tree.Items.AddChild(fInclNode, fold); itm := Tree.Items.AddChild(fInclNode, fold);
itm.ImageIndex := 5; itm.ImageIndex := 5;
itm.SelectedIndex := 5; itm.SelectedIndex := 5;
@ -471,7 +471,7 @@ begin
if str.isEmpty then if str.isEmpty then
continue; continue;
src := expandFilenameEx(fProject.basePath, str); src := expandFilenameEx(fProject.basePath, str);
src := symbolExpander.get(src); src := fSymStringExpander.expand(src);
lst := TStringList.Create; lst := TStringList.Create;
try try
if listAsteriskPath(src, lst) then for src in lst do if listAsteriskPath(src, lst) then for src in lst do

View File

@ -25,7 +25,7 @@ type
* TCESymbolExpander is designed to expand Coedit symbolic strings, * TCESymbolExpander is designed to expand Coedit symbolic strings,
* using the information collected from several observer interfaces. * using the information collected from several observer interfaces.
*) *)
TCESymbolExpander = class(ICEMultiDocObserver, ICEProjectObserver) TCESymbolExpander = class(ICEMultiDocObserver, ICEProjectObserver, ICESymStringExpander)
private private
fProj: TCENativeProject; fProj: TCENativeProject;
fProjInterface: ICECommonProject; fProjInterface: ICECommonProject;
@ -45,25 +45,26 @@ type
procedure docClosing(aDoc: TCESynMemo); procedure docClosing(aDoc: TCESynMemo);
procedure docFocused(aDoc: TCESynMemo); procedure docFocused(aDoc: TCESynMemo);
procedure docChanged(aDoc: TCESynMemo); procedure docChanged(aDoc: TCESynMemo);
//
function singleServiceName: string;
function expand(const value: string): string;
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
// expands the symbols contained in symString
function get(const symString: string): string;
end; end;
var
symbolExpander: TCESymbolExpander;
implementation implementation
uses uses
Forms, SysUtils, Classes; Forms, SysUtils, Classes;
var
symbolExpander: TCESymbolExpander;
{$REGION Standard Comp/Obj------------------------------------------------------} {$REGION Standard Comp/Obj------------------------------------------------------}
constructor TCESymbolExpander.Create; constructor TCESymbolExpander.Create;
begin begin
EntitiesConnector.addObserver(self); EntitiesConnector.addObserver(self);
EntitiesConnector.addSingleService(self);
fNeedUpdate := true; fNeedUpdate := true;
// //
{$IFDEF UNIX} {$IFDEF UNIX}
@ -237,17 +238,22 @@ begin
end; end;
end; end;
function TCESymbolExpander.get(const symString: string): string; function TCESymbolExpander.singleServiceName: string;
begin
exit('ICESymStringExpander');
end;
function TCESymbolExpander.expand(const value: string): string;
var var
rng: TStringRange; rng: TStringRange;
sym: string; sym: string;
begin begin
Result := ''; Result := '';
if symString.isEmpty then if value.isEmpty then
exit; exit;
// //
updateSymbols; updateSymbols;
rng := TStringRange.create(symString); rng := TStringRange.create(value);
while true do while true do
begin begin
if rng.empty then if rng.empty then

View File

@ -8,7 +8,7 @@ uses
Classes, SysUtils, FileUtil, ListFilterEdit, Forms, Controls, Classes, SysUtils, FileUtil, ListFilterEdit, Forms, Controls,
strutils, Graphics, Dialogs, ExtCtrls, Menus, Buttons, ComCtrls, strutils, Graphics, Dialogs, ExtCtrls, Menus, Buttons, ComCtrls,
ce_widget, process, ce_common, ce_interfaces, ce_synmemo, ce_processes, ce_widget, process, ce_common, ce_interfaces, ce_synmemo, ce_processes,
ce_nativeproject, ce_symstring, ce_writableComponent, ce_observer, ce_sharedres; ce_nativeproject, ce_writableComponent, ce_observer, ce_sharedres;
type type

View File

@ -30,6 +30,7 @@ type
fOutputToNext: boolean; fOutputToNext: boolean;
fShortcut: TShortcut; fShortcut: TShortcut;
fMsgs: ICEMessagesDisplay; fMsgs: ICEMessagesDisplay;
fSymStringExpander: ICESymStringExpander;
procedure setParameters(value: TStringList); procedure setParameters(value: TStringList);
procedure processOutput(sender: TObject); procedure processOutput(sender: TObject);
procedure setToolAlias(value: string); procedure setToolAlias(value: string);
@ -107,7 +108,7 @@ var
implementation implementation
uses uses
ce_symstring, dialogs; dialogs;
const const
toolsFname = 'tools.txt'; toolsFname = 'tools.txt';
@ -126,6 +127,8 @@ end;
constructor TCEToolItem.create(ACollection: TCollection); constructor TCEToolItem.create(ACollection: TCollection);
begin begin
inherited; inherited;
fSymStringExpander:= getSymStringExpander;
fMsgs := getMessageDisplay;
fToolItems := TCEToolItems(ACollection); fToolItems := TCEToolItems(ACollection);
fToolAlias := format('<tool %d>', [ID]); fToolAlias := format('<tool %d>', [ID]);
fParameters := TStringList.create; fParameters := TStringList.create;
@ -203,16 +206,16 @@ begin
fProcess.OnReadData:= @processOutput; fProcess.OnReadData:= @processOutput;
fProcess.OnTerminate:= @processOutput; fProcess.OnTerminate:= @processOutput;
fProcess.Options := fOpts; fProcess.Options := fOpts;
fProcess.Executable := exeFullName(symbolExpander.get(fExecutable)); fProcess.Executable := exeFullName(fSymStringExpander.expand(fExecutable));
fProcess.ShowWindow := fShowWin; fProcess.ShowWindow := fShowWin;
fProcess.CurrentDirectory := symbolExpander.get(fWorkingDir); fProcess.CurrentDirectory := fSymStringExpander.expand(fWorkingDir);
for prm in fParameters do if not isStringDisabled(prm) then for prm in fParameters do if not isStringDisabled(prm) then
fProcess.Parameters.AddText(symbolExpander.get(prm)); fProcess.Parameters.AddText(fSymStringExpander.expand(prm));
if fQueryParams then if fQueryParams then
begin begin
prm := ''; prm := '';
if InputQuery('Parameters', '', prm) then if InputQuery('Parameters', '', prm) then
if prm.isNotEmpty then fProcess.Parameters.AddText(symbolExpander.get(prm)); if prm.isNotEmpty then fProcess.Parameters.AddText(fSymStringExpander.expand(prm));
end; end;
ensureNoPipeIfWait(fProcess); ensureNoPipeIfWait(fProcess);
// //
@ -241,7 +244,6 @@ var
begin begin
if ((not fOutputToNext) or fNextToolAlias.isEmpty) and (poUsePipes in options) then if ((not fOutputToNext) or fNextToolAlias.isEmpty) and (poUsePipes in options) then
begin begin
getMessageDisplay(fMsgs);
lst := TStringList.Create; lst := TStringList.Create;
try try
fProcess.getFullLines(lst); fProcess.getFullLines(lst);