Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 3.4/apyshkin/bugs
Browse files Browse the repository at this point in the history
Conflicts:
	workbench/mps-platform/source/jetbrains/mps/progress/ProgressMonitorAdapter.java
	workbench/mps-workbench/source/jetbrains/mps/workbench/dialogs/project/newproject/ProjectFactory.java
  • Loading branch information
apyshkin committed Jul 26, 2016
2 parents 93ecd34 + acdbe87 commit c6c9658
Show file tree
Hide file tree
Showing 495 changed files with 28,609 additions and 18,429 deletions.
Expand Up @@ -176,7 +176,8 @@ public String toString() {

@Override
public long getModificationStamp() {
return getVirtualFile().getModificationStamp();
VirtualFile file = getVirtualFile();
return file != null ? file.getModificationStamp() : -1;
}

@NotNull
Expand Down Expand Up @@ -277,7 +278,12 @@ public PsiElement getContext() {
VirtualFile vFile = mySeparateFile != null ?
mySeparateFile :
myModel.getSourceVirtualFile();
return vFile.isValid() ? PsiManager.getInstance(getProject()).findFile(vFile) : null;
// TEMP FIX: Guarding vFile == null
// model.getSourceFile() gives us null in case model is in a jar file, because its
// source.getFile() returns not a virtual file, but a JarEntryFile
// Proper solution, i think: exclude them from indexing by MPSFQNameJavaClassIndex and the like
// Came here from MPSJavaClassFinder
return vFile != null && vFile.isValid() ? PsiManager.getInstance(getProject()).findFile(vFile) : null;
}

@Override
Expand Down
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<debug-info-v2>
<debug-info version="2">
<concept fqn="c:f3061a53-9226-4cc5-a443-f952ceaf5816/1160998861373:jetbrains.mps.baseLanguage.structure.AssertStatement" />
<concept fqn="c:f3061a53-9226-4cc5-a443-f952ceaf5816/1082485599095:jetbrains.mps.baseLanguage.structure.BlockStatement" />
<concept fqn="c:f3061a53-9226-4cc5-a443-f952ceaf5816/1068580123140:jetbrains.mps.baseLanguage.structure.ConstructorDeclaration" />
Expand Down Expand Up @@ -217,5 +217,5 @@
<unit id="3335509261457006477" at="21,0,76,0" name="jetbrains.mps.idea.java.fastFind.JavaPsiStubsNavigationContributor" />
</file>
</root>
</debug-info-v2>
</debug-info>

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<debug-info-v2>
<debug-info version="2">
<concept fqn="c:f3061a53-9226-4cc5-a443-f952ceaf5816/1082485599095:jetbrains.mps.baseLanguage.structure.BlockStatement" />
<concept fqn="c:f3061a53-9226-4cc5-a443-f952ceaf5816/1068580123140:jetbrains.mps.baseLanguage.structure.ConstructorDeclaration" />
<concept fqn="c:f3061a53-9226-4cc5-a443-f952ceaf5816/1068580123155:jetbrains.mps.baseLanguage.structure.ExpressionStatement" />
Expand Down Expand Up @@ -176,5 +176,5 @@
<unit id="8308904528689640856" at="23,0,49,0" name="jetbrains.mps.idea.java.psi.impl.blTypes.MPSPsiCollectionType" />
</file>
</root>
</debug-info-v2>
</debug-info>

Large diffs are not rendered by default.

Expand Up @@ -200,15 +200,15 @@ public synchronized void changed(DataSource source, final PsiJavaStubEvent event


private SNode getImports(PsiImportStatementBase[] imports) {
SNode javaImports = SConceptOperations.createNewNode(SNodeOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x53f7c33f069862f2L, "jetbrains.mps.baseLanguage.structure.JavaImports")));
SNode javaImports = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x53f7c33f069862f2L, "jetbrains.mps.baseLanguage.structure.JavaImports"));

for (PsiImportStatementBase imp : imports) {
PsiJavaCodeReferenceElement ref = imp.getImportReference();
if (ref == null) {
continue;
}

SNode javaImport = SConceptOperations.createNewNode(SNodeOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x64c0181e603bcfL, "jetbrains.mps.baseLanguage.structure.JavaImport")));
SNode javaImport = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x64c0181e603bcfL, "jetbrains.mps.baseLanguage.structure.JavaImport"));
SPropertyOperations.set(javaImport, MetaAdapterFactory.getProperty(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x64c0181e603bcfL, 0x64c0181e603bd0L, "onDemand"), "" + (imp.isOnDemand()));
SPropertyOperations.set(javaImport, MetaAdapterFactory.getProperty(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x64c0181e603bcfL, 0x4d5c30eb30af1572L, "static"), "" + (imp instanceof PsiImportStaticStatement));
String qName = ref.getQualifiedName();
Expand Down

