Lines 84-90
Link Here
|
84 |
String ext = this.file.getExt(); |
84 |
String ext = this.file.getExt(); |
85 |
this.kind = FileObjects.getKind(ext); |
85 |
this.kind = FileObjects.getKind(ext); |
86 |
if (renderNow && this.kind == Kind.SOURCE) { |
86 |
if (renderNow && this.kind == Kind.SOURCE) { |
87 |
text = getCharContentImpl().toString(); |
87 |
getCharContentImpl(true); |
88 |
} |
88 |
} |
89 |
} |
89 |
} |
90 |
|
90 |
|
Lines 104-116
Link Here
|
104 |
return CharBuffer.wrap(_text); |
104 |
return CharBuffer.wrap(_text); |
105 |
} |
105 |
} |
106 |
else { |
106 |
else { |
107 |
return getCharContentImpl(); |
107 |
return getCharContentImpl(false); |
108 |
} |
108 |
} |
109 |
} |
109 |
} |
110 |
|
110 |
|
111 |
public TokenHierarchy<Void> getTokenHierarchy() throws IOException { |
111 |
public TokenHierarchy<Void> getTokenHierarchy() throws IOException { |
112 |
if (tokens == null) |
112 |
if (tokens == null) |
113 |
getCharContentImpl(); |
113 |
getCharContentImpl(false); |
114 |
|
114 |
|
115 |
return tokens; |
115 |
return tokens; |
116 |
} |
116 |
} |
Lines 326-357
Link Here
|
326 |
} |
326 |
} |
327 |
} |
327 |
} |
328 |
|
328 |
|
329 |
private CharBuffer getCharContentImpl () throws IOException { |
329 |
private CharBuffer getCharContentImpl (boolean assign) throws IOException { |
330 |
final Document doc = getDocument(isOpened()); |
330 |
final Document doc = getDocument(isOpened()); |
331 |
final char[][] result = new char[1][]; |
331 |
char[] result = null; |
332 |
final int[] length = new int[1]; |
332 |
int length = 0; |
333 |
if (doc == null) { |
333 |
if (doc == null) { |
334 |
Reader in = this.openReader (true); |
334 |
Reader in = this.openReader (true); |
335 |
int red = 0, rv; |
335 |
int red = 0, rv; |
336 |
try { |
336 |
try { |
337 |
int len = (int)this.file.getSize(); |
337 |
int len = (int)this.file.getSize(); |
338 |
result[0] = new char [len+1]; |
338 |
result = new char [len+1]; |
339 |
while ((rv=in.read(result[0],red,len-red))>0 && (red=red+rv)<len); |
339 |
while ((rv=in.read(result,red,len-red))>0 && (red=red+rv)<len); |
340 |
} finally { |
340 |
} finally { |
341 |
in.close(); |
341 |
in.close(); |
342 |
} |
342 |
} |
343 |
int j=0; |
343 |
int j=0; |
344 |
for (int i=0; i<red;i++) { |
344 |
for (int i=0; i<red;i++) { |
345 |
if (result[0][i] =='\r') { //NOI18N |
345 |
if (result[i] =='\r') { //NOI18N |
346 |
if (i+1>=red || result[0][i+1]!='\n') { //NOI18N |
346 |
if (i+1>=red || result[i+1]!='\n') { //NOI18N |
347 |
result[0][j++] = '\n'; //NOI18N |
347 |
result[j++] = '\n'; //NOI18N |
348 |
} |
348 |
} |
349 |
} |
349 |
} |
350 |
else { |
350 |
else { |
351 |
result[0][j++] = result[0][i]; |
351 |
result[j++] = result[i]; |
352 |
} |
352 |
} |
353 |
} |
353 |
} |
354 |
length[0] = j; |
354 |
length = j; |
355 |
} |
355 |
} |
356 |
else { |
356 |
else { |
357 |
final CharSequence[] _text = new CharSequence[1]; |
357 |
final CharSequence[] _text = new CharSequence[1]; |
Lines 369-382
Link Here
|
369 |
_text[0] = filter.filterCharSequence(_text[0]); |
369 |
_text[0] = filter.filterCharSequence(_text[0]); |
370 |
} |
370 |
} |
371 |
int len = _text[0].length(); |
371 |
int len = _text[0].length(); |
372 |
result[0] = new char[len+1]; |
372 |
result = new char[len+1]; |
373 |
_text[0].toString().getChars(0,len,result[0],0); |
373 |
_text[0].toString().getChars(0,len,result,0); |
374 |
length[0] = len; |
374 |
length = len; |
375 |
} |
375 |
} |
376 |
} |
376 |
} |
377 |
result[0][length[0]]='\n'; //NOI18N |
377 |
result[length]='\n'; //NOI18N |
378 |
CharBuffer charBuffer = CharBuffer.wrap (result[0],0,length[0]); |
378 |
|
|
|
379 |
String str = new String(result,0,length); |
380 |
CharBuffer charBuffer = CharBuffer.wrap (str); |
379 |
tokens = TokenHierarchy.create(charBuffer, false, JavaTokenId.language(), null, null); //TODO: .createSnapshot(); |
381 |
tokens = TokenHierarchy.create(charBuffer, false, JavaTokenId.language(), null, null); //TODO: .createSnapshot(); |
|
|
382 |
if (assign) text = str; |
380 |
return charBuffer; |
383 |
return charBuffer; |
381 |
} |
384 |
} |
382 |
|
385 |
|