MG: internationalization for codetools

git-svn-id: trunk@1568 -
This commit is contained in:
lazarus 2002-03-29 16:23:02 +00:00
parent ec6a50b270
commit 248d37e16d
2 changed files with 321 additions and 306 deletions

View File

@ -88,7 +88,6 @@ ResourceString
ctsEndForClassNotFound = '"end" for class/object not found'; ctsEndForClassNotFound = '"end" for class/object not found';
ctsUnexpectedSubRangeOperatorFound = 'unexpected subrange operator ''..'' found'; ctsUnexpectedSubRangeOperatorFound = 'unexpected subrange operator ''..'' found';
ctsInvalidSubrange = 'invalid subrange'; ctsInvalidSubrange = 'invalid subrange';
ctsInvalidType = 'invalid type';
// find declaration // find declaration
ctsUnitNotFound = 'unit not found: %s'; ctsUnitNotFound = 'unit not found: %s';
@ -96,6 +95,23 @@ ResourceString
ctsExprTypeIsNotVariable = 'expression type is not a variable'; ctsExprTypeIsNotVariable = 'expression type is not a variable';
ctsInheritedKeywordOnlyAllowedInMethods = ctsInheritedKeywordOnlyAllowedInMethods =
'inherited keyword only allowed in methods'; 'inherited keyword only allowed in methods';
ctsCircleInDefinitions = 'circle in definitions';
ctsForwardClassDefinitionNotResolved = 'Forward class definition not resolved: %s';
ctsTypeIdentifier = 'type identifier';
ctsAncestorIsNotProperty = 'ancestor of untyped property is not a property';
ctsBaseTypeOfNotFound = 'base type of "%s" not found';
ctsClassIdentifierExpected = 'class identifier expected';
ctsDefaultClassAncestorTObjectNotFound = 'default class ancestor TObject not found';
ctsExprTypeMustBeClassOrRecord = 'expression type must be class or record type';
ctsClassWithoutName = 'class without name';
ctsBinaryOperator = 'binary operator';
ctsInvalidType = 'invalid type';
ctsKeywordIn = 'keyword "in"';
ctsIllegalCircleInUsedUnits = 'illegal circle using unit: %s';
ctsSourceIsNotUnit = 'source is not unit';
ctsInterfaceSectionNotFound = 'interface section not found';
ctsUsedUnitIsNotAPascalUnit = 'used unit is not a pascal unit';
ctsDuplicateIdentifier = 'duplicate identifier: %s';
// codecompletion // codecompletion
ctsPropertySpecifierAlreadyDefined = 'property specifier already defined: %s'; ctsPropertySpecifierAlreadyDefined = 'property specifier already defined: %s';
@ -174,7 +190,6 @@ ResourceString
ctsFileHasCircularSymLink = '%s has a circular symbolic link'; ctsFileHasCircularSymLink = '%s has a circular symbolic link';
ctsFileIsNotExecutable = '%s is not executable'; ctsFileIsNotExecutable = '%s is not executable';
implementation implementation
end. end.

View File

