Community
Participate
Working Groups
originally posted here - https://www.ebayopensource.org/jira/browse/VJET-99 In message https://www.ebayopensource.org/forum/index.php?t=msg&th=184&goto=857&S=a8ce91360fe8d6951df18e1b7a78d1b3#msg_857 huntc reports that file path segments which contain a period (dot) cause an erroneous problem report to be shown in the ide with the message: file path contains unsupported character (dot). This is because the function CodeassistUtils.getClassName() builds a class name from the structure of the path. However it assumes the characters after a dot in any segment of the path are the extension of the source file so dumps them all not in just the last one (where the file name will be). To protect this flawed routine the path is checked in vjoSourceParser.ModuleDeclaration before getClassName() is called and a problem report created if folder segments of the path contain dots. The code below is my suggested alternative implementation of the CodeassistUtils.getClassName() function. After implementation of something like it the guard check in vjoSourceParser.ModuleDeclaration can be removed. This implementation only seeks to remove characters after the period (dot) in the last of the segments. The majority of this function is unchanged. The code changed is within the second 'for' loop. /** * Return class name if the path object contains source folders information. * * @param sourceFolders * list of the {@link IPath} source filders object. * @param path * path of the resource * @return class name. */ private static String getClassName(List<IPath> sourceFolders, IPath path) { StringBuffer buffer = new StringBuffer(); // remove source folder segment for (IPath path2 : sourceFolders) { if (path2.toString().length() > 0 && path2.isPrefixOf(path)) { path = path.removeFirstSegments(path2.segmentCount()); break; } } String[] segmStrings = path.segments(); for (int i = 0; i < segmStrings.length; i++) { if (i > 0) buffer.append(DOT); String name = segmStrings[i]; if (i + 1 == segmStrings.length) { // Remove chars after period int dotIndex = name.lastIndexOf(DOT); if (dotIndex != -1) { name = name.substring(0, dotIndex); } } buffer.append(name); } return buffer.toString(); }
Dot in directory name also causes builder errors such as: java.lang.NullPointerException at org.eclipse.vjet.dsf.jstojava.controller.JstParseController.resolve(JstParseController.java:110) at org.eclipse.vjet.eclipse.core.builder.VjetScriptBuilder.buildElements(VjetScriptBuilder.java:1086) at org.eclipse.vjet.eclipse.core.builder.VjetScriptBuilder.fullBuild(VjetScriptBuilder.java:706) at org.eclipse.vjet.eclipse.core.builder.VjetScriptBuilder.build(VjetScriptBuilder.java:407) at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239) at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374) at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143) at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)