mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
Generated
+14
@@ -0,0 +1,14 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Kryo">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/minlog-1.2.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/kryo-2.22.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/reflectasm-1.07.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/objenesis-1.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/kryo-src.zip!/src" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
Generated
+1
@@ -65,6 +65,7 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/google-app-engine/google-app-engine.iml" filepath="$PROJECT_DIR$/plugins/google-app-engine/google-app-engine.iml" group="plugins/GAE" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/google-app-engine/jps-plugin/google-app-engine-jps-plugin.iml" filepath="$PROJECT_DIR$/plugins/google-app-engine/jps-plugin/google-app-engine-jps-plugin.iml" group="plugins/GAE" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/gradle.iml" filepath="$PROJECT_DIR$/plugins/gradle/gradle.iml" group="community/plugins/gradle" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/jps-plugin/gradle-jps-plugin.iml" filepath="$PROJECT_DIR$/plugins/gradle/jps-plugin/gradle-jps-plugin.iml" group="community/plugins/gradle" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/tooling-extension-api/gradle-tooling-extension-api.iml" filepath="$PROJECT_DIR$/plugins/gradle/tooling-extension-api/gradle-tooling-extension-api.iml" group="community/plugins/gradle" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/tooling-extension-impl/gradle-tooling-extension-impl.iml" filepath="$PROJECT_DIR$/plugins/gradle/tooling-extension-impl/gradle-tooling-extension-impl.iml" group="community/plugins/gradle" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/groovy/jps-plugin/groovy-jps-plugin.iml" filepath="$PROJECT_DIR$/plugins/groovy/jps-plugin/groovy-jps-plugin.iml" group="plugins/Groovy" />
|
||||
|
||||
@@ -336,6 +336,10 @@ public def layoutCommunityPlugins(String home) {
|
||||
}
|
||||
|
||||
layoutPlugin("gradle") {
|
||||
jar("gradle-jps-plugin.jar") {
|
||||
module("gradle-jps-plugin")
|
||||
}
|
||||
|
||||
jar("gradle-tooling-extension-api.jar") {
|
||||
module("gradle-tooling-extension-api")
|
||||
}
|
||||
@@ -344,6 +348,13 @@ public def layoutCommunityPlugins(String home) {
|
||||
module("gradle-tooling-extension-impl")
|
||||
}
|
||||
fileset(dir: "$home/plugins/gradle/lib") { include(name: "*.jar") }
|
||||
// add kryo lib
|
||||
fileset(dir: "$home/lib/") {
|
||||
include(name: "kryo-*.jar")
|
||||
include(name: "reflectasm-*.jar")
|
||||
include(name: "objenesis-*.jar")
|
||||
include(name: "minlog-*.jar")
|
||||
}
|
||||
}
|
||||
|
||||
layoutPlugin("git4idea") {
|
||||
@@ -753,6 +764,7 @@ def layoutJps(String home, String targetDir, String buildNumber, Closure additio
|
||||
|
||||
|
||||
jar("maven-jps-plugin.jar") { module("maven-jps-plugin") }
|
||||
jar("gradle-jps-plugin.jar") { module("gradle-jps-plugin") }
|
||||
fileset(dir: "$home/plugins/maven/maven3-server-impl/lib/maven3/lib") {include(name: "plexus-utils-*.jar")}
|
||||
|
||||
jar("eclipse-jps-plugin.jar") {
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<orderEntry type="module" module-name="testFramework-java" scope="TEST" />
|
||||
<orderEntry type="module" module-name="jps-model-impl" />
|
||||
<orderEntry type="module" module-name="java-analysis-impl" />
|
||||
<orderEntry type="module" module-name="xml" />
|
||||
</component>
|
||||
<component name="copyright">
|
||||
<Base>
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package org.jetbrains.builtInWebServer;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactManager;
|
||||
import com.intellij.util.PairFunction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
final class ArtifactProjectRootsProvider extends ProjectRootsProvider.PrefixlessProjectRootsProvider {
|
||||
@Nullable
|
||||
@Override
|
||||
public Pair<VirtualFile, Pair<VirtualFile, String>> resolve(@NotNull String path, @NotNull Project project, @NotNull PairFunction<String, VirtualFile, VirtualFile> resolver) {
|
||||
for (Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) {
|
||||
VirtualFile root = artifact.getOutputFile();
|
||||
if (root != null) {
|
||||
VirtualFile file = root.findFileByRelativePath(path);
|
||||
if (file != null) {
|
||||
return Pair.create(file, new Pair<VirtualFile, String>(root, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Pair<VirtualFile, String> getRoot(@NotNull VirtualFile file, @NotNull Project project) {
|
||||
for (Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) {
|
||||
VirtualFile root = artifact.getOutputFile();
|
||||
if (root != null && VfsUtilCore.isAncestor(root, file, true)) {
|
||||
return Pair.create(root, null);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+32
-71
@@ -25,13 +25,10 @@ import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.debugger.ui.DebuggerExpressionTextField;
|
||||
import com.intellij.debugger.ui.JavaDebuggerSupport;
|
||||
import com.intellij.debugger.ui.tree.render.*;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.options.UnnamedConfigurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
@@ -51,54 +48,33 @@ import java.awt.event.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Feb 24, 2005
|
||||
*/
|
||||
public class CompoundRendererConfigurable implements UnnamedConfigurable {
|
||||
class CompoundRendererConfigurable extends JPanel {
|
||||
private CompoundReferenceRenderer myRenderer;
|
||||
private CompoundReferenceRenderer myOriginalRenderer;
|
||||
private Project myProject;
|
||||
private ClassNameEditorWithBrowseButton myClassNameField;
|
||||
private JRadioButton myRbDefaultLabel;
|
||||
private JRadioButton myRbExpressionLabel;
|
||||
private JRadioButton myRbDefaultChildrenRenderer;
|
||||
private JRadioButton myRbExpressionChildrenRenderer;
|
||||
private JRadioButton myRbListChildrenRenderer;
|
||||
private DebuggerExpressionTextField myLabelEditor;
|
||||
private DebuggerExpressionTextField myChildrenEditor;
|
||||
private DebuggerExpressionTextField myChildrenExpandedEditor;
|
||||
private final ClassNameEditorWithBrowseButton myClassNameField;
|
||||
private final JRadioButton myRbDefaultLabel;
|
||||
private final JRadioButton myRbExpressionLabel;
|
||||
private final JRadioButton myRbDefaultChildrenRenderer;
|
||||
private final JRadioButton myRbExpressionChildrenRenderer;
|
||||
private final JRadioButton myRbListChildrenRenderer;
|
||||
private final DebuggerExpressionTextField myLabelEditor;
|
||||
private final DebuggerExpressionTextField myChildrenEditor;
|
||||
private final DebuggerExpressionTextField myChildrenExpandedEditor;
|
||||
private DebuggerExpressionTextField myListChildrenEditor;
|
||||
private JLabel myExpandedLabel;
|
||||
private JPanel myMainPanel;
|
||||
private final JLabel myExpandedLabel;
|
||||
private JBTable myTable;
|
||||
@NonNls private static final String EMPTY_PANEL_ID = "EMPTY";
|
||||
@NonNls private static final String DATA_PANEL_ID = "DATA";
|
||||
private static final int NAME_TABLE_COLUMN = 0;
|
||||
private static final int EXPRESSION_TABLE_COLUMN = 1;
|
||||
|
||||
public void setRenderer(NodeRenderer renderer) {
|
||||
if (renderer instanceof CompoundReferenceRenderer) {
|
||||
myRenderer = (CompoundReferenceRenderer)renderer;
|
||||
myOriginalRenderer = (CompoundReferenceRenderer)renderer.clone();
|
||||
}
|
||||
else {
|
||||
myRenderer = myOriginalRenderer = null;
|
||||
}
|
||||
reset();
|
||||
}
|
||||
public CompoundRendererConfigurable() {
|
||||
super(new CardLayout());
|
||||
|
||||
public CompoundReferenceRenderer getRenderer() {
|
||||
return myRenderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JComponent createComponent() {
|
||||
if (myProject == null) {
|
||||
myProject = JavaDebuggerSupport.getContextProjectForEditorFieldsInDebuggerConfigurables();
|
||||
}
|
||||
final JPanel panel = new JPanel(new GridBagLayout());
|
||||
|
||||
myRbDefaultLabel = new JRadioButton(DebuggerBundle.message("label.compound.renderer.configurable.use.default.renderer"));
|
||||
myRbExpressionLabel = new JRadioButton(DebuggerBundle.message("label.compound.renderer.configurable.use.expression"));
|
||||
@@ -141,21 +117,14 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable {
|
||||
}
|
||||
}
|
||||
}, myProject);
|
||||
final EditorTextField textField = myClassNameField.getEditorTextField();
|
||||
final FocusAdapter updateContextListener = new FocusAdapter() {
|
||||
myClassNameField.getEditorTextField().addFocusListener(new FocusAdapter() {
|
||||
@Override
|
||||
public void focusLost(@NotNull FocusEvent e) {
|
||||
updateContext(myClassNameField.getText());
|
||||
}
|
||||
};
|
||||
textField.addFocusListener(updateContextListener);
|
||||
Disposer.register(myClassNameField, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
textField.removeFocusListener(updateContextListener);
|
||||
}
|
||||
});
|
||||
|
||||
JPanel panel = new JPanel(new GridBagLayout());
|
||||
panel.add(new JLabel(DebuggerBundle.message("label.compound.renderer.configurable.apply.to")),
|
||||
new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
|
||||
new Insets(0, 0, 0, 0), 0, 0));
|
||||
@@ -196,11 +165,23 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable {
|
||||
panel.add(myChildrenListEditor,
|
||||
new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
|
||||
new Insets(4, 30, 0, 0), 0, 0));
|
||||
add(new JPanel(), EMPTY_PANEL_ID);
|
||||
add(panel, DATA_PANEL_ID);
|
||||
}
|
||||
|
||||
myMainPanel = new JPanel(new CardLayout());
|
||||
myMainPanel.add(new JPanel(), EMPTY_PANEL_ID);
|
||||
myMainPanel.add(panel, DATA_PANEL_ID);
|
||||
return myMainPanel;
|
||||
public void setRenderer(NodeRenderer renderer) {
|
||||
if (renderer instanceof CompoundReferenceRenderer) {
|
||||
myRenderer = (CompoundReferenceRenderer)renderer;
|
||||
myOriginalRenderer = (CompoundReferenceRenderer)renderer.clone();
|
||||
}
|
||||
else {
|
||||
myRenderer = myOriginalRenderer = null;
|
||||
}
|
||||
reset();
|
||||
}
|
||||
|
||||
public CompoundReferenceRenderer getRenderer() {
|
||||
return myRenderer;
|
||||
}
|
||||
|
||||
private void updateContext(final String qName) {
|
||||
@@ -305,7 +286,6 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable {
|
||||
}).createPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
if (myRenderer == null) {
|
||||
return false;
|
||||
@@ -315,7 +295,6 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable {
|
||||
return !DebuggerUtilsEx.externalizableEqual(cloned, myOriginalRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
if (myRenderer == null) {
|
||||
return;
|
||||
@@ -347,10 +326,9 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable {
|
||||
renderer.setClassName(myClassNameField.getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
final TextWithImports emptyExpressionFragment = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, "");
|
||||
((CardLayout)myMainPanel.getLayout()).show(myMainPanel, myRenderer == null ? EMPTY_PANEL_ID : DATA_PANEL_ID);
|
||||
((CardLayout)getLayout()).show(this, myRenderer == null ? EMPTY_PANEL_ID : DATA_PANEL_ID);
|
||||
if (myRenderer == null) {
|
||||
return;
|
||||
}
|
||||
@@ -398,23 +376,6 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable {
|
||||
updateContext(className);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeUIResources() {
|
||||
myRenderer = null;
|
||||
myOriginalRenderer = null;
|
||||
myLabelEditor.dispose();
|
||||
myChildrenEditor.dispose();
|
||||
myChildrenExpandedEditor.dispose();
|
||||
myListChildrenEditor.dispose();
|
||||
Disposer.dispose(myClassNameField);
|
||||
myLabelEditor = null;
|
||||
myChildrenEditor = null;
|
||||
myChildrenExpandedEditor = null;
|
||||
myListChildrenEditor = null;
|
||||
myClassNameField = null;
|
||||
myProject = null;
|
||||
}
|
||||
|
||||
private MyTableModel getTableModel() {
|
||||
return (MyTableModel)myTable.getModel();
|
||||
}
|
||||
|
||||
+6
-18
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -35,10 +35,6 @@ import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Feb 19, 2005
|
||||
*/
|
||||
public class UserRenderersConfigurable implements ConfigurableUi<NodeRendererSettings> {
|
||||
private static final Icon ADD_ICON = IconUtil.getAddIcon();
|
||||
private static final Icon REMOVE_ICON = IconUtil.getRemoveIcon();
|
||||
@@ -55,16 +51,9 @@ public class UserRenderersConfigurable implements ConfigurableUi<NodeRendererSet
|
||||
@Override
|
||||
@NotNull
|
||||
public JComponent getComponent() {
|
||||
final JPanel panel = new JPanel(new BorderLayout(4, 0));
|
||||
|
||||
final JComponent renderersList = createRenderersList();
|
||||
final JComponent toolbar = createToolbar();
|
||||
final JComponent rendererDataPanel = myRendererDataConfigurable.createComponent();
|
||||
|
||||
final JPanel left = new JPanel(new BorderLayout());
|
||||
|
||||
left.add(toolbar, BorderLayout.NORTH);
|
||||
left.add(renderersList, BorderLayout.CENTER);
|
||||
JPanel left = new JPanel(new BorderLayout());
|
||||
left.add(createToolbar(), BorderLayout.NORTH);
|
||||
left.add(createRenderersList(), BorderLayout.CENTER);
|
||||
|
||||
myNameField = new JTextField();
|
||||
myNameFieldPanel = new JPanel(new BorderLayout());
|
||||
@@ -73,9 +62,8 @@ public class UserRenderersConfigurable implements ConfigurableUi<NodeRendererSet
|
||||
myNameFieldPanel.setVisible(false);
|
||||
|
||||
final JPanel center = new JPanel(new BorderLayout(0, 4));
|
||||
|
||||
center.add(myNameFieldPanel, BorderLayout.NORTH);
|
||||
center.add(rendererDataPanel, BorderLayout.CENTER);
|
||||
center.add(myRendererDataConfigurable, BorderLayout.CENTER);
|
||||
|
||||
myNameField.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
@@ -87,9 +75,9 @@ public class UserRenderersConfigurable implements ConfigurableUi<NodeRendererSet
|
||||
}
|
||||
});
|
||||
|
||||
JPanel panel = new JPanel(new BorderLayout(4, 0));
|
||||
panel.add(left, BorderLayout.WEST);
|
||||
panel.add(center, BorderLayout.CENTER);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ public abstract class JavaBreakpointTypeBase<T extends JavaBreakpointProperties>
|
||||
Breakpoint javaBreakpoint = BreakpointManager.getJavaBreakpoint(breakpoint);
|
||||
if (javaBreakpoint != null) {
|
||||
PsiClass aClass = javaBreakpoint.getPsiClass();
|
||||
if (aClass != null && aClass.getContainingFile() != null) {
|
||||
if (aClass != null && aClass.getContainingFile() != null && aClass.getTextOffset() >= 0) {
|
||||
return XDebuggerUtil.getInstance().createPositionByOffset(aClass.getContainingFile().getVirtualFile(), aClass.getTextOffset());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,6 +280,7 @@ public class JavaArrangementVisitor extends JavaRecursiveElementVisitor {
|
||||
if (ref instanceof PsiField && containingClassFields.contains(ref)) {
|
||||
referencedElements.add((PsiField)ref);
|
||||
}
|
||||
super.visitReferenceExpression(expression);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.psi.impl.search;
|
||||
import com.intellij.lang.LanguageParserDefinitions;
|
||||
import com.intellij.lang.ParserDefinition;
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.openapi.editor.impl.EditorHighlighterCache;
|
||||
import com.intellij.psi.JspPsiUtil;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.impl.source.tree.StdTokenSets;
|
||||
@@ -34,7 +35,7 @@ public class JspIndexPatternBuilder implements IndexPatternBuilder {
|
||||
@Override
|
||||
public Lexer getIndexingLexer(@NotNull final PsiFile file) {
|
||||
if (JspPsiUtil.isInJspFile(file)) {
|
||||
return LexerEditorHighlighterLexer.getLexerBasedOnLexerHighlighter(file.getText(), file.getVirtualFile(), file.getProject());
|
||||
return EditorHighlighterCache.getLexerBasedOnLexerHighlighter(file.getText(), file.getVirtualFile(), file.getProject());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -687,4 +687,33 @@ public class PsiImplUtil {
|
||||
return element instanceof LeafElement && tokenSet.contains(((LeafElement)element).getElementType());
|
||||
}
|
||||
|
||||
public static PsiType buildTypeFromTypeString(@NotNull final String typeName, @NotNull final PsiElement context, @NotNull final PsiFile psiFile) {
|
||||
PsiType resultType;
|
||||
final PsiManager psiManager = psiFile.getManager();
|
||||
|
||||
if (typeName.indexOf('<') != -1 || typeName.indexOf('[') != -1 || typeName.indexOf('.') == -1) {
|
||||
try {
|
||||
return JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory().createTypeFromText(typeName, context);
|
||||
} catch(Exception ex) {} // invalid syntax will produce unresolved class type
|
||||
}
|
||||
|
||||
PsiClass aClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(typeName, context.getResolveScope());
|
||||
|
||||
if (aClass == null) {
|
||||
final LightClassReference ref = new LightClassReference(
|
||||
psiManager,
|
||||
PsiNameHelper.getShortClassName(typeName),
|
||||
typeName,
|
||||
PsiSubstitutor.EMPTY,
|
||||
psiFile
|
||||
);
|
||||
resultType = new PsiClassReferenceType(ref, null);
|
||||
} else {
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory();
|
||||
PsiSubstitutor substitutor = factory.createRawSubstitutor(aClass);
|
||||
resultType = factory.createType(aClass, substitutor);
|
||||
}
|
||||
|
||||
return resultType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@ myStringToFind =a
|
||||
myStringToReplace =
|
||||
isReplaceState =false
|
||||
isWholeWordsOnly =false
|
||||
isInStringLiterals =false
|
||||
isInComments =false
|
||||
searchContext =ANY
|
||||
isFromCursor =true
|
||||
isForward =true
|
||||
isGlobal =true
|
||||
|
||||
@@ -3,8 +3,7 @@ myStringToFind =a
|
||||
myStringToReplace =
|
||||
isReplaceState =false
|
||||
isWholeWordsOnly =false
|
||||
isInStringLiterals =false
|
||||
isInComments =false
|
||||
searchContext =ANY
|
||||
isFromCursor =true
|
||||
isForward =true
|
||||
isGlobal =true
|
||||
@@ -38,8 +37,7 @@ myStringToFind =ab
|
||||
myStringToReplace =
|
||||
isReplaceState =false
|
||||
isWholeWordsOnly =false
|
||||
isInStringLiterals =false
|
||||
isInComments =false
|
||||
searchContext =ANY
|
||||
isFromCursor =true
|
||||
isForward =true
|
||||
isGlobal =true
|
||||
@@ -72,8 +70,7 @@ myStringToFind =a
|
||||
myStringToReplace =
|
||||
isReplaceState =false
|
||||
isWholeWordsOnly =false
|
||||
isInStringLiterals =false
|
||||
isInComments =false
|
||||
searchContext =ANY
|
||||
isFromCursor =true
|
||||
isForward =true
|
||||
isGlobal =true
|
||||
|
||||
@@ -3,8 +3,7 @@ myStringToFind =
|
||||
myStringToReplace =
|
||||
isReplaceState =false
|
||||
isWholeWordsOnly =false
|
||||
isInStringLiterals =false
|
||||
isInComments =false
|
||||
searchContext =ANY
|
||||
isFromCursor =true
|
||||
isForward =true
|
||||
isGlobal =true
|
||||
@@ -34,8 +33,7 @@ myStringToFind =a
|
||||
myStringToReplace =
|
||||
isReplaceState =false
|
||||
isWholeWordsOnly =false
|
||||
isInStringLiterals =false
|
||||
isInComments =false
|
||||
searchContext =ANY
|
||||
isFromCursor =true
|
||||
isForward =true
|
||||
isGlobal =true
|
||||
@@ -67,8 +65,7 @@ myStringToFind =a
|
||||
myStringToReplace =
|
||||
isReplaceState =true
|
||||
isWholeWordsOnly =false
|
||||
isInStringLiterals =false
|
||||
isInComments =false
|
||||
searchContext =ANY
|
||||
isFromCursor =true
|
||||
isForward =true
|
||||
isGlobal =true
|
||||
@@ -102,8 +99,7 @@ myStringToFind =a
|
||||
myStringToReplace =
|
||||
isReplaceState =true
|
||||
isWholeWordsOnly =false
|
||||
isInStringLiterals =false
|
||||
isInComments =false
|
||||
searchContext =ANY
|
||||
isFromCursor =true
|
||||
isForward =true
|
||||
isGlobal =true
|
||||
|
||||
@@ -615,7 +615,7 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
|
||||
FindModel findModel = FindManagerTestUtils.configureFindModel("^done$");
|
||||
|
||||
findModel.setRegularExpressions(true);
|
||||
findModel.setSearchContext(FindModel.SearchContext.IN_STRINGS);
|
||||
findModel.setSearchContext(FindModel.SearchContext.IN_STRING_LITERALS);
|
||||
String text = "\"done\"; 'done'; 'done' \"done2\"";
|
||||
FindManagerTestUtils.runFindForwardAndBackward(myFindManager, findModel, text, "java");
|
||||
|
||||
@@ -650,4 +650,42 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
|
||||
findModel.setWholeWordsOnly(true);
|
||||
assertSize(1, findUsages(findModel));
|
||||
}
|
||||
|
||||
public void testFindExceptComments() {
|
||||
FindModel findModel = FindManagerTestUtils.configureFindModel("done");
|
||||
|
||||
String prefix = "/*";
|
||||
String text = prefix + "done*/done";
|
||||
|
||||
findModel.setSearchContext(FindModel.SearchContext.EXCEPT_COMMENTS);
|
||||
LightVirtualFile file = new LightVirtualFile("A.java", text);
|
||||
|
||||
FindResult findResult = myFindManager.findString(text, prefix.length(), findModel, file);
|
||||
assertTrue(findResult.isStringFound());
|
||||
assertTrue(findResult.getStartOffset() > prefix.length());
|
||||
|
||||
findModel.setRegularExpressions(true);
|
||||
findResult = myFindManager.findString(text, prefix.length(), findModel, file);
|
||||
assertTrue(findResult.isStringFound());
|
||||
assertTrue(findResult.getStartOffset() > prefix.length());
|
||||
}
|
||||
|
||||
public void testFindExceptLiterals() {
|
||||
FindModel findModel = FindManagerTestUtils.configureFindModel("done");
|
||||
|
||||
String prefix = "\"";
|
||||
String text = prefix + "done\"done";
|
||||
|
||||
findModel.setSearchContext(FindModel.SearchContext.EXCEPT_STRING_LITERALS);
|
||||
LightVirtualFile file = new LightVirtualFile("A.java", text);
|
||||
|
||||
FindResult findResult = myFindManager.findString(text, prefix.length(), findModel, file);
|
||||
assertTrue(findResult.isStringFound());
|
||||
assertTrue(findResult.getStartOffset() > prefix.length());
|
||||
|
||||
findModel.setRegularExpressions(true);
|
||||
findResult = myFindManager.findString(text, prefix.length(), findModel, file);
|
||||
assertTrue(findResult.isStringFound());
|
||||
assertTrue(findResult.getStartOffset() > prefix.length());
|
||||
}
|
||||
}
|
||||
|
||||
+24
@@ -385,4 +385,28 @@ public class test {
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
void "test IDEA-128071"() {
|
||||
doTest(
|
||||
initial: '''
|
||||
public class FormatTest {
|
||||
public int a = 3;
|
||||
private static final String FACEBOOK_CLIENT_ID = "";
|
||||
public static final String FACEBOOK_OAUTH_URL = "".concat(FACEBOOK_CLIENT_ID).concat("");
|
||||
}
|
||||
''',
|
||||
expected: '''
|
||||
public class FormatTest {
|
||||
private static final String FACEBOOK_CLIENT_ID = "";
|
||||
public static final String FACEBOOK_OAUTH_URL = "".concat(FACEBOOK_CLIENT_ID).concat("");
|
||||
public int a = 3;
|
||||
}
|
||||
''',
|
||||
rules: [
|
||||
rule(PUBLIC, STATIC, FINAL),
|
||||
rule(PRIVATE, STATIC, FINAL),
|
||||
rule(PUBLIC)
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class FindManagerTestUtils {
|
||||
}
|
||||
|
||||
public static void runFindInCommentsAndLiterals(FindManager findManager, FindModel findModel, String text, String ext) {
|
||||
findModel.setSearchContext(FindModel.SearchContext.IN_STRINGS);
|
||||
findModel.setSearchContext(FindModel.SearchContext.IN_STRING_LITERALS);
|
||||
runFindForwardAndBackward(findManager, findModel, text, ext);
|
||||
|
||||
findModel.setSearchContext(FindModel.SearchContext.IN_COMMENTS);
|
||||
|
||||
+17
-20
@@ -16,16 +16,19 @@
|
||||
package org.jetbrains.jps.model.serialization;
|
||||
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.intellij.openapi.util.io.FileUtil.toSystemIndependentName;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
@@ -34,9 +37,16 @@ public class PathMacroUtil {
|
||||
@NonNls public static final String MODULE_DIR_MACRO_NAME = "MODULE_DIR";
|
||||
@NonNls public static final String DIRECTORY_STORE_NAME = ".idea";
|
||||
@NonNls public static final String APPLICATION_HOME_DIR = "APPLICATION_HOME_DIR";
|
||||
@NonNls public static final String APPLICATION_CONFIG_DIR = "APPLICATION_CONFIG_DIR";
|
||||
@NonNls public static final String APPLICATION_PLUGINS_DIR = "APPLICATION_PLUGINS_DIR";
|
||||
@NonNls public static final String USER_HOME_NAME = "USER_HOME";
|
||||
|
||||
private static final Map<String, String> ourGlobalMacros = ContainerUtil.<String, String>immutableMapBuilder()
|
||||
.put(APPLICATION_HOME_DIR, toSystemIndependentName(PathManager.getHomePath()))
|
||||
.put(APPLICATION_CONFIG_DIR, toSystemIndependentName(PathManager.getConfigPath()))
|
||||
.put(APPLICATION_PLUGINS_DIR, toSystemIndependentName(PathManager.getPluginsPath()))
|
||||
.put(USER_HOME_NAME, StringUtil.trimEnd(toSystemIndependentName(SystemProperties.getUserHome()), "/")).build();
|
||||
|
||||
@Nullable
|
||||
public static String getModuleDir(String moduleFilePath) {
|
||||
File moduleDirFile = new File(moduleFilePath).getParentFile();
|
||||
@@ -57,31 +67,18 @@ public class PathMacroUtil {
|
||||
return moduleDir;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getUserHomePath() {
|
||||
return StringUtil.trimEnd(FileUtil.toSystemIndependentName(SystemProperties.getUserHome()), "/");
|
||||
return ObjectUtils.assertNotNull(getGlobalSystemMacroValue(USER_HOME_NAME));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Map<String, String> getGlobalSystemMacros() {
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
map.put(APPLICATION_HOME_DIR, getApplicationHomeDirPath());
|
||||
map.put(APPLICATION_PLUGINS_DIR, getApplicationPluginsDirPath());
|
||||
map.put(USER_HOME_NAME, getUserHomePath());
|
||||
return map;
|
||||
}
|
||||
|
||||
private static String getApplicationHomeDirPath() {
|
||||
return FileUtil.toSystemIndependentName(PathManager.getHomePath());
|
||||
}
|
||||
|
||||
private static String getApplicationPluginsDirPath() {
|
||||
return FileUtil.toSystemIndependentName(PathManager.getPluginsPath());
|
||||
return ourGlobalMacros;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getGlobalSystemMacroValue(String name) {
|
||||
if (APPLICATION_HOME_DIR.equals(name)) return getApplicationHomeDirPath();
|
||||
if (APPLICATION_PLUGINS_DIR.equals(name)) return getApplicationPluginsDirPath();
|
||||
if (USER_HOME_NAME.equals(name)) return getUserHomePath();
|
||||
return null;
|
||||
return ourGlobalMacros.get(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.dvcs.ui;
|
||||
|
||||
import com.intellij.dvcs.repo.Repository;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.vcs.log.VcsFullCommitDetails;
|
||||
import com.intellij.vcs.log.VcsLog;
|
||||
import com.intellij.vcs.log.VcsLogDataKeys;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class VcsLogAction<Repo extends Repository> extends DumbAwareAction {
|
||||
|
||||
protected enum Mode {
|
||||
SINGLE_COMMIT,
|
||||
SINGLE_PER_REPO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
|
||||
VcsLog log = e.getRequiredData(VcsLogDataKeys.VSC_LOG);
|
||||
List<VcsFullCommitDetails> details = log.getSelectedDetails();
|
||||
MultiMap<Repo, VcsFullCommitDetails> grouped = groupByRoot(project, details);
|
||||
assert grouped != null;
|
||||
Map<Repo, VcsFullCommitDetails> singleElementMap = convertToSingleElementMap(grouped);
|
||||
assert singleElementMap != null;
|
||||
actionPerformed(project, singleElementMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
Project project = e.getProject();
|
||||
VcsLog log = e.getData(VcsLogDataKeys.VSC_LOG);
|
||||
if (project == null || log == null) {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
List<VcsFullCommitDetails> details = log.getSelectedDetails();
|
||||
MultiMap<Repo, VcsFullCommitDetails> grouped = groupByRoot(project, details);
|
||||
if (grouped == null) {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
}
|
||||
else {
|
||||
e.getPresentation().setVisible(true);
|
||||
e.getPresentation().setEnabled(isEnabled(grouped));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEnabled(@NotNull MultiMap<Repo, VcsFullCommitDetails> grouped) {
|
||||
Mode mode = getMode();
|
||||
if (mode == Mode.SINGLE_COMMIT) {
|
||||
return grouped.size() == 1;
|
||||
}
|
||||
if (mode == Mode.SINGLE_PER_REPO) {
|
||||
return allValuesAreSingletons(grouped);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected abstract Repo getRepositoryForRoot(@NotNull Project project, @NotNull VirtualFile root);
|
||||
|
||||
protected abstract void actionPerformed(@NotNull Project project, @NotNull Map<Repo, VcsFullCommitDetails> commits);
|
||||
|
||||
@NotNull
|
||||
protected abstract Mode getMode();
|
||||
|
||||
@Nullable
|
||||
private MultiMap<Repo, VcsFullCommitDetails> groupByRoot(@NotNull Project project, @NotNull List<VcsFullCommitDetails> commits) {
|
||||
MultiMap<Repo, VcsFullCommitDetails> map = MultiMap.create();
|
||||
for (VcsFullCommitDetails commit : commits) {
|
||||
Repo root = getRepositoryForRoot(project, commit.getRoot());
|
||||
if (root == null) { // commit from some other VCS
|
||||
return null;
|
||||
}
|
||||
map.putValue(root, commit);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private boolean allValuesAreSingletons(@NotNull MultiMap<Repo, VcsFullCommitDetails> grouped) {
|
||||
return !ContainerUtil.exists(grouped.entrySet(), new Condition<Map.Entry<Repo, Collection<VcsFullCommitDetails>>>() {
|
||||
@Override
|
||||
public boolean value(Map.Entry<Repo, Collection<VcsFullCommitDetails>> entry) {
|
||||
return entry.getValue().size() != 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Map<Repo, VcsFullCommitDetails> convertToSingleElementMap(@NotNull MultiMap<Repo, VcsFullCommitDetails> groupedCommits) {
|
||||
Map<Repo, VcsFullCommitDetails> map = ContainerUtil.newHashMap();
|
||||
for (Map.Entry<Repo, Collection<VcsFullCommitDetails>> entry : groupedCommits.entrySet()) {
|
||||
Collection<VcsFullCommitDetails> commits = entry.getValue();
|
||||
if (commits.size() != 1) {
|
||||
return null;
|
||||
}
|
||||
map.put(entry.getKey(), commits.iterator().next());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.dvcs.ui;
|
||||
|
||||
import com.intellij.dvcs.repo.Repository;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.vcs.log.VcsFullCommitDetails;
|
||||
import com.intellij.vcs.log.VcsLog;
|
||||
import com.intellij.vcs.log.VcsLogDataKeys;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class VcsLogSingleCommitAction<Repo extends Repository> extends DumbAwareAction {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
|
||||
VcsLog log = e.getRequiredData(VcsLogDataKeys.VSC_LOG);
|
||||
List<VcsFullCommitDetails> details = log.getSelectedDetails();
|
||||
assert details.size() == 1;
|
||||
VcsFullCommitDetails commit = details.get(0);
|
||||
Repo repository = getRepositoryForRoot(project, commit.getRoot());
|
||||
assert repository != null;
|
||||
|
||||
actionPerformed(repository, commit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
Project project = e.getProject();
|
||||
VcsLog log = e.getData(VcsLogDataKeys.VSC_LOG);
|
||||
if (project == null || log == null) {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
List<VcsFullCommitDetails> details = log.getSelectedDetails();
|
||||
if (containsCommitFromOtherVcs(project, details)) {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
}
|
||||
else {
|
||||
e.getPresentation().setVisible(true);
|
||||
e.getPresentation().setEnabled(details.size() == 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected abstract Repo getRepositoryForRoot(@NotNull Project project, @NotNull VirtualFile root);
|
||||
|
||||
protected abstract void actionPerformed(@NotNull Repo repository, @NotNull VcsFullCommitDetails commit);
|
||||
|
||||
private boolean containsCommitFromOtherVcs(@NotNull final Project project, @NotNull List<VcsFullCommitDetails> details) {
|
||||
return ContainerUtil.exists(details, new Condition<VcsFullCommitDetails>() {
|
||||
@Override
|
||||
public boolean value(VcsFullCommitDetails details) {
|
||||
return getRepositoryForRoot(project, details.getRoot()) == null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
-36
@@ -15,23 +15,12 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.search;
|
||||
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.lexer.LexerBase;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory;
|
||||
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import com.intellij.openapi.editor.impl.EditorHighlighterCache;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.cache.impl.id.PlatformIdTableBuilding;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.text.CharSequenceSubSequence;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Sergey Evdokimov
|
||||
@@ -49,31 +38,6 @@ public class LexerEditorHighlighterLexer extends LexerBase {
|
||||
myAlreadyInitializedHighlighter = alreadyInitializedHighlighter;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Lexer getLexerBasedOnLexerHighlighter(CharSequence text, VirtualFile virtualFile, Project project) {
|
||||
EditorHighlighter highlighter = null;
|
||||
|
||||
PsiFile psiFile = virtualFile != null ? PsiManager.getInstance(project).findFile(virtualFile) : null;
|
||||
final Document document = psiFile != null ? PsiDocumentManager.getInstance(project).getDocument(psiFile) : null;
|
||||
final EditorHighlighter cachedEditorHighlighter;
|
||||
boolean alreadyInitializedHighlighter = false;
|
||||
|
||||
if (document != null &&
|
||||
(cachedEditorHighlighter = EditorHighlighterCache.getEditorHighlighterForCachesBuilding(document)) != null &&
|
||||
PlatformIdTableBuilding.checkCanUseCachedEditorHighlighter(text, cachedEditorHighlighter)) {
|
||||
highlighter = cachedEditorHighlighter;
|
||||
alreadyInitializedHighlighter = true;
|
||||
}
|
||||
else if (virtualFile != null) {
|
||||
highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(project, virtualFile);
|
||||
}
|
||||
|
||||
if (highlighter != null) {
|
||||
return new LexerEditorHighlighterLexer(highlighter, alreadyInitializedHighlighter);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(@NotNull CharSequence buffer, int startOffset, int endOffset, int state) {
|
||||
if (myAlreadyInitializedHighlighter) {
|
||||
+12
@@ -68,6 +68,18 @@ public class DataNode<T> implements Serializable {
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <T> DataNode<T> createOrReplaceChild(@NotNull Key<T> key, @NotNull T data) {
|
||||
for (Iterator<DataNode<?>> iterator = myChildren.iterator(); iterator.hasNext(); ) {
|
||||
DataNode<?> child = iterator.next();
|
||||
if (child.getKey().equals(key)) {
|
||||
iterator.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return createChild(key, data);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Key<T> getKey() {
|
||||
return myKey;
|
||||
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.externalSystem.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 7/22/2014
|
||||
*/
|
||||
public class DefaultExternalFilter implements ExternalFilter {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull
|
||||
private String myFilterType;
|
||||
@NotNull
|
||||
private String myPropertiesAsJsonMap;
|
||||
|
||||
public DefaultExternalFilter() {
|
||||
myPropertiesAsJsonMap = "";
|
||||
myFilterType = "";
|
||||
}
|
||||
|
||||
|
||||
public DefaultExternalFilter(ExternalFilter filter) {
|
||||
myPropertiesAsJsonMap = filter.getPropertiesAsJsonMap();
|
||||
myFilterType = filter.getFilterType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFilterType() {
|
||||
return myFilterType;
|
||||
}
|
||||
|
||||
public void setFilterType(@NotNull String filterType) {
|
||||
myFilterType = filterType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getPropertiesAsJsonMap() {
|
||||
return myPropertiesAsJsonMap;
|
||||
}
|
||||
|
||||
public void setPropertiesAsJsonMap(@NotNull String propertiesAsJsonMap) {
|
||||
myPropertiesAsJsonMap = propertiesAsJsonMap;
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.externalSystem.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 7/16/2014
|
||||
*/
|
||||
public class DefaultExternalPlugin implements ExternalPlugin {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull
|
||||
private String myId;
|
||||
|
||||
public DefaultExternalPlugin() {
|
||||
}
|
||||
|
||||
public DefaultExternalPlugin(ExternalPlugin plugin) {
|
||||
myId = plugin.getId();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getId() {
|
||||
return myId;
|
||||
}
|
||||
|
||||
public void setId(@NotNull String id) {
|
||||
myId = id;
|
||||
}
|
||||
}
|
||||
+243
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.externalSystem.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 7/14/2014
|
||||
*/
|
||||
public class DefaultExternalProject implements ExternalProject {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull
|
||||
private String myName;
|
||||
@NotNull
|
||||
private String myQName;
|
||||
@Nullable
|
||||
private String myDescription;
|
||||
@NotNull
|
||||
private String myGroup;
|
||||
@NotNull
|
||||
private String myVersion;
|
||||
@NotNull
|
||||
private Map<String, ExternalProject> myChildProjects;
|
||||
@NotNull
|
||||
private File myProjectDir;
|
||||
@NotNull
|
||||
private File myBuildDir;
|
||||
@Nullable
|
||||
private File myBuildFile;
|
||||
@NotNull
|
||||
private Map<String, ExternalTask> myTasks;
|
||||
@NotNull
|
||||
private Map<String, ?> myProperties;
|
||||
@NotNull
|
||||
private Map<String, ExternalSourceSet> mySourceSets;
|
||||
@NotNull
|
||||
private String myExternalSystemId;
|
||||
@NotNull
|
||||
private Map<String, ExternalPlugin> myPlugins;
|
||||
|
||||
public DefaultExternalProject() {
|
||||
myChildProjects = new HashMap<String, ExternalProject>();
|
||||
myTasks = new HashMap<String, ExternalTask>();
|
||||
myProperties = new HashMap<String, Object>();
|
||||
mySourceSets = new HashMap<String, ExternalSourceSet>();
|
||||
myPlugins = new HashMap<String, ExternalPlugin>();
|
||||
}
|
||||
|
||||
public DefaultExternalProject(@NotNull ExternalProject externalProject) {
|
||||
this();
|
||||
myName = externalProject.getName();
|
||||
myQName = externalProject.getQName();
|
||||
myVersion = externalProject.getVersion();
|
||||
myGroup = externalProject.getGroup();
|
||||
myDescription = externalProject.getDescription();
|
||||
myProjectDir = externalProject.getProjectDir();
|
||||
myBuildDir = externalProject.getBuildDir();
|
||||
myBuildFile = externalProject.getBuildFile();
|
||||
myExternalSystemId = externalProject.getExternalSystemId();
|
||||
|
||||
for (Map.Entry<String, ExternalProject> entry : externalProject.getChildProjects().entrySet()) {
|
||||
myChildProjects.put(entry.getKey(), new DefaultExternalProject(entry.getValue()));
|
||||
}
|
||||
|
||||
for (Map.Entry<String, ExternalTask> entry : externalProject.getTasks().entrySet()) {
|
||||
myTasks.put(entry.getKey(), new DefaultExternalTask(entry.getValue()));
|
||||
}
|
||||
for (Map.Entry<String, ExternalSourceSet> entry : externalProject.getSourceSets().entrySet()) {
|
||||
mySourceSets.put(entry.getKey(), new DefaultExternalSourceSet(entry.getValue()));
|
||||
}
|
||||
for (Map.Entry<String, ExternalPlugin> entry : externalProject.getPlugins().entrySet()) {
|
||||
myPlugins.put(entry.getKey(), new DefaultExternalPlugin(entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getExternalSystemId() {
|
||||
return myExternalSystemId;
|
||||
}
|
||||
|
||||
public void setExternalSystemId(@NotNull String externalSystemId) {
|
||||
myExternalSystemId = externalSystemId;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
public void setName(@NotNull String name) {
|
||||
myName = name;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getQName() {
|
||||
return myQName;
|
||||
}
|
||||
|
||||
public void setQName(@NotNull String QName) {
|
||||
myQName = QName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return myDescription;
|
||||
}
|
||||
|
||||
public void setDescription(@Nullable String description) {
|
||||
myDescription = description;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getGroup() {
|
||||
return myGroup;
|
||||
}
|
||||
|
||||
public void setGroup(@NotNull String group) {
|
||||
myGroup = group;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return myVersion;
|
||||
}
|
||||
|
||||
public void setVersion(@NotNull String version) {
|
||||
myVersion = version;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<String, ExternalProject> getChildProjects() {
|
||||
return myChildProjects;
|
||||
}
|
||||
|
||||
public void setChildProjects(@NotNull Map<String, ExternalProject> childProjects) {
|
||||
myChildProjects = childProjects;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public File getProjectDir() {
|
||||
return myProjectDir;
|
||||
}
|
||||
|
||||
public void setProjectDir(@NotNull File projectDir) {
|
||||
myProjectDir = projectDir;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public File getBuildDir() {
|
||||
return myBuildDir;
|
||||
}
|
||||
|
||||
public void setBuildDir(@NotNull File buildDir) {
|
||||
myBuildDir = buildDir;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public File getBuildFile() {
|
||||
return myBuildFile;
|
||||
}
|
||||
|
||||
public void setBuildFile(@Nullable File buildFile) {
|
||||
myBuildFile = buildFile;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<String, ExternalTask> getTasks() {
|
||||
return myTasks;
|
||||
}
|
||||
|
||||
public void setTasks(@NotNull Map<String, ExternalTask> tasks) {
|
||||
myTasks = tasks;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<String, ExternalPlugin> getPlugins() {
|
||||
return myPlugins;
|
||||
}
|
||||
|
||||
public void setPlugins(@NotNull Map<String, ExternalPlugin> plugins) {
|
||||
myPlugins = plugins;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<String, ?> getProperties() {
|
||||
return myProperties;
|
||||
}
|
||||
|
||||
public void setProperties(@NotNull Map<String, ?> properties) {
|
||||
myProperties = properties;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getProperty(String name) {
|
||||
return myProperties.get(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<String, ExternalSourceSet> getSourceSets() {
|
||||
return mySourceSets;
|
||||
}
|
||||
|
||||
public void setSourceSets(@NotNull Map<String, ExternalSourceSet> sourceSets) {
|
||||
mySourceSets = sourceSets;
|
||||
}
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.externalSystem.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 7/14/2014
|
||||
*/
|
||||
public class DefaultExternalSourceDirectorySet implements ExternalSourceDirectorySet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull
|
||||
private String myName;
|
||||
@NotNull
|
||||
private Set<File> mySrcDirs;
|
||||
@NotNull
|
||||
private File myOutputDir;
|
||||
@NotNull
|
||||
private Set<String> myExcludes;
|
||||
@NotNull
|
||||
private Set<String> myIncludes;
|
||||
@NotNull
|
||||
private List<ExternalFilter> myFilters;
|
||||
|
||||
public DefaultExternalSourceDirectorySet() {
|
||||
mySrcDirs = new HashSet<File>();
|
||||
myExcludes = new HashSet<String>();
|
||||
myIncludes = new HashSet<String>();
|
||||
myFilters = new ArrayList<ExternalFilter>();
|
||||
}
|
||||
|
||||
public DefaultExternalSourceDirectorySet(ExternalSourceDirectorySet sourceDirectorySet) {
|
||||
this();
|
||||
myName = sourceDirectorySet.getName();
|
||||
mySrcDirs = new HashSet<File>(sourceDirectorySet.getSrcDirs());
|
||||
myOutputDir = sourceDirectorySet.getOutputDir();
|
||||
myExcludes = new HashSet<String>(sourceDirectorySet.getExcludes());
|
||||
myIncludes = new HashSet<String>(sourceDirectorySet.getIncludes());
|
||||
for (ExternalFilter filter : sourceDirectorySet.getFilters()) {
|
||||
myFilters.add(new DefaultExternalFilter(filter));
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
public void setName(@NotNull String name) {
|
||||
myName = name;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<File> getSrcDirs() {
|
||||
return mySrcDirs;
|
||||
}
|
||||
|
||||
public void setSrcDirs(@NotNull Set<File> srcDirs) {
|
||||
mySrcDirs = srcDirs;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public File getOutputDir() {
|
||||
return myOutputDir;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<String> getIncludes() {
|
||||
return myIncludes;
|
||||
}
|
||||
|
||||
public void setIncludes(@NotNull Set<String> includes) {
|
||||
myIncludes = includes;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<String> getExcludes() {
|
||||
return myExcludes;
|
||||
}
|
||||
|
||||
public void setExcludes(@NotNull Set<String> excludes) {
|
||||
myExcludes = excludes;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<ExternalFilter> getFilters() {
|
||||
return myFilters;
|
||||
}
|
||||
|
||||
public void setFilters(@NotNull List<ExternalFilter> filters) {
|
||||
myFilters = filters;
|
||||
}
|
||||
|
||||
public void setOutputDir(@NotNull File outputDir) {
|
||||
myOutputDir = outputDir;
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.externalSystem.model;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.project.ExternalSystemSourceType;
|
||||
import com.intellij.openapi.externalSystem.model.project.IExternalSystemSourceType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 7/14/2014
|
||||
*/
|
||||
public class DefaultExternalSourceSet implements ExternalSourceSet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String myName;
|
||||
private Map<IExternalSystemSourceType, ExternalSourceDirectorySet> mySources;
|
||||
|
||||
public DefaultExternalSourceSet() {
|
||||
mySources = new HashMap<IExternalSystemSourceType, ExternalSourceDirectorySet>();
|
||||
}
|
||||
|
||||
public DefaultExternalSourceSet(ExternalSourceSet sourceSet) {
|
||||
this();
|
||||
myName = sourceSet.getName();
|
||||
for (Map.Entry<IExternalSystemSourceType, ExternalSourceDirectorySet> entry : sourceSet.getSources().entrySet()) {
|
||||
mySources.put(ExternalSystemSourceType.from(entry.getKey()), new DefaultExternalSourceDirectorySet(entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
myName = name;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<IExternalSystemSourceType, ExternalSourceDirectorySet> getSources() {
|
||||
return mySources;
|
||||
}
|
||||
|
||||
public void setSources(Map<IExternalSystemSourceType, ExternalSourceDirectorySet> sources) {
|
||||
mySources = sources;
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.externalSystem.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 7/14/2014
|
||||
*/
|
||||
public class DefaultExternalTask implements ExternalTask {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull
|
||||
private String myName;
|
||||
@NotNull
|
||||
private String myQName;
|
||||
@Nullable
|
||||
private String myDescription;
|
||||
@Nullable
|
||||
private String myGroup;
|
||||
|
||||
public DefaultExternalTask() {
|
||||
}
|
||||
|
||||
public DefaultExternalTask(ExternalTask externalTask) {
|
||||
myName = externalTask.getName();
|
||||
myQName = externalTask.getQName();
|
||||
myDescription = externalTask.getDescription();
|
||||
myGroup = externalTask.getGroup();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
public void setName(@NotNull String name) {
|
||||
myName = name;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getQName() {
|
||||
return myQName;
|
||||
}
|
||||
|
||||
public void setQName(@NotNull String QName) {
|
||||
myQName = QName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return myDescription;
|
||||
}
|
||||
|
||||
public void setDescription(@Nullable String description) {
|
||||
myDescription = description;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getGroup() {
|
||||
return myGroup;
|
||||
}
|
||||
|
||||
public void setGroup(@Nullable String group) {
|
||||
myGroup = group;
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.externalSystem.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 7/14/2014
|
||||
*/
|
||||
public interface ExternalFilter extends Serializable {
|
||||
@NotNull
|
||||
String getFilterType();
|
||||
@NotNull
|
||||
String getPropertiesAsJsonMap();
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.externalSystem.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 7/14/2014
|
||||
*/
|
||||
public interface ExternalPlugin extends Serializable {
|
||||
@NotNull
|
||||
String getId();
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.externalSystem.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 7/14/2014
|
||||
*/
|
||||
public interface ExternalProject extends Serializable {
|
||||
|
||||
@NotNull
|
||||
String getExternalSystemId();
|
||||
|
||||
@NotNull
|
||||
String getName();
|
||||
|
||||
@NotNull
|
||||
String getQName();
|
||||
|
||||
@Nullable
|
||||
String getDescription();
|
||||
|
||||
@NotNull
|
||||
String getGroup();
|
||||
|
||||
@NotNull
|
||||
String getVersion();
|
||||
|
||||
@NotNull
|
||||
Map<String, ExternalProject> getChildProjects();
|
||||
|
||||
@NotNull
|
||||
File getProjectDir();
|
||||
|
||||
@NotNull
|
||||
File getBuildDir();
|
||||
|
||||
@Nullable
|
||||
File getBuildFile();
|
||||
|
||||
@NotNull
|
||||
Map<String, ExternalTask> getTasks();
|
||||
|
||||
//@NotNull
|
||||
//Map<String, ExternalConfiguration> getConfigurations();
|
||||
|
||||
//@NotNull
|
||||
//List<ExternalRepository> getRepositories();
|
||||
|
||||
//@NotNull
|
||||
//List<ExternalDependency> getDependencies();
|
||||
|
||||
@NotNull
|
||||
Map<String, ExternalPlugin> getPlugins();
|
||||
|
||||
//@NotNull
|
||||
//ExternalProjectBuild getBuild();
|
||||
|
||||
@NotNull
|
||||
Map<String, ?> getProperties();
|
||||
|
||||
@Nullable
|
||||
Object getProperty(String name);
|
||||
|
||||
@NotNull
|
||||
Map<String, ExternalSourceSet> getSourceSets();
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.externalSystem.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 7/14/2014
|
||||
*/
|
||||
public interface ExternalSourceDirectorySet extends Serializable {
|
||||
@NotNull
|
||||
String getName();
|
||||
|
||||
@NotNull
|
||||
Set<File> getSrcDirs();
|
||||
|
||||
@NotNull
|
||||
File getOutputDir();
|
||||
|
||||
@NotNull
|
||||
Set<String> getExcludes();
|
||||
@NotNull
|
||||
Set<String> getIncludes();
|
||||
|
||||
@NotNull
|
||||
List<ExternalFilter> getFilters();
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.externalSystem.model;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.project.IExternalSystemSourceType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 7/14/2014
|
||||
*/
|
||||
public interface ExternalSourceSet extends Serializable {
|
||||
@NotNull
|
||||
String getName();
|
||||
//@NotNull
|
||||
//ClasspathContainer getCompileClasspath();
|
||||
|
||||
//@NotNull
|
||||
//ClasspathContainer getRuntimeClasspath();
|
||||
|
||||
@NotNull
|
||||
Map<IExternalSystemSourceType, ExternalSourceDirectorySet> getSources();
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.externalSystem.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 7/14/2014
|
||||
*/
|
||||
public interface ExternalTask extends Serializable {
|
||||
@NotNull
|
||||
String getName();
|
||||
@NotNull
|
||||
String getQName();
|
||||
@Nullable
|
||||
String getDescription();
|
||||
@Nullable
|
||||
String getGroup();
|
||||
}
|
||||
+40
-30
@@ -1,52 +1,62 @@
|
||||
package com.intellij.openapi.externalSystem.model.project;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Enumerates module source types.
|
||||
*
|
||||
* @author Denis Zhdanov
|
||||
* @since 8/10/11 5:21 PM
|
||||
*/
|
||||
public class ExternalSystemSourceType implements Serializable {
|
||||
public enum ExternalSystemSourceType implements IExternalSystemSourceType {
|
||||
|
||||
@NotNull public static final ExternalSystemSourceType SOURCE = new ExternalSystemSourceType("SOURCE");
|
||||
@NotNull public static final ExternalSystemSourceType TEST = new ExternalSystemSourceType("TEST");
|
||||
@NotNull public static final ExternalSystemSourceType EXCLUDED = new ExternalSystemSourceType("EXCLUDED");
|
||||
@NotNull public static final ExternalSystemSourceType SOURCE_GENERATED = new ExternalSystemSourceType("SOURCE_GENERATED");
|
||||
@NotNull public static final ExternalSystemSourceType TEST_GENERATED = new ExternalSystemSourceType("TEST_GENERATED");
|
||||
@NotNull public static final ExternalSystemSourceType RESOURCE = new ExternalSystemSourceType("RESOURCE");
|
||||
@NotNull public static final ExternalSystemSourceType TEST_RESOURCE = new ExternalSystemSourceType("TEST_RESOURCE");
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
SOURCE(false, false, false, false),
|
||||
TEST(true, false, false, false),
|
||||
EXCLUDED(false, false, false, true),
|
||||
SOURCE_GENERATED(true, true, false, false),
|
||||
TEST_GENERATED(true, true, false, false),
|
||||
RESOURCE(false, false, true, false),
|
||||
TEST_RESOURCE(true, false, true, false);
|
||||
|
||||
@NotNull private final String myId;
|
||||
private final boolean isTest;
|
||||
private final boolean isGenerated;
|
||||
private final boolean isResource;
|
||||
private final boolean isExcluded;
|
||||
|
||||
public ExternalSystemSourceType(@NotNull String id) {
|
||||
myId = id;
|
||||
ExternalSystemSourceType(boolean test, boolean generated, boolean resource, boolean excluded) {
|
||||
isTest = test;
|
||||
isGenerated = generated;
|
||||
isResource = resource;
|
||||
isExcluded = excluded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ExternalSystemSourceType type = (ExternalSystemSourceType)o;
|
||||
|
||||
if (!myId.equals(type.myId)) return false;
|
||||
|
||||
return true;
|
||||
public boolean isTest() {
|
||||
return isTest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return myId.hashCode();
|
||||
public boolean isGenerated() {
|
||||
return isGenerated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return myId;
|
||||
public boolean isResource() {
|
||||
return isResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExcluded() {
|
||||
return isExcluded;
|
||||
}
|
||||
|
||||
public static ExternalSystemSourceType from(IExternalSystemSourceType sourceType) {
|
||||
for (ExternalSystemSourceType systemSourceType : ExternalSystemSourceType.values()) {
|
||||
if (systemSourceType.isGenerated == sourceType.isGenerated() &&
|
||||
systemSourceType.isResource == sourceType.isResource() &&
|
||||
systemSourceType.isTest == sourceType.isTest() &&
|
||||
systemSourceType.isExcluded == sourceType.isExcluded()) {
|
||||
return systemSourceType;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid source type: " + sourceType);
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -13,20 +13,20 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package icons;
|
||||
package com.intellij.openapi.externalSystem.model.project;
|
||||
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* NOTE THIS FILE IS AUTO-GENERATED
|
||||
* DO NOT EDIT IT BY HAND, run build/scripts/icons.gant instead
|
||||
* @author Vladislav.Soroka
|
||||
* @since 7/17/2014
|
||||
*/
|
||||
public class PropertiesIcons {
|
||||
private static Icon load(String path) {
|
||||
return IconLoader.getIcon(path, PropertiesIcons.class);
|
||||
}
|
||||
public interface IExternalSystemSourceType extends Serializable {
|
||||
boolean isTest();
|
||||
|
||||
public static final Icon XmlProperties = load("/icons/xmlProperties.png"); // 16x16
|
||||
boolean isGenerated();
|
||||
|
||||
boolean isResource();
|
||||
|
||||
boolean isExcluded();
|
||||
}
|
||||
+5
@@ -681,4 +681,9 @@ public class ExternalSystemApiUtil {
|
||||
public static String getExternalProjectPath(@Nullable Module module) {
|
||||
return module != null ? module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getExternalProjectId(@Nullable Module module) {
|
||||
return module != null ? module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_ID_KEY) : null;
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -27,6 +27,7 @@ public class ExternalSystemConstants {
|
||||
@NonNls @NotNull public static final String EXTERNAL_SYSTEM_ID_KEY = "external.system.id";
|
||||
@NonNls @NotNull public static final String LINKED_PROJECT_PATH_KEY = "external.linked.project.path";
|
||||
@NonNls @NotNull public static final String ROOT_PROJECT_PATH_KEY = "external.root.project.path";
|
||||
@NonNls @NotNull public static final String LINKED_PROJECT_ID_KEY = "external.linked.project.id";
|
||||
|
||||
@NonNls @NotNull public static final String EXTERNAL_SYSTEM_MODULE_GROUP_KEY = "external.system.module.group";
|
||||
@NonNls @NotNull public static final String EXTERNAL_SYSTEM_MODULE_VERSION_KEY = "external.system.module.version";
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
<orderEntry type="library" scope="TEST" name="JUnit4" level="project" />
|
||||
<orderEntry type="module" module-name="testFramework" scope="TEST" />
|
||||
<orderEntry type="module" module-name="testFramework-java" scope="TEST" />
|
||||
<orderEntry type="module" module-name="compiler-impl" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
package com.intellij.openapi.externalSystem.service.project;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Facades all services necessary for the 'sync project changes' processing.
|
||||
* <p/>
|
||||
* Thread-safe.
|
||||
*
|
||||
* @author Denis Zhdanov
|
||||
* @since 2/14/12 1:26 PM
|
||||
*/
|
||||
public class ProjectStructureServices {
|
||||
|
||||
@NotNull private final ProjectStructureHelper myProjectStructureHelper;
|
||||
@NotNull private final PlatformFacade myPlatformFacade;
|
||||
@NotNull private final ExternalLibraryPathTypeMapper myLibraryPathTypeMapper;
|
||||
|
||||
public ProjectStructureServices(@NotNull ProjectStructureHelper projectStructureHelper,
|
||||
@NotNull PlatformFacade platformFacade,
|
||||
@NotNull ExternalLibraryPathTypeMapper mapper)
|
||||
{
|
||||
myProjectStructureHelper = projectStructureHelper;
|
||||
myPlatformFacade = platformFacade;
|
||||
myLibraryPathTypeMapper = mapper;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ProjectStructureHelper getProjectStructureHelper() {
|
||||
return myProjectStructureHelper;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PlatformFacade getPlatformFacade() {
|
||||
return myPlatformFacade;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ExternalLibraryPathTypeMapper getLibraryPathTypeMapper() {
|
||||
return myLibraryPathTypeMapper;
|
||||
}
|
||||
}
|
||||
+1
@@ -274,6 +274,7 @@ public class ModuleDataService implements ProjectDataService<ModuleData, Module>
|
||||
module.putUserData(MODULE_DATA_KEY, moduleData);
|
||||
|
||||
module.setOption(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY, moduleData.getOwner().toString());
|
||||
module.setOption(ExternalSystemConstants.LINKED_PROJECT_ID_KEY, moduleData.getId());
|
||||
module.setOption(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY, moduleData.getLinkedExternalProjectPath());
|
||||
final ProjectData projectData = moduleDataNode.getData(ProjectKeys.PROJECT);
|
||||
module.setOption(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY, projectData != null ? projectData.getLinkedExternalProjectPath() : "");
|
||||
|
||||
+18
-3
@@ -25,6 +25,7 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -40,8 +41,10 @@ public class ProjectDataManager {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#" + ProjectDataManager.class.getName());
|
||||
|
||||
@NotNull private final NotNullLazyValue<Map<Key<?>, List<ProjectDataService<?, ?>>>> myServices =
|
||||
new NotNullLazyValue<Map<Key<?>, List<ProjectDataService<?, ?>>>>() {
|
||||
@NotNull private final NotNullLazyValue<Map<Key<?>, List<ProjectDataService<?, ?>>>> myServices;
|
||||
|
||||
public ProjectDataManager() {
|
||||
myServices = new NotNullLazyValue<Map<Key<?>, List<ProjectDataService<?, ?>>>>() {
|
||||
@NotNull
|
||||
@Override
|
||||
protected Map<Key<?>, List<ProjectDataService<?, ?>>> compute() {
|
||||
@@ -57,10 +60,22 @@ public class ProjectDataManager {
|
||||
for (List<ProjectDataService<?, ?>> services : result.values()) {
|
||||
ExternalSystemApiUtil.orderAwareSort(services);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<ProjectDataService<?, ?>> getDataServices(Key<?> key) {
|
||||
return myServices.getValue().get(key);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ProjectDataService<?, ?> getDataService(Key<?> key) {
|
||||
final List<ProjectDataService<?, ?>> dataServices = myServices.getValue().get(key);
|
||||
assert dataServices == null || dataServices.isEmpty() || dataServices.size() == 1;
|
||||
return ContainerUtil.getFirstItem(dataServices);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> void importData(@NotNull Collection<DataNode<?>> nodes, @NotNull Project project, boolean synchronous) {
|
||||
|
||||
+5
@@ -193,6 +193,11 @@ public abstract class AbstractImportFromExternalSystemControl<
|
||||
return myProjectSettingsControl;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ExternalSystemSettingsControl<SystemSettings> getSystemSettingsControl() {
|
||||
return mySystemSettingsControl;
|
||||
}
|
||||
|
||||
public void setLinkedProjectPath(@NotNull String path) {
|
||||
myProjectSettings.setExternalProjectPath(path);
|
||||
myLinkedProjectPathField.setText(path);
|
||||
|
||||
+134
-3
@@ -15,24 +15,41 @@
|
||||
*/
|
||||
package com.intellij.openapi.externalSystem.test;
|
||||
|
||||
import com.intellij.compiler.CompilerTestUtil;
|
||||
import com.intellij.compiler.CompilerWorkspaceConfiguration;
|
||||
import com.intellij.compiler.artifacts.ArtifactsTestUtil;
|
||||
import com.intellij.compiler.impl.ModuleCompileScope;
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.compiler.CompileScope;
|
||||
import com.intellij.openapi.compiler.CompileStatusNotification;
|
||||
import com.intellij.openapi.compiler.CompilerManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.module.StdModuleTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl;
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.impl.compiler.ArtifactCompileScope;
|
||||
import com.intellij.testFramework.IdeaTestCase;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import com.intellij.testFramework.fixtures.IdeaProjectTestFixture;
|
||||
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import com.intellij.util.io.TestFileSystemItem;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -40,6 +57,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -129,11 +147,11 @@ public abstract class ExternalSystemTestCase extends UsefulTestCase {
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
try {
|
||||
myProject = null;
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
edt(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
CompilerTestUtil.disableExternalCompiler(myProject);
|
||||
tearDownFixtures();
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -141,6 +159,7 @@ public abstract class ExternalSystemTestCase extends UsefulTestCase {
|
||||
}
|
||||
}
|
||||
});
|
||||
myProject = null;
|
||||
if (!FileUtil.delete(myTestDir) && myTestDir.exists()) {
|
||||
System.err.println("Cannot delete " + myTestDir);
|
||||
//printDirectoryContent(myDir);
|
||||
@@ -319,7 +338,11 @@ public abstract class ExternalSystemTestCase extends UsefulTestCase {
|
||||
protected VirtualFile createProjectSubFile(String relativePath) throws IOException {
|
||||
File f = new File(getProjectPath(), relativePath);
|
||||
FileUtil.ensureExists(f.getParentFile());
|
||||
f.createNewFile();
|
||||
FileUtil.ensureCanCreateFile(f);
|
||||
final boolean created = f.createNewFile();
|
||||
if(!created) {
|
||||
throw new AssertionError("Unable to create the project sub file: " + f.getAbsolutePath());
|
||||
}
|
||||
return LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f);
|
||||
}
|
||||
|
||||
@@ -329,6 +352,114 @@ public abstract class ExternalSystemTestCase extends UsefulTestCase {
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
protected void compileModules(final String... moduleNames) {
|
||||
compile(createModulesCompileScope(moduleNames));
|
||||
}
|
||||
|
||||
protected void buildArtifacts(String... artifactNames) {
|
||||
compile(createArtifactsScope(artifactNames));
|
||||
}
|
||||
|
||||
private void compile(final CompileScope scope) {
|
||||
edt(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Module module : scope.getAffectedModules()) {
|
||||
setupJdkForModule(module.getName());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
CompilerWorkspaceConfiguration.getInstance(myProject).CLEAR_OUTPUT_DIRECTORY = true;
|
||||
|
||||
final Semaphore semaphore = new Semaphore();
|
||||
semaphore.down();
|
||||
edt(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CompilerTestUtil.enableExternalCompiler();
|
||||
CompilerManager.getInstance(myProject).make(scope, new CompileStatusNotification() {
|
||||
@Override
|
||||
public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
|
||||
//assertFalse(aborted);
|
||||
//assertEquals(collectMessages(compileContext, CompilerMessageCategory.ERROR), 0, errors);
|
||||
//assertEquals(collectMessages(compileContext, CompilerMessageCategory.WARNING), 0, warnings);
|
||||
semaphore.up();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
while (!semaphore.waitFor(100)) {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
}
|
||||
}
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
}
|
||||
}
|
||||
|
||||
private CompileScope createModulesCompileScope(final String[] moduleNames) {
|
||||
final List<Module> modules = new ArrayList<Module>();
|
||||
for (String name : moduleNames) {
|
||||
modules.add(getModule(name));
|
||||
}
|
||||
return new ModuleCompileScope(myProject, modules.toArray(new Module[modules.size()]), false);
|
||||
}
|
||||
|
||||
private CompileScope createArtifactsScope(String[] artifactNames) {
|
||||
List<Artifact> artifacts = new ArrayList<Artifact>();
|
||||
for (String name : artifactNames) {
|
||||
artifacts.add(ArtifactsTestUtil.findArtifact(myProject, name));
|
||||
}
|
||||
return ArtifactCompileScope.createArtifactsScope(myProject, artifacts);
|
||||
}
|
||||
|
||||
protected Sdk setupJdkForModule(final String moduleName) {
|
||||
final Sdk sdk = true ? JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk() : createJdk("Java 1.5");
|
||||
ModuleRootModificationUtil.setModuleSdk(getModule(moduleName), sdk);
|
||||
return sdk;
|
||||
}
|
||||
|
||||
protected static Sdk createJdk(String versionName) {
|
||||
return IdeaTestUtil.getMockJdk17(versionName);
|
||||
}
|
||||
|
||||
protected Module getModule(final String name) {
|
||||
AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
|
||||
try {
|
||||
Module m = ModuleManager.getInstance(myProject).findModuleByName(name);
|
||||
assertNotNull("Module " + name + " not found", m);
|
||||
return m;
|
||||
}
|
||||
finally {
|
||||
accessToken.finish();
|
||||
}
|
||||
}
|
||||
|
||||
protected void assertExplodedLayout(String artifactName, String expected) {
|
||||
assertJarLayout(artifactName + " exploded", expected);
|
||||
}
|
||||
|
||||
protected void assertJarLayout(String artifactName, String expected) {
|
||||
ArtifactsTestUtil.assertLayout(myProject, artifactName, expected);
|
||||
}
|
||||
|
||||
protected void assertArtifactOutputPath(final String artifactName, final String expected) {
|
||||
ArtifactsTestUtil.assertOutputPath(myProject, artifactName, expected);
|
||||
}
|
||||
|
||||
protected void assertArtifactOutputFileName(final String artifactName, final String expected) {
|
||||
ArtifactsTestUtil.assertOutputFileName(myProject, artifactName, expected);
|
||||
}
|
||||
|
||||
protected void assertArtifactOutput(String artifactName, TestFileSystemItem fs) {
|
||||
final String outputPath = ArtifactsTestUtil.findArtifact(myProject, artifactName).getOutputPath();
|
||||
assert outputPath != null;
|
||||
fs.assertDirectoryEqual(new File(outputPath));
|
||||
}
|
||||
|
||||
private static void setFileContent(final VirtualFile file, final String content, final boolean advanceStamps) throws IOException {
|
||||
new WriteAction<VirtualFile>() {
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.util.PatternUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -274,7 +275,7 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
|
||||
public void setStringToFind(@NotNull String s) {
|
||||
boolean changed = !StringUtil.equals(s, myStringToFind);
|
||||
myStringToFind = s;
|
||||
myPattern = NO_PATTERN;
|
||||
myPattern = PatternUtil.NOTHING;
|
||||
if (changed) {
|
||||
notifyObservers();
|
||||
}
|
||||
@@ -409,7 +410,7 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
|
||||
boolean changed = val != isCaseSensitive;
|
||||
isCaseSensitive = val;
|
||||
if (changed) {
|
||||
myPattern = NO_PATTERN;
|
||||
myPattern = PatternUtil.NOTHING;
|
||||
notifyObservers();
|
||||
}
|
||||
}
|
||||
@@ -850,11 +851,11 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
|
||||
}
|
||||
|
||||
public enum SearchContext {
|
||||
ANY, IN_STRINGS, IN_COMMENTS, EXCEPT_STRINGS, EXCEPT_COMMENTS, EXCEPT_STRINGS_AND_COMMENTS
|
||||
ANY, IN_STRING_LITERALS, IN_COMMENTS, EXCEPT_STRING_LITERALS, EXCEPT_COMMENTS, EXCEPT_COMMENTS_AND_STRING_LITERALS
|
||||
}
|
||||
|
||||
public boolean isInStringLiteralsOnly() {
|
||||
return searchContext == SearchContext.IN_STRINGS;
|
||||
return searchContext == SearchContext.IN_STRING_LITERALS;
|
||||
}
|
||||
|
||||
public boolean isExceptComments() {
|
||||
@@ -862,7 +863,7 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
|
||||
}
|
||||
|
||||
public boolean isExceptStringLiterals() {
|
||||
return searchContext == SearchContext.EXCEPT_STRINGS;
|
||||
return searchContext == SearchContext.EXCEPT_STRING_LITERALS;
|
||||
}
|
||||
|
||||
public boolean isInCommentsOnly() {
|
||||
@@ -870,7 +871,32 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
|
||||
}
|
||||
|
||||
public boolean isExceptCommentsAndStringLiterals() {
|
||||
return searchContext == SearchContext.EXCEPT_STRINGS_AND_COMMENTS;
|
||||
return searchContext == SearchContext.EXCEPT_COMMENTS_AND_STRING_LITERALS;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setInCommentsOnly(boolean inCommentsOnly) {
|
||||
doApplyContextChange(inCommentsOnly, SearchContext.IN_COMMENTS);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setInStringLiteralsOnly(boolean inStringLiteralsOnly) {
|
||||
doApplyContextChange(inStringLiteralsOnly, SearchContext.IN_STRING_LITERALS);
|
||||
}
|
||||
|
||||
public void doApplyContextChange(boolean inCommentsOnly, SearchContext option) {
|
||||
boolean changed = false;
|
||||
if (inCommentsOnly) {
|
||||
changed = searchContext == option;
|
||||
searchContext = option;
|
||||
} else if (searchContext == option) { // do not reset unrelated value
|
||||
changed = true;
|
||||
searchContext = SearchContext.ANY;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
notifyObservers();
|
||||
}
|
||||
}
|
||||
|
||||
public @NotNull SearchContext getSearchContext() {
|
||||
@@ -901,21 +927,18 @@ public class FindModel extends UserDataHolderBase implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
private static final Pattern NO_PATTERN = Pattern.compile("");
|
||||
private Pattern myPattern = NO_PATTERN;
|
||||
private Pattern myPattern = PatternUtil.NOTHING;
|
||||
|
||||
public Pattern compileRegExp() {
|
||||
String toFind = getStringToFind();
|
||||
|
||||
Pattern pattern = myPattern;
|
||||
if (pattern == NO_PATTERN) {
|
||||
if (pattern == PatternUtil.NOTHING) {
|
||||
try {
|
||||
myPattern = pattern = Pattern.compile(toFind, isCaseSensitive() ? Pattern.MULTILINE : Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
|
||||
}
|
||||
catch (PatternSyntaxException e) {
|
||||
LOG.error("Regexp:'" + toFind + "'", e);
|
||||
myPattern = null;
|
||||
return null;
|
||||
myPattern = pattern = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-8
@@ -27,11 +27,8 @@ import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
@@ -46,12 +43,10 @@ public class IndentingBackspaceHandler extends BackspaceHandlerDelegate {
|
||||
private static final Logger LOG = Logger.getInstance(IndentingBackspaceHandler.class);
|
||||
|
||||
private boolean caretWasAtLineStart;
|
||||
private int initialCaretOffset;
|
||||
|
||||
@Override
|
||||
public void beforeCharDeleted(char c, PsiFile file, Editor editor) {
|
||||
caretWasAtLineStart = editor.getCaretModel().getLogicalPosition().column == 0;
|
||||
initialCaretOffset = editor.getCaretModel().getOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,11 +62,10 @@ public class IndentingBackspaceHandler extends BackspaceHandlerDelegate {
|
||||
Project project = file.getProject();
|
||||
Document document = editor.getDocument();
|
||||
CaretModel caretModel = editor.getCaretModel();
|
||||
boolean isUncommitted = PsiDocumentManager.getInstance(project).isUncommited(document);
|
||||
|
||||
int caretOffset = caretModel.getOffset();
|
||||
int offset = CharArrayUtil.shiftForward(document.getCharsSequence(), caretOffset, " \t");
|
||||
int offsetInPsi = offset + (isUncommitted ? 1 : 0);
|
||||
int offsetInPsi = getOffsetInPsi(document, file, offset);
|
||||
int beforeWhitespaceOffset = CharArrayUtil.shiftBackward(document.getCharsSequence(), offset - 1, " \t") + 1;
|
||||
LogicalPosition logicalPosition = caretOffset < offset ? editor.offsetToLogicalPosition(offset) : caretModel.getLogicalPosition();
|
||||
int lineStartOffset = document.getLineStartOffset(logicalPosition.line);
|
||||
@@ -89,7 +83,7 @@ public class IndentingBackspaceHandler extends BackspaceHandlerDelegate {
|
||||
|
||||
CodeStyleFacade codeStyleFacade = CodeStyleFacade.getInstance(project);
|
||||
// We should calculate indent at line containing the text after caret, cause that text might affect the result (e.g. closing brace in Java)
|
||||
String indent = codeStyleFacade.getLineIndent(document, caretWasAtLineStart && isUncommitted ? initialCaretOffset : lineStartOffset);
|
||||
String indent = codeStyleFacade.getLineIndent(document, offsetInPsi);
|
||||
if (indent == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -131,6 +125,11 @@ public class IndentingBackspaceHandler extends BackspaceHandlerDelegate {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int getOffsetInPsi(Document document, PsiFile file, int offset) {
|
||||
int psiLength = file.getTextLength();
|
||||
return Math.max(0, Math.min(psiLength, offset + psiLength - document.getTextLength()));
|
||||
}
|
||||
|
||||
private static int getTabSize(@NotNull CodeStyleFacade codeStyleFacade, @NotNull Document document) {
|
||||
VirtualFile file = FileDocumentManager.getInstance().getFile(document);
|
||||
FileType fileType = file == null ? null : file.getFileType();
|
||||
|
||||
@@ -212,8 +212,11 @@ public class TemplateState implements Disposable {
|
||||
if (variableName.equals(TemplateImpl.END)) {
|
||||
return new TextResult("");
|
||||
}
|
||||
if (myPredefinedVariableValues != null && myPredefinedVariableValues.containsKey(variableName)) {
|
||||
return new TextResult(myPredefinedVariableValues.get(variableName));
|
||||
if (myPredefinedVariableValues != null) {
|
||||
String text = myPredefinedVariableValues.get(variableName);
|
||||
if (text != null) {
|
||||
return new TextResult(text);
|
||||
}
|
||||
}
|
||||
CharSequence text = myDocument.getCharsSequence();
|
||||
int segmentNumber = myTemplate.getVariableSegmentNumber(variableName);
|
||||
|
||||
+43
-20
@@ -45,7 +45,9 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiFileFactory;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import com.intellij.util.ExceptionUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.io.SafeFileOutputStream;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.xml.XppReader;
|
||||
@@ -56,7 +58,6 @@ import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
@@ -65,6 +66,8 @@ import java.util.ListIterator;
|
||||
*/
|
||||
public class ConsoleHistoryController {
|
||||
|
||||
private static final int VERSION = 1;
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("com.intellij.execution.console.ConsoleHistoryController");
|
||||
|
||||
private final LanguageConsoleImpl myConsole;
|
||||
@@ -394,7 +397,15 @@ public class ConsoleHistoryController {
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LOG.error(ex);
|
||||
//noinspection ThrowableResultOfMethodCallIgnored
|
||||
Throwable cause = ExceptionUtil.getRootCause(ex);
|
||||
if (cause instanceof EOFException) {
|
||||
LOG.warn("Failed to load " + myType + " console history from: " + file.getPath(), ex);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
LOG.error(ex);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (xmlReader != null) {
|
||||
@@ -423,6 +434,7 @@ public class ConsoleHistoryController {
|
||||
}
|
||||
serializer.setOutput(os = new SafeFileOutputStream(file), CharsetToolkit.UTF8);
|
||||
saveHistory(serializer);
|
||||
serializer.flush();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
LOG.error(ex);
|
||||
@@ -439,47 +451,58 @@ public class ConsoleHistoryController {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String loadHistory(final HierarchicalStreamReader in, final String expectedId) {
|
||||
private String loadHistory(HierarchicalStreamReader in, String expectedId) {
|
||||
if (!in.getNodeName().equals("console-history")) return null;
|
||||
final String id = in.getAttribute("id");
|
||||
int version = StringUtil.parseInt(in.getAttribute("version"), 0);
|
||||
String id = in.getAttribute("id");
|
||||
if (!expectedId.equals(id)) return null;
|
||||
final ArrayList<String> entries = new ArrayList<String>();
|
||||
List<String> entries = ContainerUtil.newArrayList();
|
||||
String consoleContent = null;
|
||||
while (in.hasMoreChildren()) {
|
||||
in.moveDown();
|
||||
if ("history-entry".equals(in.getNodeName())) {
|
||||
entries.add(in.getValue());
|
||||
entries.add(StringUtil.notNullize(in.getValue()));
|
||||
}
|
||||
else if ("console-content".equals(in.getNodeName())) {
|
||||
consoleContent = in.getValue();
|
||||
consoleContent = StringUtil.notNullize(in.getValue());
|
||||
}
|
||||
in.moveUp();
|
||||
}
|
||||
for (ListIterator<String> iterator = entries.listIterator(entries.size()); iterator.hasPrevious(); ) {
|
||||
final String entry = iterator.previous();
|
||||
String entry = iterator.previous();
|
||||
getModel().addToHistory(entry);
|
||||
}
|
||||
return consoleContent;
|
||||
}
|
||||
|
||||
private void saveHistory(final XmlSerializer out) throws IOException {
|
||||
private void saveHistory(XmlSerializer out) throws IOException {
|
||||
out.startDocument(CharsetToolkit.UTF8, null);
|
||||
out.startTag(null, "console-history");
|
||||
out.attribute(null, "version", String.valueOf(VERSION));
|
||||
out.attribute(null, "id", myId);
|
||||
for (String s : getModel().getHistory()) {
|
||||
out.startTag(null, "history-entry");
|
||||
out.text(s);
|
||||
out.endTag(null, "history-entry");
|
||||
try {
|
||||
for (String s : getModel().getHistory()) {
|
||||
textTag(out, "history-entry", s);
|
||||
}
|
||||
String current = myContent;
|
||||
if (StringUtil.isNotEmpty(current)) {
|
||||
textTag(out, "console-content", current);
|
||||
}
|
||||
}
|
||||
String current = myContent;
|
||||
if (StringUtil.isNotEmpty(current)) {
|
||||
out.startTag(null, "console-content");
|
||||
out.text(current);
|
||||
out.endTag(null, "console-content");
|
||||
finally {
|
||||
out.endTag(null, "console-history");
|
||||
out.endDocument();
|
||||
}
|
||||
out.endTag(null, "console-history");
|
||||
out.endDocument();
|
||||
}
|
||||
}
|
||||
|
||||
private static void textTag(@NotNull XmlSerializer out, @NotNull String tag, @NotNull String text) throws IOException {
|
||||
out.startTag(null, tag);
|
||||
try {
|
||||
out.cdsect(text);
|
||||
}
|
||||
finally {
|
||||
out.endTag(null, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,6 +33,6 @@ public class ToggleExceptCommentsAndLiteralsAction extends EditorHeaderToggleAct
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
getEditorSearchComponent().getFindModel().setSearchContext(state ? FindModel.SearchContext.EXCEPT_STRINGS_AND_COMMENTS : FindModel.SearchContext.ANY);
|
||||
getEditorSearchComponent().getFindModel().setSearchContext(state ? FindModel.SearchContext.EXCEPT_COMMENTS_AND_STRING_LITERALS : FindModel.SearchContext.ANY);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,6 +33,6 @@ public class ToggleExceptLiteralsAction extends EditorHeaderToggleAction impleme
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
getEditorSearchComponent().getFindModel().setSearchContext(state ? FindModel.SearchContext.EXCEPT_STRINGS : FindModel.SearchContext.ANY);
|
||||
getEditorSearchComponent().getFindModel().setSearchContext(state ? FindModel.SearchContext.EXCEPT_STRING_LITERALS : FindModel.SearchContext.ANY);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -18,6 +18,6 @@ public class ToggleInLiteralsOnlyAction extends EditorHeaderToggleAction implem
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
getEditorSearchComponent().getFindModel().setSearchContext(state ? FindModel.SearchContext.IN_STRINGS : FindModel.SearchContext.ANY);
|
||||
getEditorSearchComponent().getFindModel().setSearchContext(state ? FindModel.SearchContext.IN_STRING_LITERALS : FindModel.SearchContext.ANY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.find.impl.FindManagerImpl;
|
||||
import com.intellij.find.replaceInProject.ReplaceInProjectManager;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -71,8 +72,14 @@ public class FindInProjectManager {
|
||||
findModel.setOpenInNewTab(toOpenInNewTab[0]);
|
||||
FindInProjectUtil.setDirectoryName(findModel, dataContext);
|
||||
|
||||
Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
|
||||
FindUtil.initStringToFindWithSelection(findModel, editor);
|
||||
String text = PlatformDataKeys.PREDEFINED_TEXT.getData(dataContext);
|
||||
if (text != null) {
|
||||
FindModel.initStringToFindNoMultiline(findModel, text);
|
||||
}
|
||||
else {
|
||||
Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
|
||||
FindUtil.initStringToFindWithSelection(findModel, editor);
|
||||
}
|
||||
|
||||
findManager.showFindDialog(findModel, new Runnable() {
|
||||
@Override
|
||||
|
||||
@@ -1000,7 +1000,7 @@ public class FindDialog extends DialogWrapper {
|
||||
String selectedSearchContextInUi = (String)mySearchContext.getSelectedItem();
|
||||
FindModel.SearchContext searchContext = FindModel.SearchContext.ANY;
|
||||
if (FindBundle.message("find.context.in.literals.scope.label").equals(selectedSearchContextInUi)) {
|
||||
searchContext = FindModel.SearchContext.IN_STRINGS;
|
||||
searchContext = FindModel.SearchContext.IN_STRING_LITERALS;
|
||||
}
|
||||
else if (FindBundle.message("find.context.in.comments.scope.label").equals(selectedSearchContextInUi)) {
|
||||
searchContext = FindModel.SearchContext.IN_COMMENTS;
|
||||
@@ -1009,9 +1009,9 @@ public class FindDialog extends DialogWrapper {
|
||||
searchContext = FindModel.SearchContext.EXCEPT_COMMENTS;
|
||||
}
|
||||
else if (FindBundle.message("find.context.except.literals.scope.label").equals(selectedSearchContextInUi)) {
|
||||
searchContext = FindModel.SearchContext.EXCEPT_STRINGS;
|
||||
searchContext = FindModel.SearchContext.EXCEPT_STRING_LITERALS;
|
||||
} else if (FindBundle.message("find.context.except.comments.and.literals.scope.label").equals(selectedSearchContextInUi)) {
|
||||
searchContext = FindModel.SearchContext.EXCEPT_STRINGS_AND_COMMENTS;
|
||||
searchContext = FindModel.SearchContext.EXCEPT_COMMENTS_AND_STRING_LITERALS;
|
||||
}
|
||||
|
||||
model.setSearchContext(searchContext);
|
||||
|
||||
@@ -27,7 +27,6 @@ import com.intellij.find.impl.livePreview.SearchResults;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageParserDefinitions;
|
||||
import com.intellij.lang.ParserDefinition;
|
||||
import com.intellij.lexer.LayeredLexer;
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.navigation.NavigationItem;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
@@ -42,11 +41,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.editor.ex.FoldingModelEx;
|
||||
import com.intellij.openapi.editor.ex.util.LayeredHighlighterIterator;
|
||||
import com.intellij.openapi.editor.ex.util.LayeredLexerEditorHighlighter;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory;
|
||||
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.TextEditor;
|
||||
@@ -58,7 +52,6 @@ import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.search.LexerEditorHighlighterLexer;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
@@ -66,8 +59,10 @@ import com.intellij.ui.LightweightHint;
|
||||
import com.intellij.ui.ReplacePromptDialog;
|
||||
import com.intellij.usages.ChunkExtractor;
|
||||
import com.intellij.usages.UsageViewManager;
|
||||
import com.intellij.usages.impl.SyntaxHighlighterOverEditorHighlighter;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.Predicate;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import com.intellij.util.text.StringSearcher;
|
||||
@@ -318,19 +313,23 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo
|
||||
LOG.debug(model.toString());
|
||||
}
|
||||
|
||||
final char[] textArray = CharArrayUtil.fromSequenceWithoutCopying(text);
|
||||
return findStringLoop(text, offset, model, file, getFindContextPredicate(model, file, text));
|
||||
}
|
||||
|
||||
private FindResult findStringLoop(CharSequence text, int offset, FindModel model, VirtualFile file, @Nullable Predicate<FindResult> filter) {
|
||||
final char[] textArray = CharArrayUtil.fromSequenceWithoutCopying(text);
|
||||
while(true) {
|
||||
FindResult result = doFindString(text, textArray, offset, model, file);
|
||||
|
||||
if (!model.isWholeWordsOnly()) {
|
||||
return result;
|
||||
}
|
||||
if (!result.isStringFound()){
|
||||
return result;
|
||||
}
|
||||
if (isWholeWord(text, result.getStartOffset(), result.getEndOffset())){
|
||||
return result;
|
||||
if (filter == null || filter.apply(result)) {
|
||||
if (!model.isWholeWordsOnly()) {
|
||||
return result;
|
||||
}
|
||||
if (!result.isStringFound()) {
|
||||
return result;
|
||||
}
|
||||
if (isWholeWord(text, result.getStartOffset(), result.getEndOffset())) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
offset = model.isForward() ? result.getStartOffset() + 1 : result.getEndOffset() - 1;
|
||||
@@ -338,6 +337,80 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo
|
||||
}
|
||||
}
|
||||
|
||||
private class FindExceptCommentsOrLiteralsData implements Predicate<FindResult> {
|
||||
private final VirtualFile myFile;
|
||||
private final FindModel myFindModel;
|
||||
private final TreeMap<Integer, Integer> mySkipRangesSet;
|
||||
|
||||
private FindExceptCommentsOrLiteralsData(VirtualFile file, FindModel model, CharSequence text) {
|
||||
myFile = file;
|
||||
myFindModel = model.clone();
|
||||
|
||||
TreeMap<Integer, Integer> result = new TreeMap<Integer, Integer>();
|
||||
|
||||
if (model.isExceptComments() || model.isExceptCommentsAndStringLiterals()) {
|
||||
addRanges(file, model, text, result, FindModel.SearchContext.IN_COMMENTS);
|
||||
}
|
||||
|
||||
if (model.isExceptStringLiterals() || model.isExceptCommentsAndStringLiterals()) {
|
||||
addRanges(file, model, text, result, FindModel.SearchContext.IN_STRING_LITERALS);
|
||||
}
|
||||
|
||||
mySkipRangesSet = result;
|
||||
}
|
||||
|
||||
private void addRanges(VirtualFile file,
|
||||
FindModel model,
|
||||
CharSequence text,
|
||||
TreeMap<Integer, Integer> result,
|
||||
FindModel.SearchContext searchContext) {
|
||||
FindModel clonedModel = model.clone();
|
||||
clonedModel.setSearchContext(searchContext);
|
||||
clonedModel.setForward(true);
|
||||
int offset = 0;
|
||||
|
||||
while(true) {
|
||||
FindResult customResult = findStringLoop(text, offset, clonedModel, file, null);
|
||||
if (!customResult.isStringFound()) break;
|
||||
result.put(customResult.getStartOffset(), customResult.getEndOffset());
|
||||
offset = Math.max(customResult.getEndOffset(), offset + 1); // avoid loop for zero size reg exps matches
|
||||
if (offset >= text.length()) break;
|
||||
}
|
||||
}
|
||||
|
||||
boolean isAcceptableFor(FindModel model, VirtualFile file) {
|
||||
return Comparing.equal(myFile, file) && myFindModel.equals(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(@Nullable FindResult input) {
|
||||
if (input == null || !input.isStringFound()) return true;
|
||||
NavigableMap<Integer, Integer> map = mySkipRangesSet.headMap(input.getStartOffset(), true);
|
||||
for(Map.Entry<Integer, Integer> e:map.descendingMap().entrySet()) {
|
||||
if (e.getKey() <= input.getStartOffset() && e.getValue() >= input.getEndOffset()) return false;
|
||||
if (e.getValue() <= input.getStartOffset()) break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
private static Key<FindExceptCommentsOrLiteralsData> ourExceptCommentsOrLiteralsDataKey = Key.create("except.comments.literals.search.data");
|
||||
|
||||
private Predicate<FindResult> getFindContextPredicate(@NotNull FindModel model, VirtualFile file, CharSequence text) {
|
||||
if (file == null) return null;
|
||||
FindModel.SearchContext context = model.getSearchContext();
|
||||
if( context == FindModel.SearchContext.ANY || context == FindModel.SearchContext.IN_COMMENTS ||
|
||||
context == FindModel.SearchContext.IN_STRING_LITERALS) {
|
||||
return null;
|
||||
}
|
||||
|
||||
FindExceptCommentsOrLiteralsData data = model.getUserData(ourExceptCommentsOrLiteralsDataKey);
|
||||
if (data == null || !data.isAcceptableFor(model, file)) {
|
||||
model.putUserData(ourExceptCommentsOrLiteralsDataKey, data = new FindExceptCommentsOrLiteralsData(file, model, text));
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int showMalformedReplacementPrompt(@NotNull FindModel model, String title, MalformedReplacementStringException exception) {
|
||||
return showPromptDialogImpl(model, title, exception);
|
||||
@@ -421,11 +494,15 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo
|
||||
return new StringSearcher(model.getStringToFind(), model.isCaseSensitive(), model.isForward());
|
||||
}
|
||||
|
||||
public static void clearPreviousFindData(FindModel model) {
|
||||
model.putUserData(ourCommentsLiteralsSearchDataKey, null);
|
||||
model.putUserData(ourExceptCommentsOrLiteralsDataKey, null);
|
||||
}
|
||||
|
||||
private static class CommentsLiteralsSearchData {
|
||||
final VirtualFile lastFile;
|
||||
int startOffset = 0;
|
||||
final SyntaxHighlighter highlighter;
|
||||
final Lexer highlightingLexer;
|
||||
final SyntaxHighlighterOverEditorHighlighter highlighter;
|
||||
|
||||
TokenSet tokensOfInterest;
|
||||
final StringSearcher searcher;
|
||||
@@ -433,8 +510,8 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo
|
||||
final Set<Language> relevantLanguages;
|
||||
final FindModel model;
|
||||
|
||||
public CommentsLiteralsSearchData(VirtualFile lastFile, Set<Language> relevantLanguages, SyntaxHighlighter highlighter,
|
||||
Lexer lexer, TokenSet tokensOfInterest,
|
||||
public CommentsLiteralsSearchData(VirtualFile lastFile, Set<Language> relevantLanguages,
|
||||
SyntaxHighlighterOverEditorHighlighter highlighter, TokenSet tokensOfInterest,
|
||||
StringSearcher searcher, Matcher matcher, FindModel model) {
|
||||
this.lastFile = lastFile;
|
||||
this.highlighter = highlighter;
|
||||
@@ -442,12 +519,11 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo
|
||||
this.searcher = searcher;
|
||||
this.matcher = matcher;
|
||||
this.relevantLanguages = relevantLanguages;
|
||||
highlightingLexer = lexer;
|
||||
this.model = model;
|
||||
}
|
||||
}
|
||||
|
||||
public static final Key<CommentsLiteralsSearchData> ourCommentsLiteralsSearchDataKey = Key.create("comments.literals.search.data");
|
||||
private static final Key<CommentsLiteralsSearchData> ourCommentsLiteralsSearchDataKey = Key.create("comments.literals.search.data");
|
||||
|
||||
@NotNull
|
||||
private FindResult findInCommentsAndLiterals(@NotNull CharSequence text,
|
||||
@@ -525,38 +601,15 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo
|
||||
|
||||
Matcher matcher = model.isRegularExpressions() ? compileRegExp(model, ""):null;
|
||||
StringSearcher searcher = matcher != null ? null: new StringSearcher(model.getStringToFind(), model.isCaseSensitive(), true);
|
||||
LayeredLexer.ourDisableLayersFlag.set(Boolean.TRUE);
|
||||
EditorHighlighter editorHighlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, file);
|
||||
Lexer lexer;
|
||||
|
||||
try {
|
||||
if (editorHighlighter instanceof LayeredLexerEditorHighlighter) {
|
||||
lexer = new LexerEditorHighlighterLexer(editorHighlighter, false);
|
||||
} else {
|
||||
lexer = highlighter.getHighlightingLexer();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
LayeredLexer.ourDisableLayersFlag.set(null);
|
||||
}
|
||||
|
||||
data = new CommentsLiteralsSearchData(file, relevantLanguages, highlighter, lexer, tokensOfInterest, searcher, matcher, (FindModel)model.clone());
|
||||
lexer.start(text, 0, text.length(), 0);
|
||||
SyntaxHighlighterOverEditorHighlighter highlighterAdapter = new SyntaxHighlighterOverEditorHighlighter(highlighter, file, myProject);
|
||||
data = new CommentsLiteralsSearchData(file, relevantLanguages, highlighterAdapter, tokensOfInterest, searcher, matcher, model.clone());
|
||||
data.highlighter.restart(text);
|
||||
model.putUserData(ourCommentsLiteralsSearchDataKey, data);
|
||||
}
|
||||
|
||||
int initialStartOffset = model.isForward() && data.startOffset < offset ? data.startOffset : 0;
|
||||
final Lexer lexer = data.highlightingLexer;
|
||||
LayeredHighlighterIterator layeredHighlighterIterator = null;
|
||||
if (lexer instanceof LexerEditorHighlighterLexer) {
|
||||
((LexerEditorHighlighterLexer)lexer).resetPosition(initialStartOffset);
|
||||
HighlighterIterator iterator = ((LexerEditorHighlighterLexer)lexer).getHighlighterIterator();
|
||||
if (iterator instanceof LayeredHighlighterIterator) {
|
||||
layeredHighlighterIterator = (LayeredHighlighterIterator)iterator;
|
||||
}
|
||||
} else {
|
||||
lexer.start(text, initialStartOffset, text.length(), 0);
|
||||
}
|
||||
data.highlighter.resetPosition(initialStartOffset);
|
||||
final Lexer lexer = data.highlighter.getHighlightingLexer();
|
||||
|
||||
IElementType tokenType;
|
||||
TokenSet tokens = data.tokensOfInterest;
|
||||
@@ -568,9 +621,7 @@ public class FindManagerImpl extends FindManager implements PersistentStateCompo
|
||||
while((tokenType = lexer.getTokenType()) != null) {
|
||||
if (lexer.getState() == 0) lastGoodOffset = lexer.getTokenStart();
|
||||
|
||||
final SyntaxHighlighter activeSyntaxHighlighter =
|
||||
layeredHighlighterIterator != null ? layeredHighlighterIterator.getActiveSyntaxHighlighter() : data.highlighter;
|
||||
final TextAttributesKey[] keys = activeSyntaxHighlighter.getTokenHighlights(tokenType);
|
||||
final TextAttributesKey[] keys = data.highlighter.getTokenHighlights(tokenType);
|
||||
|
||||
if (tokens.contains(tokenType) ||
|
||||
(model.isInStringLiteralsOnly() && ChunkExtractor.isHighlightedAsString(keys)) ||
|
||||
|
||||
@@ -80,7 +80,7 @@ public class FindResultUsageInfo extends UsageInfo {
|
||||
Long data = myFindModel.getUserData(ourDocumentTimestampKey);
|
||||
if (data == null || data != myTimestamp) {
|
||||
data = myTimestamp;
|
||||
myFindModel.putUserData(FindManagerImpl.ourCommentsLiteralsSearchDataKey, null);
|
||||
FindManagerImpl.clearPreviousFindData(myFindModel);
|
||||
}
|
||||
myFindModel.putUserData(ourDocumentTimestampKey, data);
|
||||
FindResult result;
|
||||
|
||||
@@ -104,8 +104,8 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean COMMENTS_ONLY = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean STRING_LITERALS_ONLY = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean EXCEPT_COMMENTS = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean EXCEPT_COMMENTS_AND_LITERALS = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean EXCEPT_LITERALS = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean EXCEPT_COMMENTS_AND_STRING_LITERALS = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean EXCEPT_STRING_LITERALS = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean LOCAL_WHOLE_WORDS_ONLY = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean REGULAR_EXPRESSIONS = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean LOCAL_REGULAR_EXPRESSIONS = false;
|
||||
@@ -282,13 +282,13 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom
|
||||
FindModel.SearchContext searchContext = isInCommentsOnly() ?
|
||||
FindModel.SearchContext.IN_COMMENTS :
|
||||
isInStringLiteralsOnly() ?
|
||||
FindModel.SearchContext.IN_STRINGS :
|
||||
FindModel.SearchContext.IN_STRING_LITERALS :
|
||||
isExceptComments() ?
|
||||
FindModel.SearchContext.EXCEPT_COMMENTS :
|
||||
isExceptStringLiterals() ?
|
||||
FindModel.SearchContext.EXCEPT_STRINGS :
|
||||
FindModel.SearchContext.EXCEPT_STRING_LITERALS :
|
||||
isExceptCommentsAndLiterals() ?
|
||||
FindModel.SearchContext.EXCEPT_STRINGS_AND_COMMENTS :
|
||||
FindModel.SearchContext.EXCEPT_COMMENTS_AND_STRING_LITERALS :
|
||||
FindModel.SearchContext.ANY;
|
||||
model.setSearchContext(searchContext);
|
||||
model.setWithSubdirectories(isWithSubdirectories());
|
||||
@@ -405,12 +405,12 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom
|
||||
|
||||
@Override
|
||||
public void setExceptCommentsAndLiterals(boolean selected) {
|
||||
EXCEPT_COMMENTS_AND_LITERALS = selected;
|
||||
EXCEPT_COMMENTS_AND_STRING_LITERALS = selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExceptCommentsAndLiterals() {
|
||||
return EXCEPT_COMMENTS_AND_LITERALS;
|
||||
return EXCEPT_COMMENTS_AND_STRING_LITERALS;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -420,11 +420,11 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom
|
||||
|
||||
@Override
|
||||
public boolean isExceptStringLiterals() {
|
||||
return EXCEPT_LITERALS;
|
||||
return EXCEPT_STRING_LITERALS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExceptStringLiterals(boolean selected) {
|
||||
EXCEPT_LITERALS = selected;
|
||||
EXCEPT_STRING_LITERALS = selected;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class FormatterImpl extends FormatterEx
|
||||
if (spacing == null) {
|
||||
return 0;
|
||||
}
|
||||
return spacing.getMinSpaces();
|
||||
return Math.max(spacing.getMinSpaces(), 0);
|
||||
}
|
||||
|
||||
private static Couple<Block> getBlockAtOffset(Block parent, Block block, int offset) {
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -149,7 +149,7 @@ abstract class CodeStyleManagerRunnable<T> {
|
||||
SourceTreeToPsiMap.psiElementToTree(CodeStyleManagerImpl.findElementInTreeWithFormatterEnabled(file, offset));
|
||||
if (elementAtOffset == null) {
|
||||
int significantRangeStart = CharArrayUtil.shiftBackward(file.getText(), offset - 1, "\r\t ");
|
||||
return new TextRange(significantRangeStart, offset);
|
||||
return new TextRange(Math.max(significantRangeStart, 0), offset);
|
||||
}
|
||||
|
||||
final FormattingModelBuilder builder = LanguageFormatting.INSTANCE.forContext(file);
|
||||
|
||||
+24
-34
@@ -8,7 +8,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.HyperlinkAdapter;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.ui.SwingHelper;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -23,19 +23,17 @@ import java.util.Map;
|
||||
* @author yole
|
||||
*/
|
||||
public class PackagesNotificationPanel {
|
||||
private final JEditorPane myEditorPane = new MyNotificationPane();
|
||||
private final Project myProject;
|
||||
private final JEditorPane myHtmlViewer;
|
||||
private final Map<String, Runnable> myLinkHandlers = new HashMap<String, Runnable>();
|
||||
private String myErrorTitle;
|
||||
private String myErrorDescription;
|
||||
|
||||
public PackagesNotificationPanel(Project project) {
|
||||
public PackagesNotificationPanel(@NotNull Project project) {
|
||||
myProject = project;
|
||||
myEditorPane.setBackground(UIManager.getColor("ArrowButton.background"));
|
||||
myEditorPane.setContentType("text/html");
|
||||
myEditorPane.setEditable(false);
|
||||
myEditorPane.setVisible(false);
|
||||
myEditorPane.addHyperlinkListener(new HyperlinkAdapter() {
|
||||
myHtmlViewer = SwingHelper.createHtmlViewer(true, null, null, null);
|
||||
myHtmlViewer.setVisible(false);
|
||||
myHtmlViewer.addHyperlinkListener(new HyperlinkAdapter() {
|
||||
@Override
|
||||
protected void hyperlinkActivated(HyperlinkEvent e) {
|
||||
final Runnable handler = myLinkHandlers.get(e.getDescription());
|
||||
@@ -78,11 +76,18 @@ public class PackagesNotificationPanel {
|
||||
|
||||
public void showResult(String packageName, @Nullable String errorDescription) {
|
||||
if (StringUtil.isEmpty(errorDescription)) {
|
||||
showSuccess("Package successfully installed.");
|
||||
String message = "Package installed successfully";
|
||||
if (packageName != null) {
|
||||
message = "Package '" + packageName + "' installed successfully";
|
||||
}
|
||||
showSuccess(message);
|
||||
}
|
||||
else {
|
||||
String title = "Install packages failed";
|
||||
final String firstLine = title + ": Error occurred when installing package " + packageName + ". ";
|
||||
String title = "Failed to install packages";
|
||||
if (packageName != null) {
|
||||
title = "Failed to install package '" + packageName + "'";
|
||||
}
|
||||
String firstLine = "Error occurred when installing package '" + packageName + "'. ";
|
||||
showError(firstLine + "<a href=\"xxx\">Details...</a>",
|
||||
title,
|
||||
firstLine + errorDescription);
|
||||
@@ -98,17 +103,17 @@ public class PackagesNotificationPanel {
|
||||
}
|
||||
|
||||
public JComponent getComponent() {
|
||||
return myEditorPane;
|
||||
return myHtmlViewer;
|
||||
}
|
||||
|
||||
public void showSuccess(String text) {
|
||||
showContent(text, MessageType.INFO.getPopupBackground());
|
||||
}
|
||||
|
||||
private void showContent(String text, final Color background) {
|
||||
private void showContent(@NotNull String text, @NotNull Color background) {
|
||||
String htmlText = text.startsWith("<html>") ? text : UIUtil.toHtml(text);
|
||||
myEditorPane.setText(htmlText);
|
||||
myEditorPane.setBackground(background);
|
||||
myHtmlViewer.setText(htmlText);
|
||||
myHtmlViewer.setBackground(background);
|
||||
setVisibleEditorPane(true);
|
||||
myErrorTitle = null;
|
||||
myErrorDescription = null;
|
||||
@@ -129,15 +134,11 @@ public class PackagesNotificationPanel {
|
||||
}
|
||||
|
||||
private void setVisibleEditorPane(boolean visible) {
|
||||
boolean oldVisible = myEditorPane.isVisible();
|
||||
myEditorPane.setVisible(visible);
|
||||
boolean oldVisible = myHtmlViewer.isVisible();
|
||||
myHtmlViewer.setVisible(visible);
|
||||
if (oldVisible != visible) {
|
||||
JComponent comp = ObjectUtils.tryCast(myEditorPane.getParent(), JComponent.class);
|
||||
if (comp == null) {
|
||||
comp = myEditorPane;
|
||||
}
|
||||
comp.revalidate();
|
||||
comp.repaint();
|
||||
myHtmlViewer.revalidate();
|
||||
myHtmlViewer.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,17 +146,6 @@ public class PackagesNotificationPanel {
|
||||
return myLinkHandlers.containsKey(key);
|
||||
}
|
||||
|
||||
private static class MyNotificationPane extends JEditorPane {
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
// This trick makes text component to carry text over to the next line
|
||||
// iff the text line width exceeds parent's width
|
||||
Dimension dimension = super.getPreferredSize();
|
||||
dimension.width = 0;
|
||||
return dimension;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeLinkHandler(String key) {
|
||||
myLinkHandlers.remove(key);
|
||||
}
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.codeInsight.editorActions;
|
||||
|
||||
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class IndentingBackspaceHandlerUncommittedDocumentTest extends LightPlatformCodeInsightTestCase {
|
||||
public void testSequentialBackspaceInvocation() throws IOException {
|
||||
configureFromFileText(getTestName(false) + ".java",
|
||||
"class Foo {\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"<caret>}");
|
||||
backspace();
|
||||
backspace();
|
||||
checkResultByText("class Foo {\n" +
|
||||
"<caret>}");
|
||||
}
|
||||
}
|
||||
@@ -271,7 +271,7 @@ public interface IdeActions {
|
||||
String ACTION_UNDO = "$Undo";
|
||||
String ACTION_REDO = "$Redo";
|
||||
String GROUP_REFACTOR = "RefactoringMenu";
|
||||
String SELECTED_CHANGES_ROLLBACK = "RollbackLineStatusChanges";
|
||||
String SELECTED_CHANGES_ROLLBACK = "Vcs.RollbackChangedLines";
|
||||
String CHANGES_VIEW_ROLLBACK = "ChangesView.Rollback";
|
||||
|
||||
String CONSOLE_CLEAR_ALL = "ConsoleView.ClearAll";
|
||||
|
||||
@@ -27,9 +27,9 @@ public abstract class SplitterActionBase extends AnAction implements DumbAware {
|
||||
public void update(final AnActionEvent event) {
|
||||
final Project project = CommonDataKeys.PROJECT.getData(event.getDataContext());
|
||||
final Presentation presentation = event.getPresentation();
|
||||
boolean context = ActionPlaces.isPopupPlace(event.getPlace());
|
||||
boolean enabled = project != null && isActionEnabled(project, context);
|
||||
if (context) {
|
||||
boolean inContextMenu = ActionPlaces.isPopupPlace(event.getPlace());
|
||||
boolean enabled = project != null && isActionEnabled(project, inContextMenu);
|
||||
if (inContextMenu) {
|
||||
presentation.setVisible(enabled);
|
||||
}
|
||||
else {
|
||||
@@ -37,7 +37,17 @@ public abstract class SplitterActionBase extends AnAction implements DumbAware {
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isActionEnabled(Project project, boolean context) {
|
||||
/**
|
||||
* This method determines whether the action is enabled for {@code project}
|
||||
* if {@code inContextMenu} is set to {@code false}. Otherwise,
|
||||
* it determines whether the action is visible in the context menu.
|
||||
*
|
||||
* @param project the specified project
|
||||
* @param inContextMenu whether the action is used in context menu
|
||||
* @return {@code true} if the action is enabled,
|
||||
* {@code false} otherwise
|
||||
*/
|
||||
protected boolean isActionEnabled(Project project, boolean inContextMenu) {
|
||||
final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
|
||||
return fileEditorManager.isInSplitter();
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ public final class UnsplitAllAction extends SplitterActionBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isActionEnabled(Project project, boolean context) {
|
||||
protected boolean isActionEnabled(Project project, boolean inContextMenu) {
|
||||
final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
|
||||
return context ? fileEditorManager.getWindowSplitCount() > 2 : fileEditorManager.isInSplitter();
|
||||
return inContextMenu ? fileEditorManager.getWindowSplitCount() > 2 : fileEditorManager.isInSplitter();
|
||||
}
|
||||
}
|
||||
|
||||
+33
@@ -15,10 +15,19 @@
|
||||
*/
|
||||
package com.intellij.openapi.editor.impl;
|
||||
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.cache.impl.id.PlatformIdTableBuilding;
|
||||
import com.intellij.psi.impl.search.LexerEditorHighlighterLexer;
|
||||
import com.intellij.reference.SoftReference;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -55,4 +64,28 @@ public class EditorHighlighterCache {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Lexer getLexerBasedOnLexerHighlighter(CharSequence text, VirtualFile virtualFile, Project project) {
|
||||
EditorHighlighter highlighter = null;
|
||||
|
||||
PsiFile psiFile = virtualFile != null ? PsiManager.getInstance(project).findFile(virtualFile) : null;
|
||||
final Document document = psiFile != null ? PsiDocumentManager.getInstance(project).getDocument(psiFile) : null;
|
||||
final EditorHighlighter cachedEditorHighlighter;
|
||||
boolean alreadyInitializedHighlighter = false;
|
||||
|
||||
if (document != null &&
|
||||
(cachedEditorHighlighter = getEditorHighlighterForCachesBuilding(document)) != null &&
|
||||
PlatformIdTableBuilding.checkCanUseCachedEditorHighlighter(text, cachedEditorHighlighter)) {
|
||||
highlighter = cachedEditorHighlighter;
|
||||
alreadyInitializedHighlighter = true;
|
||||
}
|
||||
else if (virtualFile != null) {
|
||||
highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(project, virtualFile);
|
||||
}
|
||||
|
||||
if (highlighter != null) {
|
||||
return new LexerEditorHighlighterLexer(highlighter, alreadyInitializedHighlighter);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+18
-19
@@ -46,7 +46,6 @@ import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.ProperTextRange;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.wm.ToolWindowAnchor;
|
||||
import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
|
||||
@@ -430,7 +429,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
public void paint(@NotNull Graphics g) {
|
||||
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintStart();
|
||||
|
||||
final Rectangle bounds = getBounds();
|
||||
@@ -439,7 +438,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
errorIconBounds.y = bounds.height / 2 - errorIconBounds.height / 2;
|
||||
|
||||
try {
|
||||
if (UISettings.getInstance().PRESENTATION_MODE || SystemInfo.isMac) {
|
||||
if (UISettings.getInstance().PRESENTATION_MODE || ButtonlessScrollBarUI.isMacOverlayScrollbarSupported()) {
|
||||
g.setColor(getEditor().getColorsScheme().getDefaultBackground());
|
||||
g.fillRect(0, 0, bounds.width, bounds.height);
|
||||
|
||||
@@ -495,7 +494,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uninstallUI(JComponent c) {
|
||||
public void uninstallUI(@NotNull JComponent c) {
|
||||
super.uninstallUI(c);
|
||||
myCachedTrack = null;
|
||||
}
|
||||
@@ -530,7 +529,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
|
||||
@Override
|
||||
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
|
||||
if (UISettings.getInstance().PRESENTATION_MODE || SystemInfo.isMac) {
|
||||
if (UISettings.getInstance().PRESENTATION_MODE || ButtonlessScrollBarUI.isMacOverlayScrollbarSupported()) {
|
||||
super.paintThumb(g, c, thumbBounds);
|
||||
return;
|
||||
}
|
||||
@@ -567,13 +566,13 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
|
||||
@Override
|
||||
protected int getThickness() {
|
||||
if (UISettings.getInstance().PRESENTATION_MODE || SystemInfo.isMac) return super.getThickness();
|
||||
if (UISettings.getInstance().PRESENTATION_MODE || ButtonlessScrollBarUI.isMacOverlayScrollbarSupported()) return super.getThickness();
|
||||
return super.getThickness() + (isMacOverlayScrollbar() ? 2 : 7);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPaintTrack(Graphics g, JComponent c, Rectangle bounds) {
|
||||
if (UISettings.getInstance().PRESENTATION_MODE || SystemInfo.isMac) {
|
||||
if (UISettings.getInstance().PRESENTATION_MODE || ButtonlessScrollBarUI.isMacOverlayScrollbarSupported()) {
|
||||
g.setColor(getEditor().getColorsScheme().getDefaultBackground());
|
||||
g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
|
||||
//return;
|
||||
@@ -611,7 +610,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
}
|
||||
|
||||
private void paintTrackBasement(Graphics g, Rectangle bounds) {
|
||||
if (UISettings.getInstance().PRESENTATION_MODE || SystemInfo.isMac) {
|
||||
if (UISettings.getInstance().PRESENTATION_MODE || ButtonlessScrollBarUI.isMacOverlayScrollbarSupported()) {
|
||||
g.setColor(EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground());
|
||||
g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
|
||||
return;
|
||||
@@ -651,13 +650,13 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
private void drawMarkup(final Graphics g, final int width, int startOffset, int endOffset, MarkupModelEx markup) {
|
||||
final Queue<PositionedStripe> thinEnds = new PriorityQueue<PositionedStripe>(5, new Comparator<PositionedStripe>() {
|
||||
@Override
|
||||
public int compare(PositionedStripe o1, PositionedStripe o2) {
|
||||
public int compare(@NotNull PositionedStripe o1, @NotNull PositionedStripe o2) {
|
||||
return o1.yEnd - o2.yEnd;
|
||||
}
|
||||
});
|
||||
final Queue<PositionedStripe> wideEnds = new PriorityQueue<PositionedStripe>(5, new Comparator<PositionedStripe>() {
|
||||
@Override
|
||||
public int compare(PositionedStripe o1, PositionedStripe o2) {
|
||||
public int compare(@NotNull PositionedStripe o1, @NotNull PositionedStripe o2) {
|
||||
return o1.yEnd - o2.yEnd;
|
||||
}
|
||||
});
|
||||
@@ -799,7 +798,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
|
||||
// mouse events
|
||||
@Override
|
||||
public void mouseClicked(final MouseEvent e) {
|
||||
public void mouseClicked(@NotNull final MouseEvent e) {
|
||||
CommandProcessor.getInstance().executeCommand(myEditor.getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -813,11 +812,11 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
public void mousePressed(@NotNull MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
public void mouseReleased(@NotNull MouseEvent e) {
|
||||
}
|
||||
|
||||
private int getWidth() {
|
||||
@@ -836,7 +835,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
public void mouseMoved(@NotNull MouseEvent e) {
|
||||
EditorImpl.MyScrollBar scrollBar = myEditor.getVerticalScrollBar();
|
||||
int buttonHeight = scrollBar.getDecScrollButtonHeight();
|
||||
int lineCount = getDocument().getLineCount() + myEditor.getSettings().getAdditionalLinesCount();
|
||||
@@ -909,16 +908,16 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
public void mouseEntered(@NotNull MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
public void mouseExited(@NotNull MouseEvent e) {
|
||||
cancelMyToolTips(e, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
public void mouseDragged(@NotNull MouseEvent e) {
|
||||
cancelMyToolTips(e, true);
|
||||
}
|
||||
|
||||
@@ -1149,7 +1148,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
myHighlighters.add(rangeHighlighter);
|
||||
}
|
||||
Collections.sort(myHighlighters, new Comparator<RangeHighlighterEx>() {
|
||||
public int compare(RangeHighlighterEx ex1, RangeHighlighterEx ex2) {
|
||||
public int compare(@NotNull RangeHighlighterEx ex1, @NotNull RangeHighlighterEx ex2) {
|
||||
LogicalPosition startPos1 = myEditor.offsetToLogicalPosition(ex1.getAffectedAreaStartOffset());
|
||||
LogicalPosition startPos2 = myEditor.offsetToLogicalPosition(ex2.getAffectedAreaStartOffset());
|
||||
if (startPos1.line != startPos2.line) return 0;
|
||||
@@ -1179,7 +1178,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
protected void paintComponent(@NotNull Graphics g) {
|
||||
if (myVisualLine ==-1) return;
|
||||
Dimension size = getPreferredSize();
|
||||
EditorGutterComponentEx gutterComponentEx = myEditor.getGutterComponentEx();
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -102,7 +102,8 @@ public final class RequestFocusInEditorComponentCmd extends FinalizableCommand{
|
||||
}
|
||||
|
||||
if(myComponent != null){
|
||||
myFocusManager.requestFocus(myComponent, myForced).notifyWhenDone(myDoneCallback).doWhenDone(new Runnable() {
|
||||
final boolean forced = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() == null;
|
||||
myFocusManager.requestFocus(myComponent, myForced || forced).notifyWhenDone(myDoneCallback).doWhenDone(new Runnable() {
|
||||
public void run() {
|
||||
// if owner is active window or it has active child window which isn't floating decorator then
|
||||
// don't bring owner window to font. If we will make toFront every time then it's possible
|
||||
|
||||
@@ -223,6 +223,7 @@ public abstract class AbstractExpandableItemsHandler<KeyType, ComponentType exte
|
||||
if (selected == null
|
||||
|| !myComponent.isEnabled()
|
||||
|| !myComponent.isShowing()
|
||||
|| !myComponent.getVisibleRect().intersects(getVisibleRect(selected))
|
||||
|| !myComponent.isFocusOwner() && !processIfUnfocused
|
||||
|| isPopup()) {
|
||||
hideHint();
|
||||
|
||||
@@ -613,7 +613,7 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
|
||||
myComp.setBorder(new EmptyBorder(borderSize, borderSize, borderSize, borderSize));
|
||||
|
||||
myLayeredPane.add(myComp);
|
||||
myLayeredPane.setLayer(myComp, getLayer());
|
||||
myLayeredPane.setLayer(myComp, getLayer(), 0); // the second balloon must be over the first one
|
||||
myPosition.updateBounds(this);
|
||||
if (myBlockClicks) {
|
||||
myComp.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@@ -162,6 +162,25 @@ public class AbstractPopup implements JBPopup {
|
||||
private UiActivity myActivityKey;
|
||||
private Disposable myProjectDisposable;
|
||||
|
||||
private volatile State myState = State.NEW;
|
||||
|
||||
private enum State {NEW, INIT, SHOWING, SHOWN, CANCEL, DISPOSE}
|
||||
|
||||
private void debugState(String message, State... states) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(hashCode() + " - " + message);
|
||||
if (!ApplicationManager.getApplication().isDispatchThread()) {
|
||||
LOG.debug("unexpected thread");
|
||||
}
|
||||
for (State state : states) {
|
||||
if (state == myState) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
LOG.debug(new IllegalStateException("myState=" + myState));
|
||||
}
|
||||
}
|
||||
|
||||
AbstractPopup() { }
|
||||
|
||||
AbstractPopup init(Project project,
|
||||
@@ -302,6 +321,8 @@ public class AbstractPopup implements JBPopup {
|
||||
}
|
||||
|
||||
myKeyEventHandler = keyEventHandler;
|
||||
debugState("popup initialized", State.NEW);
|
||||
myState = State.INIT;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -582,10 +603,18 @@ public class AbstractPopup implements JBPopup {
|
||||
|
||||
@Override
|
||||
public void cancel(InputEvent e) {
|
||||
if (myState == State.CANCEL || myState == State.DISPOSE) {
|
||||
return;
|
||||
}
|
||||
debugState("cancel popup", State.SHOWN);
|
||||
myState = State.CANCEL;
|
||||
|
||||
if (isDisposed()) return;
|
||||
|
||||
if (myPopup != null) {
|
||||
if (!canClose()) {
|
||||
debugState("cannot cancel popup", State.CANCEL);
|
||||
myState = State.SHOWN;
|
||||
return;
|
||||
}
|
||||
storeDimensionSize(myContent.getSize());
|
||||
@@ -669,6 +698,9 @@ public class AbstractPopup implements JBPopup {
|
||||
|
||||
assert ApplicationManager.getApplication().isDispatchThread();
|
||||
|
||||
debugState("show popup", State.INIT);
|
||||
myState = State.SHOWING;
|
||||
|
||||
installWindowHook(this);
|
||||
installProjectDisposer();
|
||||
addActivity();
|
||||
@@ -678,6 +710,8 @@ public class AbstractPopup implements JBPopup {
|
||||
final boolean shouldShow = beforeShow();
|
||||
if (!shouldShow) {
|
||||
removeActivity();
|
||||
debugState("rejected to show popup", State.SHOWING);
|
||||
myState = State.INIT;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -963,6 +997,8 @@ public class AbstractPopup implements JBPopup {
|
||||
}
|
||||
});
|
||||
}
|
||||
debugState("popup shown", State.SHOWING);
|
||||
myState = State.SHOWN;
|
||||
}
|
||||
|
||||
public void focusPreferredComponent() {
|
||||
@@ -1238,6 +1274,16 @@ public class AbstractPopup implements JBPopup {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (myState == State.SHOWN) {
|
||||
LOG.debug("shown popup must be cancelled");
|
||||
cancel();
|
||||
}
|
||||
if (myState == State.DISPOSE) {
|
||||
return;
|
||||
}
|
||||
debugState("dispose popup", State.INIT, State.CANCEL);
|
||||
myState = State.DISPOSE;
|
||||
|
||||
if (myDisposed) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1016,8 +1016,8 @@ action.Vcs.ShowDiffAction.text=Show Changes
|
||||
action.Vcs.ShowDiffAction.description=Show changes
|
||||
action.Vcs.RollbackChanges.text=Rollback Changes
|
||||
action.Vcs.RollbackChanges.description=Rollback changes
|
||||
action.RollbackLineStatusChanges.text=Rollback
|
||||
action.RollbackLineStatusChanges.description=Rollback selected local changes
|
||||
action.Vcs.RollbackChangedLines.text=Rollback
|
||||
action.Vcs.RollbackChangedLines.description=Rollback changes in selected lines
|
||||
action.Vcs.EditSourceAction.text=Edit Source
|
||||
action.Vcs.EditSourceAction.description=Edit source
|
||||
action.Vcs.ExcludeAction.text=Exclude from Commit
|
||||
|
||||
@@ -233,3 +233,6 @@ start.browser.with.js.debugger=with &JavaScript debugger
|
||||
|
||||
javascript.debugger.settings.choose.file.title=Select
|
||||
javascript.debugger.settings.choose.file.subtitle=Select file to debug JavaScript in
|
||||
|
||||
setting.value.builtin.server.port.label=Built-in server &port:
|
||||
setting.value.can.accept.external.connections=Can accept &external connections
|
||||
@@ -89,6 +89,9 @@
|
||||
</extensionPoint>
|
||||
|
||||
<extensionPoint name="xml.undefinedElementFixProvider" interface="com.intellij.xml.XmlUndefinedElementFixProvider"/>
|
||||
|
||||
<extensionPoint qualifiedName="org.jetbrains.webServerFileHandler" interface="org.jetbrains.builtInWebServer.FileHandler"/>
|
||||
<extensionPoint qualifiedName="org.jetbrains.webServerProjectRootsProvider" interface="org.jetbrains.builtInWebServer.ProjectRootsProvider"/>
|
||||
</extensionPoints>
|
||||
|
||||
<project-components>
|
||||
@@ -530,8 +533,20 @@
|
||||
<applicationConfigurable groupId="tools" instance="com.intellij.ide.browsers.BrowserSettings" id="reference.settings.ide.settings.web.browsers"
|
||||
key="browsers.settings" bundle="messages.IdeBundle"/>
|
||||
<lang.inspectionSuppressor language="XML" implementationClass="com.intellij.codeInspection.XmlInspectionSuppressor"/>
|
||||
|
||||
<httpRequestHandler implementation="org.jetbrains.builtInWebServer.BuiltInWebServer"/>
|
||||
<webBrowserUrlProvider implementation="org.jetbrains.builtInWebServer.BuiltInWebBrowserUrlProvider"/>
|
||||
|
||||
<customPortServerManager implementation="org.jetbrains.builtInWebServer.BuiltInServerOptions$MyCustomPortServerManager"/>
|
||||
<xdebugger.configurableProvider implementation="org.jetbrains.builtInWebServer.BuiltInServerOptions$BuiltInServerDebuggerConfigurableProvider"/>
|
||||
|
||||
<exportable serviceInterface="org.jetbrains.builtInWebServer.BuiltInServerOptions"/>
|
||||
<applicationService serviceInterface="org.jetbrains.builtInWebServer.BuiltInServerOptions" serviceImplementation="org.jetbrains.builtInWebServer.BuiltInServerOptions"/>
|
||||
<projectService serviceInterface="org.jetbrains.builtInWebServer.PathToFileManager" serviceImplementation="org.jetbrains.builtInWebServer.PathToFileManager"/>
|
||||
</extensions>
|
||||
<extensions defaultExtensionNs="org.jetbrains">
|
||||
<urlOpener implementation="com.intellij.ide.browsers.impl.DefaultUrlOpener" order="last"/>
|
||||
<webServerFileHandler implementation="org.jetbrains.builtInWebServer.BuiltInWebServer$StaticFileHandler" order="last"/>
|
||||
<webServerProjectRootsProvider implementation="org.jetbrains.builtInWebServer.ProjectRootsProviderImpl"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
|
||||
@@ -506,6 +506,9 @@
|
||||
<action id="EditorPasteFromX11">
|
||||
<mouse-shortcut keystroke="button2"/>
|
||||
</action>
|
||||
<action id="Vcs.RollbackChangedLines">
|
||||
<keyboard-shortcut first-keystroke="control alt Z"/>
|
||||
</action>
|
||||
|
||||
<action id="GotoNextError">
|
||||
<keyboard-shortcut first-keystroke="F2"/>
|
||||
|
||||
@@ -265,7 +265,7 @@
|
||||
<add-to-group group-id="CloseEditorsGroup" anchor="before" relative-to-action="CloseAllUnpinnedEditors"/>
|
||||
</action>
|
||||
|
||||
<action id="RollbackLineStatusChanges" class="com.intellij.openapi.vcs.ex.RollbackLineStatusAction">
|
||||
<action id="Vcs.RollbackChangedLines" class="com.intellij.openapi.vcs.ex.RollbackLineStatusAction" icon="AllIcons.Actions.Reset">
|
||||
</action>
|
||||
|
||||
<action id="WelcomeScreen.GetFromVcs" class="com.intellij.openapi.wm.impl.welcomeScreen.GetFromVcsAction"
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.openapi.roots;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -65,4 +66,12 @@ public abstract class OrderEnumerationHandler {
|
||||
@NotNull Collection<String> urls) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean addCustomModuleRoots(@NotNull OrderRootType type,
|
||||
@NotNull ModuleRootModel rootModel,
|
||||
@NotNull Collection<String> result,
|
||||
boolean includeProduction,
|
||||
boolean includeTests) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+32
@@ -356,6 +356,38 @@ abstract class OrderEnumeratorBase extends OrderEnumerator implements OrderEnume
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean addCustomRootsForModule(OrderRootType type,
|
||||
ModuleRootModel rootModel,
|
||||
Collection<VirtualFile> result,
|
||||
boolean includeProduction,
|
||||
boolean includeTests) {
|
||||
for (OrderEnumerationHandler handler : myCustomHandlers) {
|
||||
final List<String> urls = new ArrayList<String>();
|
||||
final boolean added = handler.addCustomModuleRoots(type, rootModel, urls, includeProduction, includeTests);
|
||||
for (String url : urls) {
|
||||
ContainerUtil.addIfNotNull(VirtualFileManager.getInstance().findFileByUrl(url), result);
|
||||
}
|
||||
|
||||
if (added) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean addCustomRootUrlsForModule(OrderRootType type,
|
||||
ModuleRootModel rootModel,
|
||||
Collection<String> result,
|
||||
boolean includeProduction,
|
||||
boolean includeTests) {
|
||||
for (OrderEnumerationHandler handler : myCustomHandlers) {
|
||||
final List<String> urls = new ArrayList<String>();
|
||||
final boolean added = handler.addCustomModuleRoots(type, rootModel, urls, includeProduction, includeTests);
|
||||
result.addAll(urls);
|
||||
|
||||
if (added) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRuntimeOnly() {
|
||||
return myRuntimeOnly;
|
||||
|
||||
+1
@@ -240,6 +240,7 @@ public class OrderRootsEnumeratorImpl implements OrderRootsEnumerator {
|
||||
}
|
||||
}
|
||||
}
|
||||
myOrderEnumerator.addCustomRootsForModule(type, rootModel, result, includeProduction, includeTests);
|
||||
}
|
||||
|
||||
private void collectModuleRootsUrls(OrderRootType type,
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.reference.SoftReference;
|
||||
import com.intellij.usageView.UsageTreeColors;
|
||||
import com.intellij.usageView.UsageTreeColorsScheme;
|
||||
import com.intellij.usages.impl.SyntaxHighlighterOverEditorHighlighter;
|
||||
import com.intellij.usages.impl.rules.UsageType;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.FactoryMap;
|
||||
@@ -64,9 +65,7 @@ public class ChunkExtractor {
|
||||
|
||||
private final Document myDocument;
|
||||
private long myDocumentStamp;
|
||||
private final SyntaxHighlighter myHighlighter;
|
||||
|
||||
private final Lexer myLexer;
|
||||
private final SyntaxHighlighterOverEditorHighlighter myHighlighter;
|
||||
|
||||
private abstract static class WeakFactory<T> {
|
||||
private WeakReference<T> myRef;
|
||||
@@ -119,11 +118,10 @@ public class ChunkExtractor {
|
||||
myDocument = PsiDocumentManager.getInstance(project).getDocument(file);
|
||||
LOG.assertTrue(myDocument != null);
|
||||
final FileType fileType = file.getFileType();
|
||||
final SyntaxHighlighter highlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, project, file.getVirtualFile());
|
||||
myHighlighter = highlighter == null ? new PlainSyntaxHighlighter() : highlighter;
|
||||
myLexer = myHighlighter.getHighlightingLexer();
|
||||
myLexer.start(myDocument.getCharsSequence());
|
||||
myDocumentStamp = myDocument.getModificationStamp();
|
||||
SyntaxHighlighter highlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(fileType, project, file.getVirtualFile());
|
||||
highlighter = highlighter == null ? new PlainSyntaxHighlighter() : highlighter;
|
||||
myHighlighter = new SyntaxHighlighterOverEditorHighlighter(highlighter, file.getVirtualFile(), project);
|
||||
myDocumentStamp = -1;
|
||||
}
|
||||
|
||||
public static int getStartOffset(final List<RangeMarker> rangeMarkers) {
|
||||
@@ -194,18 +192,21 @@ public class ChunkExtractor {
|
||||
int end,
|
||||
boolean selectUsageWithBold,
|
||||
@NotNull List<TextChunk> result) {
|
||||
final Lexer lexer = myLexer;
|
||||
final SyntaxHighlighter highlighter = myHighlighter;
|
||||
final Lexer lexer = myHighlighter.getHighlightingLexer();
|
||||
final SyntaxHighlighterOverEditorHighlighter highlighter = myHighlighter;
|
||||
|
||||
LOG.assertTrue(start <= end);
|
||||
|
||||
int i = StringUtil.indexOf(chars, '\n', start, end);
|
||||
if (i != -1) end = i;
|
||||
|
||||
if (lexer.getTokenStart() > start || myDocumentStamp != myDocument.getModificationStamp()) {
|
||||
lexer.start(chars);
|
||||
if (myDocumentStamp != myDocument.getModificationStamp()) {
|
||||
highlighter.restart(chars);
|
||||
myDocumentStamp = myDocument.getModificationStamp();
|
||||
} else if(lexer.getTokenStart() > start) {
|
||||
highlighter.resetPosition(0);
|
||||
}
|
||||
|
||||
boolean isBeginning = true;
|
||||
|
||||
for(;lexer.getTokenType() != null; lexer.advance()) {
|
||||
@@ -218,8 +219,10 @@ public class ChunkExtractor {
|
||||
hiEnd = Math.min(hiEnd, end);
|
||||
if (hiStart >= hiEnd) { continue; }
|
||||
|
||||
String text = chars.subSequence(hiStart, hiEnd).toString();
|
||||
if (isBeginning && text.trim().isEmpty()) continue;
|
||||
if (isBeginning) {
|
||||
String text = chars.subSequence(hiStart, hiEnd).toString();
|
||||
if(text.trim().isEmpty()) continue;
|
||||
}
|
||||
isBeginning = false;
|
||||
IElementType tokenType = lexer.getTokenType();
|
||||
TextAttributesKey[] tokenHighlights = highlighter.getTokenHighlights(tokenType);
|
||||
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.usages.impl;
|
||||
|
||||
import com.intellij.lexer.LayeredLexer;
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.editor.ex.util.LayeredHighlighterIterator;
|
||||
import com.intellij.openapi.editor.ex.util.LayeredLexerEditorHighlighter;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory;
|
||||
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import com.intellij.openapi.fileTypes.PlainSyntaxHighlighter;
|
||||
import com.intellij.openapi.fileTypes.PlainTextFileType;
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.impl.search.LexerEditorHighlighterLexer;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Created by Maxim.Mossienko on 7/31/2014.
|
||||
*/
|
||||
public class SyntaxHighlighterOverEditorHighlighter implements SyntaxHighlighter {
|
||||
private final Lexer lexer;
|
||||
private LayeredHighlighterIterator layeredHighlighterIterator = null;
|
||||
private final SyntaxHighlighter highlighter;
|
||||
|
||||
public SyntaxHighlighterOverEditorHighlighter(SyntaxHighlighter _highlighter, VirtualFile file, Project project) {
|
||||
if (file.getFileType() == PlainTextFileType.INSTANCE) { // optimization for large files, PlainTextSyntaxHighlighterFactory is slow
|
||||
highlighter = new PlainSyntaxHighlighter();
|
||||
lexer = highlighter.getHighlightingLexer();
|
||||
} else {
|
||||
highlighter = _highlighter;
|
||||
LayeredLexer.ourDisableLayersFlag.set(Boolean.TRUE);
|
||||
EditorHighlighter editorHighlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(project, file);
|
||||
|
||||
try {
|
||||
if (editorHighlighter instanceof LayeredLexerEditorHighlighter) {
|
||||
lexer = new LexerEditorHighlighterLexer(editorHighlighter, false);
|
||||
}
|
||||
else {
|
||||
lexer = highlighter.getHighlightingLexer();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
LayeredLexer.ourDisableLayersFlag.set(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Lexer getHighlightingLexer() {
|
||||
return lexer;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
|
||||
final SyntaxHighlighter activeSyntaxHighlighter =
|
||||
layeredHighlighterIterator != null ? layeredHighlighterIterator.getActiveSyntaxHighlighter() : highlighter;
|
||||
return activeSyntaxHighlighter.getTokenHighlights(tokenType);
|
||||
}
|
||||
|
||||
public void restart(@NotNull CharSequence text) {
|
||||
lexer.start(text);
|
||||
|
||||
if (lexer instanceof LexerEditorHighlighterLexer) {
|
||||
HighlighterIterator iterator = ((LexerEditorHighlighterLexer)lexer).getHighlighterIterator();
|
||||
if (iterator instanceof LayeredHighlighterIterator) {
|
||||
layeredHighlighterIterator = (LayeredHighlighterIterator)iterator;
|
||||
} else {
|
||||
layeredHighlighterIterator = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetPosition(int startOffset) {
|
||||
if (lexer instanceof LexerEditorHighlighterLexer) {
|
||||
((LexerEditorHighlighterLexer)lexer).resetPosition(startOffset);
|
||||
|
||||
HighlighterIterator iterator = ((LexerEditorHighlighterLexer)lexer).getHighlighterIterator();
|
||||
if (iterator instanceof LayeredHighlighterIterator) {
|
||||
layeredHighlighterIterator = (LayeredHighlighterIterator)iterator;
|
||||
} else {
|
||||
layeredHighlighterIterator = null;
|
||||
}
|
||||
} else {
|
||||
CharSequence text = lexer.getBufferSequence();
|
||||
lexer.start(text, startOffset, text.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="lang-api" />
|
||||
<orderEntry type="module" module-name="core-impl" />
|
||||
<orderEntry type="module" module-name="editor-ui-ex" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -316,6 +316,7 @@ diff.patience.alg=false
|
||||
|
||||
svn.use.terminal=false
|
||||
svn.use.incoming.optimization=false
|
||||
svn.executable.locale=C.UTF-8
|
||||
|
||||
completion.enable.relevant.method.chain.suggestions=false
|
||||
ide.mac.message.sheets.java.emulation=false
|
||||
@@ -398,4 +399,4 @@ fix.jdk7.alt.shortcuts=true
|
||||
fix.jdk7.alt.shortcuts.description=Allow to use alt for shortcuts on MacOSX with jdk7+
|
||||
|
||||
ide.new.markup.markers=true
|
||||
ide.new.markup.markers.description=New error stripe markers
|
||||
ide.new.markup.markers.description=New error stripe markers
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
package com.intellij.openapi.vcs.ex;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.idea.ActionsBundle;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -32,7 +33,9 @@ import java.util.List;
|
||||
|
||||
public class RollbackLineStatusAction extends DumbAwareAction {
|
||||
public RollbackLineStatusAction() {
|
||||
super("Rollback", "Rollback selected changes", AllIcons.Actions.Reset);
|
||||
super(ActionsBundle.actionText("Vcs.RollbackChangedLines"),
|
||||
ActionsBundle.actionDescription("Vcs.RollbackChangedLines"),
|
||||
AllIcons.Actions.Reset);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+197
@@ -0,0 +1,197 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.vcs.history;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogBuilder;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ui.ChangesBrowser;
|
||||
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Konstantin Kolosovsky.
|
||||
*/
|
||||
public abstract class BaseDiffFromHistoryHandler<T extends VcsFileRevision> implements DiffFromHistoryHandler {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance(BaseDiffFromHistoryHandler.class);
|
||||
|
||||
@NotNull protected final Project myProject;
|
||||
|
||||
protected BaseDiffFromHistoryHandler(@NotNull Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showDiffForOne(@NotNull AnActionEvent e,
|
||||
@NotNull FilePath filePath,
|
||||
@NotNull VcsFileRevision previousRevision,
|
||||
@NotNull VcsFileRevision revision) {
|
||||
doShowDiff(filePath, previousRevision, revision, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showDiffForTwo(@NotNull FilePath filePath, @NotNull VcsFileRevision revision1, @NotNull VcsFileRevision revision2) {
|
||||
doShowDiff(filePath, revision1, revision2, true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void doShowDiff(@NotNull FilePath filePath,
|
||||
@NotNull VcsFileRevision revision1,
|
||||
@NotNull VcsFileRevision revision2,
|
||||
boolean autoSort) {
|
||||
if (!filePath.isDirectory()) {
|
||||
VcsHistoryUtil.showDifferencesInBackground(myProject, filePath, revision1, revision2, autoSort);
|
||||
}
|
||||
else if (revision1.equals(VcsFileRevision.NULL)) {
|
||||
T right = (T)revision2;
|
||||
showAffectedChanges(filePath, right);
|
||||
}
|
||||
else if (revision2 instanceof CurrentRevision) {
|
||||
T left = (T)revision1;
|
||||
showChangesBetweenRevisions(filePath, left, null);
|
||||
}
|
||||
else {
|
||||
T left = (T)revision1;
|
||||
T right = (T)revision2;
|
||||
if (autoSort) {
|
||||
Couple<VcsFileRevision> pair = VcsHistoryUtil.sortRevisions(revision1, revision2);
|
||||
left = (T)pair.first;
|
||||
right = (T)pair.second;
|
||||
}
|
||||
showChangesBetweenRevisions(filePath, left, right);
|
||||
}
|
||||
}
|
||||
|
||||
protected void showChangesBetweenRevisions(@NotNull final FilePath path, @NotNull final T rev1, @Nullable final T rev2) {
|
||||
new CollectChangesTask("Comparing revisions...") {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Change> getChanges() throws VcsException {
|
||||
return getChangesBetweenRevisions(path, rev1, rev2);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDialogTitle() {
|
||||
return getChangesBetweenRevisionsDialogTitle(path, rev1, rev2);
|
||||
}
|
||||
}.queue();
|
||||
}
|
||||
|
||||
protected void showAffectedChanges(@NotNull final FilePath path, @NotNull final T rev) {
|
||||
new CollectChangesTask("Collecting affected changes...") {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Change> getChanges() throws VcsException {
|
||||
return getAffectedChanges(path, rev);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDialogTitle() {
|
||||
return getAffectedChangesDialogTitle(path, rev);
|
||||
}
|
||||
}.queue();
|
||||
}
|
||||
|
||||
// rev2 == null -> compare rev1 with local
|
||||
// rev2 != null -> compare rev1 with rev2
|
||||
@NotNull
|
||||
protected abstract List<Change> getChangesBetweenRevisions(@NotNull final FilePath path, @NotNull final T rev1, @Nullable final T rev2)
|
||||
throws VcsException;
|
||||
|
||||
@NotNull
|
||||
protected abstract List<Change> getAffectedChanges(@NotNull final FilePath path, @NotNull final T rev) throws VcsException;
|
||||
|
||||
@NotNull
|
||||
protected abstract String getPresentableName(@NotNull T revision);
|
||||
|
||||
protected void showChangesDialog(@NotNull String title, @NotNull List<Change> changes) {
|
||||
DialogBuilder dialogBuilder = new DialogBuilder(myProject);
|
||||
|
||||
dialogBuilder.setTitle(title);
|
||||
dialogBuilder.setActionDescriptors(new DialogBuilder.ActionDescriptor[]{new DialogBuilder.CloseDialogAction()});
|
||||
final ChangesBrowser changesBrowser =
|
||||
new ChangesBrowser(myProject, null, changes, null, false, true, null, ChangesBrowser.MyUseCase.COMMITTED_CHANGES, null);
|
||||
changesBrowser.setChangesToDisplay(changes);
|
||||
dialogBuilder.setCenterPanel(changesBrowser);
|
||||
dialogBuilder.showNotModal();
|
||||
}
|
||||
|
||||
protected void showError(@NotNull VcsException e, @NotNull String logMessage) {
|
||||
LOG.info(logMessage, e);
|
||||
VcsBalloonProblemNotifier.showOverVersionControlView(myProject, e.getMessage(), MessageType.ERROR);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected String getChangesBetweenRevisionsDialogTitle(@NotNull final FilePath path, @NotNull final T rev1, @Nullable final T rev2) {
|
||||
String rev1Title = getPresentableName(rev1);
|
||||
|
||||
return rev2 != null
|
||||
? String.format("Difference between %s and %s in %s", rev1Title, getPresentableName(rev2), path.getName())
|
||||
: String.format("Difference between %s and local version in %s", rev1Title, path.getName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected String getAffectedChangesDialogTitle(@NotNull final FilePath path, @NotNull final T rev) {
|
||||
return String.format("Initial commit %s in %s", getPresentableName(rev), path.getName());
|
||||
}
|
||||
|
||||
protected abstract class CollectChangesTask extends Task.Backgroundable {
|
||||
|
||||
private List<Change> myChanges;
|
||||
|
||||
public CollectChangesTask(@NotNull String title) {
|
||||
super(BaseDiffFromHistoryHandler.this.myProject, title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
try {
|
||||
myChanges = getChanges();
|
||||
}
|
||||
catch (VcsException e) {
|
||||
showError(e, "Error during task: " + getDialogTitle());
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract List<Change> getChanges() throws VcsException;
|
||||
|
||||
@NotNull
|
||||
public abstract String getDialogTitle();
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
showChangesDialog(getDialogTitle(), ContainerUtil.notNullize(myChanges));
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-1
@@ -58,6 +58,15 @@ class MergedCompositeConfigurable implements SearchableConfigurable {
|
||||
return children.length == 1 ? children[0].getHelpTopic() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* false by default.
|
||||
*
|
||||
* If Ruby general settings will be without titled border in RubyMine, user could think that all other debugger categories also about Ruby.
|
||||
*/
|
||||
protected boolean isUseTargetedProductPolicyIfSeveralChildren() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JComponent createComponent() {
|
||||
@@ -82,7 +91,7 @@ class MergedCompositeConfigurable implements SearchableConfigurable {
|
||||
}
|
||||
else {
|
||||
boolean addBorder = true;
|
||||
if (isFirstNamed) {
|
||||
if (isUseTargetedProductPolicyIfSeveralChildren() && isFirstNamed) {
|
||||
isFirstNamed = false;
|
||||
if (isTargetedToProduct(configurable)) {
|
||||
addBorder = false;
|
||||
|
||||
@@ -35,10 +35,7 @@ import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
|
||||
import com.intellij.xdebugger.frame.XDebuggerTreeNodeHyperlink;
|
||||
import com.intellij.xdebugger.impl.actions.XDebuggerActions;
|
||||
import com.intellij.xdebugger.impl.frame.XValueMarkers;
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.MessageTreeNode;
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.RestorableStateNode;
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode;
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueContainerNode;
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.*;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -254,6 +251,12 @@ public class XDebuggerTree extends DnDAwareTree implements DataProvider, Disposa
|
||||
if (XDEBUGGER_TREE_KEY.is(dataId)) {
|
||||
return this;
|
||||
}
|
||||
if (PlatformDataKeys.PREDEFINED_TEXT.is(dataId)) {
|
||||
XValueNodeImpl[] selectedNodes = getSelectedNodes(XValueNodeImpl.class, null);
|
||||
if (selectedNodes.length == 1 && selectedNodes[0].getFullValueEvaluator() == null) {
|
||||
return selectedNodes[0].getRawValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -1841,8 +1841,9 @@ double.literal.may.be.float.literal.problem.descriptor=<code>#ref</code> could b
|
||||
double.literal.may.be.float.literal.quickfix=Replace with ''{0}''
|
||||
multiple.declaration.option=Ignore 'for' loop declarations
|
||||
simplifiable.annotation.display.name=Simplifiable annotation
|
||||
simplifiable.annotation.problem.descriptor=Annotation <code>#ref</code> can be simplified #loc
|
||||
simplifiable.annotation.quickfix=Replace with ''{0}''
|
||||
simplifiable.annotation.problem.descriptor=Unnecessary <code>#ref</code> in annotation #loc
|
||||
simplifiable.annotation.whitespace.problem.descriptor=Unnecessary whitespace in annotation #loc
|
||||
simplifiable.annotation.quickfix=Simplify annotation
|
||||
overloaded.methods.with.same.number.parameters.option=<html>Ignore overloaded methods whose parameter types are definitely incompatible</html>
|
||||
string.concatenation.in.format.call.display.name=String concatenation as argument to 'format()' call
|
||||
string.concatenation.in.format.call.problem.descriptor=<code>#ref()</code> call has a String concatenation argument #loc
|
||||
|
||||
+9
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2014 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -191,8 +191,13 @@ public abstract class BaseInspectionVisitor extends JavaElementVisitor {
|
||||
holder.registerProblem(location, description, highlightType, fixes);
|
||||
}
|
||||
|
||||
protected final void registerErrorAtOffset(@NotNull PsiElement location,
|
||||
int offset, int length, Object... infos) {
|
||||
protected final void registerErrorAtOffset(@NotNull PsiElement location, int offset, int length, Object... infos) {
|
||||
registerErrorAtOffset(location, offset, length, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, infos);
|
||||
}
|
||||
|
||||
protected final void registerErrorAtOffset(@NotNull PsiElement location, int offset, int length,
|
||||
ProblemHighlightType highlightType,
|
||||
Object... infos) {
|
||||
if (location.getTextLength() == 0 || length == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -202,7 +207,7 @@ public abstract class BaseInspectionVisitor extends JavaElementVisitor {
|
||||
}
|
||||
final String description = inspection.buildErrorString(infos);
|
||||
final TextRange range = new TextRange(offset, offset + length);
|
||||
holder.registerProblem(location, range, description, fixes);
|
||||
holder.registerProblem(location, description, highlightType, range, fixes);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+46
-45
@@ -16,9 +16,10 @@
|
||||
package com.siyeh.ig.style;
|
||||
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.codeInspection.ProblemHighlightType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
@@ -46,30 +47,30 @@ public class SimplifiableAnnotationInspection extends BaseInspection {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String buildErrorString(Object... infos) {
|
||||
return InspectionGadgetsBundle.message("simplifiable.annotation.problem.descriptor");
|
||||
if (((Boolean)infos[0]).booleanValue()) {
|
||||
return InspectionGadgetsBundle.message("simplifiable.annotation.whitespace.problem.descriptor");
|
||||
}
|
||||
else {
|
||||
return InspectionGadgetsBundle.message("simplifiable.annotation.problem.descriptor");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InspectionGadgetsFix buildFix(Object... infos) {
|
||||
final PsiAnnotation annotation = (PsiAnnotation)infos[0];
|
||||
return new SimplifiableAnnotationFix(annotation);
|
||||
return new SimplifiableAnnotationFix();
|
||||
}
|
||||
|
||||
private static class SimplifiableAnnotationFix extends InspectionGadgetsFix {
|
||||
|
||||
private final String replacement;
|
||||
|
||||
public SimplifiableAnnotationFix(PsiAnnotation annotation) {
|
||||
this.replacement = buildAnnotationText(annotation, new StringBuilder()).toString();
|
||||
}
|
||||
public SimplifiableAnnotationFix() {}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return InspectionGadgetsBundle.message("simplifiable.annotation.quickfix",
|
||||
StringUtil.shortenTextWithEllipsis(replacement, 50, 0, true));
|
||||
return InspectionGadgetsBundle.message("simplifiable.annotation.quickfix");
|
||||
}
|
||||
@Override
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return getName();
|
||||
@@ -78,25 +79,25 @@ public class SimplifiableAnnotationInspection extends BaseInspection {
|
||||
@Override
|
||||
protected void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
|
||||
final PsiElement element = descriptor.getPsiElement();
|
||||
if (!(element instanceof PsiAnnotation)) {
|
||||
final PsiAnnotation annotation = PsiTreeUtil.getParentOfType(element, PsiAnnotation.class);
|
||||
if (annotation == null) {
|
||||
return;
|
||||
}
|
||||
final PsiAnnotation annotation = (PsiAnnotation)element;
|
||||
final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
|
||||
final String annotationText = buildAnnotationText(annotation, new StringBuilder()).toString();
|
||||
final String annotationText = buildAnnotationText(annotation);
|
||||
final PsiAnnotation newAnnotation = factory.createAnnotationFromText(annotationText, element);
|
||||
annotation.replace(newAnnotation);
|
||||
}
|
||||
|
||||
private static StringBuilder buildAnnotationText(PsiAnnotation annotation, StringBuilder out) {
|
||||
out.append('@');
|
||||
private static String buildAnnotationText(PsiAnnotation annotation) {
|
||||
final StringBuilder out = new StringBuilder("@");
|
||||
final PsiJavaCodeReferenceElement nameReferenceElement = annotation.getNameReferenceElement();
|
||||
assert nameReferenceElement != null;
|
||||
out.append(nameReferenceElement.getText());
|
||||
final PsiAnnotationParameterList parameterList = annotation.getParameterList();
|
||||
final PsiNameValuePair[] attributes = parameterList.getAttributes();
|
||||
if (attributes.length == 0) {
|
||||
return out;
|
||||
return out.toString();
|
||||
}
|
||||
out.append('(');
|
||||
if (attributes.length == 1) {
|
||||
@@ -118,7 +119,7 @@ public class SimplifiableAnnotationInspection extends BaseInspection {
|
||||
}
|
||||
}
|
||||
out.append(')');
|
||||
return out;
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
private static StringBuilder buildAttributeValueText(PsiAnnotationMemberValue value, StringBuilder out) {
|
||||
@@ -130,7 +131,7 @@ public class SimplifiableAnnotationInspection extends BaseInspection {
|
||||
}
|
||||
}
|
||||
else if (value instanceof PsiAnnotation) {
|
||||
return buildAnnotationText((PsiAnnotation)value, out);
|
||||
return out.append(buildAnnotationText((PsiAnnotation)value));
|
||||
}
|
||||
return out.append(value.getText());
|
||||
}
|
||||
@@ -153,36 +154,36 @@ public class SimplifiableAnnotationInspection extends BaseInspection {
|
||||
}
|
||||
final PsiNameValuePair[] attributes = parameterList.getAttributes();
|
||||
final PsiElement[] annotationChildren = annotation.getChildren();
|
||||
if (annotationChildren.length >= 2 && annotationChildren[1] instanceof PsiWhiteSpace) {
|
||||
if (!containsError(annotation)) {
|
||||
registerError(annotation, annotation);
|
||||
}
|
||||
if (annotationChildren.length >= 2 && annotationChildren[1] instanceof PsiWhiteSpace && !containsError(annotation)) {
|
||||
registerError(annotationChildren[1], Boolean.TRUE);
|
||||
}
|
||||
else if (attributes.length == 0) {
|
||||
final PsiElement[] children = parameterList.getChildren();
|
||||
if (children.length <= 0) {
|
||||
return;
|
||||
}
|
||||
if (!containsError(annotation)) {
|
||||
registerError(annotation, annotation);
|
||||
if (attributes.length == 0) {
|
||||
if (parameterList.getChildren().length > 0 && !containsError(annotation)) {
|
||||
registerError(parameterList, ProblemHighlightType.LIKE_UNUSED_SYMBOL, Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
else if (attributes.length == 1) {
|
||||
final PsiNameValuePair attribute = attributes[0];
|
||||
@NonNls final String name = attribute.getName();
|
||||
final PsiIdentifier identifier = attribute.getNameIdentifier();
|
||||
final PsiAnnotationMemberValue attributeValue = attribute.getValue();
|
||||
if (!PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME.equals(name)) {
|
||||
if (!(attributeValue instanceof PsiArrayInitializerMemberValue)) {
|
||||
return;
|
||||
}
|
||||
final PsiArrayInitializerMemberValue arrayValue = (PsiArrayInitializerMemberValue)attributeValue;
|
||||
final PsiAnnotationMemberValue[] initializers = arrayValue.getInitializers();
|
||||
if (initializers.length != 1) {
|
||||
return;
|
||||
if (identifier != null && attributeValue != null) {
|
||||
@NonNls final String name = attribute.getName();
|
||||
if (PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME.equals(name) && !containsError(annotation)) {
|
||||
registerErrorAtOffset(attribute, 0, attributeValue.getStartOffsetInParent(), ProblemHighlightType.LIKE_UNUSED_SYMBOL,
|
||||
Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
if (!(attributeValue instanceof PsiArrayInitializerMemberValue)) {
|
||||
return;
|
||||
}
|
||||
final PsiArrayInitializerMemberValue arrayValue = (PsiArrayInitializerMemberValue)attributeValue;
|
||||
final PsiAnnotationMemberValue[] initializers = arrayValue.getInitializers();
|
||||
if (initializers.length != 1) {
|
||||
return;
|
||||
}
|
||||
if (!containsError(annotation)) {
|
||||
registerError(annotation, annotation);
|
||||
registerError(arrayValue.getFirstChild(), ProblemHighlightType.LIKE_UNUSED_SYMBOL, Boolean.FALSE);
|
||||
registerError(arrayValue.getLastChild(), ProblemHighlightType.LIKE_UNUSED_SYMBOL, Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
else if (attributes.length > 1) {
|
||||
@@ -191,15 +192,15 @@ public class SimplifiableAnnotationInspection extends BaseInspection {
|
||||
if (!(value instanceof PsiArrayInitializerMemberValue)) {
|
||||
continue;
|
||||
}
|
||||
final PsiArrayInitializerMemberValue arrayInitializerMemberValue = (PsiArrayInitializerMemberValue)value;
|
||||
final PsiAnnotationMemberValue[] initializers = arrayInitializerMemberValue.getInitializers();
|
||||
final PsiArrayInitializerMemberValue arrayValue = (PsiArrayInitializerMemberValue)value;
|
||||
final PsiAnnotationMemberValue[] initializers = arrayValue.getInitializers();
|
||||
if (initializers.length != 1) {
|
||||
continue;
|
||||
}
|
||||
if (!containsError(annotation)) {
|
||||
registerError(annotation, annotation);
|
||||
registerError(arrayValue.getFirstChild(), ProblemHighlightType.LIKE_UNUSED_SYMBOL, Boolean.FALSE);
|
||||
registerError(arrayValue.getLastChild(), ProblemHighlightType.LIKE_UNUSED_SYMBOL, Boolean.FALSE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2014 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,7 @@ package com.siyeh.ig.style;
|
||||
|
||||
import com.intellij.codeInspection.CleanupLocalInspectionTool;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.codeInspection.ProblemHighlightType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
@@ -112,7 +113,7 @@ public class UnnecessaryEnumModifierInspection extends BaseInspection implements
|
||||
for (final PsiElement child : children) {
|
||||
final String text = child.getText();
|
||||
if (PsiModifier.STATIC.equals(text)) {
|
||||
registerError(child, child, aClass);
|
||||
registerError(child, ProblemHighlightType.LIKE_UNUSED_SYMBOL, child, aClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,7 +132,7 @@ public class UnnecessaryEnumModifierInspection extends BaseInspection implements
|
||||
for (final PsiElement child : children) {
|
||||
final String text = child.getText();
|
||||
if (PsiModifier.PRIVATE.equals(text)) {
|
||||
registerError(child, child, method);
|
||||
registerError(child, ProblemHighlightType.LIKE_UNUSED_SYMBOL, child, method);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2014 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,7 @@ package com.siyeh.ig.style;
|
||||
|
||||
import com.intellij.codeInspection.CleanupLocalInspectionTool;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.codeInspection.ProblemHighlightType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -214,7 +215,7 @@ public class UnnecessaryInterfaceModifierInspection extends BaseInspection imple
|
||||
}
|
||||
for (PsiElement child : children) {
|
||||
if (modifiers.contains(child.getText())) {
|
||||
registerError(child, redundantModifiers.toString(), list);
|
||||
registerError(child, ProblemHighlightType.LIKE_UNUSED_SYMBOL, redundantModifiers.toString(), list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2009 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2014 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,7 @@ package com.siyeh.ig.style;
|
||||
|
||||
import com.intellij.codeInspection.CleanupLocalInspectionTool;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.codeInspection.ProblemHighlightType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
@@ -111,7 +112,7 @@ public class UnnecessarySemicolonInspection extends BaseInspection implements Cl
|
||||
private void findTopLevelSemicolons(PsiElement element) {
|
||||
for (PsiElement sibling = element.getFirstChild(); sibling != null; sibling = skipForwardWhiteSpacesAndComments(sibling)) {
|
||||
if (PsiUtil.isJavaToken(sibling, JavaTokenType.SEMICOLON)) {
|
||||
registerError(sibling);
|
||||
registerError(sibling, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,7 +150,7 @@ public class UnnecessarySemicolonInspection extends BaseInspection implements Cl
|
||||
if (next == null || !next.equals(aClass.getRBrace())) {
|
||||
return;
|
||||
}
|
||||
registerError(element);
|
||||
registerError(element, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
|
||||
}
|
||||
|
||||
private void findUnnecessarySemicolonsAfterEnumConstants(
|
||||
@@ -171,11 +172,11 @@ public class UnnecessarySemicolonInspection extends BaseInspection implements Cl
|
||||
if (!JavaTokenType.COMMA.equals(prevTokenType)
|
||||
&& !JavaTokenType.LBRACE.equals(
|
||||
prevTokenType)) {
|
||||
registerError(child);
|
||||
registerError(child, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
registerError(child);
|
||||
registerError(child, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,7 +208,7 @@ public class UnnecessarySemicolonInspection extends BaseInspection implements Cl
|
||||
if (semicolon == null) {
|
||||
return;
|
||||
}
|
||||
registerError(semicolon);
|
||||
registerError(semicolon, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +219,7 @@ public class UnnecessarySemicolonInspection extends BaseInspection implements Cl
|
||||
if (last instanceof PsiJavaToken && ((PsiJavaToken)last).getTokenType() == JavaTokenType.RPARENTH) {
|
||||
final PsiElement prev = skipBackwardWhiteSpacesAndComments(last);
|
||||
if (prev instanceof PsiJavaToken && ((PsiJavaToken)prev).getTokenType() == JavaTokenType.SEMICOLON) {
|
||||
registerError(prev);
|
||||
registerError(prev, ProblemHighlightType.LIKE_UNUSED_SYMBOL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -2,8 +2,8 @@ package com.siyeh.igtest.style.simplifiable_annotation;
|
||||
|
||||
public class SimplifiableAnnotation {
|
||||
|
||||
<warning descr="Annotation '@ SuppressWarnings(value = \\"blabla\\")' can be simplified">@ SuppressWarnings(value = "blabla")</warning>
|
||||
<warning descr="Annotation '@ Deprecated()' can be simplified">@ Deprecated()</warning>
|
||||
@<warning descr="Unnecessary whitespace in annotation"> </warning>SuppressWarnings(<warning descr="Unnecessary 'value =' in annotation">value = </warning>"blabla")
|
||||
@<warning descr="Unnecessary whitespace in annotation"> </warning>Deprecated<warning descr="Unnecessary '()' in annotation">()</warning>
|
||||
Object foo() {
|
||||
return null;
|
||||
}
|
||||
@@ -14,8 +14,8 @@ public class SimplifiableAnnotation {
|
||||
@interface ArrayAnnotation {
|
||||
String[] array();
|
||||
}
|
||||
<warning descr="Annotation '@ValueAnnotation({\\"the value\\"})' can be simplified">@ValueAnnotation({"the value"})</warning>
|
||||
<warning descr="Annotation '@ArrayAnnotation(array = {\\"first\\"})' can be simplified">@ArrayAnnotation(array = {"first"})</warning>
|
||||
@ValueAnnotation(<warning descr="Unnecessary '{' in annotation">{</warning>"the value"<warning descr="Unnecessary '}' in annotation">}</warning>)
|
||||
@ArrayAnnotation(array = <warning descr="Unnecessary '{' in annotation">{</warning>"first"<warning descr="Unnecessary '}' in annotation">}</warning>)
|
||||
class MyClass {
|
||||
|
||||
@ <error descr="'value' missing though required">ValueAnnotation</error>
|
||||
@@ -23,7 +23,7 @@ class MyClass {
|
||||
return -1;
|
||||
}
|
||||
|
||||
<warning descr="Annotation '@Two(i={1}, j = 2)' can be simplified">@Two(i={1}, j = 2)</warning>
|
||||
@Two(i=<warning descr="Unnecessary '{' in annotation">{</warning>1<warning descr="Unnecessary '}' in annotation">}</warning>, j = 2)
|
||||
String s;
|
||||
}
|
||||
@interface Two {
|
||||
|
||||
@@ -92,12 +92,13 @@
|
||||
<separator/>
|
||||
</group>
|
||||
|
||||
<action id="Git.CherryPick" class="git4idea.cherrypick.GitCherryPickAction" text="Cherry-Pick" icon="Git4ideaIcons.CherryPick"/>
|
||||
<action id="Git.CherryPick" class="git4idea.cherrypick.GitCherryPickAction" icon="Git4ideaIcons.CherryPick"/>
|
||||
<action class="git4idea.actions.GitCheckoutRevisionAction" id="Git.CheckoutRevision" text="Checkout Revision"/>
|
||||
<action class="git4idea.actions.GitCreateNewBranchAction" id="Git.CreateNewBranch" text="New Branch"
|
||||
<action class="git4idea.actions.GitCreateNewBranchAction" id="Git.CreateNewBranch" text="New Branch..."
|
||||
description="Create new branch starting from the selected commit"/>
|
||||
<action class="git4idea.actions.GitCreateTagAction" id="Git.CreateNewTag" text="New Tag"
|
||||
<action class="git4idea.actions.GitCreateTagAction" id="Git.CreateNewTag" text="New Tag..."
|
||||
description="Create new tag pointing to this commit"/>
|
||||
<action id="Git.Reset.In.Log" class="git4idea.reset.GitResetAction" text="Reset Current Branch to Here..." />
|
||||
|
||||
<group id="Git.Log.ContextMenu">
|
||||
<separator/>
|
||||
@@ -105,6 +106,8 @@
|
||||
<reference id="Git.CheckoutRevision"/>
|
||||
<reference id="Git.CreateNewBranch" />
|
||||
<reference id="Git.CreateNewTag" />
|
||||
<separator/>
|
||||
<reference id="Git.Reset.In.Log" />
|
||||
<add-to-group group-id="Vcs.Log.ContextMenu" />
|
||||
</group>
|
||||
|
||||
|
||||
@@ -1025,4 +1025,14 @@ public class GitUtil {
|
||||
ApplicationManager.getApplication().getMessageBus().syncPublisher(BatchFileChangeListener.TOPIC).batchChangeCompleted(project);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String cleanupErrorPrefixes(@NotNull String msg) {
|
||||
final String[] PREFIXES = { "fatal:", "error:" };
|
||||
for (String prefix : PREFIXES) {
|
||||
if (msg.startsWith(prefix)) {
|
||||
return msg.substring(prefix.length()).trim();
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,16 +15,19 @@
|
||||
*/
|
||||
package git4idea.actions;
|
||||
|
||||
import com.intellij.dvcs.ui.VcsLogSingleCommitAction;
|
||||
import com.intellij.dvcs.ui.VcsLogAction;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.vcs.log.VcsFullCommitDetails;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.repo.GitRepositoryManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class GitLogSingleCommitAction extends VcsLogSingleCommitAction<GitRepository> {
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class GitLogSingleCommitAction extends VcsLogAction<GitRepository> {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@@ -32,4 +35,21 @@ public abstract class GitLogSingleCommitAction extends VcsLogSingleCommitAction<
|
||||
return ServiceManager.getService(project, GitRepositoryManager.class).getRepositoryForRoot(root);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Mode getMode() {
|
||||
return Mode.SINGLE_COMMIT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(@NotNull Project project, @NotNull Map<GitRepository, VcsFullCommitDetails> commits) {
|
||||
assert commits.size() == 1;
|
||||
Map.Entry<GitRepository, VcsFullCommitDetails> entry = commits.entrySet().iterator().next();
|
||||
GitRepository repository = entry.getKey();
|
||||
VcsFullCommitDetails commit = entry.getValue();
|
||||
actionPerformed(repository, commit);
|
||||
}
|
||||
|
||||
protected abstract void actionPerformed(@NotNull GitRepository repository, @NotNull VcsFullCommitDetails commit);
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import git4idea.GitCommit;
|
||||
import git4idea.repo.GitRepository;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -68,14 +69,15 @@ public interface GitBranchUiHandler {
|
||||
* Shows the dialog proposing to execute the operation (checkout or merge) smartly, i.e. stash-execute-unstash.
|
||||
*
|
||||
* @param project
|
||||
* @param changes local changes that would be overwritten by checkout or merge.
|
||||
* @param paths paths reported by Git (in most cases this is covered by {@code changes}.
|
||||
* @param operation operation name: checkout or merge
|
||||
* @param isForcePossible can the operation be executed force (force checkout is possible, force merge - not).
|
||||
* @param changes local changes that would be overwritten by checkout or merge.
|
||||
* @param paths paths reported by Git (in most cases this is covered by {@code changes}.
|
||||
* @param operation operation name: checkout or merge
|
||||
* @param forceButtonTitle if the operation can be executed force (force checkout is possible),
|
||||
* specify the title of the force button; otherwise (force merge is not possible) pass null.
|
||||
* @return the code of the decision.
|
||||
*/
|
||||
int showSmartOperationDialog(@NotNull Project project, @NotNull List<Change> changes, @NotNull Collection<String> paths,
|
||||
@NotNull String operation, boolean isForcePossible);
|
||||
@NotNull String operation, @Nullable String forceButtonTitle);
|
||||
|
||||
boolean showBranchIsNotFullyMergedDialog(@NotNull Project project, @NotNull Map<GitRepository, List<GitCommit>> history,
|
||||
@NotNull String unmergedBranch, @NotNull List<String> mergedToBranches,
|
||||
|
||||
@@ -172,7 +172,7 @@ public class GitBranchUiHandlerImpl implements GitBranchUiHandler {
|
||||
|
||||
@Override
|
||||
public int showSmartOperationDialog(@NotNull Project project, @NotNull List<Change> changes, @NotNull Collection<String> paths,
|
||||
@NotNull String operation, boolean isForcePossible) {
|
||||
@NotNull String operation, @Nullable String forceButtonTitle) {
|
||||
JComponent fileBrowser;
|
||||
if (!changes.isEmpty()) {
|
||||
fileBrowser = new ChangesBrowserWithRollback(project, changes);
|
||||
@@ -180,7 +180,7 @@ public class GitBranchUiHandlerImpl implements GitBranchUiHandler {
|
||||
else {
|
||||
fileBrowser = new GitSimplePathsBrowser(project, paths);
|
||||
}
|
||||
return GitSmartOperationDialog.showAndGetAnswer(myProject, fileBrowser, operation, isForcePossible);
|
||||
return GitSmartOperationDialog.showAndGetAnswer(myProject, fileBrowser, operation, forceButtonTitle);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -121,7 +121,8 @@ class GitCheckoutOperation extends GitBranchOperation {
|
||||
List<Change> affectedChanges = conflictingRepositoriesAndAffectedChanges.getSecond();
|
||||
|
||||
Collection<String> absolutePaths = GitUtil.toAbsolute(repository.getRoot(), localChangesOverwrittenByCheckout.getRelativeFilePaths());
|
||||
int smartCheckoutDecision = myUiHandler.showSmartOperationDialog(myProject, affectedChanges, absolutePaths, "checkout", true);
|
||||
int smartCheckoutDecision = myUiHandler.showSmartOperationDialog(myProject, affectedChanges, absolutePaths, "checkout",
|
||||
"&Force Checkout");
|
||||
if (smartCheckoutDecision == GitSmartOperationDialog.SMART_EXIT_CODE) {
|
||||
boolean smartCheckedOutSuccessfully = smartCheckout(allConflictingRepositories, myStartPointReference, myNewBranch, getIndicator());
|
||||
if (smartCheckedOutSuccessfully) {
|
||||
|
||||
@@ -34,6 +34,7 @@ import git4idea.commands.*;
|
||||
import git4idea.merge.GitMergeCommittingConflictResolver;
|
||||
import git4idea.merge.GitMerger;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.reset.GitResetMode;
|
||||
import git4idea.util.GitPreservingProcess;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -195,7 +196,7 @@ class GitMergeOperation extends GitBranchOperation {
|
||||
List<Change> affectedChanges = conflictingRepositoriesAndAffectedChanges.getSecond();
|
||||
|
||||
Collection<String> absolutePaths = GitUtil.toAbsolute(repository.getRoot(), localChangesOverwrittenByMerge.getRelativeFilePaths());
|
||||
int smartCheckoutDecision = myUiHandler.showSmartOperationDialog(myProject, affectedChanges, absolutePaths, "merge", false);
|
||||
int smartCheckoutDecision = myUiHandler.showSmartOperationDialog(myProject, affectedChanges, absolutePaths, "merge", null);
|
||||
if (smartCheckoutDecision == GitSmartOperationDialog.SMART_EXIT_CODE) {
|
||||
return doSmartMerge(allConflictingRepositories);
|
||||
}
|
||||
@@ -323,7 +324,7 @@ class GitMergeOperation extends GitBranchOperation {
|
||||
|
||||
@NotNull
|
||||
private GitCommandResult rollback(@NotNull GitRepository repository) {
|
||||
return myGit.resetHard(repository, myCurrentRevisionsBeforeMerge.get(repository));
|
||||
return myGit.reset(repository, GitResetMode.HARD, myCurrentRevisionsBeforeMerge.get(repository));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import git4idea.GitPlatformFacade;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
@@ -44,18 +45,18 @@ public class GitSmartOperationDialog extends DialogWrapper {
|
||||
|
||||
@NotNull private final JComponent myFileBrowser;
|
||||
@NotNull private final String myOperationTitle;
|
||||
private final boolean myShowForceButton;
|
||||
@Nullable private final String myForceButton;
|
||||
|
||||
/**
|
||||
* Shows the dialog with the list of local changes preventing merge/checkout and returns the dialog exit code.
|
||||
*/
|
||||
static int showAndGetAnswer(@NotNull final Project project, @NotNull final JComponent fileBrowser,
|
||||
@NotNull final String operationTitle, final boolean showForceButton) {
|
||||
@NotNull final String operationTitle, @Nullable final String forceButtonTitle) {
|
||||
final AtomicInteger exitCode = new AtomicInteger();
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GitSmartOperationDialog dialog = new GitSmartOperationDialog(project, fileBrowser, operationTitle, showForceButton);
|
||||
GitSmartOperationDialog dialog = new GitSmartOperationDialog(project, fileBrowser, operationTitle, forceButtonTitle);
|
||||
ServiceManager.getService(project, GitPlatformFacade.class).showDialog(dialog);
|
||||
exitCode.set(dialog.getExitCode());
|
||||
}
|
||||
@@ -64,11 +65,11 @@ public class GitSmartOperationDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
private GitSmartOperationDialog(@NotNull Project project, @NotNull JComponent fileBrowser, @NotNull String operationTitle,
|
||||
boolean showForceButton) {
|
||||
@Nullable String forceButton) {
|
||||
super(project);
|
||||
myFileBrowser = fileBrowser;
|
||||
myOperationTitle = operationTitle;
|
||||
myShowForceButton = showForceButton;
|
||||
myForceButton = forceButton;
|
||||
String capitalizedOperation = capitalize(myOperationTitle);
|
||||
setTitle("Git " + capitalizedOperation + " Problem");
|
||||
|
||||
@@ -82,8 +83,8 @@ public class GitSmartOperationDialog extends DialogWrapper {
|
||||
@NotNull
|
||||
@Override
|
||||
protected Action[] createLeftSideActions() {
|
||||
if (myShowForceButton) {
|
||||
return new Action[] {new ForceCheckoutAction(myOperationTitle) };
|
||||
if (myForceButton != null) {
|
||||
return new Action[]{new ForceCheckoutAction(myForceButton, myOperationTitle)};
|
||||
}
|
||||
return new Action[0];
|
||||
}
|
||||
@@ -110,8 +111,8 @@ public class GitSmartOperationDialog extends DialogWrapper {
|
||||
|
||||
private class ForceCheckoutAction extends AbstractAction {
|
||||
|
||||
ForceCheckoutAction(@NotNull String operationTitle) {
|
||||
super("&Force " + capitalize(operationTitle));
|
||||
ForceCheckoutAction(@NotNull String buttonTitle, @NotNull String operationTitle) {
|
||||
super(buttonTitle);
|
||||
putValue(Action.SHORT_DESCRIPTION, capitalize(operationTitle) + " and overwrite local changes");
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user