Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into develar/is
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Jul 19, 2016
2 parents 7660f19 + 88e2960 commit 47225b8
Show file tree
Hide file tree
Showing 74 changed files with 385 additions and 252 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
Expand Down Expand Up @@ -66,7 +66,7 @@ protected void setUpModule() {
@Override
protected void setUp() throws Exception {
super.setUp();
myProject.getMessageBus().connect(myTestRootDisposable).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
myProject.getMessageBus().connect(getTestRootDisposable()).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
@Override
public void rootsChanged(ModuleRootEvent event) {
//todo[nik] projectOpened isn't called in tests so we need to add this listener manually
Expand Down Expand Up @@ -249,7 +249,7 @@ private CompilationLog compile(final ParameterizedRunnable<CompileStatusNotifica
public void fileGenerated(String outputRoot, String relativePath) {
generatedFilePaths.add(relativePath);
}
}, myTestRootDisposable);
}, getTestRootDisposable());
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private Block createJavaBlock(@NotNull ASTNode child,
InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)child)) {
return new CommentWithInjectionBlock(child, wrap, alignment, indent, settings, javaSettings);
}
if (child instanceof LeafElement || childPsi instanceof PsiJavaModuleReference) {
if (child instanceof LeafElement || childPsi instanceof PsiJavaModuleReferenceElement) {
final LeafBlock block = new LeafBlock(child, wrap, alignment, actualIndent);
block.setStartOffset(startOffset);
return block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ public void visitModule(PsiJavaModule module) {
visitElement(module);
}

public void visitModuleReference(PsiJavaModuleReference moduleRef) {
public void visitModuleReference(PsiJavaModuleReferenceElement moduleRef) {
visitElement(moduleRef);
}

Expand Down
3 changes: 2 additions & 1 deletion java/java-psi-api/src/com/intellij/psi/PsiJavaModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public interface PsiJavaModule extends NavigatablePsiElement {
String MODULE_INFO_CLASS = "module-info";
String MODULE_INFO_FILE = MODULE_INFO_CLASS + ".java";

@NotNull PsiJavaModuleReference getNameElement();
@NotNull
PsiJavaModuleReferenceElement getNameElement();
@NotNull String getModuleName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
*
* @since 2016.3
*/
public interface PsiJavaModuleReference extends PsiElement {
public interface PsiJavaModuleReferenceElement extends PsiElement {
@NotNull String getReferenceText();
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
import org.jetbrains.annotations.NotNull;

public class ClsJavaModuleImpl extends ClsRepositoryPsiElement<PsiJavaModuleStub> implements PsiJavaModule {
private PsiJavaModuleReference myReference;
private PsiJavaModuleReferenceElement myReference;

public ClsJavaModuleImpl(PsiJavaModuleStub stub) {
super(stub);
myReference = new ClsJavaModuleReferenceImpl(this, stub.getName());
myReference = new ClsJavaModuleReferenceElementImpl(this, stub.getName());
}

@NotNull
@Override
public PsiJavaModuleReference getNameElement() {
public PsiJavaModuleReferenceElement getNameElement() {
return myReference;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
import com.intellij.psi.JavaElementVisitor;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.PsiJavaModuleReference;
import com.intellij.psi.PsiJavaModuleReferenceElement;
import com.intellij.psi.impl.source.tree.JavaElementType;
import com.intellij.psi.impl.source.tree.TreeElement;
import org.jetbrains.annotations.NotNull;

public class ClsJavaModuleReferenceImpl extends ClsElementImpl implements PsiJavaModuleReference {
public class ClsJavaModuleReferenceElementImpl extends ClsElementImpl implements PsiJavaModuleReferenceElement {
private final PsiElement myParent;
private final String myText;

public ClsJavaModuleReferenceImpl(PsiElement parent, String text) {
public ClsJavaModuleReferenceElementImpl(PsiElement parent, String text) {
myParent = parent;
myText = text;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public PsiJavaModuleImpl(@NotNull ASTNode node) {

@NotNull
@Override
public PsiJavaModuleReference getNameElement() {
return PsiTreeUtil.getRequiredChildOfType(this, PsiJavaModuleReference.class);
public PsiJavaModuleReferenceElement getNameElement() {
return PsiTreeUtil.getRequiredChildOfType(this, PsiJavaModuleReferenceElement.class);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import com.intellij.psi.impl.source.tree.JavaElementType;
import org.jetbrains.annotations.NotNull;

public class PsiJavaModuleReferenceImpl extends CompositePsiElement implements PsiJavaModuleReference {
public PsiJavaModuleReferenceImpl() {
public class PsiJavaModuleReferenceElementImpl extends CompositePsiElement implements PsiJavaModuleReferenceElement {
public PsiJavaModuleReferenceElementImpl() {
super(JavaElementType.MODULE_REFERENCE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public ASTNode createCompositeNode() {
IElementType ANNOTATION_ARRAY_INITIALIZER = new JavaCompositeElementType("ANNOTATION_ARRAY_INITIALIZER", PsiArrayInitializerMemberValueImpl.class);
IElementType RECEIVER_PARAMETER = new JavaCompositeElementType("RECEIVER", PsiReceiverParameterImpl.class);

IElementType MODULE_REFERENCE = new JavaCompositeElementType("MODULE_REFERENCE", PsiJavaModuleReferenceImpl.class);
IElementType MODULE_REFERENCE = new JavaCompositeElementType("MODULE_REFERENCE", PsiJavaModuleReferenceElementImpl.class);
IElementType REQUIRES_STATEMENT = new JavaCompositeElementType("REQUIRES_STATEMENT", PsiRequiresStatementImpl.class);
IElementType EXPORTS_STATEMENT = new JavaCompositeElementType("EXPORTS_STATEMENT", PsiExportsStatementImpl.class);
IElementType USES_STATEMENT = new JavaCompositeElementType("USES_STATEMENT", PsiUsesStatementImpl.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
Expand Down Expand Up @@ -81,7 +81,7 @@ public void testTypeAnnotatedField() {
myFixture.addClass("package foo;\n\nimport java.lang.annotation.*;\n\n@Target(ElementType.TYPE_USE) public @interface TestNotNull { }");
NullableNotNullManager manager = NullableNotNullManager.getInstance(getProject());
manager.setNotNulls("foo.TestNotNull");
Disposer.register(myTestRootDisposable, manager::setNotNulls);
Disposer.register(getTestRootDisposable(), manager::setNotNulls);
doTest();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.completion;

import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.codeInsight.lookup.Lookup;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementPresentation;
import com.intellij.codeInsight.template.SmartCompletionContextType;
import com.intellij.codeInsight.template.Template;
Expand All @@ -12,7 +26,6 @@
import com.intellij.codeInsight.template.impl.TemplateImpl;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.util.Condition;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
Expand Down Expand Up @@ -656,7 +669,7 @@ public void testLiveTemplate() throws Throwable {
final SmartCompletionContextType completionContextType =
ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), SmartCompletionContextType.class);
((TemplateImpl)template).getTemplateContext().setEnabled(completionContextType, true);
CodeInsightTestUtil.addTemplate(template, myTestRootDisposable);
CodeInsightTestUtil.addTemplate(template, getTestRootDisposable());
doTest();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2016 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.
Expand All @@ -18,7 +18,6 @@
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.defUse.DefUseInspection;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.testFramework.IdeaTestUtil;
Expand Down Expand Up @@ -79,7 +78,7 @@ private void doTestAmbiguous() throws Exception {
//ambiguous method calls
private void doTestAmbiguous(@NotNull JavaSdkVersion javaSdkVersion) throws Exception {
final String name = getTestName(true);
IdeaTestUtil.setTestVersion(javaSdkVersion, getModule(), myTestRootDisposable);
IdeaTestUtil.setTestVersion(javaSdkVersion, getModule(), getTestRootDisposable());
doTest(BASE_PATH + name + "/pck/AmbiguousMethodCall.java", BASE_PATH + "/" + name, false, false);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2016 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.
Expand Down Expand Up @@ -55,7 +55,7 @@ protected Sdk getProjectJDK() {

private void doTest(@NotNull LanguageLevel languageLevel, @NotNull JavaSdkVersion sdkVersion, boolean checkWarnings) {
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(languageLevel);
IdeaTestUtil.setTestVersion(sdkVersion, getModule(), myTestRootDisposable);
IdeaTestUtil.setTestVersion(sdkVersion, getModule(), getTestRootDisposable());
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
}
private void doTest5(boolean checkWarnings) { doTest(LanguageLevel.JDK_1_5, JavaSdkVersion.JDK_1_6, checkWarnings); }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
Expand Down Expand Up @@ -31,7 +31,7 @@ protected void setUp() throws Exception {
super.setUp();
enableInspectionTools(new UnusedDeclarationInspection(), new UncheckedWarningLocalInspection(), new JavacQuirksInspection(), new RedundantCastInspection());
setLanguageLevel(LanguageLevel.JDK_1_6);
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_6, getModule(), myTestRootDisposable);
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_6, getModule(), getTestRootDisposable());
}

private void doTest(boolean checkWarnings, boolean checkInfos) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected void setUp() throws Exception {
super.setUp();
enableInspectionTools(new UnusedDeclarationInspection(), new UncheckedWarningLocalInspection(), new JavacQuirksInspection(), new RedundantCastInspection());
setLanguageLevel(LanguageLevel.JDK_1_7);
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_7, getModule(), myTestRootDisposable);
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_7, getModule(), getTestRootDisposable());
}

private void doTest(boolean checkWarnings, boolean checkInfos, InspectionProfileEntry... inspections) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public void testSillyAssignment() {
public void testUnused() { doTest(true, false); }
public void testQualifierBeforeClassName() { doTest(false, false); }
public void testQualifiedSuper() {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_6, getModule(), myTestRootDisposable);
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_6, getModule(), getTestRootDisposable());
doTest(false, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected String getTestDataPath() {
@Override
public void setUp() throws Exception {
super.setUp();
PlatformTestUtil.registerExtension(PsiAugmentProvider.EP_NAME, new TestAugmentProvider(), myTestRootDisposable);
PlatformTestUtil.registerExtension(PsiAugmentProvider.EP_NAME, new TestAugmentProvider(), getTestRootDisposable());
myFixture.addClass("package lombok;\npublic @interface val { }");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
import com.intellij.openapi.application.AccessToken;
import com.intellij.openapi.application.ApplicationManager;
Expand Down Expand Up @@ -883,7 +886,7 @@ public void collectSlowLineMarkers(@NotNull List<PsiElement> elements, @NotNull
}
};
LineMarkerProviders.INSTANCE.addExplicitExtension(JavaLanguage.INSTANCE, provider);
Disposer.register(myTestRootDisposable, () -> LineMarkerProviders.INSTANCE.removeExplicitExtension(JavaLanguage.INSTANCE, provider));
Disposer.register(getTestRootDisposable(), () -> LineMarkerProviders.INSTANCE.removeExplicitExtension(JavaLanguage.INSTANCE, provider));
myDaemonCodeAnalyzer.restart();
try {
TextRange range = FileStatusMap.getDirtyTextRange(getEditor(), Pass.UPDATE_ALL);
Expand Down Expand Up @@ -2193,7 +2196,7 @@ public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file
}
};
IntentionManager.getInstance().addAction(longLongUpdate);
Disposer.register(myTestRootDisposable, () -> IntentionManager.getInstance().unregisterIntention(longLongUpdate));
Disposer.register(getTestRootDisposable(), () -> IntentionManager.getInstance().unregisterIntention(longLongUpdate));
configureByText(JavaFileType.INSTANCE, "class X { <caret> }");
makeEditorWindowVisible(new Point(0, 0));
doHighlighting();
Expand All @@ -2220,7 +2223,7 @@ public void testLightBulbIsHiddenWhenFixRangeIsCollapsed() {
((EditorImpl)myEditor).getScrollPane().getViewport().setSize(1000, 1000);

final Set<LightweightHint> visibleHints = ContainerUtil.newIdentityTroveSet();
getProject().getMessageBus().connect(myTestRootDisposable).subscribe(EditorHintListener.TOPIC, new EditorHintListener() {
getProject().getMessageBus().connect(getTestRootDisposable()).subscribe(EditorHintListener.TOPIC, new EditorHintListener() {
@Override
public void hintShown(final Project project, final LightweightHint hint, final int flags) {
visibleHints.add(hint);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 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.
Expand Down Expand Up @@ -803,7 +803,7 @@ private void doTest() {

private void doTest(boolean warnings) {
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), myTestRootDisposable);
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 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.
Expand Down Expand Up @@ -43,7 +43,7 @@ public void _testUnrelatedClassesExtendsTypeParams() throws Exception {

private void doTest() {
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), myTestRootDisposable);
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
Expand Down Expand Up @@ -45,7 +45,7 @@ protected String getBasePath() {
@Override
protected void beforeActionStarted(String testName, String contents) {
if (testName.contains("Guava")) {
ReplaceFromOfNullableFixTest.addGuavaOptional(myTestRootDisposable);
ReplaceFromOfNullableFixTest.addGuavaOptional(getTestRootDisposable());
}
super.beforeActionStarted(testName, contents);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2000-2016 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.
*/

/*
* Created by IntelliJ IDEA.
* User: max
Expand All @@ -11,7 +27,6 @@
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.daemon.ImplicitUsageProvider;
import com.intellij.codeInspection.canBeFinal.CanBeFinalInspection;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiField;
import com.intellij.psi.PsiNamedElement;
Expand Down Expand Up @@ -143,7 +158,7 @@ public boolean isImplicitRead(PsiElement element) {
public boolean isImplicitWrite(PsiElement element) {
return element instanceof PsiField && "implicitWrite".equals(((PsiNamedElement)element).getName());
}
}, myTestRootDisposable);
}, getTestRootDisposable());

doTest();
}
Expand Down
Loading

0 comments on commit 47225b8

Please sign in to comment.