PhpStorm不会自动完成JavaScript本机方法或属性

时间:2013-12-14 18:54:13

标签: javascript autocomplete ide phpstorm

我使用PhpStorm,我注意到在编写JavaScript时,IDE不会自动完成PhpStorm应该知道的变量的本机方法或属性。

var checkButton = document.forms.addSeller.check;
checkButton.onclick = function(e) {
    e.preventDefault();
    var request = new XMLHttpRequest;
    request.open("POST", "/seller");
    request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    request.onload = function() {
        if (request.readyState == 4) {
            if (request.status == 200) {
                var response = JSON.parse(request.responseText);
                console.log(response);
                var target = document.getElementById("seller_info");
                var image = document.createElement("img");
                image.src = response.logo;
                image.id = "seller_logo";
                target.appendChild(image);
            }
            else {
                alert("Problem!");
            }
        }
    };
    request.send("seller=" + document.forms.addSeller.seller.value);
}

所有方法(.preventDefault().open().setRequestHeader())或属性(.onload.onclick)均未自动完成。

据我所知,设置看起来很好,但我没有找到特定的JavaScript自动完成设置。

任何人都知道如何重新启用它? PhpStorm 100%知道它们是哪些对象,因为它可以很好地进行语法高亮和错误报告,当我 CTRL +单击一个方法/属性时,它将打开PhpStorm的内部语法正确符号上的文件。

3 个答案:

答案 0 :(得分:2)

请尝试File | Invalidate Caches | Invalidate and Restart,如果遇到如此奇怪的问题,通常会有所帮助。

答案 1 :(得分:0)

    2017-07-21 16:18:35,129 [ 290368]  ERROR - on.CompletionProgressIndicator - PhpStorm 2017.2  Build #PS-172.3317.83 
2017-07-21 16:18:35,129 [ 290368]  ERROR - on.CompletionProgressIndicator - JDK: 1.8.0_152-release 
2017-07-21 16:18:35,129 [ 290368]  ERROR - on.CompletionProgressIndicator - VM: OpenJDK 64-Bit Server VM 
2017-07-21 16:18:35,129 [ 290368]  ERROR - on.CompletionProgressIndicator - Vendor: JetBrains s.r.o 
2017-07-21 16:18:35,129 [ 290368]  ERROR - on.CompletionProgressIndicator - OS: Mac OS X 
2017-07-21 16:18:35,129 [ 290368]  ERROR - on.CompletionProgressIndicator - Last Action: CodeCompletion 
2017-07-21 16:18:35,275 [ 290514]  ERROR - on.CompletionProgressIndicator - null 
java.lang.NullPointerException
    at com.jetbrains.php.lang.psi.resolve.types.PhpParameterBasedTypeProvider.isMeta(PhpParameterBasedTypeProvider.java:318)
    at com.jetbrains.php.lang.inspections.suppression.PhpSuppressionUtil.isSuppressedFor(PhpSuppressionUtil.java:49)
    at com.jetbrains.php.lang.inspections.suppression.PhpInspectionSuppressor.isSuppressedFor(PhpInspectionSuppressor.java:12)
    at com.intellij.codeInspection.InspectionProfileEntry.isSuppressed(InspectionProfileEntry.java:167)
    at com.intellij.codeInspection.InspectionProfileEntry.isSuppressedFor(InspectionProfileEntry.java:82)
    at com.intellij.lang.javascript.frameworks.webpack.WebpackInJavaScriptJsonSchemaProvider.isWebpackInspectionAllowed(WebpackInJavaScriptJsonSchemaProvider.java:87)
    at com.intellij.lang.javascript.frameworks.webpack.WebpackInJavaScriptJsonSchemaProvider.isAvailable(WebpackInJavaScriptJsonSchemaProvider.java:51)
    at com.intellij.lang.javascript.json.JsonSchemaInJavaScriptCompletionContributor.lambda$fillCompletionVariants$0(JsonSchemaInJavaScriptCompletionContributor.java:24)
    at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174)
    at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
    at com.intellij.lang.javascript.json.JsonSchemaInJavaScriptCompletionContributor.fillCompletionVariants(JsonSchemaInJavaScriptCompletionContributor.java:25)
    at com.intellij.codeInsight.completion.CompletionService.getVariantsFromContributors(CompletionService.java:81)
    at com.intellij.codeInsight.completion.CompletionResultSet.runRemainingContributors(CompletionResultSet.java:149)
    at com.intellij.codeInsight.completion.CompletionResultSet.runRemainingContributors(CompletionResultSet.java:142)
    at com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor$2.addCompletions(LiveTemplateCompletionContributor.java:88)
    at com.intellij.codeInsight.completion.CompletionProvider.addCompletionVariants(CompletionProvider.java:36)
    at com.intellij.codeInsight.completion.CompletionContributor.fillCompletionVariants(CompletionContributor.java:150)
    at com.intellij.codeInsight.completion.CompletionService.getVariantsFromContributors(CompletionService.java:81)
    at com.intellij.codeInsight.completion.CompletionService.performCompletion(CompletionService.java:110)
    at com.intellij.codeInsight.completion.CompletionProgressIndicator.a(CompletionProgressIndicator.java:839)
    at com.intellij.codeInsight.completion.CompletionProgressIndicator.access$600(CompletionProgressIndicator.java:92)
    at com.intellij.codeInsight.completion.CompletionProgressIndicator$1CalculateItems.run(CompletionProgressIndicator.java:821)
    at com.intellij.codeInsight.completion.AsyncCompletion.a(CompletionThreading.java:108)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:939)
    at com.intellij.codeInsight.completion.AsyncCompletion.b(CompletionThreading.java:105)
    at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:170)
    at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:548)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:493)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:94)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:157)
    at com.intellij.codeInsight.completion.AsyncCompletion.a(CompletionThreading.java:103)
    at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:343)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
