-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Refactor the `GlspElkLayoutEngine` and related concepts to properly support layout computation for ports. In this process we also opted out of trying to reuse the existing `SprottyElkLayoutEngine` and instead implement a new layout engine specifically for the GLSP graphmodel. This implementation is more in line with the Java ELK-Layout Engine and implements similar features like automatic detection of common ancestors of edge source/targets to correctly transform them in the ELK graph. - Removes the no longer needed `BasicTypeMapper` Also: - Provide utility functions for querying parent elements of a given element that match a predicate. (gmodel-util.ts) - Only rerexport the the subset of types that are really needed from "sprotty-elk" to avoid unncessary naming clashes. - Add jsdoc for `GModelSerializer` - Fix implementation of `getAllEdges` in `GModelIndex` - Remove unused (and unset) `source` and `target` references in `GEdge` Contributed on behalf of STMicroelectronics
- Loading branch information
Showing
21 changed files
with
662 additions
and
345 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2022 STMicroelectronics and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
import { GModelElement, GModelElementConstructor } from '.'; | ||
|
||
export type Predicate<T> = (element: T) => boolean; | ||
|
||
/** | ||
* Returns the first element matching the search predicate starting from the given | ||
* element and walking up the parent hierarchy. | ||
* | ||
* @param element The element to start the search from. | ||
* @param searchPredicate The predicate which the element should match. | ||
* @returns The first matching element or `undefined`. | ||
*/ | ||
export function findParent(element: GModelElement, searchPredicate: Predicate<GModelElement>): GModelElement | undefined { | ||
if (!element) { | ||
return undefined; | ||
} | ||
if (searchPredicate(element)) { | ||
return element; | ||
} | ||
const parent = element.parent; | ||
return parent ? findParent(parent, searchPredicate) : undefined; | ||
} | ||
|
||
/** | ||
* Returns the first parent element that is an instance of the given {@link GModelElementConstructor} starting from the given element. | ||
* (recursively walking up the parent hierarchy). | ||
* | ||
* @param element The element to start the search from. | ||
* @param constructor The queried parent class ({@link GModelElementConstructor}). | ||
* @returns The first matching parent element or `undefined`. | ||
*/ | ||
export function findParentByClass<G extends GModelElement>( | ||
element: GModelElement, | ||
constructor: GModelElementConstructor<G> | ||
): G | undefined { | ||
const predicate: Predicate<GModelElement> = element => element instanceof constructor; | ||
const result = findParent(element, predicate); | ||
if (result) { | ||
return result as G; | ||
} | ||
return undefined; | ||
} |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.