use of com.intellij.openapi.project.Project in project Main by SpartanRefactoring.
the class SpartanizerAnnotator method annotate.
@Override
public void annotate(@NotNull final PsiElement e, @NotNull AnnotationHolder h) {
try {
if (!Spartanizer.canTip(e) || e.getContainingFile().getName().contains("Spartanizer"))
return;
Annotation annotation = h.createInfoAnnotation(e, "Spartanize This!");
annotation.registerFix(new IntentionAction() {
@SuppressWarnings("unchecked")
@Nls
@NotNull
@Override
public String getText() {
return Toolbox.getInstance().getTipper(e).description(e);
}
@Nls
@NotNull
@Override
public String getFamilyName() {
return "SpartanizerAction";
}
@Override
public boolean isAvailable(@NotNull Project __, Editor e, PsiFile f) {
return true;
}
@Override
public void invoke(@NotNull Project p, Editor ed, PsiFile f) throws IncorrectOperationException {
Spartanizer.spartanizeElement(e);
}
@Override
public boolean startInWriteAction() {
return false;
}
});
TextAttributesKey.createTextAttributesKey("");
annotation.setEnforcedTextAttributes((new TextAttributes(null, null, JBColor.BLUE, EffectType.WAVE_UNDERSCORE, 0)));
} catch (Throwable t) {
Logger l = new Logger(this.getClass());
l.error("", t);
}
}
use of com.intellij.openapi.project.Project in project kotlin by JetBrains.
the class KotlinTestNgConfigurationProducer method setupConfigurationFromContext.
@Override
protected boolean setupConfigurationFromContext(TestNGConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
// TODO: check TestNG Pattern running first, before method/class (see TestNGInClassConfigurationProducer for logic)
// TODO: and PsiClassOwner not handled, which is in TestNGInClassConfigurationProducer
Location location = context.getLocation();
if (location == null) {
return false;
}
Project project = context.getProject();
PsiElement leaf = location.getPsiElement();
if (!ProjectRootsUtil.isInProjectOrLibSource(leaf)) {
return false;
}
if (!(leaf.getContainingFile() instanceof KtFile)) {
return false;
}
KtFile ktFile = (KtFile) leaf.getContainingFile();
if (TargetPlatformDetector.getPlatform(ktFile) != JvmPlatform.INSTANCE) {
return false;
}
KtNamedDeclaration declarationToRun = getDeclarationToRun(leaf);
if (declarationToRun instanceof KtNamedFunction) {
KtNamedFunction function = (KtNamedFunction) declarationToRun;
@SuppressWarnings("unchecked") KtElement owner = PsiTreeUtil.getParentOfType(function, KtFunction.class, KtClass.class);
if (owner instanceof KtClass) {
PsiClass delegate = toLightClass((KtClass) owner);
if (delegate != null) {
for (PsiMethod method : delegate.getMethods()) {
if (method.getNavigationElement() == function) {
if (TestNGUtil.hasTest(method)) {
return configure(configuration, location, context, project, delegate, method);
}
break;
}
}
}
}
}
if (declarationToRun instanceof KtClass) {
PsiClass delegate = toLightClass((KtClassOrObject) declarationToRun);
if (!isTestNGClass(delegate)) {
return false;
}
return configure(configuration, location, context, project, delegate, null);
}
return false;
}
use of com.intellij.openapi.project.Project in project intellij-community by JetBrains.
the class DomDescriptorProvider method getDescriptor.
@Override
@Nullable
public XmlElementDescriptor getDescriptor(final XmlTag tag) {
Project project = tag.getProject();
if (project.isDefault())
return null;
final DomInvocationHandler<?, ?> handler = DomManagerImpl.getDomManager(project).getDomHandler(tag);
if (handler != null) {
final DefinesXml definesXml = handler.getAnnotation(DefinesXml.class);
if (definesXml != null) {
return new DomElementXmlDescriptor(handler);
}
final PsiElement parent = tag.getParent();
if (parent instanceof XmlTag) {
final XmlElementDescriptor descriptor = ((XmlTag) parent).getDescriptor();
if (descriptor instanceof DomElementXmlDescriptor) {
return descriptor.getElementDescriptor(tag, (XmlTag) parent);
}
}
}
return null;
}
use of com.intellij.openapi.project.Project in project intellij-community by JetBrains.
the class DynamicGenericInfo method runDomExtenders.
@Nullable
private DomExtensionsRegistrarImpl runDomExtenders() {
DomExtensionsRegistrarImpl registrar = null;
final Project project = myInvocationHandler.getManager().getProject();
DomExtenderEP[] extenders = Extensions.getExtensions(DomExtenderEP.EP_NAME);
if (extenders.length > 0) {
for (final DomExtenderEP extenderEP : extenders) {
registrar = extenderEP.extend(project, myInvocationHandler, registrar);
}
}
final AbstractDomChildDescriptionImpl description = myInvocationHandler.getChildDescription();
if (description != null) {
final List<DomExtender> extendersFromParent = description.getUserData(DomExtensionImpl.DOM_EXTENDER_KEY);
if (extendersFromParent != null) {
if (registrar == null)
registrar = new DomExtensionsRegistrarImpl();
for (final DomExtender extender : extendersFromParent) {
//noinspection unchecked
extender.registerExtensions(myInvocationHandler.getProxy(), registrar);
}
}
}
return registrar;
}
use of com.intellij.openapi.project.Project in project intellij-community by JetBrains.
the class EditorTextFieldControl method createMainComponent.
@Override
protected T createMainComponent(T boundedComponent) {
final Project project = getProject();
boundedComponent = createMainComponent(boundedComponent, project);
final EditorTextField editorTextField = getEditorTextField(boundedComponent);
editorTextField.setSupplementary(true);
editorTextField.getDocument().addDocumentListener(myListener);
return boundedComponent;
}
Aggregations