org.netbeans.modules.php.api.util.StringUtils Java Examples

The following examples show how to use org.netbeans.modules.php.api.util.StringUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RunConfigLocalValidator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static String validate(RunConfigLocal config, boolean validateIndex) {
    String error;
    error = RunConfigWebValidator.validateUrl(config.getUrl());
    if (error != null) {
        return error;
    }
    if (validateIndex) {
        String indexRelativePath = config.getIndexRelativePath();
        if (StringUtils.hasText(indexRelativePath)) {
            error = BaseRunConfigValidator.validateIndexFile(config.getIndexParentDir(), indexRelativePath);
            if (error != null) {
                return error;
            }
        }
    }
    return null;
}
 
Example #2
Source File: TableVisitor.java    From cakephp3-netbeans with Apache License 2.0 6 votes vote down vote up
private void handleMethod(FunctionInvocation method) {
    String methodName = CodeUtils.extractFunctionName(method);
    if (StringUtils.isEmpty(methodName)) {
        return;
    }
    Assosiation assosiation = Assosiation.get(methodName);
    if (assosiation != Assosiation.UNKNOWN) {
        addTable(method);
    }

    switch (methodName) {
        case ADD_BEHABIOR_METHOD:
            addBehavior(method);
            break;
        default:
            break;
    }
}
 
Example #3
Source File: SourceRoots.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the display names of source roots.
 * The returned array has the same length as an array returned by the {@link #getRootProperties()}.
 * It may contain empty {@link String}s but not <code>null</code>.
 * @return an array of source roots names.
 */
@NbBundle.Messages({
    "# {0} - display name of the source root",
    "# {1} - directory of the source root",
    "SourceRoots.displayName={0} ({1})",
})
public String[] getRootNames() {
    String[] pureRootNames = getPureRootNames();
    if (pureRootNames.length == 0) {
        return new String[0];
    }
    String[] names = new String[pureRootNames.length];
    for (int i = 0; i < names.length; i++) {
        String pureName = pureRootNames[i];
        String name;
        if (StringUtils.hasText(pureName)) {
            name = Bundle.SourceRoots_displayName(displayName, pureName);
        } else {
            name = displayName;
        }
        names[i] = name;
    }
    return names;
}
 
Example #4
Source File: PHPStan.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private List<String> getParameters(PHPStanParams parameters, FileObject file) {
    // analyse /path/to/{dir|file}
    List<String> params = new ArrayList<>();
    params.add(ANALYSE_COMMAND);
    params.addAll(ANALYZE_DEFAULT_PARAMS);
    String level = parameters.getLevel();
    if (!StringUtils.isEmpty(level)) {
        params.add(String.format(LEVEL_PARAM, level));
    }
    FileObject configuration = parameters.getConfiguration();
    if (configuration != null) {
        params.add(String.format(CONFIGURATION_PARAM, FileUtil.toFile(configuration).getAbsolutePath()));
    }
    String memoryLimit = parameters.getMemoryLimit();
    if (!StringUtils.isEmpty(memoryLimit)) {
        params.add(String.format(MEMORY_LIMIT_PARAM, memoryLimit));
    }
    params.add(FileUtil.toFile(file).getAbsolutePath());
    return params;
}
 
Example #5
Source File: SymfonyScript.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void processLine(String line) {
    if (!StringUtils.hasText(line)) {
        prefix = null;
        return;
    }

    String trimmed = line.trim();
    Matcher prefixMatcher = PREFIX_PATTERN.matcher(trimmed);
    if (prefixMatcher.matches()) {
        prefix = prefixMatcher.group(1);
    }
    Matcher commandMatcher = COMMAND_PATTERN.matcher(trimmed);
    if (commandMatcher.matches()) {
        String command = commandMatcher.group(1);
        if (prefix != null) {
            command = prefix + ":" + command; // NOI18N
        }
        String description = commandMatcher.group(2);
        synchronized (commands) {
            commands.add(new SymfonyCommand(phpModule, command, description, command));
        }
    }
}
 
Example #6
Source File: OccurenceBuilder.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void buildDocTagsForClasses(ElementInfo nodeCtxInfo, FileScopeImpl fileScope, final List<Occurence> occurences) {
    Set<? extends PhpElement> elements = nodeCtxInfo.getDeclarations();
    for (PhpElement phpElement : elements) {
        for (Entry<PhpDocTypeTagInfo, Scope> entry : docTags.entrySet()) {
            if (CancelSupport.getDefault().isCancelled()) {
                return;
            }
            PhpDocTypeTagInfo nodeInfo = entry.getKey();
            final QualifiedName qualifiedName = VariousUtils.getFullyQualifiedName(nodeInfo.getQualifiedName(), nodeInfo.getOriginalNode().getStartOffset(), entry.getValue());
            final String name = CodeUtils.removeNullableTypePrefix(nodeInfo.getName());
            if (StringUtils.hasText(name) && NameKind.exact(name).matchesName(PhpElementKind.CLASS, phpElement.getName())
                    && NameKind.exact(qualifiedName).matchesName(phpElement)) {
                if (qualifiedName.getKind().isUnqualified()) {
                    occurences.add(new OccurenceImpl(ElementFilter.forFiles(fileScope.getFileObject()).prefer(elements), nodeInfo.getRange()));
                } else {
                    occurences.add(new OccurenceImpl(phpElement, nodeInfo.getRange()));
                }
            }
        }
    }
}
 
Example #7
Source File: PHP5ErrorHandlerImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages("SE_After=after")
public String createAfterText() {
    String result;
    String afterText = null;
    if (isValuableToken(token)) {
        afterText = getTokenTextForm(token.sym) + " '" + String.valueOf(token.value) + "'";
    } else {
        if (!isNodeToken()) {
            String previousText = getTokenTextForm(token.sym);
            if (StringUtils.hasText(previousText)) {
                afterText = previousText.trim();
            }
        }
    }
    if (afterText == null) {
        result = ""; //NOI18N
    } else {
        result = "\n " + Bundle.SE_After() + ":\t" + afterText; //NOI18N
    }
    return result;
}
 
Example #8
Source File: UserAnnotationPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "UserAnnotationPanel.error.noName=Name must be set.",
    "UserAnnotationPanel.error.noFor=At least one target must be set.",
    "UserAnnotationPanel.error.noTemplate=Template must be set."
})
void validateAnnotation() {
    if (!StringUtils.hasText(nameTextField.getText())) {
        setError(Bundle.UserAnnotationPanel_error_noName());
        return;
    }
    if (!anyTypeSelected()) {
        setError(Bundle.UserAnnotationPanel_error_noFor());
        return;
    }
    if (!StringUtils.hasText(templateTextField.getText())) {
        setError(Bundle.UserAnnotationPanel_error_noTemplate());
        return;
    }
    clearError();
}
 
