|
Lines 35-40
Link Here
|
| 35 |
IDocument document = textViewer.getDocument(); |
35 |
IDocument document = textViewer.getDocument(); |
| 36 |
|
36 |
|
| 37 |
int offset = region.getOffset(); |
37 |
int offset = region.getOffset(); |
|
|
38 |
char doubleChar = ' '; |
| 38 |
|
39 |
|
| 39 |
String urlString = null; |
40 |
String urlString = null; |
| 40 |
if (document == null) { |
41 |
if (document == null) { |
|
Lines 68-74
Link Here
|
| 68 |
if (urlOffsetInLine > -1) { |
69 |
if (urlOffsetInLine > -1) { |
| 69 |
ch = line.charAt(urlOffsetInLine); |
70 |
ch = line.charAt(urlOffsetInLine); |
| 70 |
} |
71 |
} |
| 71 |
startDoubleQuote = ch == '"'; |
72 |
doubleChar = ch; |
|
|
73 |
switch (ch) { |
| 74 |
case '"': |
| 75 |
doubleChar = '"'; |
| 76 |
break; |
| 77 |
case '\'': |
| 78 |
doubleChar = '\''; |
| 79 |
break; |
| 80 |
case '[': |
| 81 |
doubleChar = ']'; |
| 82 |
break; |
| 83 |
case '(': |
| 84 |
doubleChar = ')'; |
| 85 |
break; |
| 86 |
case '{': |
| 87 |
doubleChar = '}'; |
| 88 |
break; |
| 89 |
|
| 90 |
default: |
| 91 |
doubleChar = ' '; |
| 92 |
break; |
| 93 |
} |
| 94 |
startDoubleQuote = doubleChar != ' '; |
| 72 |
} while (Character.isUnicodeIdentifierStart(ch)); |
95 |
} while (Character.isUnicodeIdentifierStart(ch)); |
| 73 |
urlOffsetInLine++; |
96 |
urlOffsetInLine++; |
| 74 |
|
97 |
|
|
Lines 93-99
Link Here
|
| 93 |
|
116 |
|
| 94 |
if (startDoubleQuote) { |
117 |
if (startDoubleQuote) { |
| 95 |
int endOffset = -1; |
118 |
int endOffset = -1; |
| 96 |
int nextDoubleQuote = line.indexOf('"', urlOffsetInLine); |
119 |
int nextDoubleQuote = line.indexOf(doubleChar, urlOffsetInLine); |
| 97 |
int nextWhitespace = line.indexOf(' ', urlOffsetInLine); |
120 |
int nextWhitespace = line.indexOf(' ', urlOffsetInLine); |
| 98 |
if (nextDoubleQuote != -1 && nextWhitespace != -1) { |
121 |
if (nextDoubleQuote != -1 && nextWhitespace != -1) { |
| 99 |
endOffset = Math.min(nextDoubleQuote, nextWhitespace); |
122 |
endOffset = Math.min(nextDoubleQuote, nextWhitespace); |
|
Lines 109-114
Link Here
|
| 109 |
|
132 |
|
| 110 |
// Set and validate URL string |
133 |
// Set and validate URL string |
| 111 |
try { |
134 |
try { |
|
|
135 |
char lastChar = line.charAt(urlOffsetInLine + urlLength - 1); |
| 136 |
if (lastChar == ',' || lastChar == '.') { |
| 137 |
urlLength--; |
| 138 |
} |
| 112 |
urlString = line.substring(urlOffsetInLine, urlOffsetInLine + urlLength); |
139 |
urlString = line.substring(urlOffsetInLine, urlOffsetInLine + urlLength); |
| 113 |
new URL(urlString); |
140 |
new URL(urlString); |
| 114 |
} catch (MalformedURLException ex) { |
141 |
} catch (MalformedURLException ex) { |