Java Code Examples for org.netbeans.modules.php.api.util.StringUtils#implode()

The following examples show how to use org.netbeans.modules.php.api.util.StringUtils#implode() . 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: 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 2
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 3
Source File: PHPCodeTemplateProcessor.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private String getNextVariableType() {
    if (!initParsing()) {
        return null;
    }
    final int offset = request.getComponent().getCaretPosition();
    Collection<? extends VariableName> declaredVariables = getDeclaredVariables(offset);
    String varName = getNextVariableName();
    if (varName == null || declaredVariables == null) {
        return null;
    }
    if (varName.charAt(0) != '$') {
        varName = "$" + varName; //NOI18N
    }

    List<? extends VariableName> variables = ModelUtils.filter(declaredVariables, varName);
    VariableName first = ModelUtils.getFirst(variables);
    if (first != null) {
        String typeNames = StringUtils.implode(getUniqueTypeNames(first, offset), "|"); // NOI18N
        if (!StringUtils.hasText(typeNames)) {
            return null;
        }
        return typeNames;
    }
    return null;
}
 
Example 4
Source File: TransferFile.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Get remote (platform independent) path of the parent file
 * or throws an exception if the file is {@link #isProjectRoot() project root}.
 * <p>
 * This method can be used to get parent directory even if {@link #getParent() parent}
 * is not set.
 * @return remote path of the parent file
 * @see #getRemotePath()
 */
public final String getParentRemotePath() {
    if (getParent() != null) {
        return getParent().getRemotePath();
    }
    List<String> fragments = new ArrayList<>(StringUtils.explode(getRemotePath(), REMOTE_PATH_SEPARATOR));
    fragments.remove(fragments.size() - 1);
    if (fragments.isEmpty()) {
        return REMOTE_PROJECT_ROOT;
    }
    return StringUtils.implode(fragments, REMOTE_PATH_SEPARATOR);
}
 
Example 5
Source File: PhpAnnotationsPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages("PhpAnnotationsPanel.value.delimiter=, ")
private String getTypes(EnumSet<UserAnnotationTag.Type> types) {
    ArrayList<String> list = new ArrayList<>(types.size());
    for (UserAnnotationTag.Type type : types) {
        list.add(type.getTitle());
    }
    return StringUtils.implode(list, Bundle.PhpAnnotationsPanel_value_delimiter());
}
 
Example 6
Source File: UserAnnotations.java    From netbeans with Apache License 2.0 5 votes vote down vote up
String marshallTypes(EnumSet<UserAnnotationTag.Type> types) {
    ArrayList<String> list = new ArrayList<>(types.size());
    for (UserAnnotationTag.Type type : types) {
        list.add(type.name());
    }
    return StringUtils.implode(list, DELIMITER);
}
 
Example 7
Source File: SeeLineParser.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private String createDescription(String[] tokens) {
    List<String> descriptionTokens = new LinkedList<>();
    for (int i = 1; i < tokens.length; i++) {
        descriptionTokens.add(tokens[i]);
    }
    return StringUtils.implode(descriptionTokens, DELIMITER);
}
 
Example 8
Source File: PhpExecutable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static String getInfoCommand(List<String> fullCommand) {
    List<String> escapedCommand = new ArrayList<>(fullCommand.size());
    for (String command : fullCommand) {
        escapedCommand.add("\"" + command.replace("\"", "\\\"") + "\""); // NOI18N
    }
    return StringUtils.implode(escapedCommand, " "); // NOI18N
}
 
Example 9
Source File: AnalysisUtils.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static String serialize(List<String> input) {
    return StringUtils.implode(input, SERIALIZE_DELIMITER);
}
 
Example 10
Source File: FrameworkCommand.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 * Get the full form of this command (e.g. suitable for preview).
 * @return the full form of this command.
 */
public String getPreview() {
    return StringUtils.implode(Arrays.asList(commands), " "); // NOI18N
}