Example #9
Source File: NewPhpProjectWizardIterator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void setIncludePath(PhpProject project, PhpProjectGenerator.ProjectProperties createProperties, EditableProperties projectProperties,
        EditableProperties privateProperties, List<PhpModuleProperties> phpModuleProperties) {
    if (phpModuleProperties.isEmpty()) {
        return;
    }

    for (PhpModuleProperties properties : phpModuleProperties) {
        List<String> customIncludePath = properties.getIncludePath();
        if (customIncludePath != null && !customIncludePath.isEmpty()) {
            Set<String> includePath = new LinkedHashSet<>();
            String current = projectProperties.getProperty(PhpProjectProperties.INCLUDE_PATH);
            if (StringUtils.hasText(current)) {
                includePath.add(current);
            }
            includePath.addAll(customIncludePath);
            IncludePathSupport includePathSupport = new IncludePathSupport(
                    ProjectPropertiesSupport.getPropertyEvaluator(project), project.getRefHelper(), project.getHelper());
            Iterator<Item> itemsIterator = includePathSupport.itemsIterator(
                    StringUtils.implode(new ArrayList<>(includePath), ":")); // NOI18N
            String[] encoded = includePathSupport.encodeToStrings(itemsIterator);
            projectProperties.setProperty(PhpProjectProperties.INCLUDE_PATH, encoded);
        }
    }
}
 
