BowlerHatLLC / vscode-as3mxml

ActionScript & MXML language extension for Visual Studio Code. Develop apps for Adobe AIR, Adobe Flash Player, or Apache Royale.
https://as3mxml.com/
Apache License 2.0
256 stars 39 forks source link

"Find All References" never returns any results #746

Closed codeandcode123 closed 5 months ago

codeandcode123 commented 5 months ago

Hi. I'm using Adobe Animate to build apps for iOS and tried VS Code with your extension for coding since FlashDevelop is no longer available. Opened the code directory in VS Code. Syntax Highlighting and IntelliSense seem to work, but "Find All References" never returns any results. Are there any additional steps I should take to make it work?

Thanks in advance.

joshtynjala commented 5 months ago

Find all references seems to be working in my projects. Nothing special to configure it, except to have a valid asconfig.json file at the root of the project directory.

Do you have a project with asconfig.json, or are you opening .as files directly in VSCode without a project? If it's the latter, that might explain why references can't be found because some code intelligence features are only available in full projects.

codeandcode123 commented 5 months ago

Yes, there is a asconfig.json file. Perhaps something is missing? Here are the contents:

{
    "compilerOptions": {
        "source-path": [
            "."
        ],
        "default-frame-rate": 30,
        "default-background-color": "#FFFFFF",
        "default-size": {
            "width": 800,
            "height": 600
        },
        "target-player": "10.0",
        "accessible": false,
        "advanced-telemetry": false,
        "benchmark": false,
        "optimize": false,
        "omit-trace-statements": true,
        "show-unused-type-selector-warnings": true,
        "strict": true,
        "use-network": true,
        "use-resource-bundle-metadata": true,
        "warnings": true,
        "verbose-stacktraces": false,
        "static-link-runtime-shared-libraries": true
    }
}
joshtynjala commented 5 months ago

Typically, an asconfig.json file should contain one (but not both) of the following fields: mainClass or files, but you don't appear to have either of them. In VSCode's Problems view, it is probably reporting a warning that says Missing property "mainClass".. That's in reference to this issue.

I typically recommend mainClass instead of files. For an Animate project, mainClass in asconfig.json should be set to the same class that you use as your "Document Class" in Animate.

If you don't have a Document Class in Animate, you may need to create one just to make VSCode happy. Just call it Main.as or something, and then this is probably enough for the contents of the file:

package
{
    import flash.display.Sprite;

    public class Main extends Sprite // or MovieClip
    {
        public function Main()
        {

        }
    }
}

Then add it to asconfig.json:

{
    "compilerOptions": {
        "source-path": [
            "."
        ],
        "default-frame-rate": 30,
        "default-background-color": "#FFFFFF",
        "default-size": {
            "width": 800,
            "height": 600
        },
        "target-player": "10.0",
        "accessible": false,
        "advanced-telemetry": false,
        "benchmark": false,
        "optimize": false,
        "omit-trace-statements": true,
        "show-unused-type-selector-warnings": true,
        "strict": true,
        "use-network": true,
        "use-resource-bundle-metadata": true,
        "warnings": true,
        "verbose-stacktraces": false,
        "static-link-runtime-shared-libraries": true
    },
    mainClass: "Main"
}

You don't actually need to set it as your Document Class in Animate, but it shouldn't hurt if you do.

codeandcode123 commented 5 months ago

Thank you so much for your prompt responses!

I added "mainClass": "Main" to asconfig.json, but that didn't help. Then I opened the Problems view and found this warning: ActionScript & MXML code intelligence disabled. SDK not found.

Perhaps this helps?

joshtynjala commented 5 months ago

ActionScript & MXML code intelligence disabled. SDK not found.

https://github.com/BowlerHatLLC/vscode-as3mxml/wiki/Choose-an-ActionScript-SDK-for-the-current-workspace-in-Visual-Studio-Code

codeandcode123 commented 5 months ago

After selecting the SDK, I'm seeing 1K+ errors in the Problems view. Mostly "Call to a possibly undefined method ..." or "Type was not found or was not a compile-time constant ...".

joshtynjala commented 5 months ago

Which SDK did you use? Probably doesn't matter, but just out of curiosity.

If that code compiles correctly in Animate, then it's likely that those errors are related to Animate symbols that vscode-as3mxml has no way of knowing about. For instance, if you've given a library symbol a "linkage name" to make it available as a class, but you didn't associate it with an .as file. Similarly, Animate has a setting named something like "automatically declare stage instances" that declares variables for you, but vscode-as3mxml has no way of communicating with Animate to know about those instances. You would need to declare them manually.

It's interesting, though, that you said that you used to use FlashDevelop. It should have the same limitations. With that in mind, it may be possible to tweak some compiler options to fix your errors. I can't really suggest more without seeing the error messages, though.

codeandcode123 commented 5 months ago

I'm using AIR 50.2.4.5.

Yes, everything worked with FlashDevelop, but that was years ago.

If that code compiles correctly in Animate, then it's likely that those errors are related to Animate symbols that vscode-as3mxml has no way of knowing about.

That makes sense. Many errors seems to relate to automatically declared stage instances. Also, there's a lot of errors like Call to a possibly undefined method SQLConnection.

It seems that it will take a lot of work to update the project. I mainly wanted to use your extension to simplify jumping around the code with "Find All References" and "Go to Definition". If there's a quick way to make it work, please let me know. If not, thanks again for your all your suggestions and the insight.

joshtynjala commented 5 months ago

Also, there's a lot of errors like Call to a possibly undefined method SQLConnection.

You should be able to fix this by adding "config": "air" (or "config": "airmobile" for iOS/Android) to your asconfig.json.


{
    "config": "air",
    "compilerOptions": {
        "source-path": [
            "."
        ],
        // ...
    },
    mainClass: "Main"
}
codeandcode123 commented 5 months ago

Thank you!!!!!!!!!!!!!!!!!!!!!!!!! Added "config": "airmobile" and now "Find All References" and "Go to Definition" work. Also, the OUTLINE panel is functional. Thank you so much!