• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JavaFileType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.ide.highlighter.JavaFileType的典型用法代码示例。如果您正苦于以下问题:Java JavaFileType类的具体用法?Java JavaFileType怎么用?Java JavaFileType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JavaFileType类属于com.intellij.ide.highlighter包,在下文中一共展示了JavaFileType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createUIComponents

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
private void createUIComponents() {
    final EditorFactory editorFactory = EditorFactory.getInstance();
    previewDocument = editorFactory.createDocument(EMPTY_TEXT);
    previewEditor = editorFactory.createEditor(previewDocument, null, JavaFileType.INSTANCE, true);

    final EditorSettings settings = previewEditor.getSettings();
    settings.setWhitespacesShown(true);
    settings.setLineMarkerAreaShown(false);
    settings.setIndentGuidesShown(false);
    settings.setLineNumbersShown(false);
    settings.setFoldingOutlineShown(false);
    settings.setRightMarginShown(false);
    settings.setVirtualSpace(false);
    settings.setWheelFontChangeEnabled(false);
    settings.setUseSoftWraps(false);
    settings.setAdditionalColumnsCount(0);
    settings.setAdditionalLinesCount(1);

    previewPanel = (JPanel) previewEditor.getComponent();
    previewPanel.setName(PREVIEW_PANEL_NAME);
    previewPanel.setPreferredSize(new Dimension(PREFERRED_PREVIEW_WIDTH, PREFERRED_PREVIEW_HEIGHT));
}
 
开发者ID:t28hub,项目名称:json2java4idea,代码行数:23,代码来源:SettingsPanel.java


示例2: run

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
@Override
protected void run(@NotNull Result<PsiFile> result) throws Throwable {
    final PsiPackage packageElement = directoryService.getPackage(directory);
    if (packageElement == null) {
        throw new InvalidDirectoryException("Target directory does not provide a package");
    }

    final String fileName = Extensions.append(name, StdFileTypes.JAVA);
    final PsiFile found = directory.findFile(fileName);
    if (found != null) {
        throw new ClassAlreadyExistsException("Class '" + name + "'already exists in " + packageElement.getName());
    }

    final String packageName = packageElement.getQualifiedName();
    final String className = Extensions.remove(this.name, StdFileTypes.JAVA);
    try {
        final String java = converter.convert(packageName, className, json);
        final PsiFile classFile = fileFactory.createFileFromText(fileName, JavaFileType.INSTANCE, java);
        CodeStyleManager.getInstance(classFile.getProject()).reformat(classFile);
        JavaCodeStyleManager.getInstance(classFile.getProject()).optimizeImports(classFile);
        final PsiFile created = (PsiFile) directory.add(classFile);
        result.setResult(created);
    } catch (IOException e) {
        throw new ClassCreationException("Failed to create new class from JSON", e);
    }
}
 
开发者ID:t28hub,项目名称:json2java4idea,代码行数:27,代码来源:NewClassCommandAction.java


示例3: createJavaFile

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
private PsiClass createJavaFile(String javaFileName, @NonNls String text) {
    PsiJavaFile psiJavaFile = (PsiJavaFile) PsiFileFactory.getInstance(mPsiClass.getProject()).createFileFromText(
            javaFileName + "." + JavaFileType.INSTANCE.getDefaultExtension(),
            JavaFileType.INSTANCE, text);
    PsiClass[] classes = psiJavaFile.getClasses();
    if (classes.length != 1) {
        throw new IncorrectOperationException("Incorrect class '" + text + "'");
    } else {
        PsiClass pc = classes[0];
        if (pc == null) {
            throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null",
                    "com/intellij/psi/impl/PsiJavaParserFacadeImpl", "createJavaFile"));
        } else {
            return pc;
        }
    }
}
 
开发者ID:LightSun,项目名称:data-mediator,代码行数:18,代码来源:PropertyProcessor.java


示例4: postProcessSelectedMainSketchClass

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
public static PsiFile postProcessSelectedMainSketchClass(@NotNull Project project,
                                                         @NotNull PsiClass selectedMainClass,
                                                         @NotNull PsiImportList correspondingImportList) {
    // Construct a valid Java class from the selected main sketch class.
    selectedMainClass.getModifierList().setModifierProperty(PsiModifier.PUBLIC, true);

    PsiJavaCodeReferenceElement pAppletReference = JavaPsiFacade.getElementFactory(project)
            .createFQClassNameReferenceElement("processing.core.PApplet", GlobalSearchScope.projectScope(project));
    selectedMainClass.getExtendsList().add(pAppletReference);

    PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(project);

    StringJoiner mainFileJoiner = new StringJoiner("\n\n");
    StringJoiner importStatementJoiner = new StringJoiner("\n");

    for (PsiImportStatementBase importStatement : correspondingImportList.getAllImportStatements()) {
        importStatementJoiner.add(importStatement.getText());
    }

    mainFileJoiner.add(importStatementJoiner.toString());
    mainFileJoiner.add(selectedMainClass.getText());

    return psiFileFactory.createFileFromText(selectedMainClass.getName() + ".java", JavaFileType.INSTANCE, mainFileJoiner.toString());
}
 