Example #10
Source File: FunctionScopeImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Add new return type but <b>only if the return type is not defined
 * in its declaration already</b> (in such a case, this new return type
 * is simply ignored).
 * @param type return type to be added
 */
public void addReturnType(String type) {
    if (declaredReturnType) {
        return;
    }
    synchronized (this) {
        if (!StringUtils.hasText(returnType)) {
            returnType = type;
        } else {
            Set<String> distinctTypes = new HashSet<>();
            distinctTypes.addAll(Arrays.asList(returnType.split(TYPE_SEPARATOR_REGEXP)));
            distinctTypes.add(type);
            returnType = StringUtils.implode(distinctTypes, TYPE_SEPARATOR);
        }
    }
}
 
Example #11
Source File: RemoteUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Sanitize upload directory, see issue #169793 for more information.
 * @param uploadDirectory upload directory to sanitize
 * @param allowEmpty <code>true</code> if the string can be empty
 * @return sanitized upload directory
 */
public static String sanitizeUploadDirectory(String uploadDirectory, boolean allowEmpty) {
    if (StringUtils.hasText(uploadDirectory)) {
        while (uploadDirectory.length() > 1
                && uploadDirectory.endsWith(TransferFile.REMOTE_PATH_SEPARATOR)) {
            uploadDirectory = uploadDirectory.substring(0, uploadDirectory.length() - 1);
        }
    } else if (!allowEmpty) {
        uploadDirectory = TransferFile.REMOTE_PATH_SEPARATOR;
    }
    if (allowEmpty
            && (uploadDirectory == null || TransferFile.REMOTE_PATH_SEPARATOR.equals(uploadDirectory))) {
        uploadDirectory = ""; // NOI18N
    }
    return uploadDirectory;
}
 
Example #12
Source File: RemoteUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Get parent path for the given path.
 * @param path file path
 * @return parent path or "/" for absolute top-level path
 * or {@code null} if parent path does not exist
 */
public static String getParentPath(String path) {
    if (path.equals(TransferFile.REMOTE_PATH_SEPARATOR)) {
        return null;
    }
    boolean absolute = path.startsWith(TransferFile.REMOTE_PATH_SEPARATOR);
    if (absolute) {
        path = path.substring(1);
    }
    String parent;
    List<String> parts = new ArrayList<>(StringUtils.explode(path, TransferFile.REMOTE_PATH_SEPARATOR));
    if (parts.size() <= 1) {
        return absolute ? TransferFile.REMOTE_PATH_SEPARATOR : null;
    }
    parts.remove(parts.size() - 1);
    parent = StringUtils.implode(parts, TransferFile.REMOTE_PATH_SEPARATOR);
    if (absolute) {
        return TransferFile.REMOTE_PATH_SEPARATOR + parent;
    }
    return parent;
}
 
Example #13
Source File: CommandUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
static String encodeRelativeUrl(String relativeUrl) {
    if (!StringUtils.hasText(relativeUrl)) {
        return relativeUrl;
    }
    StringBuilder sb = new StringBuilder(relativeUrl.length() * 2);
    try {
        for (String part : StringUtils.explode(relativeUrl, "/")) { // NOI18N
            if (sb.length() > 0) {
                sb.append('/'); // NOI18N
            }
            sb.append(URLEncoder.encode(part, "UTF-8")); // NOI18N
        }
    } catch (UnsupportedEncodingException ex) {
        Exceptions.printStackTrace(ex);
        return relativeUrl;
    }
    return sb.toString();
}
 
Example #14
Source File: RemoteValidator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "RemoteValidator.error.uploadDirectory.missing=Upload directory must be specified.",
    "# {0} - remote path separator",
    "RemoteValidator.error.uploadDirectory.start=Upload directory must start with \"{0}\".",
    "# {0} - invalid path separator",
    "RemoteValidator.error.uploadDirectory.content=Upload directory cannot contain \"{0}\"."
})
public static String validateUploadDirectory(String uploadDirectory) {
    if (!StringUtils.hasText(uploadDirectory)) {
        return Bundle.RemoteValidator_error_uploadDirectory_missing();
    } else if (!uploadDirectory.startsWith(TransferFile.REMOTE_PATH_SEPARATOR)) {
        return Bundle.RemoteValidator_error_uploadDirectory_start(TransferFile.REMOTE_PATH_SEPARATOR);
    } else if (uploadDirectory.contains(INVALID_SEPARATOR)) {
        return Bundle.RemoteValidator_error_uploadDirectory_content(INVALID_SEPARATOR);
    }
    return null;
}
 