Large diffs are not rendered by default.

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<debug-info-v2>
<debug-info version="2">
<concept fqn="c:f3061a53-9226-4cc5-a443-f952ceaf5816/1070462154015:jetbrains.mps.baseLanguage.structure.StaticFieldDeclaration" />
<root nodeRef="r:7ef5e488-ffbd-46d7-b31e-58c7f710bbdf(jetbrains.mps.idea.java)/5993361350499286549">
<file name="Constants.java">
Expand Down Expand Up @@ -35,5 +35,5 @@
<unit id="5993361350499286549" at="9,0,48,0" name="jetbrains.mps.idea.java.Constants" />
</file>
</root>
</debug-info-v2>
</debug-info>

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<debug-info-v2>
<debug-info version="2">
<concept fqn="c:f3061a53-9226-4cc5-a443-f952ceaf5816/1081855346303:jetbrains.mps.baseLanguage.structure.BreakStatement" />
<concept fqn="c:f3061a53-9226-4cc5-a443-f952ceaf5816/1177666668936:jetbrains.mps.baseLanguage.structure.DoWhileStatement" />
<concept fqn="c:f3061a53-9226-4cc5-a443-f952ceaf5816/1068580123155:jetbrains.mps.baseLanguage.structure.ExpressionStatement" />
Expand Down Expand Up @@ -43,5 +43,5 @@
<unit id="7053458875161789292" at="11,0,34,0" name="jetbrains.mps.idea.java.util.ClassUtil" />
</file>
</root>
</debug-info-v2>
</debug-info>

Expand Up @@ -23,11 +23,10 @@
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiSubstitutor;
import com.intellij.psi.PsiType;
import com.intellij.psi.PsiTypeParameter;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.ArrayUtil;
import com.jgoodies.common.collect.ArrayListModel;
import jetbrains.mps.idea.core.psi.impl.MPSPsiNode;
import jetbrains.mps.idea.core.psi.impl.MPSPsiNodeBase;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -43,12 +42,23 @@ public class MPSPsiClassifierType extends MPSPsiNode implements ComputesPsiType<

MPSPsiClassifierType(SNodeId id, String concept, String containingRole, PsiManager manager) {
super(id, concept, containingRole, manager);
addChildLast(new MPSPsiTypeParamList(manager));
}

// public PsiClass getTargetClass() {
// return getReferenceTarget("classifier", PsiClass.class);
// }


@Nullable
@Override
protected MPSPsiNodeBase getParentFor(MPSPsiNode child) {
if (child instanceof MPSPsiTypeParameter) {
return getChildOfType(MPSPsiTypeParamList.class);
}
return super.getParentFor(child);
}

