Java Code Examples for java.nio.file.InvalidPathException#getMessage()

The following examples show how to use java.nio.file.InvalidPathException#getMessage() . 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: RefactoringHelper.java    From Refactoring-Bot with MIT License 5 votes vote down vote up
/**
 * @param targetClass
 * @param targetMethod
 * @return list of resolved classes and interfaces which are ancestors of the
 *         given classes (not including java.lang.Object or external
 *         dependencies) and contain the given target method
 * @throws BotRefactoringException
 */
private static Set<ResolvedReferenceTypeDeclaration> findAllAncestors(ClassOrInterfaceDeclaration targetClass,
		MethodDeclaration targetMethod) throws BotRefactoringException {
	List<ResolvedReferenceType> ancestors = new ArrayList<>();
	Set<ResolvedReferenceTypeDeclaration> result = new HashSet<>();

	try {
		ancestors = targetClass.resolve().getAllAncestors();
	} catch (UnsolvedSymbolException u) {
		ancestors = RefactoringHelper.getAllResolvableAncestors(targetClass.resolve());
		logger.warn("Refactored classes might extend/implement classes or interfaces from external dependency! "
				+ "Please validate the correctness of the refactoring.");
		// TODO propagate warning
	} catch (InvalidPathException i) {
		throw new BotRefactoringException("Javaparser could not parse file: " + i.getMessage());
	} catch (Exception e) {
		throw new BotRefactoringException("Error while resolving superclasses occured!");
	}

	for (ResolvedReferenceType ancestor : ancestors) {
		if (!ancestor.getQualifiedName().equals("java.lang.Object")) {
			for (ResolvedMethodDeclaration method : ancestor.getAllMethods()) {
				if (method.getSignature().equals(targetMethod.resolve().getSignature())) {
					result.add(ancestor.getTypeDeclaration());
				}
			}
		}
	}

	return result;
}
 
Example 2
Source File: PathParser.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Path parse(String text) throws ParseException {
    try {
        return Paths.get(text);
    } catch(InvalidPathException e) {
        throw new FormatException(e.getMessage());
    }
}
 
Example 3
Source File: PathUtil.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
/** @return a valid path from given pathString. 
 * @throws CommonException if a valid path could not be created. 
 * Given errorMessagePrefix will be used as a prefix in {@link CommonException}'s message. */
public static Path createPath(String pathString, String errorMessagePrefix) throws CommonException {
	try {
		return Paths.get(pathString);
	} catch (InvalidPathException ipe) {
		String pathMessage = ipe.getMessage();
		if(pathMessage == null) {
			pathMessage = ipe.toString();
		}
		throw new CommonException(errorMessagePrefix + pathMessage);
	}
}