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:
@@ -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.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.facet.impl.ui;
|
||||
|
||||
import com.intellij.facet.Facet;
|
||||
@@ -61,6 +60,7 @@ public class FacetEditorImpl extends UnnamedConfigurableGroup implements Unnamed
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
myErrorPanel.getValidatorsManager().validate();
|
||||
@@ -73,6 +73,7 @@ public class FacetEditorImpl extends UnnamedConfigurableGroup implements Unnamed
|
||||
return myComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent createComponent() {
|
||||
final JComponent editorComponent;
|
||||
if (myEditorTabs.length > 1) {
|
||||
@@ -83,7 +84,8 @@ public class FacetEditorImpl extends UnnamedConfigurableGroup implements Unnamed
|
||||
tabbedPane.addTab(editorTab.getDisplayName(), c);
|
||||
}
|
||||
tabbedPane.addChangeListener(new ChangeListener() {
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
@Override
|
||||
public void stateChanged(@NotNull ChangeEvent e) {
|
||||
myEditorTabs[mySelectedTabIndex].onTabLeaving();
|
||||
mySelectedTabIndex = tabbedPane.getSelectedIndex();
|
||||
onTabSelected(myEditorTabs[mySelectedTabIndex]);
|
||||
@@ -99,10 +101,13 @@ public class FacetEditorImpl extends UnnamedConfigurableGroup implements Unnamed
|
||||
else {
|
||||
editorComponent = new JPanel();
|
||||
}
|
||||
|
||||
final JComponent errorComponent = myErrorPanel.getComponent();
|
||||
UIUtil.addInsets(errorComponent, new Insets(0, 5, 5, 0));
|
||||
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(BorderLayout.CENTER, editorComponent);
|
||||
panel.add(BorderLayout.SOUTH, myErrorPanel.getComponent());
|
||||
|
||||
panel.add(BorderLayout.SOUTH, errorComponent);
|
||||
return panel;
|
||||
}
|
||||
|
||||
@@ -122,6 +127,7 @@ public class FacetEditorImpl extends UnnamedConfigurableGroup implements Unnamed
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeUIResources() {
|
||||
Disposer.dispose(myDisposable);
|
||||
myErrorPanel.disposeUIResources();
|
||||
@@ -161,10 +167,12 @@ public class FacetEditorImpl extends UnnamedConfigurableGroup implements Unnamed
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FacetEditorTab[] getEditorTabs() {
|
||||
return myEditorTabs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends FacetEditorTab> T getEditorTab(@NotNull final Class<T> aClass) {
|
||||
for (FacetEditorTab editorTab : myEditorTabs) {
|
||||
if (aClass.isInstance(editorTab)) {
|
||||
|
||||
@@ -33,21 +33,25 @@ import java.util.List;
|
||||
|
||||
public class LightStubBuilder implements StubBuilder {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.stubs.LightStubBuilder");
|
||||
private LighterAST myForcedLighterAst;
|
||||
|
||||
@Override
|
||||
public StubElement buildStubTree(@NotNull PsiFile file) {
|
||||
FileType fileType = file.getFileType();
|
||||
if (!(fileType instanceof LanguageFileType)) {
|
||||
LOG.error("File is not of LanguageFileType: " + fileType + ", " + file);
|
||||
return null;
|
||||
LighterAST tree = myForcedLighterAst;
|
||||
if (tree == null) {
|
||||
FileType fileType = file.getFileType();
|
||||
if (!(fileType instanceof LanguageFileType)) {
|
||||
LOG.error("File is not of LanguageFileType: " + fileType + ", " + file);
|
||||
return null;
|
||||
}
|
||||
Language language = ((LanguageFileType)fileType).getLanguage();
|
||||
final IFileElementType contentType = LanguageParserDefinitions.INSTANCE.forLanguage(language).getFileNodeType();
|
||||
if (!(contentType instanceof ILightStubFileElementType)) {
|
||||
LOG.error("File is not of ILightStubFileElementType: " + contentType + ", " + file);
|
||||
return null;
|
||||
}
|
||||
tree = file.getNode().getLighterAST();
|
||||
}
|
||||
Language language = ((LanguageFileType)fileType).getLanguage();
|
||||
final IFileElementType contentType = LanguageParserDefinitions.INSTANCE.forLanguage(language).getFileNodeType();
|
||||
if (!(contentType instanceof ILightStubFileElementType)) {
|
||||
LOG.error("File is not of ILightStubFileElementType: " + contentType + ", " + file);
|
||||
return null;
|
||||
}
|
||||
final LighterAST tree = file.getNode().getLighterAST();
|
||||
if (tree == null) return null;
|
||||
|
||||
final StubElement rootStub = createStubForFile(file, tree);
|
||||
@@ -154,4 +158,8 @@ public class LightStubBuilder implements StubBuilder {
|
||||
protected boolean skipChildProcessingWhenBuildingStubs(@NotNull LighterAST tree, @NotNull LighterASTNode parent, @NotNull LighterASTNode node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setForcedLighterAst(LighterAST forcedLighterAst) {
|
||||
myForcedLighterAst = forcedLighterAst;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.intellij.psi.impl.source.tree;
|
||||
|
||||
import com.intellij.lang.*;
|
||||
import com.intellij.openapi.util.Getter;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.impl.source.CharTableImpl;
|
||||
@@ -26,7 +25,6 @@ import com.intellij.psi.impl.source.PsiFileImpl;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.IFileElementType;
|
||||
import com.intellij.psi.tree.ILightStubFileElementType;
|
||||
import com.intellij.reference.SoftReference;
|
||||
import com.intellij.util.CharTable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -51,8 +49,6 @@ public class FileElement extends LazyParseableElement implements FileASTNode, Ge
|
||||
return myCharTable;
|
||||
}
|
||||
|
||||
private static final Key<SoftReference<LighterAST>> ourTreeKey = Key.create("lighter.key");
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public LighterAST getLighterAST() {
|
||||
@@ -61,12 +57,7 @@ public class FileElement extends LazyParseableElement implements FileASTNode, Ge
|
||||
|
||||
LighterAST tree;
|
||||
if (!isParsed()) {
|
||||
tree = SoftReference.dereference(getUserData(ourTreeKey));
|
||||
if (tree == null) {
|
||||
final ILightStubFileElementType<?> type = (ILightStubFileElementType)contentType;
|
||||
tree = new FCTSBackedLighterAST(getCharTable(), type.parseContentsLight(this));
|
||||
tree = SoftReference.dereference(putUserDataIfAbsent(ourTreeKey, new SoftReference<LighterAST>(tree)));
|
||||
}
|
||||
return new FCTSBackedLighterAST(getCharTable(), ((ILightStubFileElementType<?>)contentType).parseContentsLight(this));
|
||||
}
|
||||
else {
|
||||
tree = new TreeBackedLighterAST(this);
|
||||
@@ -74,12 +65,6 @@ public class FileElement extends LazyParseableElement implements FileASTNode, Ge
|
||||
return tree;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void resetCachesOnParsedStateUpdate() {
|
||||
putUserData(ourTreeKey, null);
|
||||
super.resetCachesOnParsedStateUpdate();
|
||||
}
|
||||
|
||||
public FileElement(IElementType type, CharSequence text) {
|
||||
super(type, text);
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ public class LazyParseableElement extends CompositeElement {
|
||||
LOG.error("Reentrant parsing?");
|
||||
}
|
||||
|
||||
resetCachesOnParsedStateUpdate();
|
||||
myText = null;
|
||||
|
||||
if (parsedNode == null) return;
|
||||
super.rawAddChildrenWithoutNotifications((TreeElement)parsedNode);
|
||||
@@ -199,10 +199,6 @@ public class LazyParseableElement extends CompositeElement {
|
||||
}
|
||||
}
|
||||
|
||||
protected void resetCachesOnParsedStateUpdate() {
|
||||
myText = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rawAddChildrenWithoutNotifications(@NotNull TreeElement first) {
|
||||
if (myText() != null) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.StubBuilder;
|
||||
import com.intellij.psi.tree.IFileElementType;
|
||||
import com.intellij.psi.tree.IStubFileElementType;
|
||||
import com.intellij.util.indexing.FileContent;
|
||||
@@ -56,7 +57,8 @@ public class StubTreeBuilder {
|
||||
final IFileElementType type = LanguageParserDefinitions.INSTANCE.forLanguage(l).getFileNodeType();
|
||||
|
||||
CharSequence contentAsText = inputData.getContentAsText();
|
||||
PsiFile psi = ((FileContentImpl)inputData).getPsiFileAccountingForUnsavedDocument();
|
||||
FileContentImpl fileContent = (FileContentImpl)inputData;
|
||||
PsiFile psi = fileContent.getPsiFileAccountingForUnsavedDocument();
|
||||
psi = psi.getViewProvider().getStubBindingRoot();
|
||||
psi.putUserData(IndexingDataKeys.FILE_TEXT_CONTENT_KEY, contentAsText);
|
||||
|
||||
@@ -78,7 +80,11 @@ public class StubTreeBuilder {
|
||||
stubFileElementType = null;
|
||||
}
|
||||
if (stubFileElementType != null) {
|
||||
data = stubFileElementType.getBuilder().buildStubTree(psi);
|
||||
StubBuilder stubBuilder = stubFileElementType.getBuilder();
|
||||
if (stubBuilder instanceof LightStubBuilder) { // each builder is pristine
|
||||
((LightStubBuilder)stubBuilder).setForcedLighterAst(fileContent.getLighterAST());
|
||||
}
|
||||
data = stubBuilder.buildStubTree(psi);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.util.indexing;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LighterAST;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
|
||||
@@ -78,6 +79,16 @@ public final class FileContentImpl extends UserDataHolderBase implements FileCon
|
||||
return psi;
|
||||
}
|
||||
|
||||
public @NotNull LighterAST getLighterAST() {
|
||||
LighterAST lighterAST = getUserData(IndexingDataKeys.LIGHTER_AST_NODE_KEY);
|
||||
if (lighterAST == null) {
|
||||
lighterAST = getPsiFileAccountingForUnsavedDocument().getNode().getLighterAST();
|
||||
assert lighterAST != null;
|
||||
putUserData(IndexingDataKeys.LIGHTER_AST_NODE_KEY, lighterAST);
|
||||
}
|
||||
return lighterAST;
|
||||
}
|
||||
|
||||
public PsiFile createFileFromText(@NotNull CharSequence text) {
|
||||
Project project = getProject();
|
||||
if (project == null) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.util.indexing;
|
||||
|
||||
import com.intellij.lang.LighterAST;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -28,6 +29,7 @@ public class IndexingDataKeys {
|
||||
public static final Key<Project> PROJECT = new Key<Project>("Context project");
|
||||
public static final Key<PsiFile> PSI_FILE = new Key<PsiFile>("PSI for stubs");
|
||||
public static final Key<CharSequence> FILE_TEXT_CONTENT_KEY = Key.create("file text content cached by stub indexer");
|
||||
public static final Key<LighterAST> LIGHTER_AST_NODE_KEY = Key.create("lighter.ast.node");
|
||||
|
||||
private IndexingDataKeys() {
|
||||
}
|
||||
|
||||
@@ -17,15 +17,15 @@ package com.intellij.dupLocator;
|
||||
|
||||
import com.intellij.lang.LighterAST;
|
||||
import com.intellij.lang.LighterASTNode;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Created by Maxim.Mossienko on 10/1/2014.
|
||||
*/
|
||||
public interface LightDuplicateProfile {
|
||||
void process(PsiFile file, Callback callback);
|
||||
void process(@NotNull LighterAST ast, @NotNull Callback callback);
|
||||
|
||||
interface Callback {
|
||||
void process(LighterAST ast, LighterASTNode node, int hash);
|
||||
void process(@NotNull LighterAST ast, @NotNull LighterASTNode node, int hash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.indexing.*;
|
||||
import com.intellij.util.io.DataExternalizer;
|
||||
@@ -116,13 +115,15 @@ public class DuplicatesIndex extends FileBasedIndexExtension<Integer, TIntArrayL
|
||||
DuplicatesProfile profile = findDuplicatesProfile(type);
|
||||
if (profile == null) return Collections.emptyMap();
|
||||
|
||||
PsiFile psiFile = ((FileContentImpl)inputData).getPsiFileAccountingForUnsavedDocument();
|
||||
FileContentImpl fileContent = (FileContentImpl)inputData;
|
||||
|
||||
if (profile instanceof LightDuplicateProfile && ourEnabledLightProfiles) {
|
||||
final THashMap<Integer, TIntArrayList> result = new THashMap<Integer, TIntArrayList>();
|
||||
((LightDuplicateProfile)profile).process(psiFile, new LightDuplicateProfile.Callback() {
|
||||
LighterAST ast = fileContent.getLighterAST();
|
||||
assert ast != null;
|
||||
((LightDuplicateProfile)profile).process(ast, new LightDuplicateProfile.Callback() {
|
||||
@Override
|
||||
public void process(LighterAST ast, LighterASTNode node, int hash) {
|
||||
public void process(@NotNull LighterAST ast, @NotNull LighterASTNode node, int hash) {
|
||||
TIntArrayList list = result.get(hash);
|
||||
if (list == null) { result.put(hash, list = new TIntArrayList(1)); }
|
||||
list.add(node.getStartOffset());
|
||||
@@ -133,7 +134,7 @@ public class DuplicatesIndex extends FileBasedIndexExtension<Integer, TIntArrayL
|
||||
MyFragmentsCollector collector = new MyFragmentsCollector(profile, ((LanguageFileType)type).getLanguage());
|
||||
DuplocateVisitor visitor = profile.createVisitor(collector, true);
|
||||
|
||||
visitor.visitNode(psiFile);
|
||||
visitor.visitNode(fileContent.getPsiFileAccountingForUnsavedDocument());
|
||||
|
||||
return collector.getMap();
|
||||
}
|
||||
|
||||
+4
-3
@@ -44,11 +44,12 @@ public class DuplicatesInspectionBase extends LocalInspectionTool {
|
||||
final Ref<DuplicatedCodeProcessor> myProcessorRef = new Ref<DuplicatedCodeProcessor>();
|
||||
|
||||
if (profile instanceof LightDuplicateProfile && DuplicatesIndex.ourEnabledLightProfiles) {
|
||||
|
||||
((LightDuplicateProfile)profile).process(psiFile, new LightDuplicateProfile.Callback() {
|
||||
LighterAST ast = psiFile.getNode().getLighterAST();
|
||||
assert ast != null;
|
||||
((LightDuplicateProfile)profile).process(ast, new LightDuplicateProfile.Callback() {
|
||||
DuplicatedCodeProcessor<LighterASTNode> myProcessor;
|
||||
@Override
|
||||
public void process(final LighterAST ast, final LighterASTNode node, int hash) {
|
||||
public void process(@NotNull final LighterAST ast, @NotNull final LighterASTNode node, int hash) {
|
||||
class LightDuplicatedCodeProcessor extends DuplicatedCodeProcessor<LighterASTNode> {
|
||||
|
||||
LightDuplicatedCodeProcessor(VirtualFile file, Project project) {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.facet.impl.ui;
|
||||
|
||||
import com.intellij.facet.ui.FacetConfigurationQuickFix;
|
||||
@@ -52,9 +51,10 @@ public class FacetErrorPanel {
|
||||
myValidatorsManager = new FacetValidatorsManagerImpl();
|
||||
myWarningLabel = new JLabel();
|
||||
myWarningLabel.setIcon(AllIcons.General.WarningDialog);
|
||||
myWarningLabel.setIconTextGap(5);
|
||||
myQuickFixButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
public void actionPerformed(@NotNull ActionEvent e) {
|
||||
if (myCurrentQuickFix != null) {
|
||||
myCurrentQuickFix.run(myQuickFixButton);
|
||||
myValidatorsManager.validate();
|
||||
|
||||
@@ -2287,7 +2287,12 @@ public class FileBasedIndexImpl extends FileBasedIndex {
|
||||
removeFileDataFromIndices(ContainerUtil.intersection(nontrivialFileIndexedStates, myRequiringContentIndices), file);
|
||||
}
|
||||
else {
|
||||
doIndexFileContent(project, fileContent);
|
||||
try {
|
||||
doIndexFileContent(project, fileContent);
|
||||
} catch (ProcessCanceledException ex) {
|
||||
myFilesToUpdate.add(file); // PCE from running invalidation tasks should reschedule file processing
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
+7
-8
@@ -17,6 +17,7 @@ package com.intellij.openapi.editor.impl;
|
||||
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.border.CustomLineBorder;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -30,6 +31,7 @@ public class EditorHeaderComponent extends JPanel {
|
||||
|
||||
public EditorHeaderComponent() {
|
||||
super(new BorderLayout(0, 0));
|
||||
setBorder(new CustomLineBorder(JBColor.border(), 0, UIUtil.isUnderGTKLookAndFeel()? 0 : 1, 1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,6 +45,8 @@ public class EditorHeaderComponent extends JPanel {
|
||||
@Override
|
||||
protected void paintComponent(@NotNull Graphics g) {
|
||||
super.paintComponent(g);
|
||||
if (UIUtil.isUnderGTKLookAndFeel()) return;
|
||||
|
||||
paintGradient(g, this);
|
||||
}
|
||||
|
||||
@@ -53,13 +57,8 @@ public class EditorHeaderComponent extends JPanel {
|
||||
|
||||
Graphics2D g2d = (Graphics2D)g;
|
||||
|
||||
if (!UIUtil.isUnderGTKLookAndFeel()) {
|
||||
g2d.setPaint(UIUtil.getGradientPaint(0, 0, GRADIENT_C1, 0, c.getHeight(), GRADIENT_C2));
|
||||
g2d.fillRect(1, 1, c.getWidth(), c.getHeight() - 1);
|
||||
g2d.setPaint(null);
|
||||
}
|
||||
|
||||
g.setColor(UIUtil.getBorderColor());
|
||||
g.drawLine(0, c.getHeight() - 1, c.getWidth(), c.getHeight() - 1);
|
||||
g2d.setPaint(UIUtil.getGradientPaint(0, 0, GRADIENT_C1, 0, c.getHeight(), GRADIENT_C2));
|
||||
g2d.fillRect(0, 0, c.getWidth(), c.getHeight() - 1);
|
||||
g2d.setPaint(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user