URI (@Nullable GrExpression expression) { if (expression == null) return null; try { if (expression instanceof PsiLiteral) { URI uri = new URI(String.valueOf(((PsiLiteral)expression).getValue())); if (uri.getScheme() != null && StringUtil.startsWith(uri.getScheme(), "http")) return uri; } } catch (URISyntaxException ignored) { // ignore it } try { PsiReference reference = expression.getReference(); if (reference == null) return null; PsiElement element = reference.resolve(); if (element instanceof GrVariable) { List<GrLiteral> grLiterals = PsiTreeUtil.getChildrenOfTypeAsList(element, GrLiteral.class); if (grLiterals.isEmpty()) return null; URI uri = new URI(String.valueOf(grLiterals.get(0).getValue())); if (uri.getScheme() != null && StringUtil.startsWith("http", uri.getScheme())) return uri; } } catch (URISyntaxException ignored) { // ignore it } return null; }