com.intellij.openapi.module.ModuleUtilCore Java Examples

The following examples show how to use com.intellij.openapi.module.ModuleUtilCore. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SdkComboBox.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
@SuppressWarnings("unchecked")
public <T extends MutableModuleExtension<?>> void insertModuleItems(@Nonnull T moduleExtension,
                                                                    @Nonnull NullableFunction<T, MutableModuleInheritableNamedPointer<Sdk>> sdkPointerFunction) {

  for (Module module : ModuleManager.getInstance(moduleExtension.getModule().getProject()).getModules()) {
    // dont add self module
    if (module == moduleExtension.getModule()) {
      continue;
    }

    ModuleExtension extension = ModuleUtilCore.getExtension(module, moduleExtension.getId());
    if (extension == null) {
      continue;
    }
    MutableModuleInheritableNamedPointer<Sdk> sdkPointer = sdkPointerFunction.fun((T)extension);
    if (sdkPointer != null) {
      // recursive depend
      if (sdkPointer.getModule() == moduleExtension.getModule()) {
        continue;
      }
      addItem(new ModuleExtensionSdkComboBoxItem(extension, sdkPointer));
    }
  }
}
 
Example #2
Source File: DaemonListeners.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static boolean canChangeFileSilently(@Nonnull PsiFileSystemItem file) {
  Project project = file.getProject();
  DaemonListeners listeners = getInstance(project);
  if (listeners == null) return true;

  if (listeners.cutOperationJustHappened) return false;
  VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile == null) return false;
  if (file instanceof PsiCodeFragment) return true;
  if (ScratchUtil.isScratch(virtualFile)) return listeners.canUndo(virtualFile);
  if (!ModuleUtilCore.projectContainsFile(project, virtualFile, false)) return false;
  Result vcs = listeners.vcsThinksItChanged(virtualFile);
  if (vcs == Result.CHANGED) return true;
  if (vcs == Result.UNCHANGED) return false;

  return listeners.canUndo(virtualFile);
}
 
Example #3
Source File: FlutterBuildActionGroup.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static Module findFlutterModule(@NotNull Project project, @NotNull VirtualFile file) {
  Module module = ModuleUtilCore.findModuleForFile(file, project);
  if (module == null) {
    return null;
  }
  if (FlutterModuleUtils.declaresFlutter(module)) {
    return module;
  }
  // We may get here if the file is in the Android module of a Flutter module project.
  VirtualFile parent = ModuleRootManager.getInstance(module).getContentRoots()[0].getParent();
  module = ModuleUtilCore.findModuleForFile(parent, project);
  if (module == null) {
    return null;
  }
  return FlutterModuleUtils.declaresFlutter(module) ? module : null;
}
 
Example #4
Source File: DirectoryChooser.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Nonnull
public Image getIcon() {
  if (myDirectory != null) {
    VirtualFile virtualFile = myDirectory.getVirtualFile();
    List<ContentFolder> contentFolders = ModuleUtilCore.getContentFolders(myDirectory.getProject());
    for (ContentFolder contentFolder : contentFolders) {
      VirtualFile file = contentFolder.getFile();
      if(file == null) {
        continue;
      }
      if(VfsUtil.isAncestor(file, virtualFile, false)) {
        return contentFolder.getType().getIcon(contentFolder.getProperties());
      }
    }
  }
  return AllIcons.Nodes.Folder;
}
 
Example #5
Source File: CSharpLanguageVersionResolver.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Nonnull
@RequiredReadAction
@Override
public LanguageVersion getLanguageVersion(@Nonnull Language language, @Nullable Project project, @Nullable VirtualFile virtualFile)
{
	if(project == null || virtualFile == null)
	{
		return CSharpLanguageVersionHelper.getInstance().getHighestVersion();
	}
	Module moduleForPsiElement = ModuleUtilCore.findModuleForFile(virtualFile, project);
	if(moduleForPsiElement == null)
	{
		return CSharpLanguageVersionHelper.getInstance().getHighestVersion();
	}
	CSharpSimpleModuleExtension extension = ModuleUtilCore.getExtension(moduleForPsiElement, CSharpSimpleModuleExtension.class);
	if(extension == null)
	{
		return CSharpLanguageVersionHelper.getInstance().getHighestVersion();
	}
	return CSharpLanguageVersionHelper.getInstance().getWrapper(extension.getLanguageVersion());
}
 
