public static String getPackageName(FileObject folder) { ClassPath cp = ClassPath.getClassPath(folder, ClassPath.SOURCE); if (cp != null) { return cp.getResourceName(folder, '.', false); } return null; }
public static String getPackageName(FileObject folder) { return ClassPath.getClassPath( folder, ClassPath.SOURCE) .getResourceName(folder, '.', false); }
private static String fileToClassName (FileObject fo) { // remove ".class" from and use dots for for separator ClassPath cp = ClassPath.getClassPath (fo, ClassPath.EXECUTE); if (cp == null) { logger.log(Level.WARNING, "Did not find EXECUTE class path for {0}", fo); return null; } // FileObject root = cp.findOwnerRoot (fo); return cp.getResourceName (fo, '.', false); } }
/** * @return corresponding class name for given source file */ static String getClassNameForFile(FileObject fo) { ClassPath cp = ClassPath.getClassPath(fo, ClassPath.SOURCE); return cp != null ? cp.getResourceName(fo, '.', false) : null; }
private static String getClassName(FileObject fileObj) { //PENDING: is it ensured that the classpath is non-null? return ClassPath.getClassPath(fileObj, ClassPath.SOURCE) .getResourceName(fileObj, '.', false); }
public static String getPackageName(FileObject folder) { assert folder.isFolder() : "argument must be folder"; //NOI18N return ClassPath.getClassPath( folder, ClassPath.SOURCE) .getResourceName(folder, '.', false); }
private static String getPackageName(FileObject folder) { assert folder.isFolder() : "argument must be folder"; return ClassPath.getClassPath( folder, ClassPath.SOURCE) .getResourceName(folder, '.', false); }
private @CheckForNull FileObject findBundle(FileObject javaFile) { ClassPath cp = ClassPath.getClassPath(javaFile, ClassPath.SOURCE); if (cp == null) { return null; } String name = cp.getResourceName(javaFile); if (name != null) { int index = name.lastIndexOf('/'); name = name.substring(0, index) + "/Bundle.properties"; //NOI18N return cp.findResource(name); } return null; }
public static String getRenamedPackageName(FileObject folder, String newName) { FileObject parent = folder.getParent(); if (parent == null) { return null; } ClassPath cp = ClassPath.getClassPath(parent, ClassPath.SOURCE); if (cp == null) { return null; } String parentName = cp.getResourceName(parent, '.', false); if (parentName == null) { return null; } if (parentName.length() > 0) { return parentName + '.' + newName; } else { return newName; } }
@Override public String[] getSourceAndTestClassNames(FileObject fo, boolean isTestNG, boolean isSelenium) { String[] result = {"", ""}; Project p = FileOwnerQuery.getOwner(fo); if (p != null) { Collection<? extends ClassPathProvider> providers = p.getLookup().lookupAll(ClassPathProvider.class); for (ClassPathProvider provider : providers) { ClassPath cp = provider.findClassPath(fo, PhpSourcePath.SOURCE_CP); if (cp != null) { result[0] = cp.getResourceName(fo, '.', false); result[1] = result[0].concat(TestCreatorProvider.TEST_CLASS_SUFFIX); } } } return result; }
public String getText(boolean isLogical) { ClassPath cp = ClassPath.getClassPath(fo, ClassPath.SOURCE); if (cp==null) { return fo.getPath(); } else { if (getRubySourceGroup(fo)!=null) { String name = cp.getResourceName(fo).replace('/','.'); if ("".equals(name)) return NbBundle.getMessage(UiUtils.class, "LBL_DefaultPackage_PDU"); return name; } else { return fo.getPath(); } } }
private static String getPreffiledName(CompilationInfo info, String selectedFramework) { FileObject fileObj = info.getFileObject(); ClassPath cp = ClassPath.getClassPath(fileObj, ClassPath.SOURCE); String className = cp.getResourceName(fileObj, '.', false); return className + getTestingFrameworkSuffix(selectedFramework) + TEST_CLASS_SUFFIX; }
private static String getTestName(ClassPath cp, FileObject selectedFO) { String resource = cp.getResourceName(selectedFO, '/', false); String testName = null; if (selectedFO.isFolder()) { //find Suite for package testName = JUnitTestUtil.convertPackage2SuiteName(resource); } else { // find Test for class testName = JUnitTestUtil.convertClass2TestName(resource); } return testName; }
ResourcePackageUpdate(RenameRefactoring refactoring, RefactoringElementImplementation refElement, FileObject resFolder) { this.refactoring = refactoring; this.refElement = refElement; this.resFolder = DataFolder.findFolder(resFolder); oldPkgName = ClassPath.getClassPath(resFolder, ClassPath.SOURCE) .getResourceName(resFolder.getParent(), '.', false); }
static PropertiesDataObject getPropertiesDataObject(FileObject srcFile) { ClassPath cp = ClassPath.getClassPath(srcFile, ClassPath.SOURCE); if (cp == null) { return null; } String srcClassName = cp.getResourceName(srcFile, '.', false); String bundleName = getBundleName(srcClassName); return getPropertiesDataObject(srcFile, bundleName, false); }
private void componentClassRename(FileObject originalFile) { String oldName = refInfo.getOldName(originalFile); String newName = refInfo.getNewName(); String pkg = ClassPath.getClassPath(originalFile, ClassPath.SOURCE) .getResourceName(originalFile.getParent(), '.', false); String oldClassName = (pkg != null && pkg.length() > 0) ? pkg + "." + oldName : oldName; // NOI18N String newClassName = (pkg != null && pkg.length() > 0) ? pkg + "." + newName : newName; // NOI18N componentChange(oldClassName, newClassName); }
/** * Copied from JUnit module implementation in 4.1 and modified */ private static String getTestName(ClassPath cp, FileObject selectedFO) { String resource = cp.getResourceName(selectedFO, '/', false); //NOI18N String testName = null; if (selectedFO.isFolder()) { //find Suite for package testName = convertPackage2SuiteName(resource); } else { // find Test for class testName = convertClass2TestName(resource); } return testName; }
/** * Get the package name of <code>file</code>. * * @param project owner of the file (for performance reasons) * @param file the FileObject whose packagename to get * @return package name of the file or null if it cannot be retrieved */ private static String getPackage(Project project, FileObject file) { SourceGroup srcGrp = JUnitTestUtil.findSourceGroupOwner(project, file); if (srcGrp!= null) { ClassPath cp = ClassPathSupport.createClassPath( new FileObject [] {srcGrp.getRootFolder()}); return cp.getResourceName(file, '.', false); } else { return null; } }
private void updateClassName() { if (tfClassName != null) { boolean shouldShowClassNameInfo = shouldShowClassNameInfo(); tfClassName.setVisible(shouldShowClassNameInfo); lblClassName.setVisible(shouldShowClassNameInfo); if (shouldShowClassNameInfo) { FileObject fileObj = activatedFOs[0]; ClassPath cp = ClassPath.getClassPath(fileObj, ClassPath.SOURCE); if (cp != null) { String className = cp.getResourceName(fileObj, '.', false); String suffix = (selectedTestingFramework != null && selectedTestingFramework.equals(TestCreatorProvider.FRAMEWORK_SELENIUM)) || (chkIntegrationTests != null && chkIntegrationTests.isEnabled() && chkIntegrationTests.isSelected()) ? TestCreatorProvider.INTEGRATION_TEST_CLASS_SUFFIX : TestCreatorProvider.TEST_CLASS_SUFFIX; String prefilledName = className + getTestingFrameworkSuffix() + suffix; tfClassName.setText(prefilledName); tfClassName.setDefaultText(prefilledName); tfClassName.setCaretPosition(prefilledName.length()); } } } }
private String classToSourceURL (FileObject fo, Log logger) { try { ClassPath cp = ClassPath.getClassPath (fo, ClassPath.EXECUTE); FileObject root = cp.findOwnerRoot (fo); String resourceName = cp.getResourceName (fo, '/', false); if (resourceName == null) { logger.info("Can not find classpath resource for "+fo+", skipping..."); return null; } int i = resourceName.indexOf ('$'); if (i > 0) resourceName = resourceName.substring (0, i); FileObject[] sRoots = SourceForBinaryQuery.findSourceRoots (root.getURL ()).getRoots (); ClassPath sourcePath = ClassPathSupport.createClassPath (sRoots); FileObject rfo = sourcePath.findResource (resourceName + ".java"); if (rfo == null) return null; return rfo.getURL ().toExternalForm (); } catch (FileStateInvalidException ex) { ex.printStackTrace (); return null; } }