@Override
public PsiClassType getPsiType() {
return new PsiClassType(LanguageLevel.JDK_1_6) { // is language level fixed for MPS code?
Expand Down Expand Up @@ -78,13 +88,13 @@ public String getClassName() {
@NotNull
@Override
public PsiType[] getParameters() {
MPSPsiNode[] typeParamNodes = MPSPsiClassifierType.this.getChildrenOfType("parameter", MPSPsiNode.class);
MPSPsiTypeParameter[] typeParamNodes = MPSPsiClassifierType.this.getChildOfType(MPSPsiTypeParamList.class).getChildren(MPSPsiTypeParameter.class);
if (typeParamNodes == null || typeParamNodes.length == 0) {
return PsiType.EMPTY_ARRAY;
}

List<PsiType> paramTypes = new ArrayList<PsiType>(typeParamNodes.length);
for (MPSPsiNode tn : typeParamNodes) {
for (MPSPsiTypeParameter tn : typeParamNodes) {
if (!(tn instanceof ComputesPsiType)) continue;
PsiType psiType = ((ComputesPsiType) tn).getPsiType();
// should probably put all params, even those which failed to resolve
Expand Down
Expand Up @@ -17,8 +17,10 @@
package jetbrains.mps.idea.java.psi.impl;

import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiParameter;
import com.intellij.psi.PsiTypeParameter;
import com.intellij.psi.PsiTypeParameterList;
import com.intellij.psi.impl.PsiImplUtil;
import jetbrains.mps.idea.core.psi.impl.MPSPsiNodeBase;

/**
Expand All @@ -32,16 +34,17 @@ public MPSPsiTypeParamList(PsiManager manager) {

@Override
public String toString() {
return null; //To change body of implemented methods use File | Settings | File Templates.
return "MPSPsiTypeParamList";
}

@Override
public PsiTypeParameter[] getTypeParameters() {
return new PsiTypeParameter[0]; //To change body of implemented methods use File | Settings | File Templates.
PsiTypeParameter[] result = getChildrenOfType("parameter", MPSPsiTypeParameter.class);
return result == null ? PsiTypeParameter.EMPTY_ARRAY : result;
}

@Override
public int getTypeParameterIndex(PsiTypeParameter typeParameter) {
return 0; //To change body of implemented methods use File | Settings | File Templates.
return PsiImplUtil.getTypeParameterIndex(typeParameter, this);
}
}
Expand Up @@ -16,6 +16,7 @@
package jetbrains.mps.findUsages;

import jetbrains.mps.smodel.ConceptDescendantsCache;
import org.jetbrains.mps.openapi.model.EditableSModel;
import org.jetbrains.mps.openapi.util.ProgressMonitor;
import org.jetbrains.mps.openapi.util.SubProgressKind;
import jetbrains.mps.util.CollectConsumer;
Expand All @@ -31,6 +32,7 @@

import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

class InstancesSearchType extends SearchType<SNode, SAbstractConcept> {
Expand Down Expand Up @@ -59,7 +61,16 @@ public Set<SNode> search(Set<SAbstractConcept> elements, SearchScope scope, @Not
}
monitor.advance(1);

Collection<SModel> current = IterableUtil.asCollection(scope.getModels());
Collection<SModel> current = new LinkedHashSet<SModel>();;
Collection<SModel> simpleSearch = new LinkedHashSet<SModel>();
for (SModel m:IterableUtil.asCollection(scope.getModels())){
if (m instanceof EditableSModel && ((EditableSModel) m).isChanged()){
simpleSearch.add(m);
} else {
current.add(m);
}
}

for (FindUsagesParticipant participant : participants) {
final Set<SModel> next = new HashSet<SModel>(current);
participant.findInstances(current, queryConcepts, consumer, new Consumer<SModel>() {
Expand All @@ -74,6 +85,8 @@ public void consume(SModel sModel) {

ProgressMonitor subMonitor = monitor.subTask(4, SubProgressKind.DEFAULT);
subMonitor.start("", current.size());
showNoFastFindTipIfNeeded(monitor, current);
current.addAll(simpleSearch);
for (SModel m : current) {
subMonitor.step(m.getModelName());
FindUsagesUtil.collectInstances(m, queryConcepts, consumer);
Expand Down
Expand Up @@ -15,12 +15,37 @@
*/
package jetbrains.mps.findUsages;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.mps.openapi.model.SModel;
import org.jetbrains.mps.openapi.module.SearchScope;
import org.jetbrains.mps.openapi.util.ProgressMonitor;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

public abstract class SearchType<T, R> {
private static final Logger LOG = LogManager.getLogger(SearchType.class);

public abstract Set<T> search(Set<R> elements, SearchScope scope, @NotNull ProgressMonitor monitor);

protected void showNoFastFindTipIfNeeded(@NotNull ProgressMonitor monitor, Collection<SModel> noFastFindModels) {
HashSet<SModel> notEmptyNoFastFindModels=new HashSet<>();
for (SModel m:noFastFindModels){
if (m.getRootNodes().iterator().hasNext()){
notEmptyNoFastFindModels.add(m);
}
}

if (notEmptyNoFastFindModels.isEmpty()) {
return;
}

int othersSize = notEmptyNoFastFindModels.size() - 1;
String others = othersSize == 0 ? "" : " and " + othersSize + " others";
LOG.warn("Fast usages search not supported for model " + notEmptyNoFastFindModels.iterator().next().getName() + others + ". " +
"Usages search may be slow.");
}
}
Expand Up @@ -31,6 +31,7 @@

import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

class UsagesSearchType extends SearchType<SReference, SNode> {
Expand All @@ -46,16 +47,22 @@ public Set<SReference> search(Set<SNode> nodes, SearchScope scope, @NotNull Prog

monitor.start("Finding usages...", participants.size() + 4);
try {
Collection<SModel> current = IterableUtil.asCollection(scope.getModels());
Collection<SModel> current = new LinkedHashSet<SModel>();;
Collection<SModel> simpleSearch = new LinkedHashSet<SModel>();
for (SModel m:IterableUtil.asCollection(scope.getModels())){
if (m instanceof EditableSModel && ((EditableSModel) m).isChanged()){
simpleSearch.add(m);
} else {
current.add(m);
}
}

for (FindUsagesParticipant participant : participants) {
final Set<SModel> next = new HashSet<SModel>(current);
participant.findUsages(current, nodes, consumer, new Consumer<SModel>() {
@Override
public void consume(SModel sModel) {
if (sModel instanceof EditableSModel && ((EditableSModel) sModel).isChanged()) {
// models being edited and modified need attention as there might be changes not yet indexed.
return;
}
assert !(sModel instanceof EditableSModel && ((EditableSModel) sModel).isChanged());
next.remove(sModel);
}
});
Expand All @@ -66,6 +73,8 @@ public void consume(SModel sModel) {
ProgressMonitor subMonitor = monitor.subTask(4, SubProgressKind.DEFAULT);
subMonitor.start("", current.size());
NodeUsageFinder nf = new NodeUsageFinder(nodes, consumer);
showNoFastFindTipIfNeeded(monitor, current);
current.addAll(simpleSearch);
for (SModel m : current) {
subMonitor.step(m.getModelName());
nf.collectUsages(m);
Expand Down

0 comments on commit c6c9658

Please sign in to comment.