'Target' soft wrap is the one that starts at the given offset.
+ *
+ * @param offset target offset
+ * @return index that conforms to {@link Collections#binarySearch(List, Object)} contract, i.e. non-negative returned
+ * index points to soft wrap that starts at the given offset; '-(negative value) - 1' points
+ * to position at {@link #getRegisteredSoftWraps() soft wraps collection} where soft wrap for the given index
+ * should be inserted
+ */
+ int getSoftWrapIndex(int offset);
+
/**
* Asks to paint drawing of target type at the given graphics buffer at the given position.
*
@@ -91,4 +104,12 @@ public interface SoftWrapModelEx extends SoftWrapModel {
* @return width in pixels required for the painting of the given type
*/
int getMinDrawingWidth(@NotNull SoftWrapDrawingType drawingType);
+
+ /**
+ * Registers given listener within the current model
+ *
+ * @param listener listener to register
+ * @return true if given listener was not registered before; false otherwise
+ */
+ boolean addSoftWrapChangeListener(@NotNull SoftWrapChangeListener listener);
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java
index 36b90cb9dc3d..bb5ade1b546a 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java
@@ -27,7 +27,6 @@ package com.intellij.openapi.editor.impl;
import com.intellij.codeInsight.hint.TooltipController;
import com.intellij.codeInsight.hint.TooltipGroup;
import com.intellij.ide.IdeEventQueue;
-import com.intellij.ide.ui.LafManager;
import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
@@ -119,6 +118,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
public void reinitSettings() {
myBackgroundColor = null;
+ revalidateMarkup();
repaint();
}
@@ -191,9 +191,12 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
private void paintAnnotations(Graphics g, Rectangle clip) {
- paintBackground(g, clip, getAnnotationsAreaOffset(), getAnnotationsAreaWidth());
-
int x = getAnnotationsAreaOffset();
+ int w = getAnnotationsAreaWidth();
+
+ if (w == 0) return;
+
+ paintBackground(g, clip, getAnnotationsAreaOffset(), w);
Color color = myEditor.getColorsScheme().getColor(EditorColors.ANNOTATIONS_COLOR);
g.setColor(color != null ? color : Color.blue);
@@ -201,6 +204,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
for (int i = 0; i < myTextAnnotationGutters.size(); i++) {
TextAnnotationGutterProvider gutterProvider = myTextAnnotationGutters.get(i);
+
int lineHeight = myEditor.getLineHeight();
int startLineNumber = clip.y / lineHeight;
int endLineNumber = (clip.y + clip.height) / lineHeight + 1;
@@ -209,7 +213,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
.line;
endLineNumber = Math.min(endLineNumber, lastLine + 1);
if (startLineNumber >= endLineNumber) {
- return;
+ break;
}
for (int j = startLineNumber; j < endLineNumber; j++) {
@@ -219,7 +223,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
final Color bg = gutterProvider.getBgColor(logLine, myEditor);
if (bg != null) {
g.setColor(bg);
- g.fillRect(x, j * lineHeight, getAnnotationsAreaWidth(), lineHeight);
+ g.fillRect(x, j * lineHeight, w, lineHeight);
}
g.setColor(myEditor.getColorsScheme().getColor(gutterProvider.getColor(logLine, myEditor)));
g.setFont(myEditor.getColorsScheme().getFont(style));
@@ -230,6 +234,8 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
x += myTextAnnotationGutterSizes.get(i);
}
+
+ UIUtil.drawVDottedLine((Graphics2D)g, getAnnotationsAreaOffset() + w - 1, clip.y, clip.y + clip.height, null, getOutlineColor(false));
}
private void paintFoldingTree(Graphics g, Rectangle clip) {
@@ -237,9 +243,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
paintFoldingTree((Graphics2D)g);
}
else {
- g.setColor(Color.white);
- int x = getWhitespaceSeparatorOffset() - 1;
- UIUtil.drawVDottedLine((Graphics2D)g, x, clip.y, clip.y + clip.height, myEditor.getBackgroundColor(), getFoldingColor(false));
+ UIUtil.drawVDottedLine((Graphics2D)g, clip.x + clip.width -1, clip.y, clip.y + clip.height, null, getOutlineColor(false));
}
}
@@ -270,28 +274,16 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
private void paintLineNumbers(Graphics g, Rectangle clip) {
if (isLineNumbersShown()) {
paintBackground(g, clip, getLineNumberAreaOffset(), getLineNumberAreaWidth());
- g.setColor(Color.white);
int x = getLineNumberAreaOffset() + getLineNumberAreaWidth() - 2;
- UIUtil.drawLine(g, x, clip.y, x, clip.y + clip.height);
+ UIUtil.drawVDottedLine((Graphics2D)g, x, clip.y, clip.y + clip.height, null, getOutlineColor(false));
paintLineNumbers(g);
}
}
public Color getBackground() {
if (myBackgroundColor == null) {
- final Color userDefinedColor = myEditor.getColorsScheme().getColor(EditorColors.LEFT_GUTTER_BACKGROUND);
- if (userDefinedColor != null) {
- myBackgroundColor = userDefinedColor;
- }
- else {
- LafManager lafManager = LafManager.getInstance();
- if (lafManager != null && lafManager.isUnderAquaLookAndFeel()) {
- myBackgroundColor = new Color(0xF0F0F0);
- }
- else {
- myBackgroundColor = super.getBackground();
- }
- }
+ Color color = myEditor.getColorsScheme().getColor(EditorColors.GUTTER_BACKGROUND);
+ myBackgroundColor = color == null ? new Color(0xF0F0F0) : color;
}
return myBackgroundColor;
}
@@ -639,8 +631,8 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
return (myEditor.getLineHeight() - icon.getIconHeight()) /2;
}
- public Color getFoldingColor(boolean isActive) {
- ColorKey key = isActive ? EditorColors.SELECTED_FOLDING_TREE_COLOR : EditorColors.FOLDING_TREE_COLOR;
+ public Color getOutlineColor(boolean isActive) {
+ ColorKey key = isActive ? EditorColors.SELECTED_TEARLINE_COLOR : EditorColors.TEARLINE_COLOR;
Color color = myEditor.getColorsScheme().getColor(key);
return color != null ? color : Color.black;
}
@@ -706,7 +698,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
if (!isFoldingOutlineShown()) return;
Rectangle clip = g.getClipBounds();
- UIUtil.drawVDottedLine(g, getWhitespaceSeparatorOffset(), clip.y, clip.y + clip.height, myEditor.getBackgroundColor(), getFoldingColor(false));
+ UIUtil.drawVDottedLine(g, getWhitespaceSeparatorOffset(), clip.y, clip.y + clip.height, null, getOutlineColor(false));
int anchorX = getFoldingAreaOffset();
int width = getFoldingAnchorWidth();
@@ -820,7 +812,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
g.fillPolygon(xPoints, yPoints, 5);
}
else {
- g.setColor(getFoldingColor(active));
+ g.setColor(getOutlineColor(active));
g.drawPolygon(xPoints, yPoints, 5);
//Minus
@@ -855,11 +847,11 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
g.fillRect(anchorX, y, width, width);
}
else {
- g.setColor(getFoldingColor(active));
+ g.setColor(getOutlineColor(active));
g.drawRect(anchorX, y, width, width);
// Draw plus
- if (!active) g.setColor(getFoldingColor(true));
+ if (!active) g.setColor(getOutlineColor(true));
UIUtil.drawLine(g, anchorX + 2, y + width / 2, anchorX + width - 2, y + width / 2);
}
}
@@ -876,7 +868,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
int lineX = anchorX + width / 2;
- g.setColor(getFoldingColor(true));
+ g.setColor(getOutlineColor(true));
UIUtil.drawLine(g, lineX, startY, lineX, endY);
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
index 4cd94276b027..b935c71b4c0d 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
@@ -176,7 +176,6 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
private static final int MOUSE_SELECTION_STATE_LINE_SELECTED = 2;
private final MarkupModelListener myMarkupModelListener;
- private final Listtrue if there is at least one soft wrap registered at the current storage; false otherwise
@@ -103,6 +114,10 @@ public class SoftWrapsStorage {
i = -i - 1;
myWraps.add(i, softWrap);
+ int changedLogicalLine = myDocument.getLineNumber(softWrap.getStart());
+ for (SoftWrapChangeListener listener : myListeners) {
+ listener.softWrapsStateChanged(changedLogicalLine);
+ }
return null;
}
@@ -127,4 +142,14 @@ public class SoftWrapsStorage {
public void removeAll() {
myWraps.clear();
}
+
+ /**
+ * Registers given listener within the current model
+ *
+ * @param listener listener to register
+ * @return true if given listener was not registered before; false otherwise
+ */
+ public boolean addSoftWrapChangeListener(@NotNull SoftWrapChangeListener listener) {
+ return myListeners.add(listener);
+ }
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorComposite.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorComposite.java
index 16a857560f58..dcd7e45aeda7 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorComposite.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorComposite.java
@@ -20,6 +20,8 @@ import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.colors.EditorColors;
+import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.fileEditor.*;
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
import com.intellij.openapi.project.DumbService;
@@ -29,6 +31,7 @@ import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.FocusWatcher;
import com.intellij.ui.PrevNextActionsDescriptor;
+import com.intellij.ui.SideBorder;
import com.intellij.ui.TabbedPaneWrapper;
import com.intellij.ui.tabs.UiDecorator;
import org.jetbrains.annotations.NotNull;
@@ -77,7 +80,6 @@ public abstract class EditorComposite implements Disposable {
private FileEditor mySelectedEditor;
private final FileEditorManagerEx myFileEditorManager;
private final long myInitialFileModificationStamp;
- private final Mapnull.
*/
@@ -409,4 +401,33 @@ public abstract class EditorComposite implements Disposable {
public void dispose() {
}
+
+ private class TopBottomPanel extends JPanel {
+ private TopBottomPanel() {
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+ }
+
+ @Override
+ public Color getBackground() {
+ Color color = EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.GUTTER_BACKGROUND);
+ return color == null ? Color.gray : color;
+ }
+ }
+
+ private class TopBottomComponentWrapper extends JPanel {
+ public TopBottomComponentWrapper(JComponent component, boolean top) {
+ super(new BorderLayout());
+ setOpaque(false);
+
+ setBorder(new SideBorder(null, top ? SideBorder.BOTTOM : SideBorder.TOP, true) {
+ @Override
+ public Color getLineColor() {
+ Color result = EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.TEARLINE_COLOR);
+ return result == null ? Color.black : result;
+ }
+ });
+
+ add(component);
+ }
+ }
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorInfoPane.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorInfoPane.java
deleted file mode 100644
index 759ad4fa40b0..000000000000
--- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorInfoPane.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * 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 com.intellij.openapi.fileEditor.impl;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.ArrayList;
-
-/**
- * @author max
- */
-public class FileEditorInfoPane extends JPanel {
- private int myCounter = 0;
- private final JPanel myCards;
- private final JButton myPrevButton;
- private final JButton myNextButton;
- private final java.util.Listtrue if and only if the holder has
+ * not null value by the key.
+ *
+ * @param holder user data holder object
+ * @return true if holder.getUserData(this) != null
+ * false otherwise.
+ */
+ public boolean isIn(@Nullable UserDataHolder holder) {
+ return get(holder) != null;
+ }
+
+ public void set(@Nullable UserDataHolder holder, T value) {
+ if (holder != null) {
+ holder.putUserData(this, value);
+ }
+ }
+}
\ No newline at end of file
diff --git a/platform/util/src/com/intellij/ui/SideBorder.java b/platform/util/src/com/intellij/ui/SideBorder.java
index 9deb144659d8..37e6df1143ec 100644
--- a/platform/util/src/com/intellij/ui/SideBorder.java
+++ b/platform/util/src/com/intellij/ui/SideBorder.java
@@ -66,24 +66,24 @@ public class SideBorder extends LineBorder {
g.setColor(getLineColor());
for(i = 0; i < getThickness(); i++){
if ((mySideMask & LEFT) != 0){
- drawLine(g, x + i, y + i, x + i, height - i - i - 1);
+ drawLine(c, g, x + i, y + i, x + i, height - i - i - 1);
}
if ((mySideMask & TOP) != 0){
- drawLine(g, x + i, y + i, width - i - i - 1, y + i);
+ drawLine(c, g, x + i, y + i, width - i - i - 1, y + i);
}
if ((mySideMask & RIGHT) != 0){
- drawLine(g, width - i - i - 1, y + i, width - i - i - 1, height - i - i - 1);
+ drawLine(c, g, width - i - i - 1, y + i, width - i - i - 1, height - i - i - 1);
}
if ((mySideMask & BOTTOM) != 0){
- drawLine(g, x + i, height - i - i - 1, width - i - i - 1, height - i - i - 1);
+ drawLine(c, g, x + i, height - i - i - 1, width - i - i - 1, height - i - i - 1);
}
}
g.setColor(oldColor);
}
- private void drawLine(Graphics g, int x1, int y1, int x2, int y2) {
+ private void drawLine(Component c, Graphics g, int x1, int y1, int x2, int y2) {
if (myDotted) {
- UIUtil.drawDottedLine((Graphics2D)g, x1, y1, x2, y2, ((Graphics2D)g).getBackground(), getLineColor());
+ UIUtil.drawDottedLine((Graphics2D)g, x1, y1, x2, y2, null, getLineColor());
}
else {
UIUtil.drawLine(g, x1, y1, x2, y2);
diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java
index c536375e1d51..57a7a6866bce 100644
--- a/platform/util/src/com/intellij/util/ui/UIUtil.java
+++ b/platform/util/src/com/intellij/util/ui/UIUtil.java
@@ -889,20 +889,23 @@ public class UIUtil {
});
}
- public static void drawVDottedLine(Graphics2D g, int lineX, int startY, int endY, final Color bgColor, final Color fgColor) {
- g.setColor(bgColor);
- drawLine(g, lineX, startY, lineX, endY);
+ public static void drawVDottedLine(Graphics2D g, int lineX, int startY, int endY, @Nullable final Color bgColor, final Color fgColor) {
+ if (bgColor != null) {
+ g.setColor(bgColor);
+ drawLine(g, lineX, startY, lineX, endY);
+ }
g.setColor(fgColor);
-
for (int i = (startY / 2) * 2; i < endY; i += 2) {
g.drawRect(lineX, i, 0, 0);
}
}
- public static void drawHDottedLine(Graphics2D g, int startX, int endX, int lineY, final Color bgColor, final Color fgColor) {
- g.setColor(bgColor);
- drawLine(g, startX, lineY, endX, lineY);
+ public static void drawHDottedLine(Graphics2D g, int startX, int endX, int lineY, @Nullable final Color bgColor, final Color fgColor) {
+ if (bgColor != null) {
+ g.setColor(bgColor);
+ drawLine(g, startX, lineY, endX, lineY);
+ }
g.setColor(fgColor);
@@ -911,7 +914,7 @@ public class UIUtil {
}
}
- public static void drawDottedLine(Graphics2D g, int x1, int y1, int x2, int y2, final Color bgColor, final Color fgColor) {
+ public static void drawDottedLine(Graphics2D g, int x1, int y1, int x2, int y2, @Nullable final Color bgColor, final Color fgColor) {
if (x1 == x2) {
drawVDottedLine(g, x1, y1, y2, bgColor, fgColor);
}
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/annotate/LineAnnotationAspectAdapter.java b/platform/vcs-api/src/com/intellij/openapi/vcs/annotate/LineAnnotationAspectAdapter.java
index 5670a5682501..7fca123359ba 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/annotate/LineAnnotationAspectAdapter.java
+++ b/platform/vcs-api/src/com/intellij/openapi/vcs/annotate/LineAnnotationAspectAdapter.java
@@ -15,8 +15,23 @@
*/
package com.intellij.openapi.vcs.annotate;
-public abstract class LineAnnotationAspectAdapter implements LineAnnotationAspect {
+import com.intellij.openapi.editor.EditorGutterAction;
+
+import java.awt.*;
+
+public abstract class LineAnnotationAspectAdapter implements LineAnnotationAspect, EditorGutterAction {
public String getTooltipText(int lineNumber) {
return null;
}
+
+ public Cursor getCursor(final int lineNum) {
+ return Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
+ }
+
+ @Override
+ public void doAction(int lineNum) {
+ showAffectedPaths(lineNum);
+ }
+
+ protected abstract void showAffectedPaths(int lineNum);
}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/OutdatedVersionNotifier.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/OutdatedVersionNotifier.java
index 2915b1c4faff..459edc2a4b36 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/OutdatedVersionNotifier.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/OutdatedVersionNotifier.java
@@ -18,6 +18,7 @@ package com.intellij.openapi.vcs.changes.committed;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java
index ee988600c8d7..1f299e5c1f40 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java
@@ -216,7 +216,7 @@ public class LineStatusTracker {
int width = endX - x;
if (r.height > 0) {
g.fillRect(x, r.y + 2, width, r.height - 4);
- g.setColor(gutter.getFoldingColor(false));
+ g.setColor(gutter.getOutlineColor(false));
UIUtil.drawLine(g, x, r.y + 2, x + width, r.y + 2);
UIUtil.drawLine(g, x, r.y + 2, x, r.y + r.height - 3);
UIUtil.drawLine(g, x, r.y + r.height - 3, x + width, r.y + r.height - 3);
@@ -230,7 +230,7 @@ public class LineStatusTracker {
r.y};
g.fillPolygon(xPoints, yPoints, 3);
- g.setColor(gutter.getFoldingColor(false));
+ g.setColor(gutter.getOutlineColor(false));
g.drawPolygon(xPoints, yPoints, 3);
}
}
diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/annotate/CvsFileAnnotation.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/annotate/CvsFileAnnotation.java
index 209635c2a056..dc9378fd1e9e 100644
--- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/annotate/CvsFileAnnotation.java
+++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/annotate/CvsFileAnnotation.java
@@ -37,7 +37,7 @@ public class CvsFileAnnotation implements FileAnnotation{
private final VirtualFile myFile;
private final ListCopyright (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