diff --git a/src/org/salesforce/apexdoc/ApexDoc.java b/src/org/salesforce/apexdoc/ApexDoc.java index 8da4f97..5213150 100644 --- a/src/org/salesforce/apexdoc/ApexDoc.java +++ b/src/org/salesforce/apexdoc/ApexDoc.java @@ -27,6 +27,7 @@ public ApexDoc() { PrintStream ps = new PrintStream(fos); System.setOut(ps); } catch (Exception ex) { + System.out.println("Error: " + ex.getMessage()); } } @@ -80,7 +81,6 @@ public static void RunApexDoc(String[] args, IProgressMonitor monitor) { System.exit(-1); } } - // default scope to global and public if not specified if (rgstrScope == null || rgstrScope.length == 0) { rgstrScope = new String[3]; @@ -529,7 +529,11 @@ private static void fillClassModel(ClassModel cModelParent, ClassModel cModel, S idxStart = comment.toLowerCase().indexOf("@group-content"); if (idxStart != -1) { - cModel.setClassGroupContent(comment.substring(idxStart + 14).trim()); + String path = comment.substring(idxStart + 14).trim(); + File f = new File(path); + if (f.exists()) { + cModel.setClassGroupContent(path); + } inDescription = false; continue; } diff --git a/src/org/salesforce/apexdoc/ClassModel.java b/src/org/salesforce/apexdoc/ClassModel.java index bb81bd6..8a8068c 100644 --- a/src/org/salesforce/apexdoc/ClassModel.java +++ b/src/org/salesforce/apexdoc/ClassModel.java @@ -46,15 +46,14 @@ public ArrayList getMethodsSorted() { @SuppressWarnings("unchecked") List sorted = (List)methods.clone(); Collections.sort(sorted, new Comparator(){ - @Override public int compare(MethodModel o1, MethodModel o2) { String methodName1 = o1.getMethodName(); String methodName2 = o2.getMethodName(); String className = getClassName(); - if(methodName1.equals(className)){ + if(methodName1 != null && methodName1.equals(className)){ return Integer.MIN_VALUE; - } else if(methodName2.equals(className)){ + } else if(methodName2 != null && methodName2.equals(className)){ return Integer.MAX_VALUE; } return (methodName1.toLowerCase().compareTo(methodName2.toLowerCase())); diff --git a/src/org/salesforce/apexdoc/FileManager.java b/src/org/salesforce/apexdoc/FileManager.java index 86ed5ad..8dc37da 100644 --- a/src/org/salesforce/apexdoc/FileManager.java +++ b/src/org/salesforce/apexdoc/FileManager.java @@ -302,7 +302,7 @@ private void createClassGroupContent(TreeMap mapFNameToContent, ClassGroup cg = mapGroupNameToClassGroup.get(strGroup); if (cg.getContentSource() != null) { String cgContent = parseHTMLFile(cg.getContentSource()); - if (cgContent != "") { + if (!cgContent.equals("")) { String strHtml = Constants.getHeader(projectDetail) + links + "" + "

" + escapeHTML(cg.getName()) + "

" + cgContent + ""; @@ -337,9 +337,10 @@ private String getPageLinks(TreeMap mapGroupNameToClassGroup } cModels = new ArrayList(tm.values()); - String links = ""; - links += ""); - links += ""; - return links; + links.append(""); + return links.toString(); } private void docopy(String source, String target) throws Exception { @@ -414,10 +420,11 @@ private void copy(String toFileName) throws IOException, Exception { public ArrayList getFiles(String path) { File folder = new File(path); ArrayList listOfFilesToCopy = new ArrayList(); - if (folder != null) { + try { File[] listOfFiles = folder.listFiles(); if (listOfFiles != null && listOfFiles.length > 0) { for (int i = 0; i < listOfFiles.length; i++) { + System.out.print(listOfFiles[i].getName() + ", "); if (listOfFiles[i].isFile()) { listOfFilesToCopy.add(listOfFiles[i]); } @@ -425,6 +432,8 @@ public ArrayList getFiles(String path) { } else { System.out.println("WARNING: No files found in directory: " + path); } + } catch (SecurityException e) { + e.printStackTrace(); } return listOfFilesToCopy; } @@ -441,22 +450,21 @@ private String parseFile(String filePath) { // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); - String contents = ""; + StringBuilder contents = new StringBuilder(); String strLine; while ((strLine = br.readLine()) != null) { // Print the content on the console strLine = strLine.trim(); if (strLine != null && strLine.length() > 0) { - contents += strLine; + contents.append(strLine); } } - // System.out.println("Contents = " + contents); br.close(); - return contents; + return contents.toString(); } } catch (Exception e) { - e.printStackTrace(); + System.out.println("Skipped " + filePath + ", doesn't exist."); } return ""; diff --git a/src/org/salesforce/apexdoc/MethodModel.java b/src/org/salesforce/apexdoc/MethodModel.java index 0663391..39a72dc 100644 --- a/src/org/salesforce/apexdoc/MethodModel.java +++ b/src/org/salesforce/apexdoc/MethodModel.java @@ -35,12 +35,13 @@ public void setReturnType(String returnType) { } public String getMethodName() { - String nameLine = getNameLine().trim(); - if (nameLine != null && nameLine.length() > 0) { + String nameLine = getNameLine(); + if (nameLine != null && nameLine.trim().length() > 0) { + nameLine = nameLine.trim(); int lastindex = nameLine.indexOf("("); if (lastindex >= 0) { String methodName = ApexDoc.strPrevWord(nameLine, lastindex); - return methodName; + return methodName == null ? "" : methodName; } } return "";