diff --git a/.idea/modules.xml b/.idea/modules.xml
index 82283e971251..d94269431fdf 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -11,6 +11,7 @@
Copyright (c) 2001-2003 Thai Open Source Software Center Ltd
+All rights reserved.
Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met:
+ +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ +This distribution includes some additional JAR files, which have +their own copying conditions:
+ +isorelax.jarCopyright (c) 2001-2002, SourceForge ISO-RELAX Project (ASAMI Tomoharu, Daisuke +Okajima, Kohsuke Kawaguchi, and MURATA Makoto)
+ +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+ +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR +A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ The plugin provides the following features: +
++ The complete list of changes in earlier versions is available + here +
+]]>+ This inspections checks for any unresolved references to named patterns ("define") in a RELAX-NG file in XML Syntax. + For unresolved references, a QuickFix is offered to create a corresponding define-element. +
+ + + + diff --git a/plugins/relaxng/src/inspectionDescriptions/UnusedDefine.html b/plugins/relaxng/src/inspectionDescriptions/UnusedDefine.html new file mode 100644 index 000000000000..1a59a9063112 --- /dev/null +++ b/plugins/relaxng/src/inspectionDescriptions/UnusedDefine.html @@ -0,0 +1,26 @@ + + + + + + ++ This inspections checks for any unused named patterns ("define") in a RELAX-NG file (XML or Compact Syntax) and + highlights them as unused symbols. This is done with respect to includes from other files, i.e. a define is not + marked as unused if is is used through an include in another file. +
+ + + + diff --git a/plugins/relaxng/src/org/intellij/plugins/relaxNG/ApplicationLoader.java b/plugins/relaxng/src/org/intellij/plugins/relaxNG/ApplicationLoader.java new file mode 100644 index 000000000000..dc50fc37c5f6 --- /dev/null +++ b/plugins/relaxng/src/org/intellij/plugins/relaxNG/ApplicationLoader.java @@ -0,0 +1,124 @@ +/* + * Copyright 2007 Sascha Weinreuter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.intellij.plugins.relaxNG; + +import org.intellij.plugins.relaxNG.compact.psi.impl.RncDocument; +import org.intellij.plugins.relaxNG.inspections.RngDomInspection; +import org.intellij.plugins.relaxNG.inspections.UnusedDefineInspection; +import org.intellij.plugins.relaxNG.model.descriptors.RngNsDescriptor; +import org.intellij.plugins.relaxNG.validation.ValidateAction; +import org.intellij.plugins.relaxNG.xml.dom.RngDefine; +import org.intellij.plugins.relaxNG.xml.dom.impl.RngDefineMetaData; + +import com.intellij.codeInspection.InspectionToolProvider; +import com.intellij.javaee.ResourceRegistrar; +import com.intellij.javaee.StandardResourceProvider; +import com.intellij.openapi.actionSystem.ActionManager; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.components.ApplicationComponent; +import com.intellij.openapi.fileTypes.FileTypeManager; +import com.intellij.openapi.fileTypes.StdFileTypes; +import com.intellij.psi.PsiElement; +import com.intellij.psi.filters.AndFilter; +import com.intellij.psi.filters.ClassFilter; +import com.intellij.psi.filters.ElementFilter; +import com.intellij.psi.filters.position.NamespaceFilter; +import com.intellij.psi.meta.MetaDataRegistrar; +import com.intellij.psi.xml.XmlDocument; +import com.intellij.psi.xml.XmlTag; +import com.intellij.util.xml.DomElement; +import com.intellij.util.xml.DomManager; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +/** + * Created by IntelliJ IDEA. + * User: sweinreuter + * Date: 18.07.2007 + */ +public class ApplicationLoader implements ApplicationComponent, InspectionToolProvider { + private static final String RNG_EXT = "rng"; + private static final String VALIDATE_XML = "ValidateXml"; + + @NonNls + @NotNull + public String getComponentName() { + return "Relax-NG"; + } + + public void initComponent() { + registerMetaData(); + + final FileTypeManager ftm = FileTypeManager.getInstance(); + ftm.registerFileType(StdFileTypes.XML, RNG_EXT); + + installValidateXmlAction(); + } + + private static void installValidateXmlAction() { + final ActionManager mgr = ActionManager.getInstance(); + final AnAction validateAction = mgr.getAction(VALIDATE_XML); + mgr.unregisterAction(VALIDATE_XML); + mgr.registerAction(VALIDATE_XML, new ValidateAction(validateAction)); + } + + private static void registerMetaData() { + final MetaDataRegistrar registrar = MetaDataRegistrar.getInstance(); + registrar.registerMetaData( + new AndFilter( + new NamespaceFilter(ProjectLoader.RNG_NAMESPACE), + new ClassFilter(XmlDocument.class) + ), + RngNsDescriptor.class); + + registrar.registerMetaData( + new ClassFilter(RncDocument.class), + RngNsDescriptor.class); + + registrar.registerMetaData(new ElementFilter() { + public boolean isAcceptable(Object element, PsiElement context) { + if (element instanceof XmlTag) { + final XmlTag tag = (XmlTag)element; + final DomElement domElement = DomManager.getDomManager(tag.getProject()).getDomElement(tag); + return domElement instanceof RngDefine; + } + return false; + } + + public boolean isClassAcceptable(Class hintClass) { + return XmlTag.class.isAssignableFrom(hintClass); + } + }, RngDefineMetaData.class); + } + + public void disposeComponent() { + } + + public Class[] getInspectionClasses() { + return new Class[]{ + RngDomInspection.class, + UnusedDefineInspection.class + }; + } + + public class ResourceProvider implements StandardResourceProvider { + public void registerResources(ResourceRegistrar registrar) { + registrar.addStdResource(ProjectLoader.RNG_NAMESPACE, "resources/relaxng.rng", getClass()); + registrar.addIgnoredResource("http://relaxng.org/ns/compatibility/annotations/1.0"); + } + } +} diff --git a/plugins/relaxng/src/org/intellij/plugins/relaxNG/GotoSymbolContributor.java b/plugins/relaxng/src/org/intellij/plugins/relaxNG/GotoSymbolContributor.java new file mode 100644 index 000000000000..148acd83a7a9 --- /dev/null +++ b/plugins/relaxng/src/org/intellij/plugins/relaxNG/GotoSymbolContributor.java @@ -0,0 +1,42 @@ +/* + * Copyright 2007 Sascha Weinreuter + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.intellij.plugins.relaxNG; + +import org.intellij.plugins.relaxNG.model.resolve.RelaxSymbolIndex; + +import com.intellij.navigation.ChooseByNameContributor; +import com.intellij.navigation.NavigationItem; +import com.intellij.openapi.project.Project; + +import java.util.Collection; + +/* +* Created by IntelliJ IDEA. +* User: sweinreuter +* Date: 24.10.2007 +*/ +public class GotoSymbolContributor implements ChooseByNameContributor { + + public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) { + return RelaxSymbolIndex.getSymbolsByName(name, project, includeNonProjectItems); + } + + public String[] getNames(Project project, boolean includeNonProjectItems) { + final Collection extends Pattern extends Pattern