Search in sources :

Example 1 with NodePackage

use of com.intellij.javascript.nodejs.util.NodePackage in project intellij-plugins by JetBrains.

the class TsLintView method setState.

@Override
protected void setState(@NotNull TsLintState state) {
    myNodeModuleConfigurationView.getNodeInterpreterField().setInterpreterRef(state.getInterpreterRef());
    myNodeModuleConfigurationView.getPackageField().setSelected(new NodePackage(state.getPackagePath()));
    myConfigFileView.setCustomConfigFileUsed(state.isCustomConfigFileUsed());
    myConfigFileView.setCustomConfigFilePath(StringUtil.notNullize(state.getCustomConfigFilePath()));
    if (!StringUtil.isEmptyOrSpaces(state.getRulesDirectory())) {
        myRules.setText(state.getRulesDirectory());
    }
    myAllowJs.setSelected(state.isAllowJs());
    resizeOnSeparateDialog();
}
Also used : NodePackage(com.intellij.javascript.nodejs.util.NodePackage)

Example 2 with NodePackage

use of com.intellij.javascript.nodejs.util.NodePackage in project intellij-plugins by JetBrains.

the class KarmaRunConfiguration method readExternal.

@Override
public void readExternal(Element element) throws InvalidDataException {
    super.readExternal(element);
    myRunSettings = KarmaRunSettingsSerializationUtil.readXml(element);
    NodePackage karmaPackage = myRunSettings.getKarmaPackage();
    if ("true".equals(element.getAttributeValue("default")) && karmaPackage != null && karmaPackage.isEmptyPath()) {
        myRunSettings = myRunSettings.toBuilder().setKarmaPackage(null).build();
    }
}
Also used : NodePackage(com.intellij.javascript.nodejs.util.NodePackage)

Example 3 with NodePackage

use of com.intellij.javascript.nodejs.util.NodePackage in project intellij-plugins by JetBrains.

the class KarmaRunSettingsSerializationUtil method readXml.

public static KarmaRunSettings readXml(@NotNull Element element) {
    KarmaRunSettings.Builder builder = new KarmaRunSettings.Builder();
    builder.setConfigPath(JDOMExternalizerUtil.getFirstChildValueAttribute(element, CONFIG_FILE));
    builder.setBrowsers(JDOMExternalizerUtil.getFirstChildValueAttribute(element, BROWSERS));
    String karmaPackageDir = JDOMExternalizerUtil.getFirstChildValueAttribute(element, KARMA_PACKAGE_DIR);
    if (karmaPackageDir != null) {
        builder.setKarmaPackage(new NodePackage(karmaPackageDir));
    }
    String interpreterRefName = JDOMExternalizerUtil.getFirstChildValueAttribute(element, NODE_INTERPRETER);
    builder.setInterpreterRef(NodeJsInterpreterRef.create(interpreterRefName));
    EnvironmentVariablesData envData = EnvironmentVariablesData.readExternal(element);
    builder.setEnvData(envData);
    KarmaScopeKind scopeKind = readScopeKind(element);
    builder.setScopeKind(scopeKind);
    if (scopeKind == KarmaScopeKind.TEST_FILE) {
        builder.setTestFilePath(JDOMExternalizerUtil.getFirstChildValueAttribute(element, TEST_FILE_PATH));
    } else if (scopeKind == KarmaScopeKind.SUITE || scopeKind == KarmaScopeKind.TEST) {
        builder.setTestNames(readTestNames(element));
    }
    return builder.build();
}
Also used : KarmaScopeKind(com.intellij.javascript.karma.scope.KarmaScopeKind) EnvironmentVariablesData(com.intellij.execution.configuration.EnvironmentVariablesData) NodePackage(com.intellij.javascript.nodejs.util.NodePackage)

Example 4 with NodePackage

use of com.intellij.javascript.nodejs.util.NodePackage in project intellij-plugins by JetBrains.

the class KarmaRunConfiguration method setRunSettings.

public void setRunSettings(@NotNull KarmaRunSettings runSettings) {
    NodePackage newKarmaPackage = runSettings.getKarmaPackage();
    NodePackage oldKarmaPackage = myRunSettings.getKarmaPackage();
    if (newKarmaPackage == null || newKarmaPackage.equals(oldKarmaPackage)) {
        myRunSettings = runSettings;
        return;
    }
    Project project = getProject();
    if (!KarmaUtil.isPathUnderContentRoots(project, newKarmaPackage)) {
        KarmaProjectSettings.setKarmaPackage(project, newKarmaPackage);
        newKarmaPackage = new NodePackage("");
    }
    if (newKarmaPackage.isEmptyPath() && isTemplate()) {
        newKarmaPackage = null;
    }
    myRunSettings = runSettings.toBuilder().setKarmaPackage(newKarmaPackage).build();
}
Also used : Project(com.intellij.openapi.project.Project) NodePackage(com.intellij.javascript.nodejs.util.NodePackage)

Example 5 with NodePackage

use of com.intellij.javascript.nodejs.util.NodePackage in project intellij-plugins by JetBrains.

the class KarmaRunConfiguration method getOrInitKarmaPackage.

@NotNull
private NodePackage getOrInitKarmaPackage() {
    NodePackage pkg = myRunSettings.getKarmaPackage();
    if (pkg == null) {
        Project project = getProject();
        NodeJsLocalInterpreter interpreter = NodeJsLocalInterpreter.tryCast(myRunSettings.getInterpreterRef().resolve(project));
        pkg = NodePackage.findPreferredPackage(project, KarmaUtil.NODE_PACKAGE_NAME, interpreter);
        if (!pkg.isEmptyPath() && !KarmaUtil.isPathUnderContentRoots(project, pkg)) {
            NodePackage projectKarmaPackage = KarmaProjectSettings.getKarmaPackage(project);
            if (projectKarmaPackage.isEmptyPath()) {
                KarmaProjectSettings.setKarmaPackage(project, pkg);
            }
            pkg = new NodePackage("");
        }
        myRunSettings = myRunSettings.toBuilder().setKarmaPackage(pkg).build();
    }
    return pkg;
}
Also used : Project(com.intellij.openapi.project.Project) NodePackage(com.intellij.javascript.nodejs.util.NodePackage) NodeJsLocalInterpreter(com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreter) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NodePackage (com.intellij.javascript.nodejs.util.NodePackage)5 Project (com.intellij.openapi.project.Project)2 EnvironmentVariablesData (com.intellij.execution.configuration.EnvironmentVariablesData)1 KarmaScopeKind (com.intellij.javascript.karma.scope.KarmaScopeKind)1 NodeJsLocalInterpreter (com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreter)1 NotNull (org.jetbrains.annotations.NotNull)1