@Override @NotNull protected String getConfigurationName(@NotNull PsiFile file) { return "go run " + file.getName(); } }
@NotNull @Override protected String getConfigurationName(@NotNull PsiFile file) { return "Build " + file.getName() + " and run"; } }
public static boolean isTestFile(@Nullable PsiFile file) { return file instanceof GoFile && file.getName().endsWith(GoConstants.TEST_SUFFIX_WITH_EXTENSION); }
@NotNull @Override protected String getConfigurationName(@NotNull PsiFile file) { return file.getName(); } }
@NotNull @Override protected String getConfigurationName(@NotNull PsiFile file) { return file.getName(); } }
public static boolean isBuiltinFile(@Nullable PsiFile file) { return file instanceof GoFile && GoConstants.BUILTIN_PACKAGE_NAME.equals(((GoFile)file).getPackageName()) && GoConstants.BUILTIN_PACKAGE_NAME.equals(((GoFile)file).getImportPath(false)) && GoConstants.BUILTIN_FILE_NAME.equals(file.getName()); }
@NotNull @Override protected String getConfigurationName(@NotNull PsiFile file) { String packageName = BallerinaPsiImplUtil.getPackage(file); if (!packageName.equals("")) { return packageName + " module"; } else { return file.getName(); } } }
@Contract("null -> false") private static boolean isBallerinaTestFile(@Nullable PsiFile psiFile) { if (psiFile == null) { return false; } return psiFile.getName().endsWith(BallerinaConstants.BALLERINA_TEST_FILE_SUFFIX); }
/** * @param checkBuildFlags should be false for directly used files: go run gen.go */ private boolean matchFile(@NotNull PsiFile file, boolean checkBuildFlags) { if (!(file instanceof GoFile)) { // TODO support .c, .cpp and other return false; } if (((GoFile)file).hasCPathImport() && myTarget.cgoEnabled != ThreeState.YES) return false; return match(file.getName(), ((GoFile)file).getBuildFlags(), checkBuildFlags); }
@NotNull @Override public Collection<PsiElement> findTestsForClass(@NotNull PsiElement element) { PsiFile file = InjectedLanguageUtil.getTopLevelFile(element); if (file instanceof GoFile) { PsiDirectory directory = file.getContainingDirectory(); PsiFile testFile = directory.findFile(FileUtil.getNameWithoutExtension(file.getName()) + GoConstants.TEST_SUFFIX_WITH_EXTENSION); if (testFile != null) { return ContainerUtil.newSmartList(testFile); } } return Collections.emptyList(); }
@NotNull @Override public Collection<PsiElement> findClassesForTest(@NotNull PsiElement element) { PsiFile testFile = InjectedLanguageUtil.getTopLevelFile(element); if (testFile instanceof GoFile) { PsiDirectory directory = testFile.getContainingDirectory(); PsiFile sourceFile = directory.findFile(StringUtil.trimEnd(testFile.getName(), GoConstants.TEST_SUFFIX_WITH_EXTENSION) + EXTENSION); if (sourceFile != null) { return ContainerUtil.newSmartList(sourceFile); } } return Collections.emptyList(); }
currentClass = ((PsiJavaFileImpl) file).getPackageName() + "." + file.getName().split("\\.")[0]; generateClassLB.setText(currentClass); generateClassTF.setText(currentClass);
@NotNull private PsiReference findReference(@NotNull PsiFile file, int offset) { if (myReference != null) { fail("only one reference should be declared in a test case, see file: " + file.getName()); } PsiReference result = file.findReferenceAt(offset); if (result == null) { fail("no reference was found at mark in file: " + file.getName() + ", offset: " + offset); } return result; } }
public void testMethodWithTransitiveImport() { myFixture.addFileToProject("a.go", "package main; import `middle`; func main() { fmt.Println(middle.A.Method()) }"); myFixture.addFileToProject("middle/middle.go", "package middle; import `declaration`; var A *declaration.D = nil"); PsiFile file = myFixture.addFileToProject("declaration/declaration.go", "package declaration; type D struct {}; func (D) Met<caret>hod() {}"); myFixture.configureFromExistingVirtualFile(file.getVirtualFile()); Collection<UsageInfo> usages = myFixture.findUsages(myFixture.getElementAtCaret()); assertEquals(1, usages.size()); //noinspection ConstantConditions assertEquals("a.go", usages.iterator().next().getFile().getName()); }
Set<String> allTestFunctionNames = collectAllTestNames(allPackageFunctionNames, project, (GoFile)file); String fileNameWithoutTestPrefix = StringUtil.trimEnd(file.getName(), GoConstants.TEST_SUFFIX_WITH_EXTENSION) + ".go"; GlobalSearchScope packageScope = GoPackageUtil.packageScope(containingDirectory, ((GoFile)file).getCanonicalPackageName()); GlobalSearchScope scope = new GoUtil.ExceptTestsScope(packageScope);
private void processPsiFile(PsiFile referenceFile, PsiFile definitionFile, int refIndex, int noRefIndex, int defIndex) { String fileName = referenceFile.getName(); if (refIndex != -1) { myReference = findReference(referenceFile, refIndex); } if (noRefIndex != -1) { myReference = findReference(referenceFile, noRefIndex); myShouldBeResolved = false; } if (defIndex != -1) { if (myDefinition != null) { fail("only one definition should be allowed in a resolve test case, see file: " + fileName); } myDefinition = definitionFile.findElementAt(defIndex); if (myDefinition == null) { fail("no definition was found at mark in file: " + fileName + ", offset: " + defIndex); } } }
private void processPsiFile(PsiFile file, int refIndex, int noRefIndex, int defIndex) { String fileName = file.getName(); if (refIndex != -1) { myReference = findReference(file, refIndex); } if (noRefIndex != -1) { myReference = findReference(file, noRefIndex); myShouldBeResolved = false; } if (defIndex != -1) { if (myDefinition != null) { fail("only one definition should be allowed in a resolve test case, see file: " + fileName); } myDefinition = file.findElementAt(defIndex); if (myDefinition == null) { fail("no definition was found at mark in file: " + fileName + ", offset: " + defIndex); } } }
public void testSdkTestDataDirectory() { myFixture.configureByText("a.go", "package a; import `doc/testdata`; func _() { println(pkg.ExportedConst<caret>ant) } "); PsiReference reference = myFixture.getFile().findReferenceAt(myFixture.getCaretOffset()); PsiElement resolve = reference != null ? reference.resolve() : null; assertNotNull(resolve); assertEquals("pkg.go", resolve.getContainingFile().getName()); assertEmpty(myFixture.findUsages(resolve)); }