Example #15
Source File: RunAsWebAdvanced.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Object[][] getPathMappings(String remotePaths, String localPaths) {
    List<String> remotes = StringUtils.explode(remotePaths, PhpProjectProperties.DEBUG_PATH_MAPPING_SEPARATOR);
    List<String> locals = StringUtils.explode(localPaths, PhpProjectProperties.DEBUG_PATH_MAPPING_SEPARATOR);
    int remotesSize = remotes.size();
    int localsSize = locals.size();
    Object[][] paths = new Object[remotesSize + 1][2];
    for (int i = 0; i < remotesSize; ++i) {
        // if user has only 1 path and local == sources => property is not stored at all!
        String local = DEFAULT_LOCAL_PATH;
        if (i < localsSize) {
            local = locals.get(i);
        }
        Pair<String, String> pathMapping = getPathMapping(remotes.get(i), local);
        paths[i][COLUMN_REMOTE_PATH] = pathMapping.first();
        paths[i][COLUMN_LOCAL_PATH] = new LocalPathCell(pathMapping.second());
    }
    paths[remotesSize][COLUMN_REMOTE_PATH] = null;
    paths[remotesSize][COLUMN_LOCAL_PATH] = new LocalPathCell(DEFAULT_LOCAL_PATH);
    return paths;
}
 
Example #16
Source File: ControllerVisitor.java    From cakephp3-netbeans with Apache License 2.0 6 votes vote down vote up
private void addModel(FunctionInvocation method) {
    List<Expression> parameters = method.getParameters();
    String tableName = ""; // NOI18N
    for (Expression parameter : parameters) {
        if (parameter instanceof Scalar) {
            tableName = CakePHPCodeUtils.getStringValue(parameter);
        }
        // only the first parameter
        break;
    }
    if (!StringUtils.isEmpty(tableName)) {
        Pair<String, PhpClass> phpClass = createPhpClass(Category.TABLE, tableName, ""); // NOI18N
        if (phpClass != null) {
            addPhpClasss(Category.TABLE, phpClass);
        }
    }
}
 
Example #17
Source File: RunConfigScript.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public String getHint() {
    StringBuilder sb = new StringBuilder(100);
    sb.append(interpreter);
    if (StringUtils.hasText(options)) {
        sb.append(" "); // NOI18N
        sb.append(options);
    }
    if (StringUtils.hasText(indexRelativePath)) {
        sb.append(" "); // NOI18N
        sb.append(indexRelativePath);
    }
    if (StringUtils.hasText(arguments)) {
        sb.append(" "); // NOI18N
        sb.append(arguments);
    }
    return sb.toString();
}
 
Example #18
Source File: RunConfigInternalValidator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages("RunConfigInternalValidator.router.label=Router")
private static String validate(RunConfigInternal config, boolean validateRouter) {
    String error;
    error = RemoteValidator.validateHost(config.getHostname());
    if (error != null) {
        return error;
    }
    error = RemoteValidator.validatePort(config.getPort());
    if (error != null) {
        return error;
    }
    if (validateRouter) {
        String routerRelativePath = config.getRouterRelativePath();
        if (StringUtils.hasText(routerRelativePath)) {
            error = BaseRunConfigValidator.validateRelativeFile(config.getWorkDir(), routerRelativePath, Bundle.RunConfigInternalValidator_router_label());
            if (error != null) {
                return error;
            }
        }
    }
    return null;
}
 
