use of org.jetbrains.annotations.NotNull in project intellij-community by JetBrains.
the class SpellCheckerDictionaryGenerator method processLeafsNames.
protected void processLeafsNames(@NotNull final PsiElement leafElement, @NotNull final HashSet<String> seenNames) {
final Language language = leafElement.getLanguage();
SpellCheckingInspection.tokenize(leafElement, language, new TokenConsumer() {
@Override
public void consumeToken(PsiElement element, final String text, boolean useRename, int offset, TextRange rangeToCheck, Splitter splitter) {
splitter.split(text, rangeToCheck, textRange -> {
final String word = textRange.substring(text);
addSeenWord(seenNames, word, language);
});
}
});
}
use of org.jetbrains.annotations.NotNull in project intellij-community by JetBrains.
the class PyClassRefactoringTest method findMember.
/**
* @param className class where member should be found
* @param memberName member that starts with dot (<code>.</code>) is treated as method.
* member that starts with dash (<code>#</code>) is treated as attribute.
* It is treated parent class otherwise
* @return member or null if not found
*/
@NotNull
protected PyElement findMember(@NotNull final String className, @NotNull String memberName) {
final PyElement result;
//TODO: Get rid of this chain of copy pastes
if (memberName.contains(".")) {
result = findMethod(className, memberName.substring(1));
} else if (memberName.contains("#")) {
result = findField(className, memberName.substring(1));
} else {
result = findClass(memberName);
}
Assert.assertNotNull(String.format("No member %s found in class %s", memberName, className), result);
return result;
}
use of org.jetbrains.annotations.NotNull in project intellij-community by JetBrains.
the class PyExtractSuperclassPresenterTest method configureByClass.
/**
* Configures presenter by class
*
* @param name name of class
* @return presenter
*/
@NotNull
private PyExtractSuperclassPresenterImpl configureByClass(@NotNull final String name) {
final PyClass childClass = getClassByName(name);
final PyMemberInfoStorage storage = new PyMemberInfoStorage(childClass);
return new PyExtractSuperclassPresenterImpl(myView, childClass, storage);
}
use of org.jetbrains.annotations.NotNull in project intellij-community by JetBrains.
the class XmlUnusedNamespaceInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new XmlElementVisitor() {
@Override
public void visitXmlAttribute(XmlAttribute attribute) {
PsiFile file = holder.getFile();
if (!(file instanceof XmlFile))
return;
XmlRefCountHolder refCountHolder = XmlRefCountHolder.getRefCountHolder((XmlFile) file);
if (refCountHolder == null)
return;
if (!attribute.isNamespaceDeclaration()) {
checkUnusedLocations(attribute, holder, refCountHolder);
return;
}
String namespace = attribute.getValue();
String declaredPrefix = getDeclaredPrefix(attribute);
if (namespace != null && !refCountHolder.isInUse(declaredPrefix)) {
ImplicitUsageProvider[] implicitUsageProviders = Extensions.getExtensions(ImplicitUsageProvider.EP_NAME);
for (ImplicitUsageProvider provider : implicitUsageProviders) {
if (provider.isImplicitUsage(attribute))
return;
}
XmlAttributeValue value = attribute.getValueElement();
assert value != null;
holder.registerProblem(attribute, XmlBundle.message("xml.inspections.unused.schema.declaration"), ProblemHighlightType.LIKE_UNUSED_SYMBOL, new RemoveNamespaceDeclarationFix(declaredPrefix, false, !refCountHolder.isUsedNamespace(namespace)));
XmlTag parent = attribute.getParent();
if (declaredPrefix.isEmpty()) {
XmlAttribute location = getDefaultLocation(parent);
if (location != null) {
holder.registerProblem(location, XmlBundle.message("xml.inspections.unused.schema.location"), ProblemHighlightType.LIKE_UNUSED_SYMBOL, new RemoveNamespaceDeclarationFix(declaredPrefix, true, true));
}
} else if (!refCountHolder.isUsedNamespace(namespace)) {
for (PsiReference reference : getLocationReferences(namespace, parent)) {
if (!XmlHighlightVisitor.hasBadResolve(reference, false))
holder.registerProblemForReference(reference, ProblemHighlightType.LIKE_UNUSED_SYMBOL, XmlBundle.message("xml.inspections.unused.schema.location"), new RemoveNamespaceDeclarationFix(declaredPrefix, true, true));
}
}
}
}
};
}
use of org.jetbrains.annotations.NotNull in project intellij-community by JetBrains.
the class HtmlLocalInspectionTool method buildVisitor.
@Override
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
return new XmlElementVisitor() {
@Override
public void visitXmlToken(final XmlToken token) {
IElementType tokenType = token.getTokenType();
if (tokenType == XmlTokenType.XML_NAME || tokenType == XmlTokenType.XML_TAG_NAME) {
PsiElement element = token.getPrevSibling();
while (element instanceof PsiWhiteSpace) element = element.getPrevSibling();
if (element instanceof XmlToken && ((XmlToken) element).getTokenType() == XmlTokenType.XML_START_TAG_START) {
PsiElement parent = element.getParent();
if (parent instanceof XmlTag && !(token.getNextSibling() instanceof OuterLanguageElement)) {
XmlTag tag = (XmlTag) parent;
checkTag(tag, holder, isOnTheFly);
}
}
}
}
@Override
public void visitXmlAttribute(final XmlAttribute attribute) {
checkAttribute(attribute, holder, isOnTheFly);
}
};
}
Aggregations