当前位置: 首页>>代码示例>>Java>>正文


Java PythonLanguage类代码示例

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


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

示例1: getCourse

import com.jetbrains.python.PythonLanguage; //导入依赖的package包/类
@NotNull
private static Course getCourse(@NotNull Project project, @NotNull CCNewProjectPanel settingsPanel) {
  final Course course = new Course();
  String name = settingsPanel.getName();
  course.setName(name);
  course.setAuthorsAsString(settingsPanel.getAuthors());
  course.setDescription(settingsPanel.getDescription());

  String language = PythonLanguage.getInstance().getID();
  course.setLanguage(language);
  course.setCourseMode(CCUtils.COURSE_MODE);

  StudyTaskManager.getInstance(project).setCourse(course);
  StudyUtils.registerStudyToolWindow(course, project);
  return course;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:17,代码来源:PyCCProjectGenerator.java

示例2: addPreColonStatements

import com.jetbrains.python.PythonLanguage; //导入依赖的package包/类
private void addPreColonStatements() {
  extend(
    CompletionType.BASIC,
    psiElement()
      .withLanguage(PythonLanguage.getInstance())
      .and(FIRST_ON_LINE)
        //.andNot(RIGHT_AFTER_COLON)
      .andNot(IN_IMPORT_STMT)
      .andNot(IN_PARAM_LIST)
      .andNot(IN_ARG_LIST)
      .andNot(BEFORE_COND)
      .andNot(AFTER_QUALIFIER).andNot(IN_STRING_LITERAL)
    ,
    new CompletionProvider<CompletionParameters>() {
      protected void addCompletions(
        @NotNull final CompletionParameters parameters, final ProcessingContext context, @NotNull final CompletionResultSet result
      ) {
        putKeywords(result, TailType.NONE, PyNames.DEF, PyNames.CLASS, PyNames.FOR, PyNames.IF, PyNames.WHILE, PyNames.WITH);
        putKeywords(result, TailType.CASE_COLON, PyNames.TRY);
      }
    }
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PyKeywordCompletionContributor.java

示例3: addStatements

import com.jetbrains.python.PythonLanguage; //导入依赖的package包/类
private void addStatements() {
  PsiElementPattern.Capture<PsiElement> inStatement = psiElement()
    .withLanguage(PythonLanguage.getInstance())
    .and(IN_BEGIN_STMT)
    .andNot(IN_IMPORT_STMT)
    .andNot(IN_PARAM_LIST)
    .andNot(IN_ARG_LIST)
    .andNot(BEFORE_COND)
    .andNot(AFTER_QUALIFIER);

  extend(
    CompletionType.BASIC,
    inStatement,
    new CompletionProvider<CompletionParameters>() {
      protected void addCompletions(
        @NotNull final CompletionParameters parameters, final ProcessingContext context, @NotNull final CompletionResultSet result
      ) {
        putKeywords(result, TailType.SPACE, PyNames.ASSERT, PyNames.DEL, PyNames.EXEC, PyNames.FROM, PyNames.IMPORT, PyNames.RAISE);
        putKeywords(result, TailType.NONE, PyNames.PASS);
      }
    }
  );

  extend(CompletionType.BASIC, inStatement.andNot(PY3K), new PyKeywordCompletionProvider(TailType.SPACE, PyNames.PRINT));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:PyKeywordCompletionContributor.java

示例4: PySpecialMethodNamesCompletionContributor

import com.jetbrains.python.PythonLanguage; //导入依赖的package包/类
public PySpecialMethodNamesCompletionContributor() {
  extend(
    CompletionType.BASIC,
    psiElement()
      .withLanguage(PythonLanguage.getInstance())
      .and(psiElement().inside(psiElement(PyFunction.class).inside(psiElement(PyClass.class))))
      .and(psiElement().afterLeaf("def"))
   ,
    new CompletionProvider<CompletionParameters>() {
      protected void addCompletions(
        @NotNull final CompletionParameters parameters, final ProcessingContext context, @NotNull final CompletionResultSet result
      ) {
        LanguageLevel languageLevel = LanguageLevel.forElement(parameters.getOriginalFile());
        for (Map.Entry<String, PyNames.BuiltinDescription> entry: PyNames.getBuiltinMethods(languageLevel).entrySet()) {
          LookupElementBuilder item = LookupElementBuilder
            .create(entry.getKey() + entry.getValue().getSignature())
            .bold()
            .withTypeText("predefined")
            .withIcon(PythonIcons.Python.Nodes.Cyan_dot)
          ;
          result.addElement(TailTypeDecorator.withTail(item, TailType.CASE_COLON));
        }
      }
    }
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:PySpecialMethodNamesCompletionContributor.java

示例5: weigh

import com.jetbrains.python.PythonLanguage; //导入依赖的package包/类
@Override
public Comparable weigh(@NotNull final LookupElement element, @NotNull final CompletionLocation location) {
  if (!PsiUtilCore.findLanguageFromElement(location.getCompletionParameters().getPosition()).isKindOf(PythonLanguage.getInstance())) {
    return 0;
  }

  final String name = element.getLookupString();
  final LookupElementPresentation presentation = LookupElementPresentation.renderElement(element);
  // move dict keys to the top
  if ("dict key".equals(presentation.getTypeText())) {
    return element.getLookupString().length();
  }
  if (name.startsWith(DOUBLE_UNDER)) {
    if (name.endsWith(DOUBLE_UNDER)) return -10; // __foo__ is lowest
    else return -5; // __foo is lower than normal
  }
  return 0; // default
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PythonCompletionWeigher.java

示例6: collectRefElements

import com.jetbrains.python.PythonLanguage; //导入依赖的package包/类
@Override
public void collectRefElements(PsiElement psiElement,
                               @Nullable RenameProcessor renameProcessor,
                               @NotNull String newName,
                               Collection<PsiElement> elementsToInvert) {
  final Collection<PsiReference> refs = ReferencesSearch.search(psiElement).findAll();

  for (PsiReference ref : refs) {
    final PsiElement refElement = ref.getElement();
    final PsiElement elementToInvert = getElementToInvert(psiElement, refElement);
    if (elementToInvert != null) {
      elementsToInvert.add(elementToInvert);
    }
    else {
      ContainerUtil.addIfNotNull(elementsToInvert, getForeignElementToInvert(psiElement, refElement, PythonLanguage.getInstance()));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PyInvertBooleanDelegate.java

示例7: doTest

import com.jetbrains.python.PythonLanguage; //导入依赖的package包/类
private void doTest(String newName) {
  final String testName = getTestName(false);
  final String beforeName = testName + ".before.py";
  final String afterName = testName + ".after.py";
  final String dir = "refactoring/extractmethod/";

  myFixture.configureByFile(dir + beforeName);
  final RefactoringSupportProvider provider = LanguageRefactoringSupport.INSTANCE.forLanguage(PythonLanguage.getInstance());
  assertNotNull(provider);
  final RefactoringActionHandler handler = provider.getExtractMethodHandler();
  assertNotNull(handler);
  System.setProperty(PyExtractMethodUtil.NAME, newName);
  try {
    refactorUsingHandler(handler);
  }
  finally {
    System.clearProperty(PyExtractMethodUtil.NAME);
  }
  myFixture.checkResultByFile(dir + afterName);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PyExtractMethodTest.java

示例8: testResultExceedsRightMargin

import com.jetbrains.python.PythonLanguage; //导入依赖的package包/类
public void testResultExceedsRightMargin() {
  final CodeStyleSettings settings = getCodeStyleSettings();
  final CommonCodeStyleSettings commonSettings = settings.getCommonSettings(PythonLanguage.getInstance());

  final int oldRightMargin = settings.getRightMargin(PythonLanguage.getInstance());
  final boolean oldWrapLongLines = commonSettings.WRAP_LONG_LINES;

  settings.setRightMargin(PythonLanguage.getInstance(), 80);
  commonSettings.WRAP_LONG_LINES = true;
  try {
    doTest();
  }
  finally {
    commonSettings.WRAP_LONG_LINES = oldWrapLongLines;
    settings.setRightMargin(PythonLanguage.getInstance(), oldRightMargin);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PyInlineLocalTest.java

示例9: updateToolWindow

import com.jetbrains.python.PythonLanguage; //导入依赖的package包/类
private void updateToolWindow(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    ContentManager contentManager = toolWindow.getContentManager();
    contentManager.removeAllContents(true);

    FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
    Editor selectedEditor = fileEditorManager.getSelectedTextEditor();
    if (selectedEditor == null) return;
    PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(selectedEditor.getDocument());
    if (psiFile == null || !psiFile.getLanguage().equals(PythonLanguage.INSTANCE)) {
        return;
    }

    FileEditor fileEditor = fileEditorManager.getSelectedEditor(psiFile.getVirtualFile());
    StructureView structureView = new PTestStructureViewFactory().getStructureViewBuilder(psiFile).createStructureView(fileEditor, project);

    Content content = ContentFactory.SERVICE.getInstance().createContent(structureView.getComponent(), "", false);
    contentManager.addContent(content);
}
 
开发者ID:KarlGong,项目名称:ptest-pycharm-plugin,代码行数:19,代码来源:PTestViewToolWindowFactory.java

示例10: setVersion

import com.jetbrains.python.PythonLanguage; //导入依赖的package包/类
protected void setVersion(Course course, CCNewProjectPanel panel) {
  String version = panel.getLanguageVersion();
  String language = PythonLanguage.getInstance().getID();
  if (version != null && !ALL_VERSIONS.equals(version)) {
    language += " " + version;
  }
  course.setLanguage(language);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:9,代码来源:PyCCChangeCourseInfo.java

示例11: addBreak

import com.jetbrains.python.PythonLanguage; //导入依赖的package包/类
private void addBreak() {
  extend(
    CompletionType.BASIC, psiElement()
    .withLanguage(PythonLanguage.getInstance())
    .and(IN_BEGIN_STMT)
    .andNot(AFTER_QUALIFIER)
    .andNot(IN_PARAM_LIST)
    .andNot(IN_ARG_LIST)
    .and(IN_LOOP)
    ,
    new PyKeywordCompletionProvider(TailType.NONE, PyNames.BREAK)
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:PyKeywordCompletionContributor.java

示例12: addContinue

import com.jetbrains.python.PythonLanguage; //导入依赖的package包/类
private void addContinue() {
  extend(
    CompletionType.BASIC, psiElement()
    .withLanguage(PythonLanguage.getInstance())
    .and(IN_BEGIN_STMT)
    .andNot(AFTER_QUALIFIER)
    .andNot(IN_PARAM_LIST)
    .andNot(IN_ARG_LIST)
    .andNot(IN_FINALLY_NO_LOOP)
    .and(IN_LOOP)
    ,
    new PyKeywordCompletionProvider(TailType.NONE, PyNames.CONTINUE)
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:PyKeywordCompletionContributor.java

示例13: addWithinIf

import com.jetbrains.python.PythonLanguage; //导入依赖的package包/类
private void addWithinIf() {
  extend(
    CompletionType.BASIC, psiElement()
    .withLanguage(PythonLanguage.getInstance())
    .and(FIRST_ON_LINE)
    .andOr(IN_IF_BODY, AFTER_IF)
    .andNot(AFTER_QUALIFIER).andNot(IN_STRING_LITERAL)
    ,
    new PyKeywordCompletionProvider(TailType.NONE, PyUnindentingInsertHandler.INSTANCE, PyNames.ELIF));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PyKeywordCompletionContributor.java

示例14: addElse

import com.jetbrains.python.PythonLanguage; //导入依赖的package包/类
private void addElse() {
  extend(
    CompletionType.BASIC, psiElement()
    .withLanguage(PythonLanguage.getInstance())
    .and(FIRST_ON_LINE)
    .andOr(IN_COND_STMT, IN_EXCEPT_BODY, AFTER_COND_STMT_NO_ELSE, AFTER_LOOP_NO_ELSE, AFTER_EXCEPT)
    .andNot(AFTER_QUALIFIER).andNot(IN_STRING_LITERAL)
    ,
    new PyKeywordCompletionProvider(TailType.CASE_COLON, PyUnindentingInsertHandler.INSTANCE, PyNames.ELSE));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PyKeywordCompletionContributor.java

示例15: addInfixOperators

import com.jetbrains.python.PythonLanguage; //导入依赖的package包/类
private void addInfixOperators() {
  extend(
    CompletionType.BASIC, psiElement()
    .withLanguage(PythonLanguage.getInstance())
    .andNot(IN_COMMENT)
    .andNot(BEFORE_COND)
    .andNot(IN_IMPORT_STMT) // expressions there are not logical anyway
    .andNot(IN_PARAM_LIST)
    .andNot(AFTER_QUALIFIER).
      andNot(IN_STRING_LITERAL).and(IN_BEGIN_STMT)
    ,
    new PyKeywordCompletionProvider(PyNames.AND, PyNames.OR, PyNames.IS, PyNames.IN)
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:PyKeywordCompletionContributor.java


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