mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git@git.labs.intellij.net:idea/community
This commit is contained in:
@@ -589,7 +589,7 @@ public class BreakpointManager implements JDOMExternalizable {
|
||||
|
||||
}
|
||||
}
|
||||
catch (InvalidDataException e) {
|
||||
catch (InvalidDataException ignored) {
|
||||
}
|
||||
|
||||
final Element rulesGroup = parentNode.getChild(RULES_GROUP_NAME);
|
||||
@@ -827,7 +827,7 @@ public class BreakpointManager implements JDOMExternalizable {
|
||||
//interaction with RequestManagerImpl
|
||||
public void disableBreakpoints(final DebugProcessImpl debugProcess) {
|
||||
final List<Breakpoint> breakpoints = getBreakpoints();
|
||||
if (breakpoints.size() > 0) {
|
||||
if (!breakpoints.isEmpty()) {
|
||||
final RequestManagerImpl requestManager = debugProcess.getRequestsManager();
|
||||
for (Breakpoint breakpoint : breakpoints) {
|
||||
breakpoint.markVerified(requestManager.isVerified(breakpoint));
|
||||
@@ -843,7 +843,7 @@ public class BreakpointManager implements JDOMExternalizable {
|
||||
|
||||
public void enableBreakpoints(final DebugProcessImpl debugProcess) {
|
||||
final List<Breakpoint> breakpoints = getBreakpoints();
|
||||
if (breakpoints.size() > 0) {
|
||||
if (!breakpoints.isEmpty()) {
|
||||
for (Breakpoint breakpoint : breakpoints) {
|
||||
breakpoint.markVerified(false); // clean cached state
|
||||
breakpoint.createRequest(debugProcess);
|
||||
|
||||
@@ -615,7 +615,7 @@ public class BreakpointTree extends CheckboxTree {
|
||||
// Fix GTK backround
|
||||
if (UIUtil.isUnderGTKLookAndFeel()){
|
||||
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
|
||||
setBackground(background);
|
||||
UIUtil.changeBackGround(this, background);
|
||||
}
|
||||
if (value instanceof CheckedTreeNode) {
|
||||
final CheckedTreeNode node = (CheckedTreeNode)value;
|
||||
|
||||
+12
-3
@@ -415,7 +415,8 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
|
||||
}
|
||||
|
||||
private void setupGutterRenderer() {
|
||||
getHighlighter().setGutterIconRenderer(new MyGutterIconRenderer());
|
||||
MyGutterIconRenderer renderer = new MyGutterIconRenderer(getIcon(), getDescription());
|
||||
getHighlighter().setGutterIconRenderer(renderer);
|
||||
}
|
||||
|
||||
public abstract Key<? extends BreakpointWithHighlighter> getCategory();
|
||||
@@ -623,13 +624,21 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
|
||||
}
|
||||
|
||||
private class MyGutterIconRenderer extends GutterIconRenderer {
|
||||
private final Icon myIcon;
|
||||
private final String myDescription;
|
||||
|
||||
public MyGutterIconRenderer(Icon icon, String description) {
|
||||
myIcon = icon;
|
||||
myDescription = description;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Icon getIcon() {
|
||||
return BreakpointWithHighlighter.this.getIcon();
|
||||
return myIcon;
|
||||
}
|
||||
|
||||
public String getTooltipText() {
|
||||
return getDescription();
|
||||
return myDescription;
|
||||
}
|
||||
|
||||
public AnAction getClickAction() {
|
||||
|
||||
+3
-3
@@ -235,9 +235,9 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
|
||||
final JButton addButton = new JButton(ProjectBundle.message("button.add"));
|
||||
final JButton removeButton = new JButton(ProjectBundle.message("button.remove"));
|
||||
myEditButton = new JButton(ProjectBundle.message("button.edit"));
|
||||
final JButton upButton = new JButton(ProjectBundle.message("button.move.up"));
|
||||
final JButton downButton = new JButton(ProjectBundle.message("button.move.down"));
|
||||
myEditButton = new JButton(ProjectBundle.message("module.classpath.button.edit"));
|
||||
final JButton upButton = new JButton(ProjectBundle.message("module.classpath.button.move.up"));
|
||||
final JButton downButton = new JButton(ProjectBundle.message("module.classpath.button.move.down"));
|
||||
final JButton analyzeButton = isAnalyzeShown ? new JButton(ProjectBundle.message("classpath.panel.analyze")) : null;
|
||||
|
||||
final JPanel panel = new JPanel(new GridBagLayout());
|
||||
|
||||
+4
@@ -17,6 +17,7 @@ package com.intellij.openapi.roots.ui.configuration.libraries.impl;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryEx;
|
||||
import com.intellij.openapi.roots.libraries.*;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryPresentationManager;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
|
||||
@@ -124,6 +125,9 @@ public class LibraryPresentationManagerImpl extends LibraryPresentationManager {
|
||||
|
||||
@NotNull
|
||||
private static VirtualFile[] getLibraryFiles(@NotNull Library library, @Nullable StructureConfigurableContext context) {
|
||||
if (((LibraryEx)library).isDisposed()) {
|
||||
return VirtualFile.EMPTY_ARRAY;
|
||||
}
|
||||
return context != null ? context.getLibraryFiles(library, OrderRootType.CLASSES) : library.getFiles(OrderRootType.CLASSES);
|
||||
}
|
||||
|
||||
|
||||
+11
-5
@@ -31,6 +31,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
@@ -177,7 +178,16 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
final PsiElement lastElement = file.findElementAt(offset - 1);
|
||||
final JavaAwareCompletionData completionData = ApplicationManager.getApplication().runReadAction(new Computable<JavaAwareCompletionData>() {
|
||||
public JavaAwareCompletionData compute() {
|
||||
return getCompletionDataByElementInner(lastElement);
|
||||
if (lastElement != null) {
|
||||
if (!lastElement.isValid()) {
|
||||
throw new ProcessCanceledException();
|
||||
}
|
||||
if (PsiUtil.isLanguageLevel5OrHigher(lastElement)) {
|
||||
return ourJava15CompletionData;
|
||||
}
|
||||
}
|
||||
|
||||
return ourJavaCompletionData;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -351,10 +361,6 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
}
|
||||
}
|
||||
|
||||
private static JavaAwareCompletionData getCompletionDataByElementInner(PsiElement element) {
|
||||
return element != null && PsiUtil.isLanguageLevel5OrHigher(element) ? ourJava15CompletionData : ourJavaCompletionData;
|
||||
}
|
||||
|
||||
|
||||
public String advertise(@NotNull final CompletionParameters parameters) {
|
||||
if (!(parameters.getOriginalFile() instanceof PsiJavaFile)) return null;
|
||||
|
||||
+26
-16
@@ -20,6 +20,7 @@ import com.intellij.codeInspection.*;
|
||||
import com.intellij.ide.fileTemplates.FileTemplate;
|
||||
import com.intellij.ide.fileTemplates.FileTemplateManager;
|
||||
import com.intellij.ide.fileTemplates.JavaTemplateUtil;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -113,26 +114,35 @@ class CatchBodyVisitor extends JavaRecursiveElementWalkingVisitor {
|
||||
|
||||
private static LocalQuickFix[] createQuickFix(final PsiCatchSection section) {
|
||||
FileTemplate template = FileTemplateManager.getInstance().getCodeTemplate(JavaTemplateUtil.TEMPLATE_CATCH_BODY);
|
||||
final Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
final PsiParameter parameter = section.getParameter();
|
||||
if (parameter == null) return;
|
||||
PsiCodeBlock catchBlock = section.getCatchBlock();
|
||||
if (catchBlock == null) return;
|
||||
PsiType type = parameter.getType();
|
||||
if (!(type instanceof PsiClassType)) return;
|
||||
final PsiJavaParserFacade elementFactory = JavaPsiFacade.getInstance(section.getProject()).getParserFacade();
|
||||
try {
|
||||
PsiCatchSection sectionTemplate = elementFactory.createCatchSection((PsiClassType)type, parameter.getName(), parameter);
|
||||
section.replace(sectionTemplate);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
ReplaceWithFileTemplateFix replaceWithFileTemplateFix = new ReplaceWithFileTemplateFix() {
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
final PsiParameter parameter = section.getParameter();
|
||||
if (parameter == null) return;
|
||||
PsiCodeBlock catchBlock = section.getCatchBlock();
|
||||
if (catchBlock == null) return;
|
||||
PsiType type = parameter.getType();
|
||||
if (!(type instanceof PsiClassType)) return;
|
||||
final PsiJavaParserFacade elementFactory = JavaPsiFacade.getInstance(section.getProject()).getParserFacade();
|
||||
try {
|
||||
PsiCatchSection sectionTemplate = elementFactory.createCatchSection((PsiClassType)type, parameter.getName(), parameter);
|
||||
section.replace(sectionTemplate);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
};
|
||||
LocalQuickFix editFileTemplateFix = DefaultFileTemplateUsageInspection.createEditFileTemplateFix(template, replaceWithFileTemplateFix);
|
||||
LocalQuickFix editFileTemplateFix = DefaultFileTemplateUsageInspection.createEditFileTemplateFix(template, runnable);
|
||||
if (template.isDefault()) {
|
||||
return new LocalQuickFix[]{editFileTemplateFix};
|
||||
}
|
||||
|
||||
+56
-22
@@ -15,14 +15,17 @@
|
||||
*/
|
||||
package com.intellij.codeInspection.defaultFileTemplateUsage;
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.ide.fileTemplates.FileTemplate;
|
||||
import com.intellij.ide.fileTemplates.FileTemplateManager;
|
||||
import com.intellij.ide.fileTemplates.impl.FileTemplateConfigurable;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -119,31 +122,62 @@ public class DefaultFileTemplateUsageInspection extends BaseJavaLocalInspectionT
|
||||
return new InspectionOptions(this).getComponent();
|
||||
}
|
||||
|
||||
public static LocalQuickFix createEditFileTemplateFix(final FileTemplate templateToEdit, final LocalQuickFix replaceTemplateFix) {
|
||||
return new LocalQuickFix() {
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return InspectionsBundle.message("default.file.template.edit.template");
|
||||
}
|
||||
public static LocalQuickFix createEditFileTemplateFix(final FileTemplate templateToEdit, final Runnable replaceTemplateFix) {
|
||||
return new MyLocalQuickFix(templateToEdit, replaceTemplateFix);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return getName();
|
||||
}
|
||||
private static class MyLocalQuickFix implements LocalQuickFix, IntentionAction {
|
||||
private final FileTemplate myTemplateToEdit;
|
||||
private final Runnable myReplaceTemplateFix;
|
||||
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
final FileTemplateConfigurable configurable = new FileTemplateConfigurable();
|
||||
SwingUtilities.invokeLater(new Runnable(){
|
||||
public void run() {
|
||||
configurable.setTemplate(templateToEdit, null);
|
||||
}
|
||||
});
|
||||
boolean ok = ShowSettingsUtil.getInstance().editConfigurable(project, configurable);
|
||||
if (ok) {
|
||||
replaceTemplateFix.applyFix(project, descriptor);
|
||||
FileTemplateManager.getInstance().saveAll();
|
||||
public MyLocalQuickFix(FileTemplate templateToEdit, Runnable replaceTemplateFix) {
|
||||
myTemplateToEdit = templateToEdit;
|
||||
myReplaceTemplateFix = replaceTemplateFix;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return InspectionsBundle.message("default.file.template.edit.template");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
invoke(project, null, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
final FileTemplateConfigurable configurable = new FileTemplateConfigurable();
|
||||
SwingUtilities.invokeLater(new Runnable(){
|
||||
public void run() {
|
||||
configurable.setTemplate(myTemplateToEdit, null);
|
||||
}
|
||||
});
|
||||
boolean ok = ShowSettingsUtil.getInstance().editConfigurable(project, configurable);
|
||||
if (ok) {
|
||||
myReplaceTemplateFix.run();
|
||||
FileTemplateManager.getInstance().saveAll();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+57
-47
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.CodeInsightUtil;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.ide.fileTemplates.FileTemplate;
|
||||
import com.intellij.ide.fileTemplates.FileTemplateManager;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -82,61 +83,70 @@ public class FileHeaderChecker {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Properties computeProperties(final Matcher matcher, final TIntObjectHashMap<String> offsetToProperty) {
|
||||
Properties properties = new Properties(FileTemplateManager.getInstance().getDefaultProperties());
|
||||
int[] offsets = offsetToProperty.keys();
|
||||
Arrays.sort(offsets);
|
||||
|
||||
for (int i = 0; i < offsets.length; i++) {
|
||||
final int offset = offsets[i];
|
||||
String propName = offsetToProperty.get(offset);
|
||||
int groupNum = i + 2; // first group is whole doc comment
|
||||
String propValue = matcher.group(groupNum);
|
||||
properties.put(propName, propValue);
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
private static LocalQuickFix[] createQuickFix(final PsiDocComment element,
|
||||
final Matcher matcher,
|
||||
final TIntObjectHashMap<String> offsetToProperty) {
|
||||
final FileTemplate template = FileTemplateManager.getInstance().getPattern(FileTemplateManager.FILE_HEADER_TEMPLATE_NAME);
|
||||
final ReplaceWithFileTemplateFix replaceTemplateFix = new ReplaceWithFileTemplateFix() {
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
if (!element.isValid()) return;
|
||||
if (!CodeInsightUtil.preparePsiElementsForWrite(element)) return;
|
||||
String newText;
|
||||
try {
|
||||
newText = template.getText(computeProperties(matcher, offsetToProperty));
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
int offset = element.getTextRange().getStartOffset();
|
||||
PsiFile psiFile = element.getContainingFile();
|
||||
if (psiFile == null) return;
|
||||
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
|
||||
Document document = documentManager.getDocument(psiFile);
|
||||
if (document == null) return;
|
||||
final Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
if (!element.isValid()) return;
|
||||
if (!CodeInsightUtil.preparePsiElementsForWrite(element)) return;
|
||||
String newText;
|
||||
try {
|
||||
newText = template.getText(computeProperties(matcher, offsetToProperty));
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
int offset = element.getTextRange().getStartOffset();
|
||||
PsiFile psiFile = element.getContainingFile();
|
||||
if (psiFile == null) return;
|
||||
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(psiFile.getProject());
|
||||
Document document = documentManager.getDocument(psiFile);
|
||||
if (document == null) return;
|
||||
|
||||
element.delete();
|
||||
documentManager.doPostponedOperationsAndUnblockDocument(document);
|
||||
documentManager.commitDocument(document);
|
||||
element.delete();
|
||||
documentManager.doPostponedOperationsAndUnblockDocument(document);
|
||||
documentManager.commitDocument(document);
|
||||
|
||||
document.insertString(offset, newText);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
LOG.error("Cannot create doc comment from text: '"+newText+"'",e);
|
||||
}
|
||||
}
|
||||
|
||||
private Properties computeProperties(final Matcher matcher, final TIntObjectHashMap<String> offsetToProperty) {
|
||||
Properties properties = new Properties(FileTemplateManager.getInstance().getDefaultProperties());
|
||||
int[] offsets = offsetToProperty.keys();
|
||||
Arrays.sort(offsets);
|
||||
|
||||
for (int i = 0; i < offsets.length; i++) {
|
||||
final int offset = offsets[i];
|
||||
String propName = offsetToProperty.get(offset);
|
||||
int groupNum = i + 2; // first group is whole doc comment
|
||||
String propValue = matcher.group(groupNum);
|
||||
properties.put(propName, propValue);
|
||||
}
|
||||
|
||||
return properties;
|
||||
document.insertString(offset, newText);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
LOG.error("Cannot create doc comment from text: '" + newText + "'", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
final LocalQuickFix editFileTemplateFix = DefaultFileTemplateUsageInspection.createEditFileTemplateFix(template, replaceTemplateFix);
|
||||
|
||||
final ReplaceWithFileTemplateFix replaceTemplateFix = new ReplaceWithFileTemplateFix() {
|
||||
public void applyFix(@NotNull final Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
runnable.run();
|
||||
}
|
||||
};
|
||||
final LocalQuickFix editFileTemplateFix = DefaultFileTemplateUsageInspection.createEditFileTemplateFix(template, runnable);
|
||||
if (template.isDefault()) {
|
||||
return new LocalQuickFix[]{editFileTemplateFix};
|
||||
}
|
||||
|
||||
+32
-22
@@ -23,6 +23,7 @@ import com.intellij.codeInspection.*;
|
||||
import com.intellij.ide.fileTemplates.FileTemplate;
|
||||
import com.intellij.ide.fileTemplates.FileTemplateManager;
|
||||
import com.intellij.ide.fileTemplates.JavaTemplateUtil;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
@@ -168,31 +169,40 @@ public class MethodBodyChecker {
|
||||
return null;
|
||||
}
|
||||
|
||||
final ReplaceWithFileTemplateFix replaceWithFileTemplateFix = new ReplaceWithFileTemplateFix() {
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
PsiType returnType = method.getReturnType();
|
||||
if (method.isConstructor() || returnType == null) return;
|
||||
PsiCodeBlock body = method.getBody();
|
||||
if (body == null) return;
|
||||
if (!CodeInsightUtil.preparePsiElementsForWrite(body)) return;
|
||||
PsiClass aClass = method.getContainingClass();
|
||||
if (aClass == null) return;
|
||||
List<HierarchicalMethodSignature> superSignatures = method.getHierarchicalMethodSignature().getSuperSignatures();
|
||||
try {
|
||||
PsiMethod templateMethod = JavaPsiFacade.getInstance(method.getProject()).getElementFactory().createMethod("x", returnType);
|
||||
setupMethodBody(superSignatures, templateMethod, aClass, false);
|
||||
final PsiCodeBlock templateBody = templateMethod.getBody();
|
||||
if (templateBody == null) return;
|
||||
final Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
PsiType returnType = method.getReturnType();
|
||||
if (method.isConstructor() || returnType == null) return;
|
||||
PsiCodeBlock body = method.getBody();
|
||||
if (body == null) return;
|
||||
if (!CodeInsightUtil.preparePsiElementsForWrite(body)) return;
|
||||
PsiClass aClass = method.getContainingClass();
|
||||
if (aClass == null) return;
|
||||
List<HierarchicalMethodSignature> superSignatures = method.getHierarchicalMethodSignature().getSuperSignatures();
|
||||
try {
|
||||
PsiMethod templateMethod = JavaPsiFacade.getInstance(method.getProject()).getElementFactory().createMethod("x", returnType);
|
||||
setupMethodBody(superSignatures, templateMethod, aClass, false);
|
||||
final PsiCodeBlock templateBody = templateMethod.getBody();
|
||||
if (templateBody == null) return;
|
||||
|
||||
PsiElement newBody = body.replace(templateBody);
|
||||
CodeStyleManager.getInstance(project).reformat(newBody);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
PsiElement newBody = body.replace(templateBody);
|
||||
CodeStyleManager.getInstance(aClass.getManager()).reformat(newBody);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
LocalQuickFix editFileTemplateFix = DefaultFileTemplateUsageInspection.createEditFileTemplateFix(template, replaceWithFileTemplateFix);
|
||||
final ReplaceWithFileTemplateFix replaceWithFileTemplateFix = new ReplaceWithFileTemplateFix() {
|
||||
public void applyFix(@NotNull final Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
runnable.run();
|
||||
}
|
||||
};
|
||||
LocalQuickFix editFileTemplateFix = DefaultFileTemplateUsageInspection.createEditFileTemplateFix(template, runnable);
|
||||
if (template != null && template.isDefault()) {
|
||||
return new LocalQuickFix[]{editFileTemplateFix};
|
||||
}
|
||||
|
||||
+33
-4
@@ -26,12 +26,19 @@ import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
|
||||
import com.intellij.codeInspection.ex.UnfairLocalInspectionTool;
|
||||
import com.intellij.codeInspection.reference.EntryPoint;
|
||||
import com.intellij.codeInspection.util.SpecialAnnotationsUtil;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.ExtensionPointListener;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.extensions.PluginDescriptor;
|
||||
import com.intellij.openapi.util.JDOMExternalizableStringList;
|
||||
import com.intellij.profile.codeInspection.InspectionProfileManager;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.PsiModifierListOwner;
|
||||
import com.intellij.psi.util.PropertyUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.intellij.lang.annotations.Pattern;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -49,7 +56,7 @@ import java.util.List;
|
||||
* Date: 17-Feb-2006
|
||||
*/
|
||||
public class UnusedSymbolLocalInspection extends BaseJavaLocalInspectionTool implements UnfairLocalInspectionTool {
|
||||
private static final Collection<String> STANDARD_INJECTION_ANNOS = Collections.unmodifiableCollection(new HashSet<String>(Arrays.asList(
|
||||
private static final Collection<String> STANDARD_INJECTION_ANNOS = Collections.unmodifiableCollection(new THashSet<String>(Arrays.asList(
|
||||
"javax.annotation.Resource",
|
||||
"javax.ejb.EJB",
|
||||
"javax.xml.ws.WebServiceRef",
|
||||
@@ -70,6 +77,28 @@ public class UnusedSymbolLocalInspection extends BaseJavaLocalInspectionTool imp
|
||||
public boolean REPORT_PARAMETER_FOR_PUBLIC_METHODS = true;
|
||||
public JDOMExternalizableStringList INJECTION_ANNOS = new JDOMExternalizableStringList();
|
||||
|
||||
static {
|
||||
final ExtensionPoint<EntryPoint> point = Extensions.getRootArea().getExtensionPoint(ExtensionPoints.DEAD_CODE_TOOL);
|
||||
point.addExtensionPointListener(new ExtensionPointListener<EntryPoint>() {
|
||||
@Override
|
||||
public void extensionAdded(@NotNull EntryPoint extension, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
extensionRemoved(extension, pluginDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extensionRemoved(@NotNull EntryPoint extension, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
ANNOTATIONS = null;
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (ApplicationManager.getApplication().isDisposed()) return;
|
||||
InspectionProfileManager.getInstance().fireProfileChanged(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getGroupDisplayName() {
|
||||
return GroupNames.DECLARATION_REDUNDANCY;
|
||||
@@ -113,7 +142,6 @@ public class UnusedSymbolLocalInspection extends BaseJavaLocalInspectionTool imp
|
||||
private JPanel myPanel;
|
||||
|
||||
public OptionsPanel() {
|
||||
|
||||
myCheckLocalVariablesCheckBox.setSelected(LOCAL_VARIABLE);
|
||||
myCheckClassesCheckBox.setSelected(CLASS);
|
||||
myCheckFieldsCheckBox.setSelected(FIELD);
|
||||
@@ -169,8 +197,9 @@ public class UnusedSymbolLocalInspection extends BaseJavaLocalInspectionTool imp
|
||||
List<String> annotations = ANNOTATIONS;
|
||||
if (annotations == null) {
|
||||
annotations = new ArrayList<String>();
|
||||
for (Object extension : Extensions.getExtensions(ExtensionPoints.DEAD_CODE_TOOL)) {
|
||||
final String[] ignoredAnnotations = ((EntryPoint)extension).getIgnoreAnnotations();
|
||||
EntryPoint[] extensions = Extensions.getExtensions(ExtensionPoints.DEAD_CODE_TOOL, null);
|
||||
for (EntryPoint extension : extensions) {
|
||||
final String[] ignoredAnnotations = extension.getIgnoreAnnotations();
|
||||
if (ignoredAnnotations != null) {
|
||||
ContainerUtil.addAll(annotations, ignoredAnnotations);
|
||||
}
|
||||
|
||||
@@ -51,10 +51,12 @@ public class JavaFileElementType extends IStubFileElementType<PsiJavaFileStub> {
|
||||
super("java.FILE", StdLanguages.JAVA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StubBuilder getBuilder() {
|
||||
return new JavaFileStubBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStubVersion() {
|
||||
return STUB_VERSION;
|
||||
}
|
||||
@@ -65,6 +67,7 @@ public class JavaFileElementType extends IStubFileElementType<PsiJavaFileStub> {
|
||||
return dir == null || dir.getUserData(LanguageLevel.KEY) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ASTNode parseContents(final ASTNode chameleon) {
|
||||
if (JavaParserDefinition.USE_NEW_PARSER) {
|
||||
final PsiBuilder builder = JavaParserUtil.createBuilder(chameleon);
|
||||
@@ -84,22 +87,26 @@ public class JavaFileElementType extends IStubFileElementType<PsiJavaFileStub> {
|
||||
return FileTextParsing.parseFileText(manager, lexer, seq, 0, seq.length(), node.getCharTable());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExternalId() {
|
||||
return "java.FILE";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(final PsiJavaFileStub stub, final StubOutputStream dataStream)
|
||||
throws IOException {
|
||||
dataStream.writeBoolean(stub.isCompiled());
|
||||
dataStream.writeName(stub.getPackageName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiJavaFileStub deserialize(final StubInputStream dataStream, final StubElement parentStub) throws IOException {
|
||||
boolean compiled = dataStream.readBoolean();
|
||||
StringRef packName = dataStream.readName();
|
||||
return new PsiJavaFileStubImpl(packName, compiled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void indexStub(final PsiJavaFileStub stub, final IndexSink sink) {
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -47,11 +47,11 @@ public class JavaConcatenationInjectorManager implements ModificationTracker {
|
||||
public JavaConcatenationInjectorManager(Project project, PsiManagerEx psiManagerEx) {
|
||||
final ExtensionPoint<ConcatenationAwareInjector> concatPoint = Extensions.getArea(project).getExtensionPoint(CONCATENATION_INJECTOR_EP_NAME);
|
||||
concatPoint.addExtensionPointListener(new ExtensionPointListener<ConcatenationAwareInjector>() {
|
||||
public void extensionAdded(ConcatenationAwareInjector injector, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
public void extensionAdded(@NotNull ConcatenationAwareInjector injector, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
registerConcatenationInjector(injector);
|
||||
}
|
||||
|
||||
public void extensionRemoved(ConcatenationAwareInjector injector, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
public void extensionRemoved(@NotNull ConcatenationAwareInjector injector, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
unregisterConcatenationInjector(injector);
|
||||
}
|
||||
});
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
|
||||
public class <warning descr="Class 'WithMain' is never used">WithMain</warning> {
|
||||
@MyAnno
|
||||
public void <warning descr="Method 'myTestMethod()' is never used">myTestMethod</warning>(){}
|
||||
}
|
||||
|
||||
@interface MyAnno {
|
||||
|
||||
}
|
||||
+86
-1
@@ -1,6 +1,21 @@
|
||||
package com.intellij.codeInsight.daemon;
|
||||
|
||||
import com.intellij.ExtensionPoints;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
|
||||
import com.intellij.codeInspection.reference.EntryPoint;
|
||||
import com.intellij.codeInspection.reference.RefElement;
|
||||
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is for "lightweight" tests only, i.e. those which can run inside default light project set up
|
||||
@@ -13,12 +28,17 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, checkInfos);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
return new LocalInspectionTool[]{new UnusedSymbolLocalInspection()};
|
||||
}
|
||||
|
||||
public void testDuplicateAnnotations() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testSwitchByString() throws Exception {
|
||||
doTest(true, false);
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDiamondPos1() throws Exception {
|
||||
@@ -56,4 +76,69 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testDiamondNeg5() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testDynamicallyAddIgnoredAnnotations() throws Exception {
|
||||
ExtensionPoint<EntryPoint> point = Extensions.getRootArea().getExtensionPoint(ExtensionPoints.DEAD_CODE_TOOL);
|
||||
EntryPoint extension = new EntryPoint() {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "duh";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEntryPoint(RefElement refElement, PsiElement psiElement) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEntryPoint(PsiElement psiElement) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(boolean selected) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(Element element) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(Element element) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getIgnoreAnnotations() {
|
||||
return new String[]{"MyAnno"};
|
||||
}
|
||||
};
|
||||
|
||||
UnusedDeclarationInspection deadCodeInspection = new UnusedDeclarationInspection();
|
||||
enableInspectionTool(deadCodeInspection);
|
||||
|
||||
doTest(true, false);
|
||||
List<HighlightInfo> infos = DaemonAnalyzerTestCase.filter(doHighlighting(), HighlightSeverity.WARNING);
|
||||
assertEquals(2, infos.size()); // unused class and unused method
|
||||
|
||||
try {
|
||||
point.registerExtension(extension);
|
||||
|
||||
infos = DaemonAnalyzerTestCase.filter(doHighlighting(), HighlightSeverity.WARNING);
|
||||
HighlightInfo info = assertOneElement(infos);
|
||||
assertEquals("Class 'WithMain' is never used", info.description);
|
||||
}
|
||||
finally {
|
||||
point.unregisterExtension(extension);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-2
@@ -3,10 +3,10 @@ package com.intellij.codeInsight.daemon;
|
||||
import com.intellij.ExtensionPoints;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.accessStaticViaInstance.AccessStaticViaInstance;
|
||||
import com.intellij.codeInspection.reference.EntryPoint;
|
||||
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
|
||||
import com.intellij.codeInspection.deprecation.DeprecationInspection;
|
||||
import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection;
|
||||
import com.intellij.codeInspection.reference.EntryPoint;
|
||||
import com.intellij.codeInspection.reference.RefElement;
|
||||
import com.intellij.codeInspection.sillyAssignment.SillyAssignmentInspection;
|
||||
import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection;
|
||||
@@ -56,7 +56,6 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
setLanguageLevel(LanguageLevel.JDK_1_4);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
myUnusedSymbolLocalInspection = new UnusedSymbolLocalInspection();
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package com.intellij.openapi.extensions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface ExtensionPointListener<T> {
|
||||
void extensionAdded(T extension, @Nullable final PluginDescriptor pluginDescriptor);
|
||||
void extensionRemoved(T extension, @Nullable final PluginDescriptor pluginDescriptor);
|
||||
void extensionAdded(@NotNull T extension, @Nullable final PluginDescriptor pluginDescriptor);
|
||||
void extensionRemoved(@NotNull T extension, @Nullable final PluginDescriptor pluginDescriptor);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public abstract class SmartExtensionPoint<Extension,V> implements ExtensionPoint
|
||||
}
|
||||
}
|
||||
|
||||
public final void extensionAdded(final Extension extension, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
public final void extensionAdded(@NotNull final Extension extension, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
dropCache();
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public abstract class SmartExtensionPoint<Extension,V> implements ExtensionPoint
|
||||
}
|
||||
}
|
||||
|
||||
public final void extensionRemoved(final Extension extension, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
public final void extensionRemoved(@NotNull final Extension extension, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
dropCache();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -250,7 +250,7 @@ public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
|
||||
getExtensionPoint(EPAvailabilityListenerExtension.EXTENSION_POINT_NAME).addExtensionPointListener(new ExtensionPointListener() {
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public void extensionRemoved(Object extension, final PluginDescriptor pluginDescriptor) {
|
||||
public void extensionRemoved(@NotNull Object extension, final PluginDescriptor pluginDescriptor) {
|
||||
EPAvailabilityListenerExtension epListenerExtension = (EPAvailabilityListenerExtension) extension;
|
||||
Collection<ExtensionPointAvailabilityListener> listeners = myAvailabilityListeners.get(epListenerExtension.getExtensionPointName());
|
||||
for (Iterator<ExtensionPointAvailabilityListener> iterator = listeners.iterator(); iterator.hasNext();) {
|
||||
@@ -263,7 +263,7 @@ public class ExtensionsAreaImpl implements ExtensionsArea {
|
||||
myLogger.warn("Failed to find EP availability listener: " + epListenerExtension.getListenerClass());
|
||||
}
|
||||
|
||||
public void extensionAdded(Object extension, final PluginDescriptor pluginDescriptor) {
|
||||
public void extensionAdded(@NotNull Object extension, final PluginDescriptor pluginDescriptor) {
|
||||
EPAvailabilityListenerExtension epListenerExtension = (EPAvailabilityListenerExtension) extension;
|
||||
try {
|
||||
String epName = epListenerExtension.getExtensionPointName();
|
||||
|
||||
+5
-4
@@ -17,6 +17,7 @@ package com.intellij.openapi.extensions.impl;
|
||||
|
||||
import com.intellij.openapi.extensions.*;
|
||||
import junit.framework.TestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.picocontainer.defaults.DefaultPicoContainer;
|
||||
|
||||
/**
|
||||
@@ -101,12 +102,12 @@ public class ExtensionPointImplTest extends TestCase {
|
||||
final boolean removed[] = new boolean[1];
|
||||
extensionPoint.addExtensionPointListener(new ExtensionPointListener() {
|
||||
@Override
|
||||
public void extensionAdded(Object extension, final PluginDescriptor pluginDescriptor) {
|
||||
public void extensionAdded(@NotNull Object extension, final PluginDescriptor pluginDescriptor) {
|
||||
added[0] = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extensionRemoved(Object extension, final PluginDescriptor pluginDescriptor) {
|
||||
public void extensionRemoved(@NotNull Object extension, final PluginDescriptor pluginDescriptor) {
|
||||
removed[0] = true;
|
||||
}
|
||||
});
|
||||
@@ -128,12 +129,12 @@ public class ExtensionPointImplTest extends TestCase {
|
||||
assertFalse(added[0]);
|
||||
extensionPoint.addExtensionPointListener(new ExtensionPointListener() {
|
||||
@Override
|
||||
public void extensionAdded(Object extension, final PluginDescriptor pluginDescriptor) {
|
||||
public void extensionAdded(@NotNull Object extension, final PluginDescriptor pluginDescriptor) {
|
||||
added[0] = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extensionRemoved(Object extension, final PluginDescriptor pluginDescriptor) {
|
||||
public void extensionRemoved(@NotNull Object extension, final PluginDescriptor pluginDescriptor) {
|
||||
}
|
||||
});
|
||||
assertTrue(added[0]);
|
||||
|
||||
+3
-2
@@ -17,6 +17,7 @@ package com.intellij.openapi.extensions.impl;
|
||||
|
||||
import com.intellij.openapi.extensions.*;
|
||||
import junit.framework.TestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.picocontainer.MutablePicoContainer;
|
||||
import org.picocontainer.defaults.DefaultPicoContainer;
|
||||
|
||||
@@ -56,11 +57,11 @@ public class ExtensionsImplTest extends TestCase {
|
||||
removed[0] = false;
|
||||
extensionsArea.getExtensionPoint(EXTENSION_POINT_NAME_1).addExtensionPointListener(new ExtensionPointListener() {
|
||||
@Override
|
||||
public void extensionAdded(Object extension, final PluginDescriptor pluginDescriptor) {
|
||||
public void extensionAdded(@NotNull Object extension, final PluginDescriptor pluginDescriptor) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extensionRemoved(Object extension, final PluginDescriptor pluginDescriptor) {
|
||||
public void extensionRemoved(@NotNull Object extension, final PluginDescriptor pluginDescriptor) {
|
||||
removed[0] = true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -38,7 +38,7 @@ public abstract class EntryPoint implements JDOMExternalizable , Cloneable {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String [] getIgnoreAnnotations() {
|
||||
public String[] getIgnoreAnnotations() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.lang;
|
||||
|
||||
|
||||
public interface LighterASTTokenNode extends LighterASTNode {
|
||||
/**
|
||||
* <b>Note</b>: a text returned may be linked back to file content text and therefore should be internalized
|
||||
* through {@linkplain com.intellij.util.CharTable} if referenced as is.
|
||||
* @return text of a token
|
||||
*/
|
||||
CharSequence getText();
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class SerializationManagerImpl extends SerializationManager implements Ap
|
||||
private final Map<StubSerializer<? extends StubElement>, Integer> mySerializerToId = new HashMap<StubSerializer<? extends StubElement>, Integer>();
|
||||
private final List<StubSerializer<? extends StubElement>> myAllSerializers = new ArrayList<StubSerializer<? extends StubElement>>();
|
||||
private final AtomicBoolean myNameStorageCrashed = new AtomicBoolean(false);
|
||||
private final File myFile = new File(PathManager.getSystemPath() + "/index/rep.names");
|
||||
private final File myFile = new File(PathManager.getIndexRoot(), "rep.names");
|
||||
private boolean mySerializersLoaded = false;
|
||||
|
||||
public SerializationManagerImpl() {
|
||||
|
||||
+10
-1
@@ -67,6 +67,15 @@ public class ColorAndFontDescriptionPanel extends JPanel {
|
||||
|
||||
add(settingsPanel, BorderLayout.CENTER);
|
||||
setBorder(BorderFactory.createEmptyBorder(4, 0, 4, 4));
|
||||
|
||||
myEffectsCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value == null) value = "Invalid";
|
||||
return super.getListCellRendererComponent(list, value, index, isSelected,
|
||||
cellHasFocus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private JPanel createSettingsPanel() {
|
||||
@@ -366,7 +375,7 @@ public class ColorAndFontDescriptionPanel extends JPanel {
|
||||
myEffectsCombo.setSelectedItem(BOLD_DOTTED_LINE_EFFECT);
|
||||
}
|
||||
else {
|
||||
LOG.assertTrue(false);
|
||||
myEffectsCombo.setSelectedItem(null);
|
||||
}
|
||||
updatingEffects = false;
|
||||
}
|
||||
|
||||
+40
-33
@@ -188,31 +188,32 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
final int offset2,
|
||||
final CompletionContext context,
|
||||
final FileCopyPatcher patcher, final Editor editor, final int invocationCount) {
|
||||
final Ref<Pair<CompletionContext, PsiElement>> ref = Ref.create(null);
|
||||
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ref.set(insertDummyIdentifier(context, patcher, context.file, context.editor));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
final PsiElement insertedElement = ref.get().getSecond();
|
||||
final CompletionContext newContext = ref.get().getFirst();
|
||||
insertedElement.putUserData(CompletionContext.COMPLETION_CONTEXT_KEY, newContext);
|
||||
|
||||
PsiFile originalFile = context.file;
|
||||
|
||||
final CompletionParameters parameters = new CompletionParameters(insertedElement, originalFile, myCompletionType, newContext.getStartOffset(), invocationCount);
|
||||
final CompletionParameters parameters = createCompletionParameters(context, patcher, invocationCount);
|
||||
|
||||
final Semaphore freezeSemaphore = new Semaphore();
|
||||
freezeSemaphore.down();
|
||||
final CompletionProgressIndicator indicator = new CompletionProgressIndicator(editor, parameters, this, freezeSemaphore, context.getOffsetMap());
|
||||
|
||||
final AtomicReference<LookupElement[]> data = startCompletionThread(parameters, indicator);
|
||||
|
||||
if (!invokedExplicitly) {
|
||||
indicator.notifyBackgrounded();
|
||||
return;
|
||||
}
|
||||
|
||||
if (freezeSemaphore.waitFor(2000)) {
|
||||
final LookupElement[] allItems = data.get();
|
||||
if (allItems != null) { // the completion is really finished, now we may auto-insert or show lookup
|
||||
completionFinished(offset1, offset2, indicator, allItems);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
indicator.notifyBackgrounded();
|
||||
indicator.showLookup();
|
||||
}
|
||||
|
||||
private AtomicReference<LookupElement[]> startCompletionThread(final CompletionParameters parameters, final CompletionProgressIndicator indicator) {
|
||||
final AtomicReference<LookupElement[]> data = new AtomicReference<LookupElement[]>(null);
|
||||
final Semaphore startSemaphore = new Semaphore();
|
||||
startSemaphore.down();
|
||||
@@ -245,22 +246,28 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
}
|
||||
|
||||
startSemaphore.waitFor();
|
||||
return data;
|
||||
}
|
||||
|
||||
if (!invokedExplicitly) {
|
||||
indicator.notifyBackgrounded();
|
||||
return;
|
||||
}
|
||||
|
||||
if (freezeSemaphore.waitFor(2000)) {
|
||||
final LookupElement[] allItems = data.get();
|
||||
if (allItems != null) { // the completion is really finished, now we may auto-insert or show lookup
|
||||
completionFinished(offset1, offset2, indicator, allItems);
|
||||
return;
|
||||
private CompletionParameters createCompletionParameters(final CompletionContext context, final FileCopyPatcher patcher, int invocationCount) {
|
||||
final Ref<Pair<CompletionContext, PsiElement>> ref = Ref.create(null);
|
||||
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ref.set(insertDummyIdentifier(context, patcher, context.file, context.editor));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
indicator.notifyBackgrounded();
|
||||
indicator.showLookup();
|
||||
final PsiElement insertedElement = ref.get().getSecond();
|
||||
final CompletionContext newContext = ref.get().getFirst();
|
||||
insertedElement.putUserData(CompletionContext.COMPLETION_CONTEXT_KEY, newContext);
|
||||
|
||||
return new CompletionParameters(insertedElement, newContext.file, myCompletionType, newContext.getStartOffset(), invocationCount);
|
||||
}
|
||||
|
||||
private AutoCompletionDecision shouldAutoComplete(
|
||||
|
||||
@@ -188,7 +188,6 @@ class DaemonListeners implements Disposable {
|
||||
});
|
||||
|
||||
connection.subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
|
||||
|
||||
public void enteredDumbMode() {
|
||||
stopDaemon(true);
|
||||
}
|
||||
@@ -312,7 +311,7 @@ class DaemonListeners implements Disposable {
|
||||
if (vcsIsThinking) return Result.UNCHANGED; // do not modify file which is in the process of updating
|
||||
|
||||
FileStatus status = FileStatusManager.getInstance(project).getStatus(virtualFile);
|
||||
|
||||
if (status == FileStatus.UNKNOWN) return Result.NOT_SURE;
|
||||
return status == FileStatus.MODIFIED || status == FileStatus.ADDED ? Result.CHANGED : Result.UNCHANGED;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -111,11 +111,11 @@ public class DefaultHighlightVisitor implements HighlightVisitor, DumbAware {
|
||||
|
||||
static {
|
||||
LanguageAnnotators.INSTANCE.addListener(new ExtensionPointListener<Annotator>() {
|
||||
public void extensionAdded(Annotator extension, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
public void extensionAdded(@NotNull Annotator extension, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
cachedAnnotators.clear();
|
||||
}
|
||||
|
||||
public void extensionRemoved(Annotator extension, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
public void extensionRemoved(@NotNull Annotator extension, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
cachedAnnotators.clear();
|
||||
}
|
||||
});
|
||||
|
||||
+2
-2
@@ -64,11 +64,11 @@ public class IntentionManagerImpl extends IntentionManager {
|
||||
final ExtensionPoint<IntentionActionBean> point = Extensions.getArea(null).getExtensionPoint(EP_INTENTION_ACTIONS);
|
||||
|
||||
point.addExtensionPointListener(new ExtensionPointListener<IntentionActionBean>() {
|
||||
public void extensionAdded(final IntentionActionBean extension, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
public void extensionAdded(@NotNull final IntentionActionBean extension, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
registerIntentionFromBean(extension);
|
||||
}
|
||||
|
||||
public void extensionRemoved(final IntentionActionBean extension, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
public void extensionRemoved(@NotNull final IntentionActionBean extension, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public abstract class IntentionSettingsTree {
|
||||
SimpleTextAttributes attributes = node.getUserObject() instanceof IntentionActionMetaData ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
|
||||
final String text = getNodeText(node);
|
||||
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
|
||||
setBackground(background);
|
||||
UIUtil.changeBackGround(this, background);
|
||||
if (text != null) {
|
||||
SearchUtil.appendFragments(myFilter != null ? myFilter.getFilter() : null,
|
||||
text,
|
||||
|
||||
+1
-1
@@ -631,7 +631,7 @@ class TemplateListPanel extends JPanel {
|
||||
// Fix GTK backround
|
||||
if (UIUtil.isUnderGTKLookAndFeel()){
|
||||
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
|
||||
setBackground(background);
|
||||
UIUtil.changeBackGround(this, background);
|
||||
}
|
||||
|
||||
if (value instanceof TemplateImpl) {
|
||||
|
||||
@@ -314,7 +314,7 @@ public abstract class BaseExecuteBeforeRunDialog<T extends BeforeRunTask> extend
|
||||
|
||||
myCheckbox.setBackground(UIUtil.getTreeTextBackground());
|
||||
setBackground(selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground());
|
||||
Color foreground = selected ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeTextForeground();
|
||||
final Color foreground = selected ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeTextForeground();
|
||||
setForeground(foreground);
|
||||
myCheckbox.setForeground(foreground);
|
||||
myLabel.setForeground(foreground);
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.ExtensionPointListener;
|
||||
import com.intellij.openapi.extensions.PluginDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -87,11 +88,11 @@ public class FacetTypeRegistryImpl extends FacetTypeRegistry {
|
||||
myExtensionsLoaded = true;
|
||||
final ExtensionPoint<FacetType> extensionPoint = Extensions.getArea(null).getExtensionPoint(FacetType.EP_NAME);
|
||||
extensionPoint.addExtensionPointListener(new ExtensionPointListener<FacetType>() {
|
||||
public void extensionAdded(final FacetType extension, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
public void extensionAdded(@NotNull final FacetType extension, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
registerFacetType(extension);
|
||||
}
|
||||
|
||||
public void extensionRemoved(final FacetType extension, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
public void extensionRemoved(@NotNull final FacetType extension, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
unregisterFacetType(extension);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -301,7 +301,8 @@ public class FormatterImpl extends FormatterEx
|
||||
final int defaultOffset = offset - whiteSpace.getLength() + newWS.length();
|
||||
|
||||
if (wsContainsCaret) {
|
||||
final int ws = whiteSpace.getStartOffset() + CharArrayUtil.shiftForward(newWS, lineStartOffset - whiteSpace.getStartOffset(), " \t");
|
||||
final int ws = whiteSpace.getStartOffset()
|
||||
+ CharArrayUtil.shiftForward(newWS, Math.max(0, lineStartOffset - whiteSpace.getStartOffset()), " \t");
|
||||
return Math.max(defaultOffset, ws);
|
||||
} else {
|
||||
return defaultOffset;
|
||||
|
||||
@@ -402,7 +402,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
return pre;
|
||||
}
|
||||
|
||||
private static class Token extends Node {
|
||||
private static abstract class Token extends Node {
|
||||
public PsiBuilderImpl myBuilder;
|
||||
public IElementType myTokenType;
|
||||
public int myTokenStart;
|
||||
@@ -461,6 +461,9 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static class TokenNode extends Token implements LighterASTTokenNode {
|
||||
}
|
||||
|
||||
private static class LazyParseableToken extends Token implements LighterLazyParseableNode {
|
||||
private MyTreeStructure myParent;
|
||||
private FlyweightCapableTreeStructure<LighterASTNode> myParsed;
|
||||
@@ -1169,7 +1172,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
}
|
||||
|
||||
public Token create() {
|
||||
return new Token();
|
||||
return new TokenNode();
|
||||
}
|
||||
});
|
||||
myLazyPool = new LimitedPool<LazyParseableToken>(200, new LimitedPool.ObjectFactory<LazyParseableToken>() {
|
||||
@@ -1229,7 +1232,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
ProductionMarker prevChild = null;
|
||||
int lexIndex = marker.myLexemeIndex;
|
||||
while (child != null) {
|
||||
lexIndex = insertLeafs(lexIndex, child.myLexemeIndex, into, marker.myBuilder);
|
||||
lexIndex = insertLeaves(lexIndex, child.myLexemeIndex, into, marker.myBuilder);
|
||||
|
||||
if (child instanceof StartMarker && ((StartMarker)child).myDoneMarker.myCollapse) {
|
||||
final int start = marker.myBuilder.myLexStarts[child.myLexemeIndex];
|
||||
@@ -1251,7 +1254,8 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
}
|
||||
child = child.next;
|
||||
}
|
||||
insertLeafs(lexIndex, marker.myDoneMarker.myLexemeIndex, into, marker.myBuilder);
|
||||
|
||||
insertLeaves(lexIndex, marker.myDoneMarker.myLexemeIndex, into, marker.myBuilder);
|
||||
|
||||
return count;
|
||||
}
|
||||
@@ -1269,7 +1273,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private int insertLeafs(int curToken, int lastIdx, Ref<LighterASTNode[]> into, PsiBuilderImpl builder) {
|
||||
private int insertLeaves(int curToken, int lastIdx, Ref<LighterASTNode[]> into, PsiBuilderImpl builder) {
|
||||
lastIdx = Math.min(lastIdx, builder.myLexemeCount);
|
||||
while (curToken < lastIdx) {
|
||||
final int start = builder.myLexStarts[curToken];
|
||||
@@ -1284,7 +1288,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
|
||||
}
|
||||
|
||||
private void insertLeaf(Ref<LighterASTNode[]> into, int start, int end, IElementType type, PsiBuilderImpl builder) {
|
||||
Token lexeme;
|
||||
final Token lexeme;
|
||||
if (type instanceof ILightLazyParseableElementType) {
|
||||
lexeme = myLazyPool.alloc();
|
||||
((LazyParseableToken)lexeme).myParent = this;
|
||||
|
||||
@@ -628,7 +628,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
}
|
||||
|
||||
private void addRootsToWatch() {
|
||||
final Set<String> rootPaths = getAllRoots();
|
||||
final Set<String> rootPaths = getAllRoots(false);
|
||||
if (rootPaths == null) return;
|
||||
|
||||
final Set<LocalFileSystem.WatchRequest> newRootsToWatch = LocalFileSystem.getInstance().addRootsToWatch(rootPaths, true);
|
||||
@@ -639,7 +639,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Set<String> getAllRoots() {
|
||||
private Set<String> getAllRoots(boolean includeSourceRoots) {
|
||||
if (myProject.isDefault()) return null;
|
||||
|
||||
final Set<String> rootPaths = new HashSet<String>();
|
||||
@@ -648,6 +648,10 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
|
||||
final String[] contentRootUrls = moduleRootManager.getContentRootUrls();
|
||||
rootPaths.addAll(getRootsToTrack(contentRootUrls));
|
||||
if (includeSourceRoots) {
|
||||
final String[] sourceRootUrls = moduleRootManager.getSourceRootUrls();
|
||||
rootPaths.addAll(getRootsToTrack(sourceRootUrls));
|
||||
}
|
||||
rootPaths.add(module.getModuleFilePath());
|
||||
}
|
||||
|
||||
@@ -775,7 +779,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
}
|
||||
|
||||
private boolean affectsRoots(VirtualFilePointer[] pointers) {
|
||||
Set<String> roots = getAllRoots();
|
||||
Set<String> roots = getAllRoots(true);
|
||||
if (roots == null) return false;
|
||||
|
||||
for (VirtualFilePointer pointer : pointers) {
|
||||
|
||||
+2
-3
@@ -60,7 +60,6 @@ import java.util.Set;
|
||||
public class InspectionProjectProfileManager extends DefaultProjectProfileManager implements SeverityProvider, ProjectComponent, PersistentStateComponent<Element> {
|
||||
private final Map<String, InspectionProfileWrapper> myName2Profile = new HashMap<String, InspectionProfileWrapper>();
|
||||
private final SeverityRegistrar mySeverityRegistrar;
|
||||
private StatusBarEx myStatusBar;
|
||||
private TogglePopupHintsPanel myTogglePopupHintsPanel;
|
||||
|
||||
public InspectionProjectProfileManager(final Project project, InspectionProfileManager inspectionProfileManager, DependencyValidationManager holder) {
|
||||
@@ -147,9 +146,9 @@ public class InspectionProjectProfileManager extends DefaultProjectProfileManage
|
||||
}
|
||||
|
||||
public void projectOpened() {
|
||||
myStatusBar = (StatusBarEx)WindowManager.getInstance().getStatusBar(myProject);
|
||||
StatusBarEx statusBar = (StatusBarEx)WindowManager.getInstance().getStatusBar(myProject);
|
||||
myTogglePopupHintsPanel = new TogglePopupHintsPanel(myProject);
|
||||
myStatusBar.addWidget(myTogglePopupHintsPanel, myProject);
|
||||
statusBar.addWidget(myTogglePopupHintsPanel, myProject);
|
||||
StartupManager.getInstance(myProject).registerPostStartupActivity(new Runnable() {
|
||||
public void run() {
|
||||
final Set<Profile> profiles = new HashSet<Profile>();
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ abstract class InspectionsConfigTreeRenderer extends CheckboxTree.CheckboxTreeCe
|
||||
Object object = node.getUserObject();
|
||||
|
||||
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
|
||||
setBackground(background);
|
||||
UIUtil.changeBackGround(this, background);
|
||||
Color foreground =
|
||||
selected ? UIUtil.getTreeSelectionForeground() : node.isProperSetting ? Color.BLUE : UIUtil.getTreeTextForeground();
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.intellij.psi.impl;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.LighterASTNode;
|
||||
import com.intellij.lang.LighterLazyParseableNode;
|
||||
import com.intellij.lang.LighterASTTokenNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
@@ -136,26 +136,18 @@ public class DebugUtil {
|
||||
}
|
||||
|
||||
public static String lightTreeToString(@NotNull final FlyweightCapableTreeStructure<LighterASTNode> tree,
|
||||
@NotNull final String source,
|
||||
final boolean skipWhitespaces) {
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
lightTreeToBuffer(tree, source, buffer, tree.getRoot(), 0, skipWhitespaces, 0);
|
||||
lightTreeToBuffer(tree, tree.getRoot(), buffer, 0, skipWhitespaces);
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
public static void lightTreeToBuffer(@NotNull final FlyweightCapableTreeStructure<LighterASTNode> tree,
|
||||
@NotNull final String source,
|
||||
@NotNull final StringBuilder buffer,
|
||||
@NotNull final LighterASTNode root,
|
||||
final int indent,
|
||||
final boolean skipWhiteSpaces,
|
||||
final int chameleonShift) {
|
||||
final IElementType tokenType = root.getTokenType();
|
||||
public static void lightTreeToBuffer(@NotNull final FlyweightCapableTreeStructure<LighterASTNode> tree, @NotNull final LighterASTNode node,
|
||||
@NotNull final StringBuilder buffer, final int indent, final boolean skipWhiteSpaces) {
|
||||
final IElementType tokenType = node.getTokenType();
|
||||
if (skipWhiteSpaces && tokenType == TokenType.WHITE_SPACE) return;
|
||||
|
||||
final Ref<LighterASTNode[]> kids = new Ref<LighterASTNode[]>();
|
||||
final int numKids = tree.getChildren(tree.prepareForGetChildren(root), kids);
|
||||
final boolean composite = numKids > 0 || root.getStartOffset() == root.getEndOffset();
|
||||
final boolean isLeaf = (node instanceof LighterASTTokenNode);
|
||||
|
||||
StringUtil.repeatSymbol(buffer, ' ', indent);
|
||||
if (tokenType == TokenType.ERROR_ELEMENT) {
|
||||
@@ -165,24 +157,25 @@ public class DebugUtil {
|
||||
buffer.append("PsiWhiteSpace");
|
||||
}
|
||||
else {
|
||||
buffer.append(composite ? "Element" : "PsiElement").append('(').append(tokenType).append(')');
|
||||
buffer.append(isLeaf ? "PsiElement" : "Element").append('(').append(tokenType).append(')');
|
||||
}
|
||||
|
||||
if (!composite) {
|
||||
final String text = source.substring(chameleonShift + root.getStartOffset(), chameleonShift + root.getEndOffset());
|
||||
if (isLeaf) {
|
||||
final String text = ((LighterASTTokenNode)node).getText().toString();
|
||||
buffer.append("('").append(fixWhiteSpaces(text)).append("')");
|
||||
}
|
||||
buffer.append('\n');
|
||||
|
||||
if (composite) {
|
||||
if (!isLeaf) {
|
||||
final Ref<LighterASTNode[]> kids = new Ref<LighterASTNode[]>();
|
||||
final int numKids = tree.getChildren(tree.prepareForGetChildren(node), kids);
|
||||
if (numKids == 0) {
|
||||
StringUtil.repeatSymbol(buffer, ' ', indent + 2);
|
||||
buffer.append("<empty list>\n");
|
||||
}
|
||||
else {
|
||||
final int shift = root instanceof LighterLazyParseableNode ? root.getStartOffset() : 0;
|
||||
for (int i = 0; i < numKids; i++) {
|
||||
lightTreeToBuffer(tree, source, buffer, kids.get()[i], indent + 2, skipWhiteSpaces, chameleonShift + shift);
|
||||
lightTreeToBuffer(tree, kids.get()[i], buffer, indent + 2, skipWhiteSpaces);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -66,20 +66,20 @@ public class InjectedLanguageManagerImpl extends InjectedLanguageManager {
|
||||
|
||||
final ExtensionPoint<MultiHostInjector> multiPoint = Extensions.getArea(project).getExtensionPoint(MultiHostInjector.MULTIHOST_INJECTOR_EP_NAME);
|
||||
multiPoint.addExtensionPointListener(new ExtensionPointListener<MultiHostInjector>() {
|
||||
public void extensionAdded(MultiHostInjector injector, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
public void extensionAdded(@NotNull MultiHostInjector injector, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
registerMultiHostInjector(injector);
|
||||
}
|
||||
|
||||
public void extensionRemoved(MultiHostInjector injector, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
public void extensionRemoved(@NotNull MultiHostInjector injector, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
unregisterMultiHostInjector(injector);
|
||||
}
|
||||
});
|
||||
final ExtensionPointListener<LanguageInjector> myListener = new ExtensionPointListener<LanguageInjector>() {
|
||||
public void extensionAdded(LanguageInjector extension, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
public void extensionAdded(@NotNull LanguageInjector extension, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
psiManagerInjectorsChanged();
|
||||
}
|
||||
|
||||
public void extensionRemoved(LanguageInjector extension, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
public void extensionRemoved(@NotNull LanguageInjector extension, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
psiManagerInjectorsChanged();
|
||||
}
|
||||
};
|
||||
|
||||
+2
-2
@@ -48,11 +48,11 @@ public abstract class BasePlatformRefactoringAction extends BaseRefactoringActio
|
||||
|
||||
public BasePlatformRefactoringAction() {
|
||||
LanguageRefactoringSupport.INSTANCE.addListener(new ExtensionPointListener<RefactoringSupportProvider>() {
|
||||
public void extensionAdded(RefactoringSupportProvider extension, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
public void extensionAdded(@NotNull RefactoringSupportProvider extension, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
myHidden = null;
|
||||
}
|
||||
|
||||
public void extensionRemoved(RefactoringSupportProvider extension, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
public void extensionRemoved(@NotNull RefactoringSupportProvider extension, @Nullable PluginDescriptor pluginDescriptor) {
|
||||
myHidden = null;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -88,7 +88,7 @@ class ToolsPanel extends JPanel {
|
||||
// Fix GTK backround
|
||||
if (UIUtil.isUnderGTKLookAndFeel()){
|
||||
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
|
||||
setBackground(background);
|
||||
UIUtil.changeBackGround(this, background);
|
||||
}
|
||||
|
||||
if (object instanceof ToolsGroup) {
|
||||
|
||||
@@ -523,10 +523,10 @@ public class PsiBuilderQuickTest {
|
||||
// check light tree composition
|
||||
final FlyweightCapableTreeStructure<LighterASTNode> lightTree = builder.getLightTree();
|
||||
final String lightExpected = expected.replaceAll("PsiErrorElement:.*\n", "PsiErrorElement\n");
|
||||
assertEquals(lightExpected, DebugUtil.lightTreeToString(lightTree, text, false));
|
||||
assertEquals(lightExpected, DebugUtil.lightTreeToString(lightTree, false));
|
||||
// verify that light tree can be taken multiple times
|
||||
final FlyweightCapableTreeStructure<LighterASTNode> lightTree2 = builder.getLightTree();
|
||||
assertEquals(lightExpected, DebugUtil.lightTreeToString(lightTree2, text, false));
|
||||
assertEquals(lightExpected, DebugUtil.lightTreeToString(lightTree2, false));
|
||||
|
||||
// check heavy tree composition
|
||||
final ASTNode root = builder.getTreeBuilt();
|
||||
|
||||
+18
-1
@@ -15,10 +15,13 @@
|
||||
*/
|
||||
package com.intellij.openapi.fileChooser;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.UIBundle;
|
||||
|
||||
public class FileChooserDescriptorFactory {
|
||||
private FileChooserDescriptorFactory() {}
|
||||
private FileChooserDescriptorFactory() {
|
||||
}
|
||||
|
||||
public static FileChooserDescriptor createAllButJarContentsDescriptor() {
|
||||
return new FileChooserDescriptor(true, true, true, true, false, true);
|
||||
@@ -59,4 +62,18 @@ public class FileChooserDescriptorFactory {
|
||||
fileChooserDescriptor.setTitle(UIBundle.message("file.chooser.select.object.title", aSearchedObjectName));
|
||||
return fileChooserDescriptor;
|
||||
}
|
||||
|
||||
public static FileChooserDescriptor createSingleFileDescriptor(final FileType fileType) {
|
||||
return new FileChooserDescriptor(true, false, false, false, false, false) {
|
||||
@Override
|
||||
public boolean isFileVisible(final VirtualFile file, final boolean showHiddenFiles) {
|
||||
return file.isDirectory() || file.getFileType() == fileType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileSelectable(final VirtualFile file) {
|
||||
return super.isFileSelectable(file) && file.getFileType() == fileType;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ public abstract class KeyedExtensionCollector<T, KeyT> {
|
||||
ExtensionPointName<KeyedLazyInstance<T>> typesafe = ExtensionPointName.create(myEpName);
|
||||
myPoint = Extensions.getRootArea().getExtensionPoint(typesafe);
|
||||
myListener = new ExtensionPointAndAreaListener<KeyedLazyInstance<T>>() {
|
||||
public void extensionAdded(final KeyedLazyInstance<T> bean, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
public void extensionAdded(@NotNull final KeyedLazyInstance<T> bean, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
w.lock();
|
||||
try {
|
||||
myCache.remove(bean.getKey());
|
||||
@@ -191,7 +191,7 @@ public abstract class KeyedExtensionCollector<T, KeyT> {
|
||||
}
|
||||
}
|
||||
|
||||
public void extensionRemoved(final KeyedLazyInstance<T> bean, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
public void extensionRemoved(@NotNull final KeyedLazyInstance<T> bean, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
w.lock();
|
||||
try {
|
||||
myCache.remove(bean.getKey());
|
||||
|
||||
@@ -232,7 +232,7 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
|
||||
// Fix GTK backround
|
||||
if (UIUtil.isUnderGTKLookAndFeel()){
|
||||
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
|
||||
setBackground(background);
|
||||
UIUtil.changeBackGround(this, background);
|
||||
}
|
||||
|
||||
if (!selected) return result;
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
|
||||
public class OtherGroup extends DefaultActionGroup implements DumbAware {
|
||||
public OtherGroup() {
|
||||
public class NonEmptyActionGroup extends DefaultActionGroup implements DumbAware {
|
||||
public NonEmptyActionGroup() {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ public class CommandMerger {
|
||||
private boolean myForcedGlobal = false;
|
||||
private boolean myTransparent = false;
|
||||
private String myCommandName = null;
|
||||
private boolean myValid = true;
|
||||
private List<UndoableAction> myCurrentActions = new ArrayList<UndoableAction>();
|
||||
private Set<DocumentReference> myAffectedDocuments = new THashSet<DocumentReference>();
|
||||
private EditorAndState myStateBefore;
|
||||
@@ -102,6 +103,7 @@ public class CommandMerger {
|
||||
myTransparent = nextCommandToMerge.myTransparent;
|
||||
}
|
||||
}
|
||||
myValid &= nextCommandToMerge.myValid;
|
||||
myForcedGlobal |= nextCommandToMerge.myForcedGlobal;
|
||||
myCurrentActions.addAll(nextCommandToMerge.myCurrentActions);
|
||||
myAffectedDocuments.addAll(nextCommandToMerge.myAffectedDocuments);
|
||||
@@ -129,7 +131,8 @@ public class CommandMerger {
|
||||
myCurrentActions,
|
||||
myManager.nextCommandTimestamp(),
|
||||
myUndoConfirmationPolicy,
|
||||
isTransparent()));
|
||||
isTransparent(),
|
||||
myValid));
|
||||
}
|
||||
|
||||
reset();
|
||||
@@ -142,6 +145,7 @@ public class CommandMerger {
|
||||
myForcedGlobal = false;
|
||||
myTransparent = false;
|
||||
myCommandName = null;
|
||||
myValid = true;
|
||||
myStateAfter = null;
|
||||
myStateBefore = null;
|
||||
myUndoConfirmationPolicy = UndoConfirmationPolicy.DEFAULT;
|
||||
@@ -244,4 +248,10 @@ public class CommandMerger {
|
||||
public void setAfterState(EditorAndState state) {
|
||||
myStateAfter = state;
|
||||
}
|
||||
|
||||
public void invalidateActionsFor(DocumentReference ref) {
|
||||
if (myAffectedDocuments.contains(ref)) {
|
||||
myValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-3
@@ -32,7 +32,8 @@ class EditorChangeAction implements UndoableAction {
|
||||
private final int myOffset;
|
||||
private final CharSequence myOldString;
|
||||
private final CharSequence myNewString;
|
||||
private final long myTimeStamp;
|
||||
private final long myOldTimeStamp;
|
||||
private final long myNewTimeStamp;
|
||||
private final boolean myBulkUpdate;
|
||||
|
||||
public EditorChangeAction(DocumentEx document,
|
||||
@@ -45,18 +46,21 @@ class EditorChangeAction implements UndoableAction {
|
||||
myOffset = offset;
|
||||
myOldString = oldString == null ? "" : oldString;
|
||||
myNewString = newString == null ? "" : newString;
|
||||
myTimeStamp = oldTimeStamp;
|
||||
myOldTimeStamp = oldTimeStamp;
|
||||
myNewTimeStamp = document.getModificationStamp();
|
||||
|
||||
myBulkUpdate = document.isInBulkUpdate();
|
||||
}
|
||||
|
||||
public void undo() {
|
||||
exchangeStrings(myNewString, myOldString);
|
||||
getDocument().setModificationStamp(myTimeStamp);
|
||||
getDocument().setModificationStamp(myOldTimeStamp);
|
||||
refreshFileStatus();
|
||||
}
|
||||
|
||||
public void redo() {
|
||||
exchangeStrings(myOldString, myNewString);
|
||||
getDocument().setModificationStamp(myNewTimeStamp);
|
||||
refreshFileStatus();
|
||||
}
|
||||
|
||||
|
||||
@@ -286,7 +286,8 @@ public class UndoManagerImpl extends UndoManager implements ProjectComponent, Ap
|
||||
|
||||
public void invalidateActionsFor(DocumentReference ref) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
LOG.assertTrue(!isInsideCommand());
|
||||
myMerger.invalidateActionsFor(ref);
|
||||
if (myCurrentMerger != null) myCurrentMerger.invalidateActionsFor(ref);
|
||||
myUndoStacksHolder.invalidateActionsFor(ref);
|
||||
myRedoStacksHolder.invalidateActionsFor(ref);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class UndoableGroup {
|
||||
private final Project myProject;
|
||||
private final UndoConfirmationPolicy myConfirmationPolicy;
|
||||
|
||||
private boolean myValid = true;
|
||||
private boolean myValid;
|
||||
|
||||
public UndoableGroup(String commandName,
|
||||
boolean isGlobal,
|
||||
@@ -61,7 +61,8 @@ class UndoableGroup {
|
||||
List<UndoableAction> actions,
|
||||
int commandTimestamp,
|
||||
UndoConfirmationPolicy confirmationPolicy,
|
||||
boolean transparent) {
|
||||
boolean transparent,
|
||||
boolean valid) {
|
||||
myCommandName = commandName;
|
||||
myGlobal = isGlobal;
|
||||
myCommandTimestamp = commandTimestamp;
|
||||
@@ -71,6 +72,7 @@ class UndoableGroup {
|
||||
myStateAfter = stateAfter;
|
||||
myConfirmationPolicy = confirmationPolicy;
|
||||
myTransparent = transparent;
|
||||
myValid = valid;
|
||||
}
|
||||
|
||||
public boolean isGlobal() {
|
||||
|
||||
+2
-2
@@ -56,7 +56,7 @@ public class ServiceManagerImpl implements BaseComponent {
|
||||
final MutablePicoContainer picoContainer = (MutablePicoContainer)componentManager.getPicoContainer();
|
||||
|
||||
myExtensionPointListener = new ExtensionPointListener<ServiceDescriptor>() {
|
||||
public void extensionAdded(final ServiceDescriptor descriptor, final PluginDescriptor pluginDescriptor) {
|
||||
public void extensionAdded(@NotNull final ServiceDescriptor descriptor, final PluginDescriptor pluginDescriptor) {
|
||||
if (descriptor.overrides) {
|
||||
ComponentAdapter oldAdapter =
|
||||
picoContainer.unregisterComponent(descriptor.getInterface());// Allow to re-define service implementations in plugins.
|
||||
@@ -68,7 +68,7 @@ public class ServiceManagerImpl implements BaseComponent {
|
||||
picoContainer.registerComponent(new MyComponentAdapter(descriptor, pluginDescriptor, (ComponentManagerEx)componentManager));
|
||||
}
|
||||
|
||||
public void extensionRemoved(final ServiceDescriptor extension, final PluginDescriptor pluginDescriptor) {
|
||||
public void extensionRemoved(@NotNull final ServiceDescriptor extension, final PluginDescriptor pluginDescriptor) {
|
||||
picoContainer.unregisterComponent(extension.getInterface());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -131,6 +131,12 @@ public class EditorUtil {
|
||||
return resVisEnd.column;
|
||||
}
|
||||
|
||||
public static int getVisualLineEndOffset(@NotNull Editor editor, int line) {
|
||||
VisualPosition endLineVisualPosition = new VisualPosition(line, getLastVisualLineColumnNumber(editor, line));
|
||||
LogicalPosition endLineLogicalPosition = editor.visualToLogicalPosition(endLineVisualPosition);
|
||||
return editor.logicalPositionToOffset(endLineLogicalPosition);
|
||||
}
|
||||
|
||||
public static float calcVerticalScrollProportion(Editor editor) {
|
||||
Rectangle viewArea = editor.getScrollingModel().getVisibleAreaOnScrollingFinished();
|
||||
if (viewArea.height == 0) {
|
||||
|
||||
+2
-1
@@ -539,7 +539,8 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse
|
||||
private void paintIconRow(int line, ArrayList<GutterIconRenderer> row, final Graphics g) {
|
||||
processIconsRow(line, row, new LineGutterIconRendererProcessor() {
|
||||
public void process(int x, int y, GutterIconRenderer renderer) {
|
||||
renderer.getIcon().paintIcon(EditorGutterComponentImpl.this, g, x, y);
|
||||
Icon icon = renderer.getIcon();
|
||||
icon.paintIcon(EditorGutterComponentImpl.this, g, x, y);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1036,13 +1036,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
|
||||
public int offsetToVisualLine(int offset) {
|
||||
int line = calcLogicalLineNumber(offset);
|
||||
return logicalToVisualLine(line);
|
||||
}
|
||||
|
||||
private int logicalToVisualLine(int line) {
|
||||
assertReadAccess();
|
||||
return logicalToVisualPosition(new LogicalPosition(line, 0)).line;
|
||||
return logicalToVisualPosition(offsetToLogicalPosition(offset)).line;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -4219,6 +4213,9 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
|
||||
private class MyMouseAdapter extends MouseAdapter {
|
||||
|
||||
private boolean mySelectionTweaked;
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
requestFocus();
|
||||
runMousePressedCommand(e);
|
||||
@@ -4248,6 +4245,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
TooltipController.getInstance().cancelTooltip(FOLDING_TOOLTIP_GROUP, e, true);
|
||||
}
|
||||
private void runMousePressedCommand(final MouseEvent e) {
|
||||
mySelectionTweaked = false;
|
||||
myMousePressedEvent = e;
|
||||
EditorMouseEvent event = new EditorMouseEvent(EditorImpl.this, e, getMouseEventArea(e));
|
||||
|
||||
@@ -4287,6 +4285,13 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
|
||||
private void runMouseReleasedCommand(final MouseEvent e) {
|
||||
if (!mySelectionTweaked) {
|
||||
tweakSelectionIfNecessary(e);
|
||||
}
|
||||
if (e.isConsumed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
myScrollingTimer.stop();
|
||||
EditorMouseEvent event = new EditorMouseEvent(EditorImpl.this, e, getMouseEventArea(e));
|
||||
for (EditorMouseListener listener : myMouseListeners) {
|
||||
@@ -4367,7 +4372,12 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
|
||||
if (e.getSource() == myGutterComponent) {
|
||||
if (eventArea == EditorMouseEventArea.LINE_MARKERS_AREA || eventArea == EditorMouseEventArea.ANNOTATIONS_AREA || eventArea == EditorMouseEventArea.LINE_NUMBERS_AREA) {
|
||||
myGutterComponent.mousePressed(e);
|
||||
if (tweakSelectionIfNecessary(e)) {
|
||||
mySelectionTweaked = true;
|
||||
}
|
||||
else {
|
||||
myGutterComponent.mousePressed(e);
|
||||
}
|
||||
if (e.isConsumed()) return;
|
||||
}
|
||||
x = 0;
|
||||
@@ -4447,6 +4457,79 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to answer if given event should tweak editor selection.
|
||||
*
|
||||
* @param e event for occurred mouse action
|
||||
* @return <code>true</code> if action that produces given event will trigger editor selection change; <code>false</code> otherwise
|
||||
*/
|
||||
private boolean tweakSelectionEvent(@NotNull MouseEvent e) {
|
||||
return getSelectionModel().hasSelection() && e.getButton() == MouseEvent.BUTTON1 && e.isShiftDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if editor selection should be changed because of click at the given point at gutter and proceeds if necessary.
|
||||
* <p/>
|
||||
* The main idea is that selection can be changed during left mouse clicks with hold <code>Shift</code> button and we want
|
||||
* to distinguish that situation from <code>'close line numbers gutter'</code> action (activated by <code>'Shift+click'</code>
|
||||
* on gutter area).
|
||||
*
|
||||
* @param e event for mouse click on gutter area
|
||||
* @return <code>true</code> if editor's selection is changed because of the click; <code>false</code> otherwise
|
||||
*/
|
||||
private boolean tweakSelectionIfNecessary(@NotNull MouseEvent e) {
|
||||
if (!tweakSelectionEvent(e)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int startSelectionOffset = getSelectionModel().getSelectionStart();
|
||||
int startVisLine = offsetToVisualLine(startSelectionOffset);
|
||||
|
||||
int endSelectionOffset = getSelectionModel().getSelectionEnd();
|
||||
int endVisLine = offsetToVisualLine(endSelectionOffset - 1);
|
||||
|
||||
int clickVisLine = xyToVisualPosition(e.getPoint()).line;
|
||||
|
||||
if (clickVisLine < startVisLine) {
|
||||
// Expand selection at backward direction.
|
||||
int startOffset = logicalPositionToOffset(visualToLogicalPosition(new VisualPosition(clickVisLine, 0)));
|
||||
getSelectionModel().setSelection(startOffset, endSelectionOffset);
|
||||
getCaretModel().moveToOffset(startOffset);
|
||||
}
|
||||
else if (clickVisLine > endVisLine) {
|
||||
// Expand selection at forward direction.
|
||||
int endLineOffset = EditorUtil.getVisualLineEndOffset(this, clickVisLine);
|
||||
getSelectionModel().setSelection(getSelectionModel().getSelectionStart(), endLineOffset);
|
||||
getCaretModel().moveToOffset(endLineOffset, true);
|
||||
}
|
||||
else if (startVisLine == endVisLine) {
|
||||
// Remove selection
|
||||
getSelectionModel().removeSelection();
|
||||
}
|
||||
else {
|
||||
// Reduce selection in backward direction.
|
||||
if (getSelectionModel().getLeadSelectionOffset() == endSelectionOffset) {
|
||||
if (clickVisLine == startVisLine) {
|
||||
clickVisLine++;
|
||||
}
|
||||
int startOffset = logicalPositionToOffset(visualToLogicalPosition(new VisualPosition(clickVisLine, 0)));
|
||||
getSelectionModel().setSelection(startOffset, endSelectionOffset);
|
||||
getCaretModel().moveToOffset(startOffset);
|
||||
}
|
||||
else {
|
||||
// Reduce selection is forward direction.
|
||||
if (clickVisLine == endVisLine) {
|
||||
clickVisLine--;
|
||||
}
|
||||
int endLineOffset = EditorUtil.getVisualLineEndOffset(this, clickVisLine);
|
||||
getSelectionModel().setSelection(startSelectionOffset, endLineOffset);
|
||||
getCaretModel().moveToOffset(endLineOffset);
|
||||
}
|
||||
}
|
||||
e.consume();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static final TooltipGroup FOLDING_TOOLTIP_GROUP = new TooltipGroup("FOLDING_TOOLTIP_GROUP", 10);
|
||||
|
||||
private class MyMouseMotionListener implements MouseMotionListener {
|
||||
|
||||
+3
-4
@@ -23,9 +23,8 @@ import com.intellij.openapi.fileEditor.FileEditorProvider;
|
||||
import com.intellij.openapi.fileEditor.WeighedFileEditorProvider;
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorProviderManager;
|
||||
import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -49,11 +48,11 @@ public final class FileEditorProviderManagerImpl extends FileEditorProviderManag
|
||||
mySharedProviderList = new ArrayList<FileEditorProvider>();
|
||||
|
||||
Extensions.getRootArea().getExtensionPoint(FileEditorProvider.EP_FILE_EDITOR_PROVIDER).addExtensionPointListener(new ExtensionPointListener<FileEditorProvider>() {
|
||||
public void extensionAdded(final FileEditorProvider extension, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
public void extensionAdded(@NotNull final FileEditorProvider extension, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
registerProvider(extension);
|
||||
}
|
||||
|
||||
public void extensionRemoved(final FileEditorProvider extension, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
public void extensionRemoved(@NotNull final FileEditorProvider extension, @Nullable final PluginDescriptor pluginDescriptor) {
|
||||
unregisterProvider(extension);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -189,15 +189,15 @@ module.remove.action=Remove
|
||||
module.remove.last.confirmation=Are you sure you want to remove the only module from this project?\nNo files will be deleted on disk.
|
||||
module.remove.confirmation=Remove module \"{0}\" from the project?\nNo files will be deleted on disk.
|
||||
module.remove.confirmation.title=Remove Module
|
||||
button.edit=&Edit...
|
||||
module.classpath.button.edit=Ed&it...
|
||||
module.libraries.include.all.button=Include All
|
||||
module.libraries.exclude.all.button=Exclude All
|
||||
modules.order.export.title=Order/Export
|
||||
modules.classpath.title=Dependencies
|
||||
modules.order.export.export.column=Export
|
||||
modules.order.export.scope.column=Scope
|
||||
button.move.up=Move &Up
|
||||
button.move.down=Move &Down
|
||||
module.classpath.button.move.up=Move &Up
|
||||
module.classpath.button.move.down=Move &Down
|
||||
module.remove.confirmation.prompt=Remove {1, choice, 1#Module|2#Modules} {0} from the project?\nNo files will be deleted.
|
||||
module.remove.command=Detach module from project
|
||||
module.new.action=New Module
|
||||
@@ -454,8 +454,8 @@ project.new.wizard.module.name.title=Na&me:
|
||||
project.new.wizard.module.root.title=Content &root:
|
||||
project.new.wizard.module.file.title=Module &file location:
|
||||
|
||||
label.text.please.select.desired.technologies=Please select the desired technologies
|
||||
label.text.framework.support.description=This will download all needed libraries and create Facets in project configuration
|
||||
label.text.please.select.desired.technologies=Please select the desired technologies.
|
||||
label.text.framework.support.description=This will download all needed libraries and create Facets in project configuration.
|
||||
file.chooser.directory.for.downloaded.libraries.title=Directory for Downloaded Libraries
|
||||
file.chooser.directory.for.downloaded.libraries.description=Downloaded libraries will be copied to selected directory
|
||||
dialog.title.library.downloading.settings=Library Downloading Settings
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<add-to-group group-id="NewGroup" anchor="before" relative-to-action="NewFromTemplate"/>
|
||||
</group>
|
||||
|
||||
<group id="NewXmlDescriptor" text="XML Configuration File" popup="true" icon="/fileTypes/xml.png">
|
||||
<group id="NewXmlDescriptor" class="com.intellij.ide.actions.NonEmptyActionGroup" text="XML Configuration File" popup="true" icon="/fileTypes/xml.png">
|
||||
<add-to-group group-id="NewGroup" anchor="last"/>
|
||||
</group>
|
||||
|
||||
|
||||
@@ -295,7 +295,7 @@
|
||||
<action id="About" class="com.intellij.ide.actions.AboutAction"/>
|
||||
</group>
|
||||
|
||||
<group id="OtherMenu" class="com.intellij.ide.actions.OtherGroup"/>
|
||||
<group id="OtherMenu" class="com.intellij.ide.actions.NonEmptyActionGroup"/>
|
||||
</group>
|
||||
|
||||
<group id="MainToolBar" configurable="true">
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.util;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
@@ -67,9 +68,9 @@ public class ShutDownTracker implements Runnable {
|
||||
threads = getStopperThreads();
|
||||
}
|
||||
|
||||
while (!myShutdownTasks.isEmpty()) {
|
||||
|
||||
for (Runnable task = removeLast(myShutdownTasks); task != null; task = removeLast(myShutdownTasks)) {
|
||||
// task can change myShutdownTasks
|
||||
final Runnable task = myShutdownTasks.removeLast();
|
||||
try {
|
||||
task.run();
|
||||
}
|
||||
@@ -78,14 +79,12 @@ public class ShutDownTracker implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
if (!myShutdownThreads.isEmpty()) {
|
||||
for (Thread thread = myShutdownThreads.removeLast(); thread != null; thread = myShutdownThreads.removeLast()) {
|
||||
thread.start();
|
||||
try {
|
||||
thread.join();
|
||||
}
|
||||
catch (InterruptedException ignored) {
|
||||
}
|
||||
for (Thread thread = removeLast(myShutdownThreads); thread != null; thread = removeLast(myShutdownThreads)) {
|
||||
thread.start();
|
||||
try {
|
||||
thread.join();
|
||||
}
|
||||
catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,19 +105,28 @@ public class ShutDownTracker implements Runnable {
|
||||
myThreads.remove(thread);
|
||||
}
|
||||
|
||||
public void registerShutdownThread(final Thread thread) {
|
||||
public synchronized void registerShutdownThread(final Thread thread) {
|
||||
myShutdownThreads.addLast(thread);
|
||||
}
|
||||
|
||||
public void registerShutdownThread(int index, final Thread thread) {
|
||||
public synchronized void registerShutdownThread(int index, final Thread thread) {
|
||||
myShutdownThreads.add(index, thread);
|
||||
}
|
||||
|
||||
public void registerShutdownTask(Runnable task) {
|
||||
public synchronized void registerShutdownTask(Runnable task) {
|
||||
myShutdownTasks.addLast(task);
|
||||
}
|
||||
|
||||
public void unregisterShutdownTask(Runnable task) {
|
||||
public synchronized void unregisterShutdownTask(Runnable task) {
|
||||
myShutdownTasks.remove(task);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private synchronized <T> T removeLast(LinkedList<T> list) {
|
||||
return list.isEmpty()? null : list.removeLast();
|
||||
}
|
||||
|
||||
private synchronized <T> boolean isEmpty(LinkedList<T> list) {
|
||||
return list.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1382,6 +1382,16 @@ public class UIUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Avoid blinking while changing background
|
||||
*/
|
||||
public static void changeBackGround(final JComponent component, final Color background) {
|
||||
final Color oldBackGround = component.getBackground();
|
||||
if (background == null || !background.equals(oldBackGround)){
|
||||
component.setBackground(background);
|
||||
}
|
||||
}
|
||||
|
||||
public static class MacTreeUI extends BasicTreeUI {
|
||||
public static final String SOURCE_LIST_CLIENT_PROPERTY = "mac.ui.source.list";
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ public class IgnoredSettingsPanel implements SearchableConfigurable {
|
||||
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
if (UIUtil.isUnderGTKLookAndFeel()){
|
||||
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
|
||||
setBackground(background);
|
||||
UIUtil.changeBackGround(this, background);
|
||||
}
|
||||
|
||||
IgnoredFileBean bean = (IgnoredFileBean) value;
|
||||
|
||||
+1
-1
@@ -192,7 +192,7 @@ public class XBreakpointsTree<B extends XBreakpoint<?>> extends CheckboxTree {
|
||||
// Fix GTK backround
|
||||
if (UIUtil.isUnderGTKLookAndFeel()){
|
||||
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
|
||||
setBackground(background);
|
||||
UIUtil.changeBackGround(this, background);
|
||||
}
|
||||
if (value instanceof BreakpointNode) {
|
||||
BreakpointNode node = (BreakpointNode)value;
|
||||
|
||||
@@ -1780,3 +1780,5 @@ method.name.pattern=Method name pattern
|
||||
query.column.name=Query name starts with
|
||||
update.column.name=Update name starts with
|
||||
assert.keyword.is.considered.an.assertion=assert keyword is considered an assertion
|
||||
expected.exception.never.thrown.display.name=Expected exception never thrown in test method body
|
||||
expected.exception.never.thrown.problem.descriptor=Expected <code>#ref</code> never thrown in body of ''{0}()''
|
||||
|
||||
@@ -1046,6 +1046,7 @@ public class InspectionGadgetsPlugin implements ApplicationComponent,
|
||||
m_inspectionClasses.add(AssertsWithoutMessagesInspection.class);
|
||||
m_inspectionClasses.add(BeforeClassOrAfterClassIsPublicStaticVoidNoArgInspection.class);
|
||||
m_inspectionClasses.add(BeforeOrAfterIsPublicVoidNoArgInspection.class);
|
||||
m_inspectionClasses.add(ExpectedExceptionNeverThrownInspection.class);
|
||||
m_inspectionClasses.add(ParameterizedParametersStaticCollectionInspection.class);
|
||||
m_inspectionClasses.add(ConstantJUnitAssertArgumentInspection.class);
|
||||
m_inspectionClasses.add(JUnit4AnnotatedMethodInJUnit3TestCaseInspection.class);
|
||||
@@ -1070,6 +1071,7 @@ public class InspectionGadgetsPlugin implements ApplicationComponent,
|
||||
m_inspectionClasses.add(UnconstructableTestCaseInspection.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright 2010 Bas Leijdekkers
|
||||
*
|
||||
* 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.siyeh.ig.junit;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.psiutils.ClassUtils;
|
||||
import com.siyeh.ig.psiutils.ExceptionUtils;
|
||||
import com.siyeh.ig.psiutils.TypeUtils;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class ExpectedExceptionNeverThrownInspection
|
||||
extends BaseInspection {
|
||||
@Nls
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return InspectionGadgetsBundle.message(
|
||||
"expected.exception.never.thrown.display.name");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String buildErrorString(Object... infos) {
|
||||
final PsiMethod method = (PsiMethod) infos[0];
|
||||
return InspectionGadgetsBundle.message(
|
||||
"expected.exception.never.thrown.problem.descriptor",
|
||||
method.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new ExpectedExceptionNeverThrownVisitor();
|
||||
}
|
||||
|
||||
private static class ExpectedExceptionNeverThrownVisitor
|
||||
extends BaseInspectionVisitor {
|
||||
|
||||
@Override
|
||||
public void visitMethod(PsiMethod method) {
|
||||
super.visitMethod(method);
|
||||
final PsiAnnotation annotation =
|
||||
AnnotationUtil.findAnnotation(method, "org.junit.Test");
|
||||
if (annotation == null) {
|
||||
return;
|
||||
}
|
||||
final PsiAnnotationParameterList parameterList =
|
||||
annotation.getParameterList();
|
||||
final PsiNameValuePair[] attributes = parameterList.getAttributes();
|
||||
PsiAnnotationMemberValue value = null;
|
||||
for (PsiNameValuePair attribute : attributes) {
|
||||
if ("expected".equals(attribute.getName())) {
|
||||
value = attribute.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!(value instanceof PsiClassObjectAccessExpression)) {
|
||||
return;
|
||||
}
|
||||
final PsiCodeBlock body = method.getBody();
|
||||
if (body == null) {
|
||||
return;
|
||||
}
|
||||
final PsiClassObjectAccessExpression classObjectAccessExpression =
|
||||
(PsiClassObjectAccessExpression) value;
|
||||
final PsiTypeElement operand =
|
||||
classObjectAccessExpression.getOperand();
|
||||
final PsiType type = operand.getType();
|
||||
if (!(type instanceof PsiClassType)) {
|
||||
return;
|
||||
}
|
||||
final PsiClassType classType = (PsiClassType) type;
|
||||
final PsiClass aClass = classType.resolve();
|
||||
if (ClassUtils.isSubclass(aClass, "java.lang.RuntimeException")) {
|
||||
return;
|
||||
}
|
||||
final Set<PsiType> exceptionsThrown =
|
||||
ExceptionUtils.calculateExceptionsThrown(body);
|
||||
if (exceptionsThrown.contains(type)) {
|
||||
return;
|
||||
}
|
||||
registerError(operand, method);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2009 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2010 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.
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.siyeh.ig.psiutils;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -38,9 +39,9 @@ public class ExceptionUtils{
|
||||
}
|
||||
|
||||
@NotNull public static Set<PsiType> calculateExceptionsThrown(
|
||||
@NotNull PsiElement statement){
|
||||
@NotNull PsiElement element){
|
||||
final ExceptionsThrownVisitor visitor = new ExceptionsThrownVisitor();
|
||||
statement.accept(visitor);
|
||||
element.accept(visitor);
|
||||
return visitor.getExceptionsThrown();
|
||||
}
|
||||
|
||||
@@ -195,8 +196,9 @@ public class ExceptionUtils{
|
||||
return;
|
||||
}
|
||||
final PsiReferenceList throwsList = method.getThrowsList();
|
||||
final PsiManager psiManager = expression.getManager();
|
||||
final PsiElementFactory factory = JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory();
|
||||
final Project project = expression.getProject();
|
||||
final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
|
||||
final PsiElementFactory factory = psiFacade.getElementFactory();
|
||||
final PsiJavaCodeReferenceElement[] list =
|
||||
throwsList.getReferenceElements();
|
||||
for(final PsiJavaCodeReferenceElement referenceElement : list){
|
||||
@@ -210,15 +212,17 @@ public class ExceptionUtils{
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void visitNewExpression(@NotNull PsiNewExpression expression){
|
||||
@Override public void visitNewExpression(
|
||||
@NotNull PsiNewExpression expression){
|
||||
super.visitNewExpression(expression);
|
||||
final PsiMethod method = expression.resolveMethod();
|
||||
if(method == null){
|
||||
return;
|
||||
}
|
||||
final PsiReferenceList throwsList = method.getThrowsList();
|
||||
final PsiManager psiManager = expression.getManager();
|
||||
final PsiElementFactory factory = JavaPsiFacade.getInstance(psiManager.getProject()).getElementFactory();
|
||||
final Project project = expression.getProject();
|
||||
final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
|
||||
final PsiElementFactory factory = psiFacade.getElementFactory();
|
||||
final PsiJavaCodeReferenceElement[] list =
|
||||
throwsList.getReferenceElements();
|
||||
for(final PsiJavaCodeReferenceElement referenceElement : list){
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<body><table> <tr> <td valign="top" height="150">
|
||||
<font face="verdana" size="-1">
|
||||
This inspection reports checked exceptions expected by a JUnit 4 test method,
|
||||
which are never thrown inside the method body.
|
||||
</font></td> </tr> <tr> <td height="20"> <font face="verdana" size="-2">Powered by InspectionGadgets </font> </td> </tr> </table> </body>
|
||||
</html>
|
||||
@@ -604,7 +604,7 @@ public class GitPushActiveBranchesDialog extends DialogWrapper {
|
||||
// Fix GTK backround
|
||||
if (UIUtil.isUnderGTKLookAndFeel()) {
|
||||
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
|
||||
setBackground(background);
|
||||
UIUtil.changeBackGround(this, background);
|
||||
}
|
||||
ColoredTreeCellRenderer r = getTextRenderer();
|
||||
if (!(value instanceof DefaultMutableTreeNode)) {
|
||||
|
||||
@@ -355,7 +355,7 @@ public class GitConvertFilesDialog extends DialogWrapper {
|
||||
// Fix GTK backround
|
||||
if (UIUtil.isUnderGTKLookAndFeel()){
|
||||
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
|
||||
setBackground(background);
|
||||
UIUtil.changeBackGround(this, background);
|
||||
}
|
||||
ColoredTreeCellRenderer r = getTextRenderer();
|
||||
if (!(value instanceof CheckedTreeNode)) {
|
||||
|
||||
@@ -247,7 +247,7 @@ public class GitRefspecAddRefsDialog extends DialogWrapper {
|
||||
// Fix GTK backround
|
||||
if (UIUtil.isUnderGTKLookAndFeel()) {
|
||||
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
|
||||
setBackground(background);
|
||||
UIUtil.changeBackGround(this, background);
|
||||
}
|
||||
final CheckedTreeNode node = (CheckedTreeNode)value;
|
||||
final Object userObject = node.getUserObject();
|
||||
|
||||
@@ -111,7 +111,7 @@ public class AntTasksProvider {
|
||||
for (VirtualFile jar : jars) {
|
||||
urls.add(VfsUtil.convertToURL(PathUtil.getLocalFile(jar).getUrl()));
|
||||
}
|
||||
final ClassLoader loader = new UrlClassLoader(urls, null);
|
||||
final ClassLoader loader = new UrlClassLoader(urls, null, false, false, true);
|
||||
final ReflectedProject antProject = ReflectedProject.getProject(loader);
|
||||
|
||||
final Map<String, Class> result = new HashMap<String, Class>();
|
||||
|
||||
+2
-2
@@ -88,9 +88,9 @@ public class GroovyInsertHandler implements InsertHandler<LookupElement> {
|
||||
PsiDocumentManager docManager = PsiDocumentManager.getInstance(method.getProject());
|
||||
docManager.commitDocument(document);
|
||||
PsiFile psiFile = docManager.getPsiFile(document);
|
||||
/*if (method.getParameterList().getParametersCount() > 0 && isTopLevelStatement(psiFile, context.getStartOffset())) {
|
||||
if (method.getParameterList().getParametersCount() > 0 && isTopLevelStatement(psiFile, context.getStartOffset())) {
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
if (isExpressionStatement(psiFile, context.getStartOffset()) &&
|
||||
(PsiType.VOID.equals(PsiUtil.getSmartReturnType(method)) ||
|
||||
method instanceof GrMethod && ((GrMethod)method).getReturnTypeElementGroovy() == null) &&
|
||||
|
||||
+12
-4
@@ -115,13 +115,17 @@ class Foo {
|
||||
static def abcmethod1(int a) {}
|
||||
static def abcmethod2(int a) {}
|
||||
}""")
|
||||
myFixture.configureByText("a.groovy", "abcme<caret>")
|
||||
myFixture.configureByText("a.groovy", """def foo() {
|
||||
abcme<caret>
|
||||
}""")
|
||||
def item = myFixture.complete(CompletionType.CLASS_NAME)[0]
|
||||
((StaticallyImportable) item).shouldBeImported = true
|
||||
myFixture.type('\n')
|
||||
myFixture.checkResult """import static Foo.abcmethod1
|
||||
|
||||
abcmethod1 <caret>"""
|
||||
def foo() {
|
||||
abcmethod1 <caret>
|
||||
}"""
|
||||
|
||||
}
|
||||
|
||||
@@ -130,11 +134,15 @@ abcmethod1 <caret>"""
|
||||
class Foo {
|
||||
static def abcmethod(int a) {}
|
||||
}""")
|
||||
myFixture.configureByText("a.groovy", "abcme<caret>")
|
||||
myFixture.configureByText("a.groovy", """def foo() {
|
||||
abcme<caret>
|
||||
}""")
|
||||
myFixture.complete(CompletionType.CLASS_NAME)
|
||||
myFixture.checkResult """import foo.Foo
|
||||
|
||||
Foo.abcmethod <caret>"""
|
||||
def foo() {
|
||||
Foo.abcmethod <caret>
|
||||
}"""
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
List<String> list=['a', 'b']
|
||||
list[0].substr<caret>
|
||||
def foo() {
|
||||
List<String> list=['a', 'b']
|
||||
list[0].substr<caret>
|
||||
}
|
||||
+4
-2
@@ -1,2 +1,4 @@
|
||||
List<String> list=['a', 'b']
|
||||
list[0].substring(<caret>)
|
||||
def foo() {
|
||||
List<String> list=['a', 'b']
|
||||
list[0].substring(<caret>)
|
||||
}
|
||||
@@ -1,2 +1,4 @@
|
||||
map=[1:'a', 3:'b', 2:'c']
|
||||
map[2].substr<caret>
|
||||
def foo() {
|
||||
map=[1:'a', 3:'b', 2:'c']
|
||||
map[2].substr<caret>
|
||||
}
|
||||
+4
-2
@@ -1,2 +1,4 @@
|
||||
map=[1:'a', 3:'b', 2:'c']
|
||||
map[2].substring(<caret>)
|
||||
def foo() {
|
||||
map=[1:'a', 3:'b', 2:'c']
|
||||
map[2].substring(<caret>)
|
||||
}
|
||||
@@ -1 +1,3 @@
|
||||
"".init<caret>
|
||||
def foo() {
|
||||
"".init<caret>
|
||||
}
|
||||
@@ -1 +1,3 @@
|
||||
"".initCause(<caret>)
|
||||
def foo() {
|
||||
"".initCause(<caret>)
|
||||
}
|
||||
+1
-1
@@ -6,4 +6,4 @@ class MyBean {
|
||||
|
||||
def bean = new MyBean()
|
||||
|
||||
bean.firePropertyChange <caret>
|
||||
bean.firePropertyChange<caret>
|
||||
+1
-1
@@ -12,4 +12,4 @@ def gr8conf = new Event(title: "GR8 Conference",
|
||||
when: df.parse("2009/05/18"))
|
||||
|
||||
|
||||
gr8conf.before(<caret>)
|
||||
gr8conf.before<caret>
|
||||
+1
-1
@@ -6,4 +6,4 @@ class MyBean {
|
||||
|
||||
def bean = new MyBean()
|
||||
|
||||
bean.fireVetoableChange <caret>
|
||||
bean.fireVetoableChange<caret>
|
||||
+1
-1
@@ -187,7 +187,7 @@ public class SelectIgnorePatternsToRemoveOnDeleteDialog extends DialogWrapper {
|
||||
// Fix GTK backround
|
||||
if (UIUtil.isUnderGTKLookAndFeel()){
|
||||
final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
|
||||
setBackground(background);
|
||||
UIUtil.changeBackGround(this, background);
|
||||
}
|
||||
final ColoredTreeCellRenderer textRenderer = getTextRenderer();
|
||||
if (value instanceof MyConsumer) {
|
||||
|
||||
Reference in New Issue
Block a user