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 258520
Collapse All | Expand All

(-)a/csl.api/apichanges.xml (+21 lines)
Lines 49-54 Link Here
49
<apidef name="csl.api">Common Scripting Language API</apidef>
49
<apidef name="csl.api">Common Scripting Language API</apidef>
50
</apidefs>
50
</apidefs>
51
<changes>
51
<changes>
52
    <change id="TypesSplit">
53
        <summary>Separate common non UI classes</summary>
54
        <version major="2" minor="54"/>
55
        <date day="31" month="3" year="2016"/>
56
        <author login="phejl"/>
57
        <compatibility addition="no" deletion="yes" modification="no" binary="compatible" source="incompatible" deprecation="no"/>
58
        <description>
59
            <p>
60
                Seperating the common non UI classes to avoid Swing dependency in dependent projects.
61
            </p>
62
        </description>
63
        <class package="org.netbeans.modules.csl.api" name="Documentation" link="no"/>
64
        <class package="org.netbeans.modules.csl.api" name="ElementHandle" link="no"/>
65
        <class package="org.netbeans.modules.csl.api" name="ElementKind" link="no"/>
66
        <class package="org.netbeans.modules.csl.api" name="Error" link="no"/>
67
        <class package="org.netbeans.modules.csl.api" name="Modifier" link="no"/>
68
        <class package="org.netbeans.modules.csl.api" name="OffsetRange" link="no"/>
69
        <class package="org.netbeans.modules.csl.api" name="Severity" link="no"/>
70
        <class package="org.netbeans.modules.csl.spi" name="ParserResult" link="no"/>
71
        <issue number="258520"/>
72
    </change>
52
    <change id="CancelSuppport">
73
    <change id="CancelSuppport">
53
        <api name="csl.api"/>
74
        <api name="csl.api"/>
54
        <summary>Added <code>CancelSupport</code> to allow scanners and other CSL services to check task cancelling</summary>
75
        <summary>Added <code>CancelSupport</code> to allow scanners and other CSL services to check task cancelling</summary>