Example #6
Source File: IncompatibleDartPluginNotificationProvider.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
  if (!FlutterUtils.isFlutteryFile(file)) return null;

  final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
  if (psiFile == null) return null;

  if (psiFile.getLanguage() != DartLanguage.INSTANCE) return null;

  final Module module = ModuleUtilCore.findModuleForPsiElement(psiFile);
  if (module == null) return null;

  if (!FlutterModuleUtils.isFlutterModule(module)) return null;

  final Version minimumVersion = DartPlugin.getInstance().getMinimumVersion();
  final Version dartVersion = DartPlugin.getInstance().getVersion();
  if (dartVersion.minor == 0 && dartVersion.bugfix == 0) {
    return null; // Running from sources.
  }
  return dartVersion.compareTo(minimumVersion) < 0 ? createUpdateDartPanel(myProject, module, dartVersion.toCompactString(),
                                                                           getPrintableRequiredDartVersion()) : null;
}
 
Example #7
Source File: ModuleLayerWidget.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
protected WidgetState getWidgetState(@Nullable VirtualFile file) {
  if (file == null) {
    return WidgetState.HIDDEN;
  }

  Module module = ModuleUtilCore.findModuleForFile(file, getProject());
  if (module == null) {
    return WidgetState.HIDDEN;
  }
  ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
  Map<String, ModuleRootLayer> layers = moduleRootManager.getLayers();
  if (layers.size() == 1) {
    return WidgetState.HIDDEN;
  }

  String currentLayerName = moduleRootManager.getCurrentLayerName();
  return new WidgetState("Module Layer: " + currentLayerName, currentLayerName, true);
}
 
Example #8
Source File: ModulePointerTest.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void testDisposePointerFromUncommitedModifiableModel() throws Exception {
  final NamedPointer<Module> pointer = ModuleUtilCore.createPointer(getProject(), "xxx");

  final ModifiableModuleModel modifiableModel = getModuleManager().getModifiableModel();
  final Module module = modifiableModel.newModule("xxx", myProject.getBaseDir().getPath());
  assertSame(pointer, ModuleUtilCore.createPointer(module));
  assertSame(pointer, ModuleUtilCore.createPointer(getProject(), "xxx"));

  assertSame(module, pointer.get());
  assertEquals("xxx", pointer.getName());

  modifiableModel.dispose();

  assertNull(pointer.get());
  assertEquals("xxx", pointer.getName());
}
 
Example #9
Source File: AssemblyModule.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Nonnull
@RequiredReadAction
static AssemblyModule resolve(@Nonnull PsiElement element)
{
	Module module = ModuleUtilCore.findModuleForPsiElement(element);
	if(module != null)
	{
		return new ConsuloModuleAsAssemblyModule(module);
	}

	VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element);
	if(virtualFile != null)
	{
		VirtualFile rootFile = ArchiveVfsUtil.getVirtualFileForArchive(virtualFile);
		if(rootFile != null && rootFile.getFileType() == DotNetModuleFileType.INSTANCE)
		{
			return new DotNetModuleAsAssemblyModule(element.getProject(), rootFile);
		}
	}
	return UnknownAssemblyModule.INSTANCE;
}
 
Example #10
Source File: FileReferenceNode.java    From protobuf-jetbrains-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Returns target proto PSI file root node.
 */
@Nullable
public ProtoPsiFileRoot getTarget() {
    String filename = getFilename();
    if (filename == null) {
        return null;
    }
    Module module = ModuleUtilCore.findModuleForPsiElement(this);
    if (module != null) {
        return getTarget(filename, module);
    }
    // fallback: if we are inside of a dependency, current module is null
    // in this case we try to resolve reference in all dependencies of all modules
    // (might be not fully correct, but better than nothing)
    ModuleManager moduleManager = ModuleManager.getInstance(getProject());
    Module[] modules = moduleManager.getModules();
    for (Module m : modules) {
        ProtoPsiFileRoot target = getTarget(filename, m);
        if (target != null) {
            return target;
        }
    }
    return null;
}
 
Example #11
Source File: FindPopupScopeUIImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public ScopeType initByModel(@Nonnull FindModel findModel) {
  myDirectoryChooser.initByModel(findModel);

  final String dirName = findModel.getDirectoryName();
  if (!StringUtil.isEmptyOrSpaces(dirName)) {
    VirtualFile dir = LocalFileSystem.getInstance().findFileByPath(dirName);
    if (dir != null) {
      Module module = ModuleUtilCore.findModuleForFile(dir, myProject);
      if (module != null) {
        myModuleComboBox.setSelectedItem(module.getName());
      }
    }
  }

  ScopeType scope = getScope(findModel);
  ScopeType selectedScope = Arrays.stream(myComponents).filter(o -> o.first == scope).findFirst().orElse(null) == null ? myComponents[0].first : scope;
  if (selectedScope == MODULE) {
    myModuleComboBox.setSelectedItem(findModel.getModuleName());
  }
  return selectedScope;
}
 
Example #12
Source File: EventsList.java    From droidtestrec with Apache License 2.0 6 votes vote down vote up
protected static void checkForTestRoots(Module srcModule, Set<VirtualFile> testFolders) {
    testFolders.addAll(ModuleRootManager.getInstance(srcModule).getSourceRoots(JavaSourceRootType.TEST_SOURCE));

    removeGenerated(testFolders);
    //create test in the same module
    if (!testFolders.isEmpty()) return;

    //suggest to choose from all dependencies modules
    final HashSet<Module> modules = new HashSet<Module>();
    ModuleUtilCore.collectModulesDependsOn(srcModule, modules);
    for (Module module : modules) {
        testFolders.addAll(ModuleRootManager.getInstance(module).getSourceRoots(JavaSourceRootType.TEST_SOURCE));
    }

    removeGenerated(testFolders);
}
 
Example #13
Source File: BaseCSharpModuleExtension.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
@RequiredReadAction
public PsiElement[] getEntryPointElements()
{
	final List<DotNetTypeDeclaration> typeDeclarations = new ArrayList<DotNetTypeDeclaration>();
	Collection<DotNetLikeMethodDeclaration> methods = MethodIndex.getInstance().get("Main", getProject(), GlobalSearchScope.moduleScope(getModule()));
	for(DotNetLikeMethodDeclaration method : methods)
	{
		if(method instanceof CSharpMethodDeclaration && DotNetRunUtil.isEntryPoint((DotNetMethodDeclaration) method))
		{
			Module moduleForPsiElement = ModuleUtilCore.findModuleForPsiElement(method);
			// scope is broken?
			if(!getModule().equals(moduleForPsiElement))
			{
				continue;
			}
			ContainerUtil.addIfNotNull(typeDeclarations, ObjectUtil.tryCast(method.getParent(), DotNetTypeDeclaration.class));
		}
	}
	return ContainerUtil.toArray(typeDeclarations, DotNetTypeDeclaration.ARRAY_FACTORY);
}
 
Example #14
Source File: HaxeProjectSdkSetupValidator.java    From intellij-haxe with Apache License 2.0 6 votes vote down vote up
private SdkValidationResult validateSdk(Project project, VirtualFile file) {
  final Module module = ModuleUtilCore.findModuleForFile(file, project);
  if (module != null && !module.isDisposed()) {
    final Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
    if (sdk == null) {
      if (ModuleRootManager.getInstance(module).isSdkInherited()) {
        return PROJECT_SDK_NOT_DEFINED;
      }
      else {
        return MODULE_SDK_NOT_DEFINED;
      }
    }
    else {
      return validateSdkRoots(sdk);
    }
  }
  return null;
}
 
Example #15
Source File: TodoTreeBuilder.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * @return read-only iterator of all valid PSI files that can have T.O.D.O items
 * and which are located under specified {@code psiDirectory}.
 * @see FileTree#getFiles(VirtualFile)
 */
public Iterator<PsiFile> getFilesUnderDirectory(PsiDirectory psiDirectory) {
  List<VirtualFile> files = myFileTree.getFilesUnderDirectory(psiDirectory.getVirtualFile());
  List<PsiFile> psiFileList = new ArrayList<>(files.size());
  PsiManager psiManager = PsiManager.getInstance(myProject);
  for (VirtualFile file : files) {
    final Module module = ModuleUtilCore.findModuleForPsiElement(psiDirectory);
    if (module != null) {
      final boolean isInContent = ModuleRootManager.getInstance(module).getFileIndex().isInContent(file);
      if (!isInContent) continue;
    }
    if (file.isValid()) {
      PsiFile psiFile = psiManager.findFile(file);
      if (psiFile != null) {
        psiFileList.add(psiFile);
      }
    }
  }
  return psiFileList.iterator();
}
 