2017-07-21 16:18:35,275 [ 290514]  ERROR - on.CompletionProgressIndicator - PhpStorm 2017.2  Build #PS-172.3317.83 
2017-07-21 16:18:35,275 [ 290514]  ERROR - on.CompletionProgressIndicator - JDK: 1.8.0_152-release 
2017-07-21 16:18:35,275 [ 290514]  ERROR - on.CompletionProgressIndicator - VM: OpenJDK 64-Bit Server VM 
2017-07-21 16:18:35,275 [ 290514]  ERROR - on.CompletionProgressIndicator - Vendor: JetBrains s.r.o 
2017-07-21 16:18:35,275 [ 290514]  ERROR - on.CompletionProgressIndicator - OS: Mac OS X 
2017-07-21 16:18:35,275 [ 290514]  ERROR - on.CompletionProgressIndicator - Last Action: CodeCompletion 

这是我的日志文件。

我的示例代码。

<script>
            $(function () {
                $("form#form_newGorevAdd").on("submit", function (e) {
                    e.preventDefault();

                    var $form = $(this);


                    document. /////// THIS IS PROBLEM. phpstorm doesnt show a list. 


                    $ajaxFullLoader.fadeIn(500);
                    $.ajax({
                        url: 'admin/ajax/gorev/add',
                        type: 'POST',
                        data: $form.serialize(),
                        success: function (data) {
                            $ajaxFullLoader.fadeOut(500);

                            if(data.status === 1){
                                $form[0].reset();
                                $("#newGorevAdd").modal("close");
                                swal({
                                    title: "Başarılı!",
                                    html: data.message,
                                    type:"success"
                                });
                                table_gorevList.ajax.reload();
                            }
                            else{
                                if(data.errors && data.errors.length > 0)
                                    $.fn.ajaxError(data.errors.join("<br />"));
                                else
                                    $.fn.ajaxError();
                            }
                        }
                    });
                });
            });
        </script>

此问题与powersave模式无关。

PhpStorm 2017.2上发生此错误

PhpStorm 2017.2
Build #PS-172.3317.83, built on July 18, 2017
Subscription is active until November 25, 2017
For educational use only.
JRE: 1.8.0_152-release-915-b5 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.5

并在PhpStorm 2017.1上自动完成工作

php自动完成工作也很好。此文件是包含javascript代码的php文件。我是用标签

拆分php和html / javascript代码

如果文件扩展名为.js,则使用自动完成功能。我的文件有.php ext,包含php,html和javascript代码。

答案 2 :(得分:0)

我知道,这个话题很旧,但是我在PhpStorm 2020.1中遇到了同样的问题。 JetBrains的支持为我解决了很多问题。

我的问题是,我使用了拼写插件(TYPO3)。 *。ts 文件类型已添加到打字稿文件中,并已删除为打字稿。

所以我不得不再次添加 *。d.ts 到打字稿(我仍然使用* .ts作为打字稿)。 intellij以某种方式使用* .d.ts文件完成代码。至少对于JS。

此后,一切都像灵符一样。