mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -228,6 +228,7 @@ public class CompileDriver {
|
||||
}
|
||||
finally {
|
||||
compileContext.commitZipFiles(); // just to be on the safe side; normally should do nothing if called in isUpToDate()
|
||||
CompilerCacheManager.getInstance(myProject).flushCaches();
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
@@ -455,6 +456,7 @@ public class CompileDriver {
|
||||
compileContext.getMessageCount(CompilerMessageCategory.WARNING),
|
||||
finish - start
|
||||
);
|
||||
CompilerCacheManager.getInstance(myProject).flushCaches();
|
||||
//if (LOG.isDebugEnabled()) {
|
||||
// LOG.debug("COMPILATION FINISHED");
|
||||
//}
|
||||
@@ -792,7 +794,6 @@ public class CompileDriver {
|
||||
finally {
|
||||
// drop in case it has not been dropped yet.
|
||||
dropDependencyCache(context);
|
||||
|
||||
final VirtualFile[] allOutputDirs = context.getAllOutputDirectories();
|
||||
|
||||
if (didSomething && GENERATE_CLASSPATH_INDEX) {
|
||||
|
||||
@@ -23,8 +23,6 @@ import com.intellij.openapi.compiler.generic.GenericCompiler;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.LowMemoryWatcher;
|
||||
import com.intellij.openapi.util.ShutDownTracker;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -48,14 +46,6 @@ public class CompilerCacheManager implements ProjectComponent {
|
||||
private final Map<GenericCompiler<?,?,?>, GenericCompilerCache<?,?,?>> myGenericCachesMap = new HashMap<GenericCompiler<?,?,?>, GenericCompilerCache<?,?,?>>();
|
||||
private final List<Disposable> myCacheDisposables = new ArrayList<Disposable>();
|
||||
private final File myCachesRoot;
|
||||
private LowMemoryWatcher myMemWatcher;
|
||||
|
||||
private final Runnable myShutdownTask = new Runnable() {
|
||||
public void run() {
|
||||
flushCaches();
|
||||
}
|
||||
};
|
||||
|
||||
private final Project myProject;
|
||||
|
||||
public CompilerCacheManager(Project project) {
|
||||
@@ -68,18 +58,9 @@ public class CompilerCacheManager implements ProjectComponent {
|
||||
}
|
||||
|
||||
public void projectOpened() {
|
||||
myMemWatcher = LowMemoryWatcher.register(new LowMemoryWatcher.ForceableAdapter() {
|
||||
public void force() {
|
||||
flushCaches();
|
||||
}
|
||||
});
|
||||
ShutDownTracker.getInstance().registerShutdownTask(myShutdownTask);
|
||||
}
|
||||
|
||||
public void projectClosed() {
|
||||
myMemWatcher.stop();
|
||||
ShutDownTracker.getInstance().unregisterShutdownTask(myShutdownTask);
|
||||
flushCaches();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -101,15 +82,17 @@ public class CompilerCacheManager implements ProjectComponent {
|
||||
}
|
||||
|
||||
public synchronized <Key, SourceState, OutputState> GenericCompilerCache<Key, SourceState, OutputState>
|
||||
getGenericCompilerCache(GenericCompiler<Key, SourceState, OutputState> compiler) throws IOException {
|
||||
getGenericCompilerCache(final GenericCompiler<Key, SourceState, OutputState> compiler) throws IOException {
|
||||
GenericCompilerCache<?,?,?> cache = myGenericCachesMap.get(compiler);
|
||||
if (cache == null) {
|
||||
final GenericCompilerCache<?,?,?> genericCache = new GenericCompilerCache<Key, SourceState, OutputState>(compiler, GenericCompilerRunner
|
||||
.getGenericCompilerCacheDir(myProject, compiler));
|
||||
myGenericCachesMap.put(compiler, genericCache);
|
||||
myCacheDisposables.add(new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Closing cache for feneric compiler " + compiler.getId());
|
||||
}
|
||||
genericCache.close();
|
||||
}
|
||||
});
|
||||
@@ -119,15 +102,17 @@ public class CompilerCacheManager implements ProjectComponent {
|
||||
return (GenericCompilerCache<Key, SourceState, OutputState>)cache;
|
||||
}
|
||||
|
||||
public synchronized FileProcessingCompilerStateCache getFileProcessingCompilerCache(FileProcessingCompiler compiler) throws IOException {
|
||||
public synchronized FileProcessingCompilerStateCache getFileProcessingCompilerCache(final FileProcessingCompiler compiler) throws IOException {
|
||||
Object cache = myCompilerToCacheMap.get(compiler);
|
||||
if (cache == null) {
|
||||
final FileProcessingCompilerStateCache stateCache = new FileProcessingCompilerStateCache(getCompilerRootDir(compiler),
|
||||
compiler
|
||||
);
|
||||
final File compilerRootDir = getCompilerRootDir(compiler);
|
||||
final FileProcessingCompilerStateCache stateCache = new FileProcessingCompilerStateCache(compilerRootDir, compiler);
|
||||
myCompilerToCacheMap.put(compiler, stateCache);
|
||||
myCacheDisposables.add(new Disposable() {
|
||||
public void dispose() {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Closing cache for compiler " + compiler.getDescription() + "; cache root dir: " + compilerRootDir);
|
||||
}
|
||||
stateCache.close();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -103,7 +103,7 @@ public class CachedPersistentHashMap<Key, Value> extends PersistentHashMap<Key,
|
||||
}
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
private void clearCache() {
|
||||
myCache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.debugger.engine;
|
||||
|
||||
import com.intellij.debugger.NoDataException;
|
||||
import com.intellij.debugger.PositionManager;
|
||||
import com.intellij.debugger.SourcePosition;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateException;
|
||||
@@ -24,7 +25,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.NullableComputable;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.Trinity;
|
||||
import com.intellij.psi.*;
|
||||
@@ -58,11 +59,11 @@ public class PositionManagerImpl implements PositionManager {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<Location> locationsOfLine(ReferenceType type,
|
||||
SourcePosition position) {
|
||||
public List<Location> locationsOfLine(ReferenceType type, SourcePosition position) throws NoDataException {
|
||||
try {
|
||||
int line = position.getLine() + 1;
|
||||
List<Location> locs = (getDebugProcess().getVirtualMachineProxy().versionHigher("1.4") ? type.locationsOfLine(DebugProcessImpl.JAVA_STRATUM, null, line) : type.locationsOfLine(line));
|
||||
List<Location> locs = (getDebugProcess().getVirtualMachineProxy().versionHigher("1.4")
|
||||
? type.locationsOfLine(DebugProcessImpl.JAVA_STRATUM, null, line) : type.locationsOfLine(line));
|
||||
if (locs.size() > 0) {
|
||||
return locs;
|
||||
}
|
||||
@@ -73,20 +74,20 @@ public class PositionManagerImpl implements PositionManager {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public ClassPrepareRequest createPrepareRequest(final ClassPrepareRequestor requestor, final SourcePosition position) {
|
||||
public ClassPrepareRequest createPrepareRequest(final ClassPrepareRequestor requestor, final SourcePosition position) throws NoDataException {
|
||||
final Ref<String> waitPrepareFor = new Ref<String>(null);
|
||||
final Ref<ClassPrepareRequestor> waitRequestor = new Ref<ClassPrepareRequestor>(null);
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
PsiClass psiClass = JVMNameUtil.getClassAt(position);
|
||||
if(psiClass == null) {
|
||||
if (psiClass == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(PsiUtil.isLocalOrAnonymousClass(psiClass)) {
|
||||
if (PsiUtil.isLocalOrAnonymousClass(psiClass)) {
|
||||
PsiClass parent = JVMNameUtil.getTopLevelParentClass(psiClass);
|
||||
|
||||
if(parent == null) {
|
||||
if (parent == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -122,7 +123,7 @@ public class PositionManagerImpl implements PositionManager {
|
||||
return myDebugProcess.getRequestsManager().createClassPrepareRequest(waitRequestor.get(), waitPrepareFor.get());
|
||||
}
|
||||
|
||||
public SourcePosition getSourcePosition(final Location location) {
|
||||
public SourcePosition getSourcePosition(final Location location) throws NoDataException {
|
||||
DebuggerManagerThreadImpl.assertIsManagerThread();
|
||||
if(location == null) {
|
||||
return null;
|
||||
@@ -204,7 +205,7 @@ public class PositionManagerImpl implements PositionManager {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<ReferenceType> getAllClasses(final SourcePosition classPosition) {
|
||||
public List<ReferenceType> getAllClasses(final SourcePosition classPosition) throws NoDataException {
|
||||
final Trinity<String, Boolean, PsiClass> trinity = calcClassName(classPosition);
|
||||
if (trinity == null) {
|
||||
return Collections.emptyList();
|
||||
@@ -231,7 +232,7 @@ public class PositionManagerImpl implements PositionManager {
|
||||
|
||||
@Nullable
|
||||
private static Trinity<String, Boolean, PsiClass> calcClassName(final SourcePosition classPosition) {
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<Trinity<String, Boolean, PsiClass>> () {
|
||||
return ApplicationManager.getApplication().runReadAction(new NullableComputable<Trinity<String, Boolean, PsiClass>>() {
|
||||
public Trinity<String, Boolean, PsiClass> compute() {
|
||||
final PsiClass psiClass = JVMNameUtil.getClassAt(classPosition);
|
||||
|
||||
@@ -296,7 +297,7 @@ public class PositionManagerImpl implements PositionManager {
|
||||
// First offsets belong to parent class, and offsets inside te substring "new Runnable(){" belong to anonymous runnable.
|
||||
final int finalRangeBegin = rangeBegin;
|
||||
final int finalRangeEnd = rangeEnd;
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<ReferenceType>() {
|
||||
return ApplicationManager.getApplication().runReadAction(new NullableComputable<ReferenceType>() {
|
||||
public ReferenceType compute() {
|
||||
final int line = Math.min(finalRangeBegin + 1, finalRangeEnd);
|
||||
final SourcePosition candidatePosition = SourcePosition.createFromLine(classToFind.getContainingFile(), line);
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.intellij.debugger.jdi.StackFrameProxyImpl;
|
||||
import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
|
||||
import com.intellij.debugger.requests.ClassPrepareRequestor;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.psi.PsiClass;
|
||||
@@ -41,14 +40,13 @@ import com.sun.jdi.ReferenceType;
|
||||
import com.sun.jdi.event.LocatableEvent;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Breakpoint extends FilteredRequestor implements ClassPrepareRequestor {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.breakpoints.Breakpoint");
|
||||
|
||||
public boolean ENABLED = true;
|
||||
public boolean LOG_ENABLED = false;
|
||||
public boolean LOG_EXPRESSION_ENABLED = false;
|
||||
@@ -134,7 +132,7 @@ public abstract class Breakpoint extends FilteredRequestor implements ClassPrepa
|
||||
}
|
||||
|
||||
protected void createOrWaitPrepare(final DebugProcessImpl debugProcess, final SourcePosition classPosition) {
|
||||
debugProcess.getRequestsManager().callbackOnPrepareClasses(Breakpoint.this, classPosition);
|
||||
debugProcess.getRequestsManager().callbackOnPrepareClasses(this, classPosition);
|
||||
|
||||
List list = debugProcess.getPositionManager().getAllClasses(classPosition);
|
||||
for (final Object aList : list) {
|
||||
@@ -163,7 +161,7 @@ public abstract class Breakpoint extends FilteredRequestor implements ClassPrepa
|
||||
return false;
|
||||
}
|
||||
|
||||
final String[] title = new String[] {DebuggerBundle.message("title.error.evaluating.breakpoint.condition") };
|
||||
final String[] title = {DebuggerBundle.message("title.error.evaluating.breakpoint.condition") };
|
||||
|
||||
try {
|
||||
final StackFrameProxyImpl frameProxy = context.getThread().frame(0);
|
||||
@@ -245,7 +243,7 @@ public abstract class Breakpoint extends FilteredRequestor implements ClassPrepa
|
||||
updateUI(EmptyRunnable.getInstance());
|
||||
}
|
||||
|
||||
public void updateUI(final Runnable afterUpdate) {
|
||||
public void updateUI(@NotNull Runnable afterUpdate) {
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
|
||||
+40
-57
@@ -36,6 +36,7 @@ import com.intellij.openapi.ui.ComboBox;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.FixedSizeButton;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.ui.FieldPanel;
|
||||
@@ -90,7 +91,7 @@ public abstract class BreakpointPropertiesPanel {
|
||||
private JButton myMakeDefaultButton;
|
||||
|
||||
ButtonGroup mySuspendPolicyGroup;
|
||||
public static final @NonNls String CONTROL_LOG_MESSAGE = "logMessage";
|
||||
@NonNls public static final String CONTROL_LOG_MESSAGE = "logMessage";
|
||||
private BreakpointComboboxHandler myBreakpointComboboxHandler;
|
||||
private static final int MAX_COMBO_WIDTH = 300;
|
||||
private final FixedSizeButton myConditionMagnifierButton;
|
||||
@@ -220,8 +221,7 @@ public abstract class BreakpointPropertiesPanel {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
reloadClassFilters();
|
||||
|
||||
ClassFilter classFilter;
|
||||
classFilter = createClassConditionFilter();
|
||||
ClassFilter classFilter = createClassConditionFilter();
|
||||
|
||||
EditClassFiltersDialog _dialog = new EditClassFiltersDialog(myProject, classFilter);
|
||||
_dialog.setFilters(myClassFilters, myClassExclusionFilters);
|
||||
@@ -321,7 +321,7 @@ public abstract class BreakpointPropertiesPanel {
|
||||
*/
|
||||
public void initFrom(Breakpoint breakpoint) {
|
||||
myBreakpointComboboxHandler.initFrom(breakpoint);
|
||||
myPassCountField.setText((breakpoint.COUNT_FILTER > 0)? Integer.toString(breakpoint.COUNT_FILTER) : "");
|
||||
myPassCountField.setText(breakpoint.COUNT_FILTER > 0 ? Integer.toString(breakpoint.COUNT_FILTER) : "");
|
||||
|
||||
PsiElement context = breakpoint.getEvaluationElement();
|
||||
myPassCountCheckbox.setSelected(breakpoint.COUNT_FILTER_ENABLED);
|
||||
@@ -367,7 +367,7 @@ public abstract class BreakpointPropertiesPanel {
|
||||
/**
|
||||
* Save values in the UI components to the breakpoint object
|
||||
*/
|
||||
public void saveTo(Breakpoint breakpoint, Runnable afterUpdate) {
|
||||
public void saveTo(Breakpoint breakpoint, @NotNull Runnable afterUpdate) {
|
||||
myBreakpointComboboxHandler.saveTo(breakpoint, myLeaveEnabledRadioButton.isSelected());
|
||||
try {
|
||||
String text = myPassCountField.getText().trim();
|
||||
@@ -379,11 +379,11 @@ public abstract class BreakpointPropertiesPanel {
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
breakpoint.COUNT_FILTER_ENABLED = breakpoint.COUNT_FILTER > 0? myPassCountCheckbox.isSelected() : false;
|
||||
breakpoint.COUNT_FILTER_ENABLED = breakpoint.COUNT_FILTER > 0 && myPassCountCheckbox.isSelected();
|
||||
breakpoint.setCondition(myConditionCombo.getText());
|
||||
breakpoint.CONDITION_ENABLED = !breakpoint.getCondition().isEmpty() ? myConditionCheckbox.isSelected() : false;
|
||||
breakpoint.CONDITION_ENABLED = !breakpoint.getCondition().isEmpty() && myConditionCheckbox.isSelected();
|
||||
breakpoint.setLogMessage(myLogExpressionCombo.getText());
|
||||
breakpoint.LOG_EXPRESSION_ENABLED = !breakpoint.getLogMessage().isEmpty()? myLogExpressionCheckBox.isSelected() : false;
|
||||
breakpoint.LOG_EXPRESSION_ENABLED = !breakpoint.getLogMessage().isEmpty() && myLogExpressionCheckBox.isSelected();
|
||||
breakpoint.LOG_ENABLED = myLogMessageCheckBox.isSelected();
|
||||
breakpoint.SUSPEND_POLICY = getSelectedSuspendPolicy();
|
||||
reloadInstanceFilters();
|
||||
@@ -391,8 +391,8 @@ public abstract class BreakpointPropertiesPanel {
|
||||
updateInstanceFilterEditor(true);
|
||||
updateClassFilterEditor(true);
|
||||
|
||||
breakpoint.INSTANCE_FILTERS_ENABLED = myInstanceFiltersField.getText().length() > 0 ? myInstanceFiltersCheckBox.isSelected() : false;
|
||||
breakpoint.CLASS_FILTERS_ENABLED = myClassFiltersField.getText().length() > 0 ? myClassFiltersCheckBox.isSelected() : false;
|
||||
breakpoint.INSTANCE_FILTERS_ENABLED = myInstanceFiltersField.getText().length() > 0 && myInstanceFiltersCheckBox.isSelected();
|
||||
breakpoint.CLASS_FILTERS_ENABLED = myClassFiltersField.getText().length() > 0 && myClassFiltersCheckBox.isSelected();
|
||||
breakpoint.setClassFilters(myClassFilters);
|
||||
breakpoint.setClassExclusionFilters(myClassExclusionFilters);
|
||||
breakpoint.setInstanceFilters(myInstanceFilters);
|
||||
@@ -402,21 +402,11 @@ public abstract class BreakpointPropertiesPanel {
|
||||
breakpoint.updateUI(afterUpdate);
|
||||
}
|
||||
|
||||
private String concatWith(List<String> s, String concator) {
|
||||
String result = "";
|
||||
for (Iterator iterator = s.iterator(); iterator.hasNext();) {
|
||||
String str = (String) iterator.next();
|
||||
result += str + concator;
|
||||
}
|
||||
if (result.length() > 0) {
|
||||
return result.substring(0, result.length() - concator.length());
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
private static String concatWith(List<String> s, String concator) {
|
||||
return StringUtil.join(s, concator);
|
||||
}
|
||||
|
||||
private String concatWithEx(List<String> s, String concator, int N, String NthConcator) {
|
||||
private static String concatWithEx(List<String> s, String concator, int N, String NthConcator) {
|
||||
String result = "";
|
||||
int i = 1;
|
||||
for (Iterator iterator = s.iterator(); iterator.hasNext(); i++) {
|
||||
@@ -435,9 +425,8 @@ public abstract class BreakpointPropertiesPanel {
|
||||
|
||||
private void updateInstanceFilterEditor(boolean updateText) {
|
||||
List<String> filters = new ArrayList<String>();
|
||||
for (int i = 0; i < myInstanceFilters.length; i++) {
|
||||
InstanceFilter instanceFilter = myInstanceFilters[i];
|
||||
if(instanceFilter.isEnabled()) {
|
||||
for (InstanceFilter instanceFilter : myInstanceFilters) {
|
||||
if (instanceFilter.isEnabled()) {
|
||||
filters.add(Long.toString(instanceFilter.getId()));
|
||||
}
|
||||
}
|
||||
@@ -465,38 +454,35 @@ public abstract class BreakpointPropertiesPanel {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < myInstanceFilters.length; i++) {
|
||||
InstanceFilter instanceFilter = myInstanceFilters[i];
|
||||
if(!instanceFilter.isEnabled()) idxs.add(instanceFilter);
|
||||
for (InstanceFilter instanceFilter : myInstanceFilters) {
|
||||
if (!instanceFilter.isEnabled()) idxs.add(instanceFilter);
|
||||
}
|
||||
myInstanceFilters = idxs.toArray(new InstanceFilter[idxs.size()]);
|
||||
}
|
||||
|
||||
private void updateClassFilterEditor(boolean updateText) {
|
||||
List<String> filters = new ArrayList<String>();
|
||||
for (int i = 0; i < myClassFilters.length; i++) {
|
||||
com.intellij.ui.classFilter.ClassFilter classFilter = myClassFilters[i];
|
||||
if(classFilter.isEnabled()) {
|
||||
for (com.intellij.ui.classFilter.ClassFilter classFilter : myClassFilters) {
|
||||
if (classFilter.isEnabled()) {
|
||||
filters.add(classFilter.getPattern());
|
||||
}
|
||||
}
|
||||
List<String> excludeFilters = new ArrayList<String>();
|
||||
for (int i = 0; i < myClassExclusionFilters.length; i++) {
|
||||
com.intellij.ui.classFilter.ClassFilter classFilter = myClassExclusionFilters[i];
|
||||
if(classFilter.isEnabled()) {
|
||||
for (com.intellij.ui.classFilter.ClassFilter classFilter : myClassExclusionFilters) {
|
||||
if (classFilter.isEnabled()) {
|
||||
excludeFilters.add("-" + classFilter.getPattern());
|
||||
}
|
||||
}
|
||||
if (updateText) {
|
||||
String editorText = concatWith(filters, " ");
|
||||
if(filters.size() > 0) editorText += " ";
|
||||
if(!filters.isEmpty()) editorText += " ";
|
||||
editorText += concatWith(excludeFilters, " ");
|
||||
myClassFiltersField.setText(editorText);
|
||||
}
|
||||
|
||||
int width = (int)Math.sqrt(myClassExclusionFilters.length + myClassFilters.length) + 1;
|
||||
String tipText = concatWithEx(filters, " ", width, "\n");
|
||||
if(filters.size() > 0) tipText += "\n";
|
||||
if(!filters.isEmpty()) tipText += "\n";
|
||||
tipText += concatWithEx(excludeFilters, " ", width, "\n");
|
||||
myClassFiltersField.getTextField().setToolTipText(tipText);
|
||||
|
||||
@@ -522,13 +508,11 @@ public abstract class BreakpointPropertiesPanel {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < myClassFilters.length; i++) {
|
||||
com.intellij.ui.classFilter.ClassFilter classFilter = myClassFilters[i];
|
||||
if(!classFilter.isEnabled()) classFilters.add(classFilter);
|
||||
for (com.intellij.ui.classFilter.ClassFilter classFilter : myClassFilters) {
|
||||
if (!classFilter.isEnabled()) classFilters.add(classFilter);
|
||||
}
|
||||
for (int i = 0; i < myClassExclusionFilters.length; i++) {
|
||||
com.intellij.ui.classFilter.ClassFilter classFilter = myClassExclusionFilters[i];
|
||||
if(!classFilter.isEnabled()) exclusionFilters.add(classFilter);
|
||||
for (com.intellij.ui.classFilter.ClassFilter classFilter : myClassExclusionFilters) {
|
||||
if (!classFilter.isEnabled()) exclusionFilters.add(classFilter);
|
||||
}
|
||||
myClassFilters = classFilters .toArray(new com.intellij.ui.classFilter.ClassFilter[classFilters .size()]);
|
||||
myClassExclusionFilters = exclusionFilters.toArray(new com.intellij.ui.classFilter.ClassFilter[exclusionFilters.size()]);
|
||||
@@ -537,18 +521,17 @@ public abstract class BreakpointPropertiesPanel {
|
||||
public void setEnabled(boolean enabled) {
|
||||
myPanel.setEnabled(enabled);
|
||||
Component[] components = myPanel.getComponents();
|
||||
for (int i = 0; i < components.length; i++) {
|
||||
Component component = components[i];
|
||||
for (Component component : components) {
|
||||
component.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateCheckboxes() {
|
||||
JCheckBox [] checkBoxes = new JCheckBox[] { myConditionCheckbox, myInstanceFiltersCheckBox, myClassFiltersCheckBox};
|
||||
JCheckBox [] checkBoxes = { myConditionCheckbox, myInstanceFiltersCheckBox, myClassFiltersCheckBox };
|
||||
JCheckBox selected = null;
|
||||
for(int i =0; i < checkBoxes.length; i++) {
|
||||
if(checkBoxes[i].isSelected()) {
|
||||
selected = checkBoxes[i];
|
||||
for (JCheckBox checkBoxe : checkBoxes) {
|
||||
if (checkBoxe.isSelected()) {
|
||||
selected = checkBoxe;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -559,8 +542,8 @@ public abstract class BreakpointPropertiesPanel {
|
||||
myPassCountCheckbox.setEnabled(true);
|
||||
}
|
||||
|
||||
for(int i =0; i < checkBoxes.length; i++) {
|
||||
checkBoxes[i].setEnabled (!myPassCountCheckbox.isSelected());
|
||||
for (JCheckBox checkBoxe : checkBoxes) {
|
||||
checkBoxe.setEnabled(!myPassCountCheckbox.isSelected());
|
||||
}
|
||||
|
||||
myPassCountField.setEditable(myPassCountCheckbox.isSelected());
|
||||
@@ -597,9 +580,8 @@ public abstract class BreakpointPropertiesPanel {
|
||||
}
|
||||
|
||||
public void selectBreakpoint(Breakpoint breakpoint) {
|
||||
for (int idx = 0; idx < myItems.length; idx++) {
|
||||
final ComboboxItem item = myItems[idx];
|
||||
if (breakpoint == null? item.getBreakpoint() == null : breakpoint.equals(item.getBreakpoint())) {
|
||||
for (final ComboboxItem item : myItems) {
|
||||
if (breakpoint == null ? item.getBreakpoint() == null : breakpoint.equals(item.getBreakpoint())) {
|
||||
if (!item.equals(getSelectedItem())) {
|
||||
setSelectedItem(item);
|
||||
}
|
||||
@@ -636,7 +618,7 @@ public abstract class BreakpointPropertiesPanel {
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return (breakpoint != null ? breakpoint.hashCode() : 0);
|
||||
return breakpoint != null ? breakpoint.hashCode() : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,8 +687,9 @@ public abstract class BreakpointPropertiesPanel {
|
||||
setText(text);
|
||||
final Icon icon;
|
||||
if (breakpoint != null) {
|
||||
icon = (breakpoint instanceof BreakpointWithHighlighter)?
|
||||
breakpoint.ENABLED? ((BreakpointWithHighlighter)breakpoint).getSetIcon(false) : ((BreakpointWithHighlighter)breakpoint).getDisabledIcon(false) : breakpoint.getIcon();
|
||||
icon = breakpoint instanceof BreakpointWithHighlighter ?
|
||||
breakpoint.ENABLED? ((BreakpointWithHighlighter)breakpoint).getSetIcon(false) : ((BreakpointWithHighlighter)breakpoint)
|
||||
.getDisabledIcon(false) : breakpoint.getIcon();
|
||||
}
|
||||
else {
|
||||
icon = null;
|
||||
|
||||
+8
-7
@@ -69,7 +69,7 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
|
||||
private SourcePosition mySourcePosition;
|
||||
|
||||
private boolean myVisible = true;
|
||||
private Icon myIcon = getSetIcon(false);
|
||||
private volatile Icon myIcon = getSetIcon(false);
|
||||
@Nullable private String myClassName;
|
||||
@Nullable private String myPackageName;
|
||||
@Nullable private String myInvalidMessage;
|
||||
@@ -317,7 +317,7 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
|
||||
/**
|
||||
* updates the state of breakpoint and all the related UI widgets etc
|
||||
*/
|
||||
public final void updateUI(final Runnable afterUpdate) {
|
||||
public final void updateUI(@NotNull final Runnable afterUpdate) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
return;
|
||||
}
|
||||
@@ -359,8 +359,9 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
|
||||
|
||||
private void updateGutter() {
|
||||
if(myVisible) {
|
||||
if (getHighlighter() != null && getHighlighter().isValid() && isValid()) {
|
||||
setupGutterRenderer();
|
||||
RangeHighlighter highlighter = getHighlighter();
|
||||
if (highlighter != null && highlighter.isValid() && isValid()) {
|
||||
setupGutterRenderer(highlighter);
|
||||
}
|
||||
else {
|
||||
DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().removeBreakpoint(this);
|
||||
@@ -369,7 +370,7 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
|
||||
}
|
||||
|
||||
/**
|
||||
* called by BreakpointManeger when destroying the breakpoint
|
||||
* called by BreakpointManager when destroying the breakpoint
|
||||
*/
|
||||
public void delete() {
|
||||
if (isVisible()) {
|
||||
@@ -414,9 +415,9 @@ public abstract class BreakpointWithHighlighter extends Breakpoint {
|
||||
});
|
||||
}
|
||||
|
||||
private void setupGutterRenderer() {
|
||||
private void setupGutterRenderer(@NotNull RangeHighlighter highlighter) {
|
||||
MyGutterIconRenderer renderer = new MyGutterIconRenderer(getIcon(), getDescription());
|
||||
getHighlighter().setGutterIconRenderer(renderer);
|
||||
highlighter.setGutterIconRenderer(renderer);
|
||||
}
|
||||
|
||||
public abstract Key<? extends BreakpointWithHighlighter> getCategory();
|
||||
|
||||
+2
-1
@@ -23,6 +23,7 @@ package com.intellij.debugger.ui.breakpoints;
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.ide.util.ClassFilter;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -99,7 +100,7 @@ public class ExceptionBreakpointPropertiesPanel extends BreakpointPropertiesPane
|
||||
myNotifyUncaughtCheckBox.setSelected(exceptionBreakpoint.NOTIFY_UNCAUGHT);
|
||||
}
|
||||
|
||||
public void saveTo(Breakpoint breakpoint, Runnable afterUpdate) {
|
||||
public void saveTo(Breakpoint breakpoint, @NotNull Runnable afterUpdate) {
|
||||
ExceptionBreakpoint exceptionBreakpoint = (ExceptionBreakpoint)breakpoint;
|
||||
exceptionBreakpoint.NOTIFY_CAUGHT = myNotifyCaughtCheckBox.isSelected();
|
||||
exceptionBreakpoint.NOTIFY_UNCAUGHT = myNotifyUncaughtCheckBox.isSelected();
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ package com.intellij.debugger.ui.breakpoints;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -90,7 +91,7 @@ public class FieldBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
|
||||
myWatchModificationCheckBox.setSelected(fieldBreakpoint.WATCH_MODIFICATION);
|
||||
}
|
||||
|
||||
public void saveTo(Breakpoint breakpoint, Runnable afterUpdate) {
|
||||
public void saveTo(Breakpoint breakpoint, @NotNull Runnable afterUpdate) {
|
||||
FieldBreakpoint fieldBreakpoint = (FieldBreakpoint)breakpoint;
|
||||
|
||||
fieldBreakpoint.WATCH_ACCESS = myWatchAccessCheckBox.isSelected();
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ package com.intellij.debugger.ui.breakpoints;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -95,7 +96,7 @@ public class MethodBreakpointPropertiesPanel extends BreakpointPropertiesPanel {
|
||||
}
|
||||
}
|
||||
|
||||
public void saveTo(Breakpoint breakpoint, Runnable afterUpdate) {
|
||||
public void saveTo(Breakpoint breakpoint, @NotNull Runnable afterUpdate) {
|
||||
if (breakpoint instanceof MethodBreakpoint) {
|
||||
MethodBreakpoint methodBreakpoint = (MethodBreakpoint)breakpoint;
|
||||
methodBreakpoint.WATCH_ENTRY = myWatchEntryCheckBox.isSelected();
|
||||
|
||||
@@ -25,16 +25,15 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public interface PositionManager {
|
||||
|
||||
@Nullable
|
||||
SourcePosition getSourcePosition(Location location) throws NoDataException;
|
||||
|
||||
@NotNull
|
||||
List<ReferenceType> getAllClasses(SourcePosition classPosition) throws NoDataException;
|
||||
|
||||
|
||||
@NotNull
|
||||
List<Location> locationsOfLine (ReferenceType type, SourcePosition position) throws NoDataException;
|
||||
List<Location> locationsOfLine(ReferenceType type, SourcePosition position) throws NoDataException;
|
||||
|
||||
@Nullable
|
||||
ClassPrepareRequest createPrepareRequest(ClassPrepareRequestor requestor, SourcePosition position)throws NoDataException;
|
||||
ClassPrepareRequest createPrepareRequest(ClassPrepareRequestor requestor, SourcePosition position) throws NoDataException;
|
||||
}
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class ApplicationConfigurationProducer extends JavaRuntimeConfigurationPr
|
||||
location = JavaExecutionUtil.stepIntoSingleClass(location);
|
||||
if (location == null) return null;
|
||||
final PsiElement element = location.getPsiElement();
|
||||
|
||||
if (!element.isPhysical()) return null;
|
||||
PsiElement currentElement = element;
|
||||
PsiMethod method;
|
||||
while ((method = findMain(currentElement)) != null) {
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import junit.runner.BaseTestRunner;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
@@ -209,6 +210,18 @@ public class JUnitUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static PsiMethod findFirstTestMethod(PsiClass clazz) {
|
||||
PsiMethod testMethod = null;
|
||||
for (PsiMethod method : clazz.getMethods()) {
|
||||
if (isTestMethod(MethodLocation.elementInClass(method, clazz)) || isSuiteMethod(method)) {
|
||||
testMethod = method;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return testMethod;
|
||||
}
|
||||
|
||||
public static class TestMethodFilter implements Condition<PsiMethod> {
|
||||
private final PsiClass myClass;
|
||||
|
||||
|
||||
+5
-5
@@ -29,7 +29,7 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContaine
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ParametrizedRunnable;
|
||||
import com.intellij.util.ParameterizedRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -45,13 +45,13 @@ public class AddCustomLibraryDialog extends DialogWrapper {
|
||||
private final LibrariesContainer myLibrariesContainer;
|
||||
private final Module myModule;
|
||||
private final ModifiableRootModel myModifiableRootModel;
|
||||
private final @Nullable ParametrizedRunnable<ModifiableRootModel> myBeforeLibraryAdded;
|
||||
private final @Nullable ParameterizedRunnable<ModifiableRootModel> myBeforeLibraryAdded;
|
||||
private final List<Library> myAddedLibraries = new ArrayList<Library>();
|
||||
|
||||
private AddCustomLibraryDialog(CustomLibraryDescription description, LibrariesContainer librariesContainer,
|
||||
Module module,
|
||||
ModifiableRootModel modifiableRootModel,
|
||||
@Nullable ParametrizedRunnable<ModifiableRootModel> beforeLibraryAdded) {
|
||||
@Nullable ParameterizedRunnable<ModifiableRootModel> beforeLibraryAdded) {
|
||||
super(module.getProject(), true);
|
||||
myLibrariesContainer = librariesContainer;
|
||||
myModule = module;
|
||||
@@ -68,14 +68,14 @@ public class AddCustomLibraryDialog extends DialogWrapper {
|
||||
|
||||
public static AddCustomLibraryDialog createDialog(@NotNull CustomLibraryDescription description,
|
||||
final @NotNull Module module,
|
||||
final ParametrizedRunnable<ModifiableRootModel> beforeLibraryAdded) {
|
||||
final ParameterizedRunnable<ModifiableRootModel> beforeLibraryAdded) {
|
||||
return createDialog(description, LibrariesContainerFactory.createContainer(module), module, null, beforeLibraryAdded);
|
||||
}
|
||||
|
||||
public static AddCustomLibraryDialog createDialog(CustomLibraryDescription description,
|
||||
final @NotNull LibrariesContainer librariesContainer, final @NotNull Module module,
|
||||
final @Nullable ModifiableRootModel modifiableRootModel,
|
||||
@Nullable ParametrizedRunnable<ModifiableRootModel> beforeLibraryAdded) {
|
||||
@Nullable ParameterizedRunnable<ModifiableRootModel> beforeLibraryAdded) {
|
||||
return new AddCustomLibraryDialog(description, librariesContainer, module, modifiableRootModel, beforeLibraryAdded);
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -84,9 +84,11 @@ public class JavadocOrderRootTypeUIFactory implements OrderRootTypeUIFactory {
|
||||
if (versionString != null) {
|
||||
final LanguageLevel level = LanguageLevelUtil.getDefaultLanguageLevel(versionString);
|
||||
if (level == LanguageLevel.JDK_1_5) {
|
||||
return "http://java.sun.com/j2se/1.5.0/docs/api/";
|
||||
return "http://download.oracle.com/javase/1.5.0/docs/api/";
|
||||
} else if (level == LanguageLevel.JDK_1_6) {
|
||||
return "http://java.sun.com/j2se/6/docs/api/";
|
||||
return "http://download.oracle.com/javase/6/docs/api/";
|
||||
} else if (level == LanguageLevel.JDK_1_7) {
|
||||
return "http://download.oracle.com/javase/7/docs/api/";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ public class DefaultInsertHandler extends TemplateInsertHandler implements Clone
|
||||
|
||||
final boolean needLeftParenth = isToInsertParenth(context, item);
|
||||
final boolean hasParams = needLeftParenth && hasParams(context, item);
|
||||
final boolean annotation = insertingAnnotation(context, item);
|
||||
|
||||
if (CompletionUtil.isOverwrite(item, completionChar)) {
|
||||
removeEndOfIdentifier(needLeftParenth && hasParams, context);
|
||||
@@ -106,15 +107,7 @@ public class DefaultInsertHandler extends TemplateInsertHandler implements Clone
|
||||
AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null);
|
||||
}
|
||||
|
||||
if (completionChar == '#') {
|
||||
context.setLaterRunnable(new Runnable() {
|
||||
public void run() {
|
||||
new CodeCompletionHandlerBase(CompletionType.BASIC).invoke(project, editor, file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (insertingAnnotation(context, item)) {
|
||||
if (annotation) {
|
||||
// Check if someone inserts annotation class that require @
|
||||
PsiElement elementAt = file.findElementAt(context.getStartOffset());
|
||||
final PsiElement parentElement = elementAt != null ? elementAt.getParent():null;
|
||||
@@ -323,7 +316,6 @@ public class DefaultInsertHandler extends TemplateInsertHandler implements Clone
|
||||
case ':': return TailType.CASE_COLON; //?
|
||||
case '<':
|
||||
case '>':
|
||||
case '#':
|
||||
case '\"':
|
||||
case '[': return TailType.createSimpleTailType(completionChar);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.codeInsight.completion;
|
||||
|
||||
import com.intellij.psi.javadoc.PsiDocTag;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.ThreeState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class FocusInJavadoc extends CompletionConfidence {
|
||||
@NotNull
|
||||
@Override
|
||||
public ThreeState shouldFocusLookup(@NotNull CompletionParameters parameters) {
|
||||
if (PsiTreeUtil.getParentOfType(parameters.getPosition(), PsiDocTag.class) != null) {
|
||||
return ThreeState.YES;
|
||||
}
|
||||
return ThreeState.UNSURE;
|
||||
}
|
||||
}
|
||||
+25
-2
@@ -17,6 +17,7 @@ package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.ExpectedTypeInfo;
|
||||
import com.intellij.codeInsight.ExpectedTypesProvider;
|
||||
import com.intellij.codeInsight.TailType;
|
||||
import com.intellij.lang.LangBundle;
|
||||
import com.intellij.lang.StdLanguages;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
@@ -32,6 +33,7 @@ import com.intellij.psi.filters.TrueFilter;
|
||||
import com.intellij.psi.filters.classes.ThisOrAnyInnerFilter;
|
||||
import com.intellij.psi.filters.element.ExcludeDeclaredFilter;
|
||||
import com.intellij.psi.filters.types.AssignableFromFilter;
|
||||
import com.intellij.psi.javadoc.PsiDocTag;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
@@ -66,8 +68,29 @@ public class JavaClassNameCompletionContributor extends CompletionContributor {
|
||||
return;
|
||||
}
|
||||
|
||||
if (completingRawConstructor(context, item) && !JavaCompletionUtil.hasAccessibleInnerClass(item.getObject(), file)) {
|
||||
ConstructorInsertHandler.insertParentheses(context, item, item.getObject());
|
||||
PsiElement position = file.findElementAt(offset);
|
||||
PsiClass psiClass = item.getObject();
|
||||
|
||||
if (context.getCompletionChar() == '#') {
|
||||
context.setLaterRunnable(new Runnable() {
|
||||
public void run() {
|
||||
new CodeCompletionHandlerBase(CompletionType.BASIC).invoke(context.getProject(), context.getEditor(), file);
|
||||
}
|
||||
});
|
||||
TailType.insertChar(context.getEditor(), context.getTailOffset(), '#');
|
||||
}
|
||||
|
||||
if (position != null) {
|
||||
PsiElement parent = position.getParent();
|
||||
if (parent instanceof PsiJavaCodeReferenceElement && PsiTreeUtil.getParentOfType(position, PsiDocTag.class) != null) {
|
||||
if (((PsiJavaCodeReferenceElement)parent).isReferenceTo(psiClass)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (completingRawConstructor(context, item) && !JavaCompletionUtil.hasAccessibleInnerClass(psiClass, file)) {
|
||||
ConstructorInsertHandler.insertParentheses(context, item, psiClass);
|
||||
DefaultInsertHandler.addImportForItem(context.getFile(), context.getStartOffset(), item);
|
||||
} else {
|
||||
new DefaultInsertHandler().handleInsert(context, item);
|
||||
|
||||
@@ -27,17 +27,13 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public class StaticMembersWeigher extends CompletionWeigher {
|
||||
public Comparable weigh(@NotNull LookupElement element, @NotNull CompletionLocation loc) {
|
||||
if (loc == null) {
|
||||
return null;
|
||||
}
|
||||
if (loc.getCompletionType() != CompletionType.BASIC) return 0;
|
||||
|
||||
final PsiElement position = loc.getCompletionParameters().getPosition();
|
||||
|
||||
// cheap weigher applicability goes first
|
||||
final Object o = element.getObject();
|
||||
if (!(o instanceof PsiMember)) return 0;
|
||||
|
||||
|
||||
final PsiElement position = loc.getCompletionParameters().getPosition();
|
||||
if (PsiTreeUtil.getParentOfType(position, PsiDocComment.class) != null) return 0;
|
||||
if (position.getParent() instanceof PsiReferenceExpression) {
|
||||
final PsiReferenceExpression refExpr = (PsiReferenceExpression)position.getParent();
|
||||
@@ -55,8 +51,9 @@ public class StaticMembersWeigher extends CompletionWeigher {
|
||||
if (o instanceof PsiField) return 4;
|
||||
}
|
||||
|
||||
if (o instanceof PsiClass && ((PsiClass) o).getContainingClass() != null) {
|
||||
return 3;
|
||||
if (o instanceof PsiClass) {
|
||||
if (((PsiClass) o).getContainingClass() != null) return 3;
|
||||
return 2;
|
||||
}
|
||||
|
||||
//instance method or field
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
|
||||
import com.intellij.codeInspection.ex.InspectionManagerEx;
|
||||
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
|
||||
import com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection;
|
||||
import com.intellij.codeInspection.unusedParameters.UnusedParametersInspection;
|
||||
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
|
||||
import com.intellij.codeInspection.util.SpecialAnnotationsUtil;
|
||||
import com.intellij.lang.Language;
|
||||
@@ -49,6 +50,7 @@ import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
@@ -172,29 +174,32 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
|
||||
|
||||
private void optimizeImportsOnTheFly(@NotNull final Editor editor) {
|
||||
if (myHasRedundantImports || myHasMissortedImports) {
|
||||
invokeOnTheFlyImportOptimizer(new Runnable() {
|
||||
public void run() {
|
||||
if (myProject.isDisposed() || editor.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
OptimizeImportsFix optimizeImportsFix = new OptimizeImportsFix();
|
||||
if (optimizeImportsFix.isAvailable(myProject, editor, myFile) && myFile.isWritable()) {
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
final OptimizeImportsFix optimizeImportsFix = new OptimizeImportsFix();
|
||||
if (optimizeImportsFix.isAvailable(myProject, editor, myFile) && myFile.isWritable()) {
|
||||
invokeOnTheFlyImportOptimizer(new Runnable() {
|
||||
public void run() {
|
||||
optimizeImportsFix.invoke(myProject, editor, myFile);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, myFile, editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void invokeOnTheFlyImportOptimizer(final Runnable runnable) {
|
||||
public static void invokeOnTheFlyImportOptimizer(@NotNull final Runnable runnable, @NotNull final PsiFile file, @NotNull final Editor editor) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
if (file.getProject().isDisposed() || editor.isDisposed()) return;
|
||||
PsiDocumentManager.getInstance(file.getProject()).commitAllDocuments();
|
||||
String beforeText = file.getText();
|
||||
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(runnable);
|
||||
}
|
||||
});
|
||||
String afterText = file.getText();
|
||||
if (Comparing.strEqual(beforeText, afterText)) {
|
||||
LOG.error("Import optimizer for the '"+file.getVirtualFile().getPath()+"' hasn't optimized any imports. Text:\n"+afterText);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -263,6 +268,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
|
||||
return processField((PsiField)parent, identifier, progress);
|
||||
}
|
||||
if (parent instanceof PsiParameter && myUnusedSymbolInspection.PARAMETER) {
|
||||
if (InspectionManagerEx.isSuppressed(identifier, UnusedParametersInspection.SHORT_NAME)) return null;
|
||||
return processParameter((PsiParameter)parent, progress);
|
||||
}
|
||||
if (parent instanceof PsiMethod && myUnusedSymbolInspection.METHOD) {
|
||||
|
||||
@@ -807,6 +807,9 @@ public class JavaDocInfoGenerator {
|
||||
" background-color: #eeeeee;" +
|
||||
" margin-bottom: 10px;" +
|
||||
" }" +
|
||||
" p {" +
|
||||
" margin: 5px 0;" +
|
||||
" }" +
|
||||
" </style>" +
|
||||
"</head><body>");
|
||||
}
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class InferNullityAnnotationsAction extends BaseAnalysisAction {
|
||||
private JCheckBox myAnnotateLocalVariablesCb;
|
||||
|
||||
public InferNullityAnnotationsAction() {
|
||||
super("Infer nullity", INFER_NULLITY_ANNOTATIONS);
|
||||
super("Infer Nullity", INFER_NULLITY_ANNOTATIONS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+21
-10
@@ -97,6 +97,7 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
|
||||
public boolean IGNORE_DEPRECATED = false;
|
||||
public boolean IGNORE_JAVADOC_PERIOD = true;
|
||||
public boolean IGNORE_DUPLICATED_THROWS = false;
|
||||
public boolean IGNORE_POINT_TO_ITSELF = false;
|
||||
public String myAdditionalJavadocTags = "";
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("com.intellij.codeInspection.javaDoc.JavaDocLocalInspection");
|
||||
@@ -252,6 +253,14 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
|
||||
}
|
||||
});
|
||||
add(ignoreDuplicateThrowsCheckBox, gc);
|
||||
|
||||
final JCheckBox ignorePointToItselfCheckBox = new JCheckBox("Ignore javadoc pointing to itself", IGNORE_POINT_TO_ITSELF);
|
||||
ignorePointToItselfCheckBox.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
IGNORE_POINT_TO_ITSELF = ignorePointToItselfCheckBox.isSelected();
|
||||
}
|
||||
});
|
||||
add(ignorePointToItselfCheckBox, gc);
|
||||
}
|
||||
|
||||
public FieldPanel createAdditionalJavadocTagsPanel(){
|
||||
@@ -951,16 +960,18 @@ public class JavaDocLocalInspection extends BaseLocalInspectionTool {
|
||||
if (manager.getTagInfo(inlineDocTag.getName()) == null) {
|
||||
checkTagInfo(inspectionManager, null, inlineDocTag, isOnTheFly, problems);
|
||||
}
|
||||
final PsiDocTagValue value = inlineDocTag.getValueElement();
|
||||
if (value != null) {
|
||||
final PsiReference reference = value.getReference();
|
||||
if (reference != null) {
|
||||
final PsiElement ref = reference.resolve();
|
||||
if (ref != null){
|
||||
if (PsiTreeUtil.getParentOfType(inlineDocTag, PsiDocCommentOwner.class) == PsiTreeUtil.getParentOfType(ref, PsiDocCommentOwner.class, false)) {
|
||||
if (nameElement != null) {
|
||||
problems.add(createDescriptor(nameElement, InspectionsBundle.message("inspection.javadoc.problem.pointing.to.itself"), inspectionManager,
|
||||
isOnTheFly));
|
||||
if (!IGNORE_POINT_TO_ITSELF) {
|
||||
final PsiDocTagValue value = inlineDocTag.getValueElement();
|
||||
if (value != null) {
|
||||
final PsiReference reference = value.getReference();
|
||||
if (reference != null) {
|
||||
final PsiElement ref = reference.resolve();
|
||||
if (ref != null){
|
||||
if (PsiTreeUtil.getParentOfType(inlineDocTag, PsiDocCommentOwner.class) == PsiTreeUtil.getParentOfType(ref, PsiDocCommentOwner.class, false)) {
|
||||
if (nameElement != null) {
|
||||
problems.add(createDescriptor(nameElement, InspectionsBundle.message("inspection.javadoc.problem.pointing.to.itself"), inspectionManager,
|
||||
isOnTheFly));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -40,6 +40,7 @@ import com.intellij.psi.util.PsiModificationTracker;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.changeSignature.ChangeSignatureProcessor;
|
||||
import com.intellij.refactoring.changeSignature.ParameterInfoImpl;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -49,6 +50,8 @@ import java.util.List;
|
||||
|
||||
public class UnusedParametersInspection extends GlobalJavaInspectionTool {
|
||||
|
||||
@NonNls public static final String SHORT_NAME = "UnusedParameters";
|
||||
|
||||
@Nullable
|
||||
public CommonProblemDescriptor[] checkElement(final RefEntity refEntity,
|
||||
final AnalysisScope scope,
|
||||
@@ -204,7 +207,7 @@ public class UnusedParametersInspection extends GlobalJavaInspectionTool {
|
||||
|
||||
@NotNull
|
||||
public String getShortName() {
|
||||
return "UnusedParameters";
|
||||
return SHORT_NAME;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-21
@@ -16,35 +16,20 @@
|
||||
|
||||
package com.intellij.codeInspection.unusedSymbol;
|
||||
|
||||
import com.intellij.ExtensionPoints;
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInsight.daemon.GroupNames;
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
|
||||
import com.intellij.codeInspection.ex.EntryPointsManager;
|
||||
import com.intellij.codeInspection.ex.EntryPointsManagerImpl;
|
||||
import com.intellij.codeInspection.ex.UnfairLocalInspectionTool;
|
||||
import com.intellij.codeInspection.reference.EntryPoint;
|
||||
import com.intellij.codeInspection.util.SpecialAnnotationsUtil;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
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.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
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;
|
||||
@@ -54,8 +39,6 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
@@ -170,13 +153,10 @@ public class UnusedSymbolLocalInspection extends BaseJavaLocalInspectionTool imp
|
||||
|
||||
public static IntentionAction createQuickFix(final String qualifiedName, String element, Project project) {
|
||||
final EntryPointsManagerImpl entryPointsManager = EntryPointsManagerImpl.getInstance(project);
|
||||
final ArrayList<String> targetList = new ArrayList<String>();
|
||||
targetList.addAll(entryPointsManager.ADDITIONAL_ANNOTATIONS);
|
||||
targetList.addAll(entryPointsManager.getAdditionalAnnotations());
|
||||
return SpecialAnnotationsUtil.createAddToSpecialAnnotationsListIntentionAction(
|
||||
QuickFixBundle.message("fix.unused.symbol.injection.text", element, qualifiedName),
|
||||
QuickFixBundle.message("fix.unused.symbol.injection.family"),
|
||||
targetList, qualifiedName);
|
||||
entryPointsManager.ADDITIONAL_ANNOTATIONS, qualifiedName);
|
||||
}
|
||||
|
||||
public static boolean isInjected(final PsiModifierListOwner modifierListOwner) {
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
*/
|
||||
package com.intellij.ide.projectView.impl;
|
||||
|
||||
import com.intellij.history.LocalHistory;
|
||||
import com.intellij.history.LocalHistoryAction;
|
||||
import com.intellij.ide.DeleteProvider;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.SelectInTarget;
|
||||
import com.intellij.ide.impl.PackagesPaneSelectInTarget;
|
||||
@@ -27,6 +30,7 @@ import com.intellij.ide.projectView.ViewSettings;
|
||||
import com.intellij.ide.projectView.impl.nodes.PackageElement;
|
||||
import com.intellij.ide.projectView.impl.nodes.PackageUtil;
|
||||
import com.intellij.ide.projectView.impl.nodes.PackageViewProjectNode;
|
||||
import com.intellij.ide.util.DeleteHandler;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeBuilder;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeNode;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeStructure;
|
||||
@@ -51,13 +55,12 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public final class PackageViewPane extends AbstractProjectViewPSIPane {
|
||||
@NonNls public static final String ID = "PackagesPane";
|
||||
public static final Icon ICON = IconLoader.getIcon("/general/packagesTab.png");
|
||||
private MyDeletePSIElementProvider myDeletePSIElementProvider = new MyDeletePSIElementProvider();
|
||||
|
||||
public PackageViewPane(Project project) {
|
||||
super(project);
|
||||
@@ -91,6 +94,12 @@ public final class PackageViewPane extends AbstractProjectViewPSIPane {
|
||||
|
||||
@Override
|
||||
public Object getData(final String dataId) {
|
||||
if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) {
|
||||
final PackageElement selectedPackageElement = getSelectedPackageElement();
|
||||
if (selectedPackageElement != null) {
|
||||
return myDeletePSIElementProvider;
|
||||
}
|
||||
}
|
||||
if (PackageElement.DATA_KEY.is(dataId)) {
|
||||
final PackageElement packageElement = getSelectedPackageElement();
|
||||
}
|
||||
@@ -290,4 +299,30 @@ public final class PackageViewPane extends AbstractProjectViewPSIPane {
|
||||
return modules.toArray(new Module[modules.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
private final class MyDeletePSIElementProvider implements DeleteProvider {
|
||||
public boolean canDeleteElement(DataContext dataContext) {
|
||||
for (PsiDirectory directory : getSelectedDirectories()) {
|
||||
if (!directory.getManager().isInProject(directory)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void deleteElement(DataContext dataContext) {
|
||||
List<PsiDirectory> allElements = Arrays.asList(getSelectedDirectories());
|
||||
List<PsiElement> validElements = new ArrayList<PsiElement>();
|
||||
for (PsiElement psiElement : allElements) {
|
||||
if (psiElement != null && psiElement.isValid()) validElements.add(psiElement);
|
||||
}
|
||||
final PsiElement[] elements = validElements.toArray(new PsiElement[validElements.size()]);
|
||||
|
||||
LocalHistoryAction a = LocalHistory.getInstance().startAction(IdeBundle.message("progress.deleting"));
|
||||
try {
|
||||
DeleteHandler.deletePsiElement(elements, myProject);
|
||||
}
|
||||
finally {
|
||||
a.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,4 +115,11 @@ class AnchorElementInfo implements SmartPointerElementInfo {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (myMarker != null) {
|
||||
myMarker.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -43,6 +43,10 @@ public class ImplicitVariableElementInfoFactory implements SmartPointerElementIn
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Document getDocumentToSynchronize() {
|
||||
return null;
|
||||
|
||||
+4
@@ -42,6 +42,10 @@ public class ImportListElementInfoFactory implements SmartPointerElementInfoFact
|
||||
return myFile.getImportList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
public Document getDocumentToSynchronize() {
|
||||
return null;
|
||||
}
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class PsiExpressionStatementImpl extends CompositePsiElement implements P
|
||||
public PsiExpression getExpression() {
|
||||
PsiExpression expression = (PsiExpression)SourceTreeToPsiMap.treeElementToPsi(findChildByType(ElementType.EXPRESSION_BIT_SET));
|
||||
if (expression != null) return expression;
|
||||
LOG.error("Illegal PSI. Children: " + DebugUtil.psiToString(this, false));
|
||||
LOG.error("Illegal PSI: \n" + DebugUtil.psiToString(getParent(), false));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+20
-10
@@ -197,16 +197,26 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
continue;
|
||||
}
|
||||
|
||||
PsiType returnType1 = method.getReturnType();
|
||||
PsiType returnType2 = existingMethod.getReturnType();
|
||||
if (returnType1 != null && returnType2 != null) {
|
||||
returnType1 = infoSubstitutor.substitute(returnType1);
|
||||
returnType2 = existing.getSubstitutor().substitute(returnType2);
|
||||
if (returnType1.isAssignableFrom(returnType2) &&
|
||||
(InheritanceUtil.isInheritorOrSelf(class1, existingClass, true) ||
|
||||
InheritanceUtil.isInheritorOrSelf(existingClass, class1, true))) {
|
||||
conflicts.remove(i);
|
||||
i--;
|
||||
if (InheritanceUtil.isInheritorOrSelf(class1, existingClass, true) ||
|
||||
InheritanceUtil.isInheritorOrSelf(existingClass, class1, true)) {
|
||||
PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
final PsiParameter[] existingParameters = existingMethod.getParameterList().getParameters();
|
||||
for (int i1 = 0, parametersLength = parameters.length; i1 < parametersLength; i1++) {
|
||||
if (parameters[i1].getType() instanceof PsiArrayType &&
|
||||
!(existingParameters[i1].getType() instanceof PsiArrayType)) {//prefer more specific type
|
||||
signatures.put(signature, info);
|
||||
continue nextConflict;
|
||||
}
|
||||
}
|
||||
PsiType returnType1 = method.getReturnType();
|
||||
PsiType returnType2 = existingMethod.getReturnType();
|
||||
if (returnType1 != null && returnType2 != null) {
|
||||
returnType1 = infoSubstitutor.substitute(returnType1);
|
||||
returnType2 = existing.getSubstitutor().substitute(returnType2);
|
||||
if (returnType1.isAssignableFrom(returnType2)) {
|
||||
conflicts.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -102,6 +102,8 @@ public class IntroduceConstantHandler extends BaseExpressionToFieldHandler {
|
||||
if (ref instanceof PsiLocalVariable) {
|
||||
localVariable = (PsiLocalVariable)ref;
|
||||
}
|
||||
} else if (anchorElement instanceof PsiLocalVariable) {
|
||||
localVariable = (PsiLocalVariable)anchorElement;
|
||||
}
|
||||
|
||||
if (localVariable == null) {
|
||||
|
||||
+4
-2
@@ -88,11 +88,13 @@ public class IntroduceFieldHandler extends BaseExpressionToFieldHandler {
|
||||
if (ref instanceof PsiLocalVariable) {
|
||||
localVariable = (PsiLocalVariable)ref;
|
||||
}
|
||||
} else if (anchorElement instanceof PsiLocalVariable) {
|
||||
localVariable = (PsiLocalVariable)anchorElement;
|
||||
}
|
||||
|
||||
int occurencesNumber = occurences.length;
|
||||
final boolean currentMethodConstructor = containingMethod != null && containingMethod.isConstructor();
|
||||
final boolean allowInitInMethod = (!currentMethodConstructor || !isInSuperOrThis) && anchorElement instanceof PsiStatement;
|
||||
final boolean allowInitInMethod = (!currentMethodConstructor || !isInSuperOrThis) && anchorElement instanceof PsiLocalVariable;
|
||||
final boolean allowInitInMethodIfAll = (!currentMethodConstructor || !isInSuperOrThis) && anchorElementIfAll instanceof PsiStatement;
|
||||
IntroduceFieldDialog dialog = new IntroduceFieldDialog(
|
||||
project, parentClass, expr, localVariable,
|
||||
@@ -139,7 +141,7 @@ public class IntroduceFieldHandler extends BaseExpressionToFieldHandler {
|
||||
PsiExpression[] occurences,
|
||||
boolean isStatic) {
|
||||
final PsiStatement statement = PsiTreeUtil.getParentOfType(local, PsiStatement.class);
|
||||
return IntroduceFieldHandler.this.showRefactoringDialog(project, editor, aClass, local.getInitializer(), local.getType(), occurences, statement, statement);
|
||||
return IntroduceFieldHandler.this.showRefactoringDialog(project, editor, aClass, local.getInitializer(), local.getType(), occurences, local, statement);
|
||||
}
|
||||
};
|
||||
return localToFieldHandler.convertLocalToField(localVariable, editor);
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
final Yy<caret>
|
||||
|
||||
private static class YyyXxx {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class YyyZzz {}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
|
||||
{
|
||||
Object o = getUD<caret>
|
||||
}
|
||||
|
||||
final String getUserDataString() {}
|
||||
final <T> T getUserData(T t) {}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
class A{
|
||||
{
|
||||
String str;
|
||||
str.toCharArray();
|
||||
str.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
class A{
|
||||
{
|
||||
final String path = BASE_PATH;
|
||||
path.toCharArray()<caret>;
|
||||
path.toString()<caret>;
|
||||
sdkfjsdkhjfh();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -2,12 +2,12 @@ import org.junit.*;
|
||||
public class T {
|
||||
private int i;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
i = 9;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,12 @@ import org.junit.Test;
|
||||
public class T {
|
||||
private int i;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
i = 9;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,11 @@ import junit.framework.TestCase;
|
||||
public class T extends TestCase {
|
||||
private int i;
|
||||
|
||||
public void test() {
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
i = 9;
|
||||
}
|
||||
|
||||
public void test() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ class Base extends TestCase {
|
||||
public class T extends Base {
|
||||
private int i;
|
||||
|
||||
public void test() {
|
||||
}
|
||||
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
i = 9;
|
||||
}
|
||||
|
||||
public void test() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
public class PsiChangesTest {
|
||||
private int a;
|
||||
private int b;
|
||||
|
||||
PsiChangesTest() {
|
||||
}
|
||||
|
||||
void foo() {
|
||||
}
|
||||
|
||||
void bar() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
public class PsiChangesTest {
|
||||
protected int a;
|
||||
private int c;
|
||||
|
||||
PsiChangesTest() {
|
||||
int i = 0;
|
||||
}
|
||||
|
||||
void foo() {
|
||||
int i = 0;
|
||||
}
|
||||
|
||||
void bar2() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
a : Modified
|
||||
b : Deleted
|
||||
c : Added
|
||||
@@ -0,0 +1,4 @@
|
||||
PsiChangesTest : Modified
|
||||
foo : Modified
|
||||
bar : Deleted
|
||||
bar2 : Added
|
||||
@@ -0,0 +1 @@
|
||||
При
|
||||
@@ -0,0 +1 @@
|
||||
<html></html>
|
||||
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0"?>
|
||||
<web-app>
|
||||
</web-app>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="IBM866"?>
|
||||
<web-app>
|
||||
<!--¯ ¯ -->
|
||||
</web-app>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app>
|
||||
<!--папа-->
|
||||
</web-app>
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
<?xml encoding='Big5' version='1.0' ?>
|
||||
<web-app>
|
||||
</web-app>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="windows-1251"?>
|
||||
<web-app>
|
||||
<!--ïàïà-->
|
||||
</web-app>
|
||||
@@ -0,0 +1 @@
|
||||
test text
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
Empty file
|
||||
@@ -217,4 +217,28 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase {
|
||||
assert lookup
|
||||
}
|
||||
|
||||
public void testFocusInJavadoc() {
|
||||
myFixture.configureByText("a.java", """
|
||||
/**
|
||||
* {@link ArrLi<caret>}
|
||||
*/
|
||||
class Foo {}
|
||||
""")
|
||||
type 's'
|
||||
assert lookup.focused
|
||||
|
||||
}
|
||||
|
||||
public void testPrefixLengthDependentSorting() {
|
||||
myFixture.addClass("package foo; public class PsiJavaCodeReferenceElement {}")
|
||||
myFixture.configureByText("a.java", """
|
||||
class PsiJavaCodeReferenceElementImpl {
|
||||
{ <caret> }
|
||||
}
|
||||
""")
|
||||
type 'PJCR'
|
||||
assertOrderedEquals myFixture.lookupElementStrings, 'PsiJavaCodeReferenceElement', 'PsiJavaCodeReferenceElementImpl'
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
@@ -112,6 +112,10 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
checkPreferredItems(0, "Xxy", "Xxx", "XxxEx", "XxxImpl");
|
||||
}
|
||||
|
||||
public void testPreferOwnInnerClasses() throws Throwable {
|
||||
checkPreferredItems(0, "YyyXxx", "YyyZzz");
|
||||
}
|
||||
|
||||
public void testDontDispreferImplsAfterNew() throws Throwable {
|
||||
VfsUtil.saveText(getSourceRoot().createChildDirectory(this, "foo").createChildData(this, "Xxx.java"), "package foo; public interface Xxx {}");
|
||||
checkPreferredItems(0, "Xxx", "XxxImpl");
|
||||
|
||||
+4
@@ -203,6 +203,10 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
checkPreferredItems(0, "Goo", "InnerGoo", "Bar", "AGoo");
|
||||
}
|
||||
|
||||
public void testPrefixOutweighsGenericity() throws Throwable {
|
||||
checkPreferredItems(0, "getUserData", "getUserDataString");
|
||||
}
|
||||
|
||||
public void testLocalVariablesOutweighStats() throws Throwable {
|
||||
final LookupImpl lookup = invokeCompletion(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertPreferredItems(0, "foo", "param", "this", "bar", "goo");
|
||||
|
||||
@@ -72,26 +72,8 @@ public class InspectionProfileTest extends UsefulTestCase {
|
||||
|
||||
private static Element loadOldStyleProfile() throws IOException, JDOMException {
|
||||
final Document document = JDOMUtil.loadDocument("<inspections version=\"1.0\" is_locked=\"false\">\n" +
|
||||
" <option name=\"myName\" value=\"" + PROFILE + "\" />\n" +
|
||||
" <option name=\"myName\" value=\"ToConvert\" />\n" +
|
||||
" <option name=\"myLocal\" value=\"true\" />\n" +
|
||||
" <used_levels>\n" +
|
||||
" <error>\n" +
|
||||
" <option name=\"myName\" value=\"ERROR\" />\n" +
|
||||
" <option name=\"myVal\" value=\"400\" />\n" +
|
||||
" </error>\n" +
|
||||
" <warning>\n" +
|
||||
" <option name=\"myName\" value=\"WARNING\" />\n" +
|
||||
" <option name=\"myVal\" value=\"300\" />\n" +
|
||||
" </warning>\n" +
|
||||
" <information>\n" +
|
||||
" <option name=\"myName\" value=\"INFO\" />\n" +
|
||||
" <option name=\"myVal\" value=\"200\" />\n" +
|
||||
" </information>\n" +
|
||||
" <server>\n" +
|
||||
" <option name=\"myName\" value=\"SERVER PROBLEM\" />\n" +
|
||||
" <option name=\"myVal\" value=\"100\" />\n" +
|
||||
" </server>\n" +
|
||||
" </used_levels>\n" +
|
||||
" <inspection_tool class=\"JavaDoc\" enabled=\"false\" level=\"WARNING\" enabled_by_default=\"false\">\n" +
|
||||
" <option name=\"TOP_LEVEL_CLASS_OPTIONS\">\n" +
|
||||
" <value>\n" +
|
||||
@@ -119,6 +101,7 @@ public class InspectionProfileTest extends UsefulTestCase {
|
||||
" <option name=\"IGNORE_DEPRECATED\" value=\"false\" />\n" +
|
||||
" <option name=\"IGNORE_JAVADOC_PERIOD\" value=\"false\" />\n" +
|
||||
" <option name=\"IGNORE_DUPLICATED_THROWS\" value=\"false\" />\n" +
|
||||
" <option name=\"IGNORE_POINT_TO_ITSELF\" value=\"false\" />\n" +
|
||||
" <option name=\"myAdditionalJavadocTags\" value=\"tag1,tag2 \" />\n" +
|
||||
" </inspection_tool>\n" +
|
||||
"</inspections>");
|
||||
@@ -127,7 +110,7 @@ public class InspectionProfileTest extends UsefulTestCase {
|
||||
|
||||
private static Element loadProfile() throws IOException, JDOMException {
|
||||
final Document document = JDOMUtil.loadDocument("<inspections version=\"1.0\" is_locked=\"false\">\n" +
|
||||
" <option name=\"myName\" value=\"" + PROFILE + "\" />\n" +
|
||||
" <option name=\"myName\" value=\"ToConvert\" />\n" +
|
||||
" <option name=\"myLocal\" value=\"true\" />\n" +
|
||||
" <inspection_tool class=\"JavaDoc\" enabled=\"false\" level=\"WARNING\" enabled_by_default=\"false\">\n" +
|
||||
" <option name=\"TOP_LEVEL_CLASS_OPTIONS\">\n" +
|
||||
@@ -156,6 +139,7 @@ public class InspectionProfileTest extends UsefulTestCase {
|
||||
" <option name=\"IGNORE_DEPRECATED\" value=\"false\" />\n" +
|
||||
" <option name=\"IGNORE_JAVADOC_PERIOD\" value=\"false\" />\n" +
|
||||
" <option name=\"IGNORE_DUPLICATED_THROWS\" value=\"false\" />\n" +
|
||||
" <option name=\"IGNORE_POINT_TO_ITSELF\" value=\"false\" />\n" +
|
||||
" <option name=\"myAdditionalJavadocTags\" value=\"tag1,tag2 \" />\n" +
|
||||
" </inspection_tool>\n" +
|
||||
"</inspections>");
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.intellij.openapi.vfs;
|
||||
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.vfs.ex.dummy.DummyFileSystem;
|
||||
import com.intellij.testFramework.IdeaTestCase;
|
||||
|
||||
public class DummyFileSystemTest extends IdeaTestCase {
|
||||
DummyFileSystem fs;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
fs = new DummyFileSystem();
|
||||
}
|
||||
|
||||
public void testDeletionEvents() throws Exception {
|
||||
final VirtualFile root = fs.createRoot("root");
|
||||
VirtualFile f = new WriteAction<VirtualFile>() {
|
||||
@Override
|
||||
protected void run(Result<VirtualFile> result) throws Throwable {
|
||||
VirtualFile res = root.createChildData(null, "f");
|
||||
result.setResult(res);
|
||||
}
|
||||
}.execute().getResultObject();
|
||||
|
||||
final VirtualFileEvent[] events = new VirtualFileEvent[2];
|
||||
fs.addVirtualFileListener(new VirtualFileAdapter() {
|
||||
@Override
|
||||
public void fileDeleted(VirtualFileEvent e) {
|
||||
events[0] = e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeFileDeletion(VirtualFileEvent e) {
|
||||
events[1] = e;
|
||||
}
|
||||
});
|
||||
|
||||
f.delete(null);
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
assertNotNull(events[i]);
|
||||
assertEquals(f, events[i].getFile());
|
||||
assertEquals("f", events[i].getFileName());
|
||||
assertEquals(root, events[i].getParent());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.intellij.openapi.vfs;
|
||||
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.testFramework.IdeaTestCase;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class GetPathPerformanceTest extends IdeaTestCase {
|
||||
public void testGetPath() throws IOException {
|
||||
File dir = createTempDirectory();
|
||||
try {
|
||||
File subdir1 = new File(dir, "1");
|
||||
File subdir2 = new File(dir, "2");
|
||||
subdir1.mkdir();
|
||||
subdir2.mkdir();
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
new File(subdir1, "" + i).createNewFile();
|
||||
new File(subdir2, "" + i).createNewFile();
|
||||
}
|
||||
VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(dir.getPath().replace(File.separatorChar, '/'));
|
||||
assertNotNull(file);
|
||||
|
||||
final VirtualFile[] children = file.getChildren();
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for( int i = 0; i < 1000000; ++i ) {
|
||||
for( VirtualFile child: children) {
|
||||
child.getPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
IdeaTestUtil.assertTiming("Performance failed", 3000, runnable);
|
||||
}
|
||||
finally {
|
||||
FileUtil.delete(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.intellij.openapi.vfs;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.testFramework.IdeaTestCase;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class JarFileSystemTest extends IdeaTestCase{
|
||||
public void testFindFile() throws Exception{
|
||||
Sdk jdk = ModuleRootManager.getInstance(myModule).getSdk();
|
||||
VirtualFile jdkHome = jdk.getHomeDirectory();
|
||||
String rtJarPath = new File(jdkHome.getPath() + "/src.zip").getCanonicalPath().replace(File.separator, "/");
|
||||
|
||||
VirtualFile file1 = findByPath(rtJarPath + JarFileSystem.JAR_SEPARATOR);
|
||||
assertTrue(file1.isDirectory());
|
||||
|
||||
VirtualFile file2 = findByPath(rtJarPath + JarFileSystem.JAR_SEPARATOR + "java");
|
||||
assertTrue(file2.isDirectory());
|
||||
|
||||
VirtualFile file3 = file1.findChild("java");
|
||||
assertEquals(file2, file3);
|
||||
|
||||
VirtualFile file4 = findByPath(rtJarPath + JarFileSystem.JAR_SEPARATOR + "java/lang/Object.java");
|
||||
assertTrue(!file4.isDirectory());
|
||||
|
||||
byte[] bytes = file4.contentsToByteArray();
|
||||
assertNotNull(bytes);
|
||||
assertTrue(bytes.length > 10);
|
||||
}
|
||||
|
||||
public void testMetaInf() throws Exception{
|
||||
Sdk jdk = ModuleRootManager.getInstance(myModule).getSdk();
|
||||
VirtualFile jdkHome = jdk.getHomeDirectory();
|
||||
String rtJarPath = jdkHome.getPath() + "/jre/lib/rt.jar";
|
||||
|
||||
VirtualFile jarRoot = JarFileSystem.getInstance().findFileByPath(rtJarPath + JarFileSystem.JAR_SEPARATOR);
|
||||
assertNotNull(jarRoot);
|
||||
|
||||
VirtualFile metaInf = jarRoot.findChild("META-INF");
|
||||
assertNotNull(metaInf);
|
||||
|
||||
VirtualFile[] children = metaInf.getChildren();
|
||||
assertEquals(1, children.length);
|
||||
}
|
||||
|
||||
private static VirtualFile findByPath(String path) {
|
||||
VirtualFile file = JarFileSystem.getInstance().findFileByPath(path);
|
||||
assertNotNull(file);
|
||||
final String filePath = file.getPath();
|
||||
final String message = "paths are not equal, path1 = " + path + " found: " + filePath;
|
||||
if (SystemInfo.isFileSystemCaseSensitive) {
|
||||
assertEquals(message, path, file.getPath());
|
||||
}
|
||||
else {
|
||||
assertTrue(message, path.equalsIgnoreCase(filePath));
|
||||
}
|
||||
return file;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
package com.intellij.openapi.vfs;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vfs.impl.win32.Win32LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.newvfs.ManagingFS;
|
||||
import com.intellij.testFramework.IdeaTestCase;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class LocalFileSystemTest extends IdeaTestCase{
|
||||
private static final String KEY = "filesystem.useNative";
|
||||
|
||||
public void testChildrenAccessedButNotCached() throws Exception{
|
||||
ApplicationManager.getApplication().runWriteAction(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
File dir = createTempDirectory();
|
||||
final ManagingFS managingFS = ManagingFS.getInstance();
|
||||
|
||||
VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(dir.getPath().replace(File.separatorChar, '/'));
|
||||
assertNotNull(vFile);
|
||||
assertFalse(managingFS.areChildrenLoaded(vFile));
|
||||
assertFalse(managingFS.wereChildrenAccessed(vFile));
|
||||
|
||||
final File child = new File(dir, "child");
|
||||
final boolean created = child.createNewFile();
|
||||
assertTrue(created);
|
||||
|
||||
final File subdir = new File(dir, "subdir");
|
||||
final boolean subdirCreated = subdir.mkdir();
|
||||
assertTrue(subdirCreated);
|
||||
|
||||
final File subChild = new File(subdir, "subdir");
|
||||
final boolean subChildCreated = subChild.createNewFile();
|
||||
assertTrue(subChildCreated);
|
||||
|
||||
final VirtualFile childVFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(child.getPath().replace(File.separatorChar, '/'));
|
||||
assertNotNull(childVFile);
|
||||
assertFalse(managingFS.areChildrenLoaded(vFile));
|
||||
assertTrue(managingFS.wereChildrenAccessed(vFile));
|
||||
|
||||
final VirtualFile subdirVFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(subdir.getPath().replace(File.separatorChar, '/'));
|
||||
assertNotNull(subdirVFile);
|
||||
assertFalse(managingFS.areChildrenLoaded(subdirVFile));
|
||||
assertFalse(managingFS.wereChildrenAccessed(subdirVFile));
|
||||
|
||||
assertFalse(managingFS.areChildrenLoaded(vFile));
|
||||
assertTrue(managingFS.wereChildrenAccessed(vFile));
|
||||
|
||||
|
||||
vFile.getChildren();
|
||||
assertTrue(managingFS.areChildrenLoaded(vFile));
|
||||
assertTrue(managingFS.wereChildrenAccessed(vFile));
|
||||
assertFalse(managingFS.areChildrenLoaded(subdirVFile));
|
||||
assertFalse(managingFS.wereChildrenAccessed(subdirVFile));
|
||||
|
||||
final VirtualFile subChildVFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(subChild.getPath().replace(File.separatorChar, '/'));
|
||||
assertNotNull(subChildVFile);
|
||||
assertTrue(managingFS.areChildrenLoaded(vFile));
|
||||
assertTrue(managingFS.wereChildrenAccessed(vFile));
|
||||
assertFalse(managingFS.areChildrenLoaded(subdirVFile));
|
||||
assertTrue(managingFS.wereChildrenAccessed(subdirVFile));
|
||||
}
|
||||
catch(IOException e){
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public void testRefreshAndFindFile() throws Exception{
|
||||
ApplicationManager.getApplication().runWriteAction(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
File dir = createTempDirectory();
|
||||
|
||||
VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(dir.getPath().replace(File.separatorChar, '/'));
|
||||
assertNotNull(vFile);
|
||||
vFile.getChildren();
|
||||
|
||||
for(int i = 0; i < 100; i++){
|
||||
File subdir = new File(dir, "a" + i);
|
||||
assertTrue(subdir.mkdir());
|
||||
}
|
||||
|
||||
File subdir = new File(dir, "aaa");
|
||||
assertTrue(subdir.mkdir());
|
||||
|
||||
VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(subdir.getPath().replace(File.separatorChar, '/'));
|
||||
assertNotNull(file);
|
||||
}
|
||||
catch(IOException e){
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public void testCopyFile() throws Exception{
|
||||
ApplicationManager.getApplication().runWriteAction(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
File fromDir = createTempDirectory();
|
||||
File toDir = createTempDirectory();
|
||||
|
||||
VirtualFile fromVDir = LocalFileSystem.getInstance().findFileByPath(fromDir.getPath().replace(File.separatorChar, '/'));
|
||||
VirtualFile toVDir = LocalFileSystem.getInstance().findFileByPath(toDir.getPath().replace(File.separatorChar, '/'));
|
||||
assertNotNull(fromVDir);
|
||||
assertNotNull(toVDir);
|
||||
final VirtualFile fileToCopy = fromVDir.createChildData(null, "temp_file");
|
||||
final byte[] byteContent = {0, 1, 2, 3};
|
||||
fileToCopy.setBinaryContent(byteContent);
|
||||
final String newName = "new_temp_file";
|
||||
final VirtualFile copy = fileToCopy.copy(null, toVDir, newName);
|
||||
assertEquals(newName, copy.getName());
|
||||
assertTrue(Arrays.equals(byteContent, copy.contentsToByteArray()));
|
||||
}
|
||||
catch(Exception e){
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public void testCopyDir() throws Exception{
|
||||
ApplicationManager.getApplication().runWriteAction(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
File fromDir = createTempDirectory();
|
||||
File toDir = createTempDirectory();
|
||||
|
||||
VirtualFile fromVDir = LocalFileSystem.getInstance().findFileByPath(fromDir.getPath().replace(File.separatorChar, '/'));
|
||||
VirtualFile toVDir = LocalFileSystem.getInstance().findFileByPath(toDir.getPath().replace(File.separatorChar, '/'));
|
||||
assertNotNull(fromVDir);
|
||||
assertNotNull(toVDir);
|
||||
final VirtualFile dirToCopy = fromVDir.createChildDirectory(null, "dir");
|
||||
final VirtualFile file = dirToCopy.createChildData(null, "temp_file");
|
||||
file.setBinaryContent(new byte[]{0, 1, 2, 3});
|
||||
final String newName = "dir";
|
||||
final VirtualFile dirCopy = dirToCopy.copy(null, toVDir, newName);
|
||||
assertEquals(newName, dirCopy.getName());
|
||||
IdeaTestUtil.assertDirectoriesEqual(toVDir, fromVDir, null);
|
||||
}
|
||||
catch(Exception e){
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public void testGermanLetters() throws Exception{
|
||||
final File dirFile = createTempDirectory();
|
||||
|
||||
final String name = "te\u00dft123123123.txt";
|
||||
final File childFile = new File(dirFile, name);
|
||||
childFile.createNewFile();
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
final VirtualFile dir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dirFile);
|
||||
assertNotNull(dir);
|
||||
|
||||
final VirtualFile child = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(childFile);
|
||||
assertNotNull(child);
|
||||
|
||||
}
|
||||
catch(Exception e){
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
assertTrue(childFile.delete());
|
||||
}
|
||||
|
||||
public void _testSymLinks() throws Exception {
|
||||
ApplicationManager.getApplication().runWriteAction(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
boolean b = Registry.get(KEY).asBoolean();
|
||||
try{
|
||||
Registry.get(KEY).setValue(false);
|
||||
final VirtualFile dir = LocalFileSystem.getInstance().refreshAndFindFileByPath("C:/Documents and Settings");
|
||||
Win32LocalFileSystem system = Win32LocalFileSystem.getWin32Instance();
|
||||
system.exists(dir);
|
||||
String[] strings = system.list(dir);
|
||||
System.out.println(Arrays.asList(strings));
|
||||
}
|
||||
catch(Exception e){
|
||||
fail(e.getMessage());
|
||||
}
|
||||
finally {
|
||||
Registry.get(KEY).setValue(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.intellij.openapi.vfs;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.testFramework.IdeaTestCase;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class RefreshChildrenTest extends IdeaTestCase {
|
||||
private File testDir;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
|
||||
// the superclass sets tmpdir on every run and cleans up, but we want to do it our way
|
||||
|
||||
String baseTempDir = FileUtil.getTempDirectory();
|
||||
testDir = new File(baseTempDir, "RefreshChildrenTest." + getName());
|
||||
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
FileUtil.delete(testDir);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testRefreshSeesLatestDirectoryContents() throws Exception {
|
||||
assertFalse(testDir.exists());
|
||||
testDir.mkdir();
|
||||
assertTrue(testDir.isDirectory());
|
||||
writeFile(testDir, "Foo.java", "");
|
||||
|
||||
LocalFileSystem local = LocalFileSystem.getInstance();
|
||||
VirtualFile virtualDir = local.findFileByIoFile(testDir);
|
||||
virtualDir.getChildren();
|
||||
virtualDir.refresh(false, true);
|
||||
|
||||
checkChildCount(virtualDir, 1);
|
||||
|
||||
writeFile(testDir, "Bar.java", "");
|
||||
virtualDir.refresh(false, true);
|
||||
|
||||
checkChildCount(virtualDir, 2);
|
||||
}
|
||||
|
||||
private void writeFile(File dir, String filename, String contents) throws IOException {
|
||||
Writer writer = new OutputStreamWriter(new FileOutputStream(new File(dir, filename)), "UTF-8");
|
||||
writer.write(contents);
|
||||
writer.close();
|
||||
}
|
||||
|
||||
private void checkChildCount(VirtualFile virtualDir, int expectedCount) {
|
||||
VirtualFile[] children = virtualDir.getChildren();
|
||||
if (children.length != expectedCount) {
|
||||
System.err.println("children:");
|
||||
for (VirtualFile child : children) {
|
||||
System.err.println(child.getPath());
|
||||
}
|
||||
}
|
||||
assertEquals(expectedCount, children.length);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
package com.intellij.openapi.vfs;
|
||||
|
||||
import com.intellij.concurrency.JobUtil;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.testFramework.IdeaTestCase;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class VfsUtilTest extends IdeaTestCase {
|
||||
@Override
|
||||
protected void runBareRunnable(Runnable runnable) throws Throwable {
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
VfsUtilTest.super.setUp();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
VfsUtilTest.super.tearDown();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testFindFileByUrl() throws Exception {
|
||||
VirtualFile file0;
|
||||
|
||||
// Should not find in jre jars - it creates a lot of VirtualFileImpl!
|
||||
|
||||
// file0 = VfsUtil.findFileByURL(ClassLoader.getSystemResource("java/lang/Object.class"));
|
||||
// assertNotNull(file0);
|
||||
// assertFalse(file0.isDirectory());
|
||||
//
|
||||
// file0 = VfsUtil.findFileByURL(ClassLoader.getSystemResource("com/sun"));
|
||||
// assertNotNull(file0);
|
||||
// assertTrue(file0.isDirectory());
|
||||
|
||||
File file1 = new File(PathManagerEx.getTestDataPath());
|
||||
file1 = new File(file1, "vfs");
|
||||
file1 = new File(file1, "findFileByUrl");
|
||||
file0 = VfsUtil.findFileByURL(file1.toURL());
|
||||
assertNotNull(file0);
|
||||
assertTrue(file0.isDirectory());
|
||||
final VirtualFile[] children = file0.getChildren();
|
||||
List<VirtualFile> list = new ArrayList<VirtualFile>();
|
||||
final VirtualFileFilter fileFilter = new VirtualFileFilter() {
|
||||
@Override
|
||||
public boolean accept(VirtualFile file) {
|
||||
return IdeaTestUtil.CVS_FILE_FILTER.accept(file) && !file.getName().endsWith(".new");
|
||||
}
|
||||
};
|
||||
for (VirtualFile child : children) {
|
||||
if (fileFilter.accept(child)) {
|
||||
list.add(child);
|
||||
}
|
||||
}
|
||||
assertEquals(2, list.size()); // "CVS" dir ignored
|
||||
|
||||
File file2 = new File(file1, "test.zip");
|
||||
URL url2 = file2.toURL();
|
||||
url2 = new URL("jar", "", url2.toExternalForm() + "!/");
|
||||
url2 = new URL(url2, "com/intellij/installer");
|
||||
url2 = new URL(url2.toExternalForm());
|
||||
file0 = VfsUtil.findFileByURL(url2);
|
||||
assertNotNull(file0);
|
||||
assertTrue(file0.isDirectory());
|
||||
|
||||
File file3 = new File(file1, "1.txt");
|
||||
file0 = VfsUtil.findFileByURL(file3.toURL());
|
||||
String content = VfsUtil.loadText(file0);
|
||||
assertNotNull(file0);
|
||||
assertFalse(file0.isDirectory());
|
||||
assertEquals(content, "test text");
|
||||
}
|
||||
|
||||
public void testRelativePath() throws Exception {
|
||||
final File root = new File(PathManagerEx.getTestDataPath());
|
||||
final File testRoot = new File(new File(root, "vfs"), "relativePath");
|
||||
VirtualFile vTestRoot = LocalFileSystem.getInstance().findFileByIoFile(testRoot);
|
||||
assertNotNull(vTestRoot);
|
||||
assertTrue(vTestRoot.isDirectory());
|
||||
|
||||
final File subDir = new File(testRoot, "subDir");
|
||||
final VirtualFile vSubDir = LocalFileSystem.getInstance().findFileByIoFile(subDir);
|
||||
assertNotNull(vSubDir);
|
||||
|
||||
final File subSubDir = new File(subDir, "subSubDir");
|
||||
final VirtualFile vSubSubDir = LocalFileSystem.getInstance().findFileByIoFile(subSubDir);
|
||||
assertNotNull(vSubSubDir);
|
||||
|
||||
assertEquals("subDir", VfsUtil.getRelativePath(vSubDir, vTestRoot, '/'));
|
||||
assertEquals("subDir/subSubDir", VfsUtil.getRelativePath(vSubSubDir, vTestRoot, '/'));
|
||||
assertEquals("", VfsUtil.getRelativePath(vTestRoot, vTestRoot, '/'));
|
||||
}
|
||||
|
||||
public void testAsyncRefresh() throws Throwable {
|
||||
final Throwable[] ex = {null};
|
||||
JobUtil.invokeConcurrentlyUnderProgress(Arrays.asList(new Object[8]), new Processor<Object>() {
|
||||
@Override
|
||||
public boolean process(Object o) {
|
||||
try {
|
||||
doAsyncRefreshTest();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
ex[0] = t;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}, false, ProgressManager.getInstance().getProgressIndicator());
|
||||
if (ex[0] != null) throw ex[0];
|
||||
}
|
||||
|
||||
private void doAsyncRefreshTest() throws Exception {
|
||||
int N = 1000;
|
||||
File temp = new WriteAction<File>() {
|
||||
@Override
|
||||
protected void run(Result<File> result) throws Throwable {
|
||||
File res = createTempDirectory();
|
||||
result.setResult(res);
|
||||
}
|
||||
}.execute().getResultObject();
|
||||
LocalFileSystem fs = LocalFileSystem.getInstance();
|
||||
VirtualFile vtemp = fs.findFileByIoFile(temp);
|
||||
assert vtemp != null;
|
||||
VirtualFile[] children = new VirtualFile[N];
|
||||
|
||||
long[] timestamp = new long[N];
|
||||
for (int i=0;i< N;i++) {
|
||||
File file = new File(temp, i + ".txt");
|
||||
FileUtil.writeToFile(file, "xxx".getBytes());
|
||||
VirtualFile child = fs.findFileByIoFile(file);
|
||||
assertNotNull(child);
|
||||
children[i] = child;
|
||||
timestamp[i] = file.lastModified();
|
||||
}
|
||||
|
||||
vtemp.refresh(false,true);
|
||||
|
||||
for (int i=0;i< N;i++) {
|
||||
File file = new File(temp, i + ".txt");
|
||||
assertEquals(timestamp[i], file.lastModified());
|
||||
}
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
File file = new File(temp, i + ".txt");
|
||||
VirtualFile child = fs.findFileByIoFile(file);
|
||||
assertNotNull(child);
|
||||
|
||||
long mod = child.getTimeStamp();
|
||||
assertEquals("File:"+child.getPath()+"; mod:"+ new Date(mod)+"; io:"+new File(child.getPath()).lastModified(),timestamp[i], mod);
|
||||
}
|
||||
|
||||
Thread.sleep(300);
|
||||
for (int i=0;i< N;i++) {
|
||||
File file = new File(temp, i + ".txt");
|
||||
FileUtil.writeToFile(file, "xxx".getBytes());
|
||||
long modified = file.lastModified();
|
||||
assertTrue(timestamp[i] != modified);
|
||||
timestamp[i] = modified;
|
||||
assertTrue(children[i].getTimeStamp() != modified);
|
||||
}
|
||||
|
||||
final CountDownLatch latch = new CountDownLatch(N);
|
||||
for (final VirtualFile child : children) {
|
||||
child.refresh(true, true, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
}
|
||||
while (true) {
|
||||
latch.await(100, TimeUnit.MILLISECONDS);
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
}
|
||||
else {
|
||||
UIUtil.pump();
|
||||
}
|
||||
if (latch.getCount() == 0) break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
VirtualFile child = children[i];
|
||||
long mod = child.getTimeStamp();
|
||||
assertEquals(timestamp[i], mod);
|
||||
}
|
||||
}
|
||||
|
||||
public void testFindChildWithTrailingSpace() throws IOException {
|
||||
File tempDir = new WriteAction<File>() {
|
||||
@Override
|
||||
protected void run(Result<File> result) throws Throwable {
|
||||
File res = createTempDirectory();
|
||||
result.setResult(res);
|
||||
}
|
||||
}.execute().getResultObject();
|
||||
VirtualFile vdir = LocalFileSystem.getInstance().findFileByIoFile(tempDir);
|
||||
assertNotNull(vdir);
|
||||
assertTrue(vdir.isDirectory());
|
||||
|
||||
VirtualFile child = vdir.findChild(" ");
|
||||
assertNull(child);
|
||||
|
||||
assertEmpty(vdir.getChildren());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,400 @@
|
||||
package com.intellij.openapi.vfs;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointer;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointerListener;
|
||||
import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager;
|
||||
import com.intellij.testFramework.IdeaTestCase;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author dsl
|
||||
*/
|
||||
public class VirtualFilePointerTest extends IdeaTestCase {
|
||||
private VirtualFilePointerManager myVirtualFilePointerManager;
|
||||
|
||||
static class LoggingListener implements VirtualFilePointerListener {
|
||||
private final ArrayList<String> myLog = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
public void beforeValidityChanged(VirtualFilePointer[] pointers) {
|
||||
verifyPointersInCorrectState(pointers);
|
||||
myLog.add(buildMessage("before", pointers));
|
||||
}
|
||||
|
||||
private static String buildMessage(@NonNls final String startMsg, VirtualFilePointer[] pointers) {
|
||||
StringBuilder buffer = new StringBuilder(startMsg);
|
||||
buffer.append(":");
|
||||
for (int i = 0; i < pointers.length; i++) {
|
||||
VirtualFilePointer pointer = pointers[i];
|
||||
final String s = Boolean.toString(pointer.isValid());
|
||||
if (i > 0) buffer.append(":");
|
||||
buffer.append(s);
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validityChanged(VirtualFilePointer[] pointers) {
|
||||
verifyPointersInCorrectState(pointers);
|
||||
myLog.add(buildMessage("after", pointers));
|
||||
}
|
||||
|
||||
public ArrayList<String> getLog() {
|
||||
return myLog;
|
||||
}
|
||||
}
|
||||
|
||||
public void testDelete() throws Exception {
|
||||
File tempDirectory = createTempDirectory();
|
||||
final File fileToDelete = new File(tempDirectory, "toDelete.txt");
|
||||
fileToDelete.createNewFile();
|
||||
final LoggingListener fileToDeleteListener = new LoggingListener();
|
||||
final VirtualFilePointer fileToDeletePointer = createPointerByFile(fileToDelete, fileToDeleteListener);
|
||||
assertTrue(fileToDeletePointer.isValid());
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final VirtualFile virtualFile = getVirtualFile(fileToDelete);
|
||||
try {
|
||||
virtualFile.delete(null);
|
||||
} catch (IOException e) {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
assertFalse(fileToDeletePointer.isValid());
|
||||
assertEquals("[before:true, after:false]", fileToDeleteListener.getLog().toString());
|
||||
myFilesToDelete.add(tempDirectory);
|
||||
}
|
||||
|
||||
public void testCreate() throws Exception {
|
||||
final File tempDirectory = createTempDirectory();
|
||||
final File fileToCreate = new File(tempDirectory, "toCreate.txt");
|
||||
final LoggingListener fileToCreateListener = new LoggingListener();
|
||||
final VirtualFilePointer fileToCreatePointer = createPointerByFile(fileToCreate, fileToCreateListener);
|
||||
assertFalse(fileToCreatePointer.isValid());
|
||||
fileToCreate.createNewFile();
|
||||
final Runnable postRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
assertTrue(fileToCreatePointer.isValid());
|
||||
assertEquals("[before:false, after:true]", fileToCreateListener.getLog().toString());
|
||||
try {
|
||||
String expectedUrl = VirtualFileManager.constructUrl(LocalFileSystem.PROTOCOL, fileToCreate.getCanonicalPath().replace(File.separatorChar, '/'));
|
||||
assertEquals(expectedUrl.toUpperCase(), fileToCreatePointer.getUrl().toUpperCase());
|
||||
} catch (IOException e) {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
};
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run () {
|
||||
VirtualFileManager.getInstance().refresh(false);
|
||||
final VirtualFile virtualFile = getVirtualFile(tempDirectory);
|
||||
virtualFile.refresh(false, true);
|
||||
}
|
||||
});
|
||||
postRunnable.run();
|
||||
myFilesToDelete.add(fileToCreate);
|
||||
myFilesToDelete.add(tempDirectory);
|
||||
}
|
||||
|
||||
public void testMove() throws Exception {
|
||||
File tempDirectory = createTempDirectory();
|
||||
final File moveTarget = new File(tempDirectory, "moveTarget");
|
||||
moveTarget.mkdir();
|
||||
final File fileToMove = new File(tempDirectory, "toMove.txt");
|
||||
fileToMove.createNewFile();
|
||||
|
||||
final LoggingListener fileToMoveListener = new LoggingListener();
|
||||
final VirtualFilePointer fileToMovePointer = createPointerByFile(fileToMove, fileToMoveListener);
|
||||
assertTrue(fileToMovePointer.isValid());
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final VirtualFile virtualFile = getVirtualFile(fileToMove);
|
||||
assertTrue(virtualFile.isValid());
|
||||
final VirtualFile target = getVirtualFile(moveTarget);
|
||||
assertTrue(target.isValid());
|
||||
try {
|
||||
virtualFile.move(null, target);
|
||||
} catch (IOException e) {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
});
|
||||
assertTrue(fileToMovePointer.isValid());
|
||||
assertEquals("[]", fileToMoveListener.getLog().toString());
|
||||
final File fileAfterMove = new File(moveTarget, fileToMove.getName());
|
||||
myFilesToDelete.add(fileAfterMove);
|
||||
myFilesToDelete.add(moveTarget);
|
||||
myFilesToDelete.add(tempDirectory);
|
||||
}
|
||||
|
||||
public void testCreate1() throws Exception {
|
||||
final File tempDirectory = createTempDirectory();
|
||||
final File fileToCreate = new File(tempDirectory, "toCreate1.txt");
|
||||
final LoggingListener fileToCreateListener = new LoggingListener();
|
||||
final VirtualFilePointer fileToCreatePointer = createPointerByFile(fileToCreate, fileToCreateListener);
|
||||
assertFalse(fileToCreatePointer.isValid());
|
||||
fileToCreate.createNewFile();
|
||||
final Runnable postRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
assertTrue(fileToCreatePointer.isValid());
|
||||
assertEquals("[before:false, after:true]", fileToCreateListener.getLog().toString());
|
||||
try {
|
||||
String expectedUrl = VirtualFileManager.constructUrl(LocalFileSystem.PROTOCOL, fileToCreate.getCanonicalPath().replace(File.separatorChar, '/'));
|
||||
assertEquals(expectedUrl.toUpperCase(), fileToCreatePointer.getUrl().toUpperCase());
|
||||
} catch (IOException e) {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
};
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run () {
|
||||
VirtualFileManager.getInstance().refresh(false);
|
||||
final VirtualFile virtualFile = getVirtualFile(tempDirectory);
|
||||
virtualFile.refresh(false, true);
|
||||
}
|
||||
});
|
||||
postRunnable.run();
|
||||
myFilesToDelete.add(fileToCreate);
|
||||
myFilesToDelete.add(tempDirectory);
|
||||
}
|
||||
|
||||
public void testMultipleNotifications() throws Exception {
|
||||
final File tempDir = createTempDirectory();
|
||||
final File file_f1 = new File(tempDir, "f1");
|
||||
final File file_f2 = new File(tempDir, "f2");
|
||||
final LoggingListener listener = new LoggingListener();
|
||||
final VirtualFilePointer pointer_f1 = createPointerByFile(file_f1, listener);
|
||||
final VirtualFilePointer pointer_f2 = createPointerByFile(file_f2, listener);
|
||||
assertFalse(pointer_f1.isValid());
|
||||
assertFalse(pointer_f2.isValid());
|
||||
file_f1.createNewFile();
|
||||
file_f2.createNewFile();
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LocalFileSystem.getInstance().refresh(false);
|
||||
}
|
||||
});
|
||||
assertEquals("[before:false:false, after:true:true]", listener.getLog().toString());
|
||||
myFilesToDelete.add(file_f1);
|
||||
myFilesToDelete.add(file_f2);
|
||||
}
|
||||
|
||||
public void testJars() throws Exception {
|
||||
final File tempDir = createTempDirectory();
|
||||
final File jarParent = new File(tempDir, "jarParent");
|
||||
jarParent.mkdir();
|
||||
final File jar = new File(jarParent, "x.jar");
|
||||
final File originalJar = new File(PathManagerEx.getTestDataPath() + "/psi/generics22/collect-2.2.jar".replace('/', File.separatorChar));
|
||||
FileUtil.copy(originalJar, jar);
|
||||
|
||||
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(jar); // Make sure we receive events when jar changes
|
||||
|
||||
final VirtualFilePointer[] pointersToWatch = new VirtualFilePointer[2];
|
||||
final VirtualFilePointerListener listener = new VirtualFilePointerListener() {
|
||||
@Override
|
||||
public void beforeValidityChanged(VirtualFilePointer[] pointers) {
|
||||
verifyPointersInCorrectState(pointersToWatch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validityChanged(VirtualFilePointer[] pointers) {
|
||||
verifyPointersInCorrectState(pointersToWatch);
|
||||
}
|
||||
};
|
||||
final VirtualFilePointer jarParentPointer = createPointerByFile(jarParent, listener);
|
||||
final String pathInJar = jar.getPath().replace(File.separatorChar, '/') + JarFileSystem.JAR_SEPARATOR;
|
||||
final String jarUrl = VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL,
|
||||
pathInJar);
|
||||
final VirtualFilePointer jarPointer = myVirtualFilePointerManager.create(jarUrl, myProject, listener);
|
||||
pointersToWatch[0] = jarParentPointer;
|
||||
pointersToWatch[1] = jarPointer;
|
||||
assertTrue(jarParentPointer.isValid());
|
||||
assertTrue(jarPointer.isValid());
|
||||
|
||||
jar.delete();
|
||||
jarParent.delete();
|
||||
refreshVFS();
|
||||
|
||||
verifyPointersInCorrectState(pointersToWatch);
|
||||
assertFalse(jarParentPointer.isValid());
|
||||
assertFalse(jarPointer.isValid());
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
|
||||
jarParent.mkdir();
|
||||
FileUtil.copy(originalJar, jar);
|
||||
|
||||
refreshVFS();
|
||||
|
||||
verifyPointersInCorrectState(pointersToWatch);
|
||||
assertTrue(jarParentPointer.isValid());
|
||||
assertTrue(jarPointer.isValid());
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
|
||||
jar.delete();
|
||||
jarParent.delete();
|
||||
refreshVFS();
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
|
||||
verifyPointersInCorrectState(pointersToWatch);
|
||||
assertFalse(jarParentPointer.isValid());
|
||||
assertFalse(jarPointer.isValid());
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
}
|
||||
|
||||
public void testJars2() throws Exception {
|
||||
final File tempDir = createTempDirectory();
|
||||
final File jarParent = new File(tempDir, "jarParent");
|
||||
jarParent.mkdir();
|
||||
final File jar = new File(jarParent, "x.jar");
|
||||
final File originalJar = new File(PathManagerEx.getTestDataPath() + "/psi/generics22/collect-2.2.jar".replace('/', File.separatorChar));
|
||||
FileUtil.copy(originalJar, jar);
|
||||
|
||||
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(jar); // Make sure we receive events when jar changes
|
||||
|
||||
final VirtualFilePointer[] pointersToWatch = new VirtualFilePointer[1];
|
||||
final VirtualFilePointerListener listener = new VirtualFilePointerListener() {
|
||||
@Override
|
||||
public void beforeValidityChanged(VirtualFilePointer[] pointers) {
|
||||
verifyPointersInCorrectState(pointersToWatch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validityChanged(VirtualFilePointer[] pointers) {
|
||||
verifyPointersInCorrectState(pointersToWatch);
|
||||
}
|
||||
};
|
||||
final String pathInJar = jar.getPath().replace(File.separatorChar, '/') + JarFileSystem.JAR_SEPARATOR;
|
||||
final String jarUrl = VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL,
|
||||
pathInJar);
|
||||
final VirtualFilePointer jarPointer = myVirtualFilePointerManager.create(jarUrl, myProject, listener);
|
||||
pointersToWatch[0] = jarPointer;
|
||||
assertTrue(jarPointer.isValid());
|
||||
|
||||
jar.delete();
|
||||
refreshVFS();
|
||||
|
||||
verifyPointersInCorrectState(pointersToWatch);
|
||||
assertFalse(jarPointer.isValid());
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
|
||||
jarParent.mkdir();
|
||||
FileUtil.copy(originalJar, jar);
|
||||
|
||||
refreshVFS();
|
||||
|
||||
verifyPointersInCorrectState(pointersToWatch);
|
||||
assertTrue(jarPointer.isValid());
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
|
||||
jar.delete();
|
||||
refreshVFS();
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
|
||||
verifyPointersInCorrectState(pointersToWatch);
|
||||
assertFalse(jarPointer.isValid());
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
}
|
||||
|
||||
private static void refreshVFS() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
VirtualFileManager.getInstance().refresh(false);
|
||||
}
|
||||
});
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
}
|
||||
|
||||
private static void verifyPointersInCorrectState(VirtualFilePointer[] pointers) {
|
||||
for (VirtualFilePointer pointer : pointers) {
|
||||
final VirtualFile file = pointer.getFile();
|
||||
assertTrue(file == null || file.isValid());
|
||||
}
|
||||
}
|
||||
|
||||
private VirtualFilePointer createPointerByFile(final File file, final VirtualFilePointerListener fileListener) throws IOException {
|
||||
final VirtualFile[] vFile = new VirtualFile[1];
|
||||
final String url = VirtualFileManager.constructUrl(LocalFileSystem.PROTOCOL, file.getCanonicalPath().replace(File.separatorChar, '/'));
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
vFile[0] = VirtualFileManager.getInstance().refreshAndFindFileByUrl(url);
|
||||
}
|
||||
});
|
||||
final VirtualFilePointer fileToDeletePointer;
|
||||
if (vFile[0] == null) {
|
||||
fileToDeletePointer = myVirtualFilePointerManager.create(url, myProject, fileListener);
|
||||
}
|
||||
else {
|
||||
fileToDeletePointer = myVirtualFilePointerManager.create(vFile[0], myProject, fileListener);
|
||||
}
|
||||
return fileToDeletePointer;
|
||||
}
|
||||
|
||||
public void testFilePointerUpdate() throws Exception {
|
||||
final File tempDir = createTempDirectory();
|
||||
final File file_f1 = new File(tempDir, "f1");
|
||||
|
||||
final VirtualFilePointer pointer_f1 = createPointerByFile(file_f1, null);
|
||||
|
||||
assertFalse(pointer_f1.isValid());
|
||||
|
||||
file_f1.createNewFile();
|
||||
|
||||
doVfsRefresh();
|
||||
|
||||
assertTrue(pointer_f1.isValid());
|
||||
|
||||
file_f1.delete();
|
||||
|
||||
doVfsRefresh();
|
||||
assertFalse(pointer_f1.isValid());
|
||||
}
|
||||
|
||||
public void testContainerDeletePerformance() throws Exception {
|
||||
PlatformTestUtil.assertTiming("", 3000, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Disposable parent = Disposer.newDisposable();
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
myVirtualFilePointerManager.createContainer(parent);
|
||||
}
|
||||
Disposer.dispose(parent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void doVfsRefresh() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LocalFileSystem.getInstance().refresh(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myVirtualFilePointerManager = VirtualFilePointerManager.getInstance();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.intellij.openapi.vfs.changes;
|
||||
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.psi.util.PsiFilter;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vcs.changes.PsiChangeTracker;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.testFramework.IdeaTestCase;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class PsiChangeTrackerTest extends IdeaTestCase {
|
||||
private PsiFile myOriginalFile;
|
||||
private PsiFile myChangedFile;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
final VirtualFile testRoot = getTestRoot();
|
||||
final VirtualFile child = testRoot.findChild("PsiChangesTest.java");
|
||||
assert child != null : "Can't find PsiChangesTest.java";
|
||||
final PsiFile original = this.getPsiManager().findFile(child);
|
||||
assert original != null : "Can't create PsiFile from VirtualFile " + child.getName();
|
||||
myOriginalFile = original;
|
||||
|
||||
final VirtualFile changedFile = testRoot.findChild("PsiChangesTest_changed.java");
|
||||
assert changedFile != null : "Can't find PsiChangesTest_changed.java";
|
||||
|
||||
myChangedFile = PsiFileFactory.getInstance(myProject)
|
||||
.createFileFromText(new String(changedFile.contentsToByteArray()), myOriginalFile);
|
||||
assert myChangedFile != null : "Can't create PsiFile from " + changedFile.getPath();
|
||||
}
|
||||
|
||||
public void testMethods() throws Exception {
|
||||
doTest(new PsiFilter<PsiMethod>(PsiMethod.class));
|
||||
}
|
||||
|
||||
public void testFields() throws Exception {
|
||||
doTest(new PsiFilter<PsiField>(PsiField.class));
|
||||
}
|
||||
|
||||
private <T extends PsiElement> void doTest(PsiFilter<T> filter) throws IOException {
|
||||
final Map<T,FileStatus> map = PsiChangeTracker.getElementsChanged(myChangedFile, myOriginalFile, filter);
|
||||
final Map<String, String> changes = convert(map);
|
||||
final Map<String, String> expected = getExpectedResults();
|
||||
assert expected.equals(changes) : "Changes are not equal \n Expected:\n" + expected + "\nFound:\n" + changes;
|
||||
}
|
||||
|
||||
private static <T extends PsiElement> Map<String, String> convert(Map<T, FileStatus> map) {
|
||||
final Map<String, String> result = new HashMap<String, String>();
|
||||
for (T key : map.keySet()) {
|
||||
final String newKey;
|
||||
if (key instanceof PsiMember) {
|
||||
newKey = ((PsiMember)key).getName();
|
||||
} else {
|
||||
newKey = key.getText();
|
||||
}
|
||||
result.put(newKey, map.get(key).getText());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Map<String, String> getExpectedResults() throws IOException {
|
||||
final String resultFileName = getTestName(true) + ".txt";
|
||||
final VirtualFile resultsDir = getTestRoot().findChild("results");
|
||||
assert resultsDir != null : "Can't find results dir";
|
||||
final VirtualFile result = resultsDir.findChild(resultFileName);
|
||||
assert result != null : "File not found " + resultsDir.getPath() + "/" + resultFileName;
|
||||
String res = new String(result.contentsToByteArray());
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
for (String s : res.replace("\r\n", "\n").split("\n")) {
|
||||
if (!StringUtil.isEmptyOrSpaces(s)) {
|
||||
final String[] strings = s.split(":");
|
||||
map.put(strings[0].trim(), strings[1].trim());
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
protected static VirtualFile getTestRoot() {
|
||||
final File root = new File(PathManagerEx.getTestDataPath());
|
||||
final File testRoot = new File(new File(root, "vfs"), "changes");
|
||||
final VirtualFile ioFile = LocalFileSystem.getInstance().findFileByIoFile(testRoot);
|
||||
assert ioFile != null : "Can't find directory vfs/changes";
|
||||
return ioFile;
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ public interface CommonClassNames {
|
||||
@NonNls String JAVA_LANG_RUNTIME_EXCEPTION = "java.lang.RuntimeException";
|
||||
@NonNls String JAVA_LANG_ENUM = "java.lang.Enum";
|
||||
@NonNls String JAVA_LANG_ITERABLE = "java.lang.Iterable";
|
||||
@NonNls String JAVA_UTIL_ITERATOR = "java.util.Iterator";
|
||||
|
||||
@NonNls String JAVA_LANG_DEPRECATED = "java.lang.Deprecated";
|
||||
@NonNls String JAVA_LANG_ANNOTATION_INHERITED = "java.lang.annotation.Inherited";
|
||||
|
||||
+9
-2
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.testFramework.fixtures.impl;
|
||||
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.ProjectScope;
|
||||
@@ -49,12 +51,17 @@ public class JavaCodeInsightTestFixtureImpl extends CodeInsightTestFixtureImpl i
|
||||
return psiClass;
|
||||
}
|
||||
|
||||
private PsiClass addClass(@NonNls String rootPath, @NotNull @NonNls final String classText) throws IOException {
|
||||
private PsiClass addClass(@NonNls final String rootPath, @NotNull @NonNls final String classText) throws IOException {
|
||||
final PsiClass aClass = ((PsiJavaFile)PsiFileFactory.getInstance(getProject()).createFileFromText("a.java", classText)).getClasses()[0];
|
||||
final String qName = aClass.getQualifiedName();
|
||||
assert qName != null;
|
||||
|
||||
final PsiFile psiFile = addFileToProject(rootPath, qName.replace('.', '/') + ".java", classText);
|
||||
final PsiFile psiFile = new WriteCommandAction<PsiFile>(getProject()) {
|
||||
@Override
|
||||
protected void run(Result<PsiFile> result) throws Throwable {
|
||||
result.setResult(addFileToProject(rootPath, qName.replace('.', '/') + ".java", classText));
|
||||
}
|
||||
}.execute().getResultObject();
|
||||
return ((PsiJavaFile)psiFile).getClasses()[0];
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 128 B |
@@ -174,8 +174,7 @@ public class ProblemsHolder {
|
||||
|
||||
@Nullable
|
||||
public ProblemDescriptor[] getResultsArray() {
|
||||
final List<ProblemDescriptor> problems = myProblems;
|
||||
myProblems = null;
|
||||
final List<ProblemDescriptor> problems = getResults();
|
||||
return problems == null ? null : problems.toArray(new ProblemDescriptor[problems.size()]);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiWhiteSpace;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
@@ -34,10 +35,15 @@ import java.util.Set;
|
||||
public class ParameterInfoUtils {
|
||||
public static final String DEFAULT_PARAMETER_CLOSE_CHARS = ",){}";
|
||||
|
||||
public static <T extends PsiElement> T findParentOfType (PsiFile file, int offset, Class<T> parentClass) {
|
||||
public static @Nullable <T extends PsiElement> T findParentOfType (PsiFile file, int offset, Class<T> parentClass) {
|
||||
PsiElement element = file.findElementAt(offset);
|
||||
if (element == null) return null;
|
||||
return PsiTreeUtil.getParentOfType(element, parentClass);
|
||||
|
||||
T parentOfType = PsiTreeUtil.getParentOfType(element, parentClass);
|
||||
if (element instanceof PsiWhiteSpace) {
|
||||
parentOfType = PsiTreeUtil.getParentOfType(PsiTreeUtil.prevLeaf(element), parentClass);
|
||||
}
|
||||
return parentOfType;
|
||||
}
|
||||
|
||||
public static int getCurrentParameterIndex(ASTNode argList, int offset, IElementType delimiterType) {
|
||||
|
||||
@@ -59,12 +59,12 @@ public class ReferenceRange {
|
||||
public static boolean containsOffsetInElement(PsiReference ref, int offset) {
|
||||
if (ref instanceof MultiRangeReference) {
|
||||
for (TextRange range : ((MultiRangeReference)ref).getRanges()) {
|
||||
if (range.contains(offset)) return true;
|
||||
if (range.containsOffset(offset)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return ref.getRangeInElement().contains(offset);
|
||||
return ref.getRangeInElement().containsOffset(offset);
|
||||
}
|
||||
|
||||
public static boolean containsRangeInElement(PsiReference ref, TextRange rangeInElement) {
|
||||
|
||||
@@ -15,13 +15,14 @@
|
||||
*/
|
||||
package com.intellij.psi.stubs;
|
||||
|
||||
import com.intellij.lang.FileASTNode;
|
||||
import com.intellij.lang.LighterAST;
|
||||
import com.intellij.lang.LighterASTNode;
|
||||
import com.intellij.lang.*;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.StubBuilder;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.IFileElementType;
|
||||
import com.intellij.psi.tree.ILightStubFileElementType;
|
||||
import gnu.trove.TIntStack;
|
||||
|
||||
@@ -34,15 +35,23 @@ public class LightStubBuilder implements StubBuilder {
|
||||
|
||||
@Override
|
||||
public StubElement buildStubTree(final PsiFile file) {
|
||||
final FileASTNode node = file.getNode();
|
||||
assert node != null;
|
||||
|
||||
if (!(node.getElementType() instanceof ILightStubFileElementType)) {
|
||||
LOG.error("File is not of ILightStubFileElementType: " + file);
|
||||
final FileType fileType = file.getFileType();
|
||||
if (!(fileType instanceof LanguageFileType)) {
|
||||
LOG.error("File is not of LanguageFileType: " + fileType + ", " + file);
|
||||
return null;
|
||||
}
|
||||
|
||||
final ILightStubFileElementType<?> type = (ILightStubFileElementType)node.getElementType();
|
||||
final Language language = ((LanguageFileType)fileType).getLanguage();
|
||||
final IFileElementType contentType = LanguageParserDefinitions.INSTANCE.forLanguage(language).getFileNodeType();
|
||||
if (!(contentType instanceof ILightStubFileElementType)) {
|
||||
LOG.error("File is not of ILightStubFileElementType: " + contentType + ", " + file);
|
||||
return null;
|
||||
}
|
||||
|
||||
final FileASTNode node = file.getNode();
|
||||
assert node != null : file;
|
||||
|
||||
final ILightStubFileElementType<?> type = (ILightStubFileElementType)contentType;
|
||||
final LighterAST tree = new LighterAST(node.getCharTable(), type.parseContentsLight(node));
|
||||
final StubElement rootStub = createStubForFile(file, tree);
|
||||
buildStubTree(tree, tree.getRoot(), rootStub);
|
||||
|
||||
+3
-1
@@ -402,7 +402,9 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
LOG.assertTrue(fileCopy.findElementAt(offset) == insertedElement, "wrong offset");
|
||||
|
||||
final TextRange range = insertedElement.getTextRange();
|
||||
LOG.assertTrue(range.substring(fileCopy.getText()).equals(insertedElement.getText()), "wrong text");
|
||||
if (!range.substring(fileCopy.getText()).equals(insertedElement.getText())) {
|
||||
LOG.error("wrong text: copy='" + fileCopy.getText() + "'; element='" + insertedElement.getText() + "'");
|
||||
}
|
||||
|
||||
return new CompletionParameters(insertedElement, fileCopy.getOriginalFile(), myCompletionType, offset, invocationCount);
|
||||
}
|
||||
|
||||
+13
-3
@@ -273,7 +273,8 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
|
||||
private boolean isOutdated() {
|
||||
if (!myDisposed) {
|
||||
LOG.assertTrue(this == CompletionServiceImpl.getCompletionService().getCurrentCompletion());
|
||||
CompletionProgressIndicator current = CompletionServiceImpl.getCompletionService().getCurrentCompletion();
|
||||
LOG.assertTrue(this == current, current);
|
||||
}
|
||||
return myDisposed || myEditor.isDisposed() || getProject().isDisposed();
|
||||
}
|
||||
@@ -327,6 +328,8 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
}
|
||||
|
||||
public void liveAfterDeath(@Nullable final LightweightHint hint) {
|
||||
assert myDisposed;
|
||||
|
||||
if (myModifiersReleased || ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
return;
|
||||
}
|
||||
@@ -391,10 +394,14 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
}
|
||||
|
||||
myLookup.show();
|
||||
//todo remove these assertions before X release
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
LOG.assertTrue(myLookup.isVisible());
|
||||
}
|
||||
}
|
||||
myLookup.refreshUi();
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
LOG.assertTrue(myLookup.isVisible());
|
||||
LOG.assertTrue(myLookup.isVisible(), "really?");
|
||||
}
|
||||
hideAutopopupIfMeaningless();
|
||||
}
|
||||
@@ -453,8 +460,9 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
if (hideLookup) {
|
||||
LookupManager.getInstance(getProject()).hideActiveLookup();
|
||||
}
|
||||
} else {
|
||||
assert myDisposed;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void finishCompletionProcess() {
|
||||
@@ -479,6 +487,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
|
||||
private void cleanup() {
|
||||
assert ApplicationManager.getApplication().isDispatchThread();
|
||||
assert myDisposed;
|
||||
myHint = null;
|
||||
myRestorePrefix = null;
|
||||
unregisterItself();
|
||||
@@ -607,6 +616,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
}
|
||||
|
||||
public void rememberDocumentState() {
|
||||
assert myDisposed;
|
||||
if (myModifiersReleased) {
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-2
@@ -35,8 +35,7 @@ public class PrefixMatchingWeigher extends CompletionWeigher {
|
||||
final String prefixHumps = StringUtil.capitalsOnly(prefix);
|
||||
final String itemHumps = StringUtil.capitalsOnly(lookupString);
|
||||
|
||||
if (itemHumps.equals(prefixHumps)) return 20;
|
||||
if (itemHumps.startsWith(prefixHumps)) return 10;
|
||||
if (itemHumps.startsWith(prefixHumps)) return 100 - itemHumps.length();
|
||||
|
||||
if (lookupString.startsWith(prefix)) return 5;
|
||||
if (StringUtil.startsWithIgnoreCase(lookupString, prefix)) return 1;
|
||||
|
||||
+21
-16
@@ -170,7 +170,8 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
@NotNull Document document,
|
||||
@NotNull TextEditor textEditor,
|
||||
@NotNull int[] toIgnore,
|
||||
boolean canChangeDocument) {
|
||||
boolean canChangeDocument,
|
||||
@Nullable Runnable callbackWhileWaiting) {
|
||||
Application application = ApplicationManager.getApplication();
|
||||
application.assertIsDispatchThread();
|
||||
assert !application.isWriteAccessAllowed();
|
||||
@@ -191,16 +192,18 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
final List<TextEditorHighlightingPass> passes = highlighter.getPasses(toIgnore);
|
||||
HighlightingPass[] array = passes.toArray(new HighlightingPass[passes.size()]);
|
||||
|
||||
final DaemonProgressIndicator progress = new DaemonProgressIndicator();
|
||||
final DaemonProgressIndicator progress = createUpdateProgress();
|
||||
progress.setDebug(true);
|
||||
progress.start();
|
||||
myPassExecutorService.submitPasses(Collections.singletonMap((FileEditor)textEditor, array), progress, Job.DEFAULT_PRIORITY);
|
||||
try {
|
||||
while (progress.isRunning()) {
|
||||
if (progress.isCanceled() && progress.isRunning()) {
|
||||
// write action sneaked in the AWT. restart
|
||||
waitForTermination();
|
||||
return runPasses(file, document, textEditor, toIgnore, canChangeDocument);
|
||||
return runPasses(file, document, textEditor, toIgnore, canChangeDocument,callbackWhileWaiting);
|
||||
}
|
||||
if (callbackWhileWaiting != null) {
|
||||
callbackWhileWaiting.run();
|
||||
}
|
||||
progress.waitFor(100);
|
||||
try {
|
||||
@@ -678,23 +681,25 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx
|
||||
// cancel all after calling createPasses() since there are perverts {@link com.intellij.util.xml.ui.DomUIFactoryImpl} who are changing PSI there
|
||||
cancelUpdateProgress(true, "Cancel by alarm");
|
||||
myAlarm.cancelAllRequests();
|
||||
DaemonProgressIndicator progress;
|
||||
synchronized (DaemonCodeAnalyzerImpl.this) {
|
||||
progress = new DaemonProgressIndicator() {
|
||||
@Override
|
||||
public void stopIfRunning() {
|
||||
super.stopIfRunning();
|
||||
myProject.getMessageBus().syncPublisher(DAEMON_EVENT_TOPIC).daemonFinished();
|
||||
}
|
||||
};
|
||||
progress.start();
|
||||
myUpdateProgress = progress;
|
||||
}
|
||||
DaemonProgressIndicator progress = createUpdateProgress();
|
||||
myPassExecutorService.submitPasses(passes, progress, Job.DEFAULT_PRIORITY);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private synchronized DaemonProgressIndicator createUpdateProgress() {
|
||||
DaemonProgressIndicator progress = new DaemonProgressIndicator() {
|
||||
@Override
|
||||
public void stopIfRunning() {
|
||||
super.stopIfRunning();
|
||||
myProject.getMessageBus().syncPublisher(DAEMON_EVENT_TOPIC).daemonFinished();
|
||||
}
|
||||
};
|
||||
progress.start();
|
||||
myUpdateProgress = progress;
|
||||
return progress;
|
||||
}
|
||||
|
||||
public boolean canChangeFileSilently(PsiFileSystemItem file) {
|
||||
return myDaemonListeners.canChangeFileSilently(file);
|
||||
}
|
||||
|
||||
@@ -328,30 +328,19 @@ class DaemonListeners implements Disposable {
|
||||
}
|
||||
|
||||
private class MyApplicationListener extends ApplicationAdapter {
|
||||
private boolean myDaemonWasRunning;
|
||||
|
||||
public void beforeWriteActionStart(Object action) {
|
||||
if (!myDaemonCodeAnalyzer.isRunning()) return; // we'll restart in writeActionFinished()
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("cancelling code highlighting by write action:" + action);
|
||||
}
|
||||
if (containsDocumentWorthBothering(action)) {
|
||||
stopDaemon(true);
|
||||
}
|
||||
myDaemonWasRunning = myDaemonCodeAnalyzer.isRunning();
|
||||
if (!myDaemonWasRunning) return; // we'll restart in writeActionFinished()
|
||||
stopDaemon(true);
|
||||
}
|
||||
|
||||
public void writeActionFinished(Object action) {
|
||||
if (containsDocumentWorthBothering(action)) {
|
||||
if (myDaemonWasRunning) {
|
||||
stopDaemon(true);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean containsDocumentWorthBothering(Object action) {
|
||||
if (isUnderIgnoredAction(action)) return false;
|
||||
DocumentRunnable currentWriteAction = action instanceof DocumentRunnable ? (DocumentRunnable)action
|
||||
: ApplicationManager.getApplication().getCurrentWriteAction(DocumentRunnable.class);
|
||||
if (currentWriteAction == null) return true;
|
||||
Document document = currentWriteAction.getDocument();
|
||||
return worthBothering(document, currentWriteAction.getProject());
|
||||
}
|
||||
}
|
||||
|
||||
private class MyCommandListener extends CommandAdapter {
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.openapi.editor.ex.RangeMarkerEx;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
|
||||
+53
-12
@@ -37,6 +37,7 @@ import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.colors.CodeInsightColors;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
@@ -106,17 +107,34 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
|
||||
InspectionProfileWrapper customProfile = file.getUserData(InspectionProfileWrapper.KEY);
|
||||
myProfileWrapper = customProfile == null ? InspectionProjectProfileManager.getInstance(myProject).getProfileWrapper() : customProfile;
|
||||
mySeverityRegistrar = ((SeverityProvider)myProfileWrapper.getInspectionProfile().getProfileManager()).getSeverityRegistrar();
|
||||
LOG.assertTrue(mySeverityRegistrar != null);
|
||||
|
||||
// initial guess
|
||||
setProgressLimit(300 * 2);
|
||||
}
|
||||
|
||||
protected void collectInformationWithProgress(final ProgressIndicator progress) {
|
||||
if (!HighlightLevelUtil.shouldInspect(myFile)) return;
|
||||
final InspectionManagerEx iManager = (InspectionManagerEx)InspectionManager.getInstance(myProject);
|
||||
final InspectionProfileWrapper profile = myProfileWrapper;
|
||||
final List<LocalInspectionTool> tools = DumbService.getInstance(myProject).filterByDumbAwareness(getInspectionTools(profile));
|
||||
inspect(tools, iManager, true, true, true, progress);
|
||||
try {
|
||||
if (!HighlightLevelUtil.shouldInspect(myFile)) return;
|
||||
final InspectionManagerEx iManager = (InspectionManagerEx)InspectionManager.getInstance(myProject);
|
||||
final InspectionProfileWrapper profile = myProfileWrapper;
|
||||
final List<LocalInspectionTool> tools = DumbService.getInstance(myProject).filterByDumbAwareness(getInspectionTools(profile));
|
||||
inspect(tools, iManager, true, true, true, progress);
|
||||
}
|
||||
finally {
|
||||
disposeDescriptors();
|
||||
}
|
||||
}
|
||||
|
||||
private void disposeDescriptors() {
|
||||
for (List<InspectionResult> list : result.values()) {
|
||||
for (InspectionResult inspectionResult : list) {
|
||||
for (ProblemDescriptor pd: inspectionResult.foundProblems) {
|
||||
((ProblemDescriptorImpl)pd).dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
result.clear();
|
||||
}
|
||||
|
||||
public void doInspectInBatch(final InspectionManagerEx iManager, List<InspectionProfileEntry> toolWrappers, boolean ignoreSuppressed) {
|
||||
@@ -202,8 +220,26 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
|
||||
final LocalInspectionToolSession session = new LocalInspectionToolSession(myFile, myStartOffset, myEndOffset);
|
||||
|
||||
List<Trinity<LocalInspectionTool, ProblemsHolder, PsiElementVisitor>> init = new ArrayList<Trinity<LocalInspectionTool, ProblemsHolder, PsiElementVisitor>>();
|
||||
visitPriorityElementsAndInit(tools, iManager, isOnTheFly, ignoreSuppressed, indicator, inside, session, init);
|
||||
visitRestElementsAndCleanup(tools,iManager,isOnTheFly,ignoreSuppressed, indicator, outside, session, init);
|
||||
boolean finished = false;
|
||||
try {
|
||||
visitPriorityElementsAndInit(tools, iManager, isOnTheFly, ignoreSuppressed, indicator, inside, session, init);
|
||||
visitRestElementsAndCleanup(tools,iManager,isOnTheFly,ignoreSuppressed, indicator, outside, session, init);
|
||||
finished = true;
|
||||
}
|
||||
finally {
|
||||
if (!finished) {
|
||||
synchronized (init) {
|
||||
for (Trinity<LocalInspectionTool, ProblemsHolder, PsiElementVisitor> trinity : init) {
|
||||
List<ProblemDescriptor> results = trinity.second.getResults();
|
||||
if (results != null) {
|
||||
for (ProblemDescriptor pd : results) {
|
||||
((ProblemDescriptorImpl)pd).dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
indicator.checkCanceled();
|
||||
|
||||
@@ -357,7 +393,9 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
|
||||
boolean isFileLevel = element instanceof PsiFile && textRange.equals(element.getTextRange());
|
||||
|
||||
final HighlightSeverity severity = highlightInfoType.getSeverity(element);
|
||||
return new HighlightInfo(mySeverityRegistrar.getTextAttributesBySeverity(severity), highlightInfoType, textRange.getStartOffset(), textRange.getEndOffset(), message, toolTip,
|
||||
TextAttributes attributes = mySeverityRegistrar.getTextAttributesBySeverity(severity);
|
||||
return new HighlightInfo(attributes, highlightInfoType, textRange.getStartOffset(),
|
||||
textRange.getEndOffset(), message, toolTip,
|
||||
severity, problemDescriptor.isAfterEndOfLine(), null, isFileLevel);
|
||||
}
|
||||
|
||||
@@ -513,7 +551,8 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
|
||||
List<TextRange> editables = ilManager.intersectWithAllEditableFragments(file, new TextRange(info.startOffset, info.endOffset));
|
||||
for (TextRange editable : editables) {
|
||||
TextRange hostRange = ((DocumentWindow)documentRange).injectedToHost(editable);
|
||||
HighlightInfo patched = HighlightInfo.createHighlightInfo(info.type, psiElement, hostRange.getStartOffset(), hostRange.getEndOffset(), info.description, info.toolTip);
|
||||
HighlightInfo patched = HighlightInfo.createHighlightInfo(info.type, psiElement, hostRange.getStartOffset(),
|
||||
hostRange.getEndOffset(), info.description, info.toolTip);
|
||||
if (patched != null) {
|
||||
registerQuickFixes(tool, descriptor, patched, emptyActionRegistered);
|
||||
outInfos.add(patched);
|
||||
@@ -553,8 +592,10 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
|
||||
return highlightInfo;
|
||||
}
|
||||
|
||||
private static void registerQuickFixes(final LocalInspectionTool tool, final ProblemDescriptor descriptor,
|
||||
final HighlightInfo highlightInfo, final Set<TextRange> emptyActionRegistered) {
|
||||
private static void registerQuickFixes(final LocalInspectionTool tool,
|
||||
final ProblemDescriptor descriptor,
|
||||
final HighlightInfo highlightInfo,
|
||||
final Set<TextRange> emptyActionRegistered) {
|
||||
final HighlightDisplayKey key = HighlightDisplayKey.find(tool.getShortName());
|
||||
boolean needEmptyAction = true;
|
||||
final QuickFix[] fixes = descriptor.getFixes();
|
||||
@@ -572,7 +613,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
|
||||
needEmptyAction = false;
|
||||
}
|
||||
if (((ProblemDescriptorImpl)descriptor).getEnforcedTextAttributes() != null) {
|
||||
needEmptyAction = false;
|
||||
needEmptyAction = false;
|
||||
}
|
||||
if (needEmptyAction && emptyActionRegistered.add(new TextRange(highlightInfo.fixStartOffset, highlightInfo.fixEndOffset))) {
|
||||
EmptyIntentionAction emptyIntentionAction = new EmptyIntentionAction(tool.getDisplayName());
|
||||
|
||||
@@ -209,6 +209,7 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass {
|
||||
if (place != null) {
|
||||
List<IntentionAction> enableDisableIntentionAction = new ArrayList<IntentionAction>();
|
||||
enableDisableIntentionAction.add(new IntentionHintComponent.EnableDisableIntentionAction(action));
|
||||
enableDisableIntentionAction.add(new IntentionHintComponent.EditIntentionSettingsAction(action));
|
||||
intentions.intentionsToShow.add(new HighlightInfo.IntentionActionDescriptor(action, enableDisableIntentionAction, null));
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.hint.ElementLocationUtil;
|
||||
import com.intellij.codeInsight.hint.HintManagerImpl;
|
||||
import com.intellij.codeInsight.hint.HintUtil;
|
||||
import com.intellij.ide.actions.ExternalJavaDocAction;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.lang.documentation.CompositeDocumentationProvider;
|
||||
import com.intellij.lang.documentation.DocumentationProvider;
|
||||
import com.intellij.lang.documentation.ExternalDocumentationHandler;
|
||||
@@ -132,6 +133,12 @@ public class DocumentationComponent extends JPanel implements Disposable {
|
||||
}
|
||||
super.processKeyEvent(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
UISettings.setupAntialiasing(g);
|
||||
super.paintComponent(g);
|
||||
}
|
||||
};
|
||||
myText = "";
|
||||
myEditorPane.setEditable(false);
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ public class CodeFoldingManagerImpl extends CodeFoldingManager implements Projec
|
||||
myProject = project;
|
||||
project.getMessageBus().connect().subscribe(DocumentBulkUpdateListener.TOPIC, new DocumentBulkUpdateListener.Adapter() {
|
||||
public void updateStarted(final Document doc) {
|
||||
resetFoldingInfo(doc); //TODO RangeMarkers tree convert
|
||||
resetFoldingInfo(doc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.SmartPsiElementPointer;
|
||||
import com.intellij.psi.impl.smartPointers.SmartPointerEx;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -36,6 +37,7 @@ public class EditorFoldingInfo {
|
||||
private final Map<FoldRegion, SmartPsiElementPointer<?>> myFoldRegionToSmartPointerMap
|
||||
= new THashMap<FoldRegion, SmartPsiElementPointer<?>>();
|
||||
|
||||
@NotNull
|
||||
public static EditorFoldingInfo get(@NotNull Editor editor) {
|
||||
EditorFoldingInfo info = editor.getUserData(KEY);
|
||||
if (info == null){
|
||||
@@ -82,15 +84,18 @@ public class EditorFoldingInfo {
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
for(FoldRegion region:myFoldRegionToSmartPointerMap.keySet()) {
|
||||
SmartPsiElementPointer<?> pointer = myFoldRegionToSmartPointerMap.get(region);
|
||||
((SmartPointerEx)pointer).dispose();
|
||||
region.dispose();
|
||||
}
|
||||
myFoldRegionToSmartPointerMap.clear();
|
||||
}
|
||||
|
||||
public static void resetInfo(final Editor editor) {
|
||||
EditorFoldingInfo info = editor.getUserData(KEY);
|
||||
if (info != null) {
|
||||
for(FoldRegion region:info.myFoldRegionToSmartPointerMap.keySet()) {
|
||||
region.dispose();
|
||||
}
|
||||
info.dispose();
|
||||
}
|
||||
editor.putUserData(KEY, null);
|
||||
}
|
||||
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.codeInsight.folding.impl.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ex.FoldingModelEx;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
|
||||
public class FoldingActionGroup extends DefaultActionGroup implements DumbAware {
|
||||
public FoldingActionGroup() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void update(AnActionEvent event){
|
||||
Presentation presentation = event.getPresentation();
|
||||
DataContext dataContext = event.getDataContext();
|
||||
|
||||
Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
|
||||
if (editor == null){
|
||||
presentation.setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
FoldingModelEx foldingModel = (FoldingModelEx)editor.getFoldingModel();
|
||||
presentation.setVisible(foldingModel.isFoldingEnabled());
|
||||
}
|
||||
}
|
||||
+47
@@ -25,6 +25,7 @@ import com.intellij.codeInsight.hint.PriorityQuestionAction;
|
||||
import com.intellij.codeInsight.hint.ScrollAwareHint;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInsight.intention.impl.config.IntentionManagerSettings;
|
||||
import com.intellij.codeInsight.intention.impl.config.IntentionSettingsConfigurable;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
@@ -33,6 +34,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.VisualPosition;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.JBPopupListener;
|
||||
@@ -489,4 +491,49 @@ public class IntentionHintComponent extends JPanel implements Disposable, Scroll
|
||||
return getText();
|
||||
}
|
||||
}
|
||||
|
||||
public static class EditIntentionSettingsAction implements IntentionAction {
|
||||
private String myFamilyName;
|
||||
|
||||
public EditIntentionSettingsAction(IntentionAction action) {
|
||||
myFamilyName = action.getFamilyName();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Edit intention settings";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return getText();
|
||||
}
|
||||
|
||||
@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 IntentionSettingsConfigurable configurable = new IntentionSettingsConfigurable();
|
||||
ShowSettingsUtil.getInstance().editConfigurable(project, configurable, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
configurable.selectIntention(myFamilyName);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -103,4 +103,7 @@ public class IntentionSettingsConfigurable extends BaseConfigurable implements S
|
||||
return HELP_ID;
|
||||
}
|
||||
|
||||
public void selectIntention(String familyName) {
|
||||
myPanel.selectIntention(familyName);
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -147,6 +147,10 @@ public class IntentionSettingsPanel implements MasterDetails {
|
||||
myIntentionDescriptionPanel.dispose();
|
||||
}
|
||||
|
||||
public void selectIntention(String familyName) {
|
||||
myIntentionSettingsTree.selectIntention(familyName);
|
||||
}
|
||||
|
||||
private static boolean isIntentionAccepted(IntentionActionMetaData metaData, @NonNls String filter, boolean forceInclude,
|
||||
final List<Set<String>> keySetList, final HashSet<String> quoted) {
|
||||
if (StringUtil.containsIgnoreCase(metaData.getFamily(), filter)) {
|
||||
|
||||
+30
@@ -189,6 +189,14 @@ public abstract class IntentionSettingsTree {
|
||||
treeModel.nodeChanged(root);
|
||||
}
|
||||
|
||||
public void selectIntention(String familyName) {
|
||||
final CheckedTreeNode child = findChildRecursively(getRoot(), familyName);
|
||||
if (child != null) {
|
||||
final TreePath path = new TreePath(child.getPath());
|
||||
TreeUtil.selectPath(myTree, path);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<IntentionActionMetaData> sort(final List<IntentionActionMetaData> intentionsToShow) {
|
||||
List<IntentionActionMetaData> copy = new ArrayList<IntentionActionMetaData>(intentionsToShow);
|
||||
Collections.sort(copy, new Comparator<IntentionActionMetaData>() {
|
||||
@@ -244,6 +252,28 @@ public abstract class IntentionSettingsTree {
|
||||
return found.get();
|
||||
}
|
||||
|
||||
private static CheckedTreeNode findChildRecursively(CheckedTreeNode node, final String name) {
|
||||
final Ref<CheckedTreeNode> found = new Ref<CheckedTreeNode>();
|
||||
visitChildren(node, new CheckedNodeVisitor() {
|
||||
public void visit(CheckedTreeNode node) {
|
||||
if (found.get() != null) return;
|
||||
final Object userObject = node.getUserObject();
|
||||
if (userObject instanceof IntentionActionMetaData) {
|
||||
String text = getNodeText(node);
|
||||
if (name.equals(text)) {
|
||||
found.set(node);
|
||||
}
|
||||
} else {
|
||||
final CheckedTreeNode child = findChildRecursively(node, name);
|
||||
if (child != null) {
|
||||
found.set(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return found.get();
|
||||
}
|
||||
|
||||
private static String getNodeText(CheckedTreeNode node) {
|
||||
final Object userObject = node.getUserObject();
|
||||
String text;
|
||||
|
||||
@@ -476,7 +476,7 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
|
||||
JComponent internalComponent = myEditor.getContentComponent();
|
||||
final JRootPane rootPane = editorComponent.getRootPane();
|
||||
if (rootPane == null) {
|
||||
LOG.error(myArranger);
|
||||
LOG.error(myArranger + "; " + myEditor.isDisposed());
|
||||
}
|
||||
JLayeredPane layeredPane = rootPane.getLayeredPane();
|
||||
Point layeredPanePoint=SwingUtilities.convertPoint(internalComponent,location, layeredPane);
|
||||
@@ -712,6 +712,9 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
|
||||
|
||||
public Rectangle getCurrentItemBounds(){
|
||||
int index = myList.getSelectedIndex();
|
||||
if (index < 0) {
|
||||
LOG.error("No selected element, size=" + myList.getModel().getSize() + "; items" + getItems());
|
||||
}
|
||||
Rectangle itmBounds = myList.getCellBounds(index, index);
|
||||
if (itmBounds == null){
|
||||
LOG.error("No bounds for " + index + "; size=" + myList.getModel().getSize());
|
||||
|
||||
@@ -985,8 +985,8 @@ public class TemplateState implements Disposable {
|
||||
RangeMarker rangeMarker = null;
|
||||
if (endSegmentNumber >= 0) {
|
||||
int endVarOffset = mySegments.getSegmentStart(endSegmentNumber);
|
||||
PsiElement marker = CodeStyleManagerImpl.insertNewLineIndentMarker(file, endVarOffset);
|
||||
if (marker != null) rangeMarker = myDocument.createRangeMarker(marker.getTextRange());
|
||||
TextRange range = CodeStyleManagerImpl.insertNewLineIndentMarker(file, myDocument, endVarOffset);
|
||||
if (range != null) rangeMarker = myDocument.createRangeMarker(range);
|
||||
}
|
||||
int startOffset = rangeMarkerToReformat != null ? rangeMarkerToReformat.getStartOffset() : myTemplateRange.getStartOffset();
|
||||
int endOffset = rangeMarkerToReformat != null ? rangeMarkerToReformat.getEndOffset() : myTemplateRange.getEndOffset();
|
||||
|
||||
+2
-148
@@ -22,12 +22,8 @@ import com.intellij.codeInspection.ex.ScopeToolState;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.util.gotoByName.SimpleChooseByNameModel;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.profile.codeInspection.InspectionProfileManager;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.apache.oro.text.regex.*;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
@@ -35,11 +31,7 @@ import java.util.*;
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class GotoInspectionModel extends SimpleChooseByNameModel {//implements CustomMatcherModel {
|
||||
private String myPattern;
|
||||
|
||||
private Pattern myCompiledPattern;
|
||||
private final PatternMatcher myMatcher = new Perl5Matcher();
|
||||
public class GotoInspectionModel extends SimpleChooseByNameModel {
|
||||
private final Map<String, InspectionProfileEntry> myToolNames = new HashMap<String, InspectionProfileEntry>();
|
||||
private final Map<String, Set<InspectionProfileEntry>> myGroupNames = new HashMap<String, Set<InspectionProfileEntry>>();
|
||||
private final Map<String, InspectionProfileEntry> myToolShortNames = new HashMap<String, InspectionProfileEntry>();
|
||||
@@ -48,7 +40,7 @@ public class GotoInspectionModel extends SimpleChooseByNameModel {//implements C
|
||||
|
||||
|
||||
public GotoInspectionModel(Project project) {
|
||||
super(project, IdeBundle.message("prompt.goto.inspection.enter.name"), null); //TODO help ID
|
||||
super(project, IdeBundle.message("prompt.goto.inspection.enter.name"), "goto.inspection.help.id");
|
||||
final InspectionProfileImpl rootProfile = (InspectionProfileImpl)InspectionProfileManager.getInstance().getRootProfile();
|
||||
for (ScopeToolState state : rootProfile.getAllTools()) {
|
||||
final InspectionProfileEntry tool = state.getTool();
|
||||
@@ -69,7 +61,6 @@ public class GotoInspectionModel extends SimpleChooseByNameModel {//implements C
|
||||
final Set<String> nameIds = new HashSet<String>();
|
||||
nameIds.addAll(myToolNames.keySet());
|
||||
nameIds.addAll(myGroupNames.keySet());
|
||||
//nameIds.addAll(myToolShortNames.keySet());
|
||||
myNames = ArrayUtil.toStringArray(nameIds);
|
||||
}
|
||||
|
||||
@@ -105,141 +96,4 @@ public class GotoInspectionModel extends SimpleChooseByNameModel {//implements C
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<InspectionProfileEntry> findEntries(String name) {
|
||||
final List<InspectionProfileEntry> result = new ArrayList<InspectionProfileEntry>();
|
||||
InspectionProfileEntry e = myToolNames.get(name);
|
||||
if (e != null) {
|
||||
result.add(e);
|
||||
}
|
||||
//e = myToolShortNames.get(name);
|
||||
//if (e != null) {
|
||||
// result.add(e);
|
||||
//}
|
||||
final Set<InspectionProfileEntry> entrySet = myGroupNames.get(name);
|
||||
if (entrySet != null) {
|
||||
result.addAll(entrySet);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean matches(@NotNull final String name, @NotNull final String pattern) {
|
||||
for (InspectionProfileEntry entry : findEntries(name)) {
|
||||
final String toolName = entry.getDisplayName();
|
||||
final String id = entry.getShortName();
|
||||
final String group = entry.getGroupDisplayName();
|
||||
final Pattern compiledPattern = getPattern(pattern);
|
||||
if (myMatcher.matches(toolName, compiledPattern)
|
||||
|| myMatcher.matches(id, compiledPattern)
|
||||
|| myMatcher.matches(group, compiledPattern)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Pattern getPattern(String pattern) {
|
||||
if (!Comparing.strEqual(pattern, myPattern)) {
|
||||
myCompiledPattern = null;
|
||||
myPattern = pattern;
|
||||
}
|
||||
if (myCompiledPattern == null) {
|
||||
boolean allowToLower = true;
|
||||
final int eol = pattern.indexOf('\n');
|
||||
if (eol != -1) {
|
||||
pattern = pattern.substring(0, eol);
|
||||
}
|
||||
if (pattern.length() >= 80) {
|
||||
pattern = pattern.substring(0, 80);
|
||||
}
|
||||
|
||||
final @NonNls StringBuffer buffer = new StringBuffer();
|
||||
|
||||
if (containsOnlyUppercaseLetters(pattern)) {
|
||||
allowToLower = false;
|
||||
}
|
||||
|
||||
if (allowToLower) {
|
||||
buffer.append(".*");
|
||||
}
|
||||
|
||||
boolean firstIdentifierLetter = true;
|
||||
for (int i = 0; i < pattern.length(); i++) {
|
||||
final char c = pattern.charAt(i);
|
||||
if (Character.isLetterOrDigit(c)) {
|
||||
// This logic allows to use uppercase letters only to catch the name like PDM for PsiDocumentManager
|
||||
if (Character.isUpperCase(c) || Character.isDigit(c)) {
|
||||
|
||||
if (!firstIdentifierLetter) {
|
||||
buffer.append("[^A-Z]*");
|
||||
}
|
||||
|
||||
buffer.append("[");
|
||||
buffer.append(c);
|
||||
if (allowToLower || i == 0) {
|
||||
buffer.append('|');
|
||||
buffer.append(Character.toLowerCase(c));
|
||||
}
|
||||
buffer.append("]");
|
||||
}
|
||||
else if (Character.isLowerCase(c)) {
|
||||
buffer.append('[');
|
||||
buffer.append(c);
|
||||
buffer.append('|');
|
||||
buffer.append(Character.toUpperCase(c));
|
||||
buffer.append(']');
|
||||
}
|
||||
else {
|
||||
buffer.append(c);
|
||||
}
|
||||
|
||||
firstIdentifierLetter = false;
|
||||
}
|
||||
else if (c == '*') {
|
||||
buffer.append(".*");
|
||||
firstIdentifierLetter = true;
|
||||
}
|
||||
else if (c == '.') {
|
||||
buffer.append("\\.");
|
||||
firstIdentifierLetter = true;
|
||||
}
|
||||
else if (c == ' ') {
|
||||
buffer.append("[^A-Z]*\\ ");
|
||||
firstIdentifierLetter = true;
|
||||
}
|
||||
else {
|
||||
firstIdentifierLetter = true;
|
||||
// for standard RegExp engine
|
||||
// buffer.append("\\u");
|
||||
// buffer.append(Integer.toHexString(c + 0x20000).substring(1));
|
||||
|
||||
// for OROMATCHER RegExp engine
|
||||
buffer.append("\\x");
|
||||
buffer.append(Integer.toHexString(c + 0x20000).substring(3));
|
||||
}
|
||||
}
|
||||
|
||||
buffer.append(".*");
|
||||
|
||||
|
||||
try {
|
||||
myCompiledPattern = new Perl5Compiler().compile(buffer.toString());
|
||||
}
|
||||
catch (MalformedPatternException e) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
return myCompiledPattern;
|
||||
}
|
||||
|
||||
private static boolean containsOnlyUppercaseLetters(String s) {
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
if (c != '*' && c != ' ' && !Character.isUpperCase(c)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.smartPointers.SmartPointerEx;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -40,7 +41,6 @@ public class ProblemDescriptorImpl extends CommonProblemDescriptorImpl implement
|
||||
@NotNull private final SmartPsiElementPointer myStartSmartPointer;
|
||||
@Nullable private final SmartPsiElementPointer myEndSmartPointer;
|
||||
|
||||
|
||||
private final ProblemHighlightType myHighlightType;
|
||||
private Navigatable myNavigatable;
|
||||
private final boolean myAfterEndOfLine;
|
||||
@@ -66,7 +66,10 @@ public class ProblemDescriptorImpl extends CommonProblemDescriptorImpl implement
|
||||
this(startElement, endElement, descriptionTemplate, fixes, highlightType, isAfterEndOfLine, rangeInElement, true, hintAction, onTheFly);
|
||||
}
|
||||
|
||||
public ProblemDescriptorImpl(@NotNull PsiElement startElement, @NotNull PsiElement endElement, String descriptionTemplate, LocalQuickFix[] fixes,
|
||||
public ProblemDescriptorImpl(@NotNull PsiElement startElement,
|
||||
@NotNull PsiElement endElement,
|
||||
String descriptionTemplate,
|
||||
LocalQuickFix[] fixes,
|
||||
ProblemHighlightType highlightType,
|
||||
boolean isAfterEndOfLine,
|
||||
final TextRange rangeInElement,
|
||||
@@ -191,4 +194,9 @@ public class ProblemDescriptorImpl extends CommonProblemDescriptorImpl implement
|
||||
public boolean showTooltip() {
|
||||
return myShowTooltip;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
((SmartPointerEx)myStartSmartPointer).dispose();
|
||||
if (myEndSmartPointer != null) ((SmartPointerEx)myEndSmartPointer).dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,4 +81,9 @@ public class EditLogPatternDialog extends DialogWrapper {
|
||||
return myFilePattern.getText();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getHelpId() {
|
||||
return "reference.run.configuration.edit.logfile.aliases";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -491,10 +491,9 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L
|
||||
|
||||
public void run() {
|
||||
if (myReader == null) return;
|
||||
while (myRunning) {
|
||||
final Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
myAlarm.cancelAllRequests();
|
||||
final Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
if (myRunning) {
|
||||
try {
|
||||
int i = 0;
|
||||
while (i++ < 1000) {
|
||||
@@ -510,9 +509,10 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
myAlarm.addRequest(runnable, 200);
|
||||
}
|
||||
myAlarm.addRequest(this, 100);
|
||||
}
|
||||
};
|
||||
myAlarm.addRequest(runnable, 10);
|
||||
}
|
||||
|
||||
public void startRunning() {
|
||||
|
||||
@@ -29,8 +29,10 @@ import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.openapi.wm.impl.IdeFrameImpl;
|
||||
import com.intellij.util.IJSwingUtilities;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -42,14 +44,14 @@ public class RunConfigurationAction extends ComboBoxAction implements DumbAware
|
||||
private static final Key<ComboBoxButton> BUTTON_KEY = Key.create("COMBOBOX_BUTTON");
|
||||
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
final IdeFrameImpl ideFrame = findFrame(e.getData(PlatformDataKeys.CONTEXT_COMPONENT));
|
||||
final ComboBoxButton button = (ComboBoxButton)ideFrame.getRootPane().getClientProperty(BUTTON_KEY);
|
||||
final IdeFrame ideFrame = findFrame(e.getData(PlatformDataKeys.CONTEXT_COMPONENT));
|
||||
final ComboBoxButton button = (ComboBoxButton)ideFrame.getComponent().getRootPane().getClientProperty(BUTTON_KEY);
|
||||
if (button == null || !button.isShowing()) return;
|
||||
button.showPopup();
|
||||
}
|
||||
|
||||
private static IdeFrameImpl findFrame(final Component component) {
|
||||
return IJSwingUtilities.findParentOfType(component, IdeFrameImpl.class);
|
||||
private static IdeFrame findFrame(final Component component) {
|
||||
return UIUtil.getParentOfType(IdeFrame.class, component);
|
||||
}
|
||||
|
||||
public void update(final AnActionEvent e) {
|
||||
@@ -112,9 +114,9 @@ public class RunConfigurationAction extends ComboBoxAction implements DumbAware
|
||||
return new ComboBoxButton(presentation) {
|
||||
public void addNotify() {
|
||||
super.addNotify(); //To change body of overriden methods use Options | File Templates.;
|
||||
final IdeFrameImpl frame = findFrame(this);
|
||||
final IdeFrame frame = findFrame(this);
|
||||
LOG.assertTrue(frame != null);
|
||||
frame.getRootPane().putClientProperty(BUTTON_KEY, this);
|
||||
frame.getComponent().getRootPane().putClientProperty(BUTTON_KEY, this);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -369,14 +369,19 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
|
||||
//offset can be changed after text trimming after insert due to buffer constraints
|
||||
appendToHistoryDocument(history, text);
|
||||
int offset = history.getTextLength() - text.length();
|
||||
final HighlighterIterator iterator = consoleEditor.getHighlighter().createIterator(0);
|
||||
final int localStartOffset = textRange.getStartOffset();
|
||||
final HighlighterIterator iterator = consoleEditor.getHighlighter().createIterator(localStartOffset);
|
||||
final int localEndOffset = textRange.getEndOffset();
|
||||
while (!iterator.atEnd()) {
|
||||
final int localOffset = textRange.getStartOffset();
|
||||
final int start = Math.max(iterator.getStart(), localOffset) - localOffset;
|
||||
final int end = Math.min(iterator.getEnd(), textRange.getEndOffset()) - localOffset;
|
||||
markupModel.addRangeHighlighter(start + offset, end + offset, HighlighterLayer.SYNTAX, iterator.getTextAttributes(),
|
||||
HighlighterTargetArea.EXACT_RANGE);
|
||||
|
||||
final int itStart = iterator.getStart();
|
||||
if (itStart > localEndOffset) break;
|
||||
final int itEnd = iterator.getEnd();
|
||||
if (itEnd >= localStartOffset) {
|
||||
final int start = Math.max(itStart, localStartOffset) - localStartOffset + offset;
|
||||
final int end = Math.min(itEnd, localEndOffset) - localStartOffset + offset;
|
||||
markupModel.addRangeHighlighter(start, end, HighlighterLayer.SYNTAX, iterator.getTextAttributes(),
|
||||
HighlighterTargetArea.EXACT_RANGE);
|
||||
}
|
||||
iterator.advance();
|
||||
}
|
||||
if (myDoSaveErrorsToHistory) {
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.intellij.ide.CommonActionsManager;
|
||||
import com.intellij.ide.OccurenceNavigator;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
@@ -43,7 +42,6 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.event.*;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable;
|
||||
import com.intellij.openapi.editor.ex.FoldingModelEx;
|
||||
import com.intellij.openapi.editor.ex.MarkupModelEx;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
@@ -196,6 +194,11 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
public int getLength() {
|
||||
return endOffset - startOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return contentType + "[" + startOffset + ";" + endOffset + "]";
|
||||
}
|
||||
}
|
||||
|
||||
private final Project myProject;
|
||||
@@ -347,6 +350,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
}
|
||||
myDeferredTypes.clear();
|
||||
myDeferredUserInput = new StringBuffer();
|
||||
myDeferredTokens.clear();
|
||||
myHyperlinks.clear();
|
||||
myTokens.clear();
|
||||
if (myEditor == null) return;
|
||||
@@ -613,7 +617,6 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
}
|
||||
|
||||
private static void addToken(int length, ConsoleViewContentType contentType, List<TokenInfo> tokens) {
|
||||
boolean needNew = true;
|
||||
int startOffset = 0;
|
||||
if (!tokens.isEmpty()) {
|
||||
final TokenInfo lastToken = tokens.get(tokens.size() - 1);
|
||||
@@ -1623,9 +1626,52 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
public void setSelected(AnActionEvent e, final boolean state) {
|
||||
super.setSelected(e, state);
|
||||
EditorSettingsExternalizable.getInstance().setUseSoftWraps(myEditor.getSettings().isUseSoftWraps(), SoftWrapAppliancePlaces.CONSOLE);
|
||||
|
||||
final String placeholder = myCommandLineFolding.getPlaceholder(0);
|
||||
if (state && placeholder == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final FoldingModel foldingModel = myEditor.getFoldingModel();
|
||||
FoldRegion[] foldRegions = foldingModel.getAllFoldRegions();
|
||||
Runnable foldTask = null;
|
||||
|
||||
final int endFoldRegionOffset = myEditor.getDocument().getLineEndOffset(0);
|
||||
Runnable addCollapsedFoldRegionTask = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FoldRegion foldRegion = foldingModel.addFoldRegion(0, endFoldRegionOffset, placeholder == null ? "..." : placeholder);
|
||||
if (foldRegion != null) {
|
||||
foldRegion.setExpanded(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (foldRegions.length <= 0) {
|
||||
if (!state) {
|
||||
return;
|
||||
}
|
||||
foldTask = addCollapsedFoldRegionTask;
|
||||
}
|
||||
else {
|
||||
final FoldRegion foldRegion = foldRegions[0];
|
||||
if (foldRegion.getStartOffset() == 0 && foldRegion.getEndOffset() == endFoldRegionOffset) {
|
||||
foldTask = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
foldRegion.setExpanded(!state);
|
||||
}
|
||||
};
|
||||
}
|
||||
else if (state) {
|
||||
foldTask = addCollapsedFoldRegionTask;
|
||||
}
|
||||
}
|
||||
|
||||
if (foldTask != null) {
|
||||
foldingModel.runBatchFoldingOperation(foldTask);
|
||||
}
|
||||
}
|
||||
};
|
||||
final AnAction autoScrollToTheEndAction = new ScrollToTheEndToolbarAction() {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user