开发者ID:mistodev,项目名称:processing-idea,代码行数:25,代码来源:MigrationActions.java


示例5: findMethodLikeCalls

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
public static List<PsiMethodCallExpression> findMethodLikeCalls(SmcMethodLikeElement psiMethodLike) {
    SmcFile containingFile = (SmcFile) psiMethodLike.getContainingFile().getContainingFile();
    PsiClass fsmClass = containingFile.getFsmClass();
    Project project = psiMethodLike.getProject();
    if (fsmClass == null) return Collections.emptyList();
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, JavaFileType.INSTANCE,
            GlobalSearchScope.projectScope(project));
    List<PsiMethodCallExpression> result = new ArrayList<>();
    for (VirtualFile virtualFile : virtualFiles) {
        PsiJavaFile psiJavaFile = (PsiJavaFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (psiJavaFile != null) {
            Collection<PsiMethodCallExpression> methodCallExpressions = PsiTreeUtil.findChildrenOfType(psiJavaFile, PsiMethodCallExpression.class);
            for (PsiMethodCallExpression methodCall : methodCallExpressions) {
                PsiMethod psiMethod = methodCall.resolveMethod();
                if (psiMethod != null && psiMethodLike.matches(psiMethod)) {
                    result.add(methodCall);
                }
            }
        }
    }
    return result;
}
 
开发者ID:menshele,项目名称:smcplugin,代码行数:23,代码来源:SmcPsiUtil.java


示例6: findJavaMethod

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
public static List<PsiMethod> findJavaMethod(Project project, String name) {
    List<PsiMethod> result = null;
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, JavaFileType.INSTANCE,
            GlobalSearchScope.projectScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        PsiJavaFile javaFile = (PsiJavaFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (javaFile != null) {
            Collection<PsiMethod> properties = PsiTreeUtil.findChildrenOfType(javaFile, PsiMethod.class);
            for (PsiMethod javaMethod : properties) {
                if (name.equals(javaMethod.getName())) {
                    if (result == null) {
                        result = new ArrayList<PsiMethod>();
                    }
                    result.add(javaMethod);
                }
            }
        }
    }
    return result != null ? result : Collections.<PsiMethod>emptyList();
}
 
开发者ID:menshele,项目名称:smcplugin,代码行数:21,代码来源:SmcPsiUtil.java


