Giter Club home page Giter Club logo

dot-language-support's Introduction

dot-language-support CD CI Dependencies npm version

A language service library, written in TypeScript. Used by dot-language-server and edotor.net.

Features

  • Highlight semantic and syntactic errors
  • Auto completion for colors and shapes
  • Code Actions:
    • Refactoring Graphs to Digraphs and vice-versa
    • Fix wrong graph edges
    • Refactor edges to sub graphs

Installation

npm -S i dot-language-support

dot-language-support's People

Contributors

codetrix avatar dependabot[bot] avatar github-actions[bot] avatar nikeee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dot-language-support's Issues

Add Color Provider Support

On attributes like a [color=white], we could provide the color to the client, so it can display a colored box next to it.

Autocomplete stops working with edge attributes

If an edge already has some attributes, the user won't get suggestions when connecting another node with the edge.

Steps to reproduce:

digraph {
    music_bus [label="Which music would you like to listen to on the bus?"]
    breakfast [label="What breakfast do you want to eat?"]
    sell_game [label="Do you want to program bandersnatch at the company?"]

    music_bus -> breakfast [color=gray]
}

Place your cursor behind breakfast, type -> sel.

Expected behaviour: Get a suggestion for node sell_game. It will work when leaving out [color=gray]

Remove optional semicolons

graph {
    a -- b;
}

is the same as

graph {
    a -- b
}

We could provide a refactoring to remove all optional semicolons in the graph.

Wrong conversion from hex color string values

There is a bug in the color conversion code when converting from a hex color string into a Color object.

The bug manifests itself (on edotor.net) as:

  1. wrong color squares next to hex type color strings (for most part of the color range).
  2. wrong color being used for the currently selected color in the color picker when hovering over a hex type color string

Running this code snippet within the colorProvider.ts will show the bug

console.log(getColorStringFromColor(getHexCodeColor("#000000")))
console.log(getColorStringFromColor(getHexCodeColor("#ffffff")))
console.log(getColorStringFromColor(getHexCodeColor("#ff7f14")))
console.log(getColorStringFromColor(getHexCodeColor("#ff0000")))
console.log(getColorStringFromColor(getHexCodeColor("#00345678")))
console.log(getColorStringFromColor(getHexCodeColor("#ffabcdef")))

The expected output is

#000000
#ffffff
#ff7f14
#ff0000
#345678  // because getColorStringFromColor ignores alpha
#abcdef  // because getColorStringFromColor ignores alpha

The actual output produced by the current version of the code is

#000000
#ff0000ff00ff
#ff00007f0014
#ff00000000
#340000560078
#ab0000cd00ef

The lines

const colorInt = parseInt(hexCode, 16);
return {
red: (colorInt & 0x00ff0000) / 255.0,
green: (colorInt & 0x0000ff00) / 255.0,
blue: (colorInt & 0x00000ff) / 255.0,
alpha: hexCode.length === 8 ? (colorInt & 0xff00000) / 255.0 : 1.0,
};

Should be changed to

    const colorInt = parseInt(hexCode, 16); 
    return { 
 	red: (colorInt >> 16 & 0xff) / 255.0, 
 	green: (colorInt >> 8 & 0xff) / 255.0, 
 	blue: (colorInt & 0xff) / 255.0, 
 	alpha: hexCode.length === 8 ? (colorInt >> 24 & 0xff) / 255.0 : 1.0, 
     };

Running the code snippet again with the suggested patch applied generates the expected output

#000000
#ffffff
#ff7f14
#ff0000
#345678
#abcdef

Refactoring: Create Labeled Node

Before:

graph {
    a -- { b c }
    c -- b
}

(user refators b to new labeled node)

After:

graph {
    node_b [label="b"]
    a -- { node_b c }
    c -- node_b
}

Cannot read property 'kind' of undefined

I get the undefined 'kind' output when I hover over 'graph'. The preview updates with property changes, making me think this example is legit sytanx for the DOT engine.

digraph {
  graph [pad="0.5", nodesep="0.5", ranksep="2"];
  node [shape=none]
  rankdir=LR;

  Foo [label=<
  <table border="0" cellborder="1" cellspacing="0">
    <tr><td><i>Input Foo</i></td></tr>
    <tr><td port="1">one</td></tr>
    <tr><td port="2">two</td></tr>
    <tr><td port="3">three</td></tr>
    <tr><td port="4">four</td></tr>
    <tr><td port="5">five</td></tr>
    <tr><td port="6">six</td></tr>
  </table>>];

  Bar [label=<
  <table border="0" cellborder="1" cellspacing="0">
    <tr><td><i>Input Bar</i></td></tr>
    <tr><td port="1">seven</td></tr>
    <tr><td port="2">eight</td></tr>
    <tr><td port="3">nine</td></tr>
    <tr><td port="4">ten</td></tr>
  </table>>];

  Baz [label=<
  <table border="0" cellborder="1" cellspacing="0">
    <tr><td><i>Output Baz</i></td></tr>
    <tr><td port="a">alpha</td></tr>
    <tr><td port="b">bravo</td></tr>
    <tr><td port="c">charlie</td></tr>
    <tr><td port="d">delta</td></tr>
    <tr><td port="e">echo</td></tr>
    <tr><td port="f">foxtrot</td></tr>
  </table>>];

  Foo:2 -> Baz:a;
  Foo:3 -> Baz:e;
  Foo:6 -> Baz:b;
  Bar:1 -> Baz:d;
  Bar:3 -> Baz:f;
}

Add Formatting Support

We are currently unable to format the source of the graph.

Blocking: Handling comments.

Unknown shape "record".

Given that Edotor provides examples containing node [shape=record], I'd expect src/service/languageFacts.ts to contain "record" among known shapes, but the language server reports

Unknown shape "record".
(DOT4001)

[Feature Request] Node Label as Hover Text

I'm using this plugin and I love it so far. I think this can be more useful on larger graphs by showing a nodes label in the hover text.

For example, in the graph:

digraph G {
    vp [label="View Profile"];
    vf [label="View Friends"];
    ...
    vp -> vf;
}

When I move my cursor over vp, then bring up the hover text, I get (node) vp. I think it would be more helpful to show (node) vp: View Profile.

Is this possible?

Hovering on the edge does show node

  • Hovering the dash in a->b yields (node) a. It should yield (edge) a -> b.
  • Hovering the space in a ->b yields (node) a. It should yield (edge) a -> b or nothing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.