Lines 20-62
Link Here
|
20 |
import java.lang.ref.ReferenceQueue; |
20 |
import java.lang.ref.ReferenceQueue; |
21 |
import java.lang.ref.WeakReference; |
21 |
import java.lang.ref.WeakReference; |
22 |
import java.util.*; |
22 |
import java.util.*; |
23 |
import java.io.Reader; |
|
|
24 |
import java.io.InputStream; |
23 |
import java.io.InputStream; |
25 |
import java.io.IOException; |
24 |
import java.io.IOException; |
26 |
|
25 |
|
27 |
import javax.swing.event.ChangeListener; |
26 |
import javax.swing.event.ChangeListener; |
28 |
import javax.swing.event.ChangeEvent; |
27 |
import javax.swing.event.ChangeEvent; |
29 |
|
28 |
|
30 |
import javax.swing.text.Segment; |
|
|
31 |
import javax.swing.text.StyledDocument; |
32 |
import javax.swing.text.BadLocationException; |
33 |
import org.netbeans.api.java.classpath.ClassPath; |
29 |
import org.netbeans.api.java.classpath.ClassPath; |
34 |
|
30 |
|
35 |
import org.openide.cookies.SourceCookie; |
|
|
36 |
import org.openide.filesystems.FileObject; |
37 |
import org.openide.nodes.Node; |
31 |
import org.openide.nodes.Node; |
38 |
import org.openide.src.*; |
32 |
import org.openide.src.*; |
39 |
import org.openide.text.CloneableEditorSupport; |
33 |
import org.openide.text.CloneableEditorSupport; |
40 |
import org.openide.util.RequestProcessor; |
34 |
import org.openide.util.RequestProcessor; |
41 |
import org.openide.util.Task; |
35 |
import org.openide.util.Task; |
42 |
import org.openide.util.TaskListener; |
|
|
43 |
import org.openide.util.Utilities; |
36 |
import org.openide.util.Utilities; |
44 |
|
37 |
|
45 |
import org.netbeans.modules.java.bridge.ElementImpl; |
|
|
46 |
import org.netbeans.modules.java.bridge.DefaultLangModel; |
47 |
import org.netbeans.modules.java.bridge.WrapperFactory; |
48 |
import org.netbeans.modules.java.bridge.LangModel; |
38 |
import org.netbeans.modules.java.bridge.LangModel; |
49 |
import org.netbeans.modules.java.bridge.CommitListener; |
39 |
import org.netbeans.modules.java.bridge.CommitListener; |
50 |
import org.netbeans.modules.java.bridge.SrcElementImpl; |
40 |
import org.netbeans.modules.java.bridge.SrcElementImpl; |
51 |
|
41 |
|
52 |
import org.netbeans.modules.java.codegen.DocumentBinding; |
42 |
import org.netbeans.modules.java.codegen.DocumentBinding; |
53 |
import org.netbeans.modules.java.codegen.SourceText; |
|
|
54 |
import org.netbeans.modules.java.ParserEngine; |
43 |
import org.netbeans.modules.java.ParserEngine; |
55 |
import org.netbeans.modules.java.ElementFactory; |
44 |
import org.netbeans.modules.java.ElementFactory; |
56 |
import org.netbeans.modules.java.ErrConsumer; |
|
|
57 |
import org.netbeans.modules.java.JavaDataObject; |
58 |
import org.netbeans.modules.java.Parsing; |
59 |
|
60 |
import org.netbeans.modules.java.JavaDataObject; |
45 |
import org.netbeans.modules.java.JavaDataObject; |
61 |
|
46 |
|
62 |
/** |
47 |
/** |
Lines 72-79
Link Here
|
72 |
*/ |
57 |
*/ |
73 |
public class ParsingSupport implements JavaParser { |
58 |
public class ParsingSupport implements JavaParser { |
74 |
|
59 |
|
75 |
private static final int READ_THRESHOLD = 2048; |
|
|
76 |
|
77 |
private PropertyChangeSupport propSupport; |
60 |
private PropertyChangeSupport propSupport; |
78 |
|
61 |
|
79 |
public static final String PROP_STATUS = "status"; // NOI18N |
62 |
public static final String PROP_STATUS = "status"; // NOI18N |
Lines 374-389
Link Here
|
374 |
fireStateChange(); |
357 |
fireStateChange(); |
375 |
} |
358 |
} |
376 |
|
359 |
|
377 |
private void fireParsingEvent(final Collection messages) { |
|
|
378 |
final Object hook = getSourceImpl(); |
379 |
|
380 |
EVENT_RP.post(new Runnable() { |
381 |
public void run() { |
382 |
Parsing.fireEvent(jdo, messages); |
383 |
} |
384 |
}); |
385 |
} |
386 |
|
387 |
protected void fireStateChange() { |
360 |
protected void fireStateChange() { |
388 |
if (changeList == null) |
361 |
if (changeList == null) |
389 |
return; |
362 |
return; |
Lines 577-599
Link Here
|
577 |
} |
550 |
} |
578 |
} |
551 |
} |
579 |
|
552 |
|
580 |
private void updateModel() throws SourceException { |
|
|
581 |
model.removePreCommitListener(this); |
582 |
if (getSyntaxErrors() > 0 && !errorsOK) { |
583 |
// don't update the model at all. |
584 |
resultStatus = SourceElement.STATUS_PARTIAL; |
585 |
return; |
586 |
} |
587 |
if (isValid()) { |
588 |
// we have the write lock, noone changed the model |
589 |
// since we started. |
590 |
|
591 |
// SUCCESS (?) |
592 |
resultStatus = getSyntaxErrors() > 0 ? |
593 |
SourceElement.STATUS_PARTIAL : SourceElement.STATUS_OK; |
594 |
} |
595 |
} |
596 |
|
597 |
private void parseLockModel() throws SourceException { |
553 |
private void parseLockModel() throws SourceException { |
598 |
model.addPreCommitListener(this); |
554 |
model.addPreCommitListener(this); |
599 |
resultStatus = -1; |
555 |
resultStatus = -1; |
Lines 629-643
Link Here
|
629 |
} |
585 |
} |
630 |
|
586 |
|
631 |
public void complete() { |
587 |
public void complete() { |
632 |
Collection messages; |
|
|
633 |
|
634 |
synchronized (ParsingSupport.this) { |
588 |
synchronized (ParsingSupport.this) { |
635 |
if (currentRequest == this) |
589 |
if (currentRequest == this) |
636 |
currentRequest = null; |
590 |
currentRequest = null; |
637 |
messages = request.getMessages(); |
|
|
638 |
} |
591 |
} |
639 |
changeStatus(resultStatus); |
592 |
changeStatus(resultStatus); |
640 |
fireParsingEvent(messages); |
|
|
641 |
task.complete(); |
593 |
task.complete(); |
642 |
if (chained != null) |
594 |
if (chained != null) |
643 |
chained.complete(); |
595 |
chained.complete(); |
Lines 724-733
Link Here
|
724 |
return request.getParserType(); |
676 |
return request.getParserType(); |
725 |
} |
677 |
} |
726 |
|
678 |
|
727 |
public ErrConsumer getErrConsumer() { |
|
|
728 |
return request.getErrConsumer(); |
729 |
} |
730 |
|
731 |
public String getSourceName() { |
679 |
public String getSourceName() { |
732 |
return request.getSourceName(); |
680 |
return request.getSourceName(); |
733 |
} |
681 |
} |
Lines 767-780
Link Here
|
767 |
/* --------------------------------------------------------------------*/ |
715 |
/* --------------------------------------------------------------------*/ |
768 |
static RequestProcessor PARSING_RP; |
716 |
static RequestProcessor PARSING_RP; |
769 |
|
717 |
|
770 |
/** processor dedicated for parser events. */ |
|
|
771 |
private static RequestProcessor EVENT_RP; |
772 |
|
773 |
private void addRequest(Processor proc, int priority) { |
718 |
private void addRequest(Processor proc, int priority) { |
774 |
synchronized (this) { |
719 |
synchronized (this) { |
775 |
if (PARSING_RP == null) { |
720 |
if (PARSING_RP == null) { |
776 |
PARSING_RP = new RequestProcessor("Java source parsing"); // NOI18N |
721 |
PARSING_RP = new RequestProcessor("Java source parsing"); // NOI18N |
777 |
EVENT_RP = new RequestProcessor("Java Parser Event Queue"); // NOI18N |
|
|
778 |
} |
722 |
} |
779 |
if (currentRequest != proc) { |
723 |
if (currentRequest != proc) { |
780 |
if (currentRequest != null) |
724 |
if (currentRequest != null) |
Lines 797-803
Link Here
|
797 |
} |
741 |
} |
798 |
|
742 |
|
799 |
protected void notifyFinalized(Reference refImpl) { |
743 |
protected void notifyFinalized(Reference refImpl) { |
800 |
int oldStatus; |
|
|
801 |
|
744 |
|
802 |
synchronized (this) { |
745 |
synchronized (this) { |
803 |
if (refImplementation != refImpl) |
746 |
if (refImplementation != refImpl) |
Lines 816-823
Link Here
|
816 |
} |
759 |
} |
817 |
|
760 |
|
818 |
public void run() { |
761 |
public void run() { |
819 |
Reference f; |
|
|
820 |
|
821 |
ParsingSupport supp = (ParsingSupport)refSupp.get(); |
762 |
ParsingSupport supp = (ParsingSupport)refSupp.get(); |
822 |
if (supp != null) |
763 |
if (supp != null) |
823 |
supp.notifyFinalized(this); |
764 |
supp.notifyFinalized(this); |