--- a/csl.api/apichanges.xml +++ a/csl.api/apichanges.xml @@ -49,6 +49,27 @@ Common Scripting Language API + + Separate common non UI classes + + + + + +

+ Seperating the common non UI classes to avoid Swing dependency in dependent projects. +

+
+ + + + + + + + + +
Added CancelSupport to allow scanners and other CSL services to check task cancelling --- a/csl.api/module-auto-deps.xml +++ a/csl.api/module-auto-deps.xml @@ -0,0 +1,61 @@ + + + + + + Splitting parts of csl.api off into csl.types + + + + + + + + + + + + + --- a/csl.api/nbproject/project.properties +++ a/csl.api/nbproject/project.properties @@ -40,7 +40,7 @@ # Version 2 license, then the option applies only if the new code is # made subject to such option by the copyright holder. -spec.version.base=2.53.0 +spec.version.base=2.54.0 is.autoload=true javac.source=1.7 --- a/csl.api/nbproject/project.xml +++ a/csl.api/nbproject/project.xml @@ -59,6 +59,15 @@ + org.netbeans.modules.csl.types + + + + 0-1 + 1.0 + + + org.netbeans.modules.diff --- a/csl.api/src/org/netbeans/modules/csl/api/Documentation.java +++ a/csl.api/src/org/netbeans/modules/csl/api/Documentation.java @@ -1,99 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2013 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): - * - * Portions Copyrighted 2013 Sun Microsystems, Inc. - */ -package org.netbeans.modules.csl.api; - -import java.net.URL; -import org.netbeans.api.annotations.common.CheckForNull; -import org.netbeans.api.annotations.common.NonNull; -import org.openide.util.Parameters; - -/** - * Represents documentation displayed in code completion window. - * - * @author Petr Hejl - * @since 2.43 - */ -public final class Documentation { - - private final String content; - - private final URL url; - - private Documentation(String content, URL url) { - assert content != null; - this.content = content; - this.url = url; - } - - @NonNull - public static Documentation create(@NonNull String content) { - Parameters.notNull("content", content); - return new Documentation(content, null); - } - - @NonNull - public static Documentation create(@NonNull String content, URL url) { - Parameters.notNull("content", content); - return new Documentation(content, url); - } - - /** - * The documentation itself. - * - * @return documentation itself - */ - @NonNull - public String getContent() { - return content; - } - - /** - * The external documentation URL. Might be {@code null}. - * - * @return external documentation URL - */ - @CheckForNull - public URL getUrl() { - return url; - } - -} --- a/csl.api/src/org/netbeans/modules/csl/api/ElementHandle.java +++ a/csl.api/src/org/netbeans/modules/csl/api/ElementHandle.java @@ -1,149 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - */ - -package org.netbeans.modules.csl.api; - -import java.util.Collections; -import java.util.Set; -import org.netbeans.api.annotations.common.CheckForNull; -import org.netbeans.api.annotations.common.NonNull; -import org.netbeans.modules.csl.spi.ParserResult; -import org.openide.filesystems.FileObject; - -/** - * Based on org.netbeans.modules.gsfpath.api.source by Tomas Zezula - * - * @author Tor Norbye - */ -public interface ElementHandle { - /** - * Return the FileObject associated with this handle, or null - * if the file is unknown or in a parse tree (in which case the - * file object is the same as the file object in the CompilationInfo - * for the root of the parse tree. - */ - @CheckForNull - FileObject getFileObject(); - - /** - * The mime type associated with this element. This is typically - * used to identify the type of element in embedded scenarios. - */ - @CheckForNull - String getMimeType(); - - @NonNull - String getName(); - - @CheckForNull - String getIn(); - - @NonNull - ElementKind getKind(); - - @NonNull - Set getModifiers(); - - /** - * Tests if the handle has the same signature as the parameter. - * @param handle to be checked - * @return true if the handles refer to elements with the same signature - */ - boolean signatureEquals (@NonNull final ElementHandle handle); - - OffsetRange getOffsetRange(@NonNull ParserResult result); - - /** - * A special handle which holds URL. Can be used to handle documentation - * requests etc. - */ - public static class UrlHandle implements ElementHandle { - private String url; - - public UrlHandle(@NonNull String url) { - this.url = url; - } - - public FileObject getFileObject() { - return null; - } - - public String getMimeType() { - return null; - } - - public boolean signatureEquals(ElementHandle handle) { - if (handle instanceof UrlHandle) { - return url.equals(((UrlHandle)handle).url); - } - - return false; - } - - public OffsetRange getOffsetRange(@NonNull ParserResult result) { - return null; - } - - @NonNull - public String getUrl() { - return url; - } - - public String getName() { - return url; - } - - public String getIn() { - return null; - } - - public ElementKind getKind() { - return ElementKind.OTHER; - } - - public Set getModifiers() { - return Collections.emptySet(); - } - } -} --- a/csl.api/src/org/netbeans/modules/csl/api/ElementKind.java +++ a/csl.api/src/org/netbeans/modules/csl/api/ElementKind.java @@ -1,55 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - */ - -package org.netbeans.modules.csl.api; - -/** - * - * @author Tor Norbye - */ -public enum ElementKind { - CONSTRUCTOR, MODULE, PACKAGE, CLASS, METHOD, FIELD, VARIABLE, - ATTRIBUTE, CONSTANT, KEYWORD, OTHER, PARAMETER, GLOBAL, - PROPERTY, ERROR, DB, CALL, TAG, RULE, FILE, TEST, INTERFACE -} --- a/csl.api/src/org/netbeans/modules/csl/api/Error.java +++ a/csl.api/src/org/netbeans/modules/csl/api/Error.java @@ -1,144 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - */ - -package org.netbeans.modules.csl.api; - -import org.netbeans.api.annotations.common.CheckForNull; -import org.netbeans.api.annotations.common.NonNull; -import org.openide.filesystems.FileObject; - -/** - * This represents an error registered for the current java source, - * possibly with associated fix proposals. - * - * @todo Add a getArgs() method etc. such that error messages can be parameterized; see javax.tools.DiagnosticMessage - * - * @author Tor Norbye - */ -public interface Error { - /** - * Provide a short user-visible (and therefore localized) description of this error - */ - @NonNull - String getDisplayName(); - - /** - * Provide a full sentence description of this item, suitable for display in a tooltip - * for example - */ - @CheckForNull - String getDescription(); - - /** - * Return a unique id/key for this error, such as "compiler.err.abstract.cant.be.instantiated". - * This key is used for error hints providers. - */ - @CheckForNull - String getKey(); - - ///** - // * Get the fixes associated with this error - // */ - //Collection getFixes(); - // - ///** - // * Register a fix proposal for this error - // */ - //void addFix(Fix fix); - - /** - * Get the file object associated with this error, if any - */ - @CheckForNull - FileObject getFile(); - - /** - * Get the position of the error in the parsing input source (in other words, - * this is the AST-based offset and may need translation to obtain the document - * offset in documents with an embedding model.) - */ - int getStartPosition(); - - /** - * Get the end offset of the error in the parsing input source (in other words, - * this is the AST-based offset and may need translation to obtain the document - * offset in documents with an embedding model.). - * - * @return The end position, or -1 if unknown. - */ - int getEndPosition(); - - /** - * Defines the way how an error annotation for this error behaves in the editor. - * - * @return true if the error annotation should span over the whole line, false if - * the annotation is restricted exactly by the range defined by getStart/EndPostion() - */ - boolean isLineError(); - - /** - * Get the severity of this error - */ - @NonNull - Severity getSeverity(); - - /** - * Return optional parameters for this message. The parameters may - * provide the specific unknown symbol name for an unknown symbol error, - * etc. - */ - @CheckForNull - Object[] getParameters(); - - /**Error that may be used to show error badge in the projects tab. - * @since 1.18 - */ - public interface Badging extends Error { - /**Whether or not the error should be used to show error badge in the projects tab. - * - * @return true if this error should be used to show error badge in the projects tab. - */ - public boolean showExplorerBadge(); - } -} --- a/csl.api/src/org/netbeans/modules/csl/api/Modifier.java +++ a/csl.api/src/org/netbeans/modules/csl/api/Modifier.java @@ -1,53 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - */ - -package org.netbeans.modules.csl.api; - -/** - * - * @author Tor Norbye - */ -public enum Modifier { - PUBLIC, STATIC, PROTECTED, PRIVATE, DEPRECATED, ABSTRACT -} --- a/csl.api/src/org/netbeans/modules/csl/api/OffsetRange.java +++ a/csl.api/src/org/netbeans/modules/csl/api/OffsetRange.java @@ -1,200 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - */ -package org.netbeans.modules.csl.api; - -/** - * An offset range provides a range (start, end) pair of offsets - * that indicate a range in a character buffer. The range represented - * is {@code [start,end>}, which means that the range includes the - * character at index=start, and ends right before the character at end. - * Put yet another way, the starting offset is inclusive, and the ending - * offset is exclusive. - * - * @todo This class should be final - * - * @author Tor Norbye - */ -public final class OffsetRange implements Comparable { - public static final OffsetRange NONE = new OffsetRange(0, 0); - private final int start; - private final int end; - - /** Creates a new instance of OffsetRange */ - public OffsetRange(int start, int end) { - assert start >= 0 : "Invalid start:" + start; - assert end >= start : "Invalid start:" + start + " end:" + end; - - this.start = start; - this.end = end; - } - - /** Get the start offset of offset range */ - public int getStart() { - return start; - } - - /** Get the end offset of offset range */ - public int getEnd() { - return end; - } - - /** Get the length of the offset range */ - public int getLength() { - return getEnd()-getStart(); - } - - /** - * Return true if the given range overlaps with the current range. - * Full containment one way or the other is also considered overlapping. - */ - public boolean overlaps(OffsetRange range) { - if (range == OffsetRange.NONE) { - return false; - } else if (this == OffsetRange.NONE) { - return false; - } else { - return end > range.start && start < range.end; - } - } - - /** - * Create a new OffsetRange that bounds the current OffsetRange with the given range. - * (e.g. an intersection) - * @param minimumStart The minimum starting position. Both the start and end - * will be at least this value. - * @param maximumEnd The maximum ending position. Both the start and end will - * be at most this value. - * @return A new offset range limited to the given bounds. - */ - public OffsetRange boundTo(int minimumStart, int maximumEnd) { - assert minimumStart <= maximumEnd; - assert this != OffsetRange.NONE; - - int newStart = start; - int newEnd = end; - if (newEnd > maximumEnd) { - newEnd = maximumEnd; - if (newStart > maximumEnd) { - newStart = maximumEnd; - } - } - if (newStart < minimumStart) { - newStart = minimumStart; - if (newEnd < minimumStart) { - newEnd = minimumStart; - } - } - - return new OffsetRange(newStart, newEnd); - } - - @Override - public String toString() { - if (this == NONE) { - return "OffsetRange[NONE]"; - } else { - return "OffsetRange[" + start + "," + end + ">"; // NOI18N - } - } - - @Override - public boolean equals(Object o) { - if (o == null) { - return false; - } - - if (o.getClass() != OffsetRange.class) { - return false; - } - - final OffsetRange test = (OffsetRange)o; - - if (this.start != test.start) { - return false; - } - - if (this.end != test.end) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - // OffsetRanges are typically not overlapping so the start is as - // good a hash as any. - //int hash = 7; - // - //hash = (23 * hash) + this.start; - //hash = (23 * hash) + this.end; - // - //return hash; - return start; - } - - /** Return true iff the given offset is within the bounds (or at the bounds) of the range */ - public boolean containsInclusive(int offset) { - if (this == NONE) { - return false; - } - - return (offset >= getStart()) && (offset <= getEnd()); - } - - public int compareTo(OffsetRange o) { - if (start != o.start) { - return start - o.start; - } else { - // Most GSF services do not allow overlapping offset ranges! - //assert end == o.end : this; - - return end - o.end; - } - } - - public boolean isEmpty() { - return start == end; - } -} --- a/csl.api/src/org/netbeans/modules/csl/api/Severity.java +++ a/csl.api/src/org/netbeans/modules/csl/api/Severity.java @@ -1,61 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - */ - -package org.netbeans.modules.csl.api; - -/** - * Types of severities (generally for Errors) - * @author Tor Norbye - */ -public enum Severity { - /** Just an informational hint */ - INFO, - /** The error is only a warning; may be correct, may not be, but user should be alerted */ - WARNING, - /** The error is a problem that must be dealt with */ - ERROR, - /** The fatal error is a problem that usually affects the further file analysis and - must be inevitably fixed */ - FATAL; -} --- a/csl.api/src/org/netbeans/modules/csl/spi/ParserResult.java +++ a/csl.api/src/org/netbeans/modules/csl/spi/ParserResult.java @@ -1,66 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2010 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): - * - * Portions Copyrighted 2008 Sun Microsystems, Inc. - */ - -package org.netbeans.modules.csl.spi; - -import java.util.List; -import org.netbeans.modules.csl.api.Error; -import org.netbeans.modules.parsing.api.Snapshot; -import org.netbeans.modules.parsing.spi.Parser; - -/** - * - * @author hanz - */ -public abstract class ParserResult extends Parser.Result { - - protected ParserResult(Snapshot snapshot) { - super(snapshot); - } - - public abstract List getDiagnostics (); - -} - - - - --- a/csl.api/test/unit/src/org/netbeans/modules/csl/api/OffsetRangeTest.java +++ a/csl.api/test/unit/src/org/netbeans/modules/csl/api/OffsetRangeTest.java @@ -1,142 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun - * Microsystems, Inc. All Rights Reserved. - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - */ - -package org.netbeans.modules.csl.api; - -import org.netbeans.modules.csl.api.OffsetRange; -import org.netbeans.junit.NbTestCase; - -/** - * @author Tor Norbye - */ -public class OffsetRangeTest extends NbTestCase { - - public OffsetRangeTest(String testName) { - super(testName); - } - - public void testOverlaps() { - OffsetRange range1 = new OffsetRange(1, 4); - OffsetRange range2 = new OffsetRange(2, 6); - OffsetRange range3 = new OffsetRange(4, 6); - OffsetRange range4 = new OffsetRange(0, 1); - OffsetRange range5 = new OffsetRange(0, 6); - assertTrue(range1.overlaps(range2)); - assertTrue(range2.overlaps(range1)); - assertFalse(range1.overlaps(range3)); - assertFalse(range3.overlaps(range1)); - assertFalse(range1.overlaps(range4)); - assertFalse(range4.overlaps(range1)); - assertTrue(range1.overlaps(range5)); - assertTrue(range5.overlaps(range1)); - - assertFalse(range1.overlaps(OffsetRange.NONE)); - assertFalse(OffsetRange.NONE.overlaps(range5)); - assertFalse(OffsetRange.NONE.overlaps(OffsetRange.NONE)); - } - - public void testGetStart() { - OffsetRange range = new OffsetRange(1, 4); - assertEquals(1, range.getStart()); - } - - public void testGetEnd() { - OffsetRange range = new OffsetRange(1, 4); - assertEquals(4, range.getEnd()); - } - - public void testGetLength() { - OffsetRange range = new OffsetRange(1, 4); - assertEquals(3, range.getLength()); - } - - public void testContainsInclusive() { - OffsetRange range = new OffsetRange(1, 4); - assertTrue(range.containsInclusive(1)); - assertTrue(range.containsInclusive(3)); - assertTrue(range.containsInclusive(4)); - assertFalse(range.containsInclusive(5)); - assertFalse(range.containsInclusive(0)); - } - - public void testEquals() { - assertEquals(new OffsetRange(1,3), new OffsetRange(1,3)); - assertEquals(new OffsetRange(0,0), new OffsetRange(0,0)); - assertFalse(new OffsetRange(1,3).equals(new Object())); - - boolean success = false; - try { - // Should generate an assertion! - new OffsetRange(9,8); - } catch (AssertionError e) { - success = true; - } - assertTrue(success); - } - - public void testComparator() { - assertTrue(new OffsetRange(1,3).compareTo(new OffsetRange(3,5)) < 0); - assertTrue(new OffsetRange(3,5).compareTo(new OffsetRange(1,3)) > 0); - assertTrue(new OffsetRange(3,5).compareTo(new OffsetRange(3,5)) == 0); - assertTrue(new OffsetRange(1,3).compareTo(new OffsetRange(1,5)) < 0); - assertTrue(new OffsetRange(1,5).compareTo(new OffsetRange(1,3)) > 0); - } - - public void testEmpty() { - assertTrue(new OffsetRange(5,5).isEmpty()); - assertFalse(new OffsetRange(5,6).isEmpty()); - } - - public void testBoundTo() { - assertEquals(new OffsetRange(1,3), new OffsetRange(1,3).boundTo(1, 3)); - assertEquals(new OffsetRange(1,3), new OffsetRange(0,4).boundTo(1, 3)); - assertEquals(new OffsetRange(1,3), new OffsetRange(1,3).boundTo(0, 4)); - assertEquals(new OffsetRange(1,2), new OffsetRange(1,3).boundTo(0, 2)); - assertEquals(new OffsetRange(2,3), new OffsetRange(1,3).boundTo(2, 4)); - assertEquals(new OffsetRange(2,2), new OffsetRange(1,3).boundTo(2, 2)); - assertEquals(new OffsetRange(101,101), new OffsetRange(102,103).boundTo(0, 101)); - assertEquals(new OffsetRange(100,101), new OffsetRange(100,103).boundTo(0, 101)); - assertEquals(new OffsetRange(100,100), new OffsetRange(90,95).boundTo(100, 150)); - } -} --- a/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java +++ a/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java @@ -740,7 +740,7 @@ // If both values are true it means the content is the same, but some lines are // placed on a different line number in actual and expected content - if (noErrorInActual && noErrorInExpected) { + if (noErrorInActual && noErrorInExpected && expectedLines.size() == actualLines.size()) { for (int lineNumber = 0; lineNumber < expectedLines.size(); lineNumber++) { String expectedLine = expectedLines.get(lineNumber); String actualLine = actualLines.get(lineNumber); --- a/api.progress.nb/apichanges.xml +++ a/api.progress.nb/apichanges.xml @@ -101,26 +101,31 @@ - Progress API - Swing extensions + Common CSL API types + Common CSL SPI types - - - - Swing dependencies separated into a new module. - - - - - + + Separate common non UI classes + + + + - Progress API was split so that parts that are directly connected to Swing types were migrated - to a separate module. + Seperating the common non UI classes to avoid Swing dependency in dependent projects. - + + + + + + + + + @@ -139,7 +144,7 @@ --> - Change History for the Progress API - Swing + Change History for the Common CSL types @@ -152,7 +157,7 @@ -
+

