mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
@@ -31,6 +31,7 @@ public class IFileElementType extends ILazyParseableElementType {
|
||||
super(debugName, language);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ASTNode parseContents(final ASTNode chameleon) {
|
||||
final PsiElement psi = chameleon.getPsi();
|
||||
|
||||
@@ -20,11 +20,11 @@ package com.intellij.ide;
|
||||
*/
|
||||
public interface StandardTargetWeights {
|
||||
float PROJECT_WEIGHT = 1;
|
||||
float FAVORITES_WEIGHT = 1.01f;
|
||||
float PACKAGES_WEIGHT = 2;
|
||||
float J2EE_WEIGHT = 3;
|
||||
float STRUCTURE_WEIGHT = 4;
|
||||
float COMMANDER_WEIGHT = 5;
|
||||
float FAVORITES_WEIGHT = 6;
|
||||
float SCOPE_WEIGHT = 6.5f;
|
||||
float NAV_BAR_WEIGHT = 8;
|
||||
float CHANGES_VIEW = 9;
|
||||
|
||||
@@ -180,9 +180,6 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
|
||||
myPanel.removeAll();
|
||||
myPanel.add(myHistoryViewer.getComponent(), BorderLayout.CENTER);
|
||||
myFullEditor = fileManager.openTextEditor(new OpenFileDescriptor(getProject(), virtualFile, 0), true);
|
||||
configureFullEditor();
|
||||
setConsoleFilePinned(fileManager);
|
||||
|
||||
myHistoryViewer.setHorizontalScrollbarVisible(true);
|
||||
myCurrentEditor = myFullEditor;
|
||||
}
|
||||
@@ -201,7 +198,7 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
|
||||
|
||||
public void setFullEditorActions(ActionGroup actionGroup) {
|
||||
myFullEditorActions = actionGroup;
|
||||
configureFullEditor();
|
||||
configureFullEditor(myFullEditor);
|
||||
}
|
||||
|
||||
public void setShowSeparatorLine(boolean showSeparatorLine) {
|
||||
@@ -539,6 +536,11 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
|
||||
for (FileEditor fileEditor : source.getAllEditors(file)) {
|
||||
if (!(fileEditor instanceof TextEditor)) continue;
|
||||
final Editor editor = ((TextEditor)fileEditor).getEditor();
|
||||
// todo what if it is splitted?
|
||||
myCurrentEditor = editor;
|
||||
myFullEditor = editor;
|
||||
configureFullEditor(editor);
|
||||
setConsoleFilePinned((FileEditorManagerEx)source);
|
||||
EmptyAction.registerActionShortcuts(editor.getComponent(), myConsoleEditor.getComponent());
|
||||
editor.getCaretModel().addCaretListener(new CaretListener() {
|
||||
public void caretPositionChanged(CaretEvent e) {
|
||||
@@ -595,20 +597,18 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
|
||||
}
|
||||
editorManager.closeFile(file);
|
||||
myFullEditor = editorManager.openTextEditor(new OpenFileDescriptor(getProject(), newVFile, offset), focusEditor);
|
||||
configureFullEditor();
|
||||
setConsoleFilePinned(editorManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void configureFullEditor() {
|
||||
if (myFullEditor == null || myFullEditorActions == null) return;
|
||||
private void configureFullEditor(final Editor editor) {
|
||||
if (editor == null || myFullEditorActions == null) return;
|
||||
final JPanel header = new JPanel(new BorderLayout());
|
||||
final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, myFullEditorActions, true);
|
||||
actionToolbar.setTargetComponent(myFullEditor.getContentComponent());
|
||||
actionToolbar.setTargetComponent(editor.getContentComponent());
|
||||
header.add(actionToolbar.getComponent(), BorderLayout.EAST);
|
||||
myFullEditor.setHeaderComponent(header);
|
||||
myFullEditor.getSettings().setLineMarkerAreaShown(false);
|
||||
editor.setHeaderComponent(header);
|
||||
editor.getSettings().setLineMarkerAreaShown(false);
|
||||
}
|
||||
|
||||
public void setInputText(final String query) {
|
||||
|
||||
@@ -590,7 +590,7 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
|
||||
return true;
|
||||
}
|
||||
final boolean destroyProcess;
|
||||
if (Boolean.TRUE.equals(processHandler.getUserData(ProcessHandler.SILENTLY_DESTROY_ON_CLOSE))) {
|
||||
if (processHandler.isSilentlyDestroyOnClose() || Boolean.TRUE.equals(processHandler.getUserData(ProcessHandler.SILENTLY_DESTROY_ON_CLOSE))) {
|
||||
destroyProcess = true;
|
||||
}
|
||||
else {
|
||||
|
||||
+10
-1
@@ -52,7 +52,11 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.ui.treeStructure.actions.CollapseAllAction;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.EditSourceOnDoubleClickHandler;
|
||||
import com.intellij.util.EditSourceOnEnterKeyHandler;
|
||||
import com.intellij.util.IconUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -68,6 +72,10 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author anna
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class FavoritesTreeViewPanel extends JPanel implements DataProvider {
|
||||
private final FavoritesTreeStructure myFavoritesTreeStructure;
|
||||
private FavoritesViewTreeBuilder myBuilder;
|
||||
@@ -167,6 +175,7 @@ public class FavoritesTreeViewPanel extends JPanel implements DataProvider {
|
||||
return CustomShortcutSet.fromString("DELETE");
|
||||
}
|
||||
})
|
||||
.addExtraAction(AnActionButton.fromAction(new CollapseAllAction(myTree)))
|
||||
.setLineBorder(0, 0, 0, 0)
|
||||
.createPanel();
|
||||
panel.setBorder(IdeBorderFactory.createEmptyBorder(0));
|
||||
|
||||
+74
-12
@@ -16,19 +16,26 @@
|
||||
|
||||
package com.intellij.ide.favoritesTreeView;
|
||||
|
||||
import com.intellij.ide.SelectInContext;
|
||||
import com.intellij.ide.SelectInManager;
|
||||
import com.intellij.ide.StandardTargetWeights;
|
||||
import com.intellij.ide.impl.ProjectViewSelectInTarget;
|
||||
import com.intellij.ide.impl.SelectInTargetPsiWrapper;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFileSystemItem;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowId;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: Feb 25, 2005
|
||||
* @author anna
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class FavoritesViewSelectInTarget extends ProjectViewSelectInTarget {
|
||||
public class FavoritesViewSelectInTarget extends SelectInTargetPsiWrapper {
|
||||
public FavoritesViewSelectInTarget(final Project project) {
|
||||
super(project);
|
||||
}
|
||||
@@ -37,8 +44,68 @@ public class FavoritesViewSelectInTarget extends ProjectViewSelectInTarget {
|
||||
return SelectInManager.FAVORITES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToolWindowId() {
|
||||
return SelectInManager.FAVORITES;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void select(Object selector, VirtualFile virtualFile, boolean requestFocus) {
|
||||
select(myProject, selector, null, null, virtualFile, requestFocus);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void select(PsiElement element, boolean requestFocus) {
|
||||
PsiElement toSelect = null;
|
||||
if (element instanceof PsiFile || element instanceof PsiDirectory) {
|
||||
toSelect = element;
|
||||
}
|
||||
else {
|
||||
final PsiFile containingFile = element.getContainingFile();
|
||||
if (containingFile == null) return;
|
||||
final FileViewProvider viewProvider = containingFile.getViewProvider();
|
||||
toSelect = viewProvider.getPsi(viewProvider.getBaseLanguage());
|
||||
}
|
||||
if (toSelect == null) return;
|
||||
PsiElement originalElement = toSelect.getOriginalElement();
|
||||
final VirtualFile virtualFile = PsiUtilBase.getVirtualFile(originalElement);
|
||||
select(originalElement, virtualFile, requestFocus);
|
||||
}
|
||||
|
||||
public static ActionCallback select(@NotNull Project project,
|
||||
final Object toSelect,
|
||||
@Nullable final String viewId,
|
||||
@Nullable final String subviewId,
|
||||
final VirtualFile virtualFile,
|
||||
final boolean requestFocus) {
|
||||
final ActionCallback result = new ActionCallback();
|
||||
|
||||
ToolWindowManager windowManager=ToolWindowManager.getInstance(project);
|
||||
final ToolWindow favoritesToolWindow = windowManager.getToolWindow(ToolWindowId.FAVORITES_VIEW);
|
||||
|
||||
if (favoritesToolWindow != null) {
|
||||
final FavoritesTreeViewPanel panel = UIUtil.findComponentOfType(favoritesToolWindow.getComponent(), FavoritesTreeViewPanel.class);
|
||||
|
||||
if (panel != null) {
|
||||
final Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
panel.selectElement(toSelect, virtualFile, requestFocus);
|
||||
result.setDone();
|
||||
}
|
||||
};
|
||||
|
||||
if (requestFocus) {
|
||||
favoritesToolWindow.activate(runnable, false);
|
||||
} else {
|
||||
favoritesToolWindow.show(runnable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected boolean canSelect(final PsiFileSystemItem file) {
|
||||
if (!super.canSelect(file)) return false;
|
||||
return findSuitableFavoritesList(file.getVirtualFile(), myProject, null) != null;
|
||||
}
|
||||
|
||||
@@ -63,9 +130,4 @@ public class FavoritesViewSelectInTarget extends ProjectViewSelectInTarget {
|
||||
protected boolean canWorkWithCustomObjects() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSubIdSelectable(String subId, SelectInContext context) {
|
||||
final FavoritesManager favoritesManager = FavoritesManager.getInstance(myProject);
|
||||
return favoritesManager.contains(subId, context.getVirtualFile());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public abstract class AnActionButton extends AnAction implements ShortcutProvide
|
||||
private boolean myEnabled = true;
|
||||
private boolean myVisible = true;
|
||||
private ShortcutSet myShortcut;
|
||||
private AnAction myAction = null;
|
||||
private JComponent myContextComponent;
|
||||
|
||||
public AnActionButton(String text) {
|
||||
@@ -47,6 +48,29 @@ public abstract class AnActionButton extends AnAction implements ShortcutProvide
|
||||
|
||||
public AnActionButton() {
|
||||
}
|
||||
|
||||
public static AnActionButton fromAction(final AnAction action) {
|
||||
final Presentation presentation = action.getTemplatePresentation();
|
||||
return new AnActionButton(presentation.getText(),
|
||||
presentation.getDescription(),
|
||||
presentation.getIcon()) {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
action.actionPerformed(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateButton(AnActionEvent e) {
|
||||
action.update(e);
|
||||
final boolean enabled = e.getPresentation().isEnabled();
|
||||
final boolean visible = e.getPresentation().isVisible();
|
||||
if (enabled && visible) {
|
||||
super.updateButton(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return myEnabled;
|
||||
@@ -66,9 +90,17 @@ public abstract class AnActionButton extends AnAction implements ShortcutProvide
|
||||
|
||||
@Override
|
||||
public final void update(AnActionEvent e) {
|
||||
final boolean enabled = isEnabled() && isContextComponentOk();
|
||||
boolean myActionVisible = true;
|
||||
boolean myActionEnabled = true;
|
||||
if (myAction != null) {
|
||||
myAction.update(e);
|
||||
myActionEnabled = myAction.getTemplatePresentation().isEnabled();
|
||||
myActionVisible = myAction.getTemplatePresentation().isVisible();
|
||||
}
|
||||
final boolean enabled = isEnabled() && isContextComponentOk() && myActionEnabled;
|
||||
e.getPresentation().setEnabled(enabled);
|
||||
e.getPresentation().setVisible(isVisible());
|
||||
e.getPresentation().setVisible(isVisible() && myActionVisible);
|
||||
|
||||
if (enabled) {
|
||||
updateButton(e);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<component id="92c6d" class="javax.swing.JTextField" binding="myProjectNameTextField">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
<preferred-size width="450" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
|
||||
@@ -56,6 +56,8 @@ public class NewDirectoryProjectDialog extends DialogWrapper {
|
||||
private boolean myModifyingProjectName = false;
|
||||
|
||||
private static final Object EMPTY_PROJECT_GENERATOR = new Object();
|
||||
private final String mySuggestedProjectName;
|
||||
private boolean myProjectNameWasChanged = false;
|
||||
|
||||
protected NewDirectoryProjectDialog(Project project) {
|
||||
super(project, true);
|
||||
@@ -65,9 +67,12 @@ public class NewDirectoryProjectDialog extends DialogWrapper {
|
||||
myLocationLabel.setLabelFor(myLocationField.getChildComponent());
|
||||
|
||||
myBaseDir = getBaseDir();
|
||||
File projectName = FileUtil.findSequentNonexistentFile(new File(myBaseDir), "untitled", "");
|
||||
myLocationField.setText(projectName.toString());
|
||||
myProjectNameTextField.setText(projectName.getName());
|
||||
|
||||
File suggestedProjectDirectory = FileUtil.findSequentNonexistentFile(new File(myBaseDir), "untitled", "");
|
||||
|
||||
myLocationField.setText(suggestedProjectDirectory.toString());
|
||||
myProjectNameTextField.setText(suggestedProjectDirectory.getName());
|
||||
mySuggestedProjectName = suggestedProjectDirectory.getName();
|
||||
|
||||
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
|
||||
ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> listener =
|
||||
@@ -75,11 +80,16 @@ public class NewDirectoryProjectDialog extends DialogWrapper {
|
||||
project,
|
||||
descriptor,
|
||||
TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {
|
||||
|
||||
protected void onFileChoosen(VirtualFile chosenFile) {
|
||||
super.onFileChoosen(chosenFile);
|
||||
myBaseDir = chosenFile.getPath();
|
||||
myLocationField.setText(new File(chosenFile.getPath(), myProjectNameTextField.getText()).toString());
|
||||
if (myProjectNameWasChanged) {
|
||||
myLocationField.setText(new File(chosenFile.getPath(), myProjectNameTextField.getText()).toString());
|
||||
} else {
|
||||
myModifyingLocation = true;
|
||||
myLocationField.setText(chosenFile.getPath());
|
||||
myProjectNameTextField.setText(chosenFile.getName());
|
||||
myModifyingLocation = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
myLocationField.addActionListener(listener);
|
||||
@@ -110,6 +120,7 @@ public class NewDirectoryProjectDialog extends DialogWrapper {
|
||||
myProjectNameTextField.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
protected void textChanged(final DocumentEvent e) {
|
||||
if (!myModifyingLocation) {
|
||||
myProjectNameWasChanged = true;
|
||||
myModifyingProjectName = true;
|
||||
File f = new File(myBaseDir);
|
||||
myLocationField.setText(new File(f, myProjectNameTextField.getText()).getPath());
|
||||
@@ -155,6 +166,10 @@ public class NewDirectoryProjectDialog extends DialogWrapper {
|
||||
});
|
||||
}
|
||||
|
||||
private boolean projectNameWasChanged() {
|
||||
return mySuggestedProjectName != null && !mySuggestedProjectName.equals(myProjectNameTextField.getText());
|
||||
}
|
||||
|
||||
private void checkValid() {
|
||||
String projectName = myProjectNameTextField.getText();
|
||||
if (projectName.trim().isEmpty()) {
|
||||
|
||||
@@ -457,6 +457,7 @@
|
||||
<selectInTarget implementation="com.intellij.ide.navigationToolbar.SelectInNavBarTarget"/>
|
||||
<selectInTarget implementation="com.intellij.ide.impl.StructureViewSelectInTarget"/>
|
||||
<selectInTarget implementation="com.intellij.ide.impl.ProjectViewSelectInExplorerTarget"/>
|
||||
<selectInTarget implementation="com.intellij.ide.favoritesTreeView.FavoritesViewSelectInTarget"/>
|
||||
|
||||
<elementLookupRenderer implementation="com.intellij.codeInsight.template.impl.TemplateLookupRenderer"/>
|
||||
|
||||
|
||||
@@ -189,6 +189,10 @@ public abstract class ProcessHandler extends UserDataHolderBase {
|
||||
public boolean isStartNotified() {
|
||||
return myState.get() > STATE_INITIAL;
|
||||
}
|
||||
|
||||
public boolean isSilentlyDestroyOnClose() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private ProcessListener createEventMulticaster() {
|
||||
final Class<ProcessListener> listenerClass = ProcessListener.class;
|
||||
|
||||
@@ -845,10 +845,8 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
|
||||
String[] parts;
|
||||
PsiElement child = literal.getFirstChild();
|
||||
assert child != null : "null child: " + literal.getText() + ";";
|
||||
ASTNode node = child.getNode();
|
||||
assert node != null : "null node: " + child.getText() + ";";
|
||||
IElementType elementType = node.getElementType();
|
||||
if (child == null) child = literal;
|
||||
IElementType elementType = child.getNode().getElementType();
|
||||
boolean isSimpleString = elementType == GroovyTokenTypes.mSTRING_LITERAL ||
|
||||
elementType == GroovyTokenTypes.mGSTRING_LITERAL ||
|
||||
elementType == GroovyTokenTypes.mREGEX_LITERAL;
|
||||
|
||||
+8
-2
@@ -709,13 +709,19 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl<GrExpressi
|
||||
}
|
||||
|
||||
public boolean isReferenceTo(PsiElement element) {
|
||||
PsiElement target = GroovyTargetElementEvaluator.correctSearchTargets(resolve());
|
||||
if (getManager().areElementsEquivalent(element, target)) {
|
||||
PsiElement baseTarget = resolve();
|
||||
if (getManager().areElementsEquivalent(element, baseTarget)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PsiElement target = GroovyTargetElementEvaluator.correctSearchTargets(baseTarget);
|
||||
if (target != baseTarget && getManager().areElementsEquivalent(element, target)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (element instanceof PsiMethod && target instanceof PsiMethod) {
|
||||
PsiMethod[] superMethods = ((PsiMethod)target).findSuperMethods(false);
|
||||
//noinspection SuspiciousMethodCalls
|
||||
if (Arrays.asList(superMethods).contains(element)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,6 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag {
|
||||
private volatile String myLocalName;
|
||||
private volatile XmlAttribute[] myAttributes = null;
|
||||
private volatile Map<String, String> myAttributeValueMap = null;
|
||||
private CachedValue<XmlTag[]> myTags = null;
|
||||
private volatile XmlTagValue myValue = null;
|
||||
private volatile Map<String, CachedValue<XmlNSDescriptor>> myNSDescriptorsMap = null;
|
||||
private volatile String myCachedNamespace;
|
||||
@@ -121,7 +120,6 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag {
|
||||
myHaveNamespaceDeclarations = false;
|
||||
myValue = null;
|
||||
myNSDescriptorsMap = null;
|
||||
myTags = null;
|
||||
super.clearCaches();
|
||||
}
|
||||
|
||||
@@ -608,29 +606,28 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag {
|
||||
|
||||
@NotNull
|
||||
public XmlTag[] getSubTags() {
|
||||
CachedValue<XmlTag[]> value = myTags;
|
||||
if (value == null) {
|
||||
value = myTags = CachedValuesManager.getManager(getProject()).createCachedValue(new CachedValueProvider<XmlTag[]>() {
|
||||
@Override
|
||||
public Result<XmlTag[]> compute() {
|
||||
final List<XmlTag> result = new ArrayList<XmlTag>();
|
||||
return CachedValuesManager.getManager(getProject()).getCachedValue(this, new CachedValueProvider<XmlTag[]>() {
|
||||
@Override
|
||||
public Result<XmlTag[]> compute() {
|
||||
final List<XmlTag> result = new ArrayList<XmlTag>();
|
||||
|
||||
fillSubTags(result);
|
||||
fillSubTags(result);
|
||||
|
||||
final int s = result.size();
|
||||
XmlTag[] tags = s > 0 ? ContainerUtil.toArray(result, new XmlTag[s]) : EMPTY;
|
||||
return Result.create(tags, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
|
||||
final int s = result.size();
|
||||
XmlTag[] tags = s > 0 ? ContainerUtil.toArray(result, new XmlTag[s]) : EMPTY;
|
||||
return Result.create(tags, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
|
||||
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
return value.getValue();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void fillSubTags(final List<XmlTag> result) {
|
||||
processElements(new PsiElementProcessor() {
|
||||
public boolean execute(@NotNull PsiElement element) {
|
||||
if (element instanceof XmlTag) result.add((XmlTag)element);
|
||||
if (element instanceof XmlTag) {
|
||||
assert element.isValid();
|
||||
result.add((XmlTag)element);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}, this);
|
||||
|
||||
@@ -57,10 +57,7 @@ import com.intellij.psi.impl.source.xml.XmlEntityRefImpl;
|
||||
import com.intellij.psi.scope.processor.FilterElementProcessor;
|
||||
import com.intellij.psi.search.PsiElementProcessor;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.CachedValue;
|
||||
import com.intellij.psi.util.CachedValueProvider;
|
||||
import com.intellij.psi.util.CachedValuesManager;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.psi.xml.*;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -672,12 +669,13 @@ public class XmlUtil {
|
||||
|
||||
final PsiElement[] inclusion = CachedValuesManager.getManager(xincludeTag.getProject()).getCachedValue(xincludeTag, new CachedValueProvider<PsiElement[]>() {
|
||||
public Result<PsiElement[]> compute() {
|
||||
return RecursionManager.doPreventingRecursion(xincludeTag, true, new Computable<Result<PsiElement[]>>() {
|
||||
PsiElement[] result = RecursionManager.doPreventingRecursion(xincludeTag, true, new NullableComputable<PsiElement[]>() {
|
||||
@Override
|
||||
public Result<PsiElement[]> compute() {
|
||||
public PsiElement[] compute() {
|
||||
return computeInclusion(xincludeTag);
|
||||
}
|
||||
});
|
||||
return Result.create(result, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -690,39 +688,26 @@ public class XmlUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static final Key<Trinity<XmlFile, String, CachedValue<PsiElement[]>>> COPY_CACHE = Key.create("XInclude.CopyCache");
|
||||
|
||||
private static CachedValueProvider.Result<PsiElement[]> computeInclusion(final XmlTag xincludeTag) {
|
||||
final PsiFile containingFile = xincludeTag.getContainingFile();
|
||||
|
||||
@Nullable
|
||||
private static PsiElement[] computeInclusion(final XmlTag xincludeTag) {
|
||||
final XmlFile included = XmlIncludeHandler.resolveXIncludeFile(xincludeTag);
|
||||
final XmlDocument document = included != null ? included.getDocument() : null;
|
||||
final XmlTag rootTag = document != null ? document.getRootTag() : null;
|
||||
if (rootTag != null) {
|
||||
final String xpointer = xincludeTag.getAttributeValue("xpointer", XINCLUDE_URI);
|
||||
Trinity<XmlFile, String, CachedValue<PsiElement[]>> cached = xincludeTag.getUserData(COPY_CACHE);
|
||||
if (cached == null || !cached.first.equals(included) || !Comparing.equal(cached.second, xpointer)) {
|
||||
cached = Trinity.create(included, xpointer, CachedValuesManager.getManager(xincludeTag.getProject()).createCachedValue(new CachedValueProvider<PsiElement[]>() {
|
||||
@Override
|
||||
public Result<PsiElement[]> compute() {
|
||||
final XmlTag[] includeTag = extractXpointer(rootTag, xpointer);
|
||||
PsiElement[] result = new PsiElement[includeTag.length];
|
||||
for (int i = 0; i < includeTag.length; i++) {
|
||||
XmlTag xmlTag = includeTag[i];
|
||||
final PsiElement psiElement = xmlTag.copy();
|
||||
psiElement.putUserData(XmlElement.INCLUDING_ELEMENT, xincludeTag.getParentTag());
|
||||
psiElement.putUserData(ORIGINAL_ELEMENT, PsiAnchor.create(xmlTag));
|
||||
result[i] = psiElement;
|
||||
}
|
||||
return Result.create(result, included);
|
||||
}
|
||||
}, false));
|
||||
xincludeTag.putUserData(COPY_CACHE, cached);
|
||||
final XmlTag[] includeTag = extractXpointer(rootTag, xpointer);
|
||||
PsiElement[] result = new PsiElement[includeTag.length];
|
||||
for (int i = 0; i < includeTag.length; i++) {
|
||||
XmlTag xmlTag = includeTag[i];
|
||||
final PsiElement psiElement = xmlTag.copy();
|
||||
psiElement.putUserData(XmlElement.INCLUDING_ELEMENT, xincludeTag.getParentTag());
|
||||
psiElement.putUserData(ORIGINAL_ELEMENT, PsiAnchor.create(xmlTag));
|
||||
result[i] = psiElement;
|
||||
}
|
||||
return new CachedValueProvider.Result<PsiElement[]>(cached.third.getValue(), containingFile);
|
||||
return result;
|
||||
}
|
||||
|
||||
return new CachedValueProvider.Result<PsiElement[]>(null, containingFile);
|
||||
return null;
|
||||
}
|
||||
|
||||
private static XmlTag[] extractXpointer(XmlTag rootTag, @Nullable final String xpointer) {
|
||||
|
||||
Reference in New Issue
Block a user