Example #16
Source File: AddUsingAction.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
private void execute0(final NamespaceReference namespaceReference)
{
	PsiDocumentManager.getInstance(myProject).commitAllDocuments();

	WriteCommandAction.runWriteCommandAction(myProject, () ->
	{
		addUsing(namespaceReference.getNamespace());

		String libraryName = namespaceReference.getLibraryName();
		if(libraryName != null)
		{
			Module moduleForFile = ModuleUtilCore.findModuleForPsiElement(myFile);
			if(moduleForFile != null)
			{
				ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(moduleForFile);

				final ModifiableRootModel modifiableModel = moduleRootManager.getModifiableModel();

				modifiableModel.addOrderEntry(new DotNetLibraryOrderEntryImpl((ModuleRootLayerImpl) moduleRootManager.getCurrentLayer(), libraryName));

				WriteAction.run(modifiableModel::commit);
			}
		}
	});
}
 
Example #17
Source File: BundleBox.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@SuppressWarnings("unchecked")
public <T extends MutableModuleExtension<?>> void addModuleExtensionItems(@Nonnull T moduleExtension, @Nonnull Function<T, MutableModuleInheritableNamedPointer<Sdk>> sdkPointerFunction) {
  MutableListModel<BundleBoxItem> listModel = (MutableListModel<BundleBoxItem>)myOriginalComboBox.getListModel();

  for (Module module : ModuleManager.getInstance(moduleExtension.getModule().getProject()).getModules()) {
    // dont add self module
    if (module == moduleExtension.getModule()) {
      continue;
    }

    ModuleExtension extension = ModuleUtilCore.getExtension(module, moduleExtension.getId());
    if (extension == null) {
      continue;
    }
    MutableModuleInheritableNamedPointer<Sdk> sdkPointer = sdkPointerFunction.apply((T)extension);
    if (sdkPointer != null) {
      // recursive depend
      if (sdkPointer.getModule() == moduleExtension.getModule()) {
        continue;
      }

      listModel.add(new ModuleExtensionBundleBoxItem(extension, sdkPointer));
    }
  }
}
 
Example #18
Source File: CSharpLanguageVersionPointer.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
public String getItemNameFromModule(@Nonnull Module module)
{
	final CSharpSimpleModuleExtension extension = (CSharpSimpleModuleExtension) ModuleUtilCore.getExtension(module, myExtensionId);
	if(extension != null)
	{
		return extension.getLanguageVersion().getName();
	}
	return null;
}
 
Example #19
Source File: CSharpCustomCompilerSdkPointer.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
public String getItemNameFromModule(@Nonnull Module module)
{
	final CSharpModuleExtension<?> extension = (CSharpModuleExtension) ModuleUtilCore.getExtension(module, myExtensionId);
	if(extension != null)
	{
		return extension.getCustomCompilerSdkPointer().getName();
	}
	return null;
}
 
Example #20
Source File: CSharpLanguageVersionPointer.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
public CSharpLanguageVersion getItemFromModule(@Nonnull Module module)
{
	final CSharpSimpleModuleExtension extension = (CSharpSimpleModuleExtension) ModuleUtilCore.getExtension(module, myExtensionId);
	if(extension != null)
	{
		return extension.getLanguageVersion();
	}
	return null;
}
 
Example #21
Source File: CSharpCustomCompilerSdkPointer.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
public Sdk getItemFromModule(@Nonnull Module module)
{
	final CSharpModuleExtension<?> extension = (CSharpModuleExtension) ModuleUtilCore.getExtension(module, myExtensionId);
	if(extension != null)
	{
		return extension.getCustomCompilerSdkPointer().get();
	}
	return null;
}
 
Example #22
Source File: UnitySpecificMethodCompletion.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
@Override
public void processCompletion(@Nonnull CompletionParameters completionParameters,
		@Nonnull ProcessingContext processingContext,
		@Nonnull Consumer<LookupElement> completionResultSet,
		@Nonnull CSharpTypeDeclaration typeDeclaration)
{
	Unity3dModuleExtension extension = ModuleUtilCore.getExtension(typeDeclaration, Unity3dModuleExtension.class);
	if(extension == null)
	{
		return;
	}

	for(Map.Entry<String, Map<String, UnityFunctionManager.FunctionInfo>> entry : UnityFunctionManager.getInstance().getFunctionsByType().entrySet())
	{
		String typeName = entry.getKey();

		if(!DotNetInheritUtil.isParent(typeName, typeDeclaration, true))
		{
			continue;
		}

		for(UnityFunctionManager.FunctionInfo functionInfo : entry.getValue().values())
		{
			UnityFunctionManager.FunctionInfo nonParameterListCopy = functionInfo.createNonParameterListCopy();
			if(nonParameterListCopy != null)
			{
				completionResultSet.consume(buildLookupItem(nonParameterListCopy, typeDeclaration));
			}

			completionResultSet.consume(buildLookupItem(functionInfo, typeDeclaration));
		}
	}
}
 
