本文整理匯總了Java中com.intellij.lang.javascript.JavaScriptSupportLoader類的典型用法代碼示例。如果您正苦於以下問題:Java JavaScriptSupportLoader類的具體用法?Java JavaScriptSupportLoader怎麽用?Java JavaScriptSupportLoader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JavaScriptSupportLoader類屬於com.intellij.lang.javascript包,在下文中一共展示了JavaScriptSupportLoader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findPackageForMxml
import com.intellij.lang.javascript.JavaScriptSupportLoader; //導入依賴的package包/類
public static String findPackageForMxml(final PsiElement expression)
{
String s = null;
final PsiFile containingFile = expression.getContainingFile();
if(containingFile.getLanguage() == JavaScriptSupportLoader.ECMA_SCRIPT_L4 && containingFile.getContext() != null)
{
final PsiFile contextContainigFile = containingFile.getContext().getContainingFile();
VirtualFile file = contextContainigFile.getVirtualFile();
if(file == null && contextContainigFile.getOriginalFile() != null)
{
file = contextContainigFile.getOriginalFile().getVirtualFile();
}
s = getExpectedPackageNameFromFile(file, containingFile.getProject(), true);
}
return s;
}
示例2: getClassFromTagNameInMxml
import com.intellij.lang.javascript.JavaScriptSupportLoader; //導入依賴的package包/類
public static JSClass getClassFromTagNameInMxml(final PsiElement psiElement)
{
XmlTag tag = psiElement != null ? PsiTreeUtil.getNonStrictParentOfType(psiElement, XmlTag.class) : null;
if(tag != null && (tag.getNamespacePrefix().length() > 0 || JavaScriptSupportLoader.isFlexMxmFile(tag.getContainingFile())))
{
if(isScriptContextTag(tag))
{
tag = ((XmlFile) tag.getContainingFile()).getDocument().getRootTag();
}
final XmlElementDescriptor descriptor = tag.getDescriptor();
if(descriptor != null)
{
PsiElement decl = descriptor.getDeclaration();
if(decl instanceof JSClass)
{
return ((JSClass) decl);
}
else if(decl instanceof XmlFile)
{
return XmlBackedJSClassImpl.getXmlBackedClass((XmlFile) decl);
}
}
}
return null;
}
示例3: findScriptNs
import com.intellij.lang.javascript.JavaScriptSupportLoader; //導入依賴的package包/類
public static String findScriptNs(XmlTag rootTag)
{
String ns = rootTag.getNamespace();
if(JavaScriptSupportLoader.isFlexMxmFile(rootTag.getContainingFile()))
{
ns = "";
for(String testNs : JavaScriptSupportLoader.MXML_URIS)
{
if(rootTag.getPrefixByNamespace(testNs) != null)
{
ns = testNs;
break;
}
}
}
return ns;
}
示例4: getNames
import com.intellij.lang.javascript.JavaScriptSupportLoader; //導入依賴的package包/類
@NotNull
@Override
public String[] getNames(Project project, boolean includeNonProjectItems)
{
final Set<String> result = new HashSet<String>();
result.addAll(StubIndex.getInstance().getAllKeys(JavaScriptIndexKeys.ELEMENTS_BY_NAME, project));
FileBasedIndex.getInstance().processAllKeys(FilenameIndex.NAME, new Processor<String>()
{
@Override
public boolean process(String s)
{
if(JavaScriptSupportLoader.isFlexMxmFile(s))
{
result.add(FileUtil.getNameWithoutExtension(s));
}
return true;
}
}, project);
return result.toArray(new String[result.size()]);
}
示例5: actionPerformed
import com.intellij.lang.javascript.JavaScriptSupportLoader; //導入依賴的package包/類
@Override
public void actionPerformed(final AnActionEvent e)
{
Editor editor = e.getData(PlatformDataKeys.EDITOR);
PsiFile psifile = e.getData(LangDataKeys.PSI_FILE);
Project project = e.getData(PlatformDataKeys.PROJECT);
final VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE);
if(JavaScriptSupportLoader.isFlexMxmFile(file))
{
editor = BaseCodeInsightAction.getInjectedEditor(project, editor);
psifile = PsiUtilBase.getPsiFileInEditor(editor, project);
}
new JavaScriptGenerateAccessorHandler(getGenerationMode()).invoke(project, editor, psifile);
}
示例6: process
import com.intellij.lang.javascript.JavaScriptSupportLoader; //導入依賴的package包/類
private static void process(final JSNamedElement node, final ProblemsHolder holder)
{
if(node.getContainingFile().getLanguage() != JavaScriptSupportLoader.ECMA_SCRIPT_L4)
{
return;
}
PsiElement nameIdentifier = node.getNameIdentifier();
if(nameIdentifier != null &&
JSPsiImplUtils.getTypeFromDeclaration(node) == null &&
(!(node instanceof JSParameter) || !((JSParameter) node).isRest()))
{
holder.registerProblem(nameIdentifier, JavaScriptBundle.message(node instanceof JSFunction ? "js.untyped.function.problem" : "js.untyped" +
".variable.problem", nameIdentifier.getText()), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new AddTypeToDclFix());
}
}
示例7: EmberJSParser
import com.intellij.lang.javascript.JavaScriptSupportLoader; //導入依賴的package包/類
public EmberJSParser(PsiBuilder builder) {
super(JavaScriptSupportLoader.JAVASCRIPT_1_5, builder);
myExpressionParser = new EmberJSExpressionParser();
myStatementParser = new StatementParser<EmberJSParser>(this) {
@Override
protected void doParseStatement(boolean canHaveClasses) {
final IElementType firstToken = builder.getTokenType();
if (firstToken == JSTokenTypes.LBRACE) {
parseExpressionStatement();
checkForSemicolon();
return;
}
if (isIdentifierToken(firstToken)) {
final IElementType nextToken = builder.lookAhead(1);
if (nextToken == JSTokenTypes.IN_KEYWORD) {
parseInStatement();
return;
}
}
if (builder.getTokenType() == JSTokenTypes.LPAR) {
if (parseInStatement()) {
return;
}
}
super.doParseStatement(canHaveClasses);
}
private boolean parseInStatement() {
PsiBuilder.Marker statement = builder.mark();
if (!getExpressionParser().parseInExpression()) {
statement.drop();
return false;
}
statement.done(JSElementTypes.EXPRESSION_STATEMENT);
return true;
}
};
}
示例8: doGenerateDoc
import com.intellij.lang.javascript.JavaScriptSupportLoader; //導入依賴的package包/類
private static String doGenerateDoc(final JSFunction function)
{
StringBuilder builder = new StringBuilder();
final JSParameterList parameterList = function.getParameterList();
final PsiFile containingFile = function.getContainingFile();
final boolean ecma = containingFile.getLanguage() == JavaScriptSupportLoader.ECMA_SCRIPT_L4;
if(parameterList != null)
{
for(JSParameter parameter : parameterList.getParameters())
{
builder.append("* @param ").append(parameter.getName());
//String s = JSPsiImplUtils.getTypeFromDeclaration(parameter);
//if (s != null) builder.append(" : ").append(s);
builder.append("\n");
}
}
if(ecma)
{
String s = JSPsiImplUtils.getTypeFromDeclaration(function);
if(s != null && !"void".equals(s))
{
builder.append("* @return ");
//builder.append(s);
builder.append("\n");
}
}
return builder.toString();
}
示例9: findElementsByName
import com.intellij.lang.javascript.JavaScriptSupportLoader; //導入依賴的package包/類
public static Collection<JSQualifiedNamedElement> findElementsByName(String name, Project project, GlobalSearchScope scope)
{
final Set<JSQualifiedNamedElement> result = new HashSet<JSQualifiedNamedElement>();
Collection<JSQualifiedNamedElement> jsQualifiedNamedElements = StubIndex.getElements(JavaScriptIndexKeys.ELEMENTS_BY_NAME, name, project, scope, JSQualifiedNamedElement.class);
for(JSQualifiedNamedElement e : jsQualifiedNamedElements)
{
result.add((JSQualifiedNamedElement) e.getNavigationElement());
}
Collection<VirtualFile> files = new ArrayList<VirtualFile>();
files.addAll(FileBasedIndex.getInstance().getContainingFiles(FilenameIndex.NAME, name + JavaScriptSupportLoader.MXML_FILE_EXTENSION_DOT, scope));
files.addAll(FileBasedIndex.getInstance().getContainingFiles(FilenameIndex.NAME, name + JavaScriptSupportLoader.MXML_FILE_EXTENSION2_DOT, scope));
for(final VirtualFile file : files)
{
if(!file.isValid())
{
continue;
}
final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if(psiFile != null)
{
result.add(XmlBackedJSClassImpl.getXmlBackedClass((XmlFile) psiFile));
}
}
return result;
}
示例10: getQNameToStartHierarchySearch
import com.intellij.lang.javascript.JavaScriptSupportLoader; //導入依賴的package包/類
public static String getQNameToStartHierarchySearch(final JSFunction node)
{
PsiElement parentNode = node.getParent();
parentNode = getClassReferenceForXmlFromContext(parentNode);
if(parentNode instanceof JSClass)
{
final JSAttributeList attributeList = node.getAttributeList();
if(attributeList == null ||
!attributeList.hasModifier(JSAttributeList.ModifierType.OVERRIDE) ||
attributeList.hasModifier(JSAttributeList.ModifierType.STATIC) ||
attributeList.getAccessType() == JSAttributeList.AccessType.PRIVATE)
{
return null;
}
if(parentNode instanceof JSClass)
{
return ((JSClass) parentNode).getQualifiedName();
}
}
else if(node instanceof JSFunctionExpression && parentNode.getContainingFile().getLanguage() != JavaScriptSupportLoader.ECMA_SCRIPT_L4)
{
final ContextResolver resolver = new ContextResolver(node.getFirstChild());
return resolver.getQualifierAsString();
}
else if(parentNode instanceof JSFile && parentNode.getContainingFile().getLanguage() != JavaScriptSupportLoader.ECMA_SCRIPT_L4)
{
return node.getName();
}
return null;
}
示例11: ImplicitJSVariableImpl
import com.intellij.lang.javascript.JavaScriptSupportLoader; //導入依賴的package包/類
public ImplicitJSVariableImpl(final String name, String qName, PsiFile containingFile)
{
super(containingFile.getManager(), JavaScriptSupportLoader.ECMA_SCRIPT_L4.getBaseLanguage());
myContainingFile = containingFile;
myName = name;
myType = qName;
}
示例12: isAdequatePlaceForImport
import com.intellij.lang.javascript.JavaScriptSupportLoader; //導入依賴的package包/類
public static boolean isAdequatePlaceForImport(final PsiNamedElement parent, @NotNull PsiElement place)
{
if(parent instanceof JSFile && !parent.getLanguage().isKindOf(JavaScriptSupportLoader.ECMA_SCRIPT_L4))
{
return false;
}
if(place instanceof JSReferenceExpression)
{
final PsiElement placeParent = place.getParent();
if(placeParent instanceof JSReferenceExpression)
{
final PsiElement currentParent = JSResolveUtil.getTopReferenceParent(placeParent);
if(JSResolveUtil.isSelfReference(currentParent, place) ||
//currentParent instanceof JSDefinitionExpression ||
currentParent instanceof JSReferenceList)
{
return false;
}
}
}
else if(place instanceof JSDocTagValue)
{
// further conditions to come
}
else
{
if(!(place instanceof JSFile))
{
return false;
}
}
return true;
}
示例13: getSignatureForParameter
import com.intellij.lang.javascript.JavaScriptSupportLoader; //導入依賴的package包/類
public static String getSignatureForParameter(final JSParameter p, boolean skipType)
{
final String s = skipType ? null : p.getTypeString();
if(s != null && s.length() > 0)
{
final boolean ecmal4 = p.getContainingFile().getLanguage() == JavaScriptSupportLoader.ECMA_SCRIPT_L4;
String result;
if(ecmal4)
{
if(p.isRest())
{
result = "...";
}
else
{
result = p.getName() + ":" + s;
}
}
else
{
result = "[" + s + "] " + p.getName();
}
final String initializerText = p.getInitializerText();
if(initializerText != null)
{
result += " = " + initializerText;
}
return result;
}
return p.getName();
}
示例14: getExceptionVarTypeBasedOnContext
import com.intellij.lang.javascript.JavaScriptSupportLoader; //導入依賴的package包/類
protected static String getExceptionVarTypeBasedOnContext(@NotNull PsiElement context)
{
if(context.getContainingFile().getLanguage() == JavaScriptSupportLoader.ECMA_SCRIPT_L4)
{
return ":Error";
}
return "";
}
示例15: update
import com.intellij.lang.javascript.JavaScriptSupportLoader; //導入依賴的package包/類
@Override
public void update(final AnActionEvent e)
{
final VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE);
boolean status = false;
if(file != null)
{
if(file.getFileType() == JavaScriptFileType.INSTANCE)
{
final Editor editor = e.getData(PlatformDataKeys.EDITOR);
final PsiFile psifile = e.getData(LangDataKeys.PSI_FILE);
if(editor != null && psifile != null)
{
status = psifile.getLanguage() == JavaScriptSupportLoader.ECMA_SCRIPT_L4;
}
}
else if(JavaScriptSupportLoader.isFlexMxmFile(file))
{
status = true;
}
}
e.getPresentation().setEnabled(status);
e.getPresentation().setVisible(status);
}