Java Code Examples for org.jetbrains.annotations.NonNls
The following examples show how to use
org.jetbrains.annotations.NonNls.
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: flutter-intellij Author: flutter File: AddToAppUtils.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
public static <T> T getStaticFieldValue(@NotNull Class objectClass, @Nullable("null means any type") Class<T> fieldType, @NotNull @NonNls String fieldName) { try { final Field field = findAssignableField(objectClass, fieldType, fieldName); if (!Modifier.isStatic(field.getModifiers())) { throw new IllegalArgumentException("Field " + objectClass + "." + fieldName + " is not static"); } field.setAccessible(true); //noinspection unchecked return (T)field.get(null); } catch (NoSuchFieldException | IllegalAccessException e) { return null; } }
Example #2
Source Project: flutter-intellij Author: flutter File: AddToAppUtils.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
public static <T> T getStaticFieldValue(@NotNull Class objectClass, @Nullable("null means any type") Class<T> fieldType, @NotNull @NonNls String fieldName) { try { final Field field = findAssignableField(objectClass, fieldType, fieldName); if (!Modifier.isStatic(field.getModifiers())) { throw new IllegalArgumentException("Field " + objectClass + "." + fieldName + " is not static"); } field.setAccessible(true); //noinspection unchecked return (T)field.get(null); } catch (NoSuchFieldException | IllegalAccessException e) { return null; } }
Example #3
Source Project: p4ic4idea Author: groboclown File: JreSettings.java License: Apache License 2.0 | 5 votes |
@NonNls @Nullable public static String getProperty(@NotNull @NonNls String key, @Nullable String defaultValue) { if (OVERRIDES.containsKey(key)) { String ret = OVERRIDES.get(key); if (ret == null) { ret = defaultValue; } return ret; } return System.getProperty(key, defaultValue); }
Example #4
Source Project: intellij-quarkus Author: redhat-developer File: GradleImportingTestCase.java License: Eclipse Public License 2.0 | 5 votes |
@NotNull protected String injectRepo(@NonNls @Language("Groovy") String config) { config = "allprojects {\n" + " repositories {\n" + " maven {\n" + " url 'http://maven.labs.intellij.net/repo1'\n" + " }\n" + " }" + "}\n" + config; return config; }
Example #5
Source Project: intellij-quarkus Author: redhat-developer File: MavenTestCase.java License: Eclipse Public License 2.0 | 5 votes |
protected VirtualFile updateSettingsXmlFully(@NonNls @Language("XML") String content) throws IOException { File ioFile = new File(myDir, "settings.xml"); ioFile.createNewFile(); VirtualFile f = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ioFile); setFileContent(f, content, true); getMavenGeneralSettings().setUserSettingsFile(f.getPath()); return f; }
Example #6
Source Project: jetbrains-plugin-sample Author: antlr File: IdentifierPSINode.java License: BSD 2-Clause "Simplified" License | 5 votes |
/** Alter this node to have text specified by the argument. Do this by * creating a new node through parsing of an ID and then doing a * replace. */ @Override public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException { if ( getParent()==null ) return this; // weird but it happened once /* IElementType elType = getParent().getNode().getElementType(); String kind = "??? "; if ( elType instanceof RuleIElementType ) { int ruleIndex = ((RuleIElementType) elType).getRuleIndex(); if ( ruleIndex == RULE_call_expr ) { kind = "call "; } else if ( ruleIndex == RULE_statement ) { kind = "assign "; } else if ( ruleIndex == RULE_function ) { kind = "func def "; } } System.out.println("IdentifierPSINode.setName("+name+") on "+ kind+this+" at "+Integer.toHexString(this.hashCode())); */ PsiElement newID = Trees.createLeafFromText(getProject(), SampleLanguage.INSTANCE, getContext(), name, SampleParserDefinition.ID); if ( newID!=null ) { return this.replace(newID); // use replace on leaves but replaceChild on ID nodes that are part of defs/decls. } return this; }
Example #7
Source Project: intellij-bpmn-editor Author: Blenta File: BPMNFileSchemaProvider.java License: GNU General Public License v3.0 | 5 votes |
private static XmlFile getReference(@NotNull @NonNls String url, @NotNull Module module) { if (url.equalsIgnoreCase("http://bpmn.sourceforge.net")) { return null; } final URL resource = BPMNFileSchemaProvider.class.getResource(BPMNModelConstants.BPMN_SCHEMA_BASEURI + BPMNModelConstants.BPMN_SYSTEM_ID); final VirtualFile fileByURL = VfsUtil.findFileByURL(resource); if (fileByURL == null) { return null; } PsiFile psiFile = PsiManager.getInstance(module.getProject()).findFile(fileByURL); return (XmlFile) psiFile.copy(); }
Example #8
Source Project: react-templates-plugin Author: idok File: AbstractCreateFormAction.java License: MIT License | 5 votes |
protected String createFormBody(@Nullable String fqn, @NonNls String formName, String layoutManager) throws IncorrectOperationException { String s = ""; try { s = FileUtil.loadTextAndClose(getClass().getResourceAsStream(formName)); } catch (IOException e) { // throw new IncorrectOperationException(RTBundle.message("error.cannot.read", formName), (Throwable)e); } s = fqn == null ? StringUtil.replace(s, "bind-to-class=\"$CLASS$\"", "") : StringUtil.replace(s, "$CLASS$", fqn); s = StringUtil.replace(s, "$LAYOUT$", layoutManager); return StringUtil.convertLineSeparators(s); }
Example #9
Source Project: BashSupport Author: BashSupport File: BashSdkLexerTest.java License: Apache License 2.0 | 5 votes |
protected void doTest(@NonNls String text, @Nullable String expected, @NotNull Lexer lexer) { String result = printTokens(text, 0, lexer); if (expected != null) { assertSameLines(expected, result); } else { // changed from the original code in LexerTestCase // LexerTestCase is expecting that the test is part of the IntelliJ repository // BashSupport is not, so we get rid of the call to PathManager.getHomePath() assertSameLinesWithFile(getDirPath() + "/" + getTestName(true) + ".txt", result); } }
Example #10
Source Project: netbeans-mmd-plugin Author: raydac File: MindMapDocumentEditor.java License: Apache License 2.0 | 5 votes |
@org.jetbrains.annotations.Nullable @Override public Object getData(@NonNls String s) { if (PlatformDataKeys.COPY_PROVIDER.is(s) || PlatformDataKeys.CUT_PROVIDER.is(s) || PlatformDataKeys.PASTE_PROVIDER.is(s)) { return this; } return null; }
Example #11
Source Project: mule-intellij-plugins Author: machaval File: MuleSchemaProvider.java License: Apache License 2.0 | 5 votes |
@Override public Set<String> getLocations(@NotNull @NonNls final String namespace, @NotNull final XmlFile context) throws ProcessCanceledException { Set<String> locations = new HashSet<>(); final Module module = ModuleUtil.findModuleForPsiElement(context); if (module == null) { return null; } try { final Map<String, XmlFile> schemas = getSchemas(module); for (Map.Entry<String, XmlFile> entry : schemas.entrySet()) { final String s = getNamespace(entry.getValue(), context.getProject()); if (s != null && s.equals(namespace)) { if (!entry.getKey().contains("mule-httpn.xsd")) { locations.add(entry.getKey()); //Observe the formatting rules XmlFile schemaFile = entry.getValue(); try { String url = schemaFile.getVirtualFile().getUrl(); if (url != null) { if (url.startsWith("jar://")) url = url.substring(6); ExternalResourceManager.getInstance().addResource(namespace, url); } } catch (Throwable ex) { Notifications.Bus.notify(new Notification("Schema Provider", "Schema Provider", ex.toString(), NotificationType.ERROR)); } } } } } catch (Exception e) { e.printStackTrace(); } return locations; }
Example #12
Source Project: weex-language-support Author: misakuo File: NewWeFileActionBase.java License: MIT License | 5 votes |
protected PsiFile createFileFromTemplate(final PsiDirectory directory, String className, @NonNls String templateName, @NonNls String... parameters) throws IncorrectOperationException { final String ext = "." + WeexFileType.INSTANCE.getDefaultExtension(); String filename = (className.endsWith(ext)) ? className : className + ext; return WeexTemplateFactory.createFromTemplate(directory, className, filename, templateName, parameters); }
Example #13
Source Project: p4ic4idea Author: groboclown File: VcsDockedComponent.java License: Apache License 2.0 | 5 votes |
public boolean addVcsTab(@NotNull @NonNls String title, @NotNull JComponent component, boolean showTab, boolean replaceExistingComponent) { if (component instanceof Disposable) { Disposer.register(this, (Disposable) component); } final ToolWindow toolW = getToolWindow(); if (toolW == null) { // cannot do anything return false; } final ContentManager contentManager = getToolWindow().getContentManager(); final Content existingContent = contentManager.findContent(title); if (existingContent != null) { if (!replaceExistingComponent) { contentManager.setSelectedContent(existingContent); return true; } else if (!existingContent.isPinned()) { contentManager.removeContent(existingContent, true); existingContent.release(); } } final Content content = contentManager.getFactory().createContent(component, title, false); contentManager.addContent(content); if (showTab) { getToolWindow().activate(null, false); } return true; }
Example #14
Source Project: flutter-intellij Author: flutter File: PropertyEditorPanel.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
public static Balloon showPopup( InspectorGroupManagerService inspectorGroupManagerService, Project project, Component component, @Nullable DiagnosticsNode node, @NonNls InspectorService.Location location, FlutterDartAnalysisServer service, Point point ) { final Balloon balloon = showPopupHelper(inspectorGroupManagerService, project, node, location, service); balloon.show(new RelativePoint(component, point), Balloon.Position.above); return balloon; }
Example #15
Source Project: BashSupport Author: BashSupport File: BashVarImpl.java License: Apache License 2.0 | 5 votes |
@Override public PsiElement setName(@NonNls @NotNull String newName) throws IncorrectOperationException { if (!BashIdentifierUtil.isValidNewVariableName(newName)) { throw new IncorrectOperationException("Invalid variable name"); } PsiElement replacement = BashPsiElementFactory.createVariable(getProject(), newName, isParameterExpansion()); return BashPsiUtils.replaceElement(this, replacement); }
Example #16
Source Project: attic-polygene-java Author: apache File: AbstractCreateElementActionBase.java License: Apache License 2.0 | 5 votes |
protected static PsiClass createClassFromTemplate( @NotNull PsiDirectory directory, @NotNull String className, @NotNull String templateName, @NonNls String... parameters ) throws IncorrectOperationException { String classFileName = className + "." + StdFileTypes.JAVA.getDefaultExtension(); PsiFile file = createFromTemplateInternal( directory, className, classFileName, templateName, parameters ); return ( (PsiJavaFile) file ).getClasses()[ 0 ]; }
Example #17
Source Project: BashSupport Author: BashSupport File: AbstractInspectionTestCase.java License: Apache License 2.0 | 5 votes |
@Pattern("[a-zA-Z_0-9.-]+") @Override @NotNull @NonNls public String getID() { return delegate.getID(); }
Example #18
Source Project: sqlitemagic Author: SiimKinks File: SqliteMagicLightModifierList.java License: Apache License 2.0 | 5 votes |
public void setModifierProperty(@PsiModifier.ModifierConstant @NotNull @NonNls String name, boolean value) throws IncorrectOperationException { if (value) { addModifier(name); } else { if (hasModifierProperty(name)) { removeModifier(name); } } }
Example #19
Source Project: sqlitemagic Author: SiimKinks File: SqliteMagicLightModifierList.java License: Apache License 2.0 | 5 votes |
private void removeModifier(@PsiModifier.ModifierConstant @NotNull @NonNls String name) { final Collection<String> myModifiers = collectAllModifiers(); myModifiers.remove(name); clearModifiers(); for (String modifier : myModifiers) { addModifier(modifier); } }
Example #20
Source Project: p4ic4idea Author: groboclown File: JreSettings.java License: Apache License 2.0 | 5 votes |
@NonNls @Nullable public static String getEnv(@NotNull @NonNls String key) { if (OVERRIDES.containsKey(key)) { // even if null! return OVERRIDES.get(key); } return System.getenv(key); }
Example #21
Source Project: sqlitemagic Author: SiimKinks File: SqliteMagicLightModifierList.java License: Apache License 2.0 | 5 votes |
@Override @NotNull public PsiAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) { final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(getProject()).getElementFactory(); final PsiAnnotation psiAnnotation = elementFactory.createAnnotationFromText('@' + qualifiedName, null); myAnnotations.put(qualifiedName, psiAnnotation); return psiAnnotation; }
Example #22
Source Project: attic-polygene-java Author: apache File: PolygeneApplicationComponent.java License: Apache License 2.0 | 5 votes |
public final FileTemplateGroupDescriptor getFileTemplatesDescriptor() { FileTemplateGroupDescriptor group = new FileTemplateGroupDescriptor( message( "polygene.file.template.group.title" ), null ); FileTypeManager fileTypeManager = FileTypeManager.getInstance(); for( @NonNls String template : FILE_TEMPLATES ) { Icon icon = fileTypeManager.getFileTypeByFileName( template ).getIcon(); group.addTemplate( new FileTemplateDescriptor( template, icon ) ); } return group; }
Example #23
Source Project: vue-for-idea Author: henjue File: NewVueActionBase.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
protected static PsiFile createFileFromTemplate(final PsiDirectory directory, String className, @NonNls String templateName, @NonNls String... parameters) throws IncorrectOperationException { final String ext = "." + VueFileType.INSTANCE.getDefaultExtension(); String filename = (className.endsWith(ext)) ? className : className + ext; return VueTemplatesFactory.createFromTemplate(directory, className, filename, templateName, parameters); }
Example #24
Source Project: aem-ide-tooling-4-intellij Author: headwirecom File: ConsoleLogToolWindowFactory.java License: Apache License 2.0 | 5 votes |
static void createContent(Project project, ToolWindow toolWindow, ConsoleLogConsole console, String title) { // update default Event Log tab title ContentManager contentManager = toolWindow.getContentManager(); Content generalContent = contentManager.getContent(0); if (generalContent != null && contentManager.getContentCount() == 1) { generalContent.setDisplayName("General"); } final Editor editor = console.getConsoleEditor(); SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true) { @Override public Object getData(@NonNls String dataId) { return PlatformDataKeys.HELP_ID.is(dataId) ? ConsoleLog.HELP_ID : super.getData(dataId); } }; panel.setContent(editor.getComponent()); panel.addAncestorListener(new LogShownTracker(project)); ActionToolbar toolbar = createToolbar(project, editor, console); toolbar.setTargetComponent(editor.getContentComponent()); panel.setToolbar(toolbar.getComponent()); Content content = ContentFactory.SERVICE.getInstance().createContent(panel, title, false); contentManager.addContent(content); contentManager.setSelectedContent(content); }
Example #25
Source Project: js-graphql-intellij-plugin Author: jimkyndemeyer File: GraphQLTokenType.java License: MIT License | 4 votes |
public GraphQLTokenType(@NotNull @NonNls String debugName) { super(debugName, GraphQLLanguage.INSTANCE); }
Example #26
Source Project: intellij-quarkus Author: redhat-developer File: GradleImportingTestCase.java License: Eclipse Public License 2.0 | 4 votes |
protected void importProjectUsingSingeModulePerGradleProject(@NonNls @Language("Groovy") String config) throws IOException { getCurrentExternalProjectSettings().setResolveModulePerSourceSet(false); importProject(config); }
Example #27
Source Project: p4ic4idea Author: groboclown File: MessageP4RequestErrorHandler.java License: Apache License 2.0 | 4 votes |
@Nls(capitalization = Nls.Capitalization.Sentence) @NotNull protected abstract String getMessage(@NonNls @NotNull String messageKey, @NotNull Throwable t, Object... arguments);
Example #28
Source Project: BashSupport Author: BashSupport File: BashResolveUtil.java License: Apache License 2.0 | 4 votes |
public static boolean isNotIndexedFile(@NonNls Project project, @Nullable VirtualFile virtualFile) { return virtualFile == null || virtualFile instanceof VirtualFileWindow || !FileIndexFacade.getInstance(project).isInContent(virtualFile); }
Example #29
Source Project: azure-devops-intellij Author: microsoft File: TFSProjectConfigurable.java License: MIT License | 4 votes |
@NonNls public String getHelpTopic() { return null; }
Example #30
Source Project: intellij-jsonnet Author: databricks File: JsonnetElementType.java License: Apache License 2.0 | 4 votes |
public JsonnetElementType(@NotNull @NonNls String debugName) { super(debugName, JsonnetLanguage.INSTANCE); }