Parser's "CaseSensitive" implementation fix.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1963 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
inoussa
2011-09-16 00:56:48 +00:00
parent 70977e292b
commit 8b1e3a960e
4 changed files with 133 additions and 80 deletions

View File

@@ -49,6 +49,7 @@ type
const const
BindingStyleNames : array[TBindingStyle] of string = ( 'Document', 'RPC', 'Unknown' ); BindingStyleNames : array[TBindingStyle] of string = ( 'Document', 'RPC', 'Unknown' );
NAME_KINDS_DEFAULT = [elkDeclaredName, elkName];
type type
TArrayStyle = ( asScoped, asEmbeded ); TArrayStyle = ( asScoped, asEmbeded );
@@ -104,6 +105,7 @@ type
FBindingList : TObjectList; FBindingList : TObjectList;
FProperties : TPropertyHolder; FProperties : TPropertyHolder;
FCaseSensitive : Boolean; FCaseSensitive : Boolean;
FDefaultSearchNameKinds: TElementNameKinds;
private private
function GetBinding(AIndex : Integer): TwstBinding; function GetBinding(AIndex : Integer): TwstBinding;
function GetBindingCount: Integer; function GetBindingCount: Integer;
@@ -138,8 +140,12 @@ type
function FindElementInModule( function FindElementInModule(
const AName: String; const AName: String;
AModule: TPasModule; AModule: TPasModule;
const ANameKinds : TElementNameKinds = [elkDeclaredName, elkName] const ANameKinds : TElementNameKinds
): TPasElement; ): TPasElement; overload;
function FindElementInModule(
const AName: String;
AModule: TPasModule
): TPasElement; overload;
function FindModule(const AName: String): TPasModule;override; function FindModule(const AName: String): TPasModule;override;
function IsEnumItemNameUsed(const AName : string; AModule : TPasModule) : Boolean;overload; function IsEnumItemNameUsed(const AName : string; AModule : TPasModule) : Boolean;overload;
function IsEnumItemNameUsed(const AName : string) : Boolean;overload; function IsEnumItemNameUsed(const AName : string) : Boolean;overload;
@@ -168,6 +174,10 @@ type
function IsOfType(AType: TPasType; AClass: TClass): Boolean; function IsOfType(AType: TPasType; AClass: TClass): Boolean;
property CaseSensitive : Boolean read FCaseSensitive write FCaseSensitive default CASE_SENSITIVE_DEFAULT; property CaseSensitive : Boolean read FCaseSensitive write FCaseSensitive default CASE_SENSITIVE_DEFAULT;
property DefaultSearchNameKinds : TElementNameKinds
read FDefaultSearchNameKinds
write FDefaultSearchNameKinds
default NAME_KINDS_DEFAULT;
end; end;
TPasNativeModule = class(TPasModule) TPasNativeModule = class(TPasModule)
@@ -418,7 +428,11 @@ function CreateWstInterfaceSymbolTable(AContainer : TwstPasTreeContainer) : TPas
var var
loc_TBaseComplexSimpleContentRemotable : TPasClassType; loc_TBaseComplexSimpleContentRemotable : TPasClassType;
locOldNameKinds : TElementNameKinds;
begin begin
locOldNameKinds := AContainer.DefaultSearchNameKinds;
AContainer.DefaultSearchNameKinds := [elkDeclaredName,elkName];
try
Result := TPasNativeModule(AContainer.CreateElement(TPasNativeModule,'base_service_intf',AContainer.Package,visPublic,'',0)); Result := TPasNativeModule(AContainer.CreateElement(TPasNativeModule,'base_service_intf',AContainer.Package,visPublic,'',0));
try try
AContainer.Package.Modules.Add(Result); AContainer.Package.Modules.Add(Result);
@@ -481,6 +495,9 @@ begin
FreeAndNil(Result); FreeAndNil(Result);
raise; raise;
end; end;
finally
AContainer.DefaultSearchNameKinds := locOldNameKinds;
end;
end; end;
function GetUltimeType(AType : TPasType) : TPasType; function GetUltimeType(AType : TPasType) : TPasType;
@@ -635,6 +652,7 @@ end;
constructor TwstPasTreeContainer.Create(); constructor TwstPasTreeContainer.Create();
begin begin
FCaseSensitive := CASE_SENSITIVE_DEFAULT; FCaseSensitive := CASE_SENSITIVE_DEFAULT;
FDefaultSearchNameKinds := NAME_KINDS_DEFAULT;
FPackage := TPasPackage.Create('sample',nil); FPackage := TPasPackage.Create('sample',nil);
FBindingList := TObjectList.Create(True); FBindingList := TObjectList.Create(True);
FProperties := TPropertyHolder.Create(); FProperties := TPropertyHolder.Create();
@@ -794,9 +812,17 @@ begin
end; end;
end; end;
function TwstPasTreeContainer.FindElementInModule(
const AName : String;
AModule : TPasModule
) : TPasElement;
begin
Result := FindElementInModule(AName,AModule,DefaultSearchNameKinds);
end;
function TwstPasTreeContainer.FindElement(const AName: String): TPasElement; function TwstPasTreeContainer.FindElement(const AName: String): TPasElement;
begin begin
Result := FindElement(AName,[elkDeclaredName,elkName]); Result := FindElement(AName,DefaultSearchNameKinds);
end; end;
function TwstPasTreeContainer.FindElement( function TwstPasTreeContainer.FindElement(

View File

@@ -79,10 +79,14 @@ var
if ( sourceType = sftXsd ) then begin if ( sourceType = sftXsd ) then begin
AppOptions := AppOptions - [ cloProxy, cloImp, cloBinder, cloWsdl ]; AppOptions := AppOptions - [ cloProxy, cloImp, cloBinder, cloWsdl ];
end; end;
if (cloParserCaseSensitive in AppOptions) then begin
if AnsiSameText('S',Trim(GetOptionArg(cloParserCaseSensitive))) then if AnsiSameText('S',Trim(GetOptionArg(cloParserCaseSensitive))) then
Include(AppOptions,cloParserCaseSensitive); Include(AppOptions,cloParserCaseSensitive);
if AnsiSameText('I',Trim(GetOptionArg(cloParserCaseSensitive))) then if AnsiSameText('I',Trim(GetOptionArg(cloParserCaseSensitive))) then
Exclude(AppOptions,cloParserCaseSensitive); Exclude(AppOptions,cloParserCaseSensitive);
end else begin
Include(AppOptions,cloParserCaseSensitive);
end;
end; end;
function GenerateSymbolTable() : Boolean ; function GenerateSymbolTable() : Boolean ;

View File

@@ -440,7 +440,11 @@ procedure TWsdlParser.Execute(const AMode: TParserMode; const AModuleName: strin
var var
locSrvcCrs : IObjectCursor; locSrvcCrs : IObjectCursor;
locObj : TDOMNodeRttiExposer; locObj : TDOMNodeRttiExposer;
locOldNameKinds : TElementNameKinds;
begin begin
locOldNameKinds := FSymbols.DefaultSearchNameKinds;
FSymbols.DefaultSearchNameKinds := [elkDeclaredName];
try
Prepare(AModuleName); Prepare(AModuleName);
locSrvcCrs := FServiceCursor.Clone() as IObjectCursor; locSrvcCrs := FServiceCursor.Clone() as IObjectCursor;
@@ -458,6 +462,9 @@ begin
SymbolTable.SetCurrentModule(FModule); SymbolTable.SetCurrentModule(FModule);
ExtractNameSpace(); ExtractNameSpace();
FixUsesList(); FixUsesList();
finally
FSymbols.DefaultSearchNameKinds := locOldNameKinds;
end;
end; end;
function TWsdlParser.ParseOperation( function TWsdlParser.ParseOperation(

View File

@@ -115,13 +115,15 @@ type
FIncludeList : TStringList; FIncludeList : TStringList;
FIncludeParsed : Boolean; FIncludeParsed : Boolean;
FPrepared : Boolean; FPrepared : Boolean;
FOldNameKinds : TElementNameKinds;
private private
procedure DoOnMessage(const AMsgType : TMessageType; const AMsg : string); procedure DoOnMessage(const AMsgType : TMessageType; const AMsg : string);
private private
function FindNamedNode(AList : IObjectCursor; const AName : WideString; const AOrder : Integer = 0):TDOMNode; function FindNamedNode(AList : IObjectCursor; const AName : WideString; const AOrder : Integer = 0):TDOMNode;
function GetParentContext() : IParserContext;{$IFDEF USE_INLINE}inline;{$ENDIF} function GetParentContext() : IParserContext;{$IFDEF USE_INLINE}inline;{$ENDIF}
procedure Prepare(const AMustSucceed : Boolean); procedure Prepare(const AMustSucceed : Boolean);
function FindElement(const AName: String) : TPasElement; {$IFDEF USE_INLINE}inline;{$ENDIF} function FindElement(const AName: String) : TPasElement; overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
function FindElement(const AName: String; const ANameKinds : TElementNameKinds) : TPasElement; overload;{$IFDEF USE_INLINE}inline;{$ENDIF}
protected protected
function GetXsShortNames() : TStrings; function GetXsShortNames() : TStrings;
function GetSymbolTable() : TwstPasTreeContainer; function GetSymbolTable() : TwstPasTreeContainer;
@@ -217,6 +219,8 @@ begin
FDoc := ADoc; FDoc := ADoc;
FParentContext := Pointer(AParentContext); FParentContext := Pointer(AParentContext);
FSymbols := ASymbols; FSymbols := ASymbols;
FOldNameKinds := FSymbols.DefaultSearchNameKinds;
FSymbols.DefaultSearchNameKinds := [elkDeclaredName];
FSchemaNode := ASchemaNode; FSchemaNode := ASchemaNode;
FNameSpaceList := TStringList.Create(); FNameSpaceList := TStringList.Create();
@@ -242,6 +246,8 @@ destructor TCustomXsdSchemaParser.Destroy();
end; end;
begin begin
if (FSymbols <> nil) then
FSymbols.DefaultSearchNameKinds := FOldNameKinds;
FParentContext := nil; FParentContext := nil;
FreeAndNil(FIncludeList); FreeAndNil(FIncludeList);
FreeList(FNameSpaceList); FreeList(FNameSpaceList);
@@ -298,6 +304,16 @@ begin
Result := SymbolTable.FindElement(AName); Result := SymbolTable.FindElement(AName);
end; end;
function TCustomXsdSchemaParser.FindElement(
const AName : String;
const ANameKinds : TElementNameKinds
) : TPasElement;
begin
Result := SymbolTable.FindElementInModule(AName,FModule,ANameKinds);
if ( Result = nil ) then
Result := SymbolTable.FindElement(AName,ANameKinds);
end;
procedure TCustomXsdSchemaParser.ParseImportDocuments(); procedure TCustomXsdSchemaParser.ParseImportDocuments();
var var
locOldCurrentModule : TPasModule; locOldCurrentModule : TPasModule;
@@ -638,7 +654,7 @@ var
if ASimpleTypeAlias.InheritsFrom(TPasNativeSimpleType) then begin if ASimpleTypeAlias.InheritsFrom(TPasNativeSimpleType) then begin
locTypeHint := ExtractTypeHint(typNd); locTypeHint := ExtractTypeHint(typNd);
if not IsStrEmpty(locTypeHint) then begin if not IsStrEmpty(locTypeHint) then begin
locHintedType := FindElement(locTypeHint) as TPasType; locHintedType := FindElement(locTypeHint,[elkName]) as TPasType;
if ( locHintedType <> nil ) then if ( locHintedType <> nil ) then
ASimpleTypeAlias := locHintedType; ASimpleTypeAlias := locHintedType;
end; end;