(-)a/csl.api/module-auto-deps.xml (+61 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
5
Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
6
7
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
8
Other names may be trademarks of their respective owners.
9
10
The contents of this file are subject to the terms of either the GNU
11
General Public License Version 2 only ("GPL") or the Common
12
Development and Distribution License("CDDL") (collectively, the
13
"License"). You may not use this file except in compliance with the
14
License. You can obtain a copy of the License at
15
http://www.netbeans.org/cddl-gplv2.html
16
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
17
specific language governing permissions and limitations under the
18
License.  When distributing the software, include this License Header
19
Notice in each file and include the License file at
20
nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
21
particular file as subject to the "Classpath" exception as provided
22
by Oracle in the GPL Version 2 section of the License file that
23
accompanied this code. If applicable, add the following below the
24
License Header, with the fields enclosed by brackets [] replaced by
25
your own identifying information:
26
"Portions Copyrighted [year] [name of copyright owner]"
27
28
Contributor(s):
29
30
The Original Software is NetBeans. The Initial Developer of the Original
31
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
32
Microsystems, Inc. All Rights Reserved.
33
34
If you wish your version of this file to be governed by only the CDDL
35
or only the GPL Version 2, indicate your decision by adding
36
"[Contributor] elects to include this software in this distribution
37
under the [CDDL or GPL Version 2] license." If you do not indicate a
38
single choice of license, a recipient has the option to distribute
39
your version of this file under either the CDDL, the GPL Version 2 or
40
to extend the choice of license to its licensees as provided above.
41
However, if you add GPL Version 2 code and therefore, elected the GPL
42
Version 2 license, then the option applies only if the new code is
43
made subject to such option by the copyright holder.
44
-->
45
<!DOCTYPE transformations PUBLIC "-//NetBeans//DTD Module Automatic Dependencies 1.0//EN" "http://www.netbeans.org/dtds/module-auto-deps-1_0.dtd">
46
<transformations version="1.0">
47
    <transformationgroup>
48
        <description>Splitting parts of csl.api off into csl.types</description>
49
        <transformation>
50
            <trigger-dependency type="older">
51
                <module-dependency codenamebase="org.netbeans.modules.csl.api" major="2" spec="2.54"/>
52
            </trigger-dependency>
53
            <implies>
54
                <result>
55
                    <module-dependency codenamebase="org.netbeans.modules.csl.types" major="1" spec="1.0"/>
56
                </result>
57
            </implies>
58
        </transformation>
59
    </transformationgroup>
60
</transformations>
61
(-)a/csl.api/nbproject/project.properties (-1 / +1 lines)
Lines 40-46 Link Here
40
# Version 2 license, then the option applies only if the new code is
40
# Version 2 license, then the option applies only if the new code is
41
# made subject to such option by the copyright holder.
41
# made subject to such option by the copyright holder.
42
42
43
spec.version.base=2.53.0
43
spec.version.base=2.54.0
44
is.autoload=true
44
is.autoload=true
45
javac.source=1.7
45
javac.source=1.7
46
46
(-)a/csl.api/nbproject/project.xml (+9 lines)
Lines 59-64 Link Here
59
                    </run-dependency>
59
                    </run-dependency>
60
                </dependency>
60
                </dependency>
61
                <dependency>
61
                <dependency>
62
                    <code-name-base>org.netbeans.modules.csl.types</code-name-base>
63
                    <build-prerequisite/>
64
                    <compile-dependency/>
65
                    <run-dependency>
66
                        <release-version>0-1</release-version>
67
                        <specification-version>1.0</specification-version>
68
                    </run-dependency>
69
                </dependency>
70
                <dependency>
62
                    <code-name-base>org.netbeans.modules.diff</code-name-base>
71
                    <code-name-base>org.netbeans.modules.diff</code-name-base>
63
                    <build-prerequisite/>
72
                    <build-prerequisite/>
64
                    <compile-dependency/>
73
                    <compile-dependency/>
(-)a/csl.api/src/org/netbeans/modules/csl/api/Documentation.java (-99 lines)
Lines 1-99 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.csl.api;
43
44
import java.net.URL;
45
import org.netbeans.api.annotations.common.CheckForNull;
46
import org.netbeans.api.annotations.common.NonNull;
47
import org.openide.util.Parameters;
48
49
/**
50
 * Represents documentation displayed in code completion window.
51
 *
52
 * @author Petr Hejl
53
 * @since 2.43
54
 */
55
public final class Documentation {
56
57
    private final String content;
58
59
    private final URL url;
60
61
    private Documentation(String content, URL url) {
62
        assert content != null;
63
        this.content = content;
64
        this.url = url;
65
    }
66
67
    @NonNull
68
    public static Documentation create(@NonNull String content) {
69
        Parameters.notNull("content", content);
70
        return new Documentation(content, null);
71
    }
72
73
    @NonNull
74
    public static Documentation create(@NonNull String content, URL url) {
75
        Parameters.notNull("content", content);
76
        return new Documentation(content, url);
77
    }
78
79
    /**
80
     * The documentation itself.
81
     *
82
     * @return documentation itself
83
     */
84
    @NonNull
85
    public String getContent() {
86
        return content;
87
    }
88
89
    /**
90
     * The external documentation URL. Might be {@code null}.
91
     *
92
     * @return external documentation URL
93
     */
94
    @CheckForNull
95
    public URL getUrl() {
96
        return url;
97
    }
98
99
}
(-)a/csl.api/src/org/netbeans/modules/csl/api/ElementHandle.java (-149 lines)
Lines 1-149 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.csl.api;
46
47
import java.util.Collections;
48
import java.util.Set;
49
import org.netbeans.api.annotations.common.CheckForNull;
50
import org.netbeans.api.annotations.common.NonNull;
51
import org.netbeans.modules.csl.spi.ParserResult;
52
import org.openide.filesystems.FileObject;
53
54
/**
55
 * Based on org.netbeans.modules.gsfpath.api.source by Tomas Zezula
56
 *
57
 * @author Tor Norbye
58
 */
59
public interface ElementHandle {
60
    /** 
61
     * Return the FileObject associated with this handle, or null
62
     * if the file is unknown or in a parse tree (in which case the
63
     * file object is the same as the file object in the CompilationInfo
64
     * for the root of the parse tree.
65
     */
66
    @CheckForNull
67
    FileObject getFileObject();
68
    
69
    /**
70
     * The mime type associated with this element. This is typically
71
     * used to identify the type of element in embedded scenarios.
72
     */
73
    @CheckForNull
74
    String getMimeType();
75
76
    @NonNull
77
    String getName();
78
79
    @CheckForNull
80
    String getIn();
81
82
    @NonNull
83
    ElementKind getKind();
84
85
    @NonNull
86
    Set<Modifier> getModifiers();
87
    
88
    /** 
89
     * Tests if the handle has the same signature as the parameter.
90
     * @param handle to be checked
91
     * @return true if the handles refer to elements with the same signature
92
     */
93
    boolean signatureEquals (@NonNull final ElementHandle handle);
94
95
    OffsetRange getOffsetRange(@NonNull ParserResult result);
96
97
    /** 
98
     * A special handle which holds URL. Can be used to handle documentation
99
     * requests etc.
100
     */
101
    public static class UrlHandle implements ElementHandle {
102
        private String url;
103
104
        public UrlHandle(@NonNull String url) {
105
            this.url = url;
106
        }
107
108
        public FileObject getFileObject() {
109
            return null;
110
        }
111
        
112
        public String getMimeType() {
113
            return null;
114
        }
115
116
        public boolean signatureEquals(ElementHandle handle) {
117
            if (handle instanceof UrlHandle) {
118
                return url.equals(((UrlHandle)handle).url);
119
            }
120
            
121
            return false;
122
        }
123
124
        public OffsetRange getOffsetRange(@NonNull ParserResult result) {
125
            return null;
126
        }
127
128
        @NonNull
129
        public String getUrl() {
130
            return url;
131
        }
132
133
        public String getName() {
134
            return url;
135
        }
136
137
        public String getIn() {
138
            return null;
139
        }
140
141
        public ElementKind getKind() {
142
            return ElementKind.OTHER;
143
        }
144
145
        public Set<Modifier> getModifiers() {
146
            return Collections.emptySet();
147
        }
148
    }
149
}
(-)a/csl.api/src/org/netbeans/modules/csl/api/ElementKind.java (-55 lines)
Lines 1-55 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.csl.api;
46
47
/**
48
 *
49
 * @author Tor Norbye
50
 */
51
public enum ElementKind {
52
    CONSTRUCTOR, MODULE, PACKAGE, CLASS, METHOD, FIELD, VARIABLE,
53
    ATTRIBUTE, CONSTANT, KEYWORD, OTHER, PARAMETER, GLOBAL,
54
    PROPERTY, ERROR, DB, CALL, TAG, RULE, FILE, TEST, INTERFACE
55
}
(-)a/csl.api/src/org/netbeans/modules/csl/api/Error.java (-144 lines)
Lines 1-144 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.csl.api;
46
47
import org.netbeans.api.annotations.common.CheckForNull;
48
import org.netbeans.api.annotations.common.NonNull;
49
import org.openide.filesystems.FileObject;
50
51
/**
52
 * This represents an error registered for the current java source,
53
 * possibly with associated fix proposals.
54
 *
55
 * @todo Add a getArgs() method etc. such that error messages can be parameterized; see javax.tools.DiagnosticMessage
56
 *
57
 * @author Tor Norbye
58
 */
59
public interface Error  {
60
    /**
61
     * Provide a short user-visible (and therefore localized) description of this error
62
     */
63
    @NonNull
64
    String getDisplayName();
65
66
    /**
67
     * Provide a full sentence description of this item, suitable for display in a tooltip
68
     * for example
69
     */
70
    @CheckForNull
71
    String getDescription();
72
73
    /**
74
     * Return a unique id/key for this error, such as "compiler.err.abstract.cant.be.instantiated".
75
     * This key is used for error hints providers.
76
     */
77
    @CheckForNull
78
    String getKey();
79
    
80
    ///** 
81
    // * Get the fixes associated with this error 
82
    // */
83
    //Collection<Fix> getFixes();
84
    //
85
    ///** 
86
    // * Register a fix proposal for this error 
87
    // */
88
    //void addFix(Fix fix);
89
    
90
    /**
91
     * Get the file object associated with this error, if any
92
     */
93
    @CheckForNull
94
    FileObject getFile();
95
96
    /**
97
     * Get the position of the error in the parsing input source (in other words,
98
     * this is the AST-based offset and may need translation to obtain the document
99
     * offset in documents with an embedding model.)
100
     */
101
    int getStartPosition();
102
    
103
    /**
104
     * Get the end offset of the error in the parsing input source (in other words,
105
     * this is the AST-based offset and may need translation to obtain the document
106
     * offset in documents with an embedding model.).
107
     * 
108
     * @return The end position, or -1 if unknown.
109
     */
110
    int getEndPosition();
111
    
112
    /**
113
     * Defines the way how an error annotation for this error behaves in the editor.
114
     * 
115
     * @return true if the error annotation should span over the whole line, false if 
116
     * the annotation is restricted exactly by the range defined by getStart/EndPostion() 
117
     */
118
    boolean isLineError();
119
120
    /**
121
     *  Get the severity of this error
122
     */
123
    @NonNull
124
    Severity getSeverity();
125
    
126
    /**
127
     * Return optional parameters for this message. The parameters may
128
     * provide the specific unknown symbol name for an unknown symbol error,
129
     * etc.
130
     */
131
    @CheckForNull
132
    Object[] getParameters();
133
134
    /**Error that may be used to show error badge in the projects tab.
135
     * @since 1.18
136
     */
137
    public interface Badging extends Error {
138
        /**Whether or not the error should be used to show error badge in the projects tab.
139
         *
140
         * @return true if this error should be used to show error badge in the projects tab.
141
         */
142
        public boolean showExplorerBadge();
143
    }
144
}
(-)a/csl.api/src/org/netbeans/modules/csl/api/Modifier.java (-53 lines)
Lines 1-53 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.csl.api;
46
47
/**
48
 *
49
 * @author Tor Norbye
50
 */
51
public enum Modifier {
52
    PUBLIC, STATIC, PROTECTED, PRIVATE, DEPRECATED, ABSTRACT
53
}
(-)a/csl.api/src/org/netbeans/modules/csl/api/OffsetRange.java (-200 lines)
Lines 1-200 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
package org.netbeans.modules.csl.api;
45
46
/**
47
 * An offset range provides a range (start, end) pair of offsets
48
 * that indicate a range in a character buffer. The range represented
49
 * is {@code [start,end>}, which means that the range includes the
50
 * character at index=start, and ends right before the character at end.
51
 * Put yet another way, the starting offset is inclusive, and the ending
52
 * offset is exclusive.
53
 *
54
 * @todo This class should be final
55
 * 
56
 * @author Tor Norbye
57
 */
58
public final class OffsetRange implements Comparable<OffsetRange> {
59
    public static final OffsetRange NONE = new OffsetRange(0, 0);
60
    private final int start;
61
    private final int end;
62
63
    /** Creates a new instance of OffsetRange */
64
    public OffsetRange(int start, int end) {
65
        assert start >= 0 : "Invalid start:" + start;
66
        assert end >= start : "Invalid start:" + start + " end:" + end;
67
68
        this.start = start;
69
        this.end = end;
70
    }
71
72
    /** Get the start offset of offset range */
73
    public int getStart() {
74
        return start;
75
    }
76
77
    /** Get the end offset of offset range */
78
    public int getEnd() {
79
        return end;
80
    }
81
    
82
    /** Get the length of the offset range */
83
    public int getLength() {
84
        return getEnd()-getStart();
85
    }
86
87
    /**
88
     * Return true if the given range overlaps with the current range.
89
     * Full containment one way or the other is also considered overlapping.
90
     */
91
    public boolean overlaps(OffsetRange range) {
92
        if (range == OffsetRange.NONE) {
93
            return false;
94
        } else if (this == OffsetRange.NONE) {
95
            return false;
96
        } else {
97
            return end > range.start && start < range.end;
98
        }
99
    }
100
101
    /**
102
     * Create a new OffsetRange that bounds the current OffsetRange with the given range.
103
     * (e.g. an intersection)
104
     * @param minimumStart The minimum starting position. Both the start and end
105
     *   will be at least this value.
106
     * @param maximumEnd The maximum ending position. Both the start and end will
107
     *   be at most this value.
108
     * @return A new offset range limited to the given bounds.
109
     */
110
    public OffsetRange boundTo(int minimumStart, int maximumEnd) {
111
        assert minimumStart <= maximumEnd;
112
        assert this != OffsetRange.NONE;
113
114
        int newStart = start;
115
        int newEnd = end;
116
        if (newEnd > maximumEnd) {
117
            newEnd = maximumEnd;
118
            if (newStart > maximumEnd) {
119
                newStart = maximumEnd;
120
            }
121
        }
122
        if (newStart < minimumStart) {
123
            newStart = minimumStart;
124
            if (newEnd < minimumStart) {
125
                newEnd = minimumStart;
126
            }
127
        }
128
129
        return new OffsetRange(newStart, newEnd);
130
    }
131
132
    @Override
133
    public String toString() {
134
        if (this == NONE) {
135
            return "OffsetRange[NONE]";
136
        } else {
137
            return "OffsetRange[" + start + "," + end + ">"; // NOI18N
138
        }
139
    }
140
141
    @Override
142
    public boolean equals(Object o) {
143
        if (o == null) {
144
            return false;
145
        }
146
147
        if (o.getClass() != OffsetRange.class) {
148
            return false;
149
        }
150
151
        final OffsetRange test = (OffsetRange)o;
152
153
        if (this.start != test.start) {
154
            return false;
155
        }
156
157
        if (this.end != test.end) {
158
            return false;
159
        }
160
161
        return true;
162
    }
163
164
    @Override
165
    public int hashCode() {
166
        // OffsetRanges are typically not overlapping so the start is as
167
        // good a hash as any.
168
        //int hash = 7;
169
        //
170
        //hash = (23 * hash) + this.start;
171
        //hash = (23 * hash) + this.end;
172
        //
173
        //return hash;
174
        return start;
175
    }
176
177
    /** Return true iff the given offset is within the bounds (or at the bounds) of the range */
178
    public boolean containsInclusive(int offset) {
179
        if (this == NONE) {
180
            return false;
181
        }
182
183
        return (offset >= getStart()) && (offset <= getEnd());
184
    }
185
    
186
    public int compareTo(OffsetRange o) {
187
        if (start != o.start) {
188
            return start - o.start;
189
        } else {
190
            // Most GSF services do not allow overlapping offset ranges!
191
            //assert end == o.end : this;
192
            
193
            return end - o.end;
194
        }
195
    }
196
    
197
    public boolean isEmpty() {
198
        return start == end;
199
    }
200
}
(-)a/csl.api/src/org/netbeans/modules/csl/api/Severity.java (-61 lines)
Lines 1-61 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.csl.api;
46
47
/**
48
 * Types of severities (generally for Errors)
49
 * @author Tor Norbye
50
 */
51
public enum Severity {
52
    /** Just an informational hint */
53
    INFO,
54
    /** The error is only a warning; may be correct, may not be, but user should be alerted */
55
    WARNING,
56
    /** The error is a problem that must be dealt with */
57
    ERROR,
58
    /** The fatal error is a problem that usually affects the further file analysis and
59
     must be inevitably fixed */    
60
    FATAL;
61
}
(-)a/csl.api/src/org/netbeans/modules/csl/spi/ParserResult.java (-66 lines)
Lines 1-66 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.csl.spi;
44
45
import java.util.List;
46
import org.netbeans.modules.csl.api.Error;
47
import org.netbeans.modules.parsing.api.Snapshot;
48
import org.netbeans.modules.parsing.spi.Parser;
49
50
/**
51
 *
52
 * @author hanz
53
 */
54
public abstract class ParserResult extends Parser.Result {
55
56
    protected ParserResult(Snapshot snapshot) {
57
        super(snapshot);
58
    }
59
60
    public abstract List<? extends Error> getDiagnostics ();
61
62
}
63
64
65
66
(-)a/csl.api/test/unit/src/org/netbeans/modules/csl/api/OffsetRangeTest.java (-142 lines)
Lines 1-142 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.csl.api;
46
47
import org.netbeans.modules.csl.api.OffsetRange;
48
import org.netbeans.junit.NbTestCase;
49
50
/**
51
 * @author Tor Norbye
52
 */
53
public class OffsetRangeTest extends NbTestCase {
54
55
    public OffsetRangeTest(String testName) {
56
        super(testName);
57
    }
58
59
    public void testOverlaps() {
60
        OffsetRange range1 = new OffsetRange(1, 4);
61
        OffsetRange range2 = new OffsetRange(2, 6);
62
        OffsetRange range3 = new OffsetRange(4, 6);
63
        OffsetRange range4 = new OffsetRange(0, 1);
64
        OffsetRange range5 = new OffsetRange(0, 6);
65
        assertTrue(range1.overlaps(range2));
66
        assertTrue(range2.overlaps(range1));
67
        assertFalse(range1.overlaps(range3));
68
        assertFalse(range3.overlaps(range1));
69
        assertFalse(range1.overlaps(range4));
70
        assertFalse(range4.overlaps(range1));
71
        assertTrue(range1.overlaps(range5));
72
        assertTrue(range5.overlaps(range1));
73
        
74
        assertFalse(range1.overlaps(OffsetRange.NONE));
75
        assertFalse(OffsetRange.NONE.overlaps(range5));
76
        assertFalse(OffsetRange.NONE.overlaps(OffsetRange.NONE));
77
    }
78
    
79
    public void testGetStart() {
80
        OffsetRange range = new OffsetRange(1, 4);
81
        assertEquals(1, range.getStart());
82
    }
83
84
    public void testGetEnd() {
85
        OffsetRange range = new OffsetRange(1, 4);
86
        assertEquals(4, range.getEnd());
87
    }
88
89
    public void testGetLength() {
90
        OffsetRange range = new OffsetRange(1, 4);
91
        assertEquals(3, range.getLength());
92
    }
93
94
    public void testContainsInclusive() {
95
        OffsetRange range = new OffsetRange(1, 4);
96
        assertTrue(range.containsInclusive(1));
97
        assertTrue(range.containsInclusive(3));
98
        assertTrue(range.containsInclusive(4));
99
        assertFalse(range.containsInclusive(5));
100
        assertFalse(range.containsInclusive(0));
101
    }
102
    
103
    public void testEquals() {
104
        assertEquals(new OffsetRange(1,3), new OffsetRange(1,3));
105
        assertEquals(new OffsetRange(0,0), new OffsetRange(0,0));
106
        assertFalse(new OffsetRange(1,3).equals(new Object()));
107
108
        boolean success = false;
109
        try {
110
            // Should generate an assertion!
111
            new OffsetRange(9,8);
112
        } catch (AssertionError e) {
113
            success = true;
114
        }
115
        assertTrue(success);
116
    }
117
    
118
    public void testComparator() {
119
        assertTrue(new OffsetRange(1,3).compareTo(new OffsetRange(3,5)) < 0);
120
        assertTrue(new OffsetRange(3,5).compareTo(new OffsetRange(1,3)) > 0);
121
        assertTrue(new OffsetRange(3,5).compareTo(new OffsetRange(3,5)) == 0);
122
        assertTrue(new OffsetRange(1,3).compareTo(new OffsetRange(1,5)) < 0);
123
        assertTrue(new OffsetRange(1,5).compareTo(new OffsetRange(1,3)) > 0);
124
    }
125
    
126
    public void testEmpty() {
127
        assertTrue(new OffsetRange(5,5).isEmpty());
128
        assertFalse(new OffsetRange(5,6).isEmpty());
129
    }
130
131
    public void testBoundTo() {
132
        assertEquals(new OffsetRange(1,3), new OffsetRange(1,3).boundTo(1, 3));
133
        assertEquals(new OffsetRange(1,3), new OffsetRange(0,4).boundTo(1, 3));
134
        assertEquals(new OffsetRange(1,3), new OffsetRange(1,3).boundTo(0, 4));
135
        assertEquals(new OffsetRange(1,2), new OffsetRange(1,3).boundTo(0, 2));
136
        assertEquals(new OffsetRange(2,3), new OffsetRange(1,3).boundTo(2, 4));
137
        assertEquals(new OffsetRange(2,2), new OffsetRange(1,3).boundTo(2, 2));
138
        assertEquals(new OffsetRange(101,101), new OffsetRange(102,103).boundTo(0, 101));
139
        assertEquals(new OffsetRange(100,101), new OffsetRange(100,103).boundTo(0, 101));
140
        assertEquals(new OffsetRange(100,100), new OffsetRange(90,95).boundTo(100, 150));
141
    }
142
}
(-)a/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java (-1 / +1 lines)
Lines 740-746 Link Here
740
740
741
        // If both values are true it means the content is the same, but some lines are
741
        // If both values are true it means the content is the same, but some lines are
742
        // placed on a different line number in actual and expected content
742
        // placed on a different line number in actual and expected content
743
        if (noErrorInActual && noErrorInExpected) {
743
        if (noErrorInActual && noErrorInExpected && expectedLines.size() == actualLines.size()) {
744
            for (int lineNumber = 0; lineNumber < expectedLines.size(); lineNumber++) {
744
            for (int lineNumber = 0; lineNumber < expectedLines.size(); lineNumber++) {
745
                String expectedLine = expectedLines.get(lineNumber);
745
                String expectedLine = expectedLines.get(lineNumber);
746
                String actualLine = actualLines.get(lineNumber);
746
                String actualLine = actualLines.get(lineNumber);
(-)a/api.progress.nb/apichanges.xml (-15 / +20 lines)
Lines 101-126 Link Here
101
101
102
    <!-- First, a list of API names you may use: -->
102
    <!-- First, a list of API names you may use: -->
103
    <apidefs>
103
    <apidefs>
104
        <apidef name="ProgressSwing">Progress API - Swing extensions</apidef>
104
        <apidef name="csl.api.types">Common CSL API types</apidef>
105
        <apidef name="csl.spi.types">Common CSL SPI types</apidef>
105
        <!-- etc. -->
106
        <!-- etc. -->
106
    </apidefs>
107
    </apidefs>
107
108
108
    <!-- ACTUAL CHANGES BEGIN HERE: -->
109
    <!-- ACTUAL CHANGES BEGIN HERE: -->
109
  <changes>
110
  <changes>
110
      <change id="swingSplit">
111
      <change id="TypesSplit">
111
          <api name="ProgressSwing"/>
112
          <summary>Separate common non UI classes</summary>
112
          <summary>
113
          <version major="1" minor="0"/>
113
              Swing dependencies separated into a new module.
114
          <date day="31" month="3" year="2016"/>
114
          </summary>
115
          <author login="phejl"/>
115
          <version major="1" minor="40"/>
116
          <compatibility binary="compatible" source="incompatible" deprecation="no" deletion="no" addition="yes"/>
116
          <date day="18" month="9" year="2014"/>
117
          <author login="sdedic"/>
118
          <compatibility binary="compatible" source="incompatible" deprecation="yes" deletion="yes" addition="yes"/>
119
          <description>
117
          <description>
120
              Progress API was split so that parts that are directly connected to Swing types were migrated
118
              Seperating the common non UI classes to avoid Swing dependency in dependent projects.
121
              to a separate module. 
122
          </description>
119
          </description>
123
          <issue number="247111"/>
120
          <class package="org.netbeans.modules.csl.api" name="Documentation"/>
121
          <class package="org.netbeans.modules.csl.api" name="ElementHandle"/>
122
          <class package="org.netbeans.modules.csl.api" name="ElementKind"/>
123
          <class package="org.netbeans.modules.csl.api" name="Error"/>
124
          <class package="org.netbeans.modules.csl.api" name="Modifier"/>
125
          <class package="org.netbeans.modules.csl.api" name="OffsetRange"/>
126
          <class package="org.netbeans.modules.csl.api" name="Severity"/>
127
          <class package="org.netbeans.modules.csl.spi" name="ParserResult"/>
128
          <issue number="258520"/>
124
      </change>
129
      </change>
125
  </changes>
130
  </changes>
126
131
Lines 139-145 Link Here
139
144
140
-->
145
-->
141
    <head>
146
    <head>
142
      <title>Change History for the Progress API - Swing</title>
147
      <title>Change History for the Common CSL types</title>
143
      <link rel="stylesheet" href="prose.css" type="text/css"/>
148
      <link rel="stylesheet" href="prose.css" type="text/css"/>
144
    </head>
149
    </head>
145
    <body>
150
    <body>
Lines 152-158 Link Here
152
157
153
<!-- The actual lists of changes, as summaries and details: -->
158
<!-- The actual lists of changes, as summaries and details: -->
154
159
155
      <hr/><standard-changelists module-code-name="org.netbeans.api.progress.nb"/>
160
      <hr/><standard-changelists module-code-name="org.netbeans.module.csl.types"/>
156
161
157
      <hr/><p>@FOOTER@</p>
162
      <hr/><p>@FOOTER@</p>
158
163
(-)a/api.progress.nb/arch.xml (-4 / +9 lines)
Lines 5-11 Link Here
5
5
6
<api-answers
6
<api-answers
7
  question-version="1.29"
7
  question-version="1.29"
8
  author="yourname@netbeans.org"
8
  author="phejl@netbeans.org"
9
>
9
>
10
10
11
  &api-questions;
11
  &api-questions;
Lines 29-37 Link Here
29
-->
29
-->
30
 <answer id="arch-overall">
30
 <answer id="arch-overall">
31
  <p>
31
  <p>
32
    <api name="ProgressSwing" group="java" type="export" category="official" 
32
    <api name="csl.api.types" group="java" type="export" category="official" 
33
         url="@org-netbeans-api-progress@/index.html"/>   
33
         url="@TOP@org/netbeans/modules/csl/api/package-summary.html"/>   
34
    Part of Progress API specialized for Swing UIs.
34
    Common CSL non UI API classes.
35
  </p>
36
  <p>
37
    <api name="csl.spi.types" group="java" type="export" category="official" 
38
         url="@TOP@org/netbeans/modules/csl/spi/package-summary.html"/>   
39
    Common CSL non UI SPI classes.
35
  </p>
40
  </p>
36
 </answer>
41
 </answer>
37
42
(-)a/csl.types/build.xml (+5 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project basedir="." default="netbeans" name="csl.types">
3
    <description>Builds, tests, and runs the project org.netbeans.modules.csl.types</description>
4
    <import file="../nbbuild/templates/projectized.xml"/>
5
</project>
(-)a/csl.types/manifest.mf (+6 lines)
Line 0 Link Here
1
Manifest-Version: 1.0
2
AutoUpdate-Show-In-Client: false
3
OpenIDE-Module: org.netbeans.modules.csl.types/1
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/csl/types/Bundle.properties
5
OpenIDE-Module-Specification-Version: 1.0
6
(-)a/csl.types/nbproject/project.properties (+6 lines)
Line 0 Link Here
1
is.autoload=true
2
javac.source=1.7
3
javac.compilerargs=-Xlint -Xlint:-serial
4
5
javadoc.arch=${basedir}/arch.xml
6
javadoc.apichanges=${basedir}/apichanges.xml
(-)a/csl.types/nbproject/project.xml (+63 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://www.netbeans.org/ns/project/1">
3
    <type>org.netbeans.modules.apisupport.project</type>
4
    <configuration>
5
        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
6
            <code-name-base>org.netbeans.modules.csl.types</code-name-base>
7
            <module-dependencies>
8
                <dependency>
9
                    <code-name-base>org.netbeans.api.annotations.common</code-name-base>
10
                    <build-prerequisite/>
11
                    <compile-dependency/>
12
                    <run-dependency>
13
                        <release-version>1</release-version>
14
                        <specification-version>1.27</specification-version>
15
                    </run-dependency>
16
                </dependency>
17
                <dependency>
18
                    <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
19
                    <build-prerequisite/>
20
                    <compile-dependency/>
21
                    <run-dependency>
22
                        <release-version>1</release-version>
23
                        <specification-version>9.6</specification-version>
24
                    </run-dependency>
25
                </dependency>
26
                <dependency>
27
                    <code-name-base>org.openide.filesystems</code-name-base>
28
                    <build-prerequisite/>
29
                    <compile-dependency/>
30
                    <run-dependency>
31
                        <specification-version>9.10</specification-version>
32
                    </run-dependency>
33
                </dependency>
34
                <dependency>
35
                    <code-name-base>org.openide.util</code-name-base>
36
                    <build-prerequisite/>
37
                    <compile-dependency/>
38
                    <run-dependency>
39
                        <specification-version>9.7</specification-version>
40
                    </run-dependency>
41
                </dependency>
42
            </module-dependencies>
43
            <test-dependencies>
44
                <test-type>
45
                    <name>unit</name>
46
                    <test-dependency>
47
                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
48
                        <compile-dependency/>
49
                    </test-dependency>
50
                    <test-dependency>
51
                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
52
                        <recursive/>
53
                        <compile-dependency/>
54
                    </test-dependency>
55
                </test-type>
56
            </test-dependencies>
57
            <public-packages>
58
                <package>org.netbeans.modules.csl.api</package>
59
                <package>org.netbeans.modules.csl.spi</package>
60
            </public-packages>
61
        </data>
62
    </configuration>
63
</project>
(-)a/csl.types/src/org/netbeans/modules/csl/api/Documentation.java (+99 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.csl.api;
43
44
import java.net.URL;
45
import org.netbeans.api.annotations.common.CheckForNull;
46
import org.netbeans.api.annotations.common.NonNull;
47
import org.openide.util.Parameters;
48
49
/**
50
 * Represents documentation displayed in code completion window.
51
 *
52
 * @author Petr Hejl
53
 * @since 2.43
54
 */
55
public final class Documentation {
56
57
    private final String content;
58
59
    private final URL url;
60
61
    private Documentation(String content, URL url) {
62
        assert content != null;
63
        this.content = content;
64
        this.url = url;
65
    }
66
67
    @NonNull
68
    public static Documentation create(@NonNull String content) {
69
        Parameters.notNull("content", content);
70
        return new Documentation(content, null);
71
    }
72
73
    @NonNull
74
    public static Documentation create(@NonNull String content, URL url) {
75
        Parameters.notNull("content", content);
76
        return new Documentation(content, url);
77
    }
78
79
    /**
80
     * The documentation itself.
81
     *
82
     * @return documentation itself
83
     */
84
    @NonNull
85
    public String getContent() {
86
        return content;
87
    }
88
89
    /**
90
     * The external documentation URL. Might be {@code null}.
91
     *
92
     * @return external documentation URL
93
     */
94
    @CheckForNull
95
    public URL getUrl() {
96
        return url;
97
    }
98
99
}
(-)a/csl.types/src/org/netbeans/modules/csl/api/ElementHandle.java (+149 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.csl.api;
46
47
import java.util.Collections;
48
import java.util.Set;
49
import org.netbeans.api.annotations.common.CheckForNull;
50
import org.netbeans.api.annotations.common.NonNull;
51
import org.netbeans.modules.csl.spi.ParserResult;
52
import org.openide.filesystems.FileObject;
53
54
/**
55
 * Based on org.netbeans.modules.gsfpath.api.source by Tomas Zezula
56
 *
57
 * @author Tor Norbye
58
 */
59
public interface ElementHandle {
60
    /** 
61
     * Return the FileObject associated with this handle, or null
62
     * if the file is unknown or in a parse tree (in which case the
63
     * file object is the same as the file object in the CompilationInfo
64
     * for the root of the parse tree.
65
     */
66
    @CheckForNull
67
    FileObject getFileObject();
68
    
69
    /**
70
     * The mime type associated with this element. This is typically
71
     * used to identify the type of element in embedded scenarios.
72
     */
73
    @CheckForNull
74
    String getMimeType();
75
76
    @NonNull
77
    String getName();
78
79
    @CheckForNull
80
    String getIn();
81
82
    @NonNull
83
    ElementKind getKind();
84
85
    @NonNull
86
    Set<Modifier> getModifiers();
87
    
88
    /** 
89
     * Tests if the handle has the same signature as the parameter.
90
     * @param handle to be checked
91
     * @return true if the handles refer to elements with the same signature
92
     */
93
    boolean signatureEquals (@NonNull final ElementHandle handle);
94
95
    OffsetRange getOffsetRange(@NonNull ParserResult result);
96
97
    /** 
98
     * A special handle which holds URL. Can be used to handle documentation
99
     * requests etc.
100
     */
101
    public static class UrlHandle implements ElementHandle {
102
        private String url;
103
104
        public UrlHandle(@NonNull String url) {
105
            this.url = url;
106
        }
107
108
        public FileObject getFileObject() {
109
            return null;
110
        }
111
        
112
        public String getMimeType() {
113
            return null;
114
        }
115
116
        public boolean signatureEquals(ElementHandle handle) {
117
            if (handle instanceof UrlHandle) {
118
                return url.equals(((UrlHandle)handle).url);
119
            }
120
            
121
            return false;
122
        }
123
124
        public OffsetRange getOffsetRange(@NonNull ParserResult result) {
125
            return null;
126
        }
127
128
        @NonNull
129
        public String getUrl() {
130
            return url;
131
        }
132
133
        public String getName() {
134
            return url;
135
        }
136
137
        public String getIn() {
138
            return null;
139
        }
140
141
        public ElementKind getKind() {
142
            return ElementKind.OTHER;
143
        }
144
145
        public Set<Modifier> getModifiers() {
146
            return Collections.emptySet();
147
        }
148
    }
149
}
(-)a/csl.types/src/org/netbeans/modules/csl/api/ElementKind.java (+55 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.csl.api;
46
47
/**
48
 *
49
 * @author Tor Norbye
50
 */
51
public enum ElementKind {
52
    CONSTRUCTOR, MODULE, PACKAGE, CLASS, METHOD, FIELD, VARIABLE,
53
    ATTRIBUTE, CONSTANT, KEYWORD, OTHER, PARAMETER, GLOBAL,
54
    PROPERTY, ERROR, DB, CALL, TAG, RULE, FILE, TEST, INTERFACE
55
}
(-)a/csl.types/src/org/netbeans/modules/csl/api/Error.java (+144 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.csl.api;
46
47
import org.netbeans.api.annotations.common.CheckForNull;
48
import org.netbeans.api.annotations.common.NonNull;
49
import org.openide.filesystems.FileObject;
50
51
/**
52
 * This represents an error registered for the current java source,
53
 * possibly with associated fix proposals.
54
 *
55
 * @todo Add a getArgs() method etc. such that error messages can be parameterized; see javax.tools.DiagnosticMessage
56
 *
57
 * @author Tor Norbye
58
 */
59
public interface Error  {
60
    /**
61
     * Provide a short user-visible (and therefore localized) description of this error
62
     */
63
    @NonNull
64
    String getDisplayName();
65
66
    /**
67
     * Provide a full sentence description of this item, suitable for display in a tooltip
68
     * for example
69
     */
70
    @CheckForNull
71
    String getDescription();
72
73
    /**
74
     * Return a unique id/key for this error, such as "compiler.err.abstract.cant.be.instantiated".
75
     * This key is used for error hints providers.
76
     */
77
    @CheckForNull
78
    String getKey();
79
    
80
    ///** 
81
    // * Get the fixes associated with this error 
82
    // */
83
    //Collection<Fix> getFixes();
84
    //
85
    ///** 
86
    // * Register a fix proposal for this error 
87
    // */
88
    //void addFix(Fix fix);
89
    
90
    /**
91
     * Get the file object associated with this error, if any
92
     */
93
    @CheckForNull
94
    FileObject getFile();
95
96
    /**
97
     * Get the position of the error in the parsing input source (in other words,
98
     * this is the AST-based offset and may need translation to obtain the document
99
     * offset in documents with an embedding model.)
100
     */
101
    int getStartPosition();
102
    
103
    /**
104
     * Get the end offset of the error in the parsing input source (in other words,
105
     * this is the AST-based offset and may need translation to obtain the document
106
     * offset in documents with an embedding model.).
107
     * 
108
     * @return The end position, or -1 if unknown.
109
     */
110
    int getEndPosition();
111
    
112
    /**
113
     * Defines the way how an error annotation for this error behaves in the editor.
114
     * 
115
     * @return true if the error annotation should span over the whole line, false if 
116
     * the annotation is restricted exactly by the range defined by getStart/EndPostion() 
117
     */
118
    boolean isLineError();
119
120
    /**
121
     *  Get the severity of this error
122
     */
123
    @NonNull
124
    Severity getSeverity();
125
    
126
    /**
127
     * Return optional parameters for this message. The parameters may
128
     * provide the specific unknown symbol name for an unknown symbol error,
129
     * etc.
130
     */
131
    @CheckForNull
132
    Object[] getParameters();
133
134
    /**Error that may be used to show error badge in the projects tab.
135
     * @since 1.18
136
     */
137
    public interface Badging extends Error {
138
        /**Whether or not the error should be used to show error badge in the projects tab.
139
         *
140
         * @return true if this error should be used to show error badge in the projects tab.
141
         */
142
        public boolean showExplorerBadge();
143
    }
144
}
(-)a/csl.types/src/org/netbeans/modules/csl/api/Modifier.java (+53 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.csl.api;
46
47
/**
48
 *
49
 * @author Tor Norbye
50
 */
51
public enum Modifier {
52
    PUBLIC, STATIC, PROTECTED, PRIVATE, DEPRECATED, ABSTRACT
53
}
(-)a/csl.types/src/org/netbeans/modules/csl/api/OffsetRange.java (+200 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
package org.netbeans.modules.csl.api;
45
46
/**
47
 * An offset range provides a range (start, end) pair of offsets
48
 * that indicate a range in a character buffer. The range represented
49
 * is {@code [start,end>}, which means that the range includes the
50
 * character at index=start, and ends right before the character at end.
51
 * Put yet another way, the starting offset is inclusive, and the ending
52
 * offset is exclusive.
53
 *
54
 * @todo This class should be final
55
 * 
56
 * @author Tor Norbye
57
 */
58
public final class OffsetRange implements Comparable<OffsetRange> {
59
    public static final OffsetRange NONE = new OffsetRange(0, 0);
60
    private final int start;
61
    private final int end;
62
63
    /** Creates a new instance of OffsetRange */
64
    public OffsetRange(int start, int end) {
65
        assert start >= 0 : "Invalid start:" + start;
66
        assert end >= start : "Invalid start:" + start + " end:" + end;
67
68
        this.start = start;
69
        this.end = end;
70
    }
71
72
    /** Get the start offset of offset range */
73
    public int getStart() {
74
        return start;
75
    }
76
77
    /** Get the end offset of offset range */
78
    public int getEnd() {
79
        return end;
80
    }
81
    
82
    /** Get the length of the offset range */
83
    public int getLength() {
84
        return getEnd()-getStart();
85
    }
86
87
    /**
88
     * Return true if the given range overlaps with the current range.
89
     * Full containment one way or the other is also considered overlapping.
90
     */
91
    public boolean overlaps(OffsetRange range) {
92
        if (range == OffsetRange.NONE) {
93
            return false;
94
        } else if (this == OffsetRange.NONE) {
95
            return false;
96
        } else {
97
            return end > range.start && start < range.end;
98
        }
99
    }
100
101
    /**
102
     * Create a new OffsetRange that bounds the current OffsetRange with the given range.
103
     * (e.g. an intersection)
104
     * @param minimumStart The minimum starting position. Both the start and end
105
     *   will be at least this value.
106
     * @param maximumEnd The maximum ending position. Both the start and end will
107
     *   be at most this value.
108
     * @return A new offset range limited to the given bounds.
109
     */
110
    public OffsetRange boundTo(int minimumStart, int maximumEnd) {
111
        assert minimumStart <= maximumEnd;
112
        assert this != OffsetRange.NONE;
113
114
        int newStart = start;
115
        int newEnd = end;
116
        if (newEnd > maximumEnd) {
117
            newEnd = maximumEnd;
118
            if (newStart > maximumEnd) {
119
                newStart = maximumEnd;
120
            }
121
        }
122
        if (newStart < minimumStart) {
123
            newStart = minimumStart;
124
            if (newEnd < minimumStart) {
125
                newEnd = minimumStart;
126
            }
127
        }
128
129
        return new OffsetRange(newStart, newEnd);
130
    }
131
132
    @Override
133
    public String toString() {
134
        if (this == NONE) {
135
            return "OffsetRange[NONE]";
136
        } else {
137
            return "OffsetRange[" + start + "," + end + ">"; // NOI18N
138
        }
139
    }
140
141
    @Override
142
    public boolean equals(Object o) {
143
        if (o == null) {
144
            return false;
145
        }
146
147
        if (o.getClass() != OffsetRange.class) {
148
            return false;
149
        }
150
151
        final OffsetRange test = (OffsetRange)o;
152
153
        if (this.start != test.start) {
154
            return false;
155
        }
156
157
        if (this.end != test.end) {
158
            return false;
159
        }
160
161
        return true;
162
    }
163
164
    @Override
165
    public int hashCode() {
166
        // OffsetRanges are typically not overlapping so the start is as
167
        // good a hash as any.
168
        //int hash = 7;
169
        //
170
        //hash = (23 * hash) + this.start;
171
        //hash = (23 * hash) + this.end;
172
        //
173
        //return hash;
174
        return start;
175
    }
176
177
    /** Return true iff the given offset is within the bounds (or at the bounds) of the range */
178
    public boolean containsInclusive(int offset) {
179
        if (this == NONE) {
180
            return false;
181
        }
182
183
        return (offset >= getStart()) && (offset <= getEnd());
184
    }
185
    
186
    public int compareTo(OffsetRange o) {
187
        if (start != o.start) {
188
            return start - o.start;
189
        } else {
190
            // Most GSF services do not allow overlapping offset ranges!
191
            //assert end == o.end : this;
192
            
193
            return end - o.end;
194
        }
195
    }
196
    
197
    public boolean isEmpty() {
198
        return start == end;
199
    }
200
}
(-)a/csl.types/src/org/netbeans/modules/csl/api/Severity.java (+61 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.csl.api;
46
47
/**
48
 * Types of severities (generally for Errors)
49
 * @author Tor Norbye
50
 */
51
public enum Severity {
52
    /** Just an informational hint */
53
    INFO,
54
    /** The error is only a warning; may be correct, may not be, but user should be alerted */
55
    WARNING,
56
    /** The error is a problem that must be dealt with */
57
    ERROR,
58
    /** The fatal error is a problem that usually affects the further file analysis and
59
     must be inevitably fixed */    
60
    FATAL;
61
}
(-)a/csl.types/src/org/netbeans/modules/csl/spi/ParserResult.java (+66 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.csl.spi;
44
45
import java.util.List;
46
import org.netbeans.modules.csl.api.Error;
47
import org.netbeans.modules.parsing.api.Snapshot;
48
import org.netbeans.modules.parsing.spi.Parser;
49
50
/**
51
 *
52
 * @author hanz
53
 */
54
public abstract class ParserResult extends Parser.Result {
55
56
    protected ParserResult(Snapshot snapshot) {
57
        super(snapshot);
58
    }
59
60
    public abstract List<? extends Error> getDiagnostics ();
61
62
}
63
64
65
66
(-)a/csl.types/src/org/netbeans/modules/csl/types/Bundle.properties (+1 lines)
Line 0 Link Here
1
OpenIDE-Module-Name=Common Scripting Language Types
(-)a/csl.types/test/unit/src/org/netbeans/modules/csl/api/OffsetRangeTest.java (+142 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.csl.api;
46
47
import org.netbeans.modules.csl.api.OffsetRange;
48
import org.netbeans.junit.NbTestCase;
49
50
/**
51
 * @author Tor Norbye
52
 */
53
public class OffsetRangeTest extends NbTestCase {
54
55
    public OffsetRangeTest(String testName) {
56
        super(testName);
57
    }
58
59
    public void testOverlaps() {
60
        OffsetRange range1 = new OffsetRange(1, 4);
61
        OffsetRange range2 = new OffsetRange(2, 6);
62
        OffsetRange range3 = new OffsetRange(4, 6);
63
        OffsetRange range4 = new OffsetRange(0, 1);
64
        OffsetRange range5 = new OffsetRange(0, 6);
65
        assertTrue(range1.overlaps(range2));
66
        assertTrue(range2.overlaps(range1));
67
        assertFalse(range1.overlaps(range3));
68
        assertFalse(range3.overlaps(range1));
69
        assertFalse(range1.overlaps(range4));
70
        assertFalse(range4.overlaps(range1));
71
        assertTrue(range1.overlaps(range5));
72
        assertTrue(range5.overlaps(range1));
73
        
74
        assertFalse(range1.overlaps(OffsetRange.NONE));
75
        assertFalse(OffsetRange.NONE.overlaps(range5));
76
        assertFalse(OffsetRange.NONE.overlaps(OffsetRange.NONE));
77
    }
78
    
79
    public void testGetStart() {
80
        OffsetRange range = new OffsetRange(1, 4);
81
        assertEquals(1, range.getStart());
82
    }
83
84
    public void testGetEnd() {
85
        OffsetRange range = new OffsetRange(1, 4);
86
        assertEquals(4, range.getEnd());
87
    }
88
89
    public void testGetLength() {
90
        OffsetRange range = new OffsetRange(1, 4);
91
        assertEquals(3, range.getLength());
92
    }
93
94
    public void testContainsInclusive() {
95
        OffsetRange range = new OffsetRange(1, 4);
96
        assertTrue(range.containsInclusive(1));
97
        assertTrue(range.containsInclusive(3));
98
        assertTrue(range.containsInclusive(4));
99
        assertFalse(range.containsInclusive(5));
100
        assertFalse(range.containsInclusive(0));
101
    }
102
    
103
    public void testEquals() {
104
        assertEquals(new OffsetRange(1,3), new OffsetRange(1,3));
105
        assertEquals(new OffsetRange(0,0), new OffsetRange(0,0));
106
        assertFalse(new OffsetRange(1,3).equals(new Object()));
107
108
        boolean success = false;
109
        try {
110
            // Should generate an assertion!
111
            new OffsetRange(9,8);
112
        } catch (AssertionError e) {
113
            success = true;
114
        }
115
        assertTrue(success);
116
    }
117
    
118
    public void testComparator() {
119
        assertTrue(new OffsetRange(1,3).compareTo(new OffsetRange(3,5)) < 0);
120
        assertTrue(new OffsetRange(3,5).compareTo(new OffsetRange(1,3)) > 0);
121
        assertTrue(new OffsetRange(3,5).compareTo(new OffsetRange(3,5)) == 0);
122
        assertTrue(new OffsetRange(1,3).compareTo(new OffsetRange(1,5)) < 0);
123
        assertTrue(new OffsetRange(1,5).compareTo(new OffsetRange(1,3)) > 0);
124
    }
125
    
126
    public void testEmpty() {
127
        assertTrue(new OffsetRange(5,5).isEmpty());
128
        assertFalse(new OffsetRange(5,6).isEmpty());
129
    }
130
131
    public void testBoundTo() {
132
        assertEquals(new OffsetRange(1,3), new OffsetRange(1,3).boundTo(1, 3));
133
        assertEquals(new OffsetRange(1,3), new OffsetRange(0,4).boundTo(1, 3));
134
        assertEquals(new OffsetRange(1,3), new OffsetRange(1,3).boundTo(0, 4));
135
        assertEquals(new OffsetRange(1,2), new OffsetRange(1,3).boundTo(0, 2));
136
        assertEquals(new OffsetRange(2,3), new OffsetRange(1,3).boundTo(2, 4));
137
        assertEquals(new OffsetRange(2,2), new OffsetRange(1,3).boundTo(2, 2));
138
        assertEquals(new OffsetRange(101,101), new OffsetRange(102,103).boundTo(0, 101));
139
        assertEquals(new OffsetRange(100,101), new OffsetRange(100,103).boundTo(0, 101));
140
        assertEquals(new OffsetRange(100,100), new OffsetRange(90,95).boundTo(100, 150));
141
    }
142
}

Return to bug 258520