Example #19
Source File: ControllerVisitor.java    From cakephp3-netbeans with Apache License 2.0 5 votes vote down vote up
private void addComponent(FunctionInvocation method) {
    List<Expression> parameters = method.getParameters();
    Pair<String, String> aliasAndEntityName = CakePHPCodeUtils.getAliasAndEntityName(parameters);
    String aliasName = aliasAndEntityName.first();
    String entityName = aliasAndEntityName.second();
    if (!StringUtils.isEmpty(aliasName)) {
        if (StringUtils.isEmpty(entityName)) {
            entityName = aliasName;
        }
        Pair<String, PhpClass> phpClass = createPhpClass(Category.COMPONENT, aliasName, entityName);
        if (phpClass != null) {
            addPhpClasss(Category.COMPONENT, phpClass);
        }
    }
}
 
Example #20
Source File: MessDetector.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private List<String> getParameters(MessDetectorParams parameters, List<FileObject> files) {
    List<String> params = new ArrayList<>();
    // paths
    params.add(joinFilePaths(files));
    // report format
    params.add(REPORT_FORMAT_PARAM);
    // rule sets
    params.add(joinRuleSets(parameters.getRuleSets(), parameters.getRuleSetFile()));
    // extensions
    params.add(SUFFIXES_PARAM);
    params.add(StringUtils.implode(FileUtil.getMIMETypeExtensions(FileUtils.PHP_MIME_TYPE), ",")); // NOI18N
    // exclude
    addIgnoredFiles(params, files);
    return params;
}
 
Example #21
Source File: PhpUnitPreferences.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static String relativizePath(PhpModule phpModule, String filePath) {
    if (!StringUtils.hasText(filePath)) {
        return ""; // NOI18N
    }
    File file = new File(filePath);
    String path = PropertyUtils.relativizeFile(FileUtil.toFile(phpModule.getProjectDirectory()), file);
    if (path == null) {
        // sorry, cannot be relativized
        path = file.getAbsolutePath();
    }
    return path;
}
 
Example #22
Source File: RunAsWebAdvanced.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean isAnyRemotePathDefined() {
    for (int i = 0; i < pathMappingTableModel.getRowCount(); ++i) {
        String remotePath = (String) pathMappingTableModel.getValueAt(i, COLUMN_REMOTE_PATH);
        if (StringUtils.hasText(remotePath)) {
            return true;
        }
    }
    return false;
}
 
Example #23
Source File: ApiGenPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private List<String> getExcludes() {
    String excludes = excludesTextField.getText().trim();
    if (StringUtils.hasText(excludes)) {
        return StringUtils.explode(excludes, SEPARATOR);
    }
    return Collections.emptyList();
}
 
