This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 64410
Collapse All | Expand All

(-)java/src/org/netbeans/modules/java/JavaDataLoader.java (-6 lines)
Lines 19-25 Link Here
19
import java.io.InputStream;
19
import java.io.InputStream;
20
import java.io.ObjectInput;
20
import java.io.ObjectInput;
21
import java.text.DateFormat;
21
import java.text.DateFormat;
22
import java.util.ArrayList;
23
import java.util.Collection;
22
import java.util.Collection;
24
import java.util.Date;
23
import java.util.Date;
25
import java.util.LinkedList;
24
import java.util.LinkedList;
Lines 56-66 Link Here
56
    
55
    
57
    public static final String PROP_PARSER_ENGINE = "parserEngine"; // NOI18N
56
    public static final String PROP_PARSER_ENGINE = "parserEngine"; // NOI18N
58
        
57
        
59
    /** The list of parsing listener - the instance is in this class, because JavaDataLoader
60
    * class is prevented to be garbage collected.
61
    */
62
    static ArrayList parsingListeners = new ArrayList();
63
    
64
    static final long serialVersionUID =-6286836352608877232L;
58
    static final long serialVersionUID =-6286836352608877232L;
65
59
66
    /** Create the loader.
60
    /** Create the loader.
(-)java/src/org/netbeans/modules/java/parser/DefaultWrapper.java (-2 lines)
Lines 15-23 Link Here
15
15
16
import org.openide.src.*;
16
import org.openide.src.*;
17
17
18
import org.netbeans.modules.java.bridge.Binding;
19
import org.netbeans.modules.java.bridge.WrapperFactory;
18
import org.netbeans.modules.java.bridge.WrapperFactory;
20
import org.netbeans.modules.java.bridge.BindingFactory;
21
import org.netbeans.modules.java.bridge.ImportElement;
19
import org.netbeans.modules.java.bridge.ImportElement;
22
20
23
/**
21
/**
(-)java/src/org/netbeans/modules/java/parser/ParseObjectRequest.java (-4 lines)
Lines 14-23 Link Here
14
package org.netbeans.modules.java.parser;
14
package org.netbeans.modules.java.parser;
15
15
16
import org.netbeans.modules.java.ElementFactory;
16
import org.netbeans.modules.java.ElementFactory;
17
import org.netbeans.modules.java.ErrConsumer;
18
import java.io.IOException;
17
import java.io.IOException;
19
import java.io.InputStream;
18
import java.io.InputStream;
20
import java.io.Reader;
21
import java.util.Collection;
19
import java.util.Collection;
22
import org.netbeans.api.java.classpath.ClassPath;
20
import org.netbeans.api.java.classpath.ClassPath;
23
21
Lines 95-102 Link Here
95
     * request */
93
     * request */
96
    public Collection getMessages();
94
    public Collection getMessages();
97
   
95
   
98
    public ErrConsumer getErrConsumer();
99
    
100
    public String getSourceName();
96
    public String getSourceName();
101
    
97
    
102
    public ClassPath getLibraryPath();
98
    public ClassPath getLibraryPath();
(-)java/src/org/netbeans/modules/java/parser/ParseSourceRequest.java (-33 / +2 lines)
Lines 7-13 Link Here
7
 * http://www.sun.com/
7
 * http://www.sun.com/
8
 *
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
12
 */
13
package org.netbeans.modules.java.parser;
13
package org.netbeans.modules.java.parser;
Lines 25-41 Link Here
25
import org.openide.text.CloneableEditorSupport;
25
import org.openide.text.CloneableEditorSupport;
26
26
27
import org.netbeans.modules.java.ElementFactory;
27
import org.netbeans.modules.java.ElementFactory;
28
import org.netbeans.modules.java.ErrConsumer;
29
import org.netbeans.modules.java.JavaDataObject;
30
import org.netbeans.modules.java.Util;
28
import org.netbeans.modules.java.Util;
31
import org.netbeans.modules.java.settings.JavaSettings;
32
29
33
/**
30
/**
34
 *
31
 *
35
 * @author  sdedic
32
 * @author  sdedic
36
 * @version
37
 */
33
 */
38
public class ParseSourceRequest implements ParsableObjectRequest, ErrConsumer {
34
public class ParseSourceRequest implements ParsableObjectRequest {
39
    public static final int     STATE_WAITING = 0;
35
    public static final int     STATE_WAITING = 0;
40
    public static final int     STATE_READING = 1;
36
    public static final int     STATE_READING = 1;
41
    public static final int     STATE_CANCELLED = 2;
37
    public static final int     STATE_CANCELLED = 2;
Lines 43-50 Link Here
43
    public static final int     STATE_UPDATING = 4;
39
    public static final int     STATE_UPDATING = 4;
44
    public static final int     STATE_COMPLETED = 10;
40
    public static final int     STATE_COMPLETED = 10;
45
41
46
    private static final int READ_THRESHOLD = 2048;
47
48
    JavaParser.Env          environment;
42
    JavaParser.Env          environment;
49
    ChangeListener          listener;
43
    ChangeListener          listener;
50
    int                     state;
44
    int                     state;
Lines 77-84 Link Here
77
    }
71
    }
78
72
79
    public ParseSourceRequest(Object parserType) {
73
    public ParseSourceRequest(Object parserType) {
80
        JavaSettings settings=JavaSettings.getDefault();
81
82
        this.parserType = parserType;
74
        this.parserType = parserType;
83
        state = STATE_WAITING;
75
        state = STATE_WAITING;
84
        valid = true;
76
        valid = true;
Lines 223-251 Link Here
223
215
224
    public Object getParserType() {
216
    public Object getParserType() {
225
        return parserType;
217
        return parserType;
226
    }
227
228
    public ErrConsumer getErrConsumer() {
229
        if (JavaParser.DEEP_PARSER.equals(getParserType())) {
230
            return this;
231
        }
232
        // null IS intentional for the shallow parser. Before you change it
233
        // be aware of JavaEditor.processAnnotations(ParserMessage[] errors) depends on it
234
        return null;
235
    }
236
237
    public void pushError(Object severity, FileObject errorFile, int line, int column, String message, String referenceText) {
238
        Integer lineInt;
239
240
        if (errorFile != null && !errorFile.getNameExt().equals(getSourceName()))
241
            return;             // error in different file
242
243
        ParserMessageImpl newErr =
244
            new ParserMessageImpl(severity,line,column,message);
245
        if (errors == null) {
246
            errors = new ArrayList(50);
247
        }
248
        errors.add(newErr);
249
    }
218
    }
250
219
251
    /** @return the set of errors encountered while processing this
220
    /** @return the set of errors encountered while processing this
(-)java/src/org/netbeans/modules/java/parser/ParsingSupport.java (-59 lines)
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);
(-)java/src/org/netbeans/modules/java/parser/ProcessorObjectRequest.java (-1 lines)
Lines 18-24 Link Here
18
package org.netbeans.modules.java.parser;
18
package org.netbeans.modules.java.parser;
19
19
20
import org.openide.text.CloneableEditorSupport;
20
import org.openide.text.CloneableEditorSupport;
21
import org.netbeans.modules.java.parser.JavaParser;
22
21
23
/**
22
/**
24
 *
23
 *

Return to bug 64410