type = ((ArrayType)type).componentType();
}
if(type instanceof ClassType) {
- final List<Location> locations = ((ClassType)type).allLineLocations();
+ final ClassType clsType = (ClassType)type;
+ final List<Location> locations = clsType.allLineLocations();
if(locations.size() > 0) {
final Location location = locations.get(0);
return ApplicationManager.getApplication().runReadAction(new Computable<SourcePosition>() {
public SourcePosition compute() {
SourcePosition position = debugProcess.getPositionManager().getSourcePosition(location);
- // adjust position
- final PsiClass classAt = JVMNameUtil.getClassAt(position);
- if (classAt != null) {
- final SourcePosition classPosition = SourcePosition.createFromElement(classAt);
- if (classPosition != null) {
- position = classPosition;
+ // adjust position for non-anonymous classes
+ if (clsType.name().indexOf("$") < 0) {
+ final PsiClass classAt = JVMNameUtil.getClassAt(position);
+ if (classAt != null) {
+ final SourcePosition classPosition = SourcePosition.createFromElement(classAt);
+ if (classPosition != null) {
+ position = classPosition;
+ }
}
}
return position;
final ThreadReference thread = ((ThreadStartEvent)event).thread();
getManagerThread().schedule(new DebuggerCommandImpl() {
protected void action() throws Exception {
+ getVirtualMachineProxy().threadStarted(thread);
myDebugProcessDispatcher.getMulticaster().threadStarted(DebugProcessEvents.this, thread);
}
});
final ThreadReference thread = ((ThreadDeathEvent)event).thread();
getManagerThread().schedule(new DebuggerCommandImpl() {
protected void action() throws Exception {
+ getVirtualMachineProxy().threadStopped(thread);
myDebugProcessDispatcher.getMulticaster().threadStopped(DebugProcessEvents.this, thread);
}
});
import com.intellij.debugger.engine.requests.RequestManagerImpl;
import com.intellij.debugger.jdi.StackFrameProxyImpl;
import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
-import com.intellij.debugger.jdi.VirtualMachineProxyImpl;
import com.intellij.debugger.ui.breakpoints.Breakpoint;
import com.intellij.debugger.ui.breakpoints.BreakpointWithHighlighter;
import com.intellij.debugger.ui.breakpoints.LineBreakpoint;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.PsiCompiledElement;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.unscramble.ThreadState;
+import com.intellij.util.Alarm;
import com.intellij.xdebugger.AbstractDebuggerSession;
import com.sun.jdi.ObjectCollectedException;
import com.sun.jdi.ThreadReference;
public static final int EVENT_START_WAIT_ATTACH = 9;
public static final int EVENT_DISPOSE = 10;
public static final int EVENT_REFRESH_VIEWS_ONLY = 11;
+ public static final int EVENT_THREADS_REFRESH = 12;
private volatile boolean myIsEvaluating;
private volatile int myIgnoreFiltersFrameCountThreshold = 0;
private final DebuggerContextImpl SESSION_EMPTY_CONTEXT;
//Thread, user is currently stepping through
private final Set<ThreadReferenceProxyImpl> mySteppingThroughThreads = new HashSet<ThreadReferenceProxyImpl>();
+ protected final Alarm myUpdateAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
public boolean isSteppingThrough(ThreadReferenceProxyImpl threadProxy) {
return mySteppingThroughThreads.contains(threadProxy);
ApplicationManager.getApplication().assertIsDispatchThread();
getProcess().dispose();
getContextManager().setState(SESSION_EMPTY_CONTEXT, STATE_DISPOSED, EVENT_DISPOSE, null);
+ Disposer.dispose(myUpdateAlarm);
}
// ManagerCommands
}
public void threadStarted(DebugProcess proc, ThreadReference thread) {
- ((VirtualMachineProxyImpl)proc.getVirtualMachineProxy()).threadStarted(thread);
- DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
- public void run() {
- final DebuggerStateManager contextManager = getContextManager();
- contextManager.fireStateChanged(contextManager.getContext(), EVENT_REFRESH_VIEWS_ONLY);
- }
- });
+ notifyThreadsRefresh();
}
public void threadStopped(DebugProcess proc, ThreadReference thread) {
- ((VirtualMachineProxyImpl)proc.getVirtualMachineProxy()).threadStopped(thread);
- DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() {
+ notifyThreadsRefresh();
+ }
+
+ private void notifyThreadsRefresh() {
+ myUpdateAlarm.cancelAllRequests();
+ myUpdateAlarm.addRequest(new Runnable() {
public void run() {
final DebuggerStateManager contextManager = getContextManager();
- contextManager.fireStateChanged(contextManager.getContext(), EVENT_REFRESH_VIEWS_ONLY);
+ contextManager.fireStateChanged(contextManager.getContext(), EVENT_THREADS_REFRESH);
}
- });
+ }, 100, ModalityState.NON_MODAL);
}
}
import com.intellij.debugger.engine.jdi.StackFrameProxy;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.impl.DebuggerContextUtil;
+import com.intellij.debugger.impl.DebuggerSession;
import com.intellij.debugger.impl.DebuggerStateManager;
import com.intellij.debugger.jdi.StackFrameProxyImpl;
import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
}
/*invoked in swing thread*/
- protected void rebuild(final boolean updateOnly) {
+ protected void rebuild(int event) {
final DebuggerContextImpl context = getContext();
final boolean paused = context.getDebuggerSession().isPaused();
-
- if (!paused || !updateOnly) {
+ final boolean isRefresh = event == DebuggerSession.EVENT_REFRESH ||
+ event == DebuggerSession.EVENT_REFRESH_VIEWS_ONLY ||
+ event == DebuggerSession.EVENT_THREADS_REFRESH;
+ if (!paused || !isRefresh) {
myThreadsCombo.removeAllItems();
synchronized (myFramesList) {
myFramesList.clear();
if (paused) {
final DebugProcessImpl process = context.getDebugProcess();
if (process != null) {
- process.getManagerThread().schedule(new RefreshFramePanelCommand(updateOnly && myThreadsCombo.getItemCount() != 0));
+ process.getManagerThread().schedule(new RefreshFramePanelCommand(isRefresh && myThreadsCombo.getItemCount() != 0));
}
}
}
stateManager.addListener(new DebuggerContextListener() {
public void changeEvent(DebuggerContextImpl newContext, int event) {
myContext = newContext;
- if (event != DebuggerSession.EVENT_REFRESH_VIEWS_ONLY) {
+ if (event != DebuggerSession.EVENT_REFRESH_VIEWS_ONLY && event != DebuggerSession.EVENT_THREADS_REFRESH) {
refresh();
}
}
protected abstract DebuggerTree createTreeView();
- protected void rebuild(final boolean updateOnly) {
+ protected void rebuild(int event) {
DebuggerSession debuggerSession = getContext().getDebuggerSession();
if(debuggerSession == null) {
return;
import com.intellij.debugger.actions.DebuggerAction;
import com.intellij.debugger.actions.DebuggerActions;
+import com.intellij.debugger.impl.DebuggerContextImpl;
+import com.intellij.debugger.impl.DebuggerSession;
import com.intellij.debugger.impl.DebuggerStateManager;
import com.intellij.debugger.ui.impl.watch.DebuggerTree;
import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl;
-import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.ActionPopupMenu;
import com.intellij.openapi.actionSystem.CommonShortcuts;
import com.intellij.openapi.project.Project;
setUpdateEnabled(true);
}
+ protected void changeEvent(DebuggerContextImpl newContext, int event) {
+ if (event != DebuggerSession.EVENT_THREADS_REFRESH) {
+ super.changeEvent(newContext, event);
+ }
+ }
protected DebuggerTree createTreeView() {
return new InspectDebuggerTree(getProject());
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.impl.DebuggerContextListener;
-import com.intellij.debugger.impl.DebuggerSession;
import com.intellij.debugger.impl.DebuggerStateManager;
import com.intellij.debugger.ui.DebuggerView;
import com.intellij.openapi.Disposable;
myRebuildAlarm.addRequest(new Runnable() {
public void run() {
try {
- rebuild(event == DebuggerSession.EVENT_REFRESH || event == DebuggerSession.EVENT_REFRESH_VIEWS_ONLY);
+ rebuild(event);
}
catch (VMDisconnectedException e) {
// ignored
}
}
- protected abstract void rebuild(boolean updateOnly);
+ protected abstract void rebuild(int event);
protected final void registerDisposable(Disposable disposable) {
myDisposables.add(disposable);
import com.intellij.debugger.actions.DebuggerAction;
import com.intellij.debugger.actions.DebuggerActions;
+import com.intellij.debugger.impl.DebuggerContextImpl;
+import com.intellij.debugger.impl.DebuggerSession;
import com.intellij.debugger.impl.DebuggerStateManager;
import com.intellij.debugger.ui.impl.watch.DebuggerTree;
import com.intellij.openapi.Disposable;
return new FrameDebuggerTree(getProject());
}
+ protected void changeEvent(DebuggerContextImpl newContext, int event) {
+ if (event != DebuggerSession.EVENT_THREADS_REFRESH) {
+ super.changeEvent(newContext, event);
+ }
+ }
protected ActionPopupMenu createPopupMenu() {
ActionGroup group = (ActionGroup)ActionManager.getInstance().getAction(DebuggerActions.FRAME_PANEL_POPUP);
import com.intellij.debugger.ui.impl.watch.DebuggerTree;
import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
import com.intellij.debugger.ui.impl.watch.WatchItemDescriptor;
-import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.ActionPopupMenu;
import com.intellij.openapi.actionSystem.CommonShortcuts;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
}
protected void changeEvent(DebuggerContextImpl newContext, int event) {
+ if (event == DebuggerSession.EVENT_THREADS_REFRESH) {
+ return;
+ }
if(event == DebuggerSession.EVENT_ATTACHED) {
DebuggerTreeNodeImpl root = (DebuggerTreeNodeImpl) getWatchTree().getModel().getRoot();
if(root != null) {
*/
package com.intellij.ide;
-import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider;
import com.intellij.lang.Language;
import com.intellij.lang.StdLanguages;
import com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable;
+import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider;
import org.jetbrains.annotations.NotNull;
/**
return GENERAL_CODE_SAMPLE;
}
+ @Override
+ public int getRightMargin(@NotNull SettingsType settingsType) {
+ if (settingsType == SettingsType.WRAPPING_AND_BRACES_SETTINGS) return 37;
+ return super.getRightMargin(settingsType);
+ }
+
@Override
public void customizeSettings(@NotNull CodeStyleSettingsCustomizable consumer, @NotNull SettingsType settingsType) {
consumer.showAllStandardOptions();
public abstract String getCodeSample(@NotNull SettingsType settingsType);
+ public int getRightMargin(@NotNull SettingsType settingsType) {
+ return settingsType == SettingsType.WRAPPING_AND_BRACES_SETTINGS ? 30 : -1;
+ }
+
public void customizeSettings(@NotNull CodeStyleSettingsCustomizable consumer, @NotNull SettingsType settingsType) {
}
return null;
}
+ public static int getRightMargin(Language lang, @NotNull SettingsType settingsType) {
+ for (LanguageCodeStyleSettingsProvider provider : Extensions.getExtensions(EP_NAME)) {
+ if (provider.getLanguage().equals(lang)) {
+ return provider.getRightMargin(settingsType);
+ }
+ }
+ return -1;
+ }
+
@Nullable
public static Language getLanguage(String langName) {
for (LanguageCodeStyleSettingsProvider provider : Extensions.getExtensions(EP_NAME)) {
import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.psi.search.PsiElementProcessor;
import com.intellij.psi.stubs.StubBase;
+import com.intellij.psi.stubs.StubElement;
import com.intellij.psi.templateLanguages.OuterLanguageElement;
import com.intellij.util.ArrayUtil;
import com.intellij.util.SmartList;
@Nullable
public static PsiElement getStubOrPsiParent(@Nullable PsiElement element) {
- return getStubOrPsiParentOfType(element, PsiElement.class);
+ if (element instanceof StubBasedPsiElement) {
+ StubBase stub = (StubBase)((StubBasedPsiElement)element).getStub();
+ if (stub != null) {
+ //noinspection unchecked
+ final StubElement parentStub = stub.getParentStub();
+ return parentStub != null ? parentStub.getPsi() : null;
+ }
+
+ }
+ return element != null ? element.getParent() : null;
}
@Nullable
package com.intellij.application.options;
import com.intellij.application.options.codeStyle.CodeStyleSchemesModel;
+import com.intellij.codeStyle.CodeStyleFacade;
import com.intellij.ide.DataManager;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
somethingChanged();
}
});
+
+ updatePreview();
}
public void setModel(final CodeStyleSchemesModel model) {
private Editor createEditor() {
EditorFactory editorFactory = EditorFactory.getInstance();
- myTextToReformat = getPreviewText();
- Document editorDocument = editorFactory.createDocument(myTextToReformat);
+ Document editorDocument = editorFactory.createDocument("");
EditorEx editor = (EditorEx)editorFactory.createViewer(editorDocument);
-
+ fillEditorSettings(editor.getSettings());
myLastDocumentModificationStamp = editor.getDocument().getModificationStamp();
-
- EditorSettings editorSettings = editor.getSettings();
- fillEditorSettings(editorSettings);
-
- updatePreviewHighlighter(editor);
-
return editor;
}
- private void updatePreviewHighlighter(final EditorEx editor) {
- EditorColorsScheme scheme = editor.getColorsScheme();
- scheme.setColor(EditorColors.CARET_ROW_COLOR, null);
-
- editor.setHighlighter(createHighlighter(scheme));
- }
-
- protected void updatePreviewEditor() {
- myTextToReformat = getPreviewText();
- updatePreview();
- updatePreviewHighlighter((EditorEx)myEditor);
- }
-
- protected abstract EditorHighlighter createHighlighter(final EditorColorsScheme scheme);
-
private void fillEditorSettings(final EditorSettings editorSettings) {
editorSettings.setWhitespacesShown(true);
editorSettings.setLineMarkerAreaShown(false);
editorSettings.setFoldingOutlineShown(false);
editorSettings.setAdditionalColumnsCount(0);
editorSettings.setAdditionalLinesCount(1);
- final int rightMargin = getRightMargin();
- if (rightMargin > 0) {
- editorSettings.setRightMargin(rightMargin);
- }
}
- protected abstract int getRightMargin();
+ protected void updatePreview() {
+ updateEditor();
+ updatePreviewHighlighter((EditorEx)myEditor);
+ }
- public final void updatePreview() {
+ private void updateEditor() {
if (!myShouldUpdatePreview || !myEditor.getComponent().isShowing()) {
return;
}
if (myLastDocumentModificationStamp != myEditor.getDocument().getModificationStamp()) {
myTextToReformat = myEditor.getDocument().getText();
+ } else {
+ myTextToReformat = getPreviewText();
}
int currOffs = myEditor.getScrollingModel().getVerticalScrollOffset();
replaceText(finalProject);
}
}, null, null);
- myEditor.getSettings().setRightMargin(getRightMargin());
+
+ myEditor.getSettings().setRightMargin(getAdjustedRightMargin());
myLastDocumentModificationStamp = myEditor.getDocument().getModificationStamp();
myEditor.getScrollingModel().scrollVertically(currOffs);
}
+ private int getAdjustedRightMargin() {
+ int result = getRightMargin();
+ return result > 0 ? result : CodeStyleFacade.getInstance(getCurrentProject()).getRightMargin();
+ }
+
+ protected abstract int getRightMargin();
+
private void replaceText(final Project project) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
prepareForReformat(psiFile);
apply(mySettings);
CodeStyleSettings clone = mySettings.clone();
- if (getRightMargin() > 0) {
- clone.RIGHT_MARGIN = getRightMargin();
- }
+ clone.RIGHT_MARGIN = getAdjustedRightMargin();
CodeStyleSettingsManager.getInstance(project).setTemporarySettings(clone);
return project;
}
+ private void updatePreviewHighlighter(final EditorEx editor) {
+ EditorColorsScheme scheme = editor.getColorsScheme();
+ scheme.setColor(EditorColors.CARET_ROW_COLOR, null);
+ editor.setHighlighter(createHighlighter(scheme));
+ }
+
+ protected abstract EditorHighlighter createHighlighter(final EditorColorsScheme scheme);
+
@NotNull
protected abstract FileType getFileType();
try {
myUpdateAlarm.cancelAllRequests();
if (isSomethingChanged()) {
- updatePreview();
+ updateEditor();
}
}
finally {
final int selIndex = myIndentOptionsTabs.getSelectedIndex();
if (selIndex != myLastSelectedTab) {
myLastSelectedTab = selIndex;
- updatePreviewEditor();
+ updatePreview();
somethingChanged();
}
}
}
- protected int getRightMargin() {
- return -1;
- }
-
public JComponent getPanel() {
return myPanel;
}
}
}
onLanguageChange(language);
- updatePreviewEditor();
+ updatePreview();
}
public Language getSelectedLanguage() {
return sample;
}
+ @Override
+ protected int getRightMargin() {
+ if (myLanguage == null) return -1;
+ return LanguageCodeStyleSettingsProvider.getRightMargin(myLanguage, getSettingsType());
+ }
+
@NotNull
@Override
protected FileType getFileType() {
setPanelLanguage(langs[0]);
}
else {
- updatePreviewEditor();
+ updatePreview();
}
tabbedPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
else {
// If settings are language-specific
previewPanel.add(getEditor().getComponent(), BorderLayout.CENTER);
- updatePreviewEditor();
+ updatePreview();
}
}
protected abstract void initTables();
- protected int getRightMargin() {
- return -1;
- }
-
protected void resetImpl(final CodeStyleSettings settings) {
TreeModel treeModel = myOptionsTree.getModel();
TreeNode root = (TreeNode)treeModel.getRoot();
addOption("VARIABLE_ANNOTATION_WRAP", ApplicationBundle.message("wrapping.local.variables.annotation"), WRAP_OPTIONS, WRAP_VALUES);
addOption("ENUM_CONSTANTS_WRAP", ApplicationBundle.message("wrapping.enum.constants"), WRAP_OPTIONS, WRAP_VALUES);
}
-
- protected int getRightMargin() {
- return 37;
- }
}
\ No newline at end of file
package com.intellij.ide.actions;
-import com.intellij.CommonBundle;
-import com.intellij.history.LocalHistory;
-import com.intellij.history.LocalHistoryAction;
import com.intellij.ide.IdeBundle;
import com.intellij.ide.IdeView;
import com.intellij.ide.util.DirectoryChooserUtil;
-import com.intellij.ide.util.DirectoryUtil;
import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.command.CommandProcessor;
-import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.InputValidatorEx;
import com.intellij.openapi.ui.Messages;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
import com.intellij.psi.impl.file.PsiDirectoryFactory;
import com.intellij.util.Icons;
-import com.intellij.util.IncorrectOperationException;
-
-import java.io.File;
public class CreateDirectoryOrPackageAction extends AnAction implements DumbAware {
public CreateDirectoryOrPackageAction() {
}
public void actionPerformed(AnActionEvent e) {
- DataContext dataContext = e.getDataContext();
-
- IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
- Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+ IdeView view = e.getData(LangDataKeys.IDE_VIEW);
+ Project project = e.getData(PlatformDataKeys.PROJECT);
PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
if (directory == null) return;
boolean isDirectory = !PsiDirectoryFactory.getInstance(project).isPackage(directory);
- MyInputValidator validator = new MyInputValidator(project, directory, isDirectory);
+ CreateDirectoryOrPackageHandler validator = new CreateDirectoryOrPackageHandler(project, directory, isDirectory,
+ isDirectory ? "\\/" : ".");
Messages.showInputDialog(project, isDirectory
? IdeBundle.message("prompt.enter.new.directory.name")
: IdeBundle.message("prompt.enter.new.package.name"),
isDirectory ? IdeBundle.message("title.new.directory") : IdeBundle.message("title.new.package"),
Messages.getQuestionIcon(), "", validator);
- if (validator.myCreatedElement == null) return;
-
- view.selectElement(validator.myCreatedElement);
+ final PsiElement result = validator.getCreatedElement();
+ if (result != null && view != null) {
+ view.selectElement(result);
+ }
}
public void update(AnActionEvent event) {
Presentation presentation = event.getPresentation();
- DataContext dataContext = event.getDataContext();
- Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+ Project project = event.getData(PlatformDataKeys.PROJECT);
if (project == null) {
presentation.setVisible(false);
presentation.setEnabled(false);
return;
}
- IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
+ IdeView view = event.getData(LangDataKeys.IDE_VIEW);
if (view == null) {
presentation.setVisible(false);
presentation.setEnabled(false);
}
}
- protected class MyInputValidator implements InputValidatorEx {
- private final Project myProject;
- private final PsiDirectory myDirectory;
- private final boolean myIsDirectory;
- private PsiElement myCreatedElement = null;
-
- public MyInputValidator(Project project, PsiDirectory directory, boolean isDirectory) {
- myProject = project;
- myDirectory = directory;
- myIsDirectory = isDirectory;
- }
-
- public boolean checkInput(String inputString) {
- return true;
- }
-
- public String getErrorText(String inputString) {
- if (FileTypeManager.getInstance().isFileIgnored(inputString)) {
- return "Trying to create a " + (myIsDirectory ? "directory" : "package") + " with ignored name, result will not be visible";
- }
- if (!myIsDirectory && inputString.length() > 0 && !PsiDirectoryFactory.getInstance(myProject).isValidPackageName(inputString)) {
- return "Not a valid package name";
- }
- return null;
- }
-
- public boolean canClose(String inputString) {
- final String subDirName = inputString;
-
- if (subDirName.length() == 0) {
- Messages.showMessageDialog(myProject, IdeBundle.message("error.name.should.be.specified"), CommonBundle.getErrorTitle(),
- Messages.getErrorIcon());
- return false;
- }
-
- final boolean multiCreation = myIsDirectory
- ? subDirName.indexOf('/') != -1 || subDirName.indexOf('\\') != -1
- : subDirName.indexOf('.') != -1;
-
- if (!multiCreation) {
- try {
- myDirectory.checkCreateSubdirectory(subDirName);
- }
- catch (IncorrectOperationException ex) {
- Messages.showMessageDialog(myProject, CreateElementActionBase.filterMessage(ex.getMessage()), CommonBundle.getErrorTitle(),
- Messages.getErrorIcon());
- return false;
- }
- }
-
- Runnable command = new Runnable() {
- public void run() {
- final Runnable run = new Runnable() {
- public void run() {
- LocalHistoryAction action = LocalHistoryAction.NULL;
- try {
- String actionName;
- String dirPath = myDirectory.getVirtualFile().getPresentableUrl();
- actionName = IdeBundle.message("progress.creating.directory", dirPath, File.separator, subDirName);
- action = LocalHistory.getInstance().startAction(actionName);
-
- final PsiDirectory createdDir;
- if (myIsDirectory) {
- createdDir = DirectoryUtil.createSubdirectories(subDirName, myDirectory, "\\/");
- }
- else {
- createdDir = DirectoryUtil.createSubdirectories(subDirName, myDirectory, ".");
- }
-
-
- myCreatedElement = createdDir;
-
- }
- catch (final IncorrectOperationException ex) {
- ApplicationManager.getApplication().invokeLater(new Runnable() {
- public void run() {
- Messages.showMessageDialog(myProject, CreateElementActionBase.filterMessage(ex.getMessage()),
- CommonBundle.getErrorTitle(), Messages.getErrorIcon());
- }
- });
- }
- finally {
- action.finish();
- }
- }
- };
- ApplicationManager.getApplication().runWriteAction(run);
- }
- };
- CommandProcessor.getInstance().executeCommand(myProject, command, myIsDirectory
- ? IdeBundle.message("command.create.directory")
- : IdeBundle.message("command.create.package"), null);
-
- return myCreatedElement != null;
- }
- }
}
--- /dev/null
+/*
+ * 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.ide.actions;
+
+import com.intellij.CommonBundle;
+import com.intellij.history.LocalHistory;
+import com.intellij.history.LocalHistoryAction;
+import com.intellij.ide.IdeBundle;
+import com.intellij.ide.util.DirectoryUtil;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.command.CommandProcessor;
+import com.intellij.openapi.fileTypes.FileTypeManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.InputValidatorEx;
+import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.PsiDirectory;
+import com.intellij.psi.impl.file.PsiDirectoryFactory;
+import com.intellij.util.IncorrectOperationException;
+
+import java.io.File;
+
+public class CreateDirectoryOrPackageHandler implements InputValidatorEx {
+ private final Project myProject;
+ private final PsiDirectory myDirectory;
+ private final boolean myIsDirectory;
+ private PsiDirectory myCreatedElement = null;
+ private String myDelimiters;
+
+ public CreateDirectoryOrPackageHandler(Project project, PsiDirectory directory, boolean isDirectory, final String delimiters) {
+ myProject = project;
+ myDirectory = directory;
+ myIsDirectory = isDirectory;
+ myDelimiters = delimiters;
+ }
+
+ public boolean checkInput(String inputString) {
+ return true;
+ }
+
+ public String getErrorText(String inputString) {
+ if (FileTypeManager.getInstance().isFileIgnored(inputString)) {
+ return "Trying to create a " + (myIsDirectory ? "directory" : "package") + " with ignored name, result will not be visible";
+ }
+ if (!myIsDirectory && inputString.length() > 0 && !PsiDirectoryFactory.getInstance(myProject).isValidPackageName(inputString)) {
+ return "Not a valid package name";
+ }
+ return null;
+ }
+
+ public boolean canClose(String inputString) {
+ final String subDirName = inputString;
+
+ if (subDirName.length() == 0) {
+ Messages.showMessageDialog(myProject, IdeBundle.message("error.name.should.be.specified"), CommonBundle.getErrorTitle(),
+ Messages.getErrorIcon());
+ return false;
+ }
+
+ final boolean multiCreation = StringUtil.containsAnyChar(subDirName, myDelimiters);
+ if (!multiCreation) {
+ try {
+ myDirectory.checkCreateSubdirectory(subDirName);
+ }
+ catch (IncorrectOperationException ex) {
+ Messages.showMessageDialog(myProject, CreateElementActionBase.filterMessage(ex.getMessage()), CommonBundle.getErrorTitle(),
+ Messages.getErrorIcon());
+ return false;
+ }
+ }
+
+ Runnable command = new Runnable() {
+ public void run() {
+ final Runnable run = new Runnable() {
+ public void run() {
+ LocalHistoryAction action = LocalHistoryAction.NULL;
+ try {
+ String actionName;
+ String dirPath = myDirectory.getVirtualFile().getPresentableUrl();
+ actionName = IdeBundle.message("progress.creating.directory", dirPath, File.separator, subDirName);
+ action = LocalHistory.getInstance().startAction(actionName);
+
+ myCreatedElement = DirectoryUtil.createSubdirectories(subDirName, myDirectory, myDelimiters);
+
+ }
+ catch (final IncorrectOperationException ex) {
+ ApplicationManager.getApplication().invokeLater(new Runnable() {
+ public void run() {
+ Messages.showMessageDialog(myProject, CreateElementActionBase.filterMessage(ex.getMessage()),
+ CommonBundle.getErrorTitle(), Messages.getErrorIcon());
+ }
+ });
+ }
+ finally {
+ action.finish();
+ }
+ }
+ };
+ ApplicationManager.getApplication().runWriteAction(run);
+ }
+ };
+ CommandProcessor.getInstance().executeCommand(myProject, command, myIsDirectory
+ ? IdeBundle.message("command.create.directory")
+ : IdeBundle.message("command.create.package"), null);
+
+ return myCreatedElement != null;
+ }
+
+ public PsiDirectory getCreatedElement() {
+ return myCreatedElement;
+ }
+}
private DirectoryChooserUtil() {
}
+ @Nullable
public static PsiDirectory getOrChooseDirectory(IdeView view) {
PsiDirectory[] dirs = view.getDirectories();
if (dirs.length == 0) return null;
}
}
+ @Nullable
public static PsiDirectory selectDirectory(Project project,
PsiDirectory[] packageDirectories,
PsiDirectory defaultDirectory,
sb.append("<whitespace>");
}
else
+ //This is really stupid and inconvinient builder - it breaks any normal pattern with uppercase
if(Character.isUpperCase(c)) {
sb.append('[').append(Character.toUpperCase(c)).append(Character.toLowerCase(c)).append(']');
}
--- /dev/null
+/*
+ * @(#)HRuleView.java 1.33 05/11/17
+ *
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+package com.intellij.codeInsight.hint;
+
+import java.awt.*;
+import javax.swing.event.DocumentEvent;
+import javax.swing.text.*;
+import javax.swing.text.html.CSS;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTMLDocument;
+import javax.swing.text.html.StyleSheet;
+import java.util.Enumeration;
+import java.lang.Integer;
+
+/**
+ * A view implementation to display an html horizontal
+ * rule.
+ *
+ * @author Timothy Prinzing
+ * @author Sara Swanson
+ * @version 1.33 11/17/05
+ */
+class CustomHrView extends View {
+
+ private Color myColor;
+
+ /**
+ * Creates a new view that represents an <hr> element.
+ *
+ * @param elem the element to create a view for
+ */
+ public CustomHrView(Element elem, Color color) {
+ super(elem);
+ myColor = color;
+ }
+
+
+ public void paint(Graphics g, Shape a) {
+ Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a : a.getBounds();
+ int x = 0;
+ int y = alloc.y + SPACE_ABOVE + (int)topMargin;
+ int width = alloc.width - (int)(leftMargin + rightMargin);
+ int height = 1;
+ if (size > 0) height = size;
+
+ // Align the rule horizontally.
+ switch (alignment) {
+ case StyleConstants.ALIGN_CENTER:
+ x = alloc.x + (alloc.width / 2) - (width / 2);
+ break;
+ case StyleConstants.ALIGN_RIGHT:
+ x = alloc.x + alloc.width - width - (int)rightMargin;
+ break;
+ case StyleConstants.ALIGN_LEFT:
+ default:
+ x = alloc.x + (int)leftMargin;
+ break;
+ }
+
+ // Paint either a shaded rule or a solid line.
+ if (noshade != null) {
+ g.setColor(myColor);
+ g.fillRect(x, y, width, height);
+ }
+ else {
+ Color bg = getContainer().getBackground();
+ Color bottom, top;
+ if (bg == null || bg.equals(Color.white)) {
+ top = Color.darkGray;
+ bottom = Color.lightGray;
+ }
+ else {
+ top = Color.darkGray;
+ bottom = Color.white;
+ }
+ g.setColor(bottom);
+ g.drawLine(x + width - 1, y, x + width - 1, y + height - 1);
+ g.drawLine(x, y + height - 1, x + width - 1, y + height - 1);
+ g.setColor(top);
+ g.drawLine(x, y, x + width - 1, y);
+ g.drawLine(x, y, x, y + height - 1);
+ }
+
+ }
+
+
+ /**
+ * Calculates the desired shape of the rule... this is
+ * basically the preferred size of the border.
+ *
+ * @param axis may be either X_AXIS or Y_AXIS
+ * @return the desired span
+ * @see View#getPreferredSpan
+ */
+ public float getPreferredSpan(int axis) {
+ switch (axis) {
+ case View.X_AXIS:
+ return 1;
+ case View.Y_AXIS:
+ if (size > 0) {
+ return size + SPACE_ABOVE + SPACE_BELOW + topMargin + bottomMargin;
+ }
+ else {
+ if (noshade != null) {
+ return 2 + SPACE_ABOVE + SPACE_BELOW + topMargin + bottomMargin;
+ }
+ else {
+ return SPACE_ABOVE + SPACE_BELOW + topMargin + bottomMargin;
+ }
+ }
+ default:
+ throw new IllegalArgumentException("Invalid axis: " + axis);
+ }
+ }
+
+ /**
+ * Gets the resize weight for the axis.
+ * The rule is: rigid vertically and flexible horizontally.
+ *
+ * @param axis may be either X_AXIS or Y_AXIS
+ * @return the weight
+ */
+ public int getResizeWeight(int axis) {
+ if (axis == View.X_AXIS) {
+ return 1;
+ }
+ else if (axis == View.Y_AXIS) {
+ return 0;
+ }
+ else {
+ return 0;
+ }
+ }
+
+ /**
+ * Determines how attractive a break opportunity in
+ * this view is. This is implemented to request a forced break.
+ *
+ * @param axis may be either View.X_AXIS or View.Y_AXIS
+ * @param pos the potential location of the start of the
+ * broken view (greater than or equal to zero).
+ * This may be useful for calculating tab
+ * positions.
+ * @param len specifies the relative length from <em>pos</em>
+ * where a potential break is desired. The value must be greater
+ * than or equal to zero.
+ * @return the weight, which should be a value between
+ * ForcedBreakWeight and BadBreakWeight.
+ */
+ public int getBreakWeight(int axis, float pos, float len) {
+ if (axis == X_AXIS) {
+ return ForcedBreakWeight;
+ }
+ return BadBreakWeight;
+ }
+
+ public View breakView(int axis, int offset, float pos, float len) {
+ return null;
+ }
+
+ /**
+ * Provides a mapping from the document model coordinate space
+ * to the coordinate space of the view mapped to it.
+ *
+ * @param pos the position to convert
+ * @param a the allocated region to render into
+ * @return the bounding box of the given position
+ * @throws BadLocationException if the given position does not
+ * represent a valid location in the associated document
+ * @see View#modelToView
+ */
+ public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException {
+ int p0 = getStartOffset();
+ int p1 = getEndOffset();
+ if ((pos >= p0) && (pos <= p1)) {
+ Rectangle r = a.getBounds();
+ if (pos == p1) {
+ r.x += r.width;
+ }
+ r.width = 0;
+ return r;
+ }
+ return null;
+ }
+
+ /**
+ * Provides a mapping from the view coordinate space to the logical
+ * coordinate space of the model.
+ *
+ * @param x the X coordinate
+ * @param y the Y coordinate
+ * @param a the allocated region to render into
+ * @return the location within the model that best represents the
+ * given point of view
+ * @see View#viewToModel
+ */
+ public int viewToModel(float x, float y, Shape a, Position.Bias[] bias) {
+ Rectangle alloc = (Rectangle)a;
+ if (x < alloc.x + (alloc.width / 2)) {
+ bias[0] = Position.Bias.Forward;
+ return getStartOffset();
+ }
+ bias[0] = Position.Bias.Backward;
+ return getEndOffset();
+ }
+
+ /**
+ * Fetches the attributes to use when rendering. This is
+ * implemented to multiplex the attributes specified in the
+ * model with a StyleSheet.
+ */
+ public AttributeSet getAttributes() {
+ return attr;
+ }
+
+ // --- variables ------------------------------------------------
+
+ private float topMargin;
+ private float bottomMargin;
+ private float leftMargin;
+ private float rightMargin;
+ private int alignment = StyleConstants.ALIGN_CENTER;
+ private String noshade = "true";
+ private int size = 0;
+
+ private static final int SPACE_ABOVE = 3;
+ private static final int SPACE_BELOW = 3;
+
+ /**
+ * View Attributes.
+ */
+ private AttributeSet attr;
+}
+
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
+import javax.swing.text.*;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTMLEditorKit;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
protected void stripDescription() {
}
- static JEditorPane initPane(@NonNls String text, HintHint hintHint, JLayeredPane layeredPane) {
+ static JEditorPane initPane(@NonNls String text, final HintHint hintHint, JLayeredPane layeredPane) {
final Ref<Dimension> prefSize = new Ref<Dimension>(null);
text = "<html><head>" +
- UIUtil.getCssFontDeclaration(hintHint.getTextFont(), hintHint.getTextForeground()) +
+ UIUtil.getCssFontDeclaration(hintHint.getTextFont(), hintHint.getTextForeground(), hintHint.getLinkForeground()) +
"</head><body>" +
getHtmlBody(text) +
"</body></html>";
- final JEditorPane pane = new JEditorPane(UIUtil.HTML_MIME, text) {
+
+ final JEditorPane pane = new JEditorPane() {
@Override
public Dimension getPreferredSize() {
return prefSize.get() != null ? prefSize.get() : super.getPreferredSize();
}
};
+ final HTMLEditorKit.HTMLFactory factory = new HTMLEditorKit.HTMLFactory() {
+ @Override
+ public View create(Element elem) {
+ AttributeSet attrs = elem.getAttributes();
+ Object elementName = attrs.getAttribute(AbstractDocument.ElementNameAttribute);
+ Object o = (elementName != null) ? null : attrs.getAttribute(StyleConstants.NameAttribute);
+ if (o instanceof HTML.Tag) {
+ HTML.Tag kind = (HTML.Tag)o;
+ if (kind == HTML.Tag.HR) {
+ return new CustomHrView(elem, hintHint.getTextForeground());
+ }
+ }
+ return super.create(elem);
+ }
+ };
+
+ HTMLEditorKit kit = new HTMLEditorKit() {
+ @Override
+ public ViewFactory getViewFactory() {
+ return factory;
+ }
+ };
+ pane.setEditorKit(kit);
+ pane.setText(text);
+
pane.setCaretPosition(0);
pane.setEditable(false);
return pane;
}
+
public static void setColors(JComponent pane) {
pane.setForeground(Color.black);
pane.setBackground(HintUtil.INFORMATION_COLOR);
}
protected static String getHtmlBody(@NonNls String text) {
+ String result = text;
if (!text.startsWith("<html>")) {
- return text.replaceAll("\n", "<br>");
+ result = text.replaceAll("\n", "<br>");
}
- final int bodyIdx = text.indexOf("<body>");
- final int closedBodyIdx = text.indexOf("</body>");
- if (bodyIdx != -1 && closedBodyIdx != -1) {
- return text.substring(bodyIdx + "<body>".length(), closedBodyIdx);
+ else {
+ final int bodyIdx = text.indexOf("<body>");
+ final int closedBodyIdx = text.indexOf("</body>");
+ if (bodyIdx != -1 && closedBodyIdx != -1) {
+ result = text.substring(bodyIdx + "<body>".length(), closedBodyIdx);
+ }
+ else {
+ text = StringUtil.trimStart(text, "<html>").trim();
+ text = StringUtil.trimEnd(text, "</html>").trim();
+ text = StringUtil.trimStart(text, "<body>").trim();
+ text = StringUtil.trimEnd(text, "</body>").trim();
+ result = text;
+ }
}
- text = StringUtil.trimStart(text, "<html>").trim();
- text = StringUtil.trimEnd(text, "</html>").trim();
- text = StringUtil.trimStart(text, "<body>").trim();
- text = StringUtil.trimEnd(text, "</body>").trim();
- return text;
+
+ return result;
}
public boolean equals(Object o) {
return useGraphite(awtTooltip) ? Color.white : UIManager.getColor("ToolTip.foreground");
}
+ public Color getLinkForeground(boolean awtTooltip) {
+ return useGraphite(awtTooltip) ? new Color(209, 209, 255) : Color.blue;
+ }
+
public Color getTextBackground(boolean awtTooltip) {
return useGraphite(awtTooltip) ? new Color(100, 100, 100, 230) : UIManager.getColor("ToolTip.background");
}
hideCurrent(null);
}
}
+
}
private ActionToolbarImpl.MyTimerListener myTimerListener;
public ActionToolbarImpl(final String place,
- final ActionGroup actionGroup,
+ @NotNull final ActionGroup actionGroup,
final boolean horizontal,
DataManager dataManager,
ActionManagerEx actionManager,
}
public ActionToolbarImpl(final String place,
- final ActionGroup actionGroup,
+ @NotNull final ActionGroup actionGroup,
final boolean horizontal,
DataManager dataManager,
ActionManagerEx actionManager,
//System.out.println("text length: " + text.length() + ", soft wraps: " + myStorage.getSoftWraps());
//for (int i = 0; i < myCache.size(); i++) {
// CacheEntry entry = myCache.get(i);
- // System.out.printf("line %d. %d-%d: '%s'%n", i, entry.startOffset, entry.endOffset,
- // text.subSequence(entry.startOffset,Math.min(entry.endOffset, text.length())));
+ // // TODO den unwrap
+ // try {
+ // System.out.printf("line %d. %d-%d: '%s'%n", i, entry.startOffset, entry.endOffset,
+ // text.subSequence(entry.startOffset,Math.min(entry.endOffset, text.length())));
+ // }
+ // catch (Throwable e) {
+ // e.printStackTrace();
+ // }
+ //}
+ //if (!myCache.isEmpty() && myCache.get(myCache.size() - 1).endOffset < text.length() - 1) {
+ // System.out.printf("Incomplete re-parsing detected! Document length is %d but last processed offset is %s%n", text.length(),
+ // myCache.get(myCache.size() - 1).endOffset);
//}
- //
+
+
//for (CacheEntry cacheEntry : myCache) {
// if (cacheEntry.startOffset > 0) {
// if (text.charAt(cacheEntry.startOffset - 1) != '\n' && myStorage.getSoftWrap(cacheEntry.startOffset) == null) {
}
private void recalculateSoftWraps(DirtyRegion region) {
- notifyListenersOnRangeRecalculation(region, true);
+ if (region.notifyAboutRecalculationStart) {
+ notifyListenersOnRangeRecalculation(region, true);
+ }
myStorage.removeInRange(region.startRange.getStartOffset(), region.startRange.getEndOffset());
try {
region.beforeRecalculation();
@Override
public void onFoldRegionStateChange(@NotNull FoldRegion region) {
+ /*
assert ApplicationManagerEx.getApplicationEx().isDispatchThread();
Document document = myEditor.getDocument();
int endOffset = document.getLineEndOffset(endLine);
myDirtyRegions.add(new DirtyRegion(startOffset, endOffset));
+ */
}
@Override
@Override
public void beforeDocumentChange(DocumentEvent event) {
- myDirtyRegions.add(new DirtyRegion(event));
+ DirtyRegion region = new DirtyRegion(event);
+ myDirtyRegions.add(region);
+ notifyListenersOnRangeRecalculation(region, true);
}
@Override
public TextRange startRange;
public TextRange endRange;
+ public boolean notifyAboutRecalculationStart;
private boolean myRecalculateEnd;
DirtyRegion(int startOffset, int endOffset) {
startRange = new TextRange(startOffset, endOffset);
endRange = new TextRange(startOffset, endOffset);
+ notifyAboutRecalculationStart = true;
}
DirtyRegion(DocumentEvent event) {
case ' ': indentInColumns += 1; indentInPixels += spaceWidth; break;
case '\t':
int x = EditorUtil.nextTabStop(indentInPixels, editor);
- indentInColumns = calculateWidthInColumns(x - indentInPixels, spaceWidth);
+ indentInColumns += calculateWidthInColumns(x - indentInPixels, spaceWidth);
indentInPixels = x;
break;
default: myNonWhiteSpaceSymbolOffset = i; return;
return getTooltipManager().getTextBackground(myAwtTooltip);
}
+ public Color getLinkForeground() {
+ return getTooltipManager().getLinkForeground(myAwtTooltip);
+ }
+
public boolean isOwnBorderAllowed() {
return getTooltipManager().isOwnBorderAllowed(myAwtTooltip);
}
<name>IDEA CORE</name>
<xi:include href="/componentSets/PlatformComponents.xml" xpointer="xpointer(/components/*)"/>
+ <xi:include href="/idea/PlatformActionManager.xml" xpointer="xpointer(/component/*)"/>
<extensionPoints>
<xi:include href="/META-INF/PlatformExtensionPoints.xml" xpointer="xpointer(/extensionPoints/*)"/>
<!-- <version name="IntelliJ IDEA" major="6" minor="0.2 Beta"/> -->
<version codename="Diana" major="8" minor="0M1" eap="true"/>
<build number="__BUILD_NUMBER__" date="__BUILD_DATE__"/>
- <logo url="/idea_logo.png"/>
+ <logo url="/idea_logo.png" textcolor="FFFFFF"/>
<about url="/idea_about.png"/>
<package code="__PACKAGE_CODE__"/>
<names product="IDEA" fullname="IntelliJ IDEA"/>
@NonNls
public static String getCssFontDeclaration(final Font font) {
- return getCssFontDeclaration(font, null);
+ return getCssFontDeclaration(font, null, null);
}
@NonNls
- public static String getCssFontDeclaration(final Font font, @Nullable Color fgColor) {
- return "<style> body, div, td { font-family: " + font.getFamily() + "; font-size: " + font.getSize() + "; " + (fgColor != null ? "color:" + ColorUtil.toHex(fgColor) : "") + " } </style>";
+ public static String getCssFontDeclaration(final Font font, @Nullable Color fgColor, @Nullable Color linkColor) {
+ String fontFamilyAndSize = "font-family:" + font.getFamily() + "; font-size:" + font.getSize() + ";";
+ String body = "body, div, td {" + fontFamilyAndSize + " " + (fgColor != null ? "color:" + ColorUtil.toHex(fgColor) : "") + "}";
+ String link = (linkColor != null ? ("a {" + fontFamilyAndSize + " color:" + ColorUtil.toHex(linkColor) + "") : "") + "}";
+ return "<style> " + body + " " + link + "</style>";
}
public static boolean isWinLafOnVista() {
return ((GrFileStub)stub).isScript();
}
- Boolean isScript = myScript;
- if (isScript == null) {
+ if (myScript == null) {
final GrTopStatement[] topStatements = findChildrenByClass(GrTopStatement.class);
- isScript = Boolean.FALSE;
+ boolean hasClassDefinitions = false;
+ boolean hasTopStatements = false;
for (GrTopStatement st : topStatements) {
- if (!(st instanceof GrTypeDefinition || st instanceof GrImportStatement || st instanceof GrPackageDefinition)) {
- isScript = Boolean.TRUE;
+ if (st instanceof GrTypeDefinition) {
+ hasClassDefinitions = true;
+ }
+ else if (!(st instanceof GrImportStatement || st instanceof GrPackageDefinition)) {
+ hasTopStatements = true;
break;
}
}
- myScript = isScript;
+ myScript = hasTopStatements || !hasClassDefinitions;
}
-
- return isScript;
+ return myScript;
}
@Override
import com.intellij.refactoring.HelpID;
import com.intellij.refactoring.JavaRefactoringSettings;
import com.intellij.refactoring.move.MoveCallback;
+import com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesDialog;
import com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesHandlerBase;
import com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesImpl;
import com.intellij.refactoring.util.CommonRefactoringUtil;