org.netbeans.api.annotations.common.NullAllowed Java Examples
The following examples show how to use
org.netbeans.api.annotations.common.NullAllowed.
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 File: JsonModelResolver.java From netbeans with Apache License 2.0 | 6 votes |
@NonNull private JsObjectImpl createJSObject( @NonNull final JsonParser.ObjectContext objLit, @NullAllowed final JsonParser.PairContext property) { final JsObjectImpl declarationScope = modelBuilder.getCurrentObject(); final Identifier name = property != null ? new Identifier( stringValue(property.key().getText()), createOffsetRange(property.key())) : new Identifier(modelBuilder.getUnigueNameForAnonymObject(parserResult), OffsetRange.NONE); JsObjectImpl object = new JsObjectImpl( declarationScope, name, createOffsetRange(property != null ? property : objLit), true, declarationScope.getMimeType(), declarationScope.getSourceLabel()); declarationScope.addProperty(object.getName(), object); object.setJsKind(JsElement.Kind.OBJECT_LITERAL); if (property == null) { object.setAnonymous(true); } else { object.addOccurrence(name.getOffsetRange()); } return object; }
Example #2
Source File: ClassIndexImpl.java From netbeans with Apache License 2.0 | 6 votes |
private void typesEvent ( @NullAllowed final ClassIndexImplEvent added, @NullAllowed final ClassIndexImplEvent removed, @NullAllowed final ClassIndexImplEvent changed) { WeakReference<ClassIndexImplListener>[] _listeners; synchronized (this.listeners) { _listeners = this.listeners.toArray(new WeakReference[this.listeners.size()]); } for (WeakReference<ClassIndexImplListener> lr : _listeners) { ClassIndexImplListener l = lr.get(); if (l != null) { if (added != null) { l.typesAdded(added); } if (removed != null) { l.typesRemoved(removed); } if (changed != null) { l.typesChanged(changed); } } } }
Example #3
Source File: ImportantFilesSupport.java From netbeans with Apache License 2.0 | 6 votes |
/** * Gets information about all important files. * @param fileInfoCreator custom {@link FileInfoCreator}, can be {@code null} * (in such case, {@link ImportantFilesImplementation.FileInfo#FileInfo(FileObject)} is used) * @return information about all important files; can be empty but never {@code null} */ public Collection<ImportantFilesImplementation.FileInfo> getFiles(@NullAllowed FileInfoCreator fileInfoCreator) { List<ImportantFilesImplementation.FileInfo> files = new ArrayList<>(); for (String name : fileNames) { FileObject fo = directory.getFileObject(name); if (fo != null) { if (fo.isFolder()) { LOGGER.log(Level.INFO, "Expected file but folder given [{0}]", fo); continue; } ImportantFilesImplementation.FileInfo info = null; if (fileInfoCreator != null) { info = fileInfoCreator.create(fo); } if (info == null) { info = new ImportantFilesImplementation.FileInfo(fo); } files.add(info); } } if (files.isEmpty()) { return Collections.emptyList(); } return files; }
Example #4
Source File: TaskProcessor.java From netbeans with Apache License 2.0 | 6 votes |
static <T extends Parser.Result> long callParserResultTask ( final @NonNull ParserResultTask<T> task, final @NullAllowed T result, final @NullAllowed SchedulerEvent event) { assert task != null; assert !Thread.holdsLock(INTERNAL_LOCK); assert parserLock.isHeldByCurrentThread(); sampler.enableSampling(); final long now; final long cancelTime; try { task.run(result, event); } finally { now = System.currentTimeMillis(); cancelTime = sampler.disableSampling(); } return cancelTime == 0 ? 0 : now - cancelTime; }
Example #5
Source File: RunAnalysis.java From netbeans with Apache License 2.0 | 6 votes |
private static @NonNull Scope augment(@NonNull Scope source, @NullAllowed Collection<FileObject> sourceRoots, @NullAllowed Collection<NonRecursiveFolder> folders, @NullAllowed Collection<FileObject> files) { Collection<FileObject> sourceRootsSet = new HashSet<FileObject>(source.getSourceRoots()); if (sourceRoots != null) { sourceRootsSet.addAll(sourceRoots); } Collection<FileObject> filesSet = new HashSet<FileObject>(source.getFiles()); if (files != null) { filesSet.addAll(files); } Collection<NonRecursiveFolder> foldersSet = new HashSet<NonRecursiveFolder>(source.getFolders()); if (folders != null) { foldersSet.addAll(folders); } return Scope.create(sourceRootsSet, foldersSet, filesSet); }
Example #6
Source File: MultiModuleNodeFactory.java From netbeans with Apache License 2.0 | 6 votes |
ModuleKey( @NonNull final Project project, @NonNull final String moduleName, @NullAllowed final MultiModule sourceModules, @NullAllowed final MultiModule testModules, @NonNull final ProcessorGeneratedSources procGenSrc, @NullAllowed final LibrariesSupport libsSupport) { Parameters.notNull("project", project); //NOI18N Parameters.notNull("moduleName", moduleName); //NOI18N Parameters.notNull("procGenSrc", procGenSrc); //NOI18N this.project = project; this.moduleName = moduleName; this.sourceModules = sourceModules; this.testModules = testModules; this.procGenSrc = procGenSrc; this.libsSupport = libsSupport; }
Example #7
Source File: NodeJsSupport.java From netbeans with Apache License 2.0 | 6 votes |
/** * Gets file path (<b>possibly with parameters!</b>) representing <tt>node</tt> executable of the given project * or {@code null} if not set/found. If the project is {@code null}, the default <tt>node</tt> * path is returned (path set in IDE Options). * @param project project to get <tt>node</tt> for, can be {@code null} * @return file path (<b>possibly with parameters!</b>) representing <tt>node</tt> executable, can be {@code null} if not set/found */ @CheckForNull public String getNode(@NullAllowed Project project) { if (project == null) { return getGlobalNode(); } org.netbeans.modules.javascript.nodejs.platform.NodeJsSupport projectNodeJsSupport = getProjectNodeJsSupport(project); if (projectNodeJsSupport == null) { return getGlobalNode(); } NodeJsPreferences preferences = projectNodeJsSupport.getPreferences(); if (!preferences.isEnabled() || preferences.isDefaultNode()) { return getGlobalNode(); } return preferences.getNode(); }
Example #8
Source File: KeyStrokeUtils.java From netbeans with Apache License 2.0 | 6 votes |
/** * Convert an array of {@link KeyStroke key stroke} to a string composed of * human-readable names of these key strokes, delimited by {@code delim}. */ public static String getKeyStrokesAsText( @NullAllowed KeyStroke[] keyStrokes, @NonNull String delim) { if (keyStrokes == null) { return ""; //NOI18N } if (keyStrokes.length == 0) { return ""; //NOI18N } StringBuilder sb = new StringBuilder(getKeyStrokeAsText(keyStrokes[0])); int i, k = keyStrokes.length; for (i = 1; i < k; i++) { sb.append(delim).append(getKeyStrokeAsText(keyStrokes[i])); } return new String(sb); }
Example #9
Source File: JsonFile.java From netbeans with Apache License 2.0 | 6 votes |
private void fireChanges(@NullAllowed Map<String, Object> oldContent, @NullAllowed Map<String, Object> newContent) { if (watchedFields == WatchedFields.ALL) { if (!Objects.equals(oldContent, newContent)) { propertyChangeSupport.firePropertyChange(null, null, null); } return; } List<Pair<String, String[]>> data = watchedFields.getData(); assert data != null; for (Pair<String, String[]> watchedField : data) { String propertyName = watchedField.first(); String[] field = watchedField.second(); Object oldValue = getContentValue(oldContent, Object.class, field); Object newValue = getContentValue(newContent, Object.class, field); if (!Objects.equals(oldValue, newValue)) { propertyChangeSupport.firePropertyChange(propertyName, oldValue, newValue); } } }
Example #10
Source File: ClusteredIndexables.java From netbeans with Apache License 2.0 | 6 votes |
It( @NonNull final Iterator<? extends String> outOfOrderIt, @NullAllowed final ClusteredIndexables deleteIndexables, @NonNull final BitSet deleteFromDeleted, @NullAllowed final ClusteredIndexables indexIndexables, @NonNull final BitSet deleteFromIndex, @NullAllowed final Pair<Long,StackTraceElement[]> attachDeleteStackTrace, @NullAllowed final Pair<Long, StackTraceElement[]> attachIndexStackTrace, @NullAllowed final Pair<Long, StackTraceElement[]> detachDeleteStackTrace, @NullAllowed final Pair<Long, StackTraceElement[]> detachIndexStackTrace) { this.outOfOrderIt = outOfOrderIt; this.deleteIndexables = deleteIndexables; this.deleteFromDeleted = deleteFromDeleted; this.indexIndexables = indexIndexables; this.deleteFromIndex = deleteFromIndex; this.attachDeleteStackTrace = attachDeleteStackTrace; this.attachIndexStackTrace = attachIndexStackTrace; this.detachDeleteStackTrace = detachDeleteStackTrace; this.detachIndexStackTrace = detachIndexStackTrace; }
Example #11
Source File: NetworkSupport.java From netbeans with Apache License 2.0 | 6 votes |
private static File copyToFile(InputStream is, File target, @NullAllowed ProgressHandle progressHandle, int contentLength) throws IOException, InterruptedException { try (OutputStream os = new FileOutputStream(target)) { final byte[] buffer = new byte[65536]; int len; int read = 0; for (;;) { checkInterrupted(); len = is.read(buffer); if (len == -1) { break; } os.write(buffer, 0, len); if (contentLength != -1) { assert progressHandle != null; read += len; progressHandle.progress(read); } } } return target; }
Example #12
Source File: ExistingProjectWizardIterator.java From netbeans with Apache License 2.0 | 6 votes |
private String relativizePath(FileObject projectDir, @NullAllowed FileObject dir) { assert projectDir != null; if (dir == null) { return null; } String relativePath = FileUtil.getRelativePath(projectDir, dir); if (relativePath != null) { return relativePath; } relativePath = PropertyUtils.relativizeFile(FileUtil.toFile(projectDir), FileUtil.toFile(dir)); if (relativePath != null) { return relativePath; } // cannot relativize return FileUtil.toFile(dir).getAbsolutePath(); }
Example #13
Source File: MultiModule.java From netbeans with Apache License 2.0 | 6 votes |
boolean matches( @NullAllowed final SourceRoots modules, @NullAllowed final SourceRoots sources) { final SourceRoots myModules = this.modules.get(); if (myModules == null) { throw REMOVE; } if (myModules != modules) { return false; } final SourceRoots mySources = this.sources.get(); if (mySources == null) { throw REMOVE; } return mySources == sources; }
Example #14
Source File: MultiModuleClassPathProvider.java From netbeans with Apache License 2.0 | 6 votes |
@CheckForNull private ClassPath getModuleLegacyClassPath( @NullAllowed final Owner owner) { if (owner != null && owner.isSource()) { return cacheFor(owner).computeIfAbsent( null, JavaClassPathConstants.MODULE_CLASS_PATH, (mods) -> { return ClassPathFactory.createClassPath(ProjectClassPathSupport.createPropertyBasedClassPathImplementation( projectDirectory, eval, owner.isTest() ? testJavacClassPath : javacClassPath)); }); } else { return null; } }
Example #15
Source File: JavaAntLogger.java From netbeans with Apache License 2.0 | 6 votes |
private static void addPath( @NullAllowed final String path, @NonNull Collection<? super FileObject> collector, final boolean modulepath) { if (path != null) { final StringTokenizer tok = new StringTokenizer(path, File.pathSeparator); while (tok.hasMoreTokens()) { final String binrootS = tok.nextToken(); final File f = FileUtil.normalizeFile(new File(binrootS)); final Collection<? extends File> toAdd = modulepath ? collectModules(f) : Collections.singleton(f); toAdd.forEach((e) -> { final URL binroot = FileUtil.urlForArchiveOrDir(f); if (binroot != null) { final FileObject[] someRoots = SourceForBinaryQuery.findSourceRoots(binroot).getRoots(); Collections.addAll(collector, someRoots); } }); } } }
Example #16
Source File: ActionUtils.java From netbeans with Apache License 2.0 | 6 votes |
/** * Runs an Ant target (or a sequence of them). * @param buildXml an Ant build script * @param targetNames one or more targets to run; or null for the default target * @param properties any Ant properties to define, or null * @param concealedProperties the names of the properties whose values should not be visible to the user or null * @return a task tracking the progress of Ant * @throws IOException if there was a problem starting Ant * @throws IllegalArgumentException if you did not provide any targets * @since 3.71 */ @NonNull public static ExecutorTask runTarget( @NonNull final FileObject buildXml, @NullAllowed final String[] targetNames, @NullAllowed final Properties properties, @NullAllowed final Set<String> concealedProperties) throws IOException, IllegalArgumentException { Parameters.notNull("buildXml", buildXml); //NOI18N if (targetNames != null && targetNames.length == 0) { throw new IllegalArgumentException("No targets supplied"); // NOI18N } AntProjectCookie apc = AntScriptUtils.antProjectCookieFor(buildXml); AntTargetExecutor.Env execenv = new AntTargetExecutor.Env(); if (properties != null) { Properties p = execenv.getProperties(); p.putAll(properties); execenv.setProperties(p); } if (concealedProperties != null) { execenv.setConcealedProperties(concealedProperties); } return AntTargetExecutor.createTargetExecutor(execenv).execute(apc, targetNames); }
Example #17
Source File: RuntimePlatformProblemsProvider.java From netbeans with Apache License 2.0 | 5 votes |
private RuntimePlatformResolver( @NonNull final Project project, @NonNull final String cfgId, @NullAllowed final String cfgDisplayName, @NonNull final Union2<String,InvalidPlatformData> data) { Parameters.notNull("project", project); //NOI18N Parameters.notNull("cfgId", cfgId); //NOI18N Parameters.notNull("data", data); //NOI18N this.prj = project; this.cfgId = cfgId; this.cfgDisplayName = cfgDisplayName == null ? cfgId : cfgDisplayName; this.data = data; }
Example #18
Source File: JsonModelResolver.java From netbeans with Apache License 2.0 | 5 votes |
@NonNull private JsArrayImpl createJsArray( @NonNull final JsonParser.ArrayContext arrayLit, @NullAllowed final JsonParser.PairContext property) { JsObjectImpl declarationScope = modelBuilder.getCurrentObject(); final Identifier name = property != null ? new Identifier( stringValue(property.key().getText()), createOffsetRange(property.key())) : new Identifier(modelBuilder.getUnigueNameForAnonymObject(parserResult), OffsetRange.NONE); JsArrayImpl array = new JsArrayImpl( declarationScope, name, createOffsetRange(property != null ? property : arrayLit), declarationScope.getMimeType(), declarationScope.getSourceLabel()); declarationScope.addProperty(array.getName(), array); array.addAssignment( new TypeUsage(TypeUsage.ARRAY, -1, true), array.getOffset()); array.setDeclared(true); //Todo: Why? but when not set it's not displayed by navigator if (property == null) { array.setAnonymous(true); array.setJsKind(JsElement.Kind.OBJECT_LITERAL); } else { array.setJsKind(JsElement.Kind.PROPERTY); array.addOccurrence(name.getOffsetRange()); } return array; }
Example #19
Source File: Utilities.java From netbeans with Apache License 2.0 | 5 votes |
public static @NonNull Collection<TypeVariable> containedTypevarsRecursively(@NullAllowed TypeMirror tm) { if (tm == null) { return Collections.emptyList(); } Collection<TypeVariable> typeVars = new LinkedList<TypeVariable>(); containedTypevarsRecursively(tm, typeVars); return typeVars; }
Example #20
Source File: Utils.java From netbeans with Apache License 2.0 | 5 votes |
/** * Refreshes a task list indexer. * If an artifact is given it tries to minimize the refresh only to project * owning the artifact. * @param artifact the optional project artifact to minimize the refresh */ public static void refreshTaskListIndex(@NullAllowed FileObject artifact) { final Optional<FileObject> maybeFile = Optional.ofNullable(artifact); if (LOG.isLoggable(Level.FINE)) { LOG.log( Level.FINE, "Refresh task list index with artefact: {0}", //NOI18N maybeFile.map((f)->FileUtil.getFileDisplayName(f)).orElse(null)); } final Optional<Collection<Request>> roots = maybeFile .map((fo) -> FileOwnerQuery.getOwner(fo)) .map((p) -> { return Arrays.stream(ProjectUtils.getSources(p).getSourceGroups(Sources.TYPE_GENERIC)) .map((sg) -> sg.getRootFolder()) .filter((root) -> root != null) .map((root) -> Request.forRoot(root)). collect(Collectors.toList()); }); final Collection<Request> toAdd = roots.isPresent() ? roots.get() : Collections.singleton(Request.all()); final boolean shouldAdd; synchronized (todo) { shouldAdd = !todo.contains(Request.all()); if (shouldAdd) { todo.addAll(toAdd); } } if (LOG.isLoggable(Level.FINE) && shouldAdd) { LOG.log( Level.FINE, "Added requests: {0}", //NOI18N toAdd); } REFRESH_INDEX_TASK.schedule(REFRESH_INDEX_SLIDING); }
Example #21
Source File: JavaTypeProvider.java From netbeans with Apache License 2.0 | 5 votes |
@CheckForNull private static URL toURL(@NullAllowed final URI uri) { try { return uri == null ? null : uri.toURL(); } catch (MalformedURLException ex) { LOGGER.log( Level.FINE, "Cannot convert URI to URL", //NOI18N ex); return null; } }
Example #22
Source File: NodeJsOptions.java From netbeans with Apache License 2.0 | 5 votes |
public void setNodeSources(@NullAllowed String nodeSources) { if (nodeSources == null) { preferences.remove(NODE_SOURCES_PATH); } else { preferences.put(NODE_SOURCES_PATH, nodeSources); } }
Example #23
Source File: ActiveConfigAction.java From netbeans with Apache License 2.0 | 5 votes |
private void configurationsListChanged(@NullAllowed Collection<? extends ProjectConfiguration> configs) { LOGGER.log(Level.FINER, "configurationsListChanged: {0}", configs); ProjectConfigurationProvider<?> _pcp; synchronized (this) { _pcp = pcp; } if (configs == null) { EventQueue.invokeLater(new Runnable() { public @Override void run() { configListCombo.setModel(EMPTY_MODEL); configListCombo.setEnabled(false); // possibly redundant, but just in case } }); } else { final DefaultComboBoxModel model = new DefaultComboBoxModel(configs.toArray()); if (_pcp != null && _pcp.hasCustomizer()) { model.addElement(CUSTOMIZE_ENTRY); } EventQueue.invokeLater(new Runnable() { public @Override void run() { configListCombo.setModel(model); configListCombo.setEnabled(true); } }); } if (_pcp != null) { activeConfigurationChanged(getActiveConfiguration(_pcp)); } }
Example #24
Source File: TaskProcessor.java From netbeans with Apache License 2.0 | 5 votes |
static void cancelParser( final @NonNull Parser parser, final boolean callDeprecatedCancel, final @NonNull Parser.CancelReason cancelReason, final @NullAllowed SourceModificationEvent event) { assert parser != null; assert cancelReason != null; assert !Thread.holdsLock(INTERNAL_LOCK); if (callDeprecatedCancel) { parser.cancel(); } parser.cancel(cancelReason,event); }
Example #25
Source File: ResolveBrokenRuntimePlatform.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates new form ResolveMissingRuntimePlatform */ private ResolveBrokenRuntimePlatform( @NonNull final Type type, @NonNull final Project prj, @NonNull final Union2<String,RuntimePlatformProblemsProvider.InvalidPlatformData> data) { Parameters.notNull("type", type); //NOI18N Parameters.notNull("prj", prj); //NOI18N Parameters.notNull("data", data); //NOI18N this.type = type; this.prj = prj; this.data = data; this.changeSupport = new ChangeSupport(this); initComponents(); platforms.setRenderer(new PlatformRenderer()); platforms.setModel(new DefaultComboBoxModel<JavaPlatform>()); updatePlatforms(); final ActionListener specificPlatformListener = new ActionListener() { @Override public void actionPerformed(@NullAllowed final ActionEvent e) { platforms.setEnabled(specificPlatform.isSelected()); create.setEnabled(specificPlatform.isSelected()); sourceLevelWarning.setEnabled(sourceLevel.isSelected()); changeSupport.fireChange(); } }; specificPlatform.addActionListener(specificPlatformListener); projectPlatform.addActionListener(specificPlatformListener); sourceLevel.addActionListener(specificPlatformListener); specificPlatformListener.actionPerformed(null); projectPlatform.setSelected(true); if (type == Type.MISSING_PLATFORM) { sourceLevel.setVisible(false); sourceLevelWarning.setVisible(false); } }
Example #26
Source File: ElementUtilities.java From netbeans with Apache License 2.0 | 5 votes |
private ElementUtilities( @NonNull final JavacTaskImpl jt, @NullAllowed final CompilationInfo info) { this.ctx = jt.getContext(); this.delegate = ElementsService.instance(ctx); this.info = info; }
Example #27
Source File: JavaTypeProvider.java From netbeans with Apache License 2.0 | 5 votes |
public CacheItem ( @NullAllowed final URL root, @NullAllowed final String cpType, @NullAllowed final DataCacheCallback callBack) throws URISyntaxException { this.cpType = cpType; this.isBinary = ClassPath.BOOT.equals(cpType) || ClassPath.COMPILE.equals(cpType); this.rootURI = root == null ? null : root.toURI(); this.callBack = callBack; }
Example #28
Source File: ReplaceConstructorWithBuilderRefactoring.java From netbeans with Apache License 2.0 | 5 votes |
/** * The only way how to create setter. * @param name the name of the setter. For instance "setA" * @param type the type of the setter. For instance "int" * @param defaultValue the default value. Might be null. For instance "1". * @param varName the name of the variable. For instance "a". * @param optional true if the setter is optional in case, that argument is the same as default value. */ public Setter( @NonNull String name, @NonNull String type, @NullAllowed String defaultValue, @NonNull String varName, boolean optional) { this.name = name; this.type = type; this.optional = optional; this.defaultValue = defaultValue; this.varName = varName; }
Example #29
Source File: Util.java From netbeans with Apache License 2.0 | 5 votes |
@NullUnknown public static Map<String,String> filterProbe ( @NullAllowed final Map<String,String> p, @NullAllowed final String probePath) { if (p != null) { final String val = p.get(J2SEPlatformImpl.SYSPROP_JAVA_CLASS_PATH); if (val != null) { p.put(J2SEPlatformImpl.SYSPROP_JAVA_CLASS_PATH, filterProbe(val, probePath)); } } return p; }
Example #30
Source File: MultiModuleClassPathProvider.java From netbeans with Apache License 2.0 | 5 votes |
@CheckForNull private ClassPath getCompileTimeClasspath( @NullAllowed final Owner owner) { if (owner != null && owner.isSource() && owner.getModuleName() != null) { return cacheFor(owner).computeIfAbsent( owner.getModuleName(), ClassPath.COMPILE, (mods) -> { final ClassPath sourcePath = getSourcepath(owner); final ClassPath systemModules = getModuleBootPath(); final ClassPath modulePath = getModuleCompilePath(owner); if (sourcePath != null && systemModules != null && modulePath != null) { return ClassPathFactory.createClassPath(ModuleClassPaths.createModuleInfoBasedPath( modulePath, sourcePath, systemModules, modulePath, getModuleLegacyClassPath(owner), null)); } else { return null; } }); } else { return null; } }