Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Trofimov
2013-03-08 14:10:24 +01:00
384 changed files with 2141 additions and 2547 deletions
Generated
+1 -9
View File
@@ -1,15 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AntConfiguration">
<defaultAnt bundledAnt="true" />
<buildFile url="file://$PROJECT_DIR$/build/update.xml">
<additionalClassPath />
<antReference projectDefault="true" />
<customJdkName value="" />
<maximumHeapSize value="128" />
<maximumStackSize value="2" />
<properties />
</buildFile>
<buildFile url="file://$PROJECT_DIR$/build/update.xml" />
</component>
</project>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -125,9 +125,13 @@ public class AddToWatchActionHandler extends DebuggerActionHandler {
}
public void threadAction() {
final DebuggerSession session = myDebuggerContext.getDebuggerSession();
if (session == null) {
return;
}
final Project project = session.getProject();
for (final DebuggerTreeNodeImpl node : mySelectedNodes) {
final NodeDescriptorImpl descriptor = node.getDescriptor();
final Project project = myDebuggerContext.getDebuggerSession().getProject();
try {
final TextWithImports expression = DebuggerTreeNodeExpression.createEvaluationText(node, myDebuggerContext);
if (expression != null) {
@@ -17,39 +17,27 @@ package com.intellij.debugger.actions;
import com.intellij.debugger.DebuggerManagerEx;
import com.intellij.debugger.SourcePosition;
import com.intellij.debugger.engine.RequestHint;
import com.intellij.debugger.engine.SuspendContextImpl;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.impl.DebuggerSession;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.ui.popup.ListPopup;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.util.containers.OrderedSet;
import com.intellij.util.text.CharArrayUtil;
import com.intellij.xdebugger.impl.actions.DebuggerActionHandler;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import gnu.trove.TObjectHashingStrategy;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
public class JvmSmartStepIntoActionHandler extends DebuggerActionHandler {
public void perform(@NotNull final Project project, final AnActionEvent event) {
final DebuggerContextImpl debuggerContext = (DebuggerManagerEx.getInstanceEx(project)).getContext();
doStep(project, debuggerContext.getSourcePosition(), debuggerContext.getDebuggerSession());
final DebuggerSession session = debuggerContext.getDebuggerSession();
if (session != null) {
doStep(project, debuggerContext.getSourcePosition(), session);
}
}
private static void doStep(final @NotNull Project project, final @Nullable SourcePosition position, final @NotNull DebuggerSession session) {
@@ -26,7 +26,10 @@ import org.jetbrains.annotations.NotNull;
public class PauseActionHandler extends DebuggerActionHandler {
public void perform(@NotNull final Project project, final AnActionEvent event) {
(DebuggerManagerEx.getInstanceEx(project)).getContext().getDebuggerSession().pause();
final DebuggerSession session = (DebuggerManagerEx.getInstanceEx(project)).getContext().getDebuggerSession();
if (session != null) {
session.pause();
}
}
@Override
@@ -25,7 +25,10 @@ import org.jetbrains.annotations.NotNull;
public class ResumeActionHandler extends DebuggerActionHandler {
public void perform(@NotNull final Project project, final AnActionEvent event) {
(DebuggerManagerEx.getInstanceEx(project)).getContext().getDebuggerSession().resume();
final DebuggerSession session = (DebuggerManagerEx.getInstanceEx(project)).getContext().getDebuggerSession();
if (session != null) {
session.resume();
}
}
public boolean isEnabled(@NotNull final Project project, final AnActionEvent event) {
@@ -83,6 +83,9 @@ public class RunToCursorActionHandler extends DebuggerActionHandler {
if (debugProcess == null) {
return;
}
context.getDebuggerSession().runToCursor(editor.getDocument(), editor.getCaretModel().getLogicalPosition().line, myIgnoreBreakpoints);
final DebuggerSession session = context.getDebuggerSession();
if (session != null) {
session.runToCursor(editor.getDocument(), editor.getCaretModel().getLogicalPosition().line, myIgnoreBreakpoints);
}
}
}
@@ -69,7 +69,10 @@ public class SetValueAction extends DebuggerAction {
private void update(final DebuggerContextImpl context) {
DebuggerInvocationUtil.swingInvokeLater(context.getProject(), new Runnable() {
public void run() {
context.getDebuggerSession().refresh(false);
final DebuggerSession session = context.getDebuggerSession();
if (session != null) {
session.refresh(false);
}
}
});
//node.setState(context);
@@ -24,7 +24,10 @@ import org.jetbrains.annotations.NotNull;
public class ShowExecutionPointActionHandler extends DebuggerActionHandler {
public void perform(@NotNull final Project project, final AnActionEvent event) {
(DebuggerManagerEx.getInstanceEx(project)).getContext().getDebuggerSession().showExecutionPoint();
final DebuggerSession session = (DebuggerManagerEx.getInstanceEx(project)).getContext().getDebuggerSession();
if (session != null) {
session.showExecutionPoint();
}
}
public boolean isEnabled(@NotNull final Project project, final AnActionEvent event) {
@@ -46,6 +46,7 @@ public final class DebuggerContextImpl implements DebuggerContext {
private boolean myInitialized;
@Nullable
private final DebuggerSession myDebuggerSession;
private final DebugProcessImpl myDebugProcess;
private final SuspendContextImpl mySuspendContext;
@@ -55,7 +56,7 @@ public final class DebuggerContextImpl implements DebuggerContext {
private SourcePosition mySourcePosition;
private PsiElement myContextElement;
private DebuggerContextImpl(DebuggerSession session, DebugProcessImpl debugProcess, SuspendContextImpl context, ThreadReferenceProxyImpl threadProxy, StackFrameProxyImpl frameProxy, SourcePosition position, PsiElement contextElement, boolean initialized) {
private DebuggerContextImpl(@Nullable DebuggerSession session, DebugProcessImpl debugProcess, SuspendContextImpl context, ThreadReferenceProxyImpl threadProxy, StackFrameProxyImpl frameProxy, SourcePosition position, PsiElement contextElement, boolean initialized) {
LOG.assertTrue(frameProxy == null || threadProxy == null || threadProxy == frameProxy.threadProxy());
LOG.assertTrue(debugProcess == null ? frameProxy == null && threadProxy == null : true);
myDebuggerSession = session;
@@ -68,6 +69,7 @@ public final class DebuggerContextImpl implements DebuggerContext {
myInitialized = initialized;
}
@Nullable
public DebuggerSession getDebuggerSession() {
return myDebuggerSession;
}
@@ -24,21 +24,28 @@ import org.jetbrains.annotations.NotNull;
public class DebuggerContextUtil {
public static void setStackFrame(DebuggerStateManager manager, final StackFrameProxyImpl stackFrame) {
ApplicationManager.getApplication().assertIsDispatchThread();
DebuggerContextImpl context = manager.getContext();
if(context == null) return;
final DebuggerContextImpl context = manager.getContext();
if(context == null) {
return;
}
DebuggerContextImpl newContext = DebuggerContextImpl.createDebuggerContext(context.getDebuggerSession(), context.getSuspendContext(), stackFrame.threadProxy(), stackFrame);
final DebuggerSession session = context.getDebuggerSession();
final DebuggerContextImpl newContext = DebuggerContextImpl.createDebuggerContext(session, context.getSuspendContext(), stackFrame.threadProxy(), stackFrame);
manager.setState(newContext, context.getDebuggerSession().getState(), DebuggerSession.EVENT_REFRESH, null);
manager.setState(newContext, session != null? session.getState() : DebuggerSession.STATE_DISPOSED, DebuggerSession.EVENT_REFRESH, null);
}
public static void setThread(DebuggerStateManager contextManager, ThreadDescriptorImpl item) {
ApplicationManager.getApplication().assertIsDispatchThread();
DebuggerContextImpl context = contextManager.getContext();
final DebuggerContextImpl context = contextManager.getContext();
if(context == null) {
return;
}
DebuggerContextImpl newContext = DebuggerContextImpl.createDebuggerContext(context.getDebuggerSession(), item.getSuspendContext(), item.getThreadReference(), null);
final DebuggerSession session = context.getDebuggerSession();
final DebuggerContextImpl newContext = DebuggerContextImpl.createDebuggerContext(session, item.getSuspendContext(), item.getThreadReference(), null);
contextManager.setState(newContext, context.getDebuggerSession().getState(), DebuggerSession.EVENT_CONTEXT, null);
contextManager.setState(newContext, session != null? session.getState() : DebuggerSession.STATE_DISPOSED, DebuggerSession.EVENT_CONTEXT, null);
}
public static DebuggerContextImpl createDebuggerContext(@NotNull DebuggerSession session, SuspendContextImpl suspendContext){
@@ -82,7 +82,7 @@ public class DebuggerManagerImpl extends DebuggerManagerEx {
final DebuggerSession session = newContext.getDebuggerSession();
if (event == DebuggerSession.EVENT_PAUSE && myDebuggerStateManager.myDebuggerSession != session) {
// if paused in non-active session; switch current session
myDebuggerStateManager.setState(newContext, session.getState(), event, null);
myDebuggerStateManager.setState(newContext, session != null? session.getState() : DebuggerSession.STATE_DISPOSED, event, null);
return;
}
@@ -145,7 +145,8 @@ public class DebuggerSession implements AbstractDebuggerSession {
*/
public void setState(final DebuggerContextImpl context, final int state, final int event, final String description) {
ApplicationManager.getApplication().assertIsDispatchThread();
LOG.assertTrue(context.getDebuggerSession() == DebuggerSession.this || context.getDebuggerSession() == null);
final DebuggerSession session = context.getDebuggerSession();
LOG.assertTrue(session == DebuggerSession.this || session == null);
final Runnable setStateRunnable = new Runnable() {
public void run() {
LOG.assertTrue(myDebuggerContext.isInitialised());
@@ -28,6 +28,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.sun.jdi.*;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -172,18 +173,23 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxy {
}
}
@Nullable
public ObjectReference thisObject() throws EvaluateException {
DebuggerManagerThreadImpl.assertIsManagerThread();
checkValid();
try {
if(myThisReference == null) {
myThisReference = getStackFrame().thisObject();
for (int attempt = 0; attempt < 2; attempt++) {
try {
if(myThisReference == null) {
myThisReference = getStackFrame().thisObject();
}
break;
}
catch (InvalidStackFrameException e) {
clearCaches();
}
}
}
catch (InvalidStackFrameException e) {
clearCaches();
return thisObject();
}
catch (InternalException e) {
// supress some internal errors caused by bugs in specific JDI implementations
if(e.errorCode() != 23) {
@@ -121,7 +121,10 @@ public abstract class EvaluationDialog extends DialogWrapper {
}
getEditor().addRecent(getCodeToEvaluate());
myEvaluationPanel.getContextManager().getContext().getDebuggerSession().refresh(true);
final DebuggerSession session = myEvaluationPanel.getContextManager().getContext().getDebuggerSession();
if (session != null) {
session.refresh(true);
}
}
@Nullable
@@ -224,7 +224,8 @@ public class FramesPanel extends UpdatableDebuggerView {
private void doRebuild(boolean refreshOnly) {
final DebuggerContextImpl context = getContext();
final boolean paused = context.getDebuggerSession().isPaused();
final DebuggerSession session = context.getDebuggerSession();
final boolean paused = session != null && session.isPaused();
if (!paused || !refreshOnly) {
myThreadsCombo.removeAllItems();
synchronized (myFramesList) {
@@ -415,7 +415,7 @@ public class FrameVariablesTree extends DebuggerTree {
private void autoscrollToNewLocals(DebuggerTreeNodeImpl frameNode) {
final DebuggerSession debuggerSession = debuggerContext.getDebuggerSession();
final boolean isSteppingThrough = debuggerSession.isSteppingThrough(debuggerContext.getThreadProxy());
final boolean isSteppingThrough = debuggerSession != null && debuggerSession.isSteppingThrough(debuggerContext.getThreadProxy());
final List<DebuggerTreeNodeImpl> toClear = new ArrayList<DebuggerTreeNodeImpl>();
final List<DebuggerTreeNodeImpl> newLocalsToSelect = new ArrayList<DebuggerTreeNodeImpl>();
@@ -36,12 +36,15 @@ public class InspectDialog extends DialogWrapper implements DebuggerContextListe
myDebuggerContext = stateManager.getContext();
myInspectView = new InspectPanel(project, myDebuggerContext.getDebuggerSession().getContextManager(), inspectDescriptor);
final DebuggerSession session = myDebuggerContext.getDebuggerSession();
assert session != null;
myInspectView = new InspectPanel(project, session.getContextManager(), inspectDescriptor);
myInspectView.setBorder(BorderFactory.createEtchedBorder());
init();
myDebuggerContext.getDebuggerSession().getContextManager().addListener(this);
session.getContextManager().addListener(this);
getInspectView().rebuildIfVisible(DebuggerSession.EVENT_CONTEXT);
}
@@ -54,7 +57,10 @@ public class InspectDialog extends DialogWrapper implements DebuggerContextListe
}
public void dispose() {
myDebuggerContext.getDebuggerSession().getContextManager().removeListener(this);
final DebuggerSession session = myDebuggerContext.getDebuggerSession();
if (session != null) {
session.getContextManager().removeListener(this);
}
if (myInspectView != null) {
myInspectView.dispose();
myInspectView = null;
@@ -15,6 +15,7 @@
*/
package com.intellij.debugger.ui.impl;
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.DebuggerInvocationUtil;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.SuspendContextImpl;
@@ -72,16 +73,16 @@ public class ThreadsDebuggerTree extends DebuggerTree {
}
protected void build(DebuggerContextImpl context) {
DebuggerSession debuggerSession = context.getDebuggerSession();
final RefreshThreadsTreeCommand command = new RefreshThreadsTreeCommand(debuggerSession);
DebuggerSession session = context.getDebuggerSession();
final RefreshThreadsTreeCommand command = new RefreshThreadsTreeCommand(session);
final int state = debuggerSession.getState();
final int state = session != null? session.getState() : DebuggerSession.STATE_DISPOSED;
if (ApplicationManager.getApplication().isUnitTestMode() || state == DebuggerSession.STATE_PAUSED || state == DebuggerSession.STATE_RUNNING) {
showMessage(MessageDescriptor.EVALUATING);
context.getDebugProcess().getManagerThread().schedule(command);
}
else {
showMessage(debuggerSession.getStateDescription());
showMessage(session != null? session.getStateDescription() : DebuggerBundle.message("status.debug.stopped"));
}
}
@@ -122,7 +122,7 @@ public class ThreadsPanel extends DebuggerTreePanel{
private void reschedule() {
final DebuggerSession session = getContext().getDebuggerSession();
if (session.isAttached() && !session.isPaused()) {
if (session != null && session.isAttached() && !session.isPaused()) {
myUpdateLabelsAlarm.addRequest(this, LABELS_UPDATE_DELAY_MS, ModalityState.NON_MODAL);
}
}
@@ -316,14 +316,14 @@ public abstract class DebuggerTree extends DebuggerTreeBase implements DataProvi
protected abstract void build(DebuggerContextImpl context);
protected final void buildWhenPaused(DebuggerContextImpl context, RefreshDebuggerTreeCommand command) {
DebuggerSession debuggerSession = context.getDebuggerSession();
DebuggerSession session = context.getDebuggerSession();
if (ApplicationManager.getApplication().isUnitTestMode() || debuggerSession.getState() == DebuggerSession.STATE_PAUSED) {
if (ApplicationManager.getApplication().isUnitTestMode() || (session != null && session.getState() == DebuggerSession.STATE_PAUSED)) {
showMessage(MessageDescriptor.EVALUATING);
context.getDebugProcess().getManagerThread().schedule(command);
}
else {
showMessage(context.getDebuggerSession().getStateDescription());
showMessage(session != null? session.getStateDescription() : DebuggerBundle.message("status.debug.stopped"));
}
}
@@ -115,8 +115,13 @@ public abstract class DebuggerUtils {
if (toStringMethod == null) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.evaluate.tostring", objRef.referenceType().name()));
}
final StringReference stringReference = (StringReference)debugProcess.invokeInstanceMethod(evaluationContext, objRef, toStringMethod, Collections.emptyList(), 0);
return stringReference == null ? "null" : stringReference.value();
// while result must be of com.sun.jdi.StringReference type, it turns out that sometimes (jvm bugs?)
// it is a plain com.sun.tools.jdi.ObjectReferenceImpl
final Value result = debugProcess.invokeInstanceMethod(evaluationContext, objRef, toStringMethod, Collections.emptyList(), 0);
if (result == null) {
return "null";
}
return result instanceof StringReference ? ((StringReference)result).value() : result.toString();
}
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.unsupported.expression.type"));
}
@@ -29,7 +29,6 @@ import com.intellij.openapi.roots.IdeaModifiableModelsProvider;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory;
import com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -99,9 +98,7 @@ public class AddFrameworkSupportInProjectStructureAction extends DumbAwareAction
final Module module = getSelectedModule();
if (module == null) return;
final VirtualFile baseDir = module.getProject().getBaseDir();
final String path = baseDir != null ? baseDir.getPath() : "";
final LibrariesContainer librariesContainer = LibrariesContainerFactory.createContainer(myModuleStructureConfigurable.getContext());
new AddSupportForSingleFrameworkDialog(module, path, myFrameworkType, myProvider, librariesContainer, new IdeaModifiableModelsProvider()).show();
new AddSupportForSingleFrameworkDialog(module, myFrameworkType, myProvider, librariesContainer, new IdeaModifiableModelsProvider()).show();
}
}
@@ -16,28 +16,29 @@
package com.intellij.framework.addSupport.impl;
import com.intellij.CommonBundle;
import com.intellij.facet.impl.DefaultFacetsProvider;
import com.intellij.facet.impl.ui.libraries.LibraryCompositionSettings;
import com.intellij.framework.FrameworkTypeEx;
import com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable;
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportModelImpl;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportUtil;
import com.intellij.ide.util.newProjectWizard.FrameworkSupportOptionsComponent;
import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.roots.LibraryOrderEntry;
import com.intellij.openapi.roots.ModifiableModelsProvider;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.OrderEntry;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription;
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryPresentationManager;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -56,22 +57,35 @@ public class AddSupportForSingleFrameworkDialog extends DialogWrapper {
private final ModifiableModelsProvider myModifiableModelsProvider;
public AddSupportForSingleFrameworkDialog(@NotNull Module module,
final @NotNull String contentRootPath,
FrameworkTypeEx frameworkType, @NotNull FrameworkSupportInModuleProvider provider,
@NotNull LibrariesContainer librariesContainer,
ModifiableModelsProvider modifiableModelsProvider) {
super(module.getProject(), true);
VirtualFile[] roots = ModuleRootManager.getInstance(module).getContentRoots();
final VirtualFile baseDir = roots.length > 0 ? roots[0] : module.getProject().getBaseDir();
final String baseDirectoryForLibraries = baseDir != null ? baseDir.getPath() : "";
myFrameworkType = frameworkType;
myModifiableModelsProvider = modifiableModelsProvider;
setTitle(ProjectBundle.message("dialog.title.add.framework.0.support", frameworkType.getPresentableName()));
myModule = module;
myModel = new FrameworkSupportModelImpl(module.getProject(), contentRootPath, librariesContainer);
myModel = new FrameworkSupportModelImpl(module.getProject(), baseDirectoryForLibraries, librariesContainer);
myConfigurable = provider.createConfigurable(myModel);
myComponent = new FrameworkSupportOptionsComponent(myModel, myModel.getLibrariesContainer(), myDisposable, myConfigurable, null);
Disposer.register(myDisposable, myConfigurable);
init();
}
public static AddSupportForSingleFrameworkDialog createDialog(@NotNull Module module,
@NotNull FrameworkSupportInModuleProvider provider) {
List<FrameworkSupportInModuleProvider> providers = FrameworkSupportUtil.getProviders(module, DefaultFacetsProvider.INSTANCE);
if (providers.isEmpty()) return null;
IdeaModifiableModelsProvider modifiableModelsProvider = new IdeaModifiableModelsProvider();
LibrariesContainer container = LibrariesContainerFactory.createContainer(modifiableModelsProvider.getModuleModifiableModel(module));
return new AddSupportForSingleFrameworkDialog(module, provider.getFrameworkType(), provider, container, modifiableModelsProvider);
}
protected void doOKAction() {
final LibraryCompositionSettings librarySettings = myComponent.getLibraryCompositionSettings();
if (librarySettings != null) {
@@ -83,7 +97,12 @@ public class AddSupportForSingleFrameworkDialog extends DialogWrapper {
}
return;
}
myModifiableModelsProvider.commitModuleModifiableModel(modifiableModel);
new WriteAction() {
protected void run(final Result result) {
myModifiableModelsProvider.commitModuleModifiableModel(modifiableModel);
}
}.execute();
final boolean downloaded = librarySettings.downloadFiles(getRootPane());
if (!downloaded) {
@@ -24,25 +24,21 @@ import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.ui.popup.ListItemDescriptor;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.platform.ProjectTemplate;
import com.intellij.platform.templates.RemoteTemplatesFactory;
import com.intellij.psi.codeStyle.MinusculeMatcher;
import com.intellij.psi.codeStyle.NameUtil;
import com.intellij.ui.CollectionListModel;
import com.intellij.ui.DocumentAdapter;
import com.intellij.ui.SearchTextField;
import com.intellij.ui.ListSpeedSearch;
import com.intellij.ui.SpeedSearchComparator;
import com.intellij.ui.components.JBList;
import com.intellij.ui.popup.list.GroupedItemsListRenderer;
import com.intellij.ui.speedSearch.FilteringListModel;
import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
@@ -56,17 +52,21 @@ import java.util.List;
public class ProjectTypesList implements Disposable {
private final JBList myList;
private final SearchTextField mySearchField;
private final FilteringListModel<TemplateItem> myFilteringListModel;
private final CollectionListModel<TemplateItem> myModel;
private MinusculeMatcher myMatcher;
private Pair<TemplateItem, Integer> myBestMatch;
private TemplateItem myLoadingItem;
public ProjectTypesList(JBList list, SearchTextField searchField, MultiMap<TemplatesGroup, ProjectTemplate> map, final WizardContext context) {
public ProjectTypesList(JBList list, MultiMap<TemplatesGroup, ProjectTemplate> map, final WizardContext context) {
myList = list;
mySearchField = searchField;
new ListSpeedSearch(myList) {
@Override
protected String getElementText(Object element) {
return super.getElementText(element);
}
}.setComparator(new SpeedSearchComparator(false));
List<TemplateItem> items = buildItems(map);
final RemoteTemplatesFactory factory = new RemoteTemplatesFactory();
final TemplatesGroup samplesGroup = new TemplatesGroup("Loading Templates...", "", null, 0);
@@ -82,8 +82,7 @@ public class ProjectTypesList implements Disposable {
}
};
items.add(myLoadingItem);
final CollectionListModel<TemplateItem> model = new CollectionListModel<TemplateItem>(items);
myFilteringListModel = new FilteringListModel<TemplateItem>(model);
myModel = new CollectionListModel<TemplateItem>(items);
ProgressManager.getInstance().run(new Task.Backgroundable(context.getProject(), "Loading Templates") {
@Override
@@ -103,8 +102,8 @@ public class ProjectTypesList implements Disposable {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
int index = myList.getSelectedIndex();
model.remove(myLoadingItem);
model.add(items);
myModel.remove(myLoadingItem);
myModel.add(items);
myList.setSelectedIndex(index);
}
});
@@ -137,8 +136,8 @@ public class ProjectTypesList implements Disposable {
@Override
public boolean hasSeparatorAboveOf(Object value) {
TemplateItem item = (TemplateItem)value;
int index = myFilteringListModel.getElementIndex(item);
return index == 0 || !myFilteringListModel.getElementAt(index -1).getGroupName().equals(item.getGroupName());
int index = myModel.getElementIndex(item);
return index == 0 || !myModel.getElementAt(index - 1).getGroupName().equals(item.getGroupName());
}
@Nullable
@@ -148,31 +147,10 @@ public class ProjectTypesList implements Disposable {
}
}));
myFilteringListModel.setFilter(new Condition<TemplateItem>() {
@Override
public boolean value(TemplateItem item) {
return item.getMatchingDegree() > Integer.MIN_VALUE;
}
});
myList.setModel(myFilteringListModel);
mySearchField.addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
String text = "*" + mySearchField.getText().trim();
myMatcher = NameUtil.buildMatcher(text, NameUtil.MatchingCaseSensitivity.NONE);
TemplateItem value = (TemplateItem)myList.getSelectedValue();
int degree = value == null ? Integer.MIN_VALUE : value.getMatchingDegree();
myBestMatch = Pair.create(degree > Integer.MIN_VALUE ? value : null, degree);
myFilteringListModel.refilter();
if (myBestMatch.first != null) {
myList.setSelectedValue(myBestMatch.first, true);
}
}
});
myList.setModel(myModel);
}
void installKeyAction(JComponent component) {
new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
@@ -194,7 +172,7 @@ public class ProjectTypesList implements Disposable {
}
}
}
}.registerCustomShortcutSet(new CustomShortcutSet(KeyEvent.VK_UP, KeyEvent.VK_DOWN), mySearchField);
}.registerCustomShortcutSet(new CustomShortcutSet(KeyEvent.VK_UP, KeyEvent.VK_DOWN), component);
}
void resetSelection() {
@@ -288,5 +266,10 @@ public class ProjectTypesList implements Disposable {
String getDescription() {
return myTemplate.getDescription();
}
@Override
public String toString() {
return getName() + " " + getGroupName();
}
}
}
@@ -36,7 +36,7 @@
<properties>
<contentType value="text/html"/>
<editable value="false"/>
<text value="&lt;html&gt;&#13;&#10; &lt;head&gt;&#13;&#10;&#13;&#10; &lt;/head&gt;&#13;&#10; &lt;body&gt;&#13;&#10; &lt;p style=&quot;margin-top: 0&quot;&gt;&#13;&#10; &#13;&#10; &lt;/p&gt;&#13;&#10; &lt;/body&gt;&#13;&#10;&lt;/html&gt;&#13;&#10;"/>
<text value="&lt;html&gt;&#13;&#10; &lt;head&gt;&#13;&#10; &#13;&#10; &lt;/head&gt;&#13;&#10; &lt;body&gt;&#13;&#10; &lt;/body&gt;&#13;&#10;&lt;/html&gt;&#13;&#10;"/>
</properties>
</component>
</children>
@@ -135,8 +135,8 @@
</vspacer>
</children>
</grid>
<grid id="90483" binding="myLeftPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<grid id="90483" binding="myLeftPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="5" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="200" height="-1"/>
@@ -146,15 +146,9 @@
<properties/>
<border type="none"/>
<children>
<component id="3580d" class="com.intellij.ui.SearchTextField" binding="mySearchField" custom-create="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<scrollpane id="474de" class="com.intellij.ui.components.JBScrollPane">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -38,7 +38,10 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.platform.ProjectTemplate;
import com.intellij.platform.templates.TemplateModuleBuilder;
import com.intellij.projectImport.ProjectFormatPanel;
import com.intellij.ui.*;
import com.intellij.ui.DocumentAdapter;
import com.intellij.ui.HideableDecorator;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.JBSplitter;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBList;
import com.intellij.util.containers.MultiMap;
@@ -61,7 +64,6 @@ public class SelectTemplateStep extends ModuleWizardStep implements SettingsStep
private JBList myTemplatesList;
private JPanel mySettingsPanel;
private SearchTextField mySearchField;
private JTextPane myDescriptionPane;
private JPanel myDescriptionPanel;
@@ -121,7 +123,8 @@ public class SelectTemplateStep extends ModuleWizardStep implements SettingsStep
myExpertPanel.setBorder(IdeBorderFactory.createEmptyBorder(0, IdeBorderFactory.TITLED_BORDER_INDENT, 5, 0));
myExpertDecorator.setContentComponent(myExpertPanel);
myList = new ProjectTypesList(myTemplatesList, mySearchField, map, context);
myList = new ProjectTypesList(myTemplatesList, map, context);
myList.installKeyAction(getNameComponent());
myTemplatesList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@@ -147,6 +150,10 @@ public class SelectTemplateStep extends ModuleWizardStep implements SettingsStep
mySplitter.setSecondComponent(myRightPanel);
}
private JTextField getNameComponent() {
return myWizardContext.isCreatingNewProject() ? myNamePathComponent.getNameComponent() : myModuleName;
}
private void addProjectFormat(JPanel panel) {
addField("Project \u001bformat:", myFormatPanel.getStorageFormatComboBox(), panel);
}
@@ -190,8 +197,8 @@ public class SelectTemplateStep extends ModuleWizardStep implements SettingsStep
if (template != null) {
description = template.getDescription();
if (StringUtil.isNotEmpty(description)) {
StringBuilder sb = new StringBuilder("<html><body><font face=\"Verdana\" ");
sb.append(SystemInfo.isMac ? "" : "size=\"-1\"").append('>');
StringBuilder sb = new StringBuilder("<html><body><font ");
sb.append(SystemInfo.isMac ? "" : "face=\"Verdana\" size=\"-1\"").append('>');
sb.append(description).append("</font></body></html>");
description = sb.toString();
myDescriptionPane.setText(description);
@@ -268,7 +275,7 @@ public class SelectTemplateStep extends ModuleWizardStep implements SettingsStep
@Override
public JComponent getPreferredFocusedComponent() {
return mySearchField;
return getNameComponent();
}
@Override
@@ -300,10 +307,6 @@ public class SelectTemplateStep extends ModuleWizardStep implements SettingsStep
return "Template Type";
}
private void createUIComponents() {
mySearchField = new SearchTextField(false);
}
@Override
public WizardContext getContext() {
return myWizardContext;
@@ -707,7 +707,10 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
}
}
else {
myHolder.add(HighlightNamesUtil.highlightMethodName(method, element, false, colorsScheme));
final PsiElement referenceNameElement = element.getReferenceNameElement();
if(referenceNameElement != null) {
myHolder.add(HighlightNamesUtil.highlightMethodName(method, referenceNameElement, false, colorsScheme));
}
}
}
catch (IndexNotReadyException ignored) {
@@ -163,7 +163,7 @@ public abstract class CreateFromUsageBaseFix extends BaseIntentionAction {
}
protected void setupVisibility(PsiClass parentClass, PsiClass targetClass, PsiModifierList list) throws IncorrectOperationException {
if (targetClass.isInterface()) {
if (targetClass.isInterface() && list.getFirstChild() != null) {
list.deleteChildRange(list.getFirstChild(), list.getLastChild());
return;
}
@@ -35,14 +35,9 @@ import com.intellij.util.containers.Stack;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import static com.intellij.psi.CommonClassNames.JAVA_LANG_ERROR;
import static com.intellij.psi.CommonClassNames.JAVA_LANG_RUNTIME_EXCEPTION;
import static com.intellij.psi.CommonClassNames.JAVA_LANG_THROWABLE;
import static com.intellij.psi.CommonClassNames.*;
class ControlFlowAnalyzer extends JavaElementVisitor {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.dataFlow.ControlFlowAnalyzer");
@@ -91,7 +86,9 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
pass2Flow.setFields(myFields.toArray(new DfaVariableValue[myFields.size()]));
LOG.assertTrue(myPass1Flow.getInstructionCount() == pass2Flow.getInstructionCount());
if (myPass1Flow.getInstructionCount() != pass2Flow.getInstructionCount()) {
LOG.error(Arrays.toString(myPass1Flow.getInstructions()) + "!=\n" + Arrays.toString(pass2Flow.getInstructions()));
}
addInstruction(new ReturnInstruction());
@@ -18,8 +18,6 @@ package com.intellij.openapi.options.colors.pages;
import com.intellij.application.options.colors.InspectionColorSettingsPage;
import com.intellij.ide.highlighter.JavaFileHighlighter;
import com.intellij.ide.highlighter.JavaHighlightingColors;
import com.intellij.openapi.editor.HighlighterColors;
import com.intellij.openapi.editor.SyntaxHighlighterColors;
import com.intellij.openapi.editor.colors.CodeInsightColors;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.fileTypes.StdFileTypes;
@@ -181,7 +179,7 @@ public class JavaColorSettingsPage implements ColorSettingsPage, InspectionColor
" int <localVar>a</localVar> = <implicitAnonymousParameter>localVar</implicitAnonymousParameter>;\n" +
" }\n" +
" };\n" +
" <reassignedParameter>reassignedParam</reassignedParameter> = new int[2];\n" +
" <reassignedParameter>reassignedParam</reassignedParameter> = new <constructorCall>ArrayList</constructorCall><<class>String</class>>().toArray(new int[0]);\n" +
" }\n" +
"}\n" +
"enum <enum>AnEnum</enum> { <static_final>CONST1</static_final>, <static_final>CONST2</static_final> }\n"+
@@ -33,9 +33,11 @@ import org.jetbrains.annotations.Nullable;
public class PsiClassConverter extends Converter<PsiClass> implements CustomReferenceConverter<PsiClass> {
public PsiClass fromString(final String s, final ConvertContext context) {
if (StringUtil.isEmptyOrSpaces(s)) return null;
final DomElement element = context.getInvocationElement();
final GlobalSearchScope scope = element instanceof GenericDomValue ? getScope(context) : null;
return DomJavaUtil.findClass(s, context.getFile(), context.getModule(), scope);
return DomJavaUtil.findClass(s.trim(), context.getFile(), context.getModule(), scope);
}
@Nullable
@@ -32,11 +32,9 @@ import com.intellij.psi.impl.PsiManagerEx;
import com.intellij.psi.impl.file.PsiPackageImpl;
import com.intellij.psi.impl.java.stubs.index.JavaFullClassNameIndex;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.Query;
import com.intellij.util.containers.ConcurrentHashMap;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.indexing.FileBasedIndex;
import com.intellij.util.messages.MessageBus;
import com.intellij.util.messages.MessageBusConnection;
import org.jetbrains.annotations.NonNls;
@@ -130,15 +128,13 @@ public abstract class JavaFileManagerBase implements JavaFileManager, Disposable
@Override
public PsiClass[] findClasses(@NotNull String qName, @NotNull final GlobalSearchScope scope) {
final Collection<? extends PsiElement> classes = JavaFullClassNameIndex.getInstance().get(qName.hashCode(), myManager.getProject(), scope);
final Collection<PsiClass> classes = JavaFullClassNameIndex.getInstance().get(qName.hashCode(), myManager.getProject(), scope);
if (classes.isEmpty()) return PsiClass.EMPTY_ARRAY;
List<PsiClass> result = new ArrayList<PsiClass>(classes.size());
int count = 0;
PsiClass aClass = null;
for (PsiElement found : classes) {
if (notClass(found)) continue;
aClass = (PsiClass)found;
for (PsiClass found : classes) {
aClass = found;
final String qualifiedName = aClass.getQualifiedName();
if (qualifiedName == null || !qualifiedName.equals(qName)) continue;
@@ -277,12 +273,9 @@ public abstract class JavaFileManagerBase implements JavaFileManager, Disposable
private PsiClass findClassInIndex(String qName, GlobalSearchScope scope) {
VirtualFile bestFile = null;
PsiClass bestClass = null;
final Collection<? extends PsiElement> classes = JavaFullClassNameIndex.getInstance().get(qName.hashCode(), myManager.getProject(), scope);
final Collection<PsiClass> classes = JavaFullClassNameIndex.getInstance().get(qName.hashCode(), myManager.getProject(), scope);
for (PsiElement found : classes) {
if (notClass(found)) continue;
PsiClass aClass = (PsiClass)found;
for (PsiClass aClass : classes) {
PsiFile file = aClass.getContainingFile();
if (file == null) {
LOG.error("aClass=" + aClass);
@@ -346,18 +339,6 @@ public abstract class JavaFileManagerBase implements JavaFileManager, Disposable
return myNontrivialPackagePrefixes;
}
private static boolean notClass(final PsiElement found) {
if (found instanceof PsiClass) return false;
VirtualFile faultyContainer = PsiUtilCore.getVirtualFile(found);
LOG.error("Non class in class list: " + faultyContainer + ". found: " + found);
if (faultyContainer != null && faultyContainer.isValid()) {
FileBasedIndex.getInstance().requestReindex(faultyContainer);
}
return true;
}
@Nullable
private static PsiClass findClassByName(PsiJavaFile scope, String name) {
PsiClass[] classes = scope.getClasses();
@@ -24,7 +24,9 @@ import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.impl.search.JavaSourceFilterScope;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.stubs.StringStubIndexExtension;
import com.intellij.psi.stubs.StubIndex;
import com.intellij.psi.stubs.StubIndexKey;
import com.intellij.psi.stubs.StubProcessingHelperBase;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
@@ -44,6 +46,6 @@ public class JavaAnnotationIndex extends StringStubIndexExtension<PsiAnnotation>
@Override
public Collection<PsiAnnotation> get(final String s, final Project project, @NotNull final GlobalSearchScope scope) {
return super.get(s, project, new JavaSourceFilterScope(scope));
return StubIndex.getInstance().safeGet(getKey(), s, project, new JavaSourceFilterScope(scope), PsiAnnotation.class);
}
}
@@ -24,6 +24,7 @@ import com.intellij.psi.PsiClass;
import com.intellij.psi.impl.search.JavaSourceFilterScope;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.stubs.IntStubIndexExtension;
import com.intellij.psi.stubs.StubIndex;
import com.intellij.psi.stubs.StubIndexKey;
import org.jetbrains.annotations.NotNull;
@@ -44,6 +45,6 @@ public class JavaFullClassNameIndex extends IntStubIndexExtension<PsiClass> {
@Override
public Collection<PsiClass> get(final Integer integer, final Project project, @NotNull final GlobalSearchScope scope) {
return super.get(integer, project, new JavaSourceFilterScope(scope));
return StubIndex.getInstance().safeGet(getKey(), integer, project, new JavaSourceFilterScope(scope), PsiClass.class);
}
}
@@ -3,7 +3,6 @@ package com.intellij.psi.impl.search;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiManagerImpl;
import com.intellij.psi.impl.java.stubs.index.JavaAnnotationIndex;
@@ -11,13 +10,12 @@ import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.LocalSearchScope;
import com.intellij.psi.search.SearchScope;
import com.intellij.psi.search.searches.AnnotatedElementsSearch;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.Processor;
import com.intellij.util.QueryExecutor;
import com.intellij.util.indexing.FileBasedIndex;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -43,46 +41,32 @@ public class AnnotatedElementsSearcher implements QueryExecutor<PsiModifierListO
final PsiManagerImpl psiManager = (PsiManagerImpl)annClass.getManager();
final SearchScope useScope = p.getScope();
Class<? extends PsiModifierListOwner>[] types = p.getTypes();
final Class<? extends PsiModifierListOwner>[] types = p.getTypes();
for (PsiElement elt : getAnnotationCandidates(annClass, useScope)) {
if (notAnnotation(elt)) continue;
final PsiAnnotation ann = (PsiAnnotation)elt;
final PsiJavaCodeReferenceElement ref = ApplicationManager.getApplication().runReadAction(new Computable<PsiJavaCodeReferenceElement>() {
for (final PsiAnnotation ann : getAnnotationCandidates(annClass, useScope)) {
final PsiModifierListOwner candidate = ApplicationManager.getApplication().runReadAction(new Computable<PsiModifierListOwner>() {
@Override
public PsiJavaCodeReferenceElement compute() {
return ann.getNameReferenceElement();
public PsiModifierListOwner compute() {
PsiElement parent = ann.getParent();
if (!(parent instanceof PsiModifierList)) {
return null; // Can be a PsiNameValuePair, if annotation is used to annotate annotation parameters
}
final PsiElement owner = parent.getParent();
if (!isInstanceof(owner, types)) {
return null;
}
final PsiJavaCodeReferenceElement ref = ann.getNameReferenceElement();
if (ref == null || !psiManager.areElementsEquivalent(ref.resolve(), annClass)) {
return null;
}
return (PsiModifierListOwner)owner;
}
});
if (ref == null) continue;
PsiElement parent = ann.getParent();
if (!(parent instanceof PsiModifierList)) continue; // Can be a PsiNameValuePair, if annotation is used to annotate annotation parameters
final PsiElement owner = parent.getParent();
if (!isInstanceof(owner, types)) continue;
final PsiModifierListOwner candidate = (PsiModifierListOwner)owner;
if (!ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
if (!candidate.isValid()) {
return false;
}
if (!psiManager.areElementsEquivalent(ref.resolve(), annClass)) {
return false;
}
return !(useScope instanceof GlobalSearchScope) ||
((GlobalSearchScope)useScope).contains(candidate.getContainingFile().getVirtualFile());
}
})) {
continue;
}
if (!consumer.process(candidate)) {
if (candidate != null && !consumer.process(candidate)) {
return false;
}
}
@@ -90,23 +74,17 @@ public class AnnotatedElementsSearcher implements QueryExecutor<PsiModifierListO
return true;
}
private static Collection<? extends PsiElement> getAnnotationCandidates(final PsiClass annClass, final SearchScope useScope) {
return ApplicationManager.getApplication().runReadAction(new Computable<Collection<? extends PsiElement>>() {
private static Collection<PsiAnnotation> getAnnotationCandidates(final PsiClass annClass, final SearchScope useScope) {
return ApplicationManager.getApplication().runReadAction(new Computable<Collection<PsiAnnotation>>() {
@Override
public Collection<? extends PsiElement> compute() {
public Collection<PsiAnnotation> compute() {
if (useScope instanceof GlobalSearchScope) {
return JavaAnnotationIndex.getInstance().get(annClass.getName(), annClass.getProject(), (GlobalSearchScope)useScope);
}
final List<PsiElement> result = new ArrayList<PsiElement>();
final List<PsiAnnotation> result = ContainerUtil.newArrayList();
for (PsiElement element : ((LocalSearchScope)useScope).getScope()) {
element.accept(new PsiRecursiveElementWalkingVisitor() {
@Override
public void visitElement(PsiElement element) {
if (element instanceof PsiAnnotation) {
result.add(element);
}
}
});
result.addAll(PsiTreeUtil.findChildrenOfType(element, PsiAnnotation.class));
}
return result;
}
@@ -120,15 +98,4 @@ public class AnnotatedElementsSearcher implements QueryExecutor<PsiModifierListO
return false;
}
private static boolean notAnnotation(final PsiElement found) {
if (found instanceof PsiAnnotation) return false;
VirtualFile faultyContainer = PsiUtilCore.getVirtualFile(found);
LOG.error("Non annotation in annotations list: " + faultyContainer+"; element:"+found);
if (faultyContainer != null && faultyContainer.isValid()) {
FileBasedIndex.getInstance().requestReindex(faultyContainer);
}
return true;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -32,29 +32,27 @@ import java.util.List;
*/
public class PsiClassReferenceType extends PsiClassType {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiClassReferenceType");
private final PsiJavaCodeReferenceElement myReference;
public PsiClassReferenceType(@NotNull PsiJavaCodeReferenceElement reference, LanguageLevel languageLevel) {
super(languageLevel, extractAnnosFromReference(reference));
public PsiClassReferenceType(@NotNull PsiJavaCodeReferenceElement reference, LanguageLevel langLevel) {
this(reference, langLevel, collectAnnotations(reference));
}
public PsiClassReferenceType(@NotNull PsiJavaCodeReferenceElement reference, LanguageLevel langLevel, @NotNull PsiAnnotation[] annotations) {
super(langLevel, annotations);
myReference = reference;
}
private static PsiAnnotation[] extractAnnosFromReference(PsiJavaCodeReferenceElement reference) {
private static PsiAnnotation[] collectAnnotations(PsiJavaCodeReferenceElement reference) {
List<PsiAnnotation> result = null;
for(PsiElement child = reference.getFirstChild(); child != null; child = child.getNextSibling()){
for (PsiElement child = reference.getFirstChild(); child != null; child = child.getNextSibling()) {
if (child instanceof PsiAnnotation) {
if (result == null) result = new SmartList<PsiAnnotation>();
result.add((PsiAnnotation)child);
}
}
if (result == null) return PsiAnnotation.EMPTY_ARRAY;
return result.toArray(new PsiAnnotation[result.size()]);
}
public PsiClassReferenceType(@NotNull PsiJavaCodeReferenceElement reference, LanguageLevel languageLevel, PsiAnnotation[] annotations) {
super(languageLevel,annotations);
myReference = reference;
return result == null ? PsiAnnotation.EMPTY_ARRAY : result.toArray(new PsiAnnotation[result.size()]);
}
@Override
@@ -84,7 +82,7 @@ public class PsiClassReferenceType extends PsiClassType {
@Override
public PsiClassType setLanguageLevel(@NotNull final LanguageLevel languageLevel) {
if (languageLevel.equals(myLanguageLevel)) return this;
return new PsiClassReferenceType(myReference,languageLevel,getAnnotations());
return new PsiClassReferenceType(myReference, languageLevel, getAnnotations());
}
@Override
@@ -158,9 +156,9 @@ public class PsiClassReferenceType extends PsiClassType {
}
String qualifiedName = myReference.getQualifiedName();
String name = myReference.getReferenceName();
if (name==null) name="";
if (name == null) name = "";
LightClassReference reference = new LightClassReference(myReference.getManager(), name, qualifiedName, myReference.getResolveScope());
return new PsiClassReferenceType(reference, null,getAnnotations());
return new PsiClassReferenceType(reference, null, getAnnotations());
}
@Override
@@ -175,9 +173,9 @@ public class PsiClassReferenceType extends PsiClassType {
}
public PsiClassType createImmediateCopy() {
final ClassResolveResult resolveResult = resolveGenerics();
if (resolveResult.getElement() == null) return this;
return new PsiImmediateClassType(resolveResult.getElement(), resolveResult.getSubstitutor());
ClassResolveResult resolveResult = resolveGenerics();
PsiClass element = resolveResult.getElement();
return element != null ? new PsiImmediateClassType(element, resolveResult.getSubstitutor()) : this;
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -21,35 +21,15 @@ import org.jetbrains.annotations.NonNls;
public class LambdaParamsTest extends LightDaemonAnalyzerTestCase {
@NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/params";
public void testFormalParams() throws Exception {
doTest();
}
public void testInferredParams() throws Exception {
doTest();
}
public void testFormalParams() { doTest(); }
public void testInferredParams() { doTest(); }
public void testMethodApplicability() { doTest(); }
public void testIncompatibleTypes() { doTest(); }
public void testRaw() { doTest(); }
public void testFormalParamsWithWildcards() { doTest(); }
public void testInferFromFormal() { doTest(); }
public void testMethodApplicability() throws Exception {
doTest();
}
public void testIncompatibleTypes() throws Exception {
doTest();
}
public void testRaw() throws Exception {
doTest();
}
public void testFormalParamsWithWildcards() throws Exception {
doTest();
}
public void testInferFromFormal() throws Exception {
doTest();
}
private void doTest() throws Exception {
private void doTest() {
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
}
}
@@ -104,7 +104,7 @@ public class BuildRunner {
targetsState = new BuildTargetsState(dataPaths, jpsModel, buildRootIndex);
projectTimestamps = new ProjectTimestamps(dataStorageRoot, targetsState);
dataManager = new BuildDataManager(dataPaths, targetsState, STORE_TEMP_CACHES_IN_MEMORY);
// second attempt succeded
// second attempt succeeded
msgHandler.processMessage(new CompilerMessage("build", BuildMessage.Kind.INFO, "Project rebuild forced: " + e.getMessage()));
}
@@ -61,11 +61,11 @@ final class BuildSession implements Runnable, CanceledStatus {
private final UUID mySessionId;
private final Channel myChannel;
private volatile boolean myCanceled = false;
private String myProjectPath;
private final String myProjectPath;
@Nullable
private CmdlineRemoteProto.Message.ControllerMessage.FSEvent myInitialFSDelta;
// state
private EventsProcessor myEventsProcessor = new EventsProcessor();
private final EventsProcessor myEventsProcessor = new EventsProcessor();
private volatile long myLastEventOrdinal;
private volatile ProjectDescriptor myProjectDescriptor;
private final Map<Pair<String, String>, ConstantSearchFuture> mySearchTasks = Collections.synchronizedMap(new HashMap<Pair<String, String>, ConstantSearchFuture>());
@@ -304,7 +304,8 @@ final class BuildSession implements Runnable, CanceledStatus {
}
}
private void applyFSEvent(ProjectDescriptor pd, @Nullable CmdlineRemoteProto.Message.ControllerMessage.FSEvent event, final boolean saveEventStamp) throws IOException {
private static void applyFSEvent(ProjectDescriptor pd, @Nullable CmdlineRemoteProto.Message.ControllerMessage.FSEvent event,
final boolean saveEventStamp) throws IOException {
if (event == null) {
return;
}
@@ -369,7 +370,7 @@ final class BuildSession implements Runnable, CanceledStatus {
}
}
private void updateFsStateOnDisk(File dataStorageRoot, DataInputStream original, final long ordinal) {
private static void updateFsStateOnDisk(File dataStorageRoot, DataInputStream original, final long ordinal) {
final File file = new File(dataStorageRoot, FS_STATE_FILE);
try {
final BufferExposingByteArrayOutputStream bytes = new BufferExposingByteArrayOutputStream();
@@ -462,8 +463,8 @@ final class BuildSession implements Runnable, CanceledStatus {
}
try {
final File file = new File(dataStorageRoot, FS_STATE_FILE);
final InputStream fs = new FileInputStream(file);
byte[] bytes;
final InputStream fs = new FileInputStream(file);
try {
bytes = FileUtil.loadBytes(fs, (int)file.length());
}
@@ -17,9 +17,11 @@ package org.jetbrains.jps.cmdline;
import org.jetbrains.jps.model.JpsModel;
import java.io.IOException;
/**
* @author nik
*/
public interface JpsModelLoader {
JpsModel loadModel();
JpsModel loadModel() throws IOException;
}
@@ -17,12 +17,10 @@ package org.jetbrains.jps.cmdline;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.ParameterizedRunnable;
import org.jetbrains.jps.model.JpsElementFactory;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.JpsModel;
import org.jetbrains.jps.model.serialization.JpsGlobalLoader;
import org.jetbrains.jps.model.serialization.JpsProjectLoader;
import org.jetbrains.jps.model.serialization.JpsSerializationManager;
import java.io.File;
import java.io.IOException;
import java.util.Map;
@@ -37,7 +35,7 @@ public class JpsModelLoaderImpl implements JpsModelLoader {
private final ParameterizedRunnable<JpsModel> myModelInitializer;
public JpsModelLoaderImpl(String projectPath, String globalOptionsPath, Map<String, String> pathVars,
ParameterizedRunnable<JpsModel> initializer) {
@Nullable ParameterizedRunnable<JpsModel> initializer) {
myProjectPath = projectPath;
myGlobalOptionsPath = globalOptionsPath;
myPathVars = pathVars;
@@ -45,32 +43,16 @@ public class JpsModelLoaderImpl implements JpsModelLoader {
}
@Override
public JpsModel loadModel() {
public JpsModel loadModel() throws IOException {
final long start = System.currentTimeMillis();
try {
final JpsModel model = JpsElementFactory.getInstance().createModel();
try {
if (myGlobalOptionsPath != null) {
JpsGlobalLoader.loadGlobalSettings(model.getGlobal(), myPathVars, myGlobalOptionsPath);
}
JpsProjectLoader.loadProject(model.getProject(), myPathVars, myProjectPath);
if (myModelInitializer != null) {
myModelInitializer.run(model);
}
LOG.info("New JPS model: " + model.getProject().getModules().size() + " modules, " + model.getProject().getLibraryCollection().getLibraries().size() + " libraries");
}
catch (IOException e) {
LOG.info(e);
}
return model;
LOG.info("Loading model: project path = " + myProjectPath + ", global options path = " + myGlobalOptionsPath);
final JpsModel model = JpsSerializationManager.getInstance().loadModel(myProjectPath, myGlobalOptionsPath, myPathVars);
if (myModelInitializer != null) {
myModelInitializer.run(model);
}
finally {
final long loadTime = System.currentTimeMillis() - start;
LOG.info("New JPS model: project " + myProjectPath + " loaded in " + loadTime + " ms");
}
}
private static boolean isDirectoryBased(File projectFile) {
return !(projectFile.isFile() && projectFile.getName().endsWith(".ipr"));
final long loadTime = System.currentTimeMillis() - start;
LOG.info("Model loaded in " + loadTime + " ms");
LOG.info("Project has " + model.getProject().getModules().size() + " modules, " + model.getProject().getLibraryCollection().getLibraries().size() + " libraries");
return model;
}
}
@@ -1,26 +0,0 @@
/*
* Copyright 2000-2012 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 org.jetbrains.jps.model.module;
import java.util.EventListener;
/**
* @author nik
*/
public interface JpsFacetListener extends EventListener {
void facetAdded(JpsFacet facet);
void facetRemoved(JpsFacet facet);
}
@@ -1,24 +0,0 @@
/*
* Copyright 2000-2012 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 org.jetbrains.jps.model.module;
import org.jetbrains.jps.model.JpsElementReference;
/**
* @author nik
*/
public interface JpsFacetReference extends JpsElementReference<JpsFacet> {
}
@@ -1,26 +0,0 @@
/*
* Copyright 2000-2012 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 org.jetbrains.jps.model.module;
import org.jetbrains.jps.model.JpsElement;
/**
* @author nik
*/
//todo[nik] I'm not sure that we really need separate interface for facets in the project model.
//Perhaps facets should be replaced by extensions for module elements
public abstract class JpsFacetType<P extends JpsElement> {
}
@@ -54,13 +54,6 @@ public interface JpsModule extends JpsNamedElement, JpsReferenceableElement<JpsM
void removeSourceRoot(@NotNull String url, @NotNull JpsModuleSourceRootType rootType);
@NotNull
<P extends JpsElement>
JpsFacet addFacet(@NotNull String name, @NotNull JpsFacetType<P> type, @NotNull P properties);
@NotNull
List<JpsFacet> getFacets();
JpsDependenciesList getDependenciesList();
@NotNull
@@ -23,10 +23,10 @@ import org.jetbrains.jps.model.ex.JpsElementChildRoleBase;
* @author nik
*/
public class JpsArtifactRole extends JpsElementChildRoleBase<JpsArtifact> {
public static final JpsArtifactRole INSTANCE = new JpsArtifactRole();
private static final JpsArtifactRole INSTANCE = new JpsArtifactRole();
public static final JpsElementCollectionRole<JpsArtifact> ARTIFACT_COLLECTION_ROLE = JpsElementCollectionRole.create(INSTANCE);
public JpsArtifactRole() {
private JpsArtifactRole() {
super("artifact");
}
}
@@ -29,7 +29,7 @@ import java.util.Map;
* @author nik
*/
public abstract class JpsEventDispatcherBase implements JpsEventDispatcher {
private Map<Class<?>, EventDispatcher<?>> myDispatchers = new HashMap<Class<?>, EventDispatcher<?>>();
private final Map<Class<?>, EventDispatcher<?>> myDispatchers = new HashMap<Class<?>, EventDispatcher<?>>();
@NotNull
@Override
@@ -41,11 +41,11 @@ public class JpsCompilerExcludesImpl implements JpsCompilerExcludes {
addExcludedDirectory(JpsPathUtil.urlToFile(url), recursively);
}
public void addExcludedFile(File file) {
protected void addExcludedFile(File file) {
myFiles.add(file);
}
public void addExcludedDirectory(File dir, boolean recursively) {
protected void addExcludedDirectory(File dir, boolean recursively) {
(recursively ? myRecursivelyExcludedDirectories : myDirectories).add(dir);
}
@@ -36,13 +36,13 @@ public class JpsJavaCompilerConfigurationImpl extends JpsCompositeElementBase<Jp
public static final JpsElementChildRole<JpsJavaCompilerConfiguration> ROLE = JpsElementChildRoleBase.create("compiler configuration");
private boolean myAddNotNullAssertions = true;
private boolean myClearOutputDirectoryOnRebuild = true;
private JpsCompilerExcludes myCompilerExcludes = new JpsCompilerExcludesImpl();
private List<String> myResourcePatterns = new ArrayList<String>();
private List<ProcessorConfigProfile> myAnnotationProcessingProfiles = new ArrayList<ProcessorConfigProfile>();
private ProcessorConfigProfileImpl myDefaultAnnotationProcessingProfile = new ProcessorConfigProfileImpl("Default");
private final JpsCompilerExcludes myCompilerExcludes = new JpsCompilerExcludesImpl();
private final List<String> myResourcePatterns = new ArrayList<String>();
private final List<ProcessorConfigProfile> myAnnotationProcessingProfiles = new ArrayList<ProcessorConfigProfile>();
private final ProcessorConfigProfileImpl myDefaultAnnotationProcessingProfile = new ProcessorConfigProfileImpl("Default");
private String myProjectByteCodeTargetLevel;
private Map<String, String> myModulesByteCodeTargetLevels = new HashMap<String, String>();
private Map<String, JpsJavaCompilerOptions> myCompilerOptions = new HashMap<String, JpsJavaCompilerOptions>();
private final Map<String, String> myModulesByteCodeTargetLevels = new HashMap<String, String>();
private final Map<String, JpsJavaCompilerOptions> myCompilerOptions = new HashMap<String, JpsJavaCompilerOptions>();
private String myJavaCompilerId = "Javac";
private Map<JpsModule, ProcessorConfigProfile> myAnnotationProcessingProfileMap;
private ResourcePatterns myCompiledPatterns;
@@ -160,7 +160,7 @@ public class ResourcePatterns {
return wildcardPattern;
}
public static boolean isPatternNegated(String wildcardPattern) {
private static boolean isPatternNegated(String wildcardPattern) {
return wildcardPattern.length() > 1 && wildcardPattern.charAt(0) == '!';
}
@@ -26,7 +26,7 @@ import org.jetbrains.jps.model.library.JpsLibraryListener;
* @author nik
*/
public class JpsLibraryRole extends JpsElementChildRoleBase<JpsLibrary> {
public static final JpsLibraryRole INSTANCE = new JpsLibraryRole();
private static final JpsLibraryRole INSTANCE = new JpsLibraryRole();
public static final JpsElementCollectionRole<JpsLibrary> LIBRARIES_COLLECTION_ROLE = JpsElementCollectionRole.create(INSTANCE);
private JpsLibraryRole() {
@@ -1,88 +0,0 @@
/*
* Copyright 2000-2012 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 org.jetbrains.jps.model.module.impl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.JpsElement;
import org.jetbrains.jps.model.JpsElementChildRole;
import org.jetbrains.jps.model.JpsElementCollection;
import org.jetbrains.jps.model.ex.JpsElementChildRoleBase;
import org.jetbrains.jps.model.ex.JpsNamedCompositeElementBase;
import org.jetbrains.jps.model.module.JpsFacet;
import org.jetbrains.jps.model.module.JpsFacetReference;
import org.jetbrains.jps.model.module.JpsFacetType;
import org.jetbrains.jps.model.module.JpsModule;
/**
* @author nik
*/
public class JpsFacetImpl extends JpsNamedCompositeElementBase<JpsFacetImpl> implements JpsFacet {
private static final JpsElementChildRole<JpsFacetReference> PARENT_FACET_REFERENCE = JpsElementChildRoleBase.create("parent facet");
private final JpsFacetType<?> myFacetType;
public <P extends JpsElement>JpsFacetImpl(JpsFacetType<?> facetType, @NotNull String name, @NotNull P properties) {
super(name);
myFacetType = facetType;
myContainer.setChild(JpsFacetRole.COLLECTION_ROLE);
}
private JpsFacetImpl(JpsFacetImpl original) {
super(original);
myFacetType = original.myFacetType;
}
@NotNull
@Override
public JpsFacetImpl createCopy() {
return new JpsFacetImpl(this);
}
@Override
@NotNull
public JpsFacetType<?> getType() {
return myFacetType;
}
@Override
public void setParentFacet(@NotNull JpsFacet facet) {
myContainer.setChild(PARENT_FACET_REFERENCE, facet.createReference());
}
@Override
@Nullable
public JpsFacet getParentFacet() {
final JpsFacetReference reference = myContainer.getChild(PARENT_FACET_REFERENCE);
return reference != null ? reference.resolve() : null;
}
@Override
public JpsModule getModule() {
return myParent != null ? (JpsModule)myParent.getParent() : null;
}
@NotNull
@Override
public JpsFacetReference createReference() {
return new JpsFacetReferenceImpl(getName(), getModule().createReference());
}
@Override
public void delete() {
//noinspection unchecked
((JpsElementCollection<JpsFacet>)myParent).removeChild(this);
}
}
@@ -1,41 +0,0 @@
/*
* Copyright 2000-2012 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 org.jetbrains.jps.model.module.impl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.impl.JpsNamedElementReferenceImpl;
import org.jetbrains.jps.model.module.JpsFacet;
import org.jetbrains.jps.model.module.JpsFacetReference;
import org.jetbrains.jps.model.module.JpsModuleReference;
/**
* @author nik
*/
public class JpsFacetReferenceImpl extends JpsNamedElementReferenceImpl<JpsFacet, JpsFacetReferenceImpl> implements JpsFacetReference {
public JpsFacetReferenceImpl(String facetName, JpsModuleReference moduleReference) {
super(JpsFacetRole.COLLECTION_ROLE, facetName, moduleReference);
}
private JpsFacetReferenceImpl(JpsFacetReferenceImpl original) {
super(original);
}
@NotNull
@Override
public JpsFacetReferenceImpl createCopy() {
return new JpsFacetReferenceImpl(this);
}
}
@@ -1,45 +0,0 @@
/*
* Copyright 2000-2012 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 org.jetbrains.jps.model.module.impl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.JpsEventDispatcher;
import org.jetbrains.jps.model.ex.JpsElementCollectionRole;
import org.jetbrains.jps.model.ex.JpsElementChildRoleBase;
import org.jetbrains.jps.model.module.JpsFacet;
import org.jetbrains.jps.model.module.JpsFacetListener;
/**
* @author nik
*/
public class JpsFacetRole extends JpsElementChildRoleBase<JpsFacet> {
public static final JpsFacetRole INSTANCE = new JpsFacetRole();
public static final JpsElementCollectionRole<JpsFacet> COLLECTION_ROLE = JpsElementCollectionRole.create(INSTANCE);
public JpsFacetRole() {
super("facet");
}
@Override
public void fireElementAdded(@NotNull JpsEventDispatcher dispatcher, @NotNull JpsFacet element) {
dispatcher.getPublisher(JpsFacetListener.class).facetAdded(element);
}
@Override
public void fireElementRemoved(@NotNull JpsEventDispatcher dispatcher, @NotNull JpsFacet element) {
dispatcher.getPublisher(JpsFacetListener.class).facetRemoved(element);
}
}
@@ -40,7 +40,7 @@ import java.util.List;
public class JpsModuleImpl<P extends JpsElement> extends JpsNamedCompositeElementBase<JpsModuleImpl<P>> implements JpsTypedModule<P> {
private static final JpsUrlListRole CONTENT_ROOTS_ROLE = new JpsUrlListRole("content roots");
private static final JpsUrlListRole EXCLUDED_ROOTS_ROLE = new JpsUrlListRole("excluded roots");
public static final JpsElementChildRole<JpsDependenciesListImpl> DEPENDENCIES_LIST_CHILD_ROLE = JpsElementChildRoleBase.create("dependencies");
private static final JpsElementChildRole<JpsDependenciesListImpl> DEPENDENCIES_LIST_CHILD_ROLE = JpsElementChildRoleBase.create("dependencies");
private final JpsModuleType<P> myModuleType;
private final JpsLibraryCollection myLibraryCollection;
@@ -50,7 +50,6 @@ public class JpsModuleImpl<P extends JpsElement> extends JpsNamedCompositeElemen
myContainer.setChild(myModuleType.getPropertiesRole(), properties);
myContainer.setChild(CONTENT_ROOTS_ROLE);
myContainer.setChild(EXCLUDED_ROOTS_ROLE);
myContainer.setChild(JpsFacetRole.COLLECTION_ROLE);
myContainer.setChild(DEPENDENCIES_LIST_CHILD_ROLE, new JpsDependenciesListImpl());
getDependenciesList().addModuleSourceDependency();
myLibraryCollection = new JpsLibraryCollectionImpl(myContainer.setChild(JpsLibraryRole.LIBRARIES_COLLECTION_ROLE));
@@ -136,18 +135,6 @@ public class JpsModuleImpl<P extends JpsElement> extends JpsNamedCompositeElemen
}
}
@NotNull
@Override
public <P extends JpsElement> JpsFacet addFacet(@NotNull String name, @NotNull JpsFacetType<P> type, @NotNull P properties) {
return myContainer.getChild(JpsFacetRole.COLLECTION_ROLE).addChild(new JpsFacetImpl(type, name, properties));
}
@NotNull
@Override
public List<JpsFacet> getFacets() {
return myContainer.getChild(JpsFacetRole.COLLECTION_ROLE).getElements();
}
@NotNull
@Override
public JpsDependenciesList getDependenciesList() {
@@ -27,10 +27,10 @@ import org.jetbrains.jps.model.module.JpsModuleListener;
* @author nik
*/
public class JpsModuleRole extends JpsElementChildRoleBase<JpsModule> {
public static final JpsElementChildRole<JpsModule> INSTANCE = new JpsModuleRole();
private static final JpsElementChildRole<JpsModule> INSTANCE = new JpsModuleRole();
public static final JpsElementCollectionRole<JpsModule> MODULE_COLLECTION_ROLE = JpsElementCollectionRole.create(INSTANCE);
public JpsModuleRole() {
private JpsModuleRole() {
super("module");
}
@@ -26,10 +26,10 @@ import org.jetbrains.jps.model.module.JpsModuleSourceRootListener;
* @author nik
*/
public class JpsModuleSourceRootRole extends JpsElementChildRoleBase<JpsModuleSourceRoot> {
public static final JpsModuleSourceRootRole INSTANCE = new JpsModuleSourceRootRole();
private static final JpsModuleSourceRootRole INSTANCE = new JpsModuleSourceRootRole();
public static final JpsElementCollectionRole<JpsModuleSourceRoot> ROOT_COLLECTION_ROLE = JpsElementCollectionRole.create(INSTANCE);
public JpsModuleSourceRootRole() {
private JpsModuleSourceRootRole() {
super("module source root");
}
@@ -1,40 +0,0 @@
/*
* Copyright 2000-2012 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 org.jetbrains.jps.model;
import org.jetbrains.jps.model.java.JpsJavaModuleType;
import org.jetbrains.jps.model.module.JpsFacet;
import org.jetbrains.jps.model.module.JpsFacetType;
import org.jetbrains.jps.model.module.JpsModule;
/**
* @author nik
*/
public class JpsFacetTest extends JpsModelTestCase {
public void testAddFacet() {
final JpsModule m = myProject.addModule("m", JpsJavaModuleType.INSTANCE);
m.addFacet("f", MY_FACET_TYPE, JpsElementFactory.getInstance().createDummyElement());
assertEquals("f", assertOneElement(m.getFacets()).getName());
}
public void testCreateReferenceByFacet() {
final JpsFacet facet = myProject.addModule("m", JpsJavaModuleType.INSTANCE).addFacet("f", MY_FACET_TYPE, JpsElementFactory.getInstance().createDummyElement());
final JpsElementReference<JpsFacet> reference = facet.createReference().asExternal(myModel);
assertSame(facet, reference.resolve());
}
private static final JpsFacetType<JpsDummyElement> MY_FACET_TYPE = new JpsFacetType<JpsDummyElement>() { };
}
@@ -0,0 +1 @@
org.jetbrains.jps.model.serialization.impl.JpsSerializationManagerImpl
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,33 +13,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jps.model.module;
package org.jetbrains.jps.model.serialization;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.JpsNamedElement;
import org.jetbrains.jps.model.JpsReferenceableElement;
import org.jetbrains.jps.model.JpsModel;
import org.jetbrains.jps.service.JpsServiceManager;
import java.io.IOException;
import java.util.Map;
/**
* @author nik
*/
//todo[nik] I'm not sure that we really need separate interface for facets in the project model.
//Perhaps facets should be replaced by extensions for module elements
public interface JpsFacet extends JpsNamedElement, JpsReferenceableElement<JpsFacet> {
JpsModule getModule();
public abstract class JpsSerializationManager {
public static JpsSerializationManager getInstance() {
return JpsServiceManager.getInstance().getService(JpsSerializationManager.class);
}
@NotNull
JpsFacetType<?> getType();
void delete();
@NotNull
@Override
JpsFacetReference createReference();
void setParentFacet(@NotNull JpsFacet facet);
@Nullable
JpsFacet getParentFacet();
public abstract JpsModel loadModel(@NotNull String projectPath, @Nullable String optionsPath, @NotNull Map<String, String> pathVariables)
throws IOException;
}
@@ -0,0 +1,44 @@
/*
* Copyright 2000-2013 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 org.jetbrains.jps.model.serialization.impl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.JpsElementFactory;
import org.jetbrains.jps.model.JpsModel;
import org.jetbrains.jps.model.serialization.JpsGlobalLoader;
import org.jetbrains.jps.model.serialization.JpsProjectLoader;
import org.jetbrains.jps.model.serialization.JpsSerializationManager;
import java.io.IOException;
import java.util.Map;
/**
* @author nik
*/
public class JpsSerializationManagerImpl extends JpsSerializationManager {
@NotNull
@Override
public JpsModel loadModel(@NotNull String projectPath, @Nullable String optionsPath, @NotNull Map<String, String> pathVariables)
throws IOException {
JpsModel model = JpsElementFactory.getInstance().createModel();
if (optionsPath != null) {
JpsGlobalLoader.loadGlobalSettings(model.getGlobal(), pathVariables, optionsPath);
}
JpsProjectLoader.loadProject(model.getProject(), pathVariables, projectPath);
return model;
}
}
@@ -317,7 +317,12 @@ public class CompositeElement extends TreeElement {
@NonNls String msg = "";
msg += ";\n changed=" + (startStamp != myModificationsCount);
msg += ";\n buffer=" + text;
msg += ";\n this=" + this;
try {
msg += ";\n this=" + this;
}
catch (StackOverflowError e) {
msg += ";\n this.toString produces SOE";
}
int shitStart = textMatches(text, 0);
msg += ";\n matches until " + shitStart;
LeafElement leaf = findLeafElementAt(Math.abs(shitStart));
Binary file not shown.

Before

Width:  |  Height:  |  Size: 309 B

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 659 B

After

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 B

After

Width:  |  Height:  |  Size: 423 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 779 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 389 B

After

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 809 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 811 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 399 B

After

Width:  |  Height:  |  Size: 402 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 712 B

After

Width:  |  Height:  |  Size: 711 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 731 B

After

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 512 B

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 489 B

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 478 B

After

Width:  |  Height:  |  Size: 481 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 475 B

After

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1007 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 451 B

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 946 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 993 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 343 B

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 355 B

After

Width:  |  Height:  |  Size: 466 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 425 B

After

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 347 B

After

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 553 B

After

Width:  |  Height:  |  Size: 578 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 365 B

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 352 B

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 471 B

After

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 393 B

After

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 844 B

Some files were not shown because too many files have changed in this diff Show More