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:
-13
@@ -90,19 +90,6 @@ public class JavaMatchingVisitor extends JavaElementVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitDocTagValue(final PsiDocTagValue value) {
|
||||
final PsiDocTagValue value2 = (PsiDocTagValue)myMatchingVisitor.getElement();
|
||||
final boolean isTypedVar = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(value);
|
||||
|
||||
if (isTypedVar) {
|
||||
myMatchingVisitor.setResult(myMatchingVisitor.handleTypedElement(value, value2));
|
||||
}
|
||||
else {
|
||||
myMatchingVisitor.setResult(value.textMatches(value2));
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isNotInstanceModifier(final PsiModifierList list2) {
|
||||
return list2.hasModifierProperty(PsiModifier.STATIC) ||
|
||||
list2.hasModifierProperty(PsiModifier.ABSTRACT);
|
||||
|
||||
+5
-5
@@ -1,20 +1,17 @@
|
||||
package com.intellij.structuralsearch.impl.matcher.compiler;
|
||||
|
||||
import com.intellij.dupLocator.iterators.NodeIterator;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.javadoc.PsiDocTag;
|
||||
import com.intellij.psi.search.*;
|
||||
import com.intellij.psi.search.searches.ClassInheritorsSearch;
|
||||
import com.intellij.structuralsearch.MatchOptions;
|
||||
import com.intellij.structuralsearch.MatchVariableConstraint;
|
||||
import com.intellij.structuralsearch.SSRBundle;
|
||||
import com.intellij.structuralsearch.UnsupportedPatternException;
|
||||
import com.intellij.structuralsearch.*;
|
||||
import com.intellij.structuralsearch.impl.matcher.CompiledPattern;
|
||||
import com.intellij.structuralsearch.impl.matcher.JavaCompiledPattern;
|
||||
import com.intellij.structuralsearch.impl.matcher.filters.*;
|
||||
import com.intellij.structuralsearch.impl.matcher.handlers.*;
|
||||
import com.intellij.structuralsearch.impl.matcher.iterators.DocValuesIterator;
|
||||
import com.intellij.dupLocator.iterators.NodeIterator;
|
||||
import com.intellij.structuralsearch.impl.matcher.predicates.RegExpPredicate;
|
||||
import com.intellij.structuralsearch.impl.matcher.strategies.*;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -84,6 +81,9 @@ public class JavaCompilingVisitor extends JavaRecursiveElementWalkingVisitor {
|
||||
);
|
||||
|
||||
SubstitutionHandler handler = (SubstitutionHandler)myCompilingVisitor.getContext().getPattern().getHandler(str);
|
||||
if (handler == null) {
|
||||
throw new MalformedPatternException();
|
||||
}
|
||||
|
||||
if (handler.getPredicate() != null) {
|
||||
((RegExpPredicate)handler.getPredicate()).setMultiline(true);
|
||||
|
||||
+1
-2
@@ -55,7 +55,6 @@ import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||
import com.intellij.psi.impl.source.resolve.FileContextUtil;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.intellij.psi.impl.source.tree.injected.Place;
|
||||
import com.intellij.psi.impl.source.tree.injected.ShredImpl;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
@@ -133,7 +132,7 @@ public class QuickEditHandler extends DocumentAdapter implements Disposable {
|
||||
// suppress possible errors as in injected mode
|
||||
myNewFile.putUserData(InjectedLanguageUtil.FRANKENSTEIN_INJECTION,
|
||||
injectedFile.getUserData(InjectedLanguageUtil.FRANKENSTEIN_INJECTION));
|
||||
myNewFile.putUserData(FileContextUtil.INJECTED_IN_ELEMENT, ((ShredImpl)firstShred).getSmartPointer());
|
||||
myNewFile.putUserData(FileContextUtil.INJECTED_IN_ELEMENT, shreds.getHostPointer());
|
||||
myNewDocument = PsiDocumentManager.getInstance(project).getDocument(myNewFile);
|
||||
assert myNewDocument != null;
|
||||
EditorActionManager.getInstance().setReadonlyFragmentModificationHandler(myNewDocument, new MyQuietHandler());
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ public class InjectedFileViewProvider extends SingleRootFileViewProvider impleme
|
||||
@NotNull Language language) {
|
||||
super(psiManager, (VirtualFile)virtualFile, true, language);
|
||||
myDocumentWindow = documentWindow;
|
||||
myProject = documentWindow.getShreds().get(0).getHost().getProject();
|
||||
myProject = documentWindow.getShreds().getHostPointer().getProject();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -596,12 +596,12 @@ public class InjectedLanguageUtil {
|
||||
shreds = getShreds(((VirtualFileWindow)virtualFile).getDocumentWindow());
|
||||
}
|
||||
}
|
||||
return shreds != null ? shreds.get(0).getHost() : null;
|
||||
return shreds != null ? shreds.getHostPointer().getElement() : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiLanguageInjectionHost findInjectionHost(@Nullable VirtualFile virtualFile) {
|
||||
return virtualFile instanceof VirtualFileWindow ?
|
||||
getShreds(((VirtualFileWindow)virtualFile).getDocumentWindow()).get(0).getHost() : null;
|
||||
getShreds(((VirtualFileWindow)virtualFile).getDocumentWindow()).getHostPointer().getElement() : null;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -389,7 +389,7 @@ public class MultiHostRegistrarImpl implements MultiHostRegistrar, ModificationT
|
||||
"\nLeaf texts concatenated:'"+ patcher.catLeafs +"';" +
|
||||
"\nFile root: "+parsedNode+
|
||||
"\nLanguage: "+parsedNode.getPsi().getLanguage()+
|
||||
"\nHost file: "+ shreds.get(0).getHost().getContainingFile().getVirtualFile()
|
||||
"\nHost file: "+ shreds.getHostPointer().getVirtualFile()
|
||||
;
|
||||
DebugUtil.startPsiModification("injection leaf patching");
|
||||
try {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.intellij.psi.impl.source.tree.injected;
|
||||
|
||||
import com.intellij.psi.PsiLanguageInjectionHost;
|
||||
import com.intellij.psi.SmartPsiElementPointer;
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -30,6 +31,11 @@ public class Place extends SmartList<PsiLanguageInjectionHost.Shred> {
|
||||
super(shreds);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public SmartPsiElementPointer<PsiLanguageInjectionHost> getHostPointer() {
|
||||
return ((ShredImpl)get(0)).getSmartPointer();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
for (PsiLanguageInjectionHost.Shred shred : this) {
|
||||
if (!shred.isValid()) {
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ShredImpl implements PsiLanguageInjectionHost.Shred {
|
||||
class ShredImpl implements PsiLanguageInjectionHost.Shred {
|
||||
private final RangeMarker relevantRangeInHost;
|
||||
private final SmartPsiElementPointer<PsiLanguageInjectionHost> hostElementPointer;
|
||||
private final TextRange range; // range in (decoded) PSI
|
||||
@@ -45,6 +45,7 @@ public class ShredImpl implements PsiLanguageInjectionHost.Shred {
|
||||
assert relevantRangeInHost.isValid();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public SmartPsiElementPointer<PsiLanguageInjectionHost> getSmartPointer() {
|
||||
return hostElementPointer;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.options.ConfigurableGroup;
|
||||
import com.intellij.openapi.options.OptionsBundle;
|
||||
import com.intellij.openapi.options.SearchableConfigurable;
|
||||
import com.intellij.openapi.options.ex.ConfigurableWrapper;
|
||||
import com.intellij.openapi.options.ex.NodeConfigurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
@@ -116,10 +117,7 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
|
||||
}
|
||||
});
|
||||
|
||||
final JScrollPane scrolls = ScrollPaneFactory.createScrollPane(myTree);
|
||||
scrolls.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
|
||||
add(scrolls, BorderLayout.CENTER);
|
||||
add(new StickySeparator(myTree), BorderLayout.CENTER);
|
||||
|
||||
mySelection = new MergingUpdateQueue("OptionsTree", 150, false, this, this, this).setRestartTimerOnAdd(true);
|
||||
myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
|
||||
@@ -312,6 +310,7 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
|
||||
myProjectIcon.setOpaque(true);
|
||||
content.add(myProjectIcon, BorderLayout.EAST);
|
||||
myRendererComponent.add(content, BorderLayout.CENTER);
|
||||
mySeparatorComponent.setCaptionCentered(false);
|
||||
}
|
||||
|
||||
public Component getTreeCellRendererComponent(final JTree tree,
|
||||
@@ -404,8 +403,25 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
|
||||
myTextLabel.setBorder(new EmptyBorder(1,2,1,0));
|
||||
}
|
||||
|
||||
Project project = getConfigurableProject(base);
|
||||
if (project != null && Registry.is("ide.file.settings.order.new")) {
|
||||
Project project = null;
|
||||
if (base != null && Registry.is("ide.file.settings.order.new")) {
|
||||
SimpleNode parent = base.getParent();
|
||||
if (parent == myRoot) {
|
||||
project = getConfigurableProject(base); // show icon for top-level nodes
|
||||
if (base.getConfigurable() instanceof NodeConfigurable) { // special case for custom subgroups (build.tools)
|
||||
Configurable[] configurables = ((NodeConfigurable)base.getConfigurable()).getConfigurables();
|
||||
if (configurables != null) { // assume that all configurables have the same project
|
||||
project = getConfigurableProject(configurables[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (parent instanceof Base && ((Base)parent).getConfigurable() instanceof NodeConfigurable) {
|
||||
if (((Base)base.getParent()).getConfigurable() instanceof NodeConfigurable) {
|
||||
project = getConfigurableProject(base); // special case for custom subgroups
|
||||
}
|
||||
}
|
||||
}
|
||||
if (project != null) {
|
||||
myProjectIcon.setBackground(selected ? getSelectionBackground() : getBackground());
|
||||
myProjectIcon.setIcon(selected ? AllIcons.General.ProjectConfigurableSelected : AllIcons.General.ProjectConfigurable);
|
||||
myProjectIcon.setVisible(true);
|
||||
@@ -903,4 +919,63 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
|
||||
}
|
||||
return getConfigurableProject(node.getParent());
|
||||
}
|
||||
|
||||
private static final class StickySeparator extends JComponent {
|
||||
private final SimpleTree myTree;
|
||||
private final JScrollPane myScroller;
|
||||
private final SeparatorWithText mySeparator;
|
||||
|
||||
public StickySeparator(SimpleTree tree) {
|
||||
myTree = tree;
|
||||
myScroller = ScrollPaneFactory.createScrollPane(myTree);
|
||||
myScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
mySeparator = new SeparatorWithText();
|
||||
mySeparator.setCaptionCentered(false);
|
||||
//mySeparator.setVisible(true);
|
||||
add(myScroller);
|
||||
mySeparator.setOpaque(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doLayout() {
|
||||
myScroller.setBounds(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
|
||||
if (Registry.is("ide.file.settings.order.new")) {
|
||||
String name = null;
|
||||
int offset = 2 * mySeparator.getFont().getSize();
|
||||
TreePath path = myTree.getClosestPathForLocation(-myTree.getX(), -myTree.getY() + offset);
|
||||
SimpleNode node = myTree.getNodeFor(path);
|
||||
if (node instanceof FilteringTreeStructure.FilteringNode) {
|
||||
Object delegate = ((FilteringTreeStructure.FilteringNode)node).getDelegate();
|
||||
if (delegate instanceof EditorNode) {
|
||||
EditorNode editor = (EditorNode)delegate;
|
||||
ConfigurableGroup group = editor.getGroup();
|
||||
if (group != null) {
|
||||
name = group.getDisplayName();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (name != null) {
|
||||
mySeparator.setCaption(name);
|
||||
|
||||
Rectangle bounds = myScroller.getViewport().getBounds();
|
||||
int height = mySeparator.getPreferredSize().height;
|
||||
if (bounds.height > height) {
|
||||
bounds.height = height;
|
||||
}
|
||||
g.setColor(myTree.getBackground());
|
||||
g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
|
||||
g.setColor(myTree.getForeground());
|
||||
g.drawLine(0, bounds.height, bounds.width, bounds.height);
|
||||
mySeparator.setBounds(bounds);
|
||||
mySeparator.paint(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -2943,4 +2943,13 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
|
||||
String pattern3 = "'_a::'_b";
|
||||
assertEquals("should find all method references", 3, findMatchesCount(source, pattern3));
|
||||
}
|
||||
|
||||
public void testNoUnexpectedException() {
|
||||
String source = "{}";
|
||||
|
||||
String pattern1 = "/*$A$a*/";
|
||||
try {
|
||||
findMatchesCount(source, pattern1);
|
||||
} catch (MalformedPatternException ignore) {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user