@ -1936,7 +1936,7 @@ begin
if NodeExistsInStack(@NodeStack,Result.Node) then begin if NodeExistsInStack(@NodeStack,Result.Node) then begin
// circle detected // circle detected
Result.Tool.MoveCursorToNodeStart(Result.Node); Result.Tool.MoveCursorToNodeStart(Result.Node);
Result.Tool.RaiseException('circle in definitions'); Result.Tool.RaiseException(ctsCircleInDefinitions);
end; end;
AddNodeToStack(@NodeStack,Result.Node); AddNodeToStack(@NodeStack,Result.Node);
@ -1982,9 +1982,9 @@ writeln('[TFindDeclarationTool.FindBaseTypeOfNode] Class is forward');
if (Params.NewNode.Desc<>ctnTypeDefinition) if (Params.NewNode.Desc<>ctnTypeDefinition)
or (Params.NewCodeTool<>Self) then begin or (Params.NewCodeTool<>Self) then begin
MoveCursorToCleanPos(Result.Node.StartPos); MoveCursorToCleanPos(Result.Node.StartPos);
RaiseException('Forward class definition not resolved: ' RaiseExceptionFmt(ctsForwardClassDefinitionNotResolved,
+copy(Src,ClassIdentNode.StartPos, [copy(Src,ClassIdentNode.StartPos,
ClassIdentNode.EndPos-ClassIdentNode.StartPos)); ClassIdentNode.EndPos-ClassIdentNode.StartPos)]);
end; end;
Result:=Params.NewCodeTool.FindBaseTypeOfNode(Params,Params.NewNode); Result:=Params.NewCodeTool.FindBaseTypeOfNode(Params,Params.NewNode);
exit; exit;
@ -2025,8 +2025,8 @@ writeln('[TFindDeclarationTool.FindBaseTypeOfNode] Class is forward');
if NodeExistsInStack(@NodeStack,Params.NewNode) then begin if NodeExistsInStack(@NodeStack,Params.NewNode) then begin
// circle detected // circle detected
Params.NewCodeTool.MoveCursorToNodeStart(Params.NewNode); Params.NewCodeTool.MoveCursorToNodeStart(Params.NewNode);
Params.NewCodeTool.RaiseException('circle in definitions' Params.NewCodeTool.RaiseException(ctsCircleInDefinitions
+' (identifier='+GetIdentifier(Params.Identifier)+')'); +' ('+ctsIdentifier+'='+GetIdentifier(Params.Identifier)+')');
end; end;
Result:=Params.NewCodeTool.FindBaseTypeOfNode(Params, Result:=Params.NewCodeTool.FindBaseTypeOfNode(Params,
Params.NewNode) Params.NewNode)
@ -2034,7 +2034,8 @@ writeln('[TFindDeclarationTool.FindBaseTypeOfNode] Class is forward');
// not a type // not a type
MoveCursorToNodeStart(DummyNode); MoveCursorToNodeStart(DummyNode);
ReadNextAtom; ReadNextAtom;
RaiseException('type identifier expected, but '+GetAtom+' found'); RaiseExceptionFmt(ctsStrExpectedButAtomFound,
[ctsTypeIdentifier,GetAtom]);
end; end;
end else end else
// predefined identifier // predefined identifier
@ -2065,8 +2066,8 @@ writeln('[TFindDeclarationTool.FindBaseTypeOfNode] Class is forward');
if NodeExistsInStack(@NodeStack,Params.NewNode) then begin if NodeExistsInStack(@NodeStack,Params.NewNode) then begin
// circle detected // circle detected
Params.NewCodeTool.MoveCursorToNodeStart(Params.NewNode); Params.NewCodeTool.MoveCursorToNodeStart(Params.NewNode);
Params.NewCodeTool.RaiseException('circle in definitions' Params.NewCodeTool.RaiseException(ctsCircleInDefinitions
+' (identifier='+GetIdentifier(Params.Identifier)+')'); +' ('+ctsIdentifier+'='+GetIdentifier(Params.Identifier)+')');
end; end;
Result:=Params.NewCodeTool.FindBaseTypeOfNode(Params, Result:=Params.NewCodeTool.FindBaseTypeOfNode(Params,
Params.NewNode) Params.NewNode)
@ -2074,8 +2075,8 @@ writeln('[TFindDeclarationTool.FindBaseTypeOfNode] Class is forward');
// not a type // not a type
MoveCursorToCleanPos(OldPos); MoveCursorToCleanPos(OldPos);
ReadNextAtom; ReadNextAtom;
RaiseException('type identifier expected,' RaiseExceptionFmt(ctsStrExpectedButAtomFound,
+' but '+GetAtom+' found'); [ctsTypeIdentifier,GetAtom]);
end; end;
end else end else
// predefined identifier // predefined identifier
@ -2104,7 +2105,7 @@ writeln('[TFindDeclarationTool.FindBaseTypeOfNode] Class is forward');
end else begin end else begin
// ancestor is not a property // ancestor is not a property
MoveCursorToCleanPos(OldPos); MoveCursorToCleanPos(OldPos);
RaiseException('ancestor of untyped property is not a property'); RaiseException(ctsAncestorIsNotProperty);
end; end;
finally finally
Params.Load(OldInput); Params.Load(OldInput);
@ -2151,8 +2152,7 @@ writeln('[TFindDeclarationTool.FindBaseTypeOfNode] Class is forward');
+' Ident="'+GetIdentifier(Params.Identifier)+'"'); +' Ident="'+GetIdentifier(Params.Identifier)+'"');
Params.IdentifierTool.MoveCursorToCleanPos(Params.Identifier); Params.IdentifierTool.MoveCursorToCleanPos(Params.Identifier);
end; end;
RaiseException('base type of "'+GetIdentifier(Params.Identifier) RaiseExceptionFmt(ctsBaseTypeOfNotFound,[GetIdentifier(Params.Identifier)]);
+'" not found');
end; end;
finally finally
// cache the result in all nodes // cache the result in all nodes
@ -2255,7 +2255,7 @@ writeln('[TFindDeclarationTool.FindIdentifierInProcContext] Proc="',copy(src,Pr
if (ClassContext.Node=nil) if (ClassContext.Node=nil)
or (ClassContext.Node.Desc<>ctnClass) then begin or (ClassContext.Node.Desc<>ctnClass) then begin
MoveCursorToCleanPos(ClassNameAtom.StartPos); MoveCursorToCleanPos(ClassNameAtom.StartPos);
RaiseException('class identifier expected'); RaiseException(ctsClassIdentifierExpected);
end; end;
// class context found // class context found
// 2. -> search identifier in class // 2. -> search identifier in class
@ -2335,7 +2335,7 @@ writeln('[TFindDeclarationTool.FindClassOfMethod] searching class of method c
if (ClassContext.Node=nil) if (ClassContext.Node=nil)
or (ClassContext.Node.Desc<>ctnClass) then begin or (ClassContext.Node.Desc<>ctnClass) then begin
MoveCursorToCleanPos(ClassNameAtom.StartPos); MoveCursorToCleanPos(ClassNameAtom.StartPos);
RaiseException('class identifier expected'); RaiseException(ctsClassIdentifierExpected);
end; end;
// class of method found // class of method found
Params.SetResult(ClassContext); Params.SetResult(ClassContext);
@ -2415,7 +2415,7 @@ writeln('[TFindDeclarationTool.FindAncestorOfClass] ',
if not FindIdentifierInContext(Params) then begin if not FindIdentifierInContext(Params) then begin
MoveCursorToNodeStart(ClassNode); MoveCursorToNodeStart(ClassNode);
//writeln(' AQ2*** ',TCodeBuffer(Scanner.MainCode).Filename,' ',CurPos.StartPos); //writeln(' AQ2*** ',TCodeBuffer(Scanner.MainCode).Filename,' ',CurPos.StartPos);
RaiseException('default class ancestor TObject not found'); RaiseException(ctsDefaultClassAncestorTObjectNotFound);
end; end;
if FindClassContext then begin if FindClassContext then begin
AncestorNode:=Params.NewNode; AncestorNode:=Params.NewNode;
@ -2483,7 +2483,7 @@ writeln('[TFindDeclarationTool.FindIdentifierInWithVarContext] ',
if (WithVarContext.Node=nil) or (WithVarContext.Node=OldInput.ContextNode) if (WithVarContext.Node=nil) or (WithVarContext.Node=OldInput.ContextNode)
or (not (WithVarContext.Node.Desc in [ctnClass,ctnRecordType])) then begin or (not (WithVarContext.Node.Desc in [ctnClass,ctnRecordType])) then begin
MoveCursorToCleanPos(WithVarNode.StartPos); MoveCursorToCleanPos(WithVarNode.StartPos);
RaiseException('expression type must be class or record type'); RaiseException(ctsExprTypeMustBeClassOrRecord);
end; end;
// search identifier in with context // search identifier in with context
Params.Load(OldInput); Params.Load(OldInput);
@ -2525,7 +2525,7 @@ begin
if (ClassIdentNode=nil) or (ClassIdentNode.Desc<>ctnTypeDefinition) then if (ClassIdentNode=nil) or (ClassIdentNode.Desc<>ctnTypeDefinition) then
begin begin
MoveCursorToNodeStart(ClassNode); MoveCursorToNodeStart(ClassNode);
RaiseException('class without name'); RaiseException(ctsClassWithoutName);
end; end;
// if this class is not TObject, TObject is class ancestor // if this class is not TObject, TObject is class ancestor
SearchTObject:=not CompareSrcIdentifier(ClassIdentNode.StartPos,'TObject'); SearchTObject:=not CompareSrcIdentifier(ClassIdentNode.StartPos,'TObject');
@ -2562,7 +2562,7 @@ writeln(' Flags=[',FindDeclarationFlagsAsString(Params.Flags),']');
if not FindIdentifierInContext(Params) then begin if not FindIdentifierInContext(Params) then begin
MoveCursorToNodeStart(ClassNode); MoveCursorToNodeStart(ClassNode);
//writeln(' AQ*** ',TCodeBuffer(Scanner.MainCode).Filename,' ',CurPos.StartPos); //writeln(' AQ*** ',TCodeBuffer(Scanner.MainCode).Filename,' ',CurPos.StartPos);
RaiseException('default class ancestor TObject not found'); RaiseException(ctsDefaultClassAncestorTObjectNotFound);
end; end;
AncestorNode:=Params.NewNode; AncestorNode:=Params.NewNode;
AncestorContext:=Params.NewCodeTool.FindBaseTypeOfNode(Params,AncestorNode); AncestorContext:=Params.NewCodeTool.FindBaseTypeOfNode(Params,AncestorNode);
@ -2711,7 +2711,7 @@ writeln('[TFindDeclarationTool.FindExpressionResultType] ',
if not WordIsBinaryOperator.DoItUpperCase(UpperSrc,CurPos.StartPos, if not WordIsBinaryOperator.DoItUpperCase(UpperSrc,CurPos.StartPos,
CurPos.EndPos-CurPos.StartPos) CurPos.EndPos-CurPos.StartPos)
then then
RaiseException('binary operator expected, but '+GetAtom+' found'); RaiseExceptionFmt(ctsStrExpectedButAtomFound,[ctsBinaryOperator,GetAtom]);
// put operator on stack // put operator on stack
ExprStack[StackPtr].theOperator:=CurPos; ExprStack[StackPtr].theOperator:=CurPos;
if WordIsLvl1Operator.DoItUpperCase(UpperSrc,CurPos.StartPos, if WordIsLvl1Operator.DoItUpperCase(UpperSrc,CurPos.StartPos,
@ -2767,7 +2767,7 @@ begin
InAtom:=CurPos; InAtom:=CurPos;
ReadPriorAtom; // read 'in' ReadPriorAtom; // read 'in'
if not UpAtomIs('IN') then if not UpAtomIs('IN') then
RaiseException('keyword "in" expected, but '+GetAtom+' found'); RaiseExceptionFmt(ctsStrExpectedButAtomFound,[ctsKeywordIn,GetAtom]);
ReadPriorAtom; // read unitname ReadPriorAtom; // read unitname
end else end else
InAtom.StartPos:=-1; InAtom.StartPos:=-1;
@ -2789,12 +2789,12 @@ begin
NewCodeTool:=FindCodeToolForUsedUnit(UnitNameAtom,InAtom,false); NewCodeTool:=FindCodeToolForUsedUnit(UnitNameAtom,InAtom,false);
if NewCodeTool=nil then begin if NewCodeTool=nil then begin
MoveCursorToCleanPos(UnitNameAtom.StartPos); MoveCursorToCleanPos(UnitNameAtom.StartPos);
RaiseException('unit not found: '+copy(Src,UnitNameAtom.StartPos, RaiseExceptionFmt(ctsUnitNotFound,[copy(Src,UnitNameAtom.StartPos,
UnitNameAtom.EndPos-UnitNameAtom.StartPos)); UnitNameAtom.EndPos-UnitNameAtom.StartPos)]);
end else if NewCodeTool=Self then begin end else if NewCodeTool=Self then begin
MoveCursorToCleanPos(UnitNameAtom.StartPos); MoveCursorToCleanPos(UnitNameAtom.StartPos);
RaiseException('illegal circle using unit: '+copy(Src, RaiseExceptionFmt(ctsIllegalCircleInUsedUnits,[copy(Src,
UnitNameAtom.StartPos,UnitNameAtom.EndPos-UnitNameAtom.StartPos)); UnitNameAtom.StartPos,UnitNameAtom.EndPos-UnitNameAtom.StartPos)]);
end; end;
// search the identifier in the interface of the used unit // search the identifier in the interface of the used unit
Params.Save(OldInput); Params.Save(OldInput);
@ -2903,7 +2903,7 @@ writeln('[TFindDeclarationTool.FindIdentifierInInterface] Ident already in cache
ReadNextAtom; // read keyword for source type, e.g. 'unit' ReadNextAtom; // read keyword for source type, e.g. 'unit'
SrcIsUsable:=UpAtomIs('UNIT'); SrcIsUsable:=UpAtomIs('UNIT');
if not SrcIsUsable then if not SrcIsUsable then
RaiseException('source is not unit'); RaiseException(ctsSourceIsNotUnit);
ReadNextAtom; // read source name ReadNextAtom; // read source name
if CompareSrcIdentifiers(CurPos.StartPos,Params.Identifier) then begin if CompareSrcIdentifiers(CurPos.StartPos,Params.Identifier) then begin
// identifier is source name // identifier is source name
@ -2915,7 +2915,7 @@ writeln('[TFindDeclarationTool.FindIdentifierInInterface] Ident already in cache
// search identifier in interface // search identifier in interface
InterfaceNode:=FindInterfaceNode; InterfaceNode:=FindInterfaceNode;
if InterfaceNode=nil then if InterfaceNode=nil then
RaiseException('interface section not found'); RaiseException(ctsInterfaceSectionNotFound);
Params.Save(OldInput); Params.Save(OldInput);
Params.Flags:=(fdfGlobalsSameIdent*Params.Flags) Params.Flags:=(fdfGlobalsSameIdent*Params.Flags)
-[fdfExceptionOnNotFound,fdfSearchInParentNodes]; -[fdfExceptionOnNotFound,fdfSearchInParentNodes];
@ -2968,12 +2968,12 @@ begin
end; end;
if not (Tree.Root.Desc in AllUsableSourceTypes) then begin if not (Tree.Root.Desc in AllUsableSourceTypes) then begin
CurPos.StartPos:=-1; CurPos.StartPos:=-1;
RaiseException('used unit is not an pascal unit'); RaiseException(ctsUsedUnitIsNotAPascalUnit);
end; end;
Result:=FindInterfaceNode; Result:=FindInterfaceNode;
if Result=nil then begin if Result=nil then begin
CurPos.StartPos:=-1; CurPos.StartPos:=-1;
RaiseException('no interface section found'); RaiseException(ctsInterfaceSectionNotFound);
end; end;
end; end;
@ -2993,7 +2993,7 @@ begin
if (NewCode=nil) then begin if (NewCode=nil) then begin
// no source found // no source found
CurPos.StartPos:=-1; CurPos.StartPos:=-1;
RaiseException('unit '+AnUnitName+' not found'); RaiseExceptionFmt(ctsUnitNotFound,[AnUnitName]);
end else begin end else begin
// source found -> get codetool for it // source found -> get codetool for it
{$IFDEF CTDEBUG} {$IFDEF CTDEBUG}
@ -3005,12 +3005,12 @@ writeln('[TFindDeclarationTool.FindIdentifierInUsedUnit] ',
NewCodeTool:=FOnGetCodeToolForBuffer(Self,NewCode); NewCodeTool:=FOnGetCodeToolForBuffer(Self,NewCode);
if NewCodeTool=nil then begin if NewCodeTool=nil then begin
CurPos.StartPos:=-1; CurPos.StartPos:=-1;
RaiseException('unit '+AnUnitName+' not found'); RaiseExceptionFmt(ctsUnitNotFound,[AnUnitName]);
end; end;
end else if NewCode=TCodeBuffer(Scanner.MainCode) then begin end else if NewCode=TCodeBuffer(Scanner.MainCode) then begin
NewCodeTool:=Self; NewCodeTool:=Self;
CurPos.StartPos:=-1; CurPos.StartPos:=-1;
RaiseException('illegal circle using unit: '+AnUnitName); RaiseExceptionFmt(ctsIllegalCircleInUsedUnits,[AnUnitName]);
end; end;
// search the identifier in the interface of the used unit // search the identifier in the interface of the used unit
Params.Save(OldInput); Params.Save(OldInput);
@ -3202,7 +3202,7 @@ writeln('[TFindDeclarationTool.FindExpressionTypeOfVariable] ',
Result:=CleanExpressionType; Result:=CleanExpressionType;
Result.Desc:=PredefinedIdentToTypeDesc(@Src[StartPos]); Result.Desc:=PredefinedIdentToTypeDesc(@Src[StartPos]);
end else end else
RaiseException('identifier expected, but '+GetAtom+' found'); RaiseExceptionFmt(ctsStrExpectedButAtomFound,[ctsIdentifier,GetAtom]);
end; end;
end; end;
@ -3307,7 +3307,7 @@ if Result.Desc=xtContext then
MoveCursorToCleanPos(SubStartPos); MoveCursorToCleanPos(SubStartPos);
ReadNextAtom; // read '[' ReadNextAtom; // read '['
ReadNextAtom; ReadNextAtom;
RaiseException('constant expected, but '+GetAtom+' found'); RaiseExceptionFmt(ctsStrExpectedButAtomFound,[ctsConstant,GetAtom]);
end; end;
end else begin end else begin
// empty set '[]' // empty set '[]'
@ -3337,7 +3337,7 @@ if Result.Desc=xtContext then
MoveCursorToCleanPos(CurPos.EndPos); MoveCursorToCleanPos(CurPos.EndPos);
end end
else else
RaiseException('identifier expected, but '+GetAtom+' found'); RaiseExceptionFmt(ctsStrExpectedButAtomFound,[ctsIdentifier,GetAtom]);
{$IFDEF ShowExprEval} {$IFDEF ShowExprEval}
write('[TFindDeclarationTool.ReadOperandTypeAtCursor] END ', write('[TFindDeclarationTool.ReadOperandTypeAtCursor] END ',
ExpressionTypeDescNames[Result.Desc]); ExpressionTypeDescNames[Result.Desc]);
@ -3651,8 +3651,8 @@ TypeCompatibilityNames[NewComp],
// identifier found with same name, but not a proc // identifier found with same name, but not a proc
// -> error: duplicate identifier // -> error: duplicate identifier
FoundContext.Tool.MoveCursorToNodeStart(FoundContext.Node); FoundContext.Tool.MoveCursorToNodeStart(FoundContext.Node);
FoundContext.Tool.RaiseException('duplicate identifier ' FoundContext.Tool.RaiseExceptionFmt(ctsDuplicateIdentifier,
+'"'+GetIdentifier(Params.Identifier)+'"'); [GetIdentifier(Params.Identifier)]);
end; end;
end else begin end else begin
{$IFDEF ShowFoundIdentifier} {$IFDEF ShowFoundIdentifier}
@ -3674,8 +3674,8 @@ writeln('[TFindDeclarationTool.CheckSrcIdentifier] no next overloaded proc ',
+TCodeBuffer(Params.IdentifierTool.Scanner.MainCode).Filename +TCodeBuffer(Params.IdentifierTool.Scanner.MainCode).Filename
+' Ident="'+GetIdentifier(Params.Identifier)+'"'); +' Ident="'+GetIdentifier(Params.Identifier)+'"');
Params.IdentifierTool.MoveCursorToCleanPos(Params.Identifier); Params.IdentifierTool.MoveCursorToCleanPos(Params.Identifier);
RaiseException('identifier not found ' RaiseExceptionFmt(ctsIdentifierNotFound,
+'"'+GetIdentifier(Params.Identifier)+'"'); [GetIdentifier(Params.Identifier)]);
end else begin end else begin
Result:=ifrAbortSearch; Result:=ifrAbortSearch;
end; end;
@ -3829,7 +3829,7 @@ writeln('[TFindDeclarationTool.CreateParamExprList] ',
ReadNextAtom; ReadNextAtom;
if AtomIsChar(BracketClose) then break; if AtomIsChar(BracketClose) then break;
if not AtomIsChar(',') then if not AtomIsChar(',') then
RaiseException(BracketClose+' expected, but '+GetAtom+' found'); RaiseExceptionFmt(ctsStrExpectedButAtomFound,[BracketClose,GetAtom]);
ReadNextAtom; ReadNextAtom;
end; end;
end; end;