Example #23
Source File: CSharpHighlightContext.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
protected DotNetSimpleModuleExtension<?> compute()
{
	Module value = myModuleValue.getValue();
	if(value == null)
	{
		return null;
	}
	return ModuleUtilCore.getExtension(value, DotNetSimpleModuleExtension.class);
}
 
Example #24
Source File: ExternalSystemApiUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Contract("null -> false, _")
public static String getExtensionSystemOption(@Nullable Module module, @Nonnull String key) {
  if (module == null) {
    return null;
  }
  ExternalSystemModuleExtension extension = ModuleUtilCore.getExtension(module, ExternalSystemModuleExtension.class);
  if (extension == null) {
    return null;
  }
  return extension.getOption(key);
}
 
Example #25
Source File: UnityScriptFileProjectViewProvider.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
@Nonnull
private Collection<AbstractTreeNode> doModify(Collection<AbstractTreeNode> children, ViewSettings settings)
{
	Unity3dRootModuleExtension rootModuleExtension = Unity3dModuleExtensionUtil.getRootModuleExtension(myProject);
	if(rootModuleExtension == null)
	{
		return children;
	}

	List<AbstractTreeNode> nodes = new ArrayList<>(children.size());
	for(AbstractTreeNode child : children)
	{
		ProgressManager.checkCanceled();

		Object value = child.getValue();
		if(value instanceof JSFile && ((JSFile) value).getFileType() == JavaScriptFileType.INSTANCE)
		{
			Module moduleForPsiElement = ModuleUtilCore.findModuleForPsiElement((PsiElement) value);
			if(moduleForPsiElement != null)
			{
				nodes.add(new UnityScriptFileNode(myProject, (PsiFile) value, settings));
				continue;
			}
		}
		nodes.add(child);
	}
	return nodes;
}
 
Example #26
Source File: UnityScriptLineBreakpointTypeResolver.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public XLineBreakpointType<?> resolveBreakpointType(@Nonnull Project project, @Nonnull VirtualFile virtualFile, int line)
{
	Unity3dScriptModuleExtension extension = ModuleUtilCore.getExtension(project, virtualFile, Unity3dScriptModuleExtension.class);
	if(extension != null)
	{
		return DotNetLineBreakpointType.getInstance();
	}
	return null;
}
 
Example #27
Source File: PsiProximityComparator.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public static WeighingComparable<PsiElement, ProximityLocation> getProximity(final Computable<? extends PsiElement> elementComputable, final PsiElement context, ProcessingContext processingContext) {
  PsiElement element = elementComputable.compute();
  if (element == null || context == null) return null;
  Module contextModule = processingContext.get(MODULE_BY_LOCATION);
  if (contextModule == null) {
    contextModule = ModuleUtilCore.findModuleForPsiElement(context);
    processingContext.put(MODULE_BY_LOCATION, contextModule);
  }

  return new WeighingComparable<>(elementComputable, new ProximityLocation(context, contextModule, processingContext), getProximityWeighers());
}
 
Example #28
Source File: Unity3dProjectService.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
@RequiredReadAction
protected CacheValue compute()
{
	Module rootModule = findRootModuleImpl(myProject);
	return new CacheValue(rootModule, rootModule == null ? null : ModuleUtilCore.getExtension(rootModule, Unity3dRootModuleExtension.class));
}
 
Example #29
Source File: OSSPantsJvmRunConfigurationIntegrationTest.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
private ConfigurationContext createContext(@NotNull PsiElement psiClass, @NotNull MapDataContext dataContext) {
  dataContext.put(CommonDataKeys.PROJECT, myProject);
  if (LangDataKeys.MODULE.getData(dataContext) == null) {
    dataContext.put(LangDataKeys.MODULE, ModuleUtilCore.findModuleForPsiElement(psiClass));
  }
  dataContext.put(Location.DATA_KEY, PsiLocation.fromPsiElement(psiClass));
  return ConfigurationContext.getFromContext(dataContext);
}
 
Example #30
Source File: BlazeRenderErrorContributorTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
private RenderErrorModel createRenderErrorModelWithMissingClasses(String... classNames) {
  PsiFile file = new MockPsiFile(new MockPsiManager(project));
  file.putUserData(ModuleUtilCore.KEY_MODULE, module);
  RenderResult result = RenderResult.createBlank(file);
  for (String className : classNames) {
    result.getLogger().addMissingClass(className);
  }
  return RenderErrorModelFactory.createErrorModel(null, result, null);
}