瀏覽代碼

fpdoc: fixed ElementType, issue 39887

(cherry picked from commit e9c278b9f127fccd9b577bb91011634839561152)
mattias 2 年之前
父節點
當前提交
57b7720a85
共有 1 個文件被更改,包括 25 次插入19 次删除
  1. 25 19
      utils/fpdoc/dw_chm.pp

+ 25 - 19
utils/fpdoc/dw_chm.pp

@@ -426,28 +426,34 @@ type
   
 function ElementType(Element: TPasElement): TClassMemberType;
 var
-  ETypeName: String;
+  C: TClass;
 begin
   Result := cmtUnknown;
   if not Assigned(Element) then Exit;
-  ETypeName := Element.ElementTypeName;
-  if Length(ETypeName) = 0 then Exit;
-  // opearator
-  if ETypeName[2] = 'p' then Exit(cmtOperator);
-  if ETypeName[3] = 'n' then Exit(cmtConstant);
-  // overloaded we don't care
-  if ETypeName[1] = 'o' then ETypeName := Copy(ETypeName, 12, Length(ETypeName));
-  
-  if ETypeName[1] = 'f' then Exit(cmtFunction);
-  if ETypeName[1] = 'c' then Exit(cmtConstructor);
-  if ETypeName[1] = 'd' then Exit(cmtDestructor);
-  if ETypeName[1] = 'v' then Exit(cmtVariable);
-  if ETypeName[1] = 'i' then Exit(cmtInterface);
-  // the p's
-  if ETypeName[4] = 'c' then Exit(cmtProcedure);
-  if ETypeName[4] = 'p' then Exit(cmtProperty);
-  // Unknown
-  // WriteLn(' Warning El name: '+ Element.Name+' path: '+Element.PathName+' TypeName: '+Element.ElementTypeName);
+
+  C:=Element.ClassType;
+  if (C=TPasProcedure) or (C=TPasClassProcedure) then
+    exit(cmtProcedure)
+  else if (C=TPasFunction) or (C=TPasClassFunction) then
+    exit(cmtFunction)
+  else if (C=TPasConstructor) or (C=TPasClassConstructor) then
+    exit(cmtConstructor)
+  else if (C=TPasDestructor) or (C=TPasClassDestructor) then
+    exit(cmtDestructor)
+  else if (C=TPasOperator) or (C=TPasClassOperator) then
+    exit(cmtOperator)
+  else if C=TPasConst then
+    exit(cmtConstant)
+  else if C=TPasVariable then
+    exit(cmtVariable)
+  else if C=TPasProperty then
+    exit(cmtProperty)
+  else
+    begin
+    // Unknown
+    exit(cmtUnknown);
+    // WriteLn(' Warning El name: '+ Element.Name+' path: '+Element.PathName+' TypeName: '+Element.ElementTypeName);
+    end;
 end;
 
 procedure TCHMHTMLWriter.GenerateIndex;