示例7: testGenerateDoc

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
public void testGenerateDoc() throws Exception {
    myFixture.configureByText(JavaFileType.INSTANCE, getJavaTestDataWithCursorAfterQuestionMark());

    PsiElement element = myFixture.findElementByText("\"file:inbox?\"", PsiLiteralExpression.class);
    String componentName = "file";
    String lookup = componentName + ":inbox?delete";
    PsiManager manager = myFixture.getPsiManager();

    PsiElement docInfo = new CamelDocumentationProvider().getDocumentationElementForLookupItem(manager, lookup, element);

    String doc = new CamelDocumentationProvider().generateDoc(docInfo, null);
    assertEquals(readExpectedFile(), doc);

    String documentation = new CamelDocumentationProvider().generateDoc(element, null);
    assertNotNull(documentation);
    assertTrue(documentation.startsWith("<b>File Component</b><br/>The file component is used for reading or writing files.<br/>"));
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:18,代码来源:CamelDocumentationProviderTestIT.java


示例8: getIndentSpecial

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
/**
 * Computes indentation of PsiClass, PsiMethod and PsiField elements after formatting
 * @param element PsiClass or PsiMethod or PsiField
 * @return indentation size
 */
private int getIndentSpecial(@NotNull PsiElement element) {
  if (element instanceof PsiDocComment) {
    return 0;
  }
  LOG.assertTrue(element instanceof PsiClass ||
                 element instanceof PsiField ||
                 element instanceof PsiMethod);

  int indentSize = mySettings.getIndentSize(JavaFileType.INSTANCE);
  boolean doNotIndentTopLevelClassMembers = mySettings.getCommonSettings(JavaLanguage.INSTANCE).DO_NOT_INDENT_TOP_LEVEL_CLASS_MEMBERS;

  int indent = 0;
  PsiClass top = PsiUtil.getTopLevelClass(element);
  while (top != null && !element.isEquivalentTo(top)) {
    if (doNotIndentTopLevelClassMembers && element.getParent().isEquivalentTo(top)) {
      break;
    }
    element = element.getParent();
    indent += indentSize;
  }

  return indent;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:CommentFormatter.java


示例9: getAdditionalResolveScope

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
@Override
public SearchScope getAdditionalResolveScope(@NotNull VirtualFile file, Project project) {
  ProjectFileIndex index = ProjectFileIndex.SERVICE.getInstance(project);
  if (index.isInLibraryClasses(file) || index.isInContent(file)) {
    return null;
  }

  String fileExtension = file.getExtension();
  if ("class".equals(fileExtension) || JavaFileType.DEFAULT_EXTENSION.equals(fileExtension)) {
    for (PsiElementFinder finder : Extensions.getExtensions(PsiElementFinder.EP_NAME, project)) {
      if (finder instanceof NonClasspathClassFinder) {
        final List<VirtualFile> roots = ((NonClasspathClassFinder)finder).getClassRoots();
        for (VirtualFile root : roots) {
          if (VfsUtilCore.isAncestor(root, file, true)) {
            return NonClasspathDirectoriesScope.compose(roots);
          }
        }
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:NonClasspathResolveScopeEnlarger.java


示例10: testPointersRefCount

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
public void testPointersRefCount() throws Exception {
  PsiFile file = configureByText(JavaFileType.INSTANCE, "class X{}");
  PsiClass aClass = ((PsiClassOwner)file).getClasses()[0];
  SmartPointerManagerImpl smartPointerManager = getPointerManager();
  SmartPsiElementPointer pointer1 = createPointer(aClass);
  SmartPsiElementPointer pointer2 = createPointer(aClass);
  assertSame(pointer1, pointer2);

  assertNotNull(pointer1.getRange());

  boolean removed2 = smartPointerManager.removePointer(pointer2);
  assertFalse(removed2);
  assertNotNull(pointer1.getRange());

  boolean removed1 = smartPointerManager.removePointer(pointer1);
  assertTrue(removed1);
  assertNull(pointer1.getRange());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:SmartPsiElementPointersTest.java


示例11: testPointersRefCountSaturated

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
public void testPointersRefCountSaturated() throws Exception {
  PsiFile file = configureByText(JavaFileType.INSTANCE, "class X{}");
  PsiClass aClass = ((PsiClassOwner)file).getClasses()[0];
  SmartPointerManagerImpl smartPointerManager = getPointerManager();
  SmartPsiElementPointerImpl pointer1 = (SmartPsiElementPointerImpl)createPointer(aClass);
  for (int i=0; i<1000; i++) {
    SmartPsiElementPointer<PsiClass> pointer2 = createPointer(aClass);
    assertSame(pointer1, pointer2);
  }

  assertNotNull(pointer1.getRange());
  assertEquals(Byte.MAX_VALUE, pointer1.incrementAndGetReferenceCount(0));

  for (int i=0; i<1100; i++) {
    boolean removed1 = smartPointerManager.removePointer(pointer1);
    assertFalse(removed1);
    Assert.assertNotNull(pointer1.getRange());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:SmartPsiElementPointersTest.java


示例12: testInsertImport

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
public void testInsertImport() {
  final PsiFile file = configureByText(JavaFileType.INSTANCE,
                                       "class S {\n" +
                                       "}");

  PsiClass aClass = ((PsiJavaFile)file).getClasses()[0];

  WriteCommandAction.runWriteCommandAction(getProject(), new Runnable() {
    @Override
    public void run() {
      getEditor().getDocument().insertString(0, "import java.util.Map;\n");
    }
  });

  PsiDocumentManager.getInstance(getProject()).commitAllDocuments();

  PsiClass aClass2 = ((PsiJavaFile)file).getClasses()[0];
  assertSame(aClass, aClass2);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:SmartPsiElementPointersTest.java


示例13: testEqualPointerRangesWhenCreatedFromStubAndAST

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
public void testEqualPointerRangesWhenCreatedFromStubAndAST() {
  final PsiFile file = configureByText(JavaFileType.INSTANCE,
                                       "class S {\n" +
                                       "}");

  PsiClass aClass = ((PsiJavaFile)file).getClasses()[0];
  assertNotNull(((PsiFileImpl)file).getStubTree());

  final SmartPointerManager manager = getPointerManager();
  final SmartPsiElementPointer<PsiClass> pointer1 = createPointer(aClass);
  Segment range1 = pointer1.getRange();
  manager.removePointer(pointer1);

  final FileASTNode node = file.getNode();
  final SmartPsiElementPointer<PsiClass> pointer2 = createPointer(aClass);
  assertEquals(range1, pointer2.getRange());
  assertNotNull(node);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:SmartPsiElementPointersTest.java


示例14: testMoveText

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
public void testMoveText() {
  PsiJavaFile file = (PsiJavaFile)configureByText(JavaFileType.INSTANCE, "class C1{}\nclass C2 {}");
  DocumentEx document = (DocumentEx)file.getViewProvider().getDocument();

  SmartPsiElementPointer<PsiClass> pointer1 =
    createPointer(file.getClasses()[0]);
  SmartPsiElementPointer<PsiClass> pointer2 =
    createPointer(file.getClasses()[1]);
  assertEquals("C1", pointer1.getElement().getName());
  assertEquals("C2", pointer2.getElement().getName());

  PlatformTestUtil.tryGcSoftlyReachableObjects();
  assertNull(((SmartPointerEx) pointer1).getCachedElement());
  assertNull(((SmartPointerEx) pointer2).getCachedElement());

  TextRange range = file.getClasses()[1].getTextRange();
  document.moveText(range.getStartOffset(), range.getEndOffset(), 0);

  System.out.println(pointer1.getRange());
  System.out.println(pointer2.getRange());

  PsiDocumentManager.getInstance(myProject).commitAllDocuments();

  assertEquals("C1", pointer1.getElement().getName());
  assertEquals("C2", pointer2.getElement().getName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:SmartPsiElementPointersTest.java


示例15: testPointerToEmptyElement2

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
public void testPointerToEmptyElement2() {
  PsiFile file = configureByText(JavaFileType.INSTANCE, "class Foo {\n" +
                                                           "  void foo() {}\n" +
                                                           "}");
  PsiMethod method = PsiTreeUtil.findElementOfClassAtOffset(file, file.getText().indexOf("void"), PsiMethod.class, false);
  SmartPointerEx pointer1 = (SmartPointerEx)createPointer(method.getModifierList());
  SmartPointerEx pointer2 = (SmartPointerEx)createPointer(method.getTypeParameterList());
  method = null;

  PlatformTestUtil.tryGcSoftlyReachableObjects();
  assertNull(pointer1.getCachedElement());
  assertNull(pointer2.getCachedElement());

  assertInstanceOf(pointer1.getElement(), PsiModifierList.class);
  assertInstanceOf(pointer2.getElement(), PsiTypeParameterList.class);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:SmartPsiElementPointersTest.java


示例16: testNonAnchoredStubbedElement

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
public void testNonAnchoredStubbedElement() {
  PsiFile file = configureByText(JavaFileType.INSTANCE, "class Foo { { @NotNull String foo; } }");
  StubTree stubTree = ((PsiFileImpl)file).getStubTree();
  assertNotNull(stubTree);
  PsiElement anno = stubTree.getPlainList().stream().map(StubElement::getPsi).filter(psiElement -> psiElement instanceof PsiAnnotation).findFirst().get();

  SmartPsiElementPointer<PsiElement> pointer = createPointer(anno);
  assertNotNull(((PsiFileImpl)file).getStubTree());

  stubTree = null;
  anno = null;
  PlatformTestUtil.tryGcSoftlyReachableObjects();
  assertNull(((SmartPointerEx) pointer).getCachedElement());

  file.getViewProvider().getDocument().insertString(0, " ");
  PsiDocumentManager.getInstance(myProject).commitAllDocuments();

  assertNotNull(pointer.getElement());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:SmartPsiElementPointersTest.java


示例17: testFileModified

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
public void testFileModified() throws Exception {
  VirtualFile root = PsiTestUtil.createTestProjectStructure(myProject, myModule, myFilesToDelete);
  VirtualFile pkg = root.createChildDirectory(this, "foo");
  PsiDirectory dir = myPsiManager.findDirectory(pkg);
  assertNotNull(dir);
  String text = "package foo;\n\nclass A {}";
  PsiElement created = dir.add(PsiFileFactory.getInstance(getProject()).createFileFromText("A.java", JavaFileType.INSTANCE, text));
  VirtualFile virtualFile = created.getContainingFile().getVirtualFile();
  assertNotNull(virtualFile);
  String fileText = LoadTextUtil.loadText(virtualFile).toString();
  assertEquals(text, fileText);

  Document doc = FileDocumentManager.getInstance().getDocument(virtualFile);
  assertNotNull(doc);
  assertFalse(FileDocumentManager.getInstance().isDocumentUnsaved(doc));
  assertFalse(FileDocumentManager.getInstance().isFileModified(virtualFile));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AddClassToFileTest.java


示例18: getOptions

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
private static Map<String, Object> getOptions() {
  Map<String, Object> options = ContainerUtil.newHashMap();

  options.put(IFernflowerPreferences.HIDE_DEFAULT_CONSTRUCTOR, "0");
  options.put(IFernflowerPreferences.DECOMPILE_GENERIC_SIGNATURES, "1");
  options.put(IFernflowerPreferences.REMOVE_SYNTHETIC, "1");
  options.put(IFernflowerPreferences.REMOVE_BRIDGE, "1");
  options.put(IFernflowerPreferences.LITERALS_AS_IS, "1");
  options.put(IFernflowerPreferences.NEW_LINE_SEPARATOR, "1");
  options.put(IFernflowerPreferences.BANNER, BANNER);
  options.put(IFernflowerPreferences.MAX_PROCESSING_METHOD, 60);

  Project project = DefaultProjectFactory.getInstance().getDefaultProject();
  CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(project).getCurrentSettings();
  CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(JavaFileType.INSTANCE);
  options.put(IFernflowerPreferences.INDENT_STRING, StringUtil.repeat(" ", indentOptions.INDENT_SIZE));

  if (ApplicationManager.getApplication().isUnitTestMode()) {
    options.put(IFernflowerPreferences.UNIT_TEST_MODE, "1");
  }

  return Collections.unmodifiableMap(options);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:IdeaDecompiler.java


示例19: testInsertVisitLambda

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
public void testInsertVisitLambda() {
  myFixture.addClass("package com.intellij.psi;\n" +
                     "public interface PsiLambdaExpression{}");
  myFixture.addClass("package com.intellij.psi;\n" +
                     "public abstract class JavaRecursiveElementVisitor{}");
  myFixture.addClass("package com.intellij.psi;\n" +
                     "public interface PsiReturnStatement{}");
  myFixture.addClass("package com.intellij.psi;\n" +
                     "public interface PsiClass{}");

  myFixture.configureByText(JavaFileType.INSTANCE, "import com.intellij.psi.*;\n" +
                                                   "class Te<caret>st extends JavaRecursiveElementVisitor {\n" +
                                                   "   public void visitReturnStatement(PsiReturnStatement statement) {}\n" +
                                                   "   public void visitClass(PsiClass aClass) {}\n" +
                                                   "}");
  IntentionAction intention = myFixture.findSingleIntention("Insert visitLambdaExpression method");
  myFixture.launchAction(intention);
  myFixture.checkResult("import com.intellij.psi.*;\n" +
                        "class Test extends JavaRecursiveElementVisitor {\n" +
                        "   public void visitReturnStatement(PsiReturnStatement statement) {}\n" +
                        "   public void visitClass(PsiClass aClass) {}\n" +
                        "\n" +
                        "    public void visitLambdaExpression(PsiLambdaExpression expression) {\n" +
                        "    }\n" +
                        "}");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:UnsafeReturnStatementVisitorTest.java


示例20: getIndentSpecial

import com.intellij.ide.highlighter.JavaFileType; //导入依赖的package包/类
/**
 * Computes indentation of PsiClass, PsiMethod and PsiField elements after formatting
 * @param element PsiClass or PsiMethod or PsiField
 * @return indentation size
 */
private int getIndentSpecial(@NotNull PsiElement element) {
  assert(element instanceof PsiClass ||
         element instanceof PsiField ||
         element instanceof PsiMethod);

  int indentSize = mySettings.getIndentSize(JavaFileType.INSTANCE);
  boolean doNotIndentTopLevelClassMembers = mySettings.getCommonSettings(JavaLanguage.INSTANCE).DO_NOT_INDENT_TOP_LEVEL_CLASS_MEMBERS;

  int indent = 0;
  PsiClass top = PsiUtil.getTopLevelClass(element);
  while (top != null && !element.isEquivalentTo(top)) {
    if (doNotIndentTopLevelClassMembers && element.getParent().isEquivalentTo(top)) {
      break;
    }
    element = element.getParent();
    indent += indentSize;
  }

  return indent;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:CommentFormatter.java



注:本文中的com.intellij.ide.highlighter.JavaFileType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RegisterRequestMessage类代码示例发布时间:2022-05-21
下一篇:
Java ReadCommand类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap