use of com.intellij.psi.impl.source.tree.TreeElement in project WebStormRequireJsPlugin by Fedott.
the class RequirejsProjectComponent method parseMapsConfig.
protected void parseMapsConfig(TreeElement mapElement) {
TreeElement firstMapConfigElement = (TreeElement) mapElement.findChildByType(JSElementTypes.PROPERTY);
parseMapConfigElement(firstMapConfigElement);
}
use of com.intellij.psi.impl.source.tree.TreeElement in project WebStormRequireJsPlugin by Fedott.
the class RequirejsProjectComponent method parseMapConfigElement.
protected void parseMapConfigElement(TreeElement mapConfigElement) {
if (null == mapConfigElement) {
return;
}
if (mapConfigElement.getElementType() == JSElementTypes.PROPERTY) {
String module = getJSPropertyName(mapConfigElement);
TreeElement mapAliasesObject = (TreeElement) mapConfigElement.findChildByType(JSElementTypes.OBJECT_LITERAL_EXPRESSION);
if (null != mapAliasesObject) {
RequireMapModule requireMapModule = new RequireMapModule();
requireMapModule.module = module;
TreeElement mapAliasProperty = (TreeElement) mapAliasesObject.findChildByType(JSElementTypes.PROPERTY);
parseMapAliasProperty(requireMapModule, mapAliasProperty);
requireMap.addModule(requireMapModule);
}
}
parseMapConfigElement(mapConfigElement.getTreeNext());
}
use of com.intellij.psi.impl.source.tree.TreeElement in project WebStormRequireJsPlugin by Fedott.
the class RequirejsProjectComponent method parseRequirejsConfig.
public void parseRequirejsConfig(TreeElement node) {
if (null == node) {
return;
}
try {
if (node.getElementType() == JSElementTypes.PROPERTY) {
TreeElement identifier = (TreeElement) node.findChildByType(JSTokenTypes.IDENTIFIER);
String identifierName = null;
if (null != identifier) {
identifierName = identifier.getText();
} else {
TreeElement identifierString = (TreeElement) node.findChildByType(JSTokenTypes.STRING_LITERAL);
if (null != identifierString) {
identifierName = dequote(identifierString.getText());
}
}
if (null != identifierName) {
if (identifierName.equals("baseUrl")) {
String baseUrl = null;
if (!settings.overrideBaseUrl) {
ASTNode baseUrlNode = node.findChildByType(JSElementTypes.LITERAL_EXPRESSION);
if (null != baseUrlNode) {
baseUrl = dequote(baseUrlNode.getText());
}
} else {
LOG.info("baseUrl override is enabled, overriding with '" + settings.baseUrl + "'");
baseUrl = settings.baseUrl;
}
if (null != baseUrl) {
LOG.info("Setting baseUrl to '" + baseUrl + "'");
setBaseUrl(baseUrl);
packageConfig.baseUrl = baseUrl;
} else {
LOG.debug("BaseUrl not set");
}
} else if (identifierName.equals("paths")) {
ASTNode pathsNode = node.findChildByType(JSElementTypes.OBJECT_LITERAL_EXPRESSION);
if (null != pathsNode) {
parseRequireJsPaths((TreeElement) pathsNode.getFirstChildNode());
}
} else if (identifierName.equals("packages")) {
TreeElement packages = (TreeElement) node.findChildByType(JSElementTypes.ARRAY_LITERAL_EXPRESSION);
LOG.debug("parsing packages");
parsePackages(packages);
LOG.debug("parsing packages done, found " + packageConfig.packages.size() + " packages");
} else if (identifierName.equals("map")) {
TreeElement mapElement = (TreeElement) node.findChildByType(JSElementTypes.OBJECT_LITERAL_EXPRESSION);
parseMapsConfig(mapElement);
}
}
}
} catch (NullPointerException exception) {
LOG.error(exception.getMessage(), exception);
}
TreeElement next = node.getTreeNext();
if (null != next) {
parseRequirejsConfig(next);
}
}
Aggregations