-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
349 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
testing/testcompat/v211/com/google/idea/sdkcompat/BaseSdkTestCompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2021 The Bazel Authors. All rights reserved. | ||
* | ||
* 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.google.idea.sdkcompat; | ||
|
||
import com.intellij.openapi.extensions.ExtensionsArea; | ||
import com.intellij.openapi.vfs.VirtualFileSystem; | ||
import com.intellij.openapi.vfs.newvfs.impl.StubVirtualFile; | ||
import java.io.File; | ||
import java.nio.file.Path; | ||
import org.jetbrains.annotations.NonNls; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
/** | ||
* Provides SDK compatibility shims for base plugin API classes, available to all IDEs during | ||
* test-time. | ||
*/ | ||
public final class BaseSdkTestCompat { | ||
private BaseSdkTestCompat() {} | ||
/** #api202 {@link TemporaryFolder#getRoot} mock call needs to return Path since 2020.3 */ | ||
@Nullable | ||
public static Path getRootWrapper(@Nullable File file) { | ||
return file == null ? null : file.toPath(); | ||
} | ||
|
||
/** #api202 Creating a StubVirtualFile requires a filesystem parameter in 2020.3 */ | ||
public static StubVirtualFile newValidStubVirtualFile(VirtualFileSystem fileSystem) { | ||
return new StubVirtualFile(fileSystem) { | ||
@Override | ||
public boolean isValid() { | ||
return true; | ||
} | ||
}; | ||
} | ||
|
||
/** #api203 API for register extensions point requires ExtensionPoint.Kind since 2021.1. */ | ||
public static void registerExtensionPoint( | ||
ExtensionsArea area, | ||
@NonNls @NotNull String extensionPointName, | ||
@NotNull String extensionPointBeanClass) { | ||
//area.registerExtensionPoint( | ||
// extensionPointName, extensionPointBeanClass, ExtensionPoint.Kind.INTERFACE); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...tcompat/v211/com/google/idea/sdkcompat/codeinsight/navigation/CtrlMouseHandlerCompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2020 The Bazel Authors. All rights reserved. | ||
* | ||
* 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.google.idea.sdkcompat.codeinsight.navigation; | ||
|
||
import com.intellij.codeInsight.navigation.CtrlMouseHandler; | ||
import com.intellij.openapi.editor.Editor; | ||
import javax.annotation.Nullable; | ||
|
||
/** Compat class for {@link CtrlMouseHandler}. */ | ||
public class CtrlMouseHandlerCompat { | ||
|
||
private CtrlMouseHandlerCompat() {} | ||
|
||
/** #api201: CtrlMouseHandler.BrowseMode.Declaration replaced with dedicated method in 2020.2 */ | ||
@Nullable | ||
public static String getGoToDeclarationOrUsagesText(Editor editor) { | ||
return CtrlMouseHandler.getGoToDeclarationOrUsagesText(editor); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
testing/testcompat/v211/com/google/idea/sdkcompat/testframework/EdtTestUtilWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2021 The Bazel Authors. All rights reserved. | ||
* | ||
* 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.google.idea.sdkcompat.testframework; | ||
|
||
import com.intellij.testFramework.EdtTestUtil; | ||
import com.intellij.util.ThrowableRunnable; | ||
|
||
/** | ||
* #api202 {@link EdtTestUtil#runInEdtAndWait} uses {@link ThrowableRunnable} instead of {@link | ||
* Runnable} since 2020.3 | ||
*/ | ||
public final class EdtTestUtilWrapper { | ||
private EdtTestUtilWrapper() {} | ||
|
||
public static void runInEdtAndWait(ThrowableRunnable<Throwable> r) throws Throwable { | ||
EdtTestUtil.runInEdtAndWait(r); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...11/com/google/idea/sdkcompat/testframework/fixtures/CompletionAutoPopupTesterAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2021 The Bazel Authors. All rights reserved. | ||
* | ||
* 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.google.idea.sdkcompat.testframework.fixtures; | ||
|
||
import com.intellij.testFramework.fixtures.CodeInsightTestFixture; | ||
import com.intellij.testFramework.fixtures.CompletionAutoPopupTester; | ||
import com.intellij.util.ThrowableRunnable; | ||
|
||
/** | ||
* #api202 {@link CompletionAutoPopupTester#runWithAutoPopupEnabled} uses {@link ThrowableRunnable} | ||
* instead of {@link Runnable} since 2020.3 | ||
*/ | ||
public class CompletionAutoPopupTesterAdapter extends CompletionAutoPopupTester { | ||
public CompletionAutoPopupTesterAdapter(CodeInsightTestFixture fixture) { | ||
super(fixture); | ||
} | ||
} |
124 changes: 124 additions & 0 deletions
124
testing/testcompat/v211/com/google/idea/testing/cidr/StubOCCompilerSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/* | ||
* Copyright 2017 The Bazel Authors. All rights reserved. | ||
* | ||
* 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.google.idea.testing.cidr; | ||
|
||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.vfs.VfsUtilCore; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
import com.jetbrains.cidr.lang.toolchains.CidrCompilerSwitches; | ||
import com.jetbrains.cidr.lang.toolchains.CidrSwitchBuilder; | ||
import com.jetbrains.cidr.lang.workspace.OCCompilerSettings; | ||
import com.jetbrains.cidr.lang.workspace.compiler.CompilerSettingsKey; | ||
import com.jetbrains.cidr.lang.workspace.compiler.OCCompilerFeatures; | ||
import com.jetbrains.cidr.lang.workspace.compiler.OCCompilerKind; | ||
import com.jetbrains.cidr.lang.workspace.headerRoots.HeadersSearchPath; | ||
import com.jetbrains.cidr.lang.workspace.headerRoots.HeadersSearchRoot; | ||
import com.jetbrains.cidr.lang.workspace.headerRoots.HeadersSearchRoots; | ||
import java.io.File; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import javax.annotation.Nullable; | ||
|
||
/** Stub {@link OCCompilerSettings} for testing. */ | ||
class StubOCCompilerSettings implements OCCompilerSettings { | ||
private final Project project; | ||
private HeadersSearchRoots roots; | ||
|
||
StubOCCompilerSettings(Project project) { | ||
this.project = project; | ||
} | ||
|
||
@Override | ||
@Nullable | ||
public OCCompilerKind getCompilerKind() { | ||
return OCCompilerKind.CLANG; | ||
} | ||
|
||
@Override | ||
@Nullable | ||
public File getCompilerExecutable() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public File getCompilerWorkingDir() { | ||
return VfsUtilCore.virtualToIoFile(project.getBaseDir()); | ||
} | ||
|
||
@Override | ||
@Nullable | ||
public CidrCompilerSwitches getCompilerSwitches() { | ||
return new CidrSwitchBuilder().build(); | ||
} | ||
|
||
@Override | ||
public HeadersSearchRoots getHeadersSearchRoots() { | ||
return roots; | ||
} | ||
|
||
@Override | ||
public List<HeadersSearchPath> getHeadersSearchPaths() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public List<VirtualFile> getImplicitIncludes() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public List<String> getImplicitIncludeUrls() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public VirtualFile getMappedInclude(String include) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getMappedIncludeUrl(String include) { | ||
return ""; | ||
} | ||
|
||
@Override | ||
public List<String> getPreprocessorDefines() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public Map<OCCompilerFeatures.Type<?>, ?> getCompilerFeatures() { | ||
return new HashMap<>(); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public CompilerSettingsKey getCachingKey() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Object getIndexingCluster() { | ||
return null; | ||
} | ||
|
||
public void setLibraryIncludeRoots(List<HeadersSearchRoot> roots) { | ||
this.roots = HeadersSearchRoots.create(roots); | ||
} | ||
} |
Oops, something went wrong.