use of org.jetbrains.annotations.NotNull in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoCoverageCalculationTest method parseData.
@NotNull
private GoCoverageProjectData parseData(@NotNull String coverageSource) throws IOException {
try (BufferedReader reader = new BufferedReader(new FileReader(new File(getTestDataPath(), coverageSource)))) {
GoCoverageProjectData data = GoCoverageRunner.parseCoverage(reader, myFixture.getProject(), myModule);
assertNotNull(data);
return data;
}
}
use of org.jetbrains.annotations.NotNull in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoCoverageCalculationTest method getRoot.
@NotNull
private VirtualFile getRoot() {
VirtualFile root = myFixture.getTempDirFixture().getFile("");
assertNotNull(root);
return root;
}
use of org.jetbrains.annotations.NotNull in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoSdkUtil method getGoPathSources.
@NotNull
public static Collection<VirtualFile> getGoPathSources(@NotNull Project project, @Nullable Module module) {
if (module != null) {
return CachedValuesManager.getManager(project).getCachedValue(module, () -> {
Collection<VirtualFile> result = newLinkedHashSet();
Project project1 = module.getProject();
GoSdkService sdkService = GoSdkService.getInstance(project1);
if (sdkService.isAppEngineSdk(module)) {
ContainerUtil.addAllNotNull(result, ContainerUtil.mapNotNull(YamlFilesModificationTracker.getYamlFiles(project1, module), VirtualFile::getParent));
}
result.addAll(getInnerGoPathSources(project1, module));
return CachedValueProvider.Result.create(result, getSdkAndLibrariesCacheDependencies(project1, module, YamlFilesModificationTracker.getInstance(project1)));
});
}
return CachedValuesManager.getManager(project).getCachedValue(project, (CachedValueProvider<Collection<VirtualFile>>) () -> CachedValueProvider.Result.create(getInnerGoPathSources(project, null), getSdkAndLibrariesCacheDependencies(project, null, YamlFilesModificationTracker.getInstance(project))));
}
use of org.jetbrains.annotations.NotNull in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoRefactoringUtil method getOccurrences.
@NotNull
public static List<PsiElement> getOccurrences(@NotNull PsiElement pattern, @Nullable PsiElement context) {
if (context == null)
return Collections.emptyList();
List<PsiElement> occurrences = ContainerUtil.newArrayList();
PsiRecursiveElementVisitor visitor = new PsiRecursiveElementVisitor() {
@Override
public void visitElement(@NotNull PsiElement element) {
if (PsiEquivalenceUtil.areElementsEquivalent(element, pattern)) {
occurrences.add(element);
return;
}
super.visitElement(element);
}
};
context.acceptChildren(visitor);
return occurrences;
}
use of org.jetbrains.annotations.NotNull in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoRefactoringUtil method getSuggestedNames.
@NotNull
private static LinkedHashSet<String> getSuggestedNames(GoExpression expression, PsiElement context) {
// todo rewrite with names resolve; check occurrences contexts
if (expression.isEquivalentTo(context)) {
context = PsiTreeUtil.getParentOfType(context, GoBlock.class);
}
LinkedHashSet<String> usedNames = getNamesInContext(context);
LinkedHashSet<String> names = ContainerUtil.newLinkedHashSet();
NamesValidator namesValidator = LanguageNamesValidation.INSTANCE.forLanguage(GoLanguage.INSTANCE);
if (expression instanceof GoCallExpr) {
GoReferenceExpression callReference = PsiTreeUtil.getChildOfType(expression, GoReferenceExpression.class);
if (callReference != null) {
String name = StringUtil.decapitalize(callReference.getIdentifier().getText());
for (String candidate : NameUtil.getSuggestionsByName(name, "", "", false, false, false)) {
if (usedNames.contains(candidate))
continue;
if (!isValidName(namesValidator, candidate))
continue;
names.add(candidate);
}
}
}
GoType type = expression.getGoType(null);
String typeText = GoPsiImplUtil.getText(type);
if (StringUtil.isNotEmpty(typeText)) {
boolean array = GoTypeUtil.isIterable(type) && !GoTypeUtil.isString(type);
for (String candidate : NameUtil.getSuggestionsByName(typeText, "", "", false, false, array)) {
if (usedNames.contains(candidate) || typeText.equals(candidate))
continue;
if (!isValidName(namesValidator, candidate))
continue;
names.add(candidate);
}
}
if (names.isEmpty()) {
names.add(UniqueNameGenerator.generateUniqueName("i", usedNames));
}
return names;
}
Aggregations