@FOOTER@

--- a/api.progress.nb/arch.xml +++ a/api.progress.nb/arch.xml @@ -5,7 +5,7 @@ &api-questions; @@ -29,9 +29,14 @@ -->

- - Part of Progress API specialized for Swing UIs. + + Common CSL non UI API classes. +

+

+ + Common CSL non UI SPI classes.

--- a/csl.types/build.xml +++ a/csl.types/build.xml @@ -0,0 +1,5 @@ + + + Builds, tests, and runs the project org.netbeans.modules.csl.types + + --- a/csl.types/manifest.mf +++ a/csl.types/manifest.mf @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +AutoUpdate-Show-In-Client: false +OpenIDE-Module: org.netbeans.modules.csl.types/1 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/csl/types/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + --- a/csl.types/nbproject/project.properties +++ a/csl.types/nbproject/project.properties @@ -0,0 +1,6 @@ +is.autoload=true +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial + +javadoc.arch=${basedir}/arch.xml +javadoc.apichanges=${basedir}/apichanges.xml --- a/csl.types/nbproject/project.xml +++ a/csl.types/nbproject/project.xml @@ -0,0 +1,63 @@ + + + org.netbeans.modules.apisupport.project + + + org.netbeans.modules.csl.types + + + org.netbeans.api.annotations.common + + + + 1 + 1.27 + + + + org.netbeans.modules.parsing.api + + + + 1 + 9.6 + + + + org.openide.filesystems + + + + 9.10 + + + + org.openide.util + + + + 9.7 + + + + + + unit + + org.netbeans.libs.junit4 + + + + org.netbeans.modules.nbjunit + + + + + + + org.netbeans.modules.csl.api + org.netbeans.modules.csl.spi + + + + --- a/csl.types/src/org/netbeans/modules/csl/api/Documentation.java +++ a/csl.types/src/org/netbeans/modules/csl/api/Documentation.java @@ -0,0 +1,99 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2013 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2013 Sun Microsystems, Inc. + */ +package org.netbeans.modules.csl.api; + +import java.net.URL; +import org.netbeans.api.annotations.common.CheckForNull; +import org.netbeans.api.annotations.common.NonNull; +import org.openide.util.Parameters; + +/** + * Represents documentation displayed in code completion window. + * + * @author Petr Hejl + * @since 2.43 + */ +public final class Documentation { + + private final String content; + + private final URL url; + + private Documentation(String content, URL url) { + assert content != null; + this.content = content; + this.url = url; + } + + @NonNull + public static Documentation create(@NonNull String content) { + Parameters.notNull("content", content); + return new Documentation(content, null); + } + + @NonNull + public static Documentation create(@NonNull String content, URL url) { + Parameters.notNull("content", content); + return new Documentation(content, url); + } + + /** + * The documentation itself. + * + * @return documentation itself + */ + @NonNull + public String getContent() { + return content; + } + + /** + * The external documentation URL. Might be {@code null}. + * + * @return external documentation URL + */ + @CheckForNull + public URL getUrl() { + return url; + } + +} --- a/csl.types/src/org/netbeans/modules/csl/api/ElementHandle.java +++ a/csl.types/src/org/netbeans/modules/csl/api/ElementHandle.java @@ -0,0 +1,149 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.modules.csl.api; + +import java.util.Collections; +import java.util.Set; +import org.netbeans.api.annotations.common.CheckForNull; +import org.netbeans.api.annotations.common.NonNull; +import org.netbeans.modules.csl.spi.ParserResult; +import org.openide.filesystems.FileObject; + +/** + * Based on org.netbeans.modules.gsfpath.api.source by Tomas Zezula + * + * @author Tor Norbye + */ +public interface ElementHandle { + /** + * Return the FileObject associated with this handle, or null + * if the file is unknown or in a parse tree (in which case the + * file object is the same as the file object in the CompilationInfo + * for the root of the parse tree. + */ + @CheckForNull + FileObject getFileObject(); + + /** + * The mime type associated with this element. This is typically + * used to identify the type of element in embedded scenarios. + */ + @CheckForNull + String getMimeType(); + + @NonNull + String getName(); + + @CheckForNull + String getIn(); + + @NonNull + ElementKind getKind(); + + @NonNull + Set getModifiers(); + + /** + * Tests if the handle has the same signature as the parameter. + * @param handle to be checked + * @return true if the handles refer to elements with the same signature + */ + boolean signatureEquals (@NonNull final ElementHandle handle); + + OffsetRange getOffsetRange(@NonNull ParserResult result); + + /** + * A special handle which holds URL. Can be used to handle documentation + * requests etc. + */ + public static class UrlHandle implements ElementHandle { + private String url; + + public UrlHandle(@NonNull String url) { + this.url = url; + } + + public FileObject getFileObject() { + return null; + } + + public String getMimeType() { + return null; + } + + public boolean signatureEquals(ElementHandle handle) { + if (handle instanceof UrlHandle) { + return url.equals(((UrlHandle)handle).url); + } + + return false; + } + + public OffsetRange getOffsetRange(@NonNull ParserResult result) { + return null; + } + + @NonNull + public String getUrl() { + return url; + } + + public String getName() { + return url; + } + + public String getIn() { + return null; + } + + public ElementKind getKind() { + return ElementKind.OTHER; + } + + public Set getModifiers() { + return Collections.emptySet(); + } + } +} --- a/csl.types/src/org/netbeans/modules/csl/api/ElementKind.java +++ a/csl.types/src/org/netbeans/modules/csl/api/ElementKind.java @@ -0,0 +1,55 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.modules.csl.api; + +/** + * + * @author Tor Norbye + */ +public enum ElementKind { + CONSTRUCTOR, MODULE, PACKAGE, CLASS, METHOD, FIELD, VARIABLE, + ATTRIBUTE, CONSTANT, KEYWORD, OTHER, PARAMETER, GLOBAL, + PROPERTY, ERROR, DB, CALL, TAG, RULE, FILE, TEST, INTERFACE +} --- a/csl.types/src/org/netbeans/modules/csl/api/Error.java +++ a/csl.types/src/org/netbeans/modules/csl/api/Error.java @@ -0,0 +1,144 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.modules.csl.api; + +import org.netbeans.api.annotations.common.CheckForNull; +import org.netbeans.api.annotations.common.NonNull; +import org.openide.filesystems.FileObject; + +/** + * This represents an error registered for the current java source, + * possibly with associated fix proposals. + * + * @todo Add a getArgs() method etc. such that error messages can be parameterized; see javax.tools.DiagnosticMessage + * + * @author Tor Norbye + */ +public interface Error { + /** + * Provide a short user-visible (and therefore localized) description of this error + */ + @NonNull + String getDisplayName(); + + /** + * Provide a full sentence description of this item, suitable for display in a tooltip + * for example + */ + @CheckForNull + String getDescription(); + + /** + * Return a unique id/key for this error, such as "compiler.err.abstract.cant.be.instantiated". + * This key is used for error hints providers. + */ + @CheckForNull + String getKey(); + + ///** + // * Get the fixes associated with this error + // */ + //Collection getFixes(); + // + ///** + // * Register a fix proposal for this error + // */ + //void addFix(Fix fix); + + /** + * Get the file object associated with this error, if any + */ + @CheckForNull + FileObject getFile(); + + /** + * Get the position of the error in the parsing input source (in other words, + * this is the AST-based offset and may need translation to obtain the document + * offset in documents with an embedding model.) + */ + int getStartPosition(); + + /** + * Get the end offset of the error in the parsing input source (in other words, + * this is the AST-based offset and may need translation to obtain the document + * offset in documents with an embedding model.). + * + * @return The end position, or -1 if unknown. + */ + int getEndPosition(); + + /** + * Defines the way how an error annotation for this error behaves in the editor. + * + * @return true if the error annotation should span over the whole line, false if + * the annotation is restricted exactly by the range defined by getStart/EndPostion() + */ + boolean isLineError(); + + /** + * Get the severity of this error + */ + @NonNull + Severity getSeverity(); + + /** + * Return optional parameters for this message. The parameters may + * provide the specific unknown symbol name for an unknown symbol error, + * etc. + */ + @CheckForNull + Object[] getParameters(); + + /**Error that may be used to show error badge in the projects tab. + * @since 1.18 + */ + public interface Badging extends Error { + /**Whether or not the error should be used to show error badge in the projects tab. + * + * @return true if this error should be used to show error badge in the projects tab. + */ + public boolean showExplorerBadge(); + } +} --- a/csl.types/src/org/netbeans/modules/csl/api/Modifier.java +++ a/csl.types/src/org/netbeans/modules/csl/api/Modifier.java @@ -0,0 +1,53 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.modules.csl.api; + +/** + * + * @author Tor Norbye + */ +public enum Modifier { + PUBLIC, STATIC, PROTECTED, PRIVATE, DEPRECATED, ABSTRACT +} --- a/csl.types/src/org/netbeans/modules/csl/api/OffsetRange.java +++ a/csl.types/src/org/netbeans/modules/csl/api/OffsetRange.java @@ -0,0 +1,200 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ +package org.netbeans.modules.csl.api; + +/** + * An offset range provides a range (start, end) pair of offsets + * that indicate a range in a character buffer. The range represented + * is {@code [start,end>}, which means that the range includes the + * character at index=start, and ends right before the character at end. + * Put yet another way, the starting offset is inclusive, and the ending + * offset is exclusive. + * + * @todo This class should be final + * + * @author Tor Norbye + */ +public final class OffsetRange implements Comparable { + public static final OffsetRange NONE = new OffsetRange(0, 0); + private final int start; + private final int end; + + /** Creates a new instance of OffsetRange */ + public OffsetRange(int start, int end) { + assert start >= 0 : "Invalid start:" + start; + assert end >= start : "Invalid start:" + start + " end:" + end; + + this.start = start; + this.end = end; + } + + /** Get the start offset of offset range */ + public int getStart() { + return start; + } + + /** Get the end offset of offset range */ + public int getEnd() { + return end; + } + + /** Get the length of the offset range */ + public int getLength() { + return getEnd()-getStart(); + } + + /** + * Return true if the given range overlaps with the current range. + * Full containment one way or the other is also considered overlapping. + */ + public boolean overlaps(OffsetRange range) { + if (range == OffsetRange.NONE) { + return false; + } else if (this == OffsetRange.NONE) { + return false; + } else { + return end > range.start && start < range.end; + } + } + + /** + * Create a new OffsetRange that bounds the current OffsetRange with the given range. + * (e.g. an intersection) + * @param minimumStart The minimum starting position. Both the start and end + * will be at least this value. + * @param maximumEnd The maximum ending position. Both the start and end will + * be at most this value. + * @return A new offset range limited to the given bounds. + */ + public OffsetRange boundTo(int minimumStart, int maximumEnd) { + assert minimumStart <= maximumEnd; + assert this != OffsetRange.NONE; + + int newStart = start; + int newEnd = end; + if (newEnd > maximumEnd) { + newEnd = maximumEnd; + if (newStart > maximumEnd) { + newStart = maximumEnd; + } + } + if (newStart < minimumStart) { + newStart = minimumStart; + if (newEnd < minimumStart) { + newEnd = minimumStart; + } + } + + return new OffsetRange(newStart, newEnd); + } + + @Override + public String toString() { + if (this == NONE) { + return "OffsetRange[NONE]"; + } else { + return "OffsetRange[" + start + "," + end + ">"; // NOI18N + } + } + + @Override + public boolean equals(Object o) { + if (o == null) { + return false; + } + + if (o.getClass() != OffsetRange.class) { + return false; + } + + final OffsetRange test = (OffsetRange)o; + + if (this.start != test.start) { + return false; + } + + if (this.end != test.end) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + // OffsetRanges are typically not overlapping so the start is as + // good a hash as any. + //int hash = 7; + // + //hash = (23 * hash) + this.start; + //hash = (23 * hash) + this.end; + // + //return hash; + return start; + } + + /** Return true iff the given offset is within the bounds (or at the bounds) of the range */ + public boolean containsInclusive(int offset) { + if (this == NONE) { + return false; + } + + return (offset >= getStart()) && (offset <= getEnd()); + } + + public int compareTo(OffsetRange o) { + if (start != o.start) { + return start - o.start; + } else { + // Most GSF services do not allow overlapping offset ranges! + //assert end == o.end : this; + + return end - o.end; + } + } + + public boolean isEmpty() { + return start == end; + } +} --- a/csl.types/src/org/netbeans/modules/csl/api/Severity.java +++ a/csl.types/src/org/netbeans/modules/csl/api/Severity.java @@ -0,0 +1,61 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.modules.csl.api; + +/** + * Types of severities (generally for Errors) + * @author Tor Norbye + */ +public enum Severity { + /** Just an informational hint */ + INFO, + /** The error is only a warning; may be correct, may not be, but user should be alerted */ + WARNING, + /** The error is a problem that must be dealt with */ + ERROR, + /** The fatal error is a problem that usually affects the further file analysis and + must be inevitably fixed */ + FATAL; +} --- a/csl.types/src/org/netbeans/modules/csl/spi/ParserResult.java +++ a/csl.types/src/org/netbeans/modules/csl/spi/ParserResult.java @@ -0,0 +1,66 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2008 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.csl.spi; + +import java.util.List; +import org.netbeans.modules.csl.api.Error; +import org.netbeans.modules.parsing.api.Snapshot; +import org.netbeans.modules.parsing.spi.Parser; + +/** + * + * @author hanz + */ +public abstract class ParserResult extends Parser.Result { + + protected ParserResult(Snapshot snapshot) { + super(snapshot); + } + + public abstract List getDiagnostics (); + +} + + + + --- a/csl.types/src/org/netbeans/modules/csl/types/Bundle.properties +++ a/csl.types/src/org/netbeans/modules/csl/types/Bundle.properties @@ -0,0 +1,1 @@ +OpenIDE-Module-Name=Common Scripting Language Types --- a/csl.types/test/unit/src/org/netbeans/modules/csl/api/OffsetRangeTest.java +++ a/csl.types/test/unit/src/org/netbeans/modules/csl/api/OffsetRangeTest.java @@ -0,0 +1,142 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ + +package org.netbeans.modules.csl.api; + +import org.netbeans.modules.csl.api.OffsetRange; +import org.netbeans.junit.NbTestCase; + +/** + * @author Tor Norbye + */ +public class OffsetRangeTest extends NbTestCase { + + public OffsetRangeTest(String testName) { + super(testName); + } + + public void testOverlaps() { + OffsetRange range1 = new OffsetRange(1, 4); + OffsetRange range2 = new OffsetRange(2, 6); + OffsetRange range3 = new OffsetRange(4, 6); + OffsetRange range4 = new OffsetRange(0, 1); + OffsetRange range5 = new OffsetRange(0, 6); + assertTrue(range1.overlaps(range2)); + assertTrue(range2.overlaps(range1)); + assertFalse(range1.overlaps(range3)); + assertFalse(range3.overlaps(range1)); + assertFalse(range1.overlaps(range4)); + assertFalse(range4.overlaps(range1)); + assertTrue(range1.overlaps(range5)); + assertTrue(range5.overlaps(range1)); + + assertFalse(range1.overlaps(OffsetRange.NONE)); + assertFalse(OffsetRange.NONE.overlaps(range5)); + assertFalse(OffsetRange.NONE.overlaps(OffsetRange.NONE)); + } + + public void testGetStart() { + OffsetRange range = new OffsetRange(1, 4); + assertEquals(1, range.getStart()); + } + + public void testGetEnd() { + OffsetRange range = new OffsetRange(1, 4); + assertEquals(4, range.getEnd()); + } + + public void testGetLength() { + OffsetRange range = new OffsetRange(1, 4); + assertEquals(3, range.getLength()); + } + + public void testContainsInclusive() { + OffsetRange range = new OffsetRange(1, 4); + assertTrue(range.containsInclusive(1)); + assertTrue(range.containsInclusive(3)); + assertTrue(range.containsInclusive(4)); + assertFalse(range.containsInclusive(5)); + assertFalse(range.containsInclusive(0)); + } + + public void testEquals() { + assertEquals(new OffsetRange(1,3), new OffsetRange(1,3)); + assertEquals(new OffsetRange(0,0), new OffsetRange(0,0)); + assertFalse(new OffsetRange(1,3).equals(new Object())); + + boolean success = false; + try { + // Should generate an assertion! + new OffsetRange(9,8); + } catch (AssertionError e) { + success = true; + } + assertTrue(success); + } + + public void testComparator() { + assertTrue(new OffsetRange(1,3).compareTo(new OffsetRange(3,5)) < 0); + assertTrue(new OffsetRange(3,5).compareTo(new OffsetRange(1,3)) > 0); + assertTrue(new OffsetRange(3,5).compareTo(new OffsetRange(3,5)) == 0); + assertTrue(new OffsetRange(1,3).compareTo(new OffsetRange(1,5)) < 0); + assertTrue(new OffsetRange(1,5).compareTo(new OffsetRange(1,3)) > 0); + } + + public void testEmpty() { + assertTrue(new OffsetRange(5,5).isEmpty()); + assertFalse(new OffsetRange(5,6).isEmpty()); + } + + public void testBoundTo() { + assertEquals(new OffsetRange(1,3), new OffsetRange(1,3).boundTo(1, 3)); + assertEquals(new OffsetRange(1,3), new OffsetRange(0,4).boundTo(1, 3)); + assertEquals(new OffsetRange(1,3), new OffsetRange(1,3).boundTo(0, 4)); + assertEquals(new OffsetRange(1,2), new OffsetRange(1,3).boundTo(0, 2)); + assertEquals(new OffsetRange(2,3), new OffsetRange(1,3).boundTo(2, 4)); + assertEquals(new OffsetRange(2,2), new OffsetRange(1,3).boundTo(2, 2)); + assertEquals(new OffsetRange(101,101), new OffsetRange(102,103).boundTo(0, 101)); + assertEquals(new OffsetRange(100,101), new OffsetRange(100,103).boundTo(0, 101)); + assertEquals(new OffsetRange(100,100), new OffsetRange(90,95).boundTo(100, 150)); + } +}