All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jetbrains.pluginverifier.dependencies.processing.DependenciesGraphCycleFinder.kt Maven / Gradle / Ivy

Go to download

JetBrains Plugin Verifier Classes for IntelliJ Platform integration with API usage detection and reporting.

There is a newer version: 1.381
Show newest version
/*
 * Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
 */

package com.jetbrains.pluginverifier.dependencies.processing

import com.jetbrains.pluginverifier.dependencies.DependenciesGraph
import com.jetbrains.pluginverifier.dependencies.DependencyNode
import org.jgrapht.Graph
import org.jgrapht.alg.cycle.JohnsonSimpleCycles
import org.jgrapht.graph.DefaultDirectedGraph
import org.jgrapht.graph.DefaultEdge

data class DependenciesGraphCycleFinder(val dependenciesGraph: DependenciesGraph) {

  fun findAllCycles(): List> {
    val graph: Graph = DefaultDirectedGraph(DefaultEdge::class.java)
    dependenciesGraph.vertices.forEach { graph.addVertex(it) }
    dependenciesGraph.edges.forEach { graph.addEdge(it.from, it.to) }
    //TODO: solve the problem here actually
    return try {
      JohnsonSimpleCycles(graph).findSimpleCycles()
    } catch (e: Exception) {
      emptyList()
    }
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy