Dart: find path to local script when using custom VM

First off, I'm loving using dart with webstorm, you guys have been doing great work indeed on improving the experience of developing with web tools.

I have a fairly abnormal setup, so I'm hoping to post here to get a gist if there is a current solution before opening an issue. In a nutshell, I'm trying without success to get the editor to recognize a local dart script I've imported, that is at a custom path. The result is that I get an error statement saying the imported file can't be found, nor can anything I define within that script file.  This taints my otherwise fantastic static analysis experience. :)

Details:

The script I'm trying to import is actually a bridge for a custom VM I'm embedding in a C++ application, using cinder and Cinder-Dart. The C++ application knows how to resolve the script location, but webstorm doesn't.  I tried adding a pubspec.yaml (this one) and referring to it by path from my dart script's pubspec.yaml, yet it tells me the pubspec.yaml file cannot be found. Here is what my dart script's pubspect.yaml file looks like:

 
name: my_project
dependencies:
  vector_math:
    git: https://github.com/johnmccutchan/vector_math.git
  cinder:
    path: ../../../../lib/Cinder-Dart/src/cidart
  

I have verified the above relative path is correct, but I am still getting the warning that the pubspec.yaml file cannot be found in that folder, nor does it fix the missing symbols in my script file. I'm I on the right track, or is there something else I could try? Or perhaps I've hit on a use case others have not yet.

Thanks for any help,
Rich

0
5 comments

How do your unresolved import statements look like?
If you had a file like ...../lib/Cinder-Dart/src/cidart/lib/foo.dart you'd be able to reference it via package:cinder/foo.dart, that's the standard way.

In fact errors in the editor and suggested quick fixes are powered by the Dart Analyzer Server from the Dart SDK. I'm not sure if this server is able to handle non-standard URI resolution. That's the question to the Google Dart team.

0
Avatar
Permanently deleted user

Thanks for the reply.  I was using a nonstandard URI, although I'd be happy to fix that if it made the analyzer happy. The problem is that the dart analyzer Webstorm is complaining when it sees my relative entry for the cinder package. Strangely, running 'pub get' from command line doesn't produce any error messages, just says 'Got dependencies!', although no symlinks have been added within the 'packages' folder.  I guess I need to bring this up on one of the dart lists to see what I should do.

By the way, my directory layout looks like this.  The following doesn't seem to be found by the analyzer:

 
import 'package:cinder/cinder.dart';

Not sure, did you add the 'lib' subpath for any particular reason?

Thanks again,
Rich

0
Avatar
Permanently deleted user

Hm, now when I look, there is no error message when I am on the pubspec.yaml page with that relative import (after Webstorm has been restarted, not sure if that is related), yet the analyzer in my dart source still tells me:

Error:(3, 8) Target of URI does not exist: 'package:cinder/cinder.dart'

I'm wondering, if the relative path is setup correctly should I be seeing any other symlinks under the packages folder? I'm not, wondering if that is wrong.  It'd be great to get this working, because otherwise the static analysis is so useful.

0
Avatar
Permanently deleted user

Ah hah, so I indeed need to place the contents of my package library files within the 'lib' folder, as per dart pub guidelines.  Nice, errors and warnings have gone away with that move.

I think the analyzer is a bit slow to update, once I made that change, I could run dartanalyzer from the command line and see the error message had gone away, but the code was still underscored red in webstorm until I a) switched to pubspec.yaml and ran 'pub get', and then switched back to my dart file.

Thanks again for the help..

Rich

0

Yes, lib folder has special meaning. Only there you can keep shared code.
Pub get is required to create symlinks, without it Dat Analysis Server can't resolve imports.
So looks like the problem is solved and your project setup is pretty much standard.
Glad to be of help.

0

Please sign in to leave a comment.