Example #24
Source File: IntroduceSuggestion.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void implement() throws Exception {
    final DataFolder dataFolder = DataFolder.findFolder(folder);
    final DataObject configDataObject = DataObject.find(template);
    final FileObject[] clsFo = new FileObject[1];
    FileUtil.runAtomicAction(new Runnable() {

        @Override
        public void run() {
            try {
                Map<String, String> parameters = new HashMap<>();
                if (StringUtils.hasText(nsPart)) {
                    parameters.put(NAMESPACE_PARAMETER_NAME, nsPart); //NOI18N
                }
                DataObject clsDataObject = configDataObject.createFromTemplate(dataFolder, className, parameters);
                clsFo[0] = clsDataObject.getPrimaryFile();
                FileObject fo = clsFo[0];
                FileLock lock = fo.lock();
                try {
                    fo.rename(lock, fo.getName(), "php"); //NOI18N
                } finally {
                    lock.releaseLock();
                }
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    });
    if (clsFo[0] != null) {
        UiUtils.open(clsFo[0], 0);
    }
}
 
Example #25
Source File: NewProjectConfigurationPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public String getErrorMessage() {
    if (otherCheckBox.isSelected()) {
        String otherAppName = getOtherAppName();
        if (!StringUtils.hasText(otherAppName)) {
            return NbBundle.getMessage(NewProjectConfigurationPanel.class, "MSG_NoAppName");
        } else if (!APP_NAME_PATTERN.matcher(otherAppName).matches()) {
            return NbBundle.getMessage(NewProjectConfigurationPanel.class, "MSG_InvalidAppName", otherAppName);
        }
    }
    return null;
}
 
Example #26
Source File: PHPStanAnalyzerImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@CheckForNull
private FileObject getValidPHPStanConfiguration() {
    String phpStanConfiguration = null;
    Preferences settings = context.getSettings();
    if (settings != null) {
        phpStanConfiguration = settings.get(PHPStanCustomizerPanel.CONFIGURATION, null);
    }
    if (phpStanConfiguration == null) {
        phpStanConfiguration = AnalysisOptions.getInstance().getPHPStanConfigurationPath();
    }
    if (StringUtils.isEmpty(phpStanConfiguration)) {
        return null;
    }
    return FileUtil.toFileObject(new File(phpStanConfiguration));
}
 
Example #27
Source File: RunConfigRemoteValidator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static String validateRemoteTransfer(RunConfigRemote config) {
    String error;
    error = validateRemoteConfiguration(config.getRemoteConfiguration());
    if (error != null) {
        return error;
    }
    String uploadDirectory = config.getUploadDirectory();
    if (StringUtils.hasText(uploadDirectory)) {
        error = validateUploadDirectory(uploadDirectory);
        if (error != null) {
            return error;
        }
    }
    return null;
}
 
Example #28
Source File: CakePHP3Visitor.java    From cakephp3-netbeans with Apache License 2.0 5 votes vote down vote up
@CheckForNull
public Pair<String, PhpClass> createPhpClass(Category category, String aliasName, String entityName) {
    if (StringUtils.isEmpty(aliasName)) {
        return null;
    }

    if (StringUtils.isEmpty(entityName)) {
        entityName = aliasName;
    }
    boolean isSame = aliasName.equals(entityName);
    // plugin?
    String pluginName = null;
    int dotPosition = entityName.indexOf("."); // NOI18N
    if (dotPosition > 0) {
        pluginName = entityName.substring(0, dotPosition);
        entityName = entityName.substring(dotPosition + 1);
        if (isSame) {
            aliasName = entityName;
        }
    }

    //get entity file
    FileObject entityFile = getEntityFile(category, entityName, pluginName);
    if (entityFile == null) {
        return null;
    }

    return createPhpClass(aliasName, entityFile);
}
 
Example #29
Source File: PhpElementImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized FileObject getFileObject() {
    String urlStr = fileUrl;
    if ((fileObject == null) && StringUtils.hasText(fileUrl)) {
        fileObject = resolveFileObject(urlStr);
    }
    return fileObject;
}
 
Example #30
Source File: FilePathParameter.java    From cakephp3-netbeans with Apache License 2.0 5 votes vote down vote up
private List<String> getCategoryElements(CakePHP3Module cakeModule, ModuleInfo info, String subpath, String filter, String pluginName, Category category) {
    Base base = info.getBase();
    if (StringUtils.isEmpty(pluginName)) {
        if (base == Base.PLUGIN) {
            pluginName = info.getPluginName();
        }
    } else {
        if (base != Base.PLUGIN) {
            base = Base.PLUGIN;
        }
    }
    // app or plugin
    List<FileObject> directories = cakeModule.getDirectories(base, category, pluginName);
    List<FileObject> coreDirectories;
    if (!StringUtils.isEmpty(pluginName)) {
        coreDirectories = Collections.emptyList();
    } else {
        coreDirectories = cakeModule.getDirectories(Base.CORE, category, null);
    }
    List<String> elements = new ArrayList<>();
    for (List<FileObject> targets : Arrays.asList(directories, coreDirectories)) {
        for (FileObject directory : targets) {
            FileObject baseDirectory = directory.getFileObject(subpath);
            if (baseDirectory != null) {
                for (FileObject child : baseDirectory.getChildren()) {
                    if (child.isFolder()) {
                        continue;
                    }
                    String name = child.getName();
                    name = ModuleUtils.toCommonName(name, category);
                    if (!elements.contains(name) && name.toLowerCase().startsWith(filter.toLowerCase())) {
                        elements.add(name);
                    }
                }
            }
        }
    }
    return elements;
}