本文整理汇总了Java中com.intellij.lang.javascript.psi.JSFile类的典型用法代码示例。如果您正苦于以下问题:Java JSFile类的具体用法?Java JSFile怎么用?Java JSFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSFile类属于com.intellij.lang.javascript.psi包,在下文中一共展示了JSFile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: restartInstance
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
public void restartInstance() {
synchronized(this.myLock) {
final JSGraphQLNodeLanguageServiceInstance instance = JSGraphQLNodeLanguageServiceClient.getLanguageServiceInstance(myProject);
if(instance != null) {
if(myToolWindowManager != null) {
myToolWindowManager.disconnectFromProcessHandler();
}
instance.restart(() -> {
final Editor editor = FileEditorManager.getInstance(myProject).getSelectedTextEditor();
if(editor != null) {
final VirtualFile file = FileDocumentManager.getInstance().getFile(editor.getDocument());
if(file != null) {
final PsiFile psiFile = PsiUtilCore.getPsiFile(myProject, file);
if(psiFile != null) {
if(psiFile instanceof JSFile || psiFile instanceof JSGraphQLFile) {
DaemonCodeAnalyzer.getInstance(myProject).restart(psiFile);
}
}
logErrorsForFile(file, true); // force true to re-show the errors for the same file
}
}
});
}
}
}
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:27,代码来源:JSGraphQLLanguageUIProjectService.java
示例2: getEnvironment
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
public static String getEnvironment(PsiFile file) {
if (file instanceof JSFile) {
// for JS Files we have to check the kind of environment being used
final Ref<String> envRef = new Ref<>();
file.accept(new PsiRecursiveElementVisitor() {
@Override
public void visitElement(PsiElement element) {
if (!isJSGraphQLLanguageInjectionTarget(element, envRef)) {
// no match yet, so keep visiting
super.visitElement(element);
}
}
});
final String environment = envRef.get();
if (environment != null) {
return environment;
}
} else if (file instanceof JSGraphQLFile) {
final Ref<String> tag = new Ref<>();
if (file.getContext() != null && isJSGraphQLLanguageInjectionTarget(file.getContext(), tag)) {
return tag.get();
}
}
// fallback is traditional GraphQL
return GRAPHQL_ENVIRONMENT;
}
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:27,代码来源:JSGraphQLLanguageInjectionUtil.java
示例3: createModel
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
@NotNull
@Override
public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
if(element instanceof JSFile || element.getContainingFile() instanceof JSFile) {
final JSFile file = (JSFile)(element instanceof JSFile ? element : element.getContainingFile());
file.putUserData(WANT_DEFAULT_FORMATTER_KEY, true);
try {
final FormattingModelBuilder formattingModelBuilder = LanguageFormatting.INSTANCE.forContext(file.getLanguage(), element);
if (formattingModelBuilder != null) {
final FormattingModel model = formattingModelBuilder.createModel(element, settings);
final Block rootBlock = model.getRootBlock();
return new DelegatingFormattingModel(model, new JSGraphQLBlockWrapper(rootBlock, null, element.getNode(), rootBlock.getWrap(), rootBlock.getAlignment(), createSpaceBuilder(settings, element), settings));
}
} finally {
file.putUserData(WANT_DEFAULT_FORMATTER_KEY, null);
}
}
throw new IllegalArgumentException("Unsupported element '" + element + "'. It must be an element in a JSFile with its own default formatter to support injected GraphQL formatting");
}
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:20,代码来源:JSGraphQLInjectedFormattingModelBuilder.java
示例4: isEngagedToFormat
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
@Override
public boolean isEngagedToFormat(PsiElement context) {
if(context instanceof JSFile) {
if(Boolean.TRUE.equals(context.getUserData(WANT_DEFAULT_FORMATTER_KEY))) {
// we're looking up the default formatter at the moment
return false;
}
Collection<JSStringTemplateExpression> templateExpressions = PsiTreeUtil.findChildrenOfType(context, JSStringTemplateExpression.class);
for (JSStringTemplateExpression templateExpression : templateExpressions) {
if(JSGraphQLLanguageInjectionUtil.isJSGraphQLLanguageInjectionTarget(templateExpression)) {
return true;
}
}
}
return false;
}
开发者ID:jimkyndemeyer,项目名称:js-graphql-intellij-plugin,代码行数:17,代码来源:JSGraphQLInjectedFormattingModelBuilder.java
示例5: testSnippetsForBackend
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
public void testSnippetsForBackend() {
PsiFile psiFile = myFixture.configureByFile("snippets.js");
Collection<ShopwareSnippet> snippetsInFile = SnippetUtil.getSnippetsInFile((JSFile) psiFile);
assertNotNull(ContainerUtil.find(snippetsInFile, snippet ->
"backend/foobar/namespace".equals(snippet.getNamespace()) && "start_accept".equals(snippet.getName())
));
assertNotNull(ContainerUtil.find(snippetsInFile, snippet ->
"backend/foobar".equals(snippet.getNamespace()) && "start_accept".equals(snippet.getName())
));
assertNotNull(ContainerUtil.find(snippetsInFile, snippet ->
"backend/foobar/namespace".equals(snippet.getNamespace()) && "filter_feature".equals(snippet.getName())
));
assertNotNull(ContainerUtil.find(snippetsInFile, snippet ->
"foobar".equals(snippet.getNamespace()) && "filter_feature".equals(snippet.getName())
));
}
开发者ID:Haehnchen,项目名称:idea-php-shopware-plugin,代码行数:22,代码来源:SnippetUtilTest.java
示例6: findTypesImpl
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
@RequiredReadAction
@NotNull
@Override
public Collection<? extends DotNetTypeDeclaration> findTypesImpl(@NotNull String key, @NotNull GlobalSearchScope searchScope)
{
if(DumbService.isDumb(myProject))
{
return Collections.emptyList();
}
Collection<JSFile> jsFiles = UnityScriptFileByNameIndex.getInstance().get(key, myProject, searchScope);
JSFile jsFile = ContainerUtil.getFirstItem(jsFiles);
if(jsFile == null)
{
return Collections.emptyList();
}
return Collections.singletonList(new UnityScriptDotNetTypeDeclaration(key, jsFile));
}
开发者ID:consulo,项目名称:consulo-unity3d,代码行数:19,代码来源:UnityScriptPsiSearcher.java
示例7: compute
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
@NotNull
@Override
@RequiredReadAction
public Set<PsiElement> compute(@NotNull final Project project,
@Nullable final IndexBasedDotNetPsiSearcher searcher,
@NotNull final String indexKey,
@NotNull final String thisQName,
@NotNull final GlobalSearchScope scope)
{
Set<PsiElement> elements = new LinkedHashSet<>();
Collection<String> keys = UnityScriptFileByNameIndex.getInstance().getAllKeys(project);
for(String key : keys)
{
ProgressManager.checkCanceled();
Collection<JSFile> jsFiles = UnityScriptFileByNameIndex.getInstance().get(key, project, scope);
for(JSFile jsFile : jsFiles)
{
elements.add(new UnityScriptDotNetTypeDeclaration(key, jsFile));
}
}
return elements;
}
开发者ID:consulo,项目名称:consulo-unity3d,代码行数:23,代码来源:UnityScriptRootNamespaceAsElement.java
示例8: findExecutableFile
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
@Nullable
public static VirtualFile findExecutableFile(ConfigurationContext configurationContext, @Nullable Condition<JSFile> condition)
{
PsiElement psiLocation = configurationContext.getPsiLocation();
PsiFile psiFile = psiLocation == null ? null : psiLocation.getContainingFile();
if(psiFile instanceof JSFile && psiFile.getFileType() == JavaScriptFileType.INSTANCE)
{
if(condition != null && !condition.value((JSFile) psiFile))
{
return null;
}
Module module = configurationContext.getModule();
if(module == null)
{
return null;
}
NodeJSModuleExtension extension = ModuleUtilCore.getExtension(module, NodeJSModuleExtension.class);
if(extension == null)
{
return null;
}
return psiFile.getVirtualFile();
}
return null;
}
开发者ID:consulo,项目名称:consulo-nodejs,代码行数:26,代码来源:NodeJSConfigurationProducerUtil.java
示例9: getBuilder
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
@Override
public StubBuilder getBuilder()
{
return new DefaultStubBuilder()
{
@NotNull
@Override
protected StubElement createStubForFile(@NotNull PsiFile file)
{
if(file instanceof JSFile)
{
return new JSFileStubImpl((JSFile) file, file.getName());
}
return super.createStubForFile(file);
}
};
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:18,代码来源:JSFileElementType.java
示例10: getQualifiedName
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
@Override
public String getQualifiedName()
{
final JSFunctionStub jsFunctionStub = getStub();
if(jsFunctionStub != null)
{
return jsFunctionStub.getQualifiedName();
}
final PsiElement parent = JSResolveUtil.findParent(this);
if(parent instanceof JSFile || parent instanceof JSPackageStatement)
{
return JSPsiImplUtils.getQName(this);
}
else
{
return getName();
}
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:20,代码来源:JSFunctionImpl.java
示例11: process
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
private static <E extends PsiElement> void process(TokenSet filter, final JSFile file, final ArrayList<E> result, final Collection<JSFile> visited)
{
if(visited.contains(file))
{
return;
}
visited.add(file);
for(PsiElement element : JSResolveUtil.getStubbedChildren(file, filter))
{
if(element instanceof JSIncludeDirective)
{
PsiFile includedFile = ((JSIncludeDirective) element).resolveFile();
if(includedFile instanceof JSFile)
{
process(filter, (JSFile) includedFile, result, visited);
}
}
else
{
result.add((E) element);
}
}
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:24,代码来源:JSClassBase.java
示例12: resolveTypeNameUsingImplicitImports
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
public static JSImportedElementResolveResult resolveTypeNameUsingImplicitImports(@NotNull String referenceName, @NotNull JSFile file)
{
final PsiElement context = file.getContext();
if(context != null)
{
JSImportedElementResolveResult expression = tryFindInMap(referenceName, file, implicitImportListMap, null);
if(expression != null)
{
return expression;
}
expression = tryFindInMap(referenceName, file, mxmlImportListMap, null);
if(expression != null)
{
return expression;
}
}
return null;
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:20,代码来源:FlexImportSupport.java
示例13: compute
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
@Override
protected CachedValue<JSFile[]> compute(final XmlTag tag, final Object p)
{
return CachedValuesManager.getManager(tag.getProject()).createCachedValue(new CachedValueProvider<JSFile[]>()
{
@Override
public Result<JSFile[]> compute()
{
final List<JSFile> injectedFiles = new ArrayList<JSFile>(2);
final List<PsiElement> dependencies = new ArrayList<PsiElement>();
dependencies.add(tag);
new InjectedScriptsVisitor(tag, doProcessAllTags(tag), false, false, new InjectedFileVisitor()
{
@Override
public void visit(XmlTag rootTag, JSFile file)
{
injectedFiles.add(file);
dependencies.add(file);
}
}).go();
return new Result<JSFile[]>(injectedFiles.toArray(new JSFile[injectedFiles.size()]), dependencies.toArray());
}
}, false);
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:25,代码来源:XmlBackedJSClassImpl.java
示例14: evalAnchor
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
protected void evalAnchor(final Editor editor, final PsiFile file)
{
anchor = null;
final PsiElement at = file.findElementAt(editor.getCaretModel().getOffset());
PsiElement parent;
if(at != null && ((parent = at.getParent()) == myJsClass || (parent instanceof JSFile && myJsClass.getParent().getContainingFile() == parent
.getContext().getContainingFile())))
{
final ASTNode atNode = at.getNode();
if(atNode.getElementType() == JSTokenTypes.RBRACE)
{
return;
}
for(ASTNode node = atNode; node != null; node = node.getTreeNext())
{
if(node.getElementType() == JSTokenTypes.LBRACE)
{
return;
}
}
anchor = at;
}
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:26,代码来源:BaseCreateMethodsFix.java
示例15: insertCommitReformat
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
@RequiredReadAction
private void insertCommitReformat(final Project project, final Editor editor, final PsiFile psiFile, final int offset, final String str,
final int shiftOffset, boolean adjustLineIndent)
{
editor.getDocument().insertString(offset, str);
editor.getCaretModel().moveToOffset(offset + shiftOffset);
commit(editor);
PsiElement at = psiFile.findElementAt(offset + shiftOffset - 1);
final PsiElement parentOfType = PsiTreeUtil.getParentOfType(at, JSStatement.class, JSFunction.class, JSClass.class, JSFile.class);
try
{
reformat(parentOfType);
if(adjustLineIndent)
{
CodeStyleManager.getInstance(project).adjustLineIndent(psiFile, editor.getCaretModel().getOffset());
}
}
catch(IncorrectOperationException ex)
{
LoggerFactory.getInstance().getLoggerInstance(getClass().getName()).error(ex);
}
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:25,代码来源:JSSmartEnterProcessor.java
示例16: getUsages
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
@NotNull
@Override
public Collection<KeyUsagePsiElement> getUsages(PsiFile psiFile) {
if(psiFile instanceof JSFile) {
JsEnvironmentCallsVisitor visitor = new JsEnvironmentCallsVisitor();
psiFile.acceptChildren(visitor);
return visitor.getCollectedItems();
}
return Collections.emptyList();
}
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:13,代码来源:JsEnvironmentVariablesUsagesProvider.java
示例17: isAcceptable
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
@Override
public boolean isAcceptable(Object element, @Nullable PsiElement context) {
if (element instanceof XmlAttributeValue && context != null && context.getContainingFile() instanceof JSFile) {
final XmlAttributeValue value = (XmlAttributeValue) element;
final XmlAttribute xmlAttribute = PsiTreeUtil.getParentOfType(value, XmlAttribute.class);
if (xmlAttribute != null) {
return xmlAttribute.getName().equals("styleName");
}
}
return false;
}
开发者ID:jimkyndemeyer,项目名称:react-css-modules-intellij-plugin,代码行数:12,代码来源:CssModulesUtil.java
示例18: getLineMarkerInfo
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
@RequiredReadAction
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element)
{
if(element.getNode().getElementType() == JSTokenTypes.IDENTIFIER && element.getParent() instanceof JSReferenceExpression && element.getParent().getParent() instanceof JSFunction)
{
UnityFunctionManager functionManager = UnityFunctionManager.getInstance();
Map<String, UnityFunctionManager.FunctionInfo> map = functionManager.getFunctionsByType().get(Unity3dTypes.UnityEngine.MonoBehaviour);
if(map == null)
{
return null;
}
UnityFunctionManager.FunctionInfo functionInfo = map.get(element.getText());
if(functionInfo == null)
{
return null;
}
Unity3dModuleExtension extension = ModuleUtilCore.getExtension(element, Unity3dModuleExtension.class);
if(extension == null)
{
return null;
}
JSFunction jsFunction = (JSFunction) element.getParent().getParent();
if(jsFunction.getParent() instanceof JSFile)
{
if(!isEqualParameters(functionInfo.getParameters(), jsFunction))
{
return null;
}
return new LineMarkerInfo<>(element, element.getTextRange(), Unity3dIcons.EventMethod, Pass.LINE_MARKERS, new ConstantFunction<>(functionInfo.getDescription()), null,
GutterIconRenderer.Alignment.LEFT);
}
}
return null;
}
开发者ID:consulo,项目名称:consulo-unity3d,代码行数:38,代码来源:UnityScriptEventFunctionLineMarkerProvider.java
示例19: processElementsWithName
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
@Override
public void processElementsWithName(@NotNull String name, @NotNull final Processor<NavigationItem> processor, @NotNull FindSymbolParameters parameters)
{
StubIndex.getInstance().processElements(UnityScriptIndexKeys.FILE_BY_NAME_INDEX, name, parameters.getProject(), parameters.getSearchScope(), parameters.getIdFilter(), JSFile.class,
new Processor<JSFile>()
{
@Override
public boolean process(final JSFile file)
{
return processor.process(new FakePsiElement()
{
@Override
public String getName()
{
return FileUtil.getNameWithoutExtension(file.getName());
}
@Nullable
@Override
public Icon getIcon(boolean open)
{
IconDescriptor descriptor = new IconDescriptor(AllIcons.Nodes.Class);
descriptor.addLayerIcon(Unity3dIcons.Js);
descriptor.setRightIcon(AllIcons.Nodes.C_public);
return descriptor.toIcon();
}
@Override
public PsiElement getParent()
{
return file;
}
});
}
});
}
开发者ID:consulo,项目名称:consulo-unity3d,代码行数:37,代码来源:UnityScriptGotoClassContributor.java
示例20: modify
import com.intellij.lang.javascript.psi.JSFile; //导入依赖的package包/类
@Override
@RequiredDispatchThread
public Collection<AbstractTreeNode> modify(AbstractTreeNode parent, Collection<AbstractTreeNode> children, ViewSettings settings)
{
if(!myProject.isInitialized())
{
return children;
}
Unity3dRootModuleExtension rootModuleExtension = Unity3dModuleExtensionUtil.getRootModuleExtension(myProject);
if(rootModuleExtension == null)
{
return children;
}
List<AbstractTreeNode> nodes = new ArrayList<AbstractTreeNode>(children.size());
for(AbstractTreeNode child : children)
{
Object value = child.getValue();
if(value instanceof JSFile)
{
Module moduleForPsiElement = ModuleUtilCore.findModuleForPsiElement((PsiElement) value);
if(moduleForPsiElement != null)
{
nodes.add(new UnityScriptFileNode(myProject, (PsiFile) value, settings));
continue;
}
}
nodes.add(child);
}
return nodes;
}
开发者ID:consulo,项目名称:consulo-unity3d,代码行数:32,代码来源:UnityScriptFileProjectViewProvider.java
注:本文中的com.intellij.lang.javascript.psi.JSFile类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论