Search in sources :

Example 6 with NotNull

use of org.jetbrains.annotations.NotNull in project qi4j-sdk by Qi4j.

the class AbstractCreateElementActionBase method invokeDialog.

@NotNull
protected final PsiElement[] invokeDialog(Project project, PsiDirectory directory) {
    Module module = ModuleUtil.findModuleForFile(directory.getVirtualFile(), project);
    if (module == null) {
        return PsiElement.EMPTY_ARRAY;
    }
    MyInputValidator validator = doInvokeDialog(project, directory);
    return validator.getCreatedElements();
}
Also used : Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with NotNull

use of org.jetbrains.annotations.NotNull in project qi4j-sdk by Qi4j.

the class Qi4jConcernUtil method addOrReplaceConcernAnnotation.

@NotNull
public static PsiAnnotation addOrReplaceConcernAnnotation(@NotNull PsiModifierListOwner modifierListOwner, @NotNull PsiClass concernClassToAdd) {
    Project project = modifierListOwner.getProject();
    JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
    PsiElementFactory factory = psiFacade.getElementFactory();
    PsiAnnotation existingConcernsAnnotation = findAnnotation(modifierListOwner, QUALIFIED_NAME_CONCERNS);
    boolean isReplace = false;
    PsiAnnotation newConcernsAnnotation;
    if (existingConcernsAnnotation != null) {
        // Check duplicate
        List<PsiAnnotationMemberValue> concernsValues = getConcernsAnnotationValue(existingConcernsAnnotation);
        for (PsiAnnotationMemberValue concernValue : concernsValues) {
            PsiJavaCodeReferenceElement concernClassReference = getConcernClassReference(concernValue);
            if (concernClassReference == null) {
                continue;
            }
            PsiElement concernClass = concernClassReference.resolve();
            if (concernClassToAdd.equals(concernClass)) {
                return existingConcernsAnnotation;
            }
        }
        isReplace = true;
    }
    String concernAnnotationText = createConcernAnnotationText(existingConcernsAnnotation, concernClassToAdd);
    newConcernsAnnotation = factory.createAnnotationFromText(concernAnnotationText, modifierListOwner);
    if (isReplace) {
        // Replace @Concerns instead
        existingConcernsAnnotation.replace(newConcernsAnnotation);
    } else {
        // @Concerns doesn't exists, add it as first child
        PsiModifierList modifierList = modifierListOwner.getModifierList();
        modifierList.addBefore(newConcernsAnnotation, modifierList.getFirstChild());
    }
    // Shorten all class references if possible
    JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(project);
    codeStyleManager.shortenClassReferences(newConcernsAnnotation);
    return newConcernsAnnotation;
}
Also used : Project(com.intellij.openapi.project.Project) JavaCodeStyleManager(com.intellij.psi.codeStyle.JavaCodeStyleManager) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with NotNull

use of org.jetbrains.annotations.NotNull in project qi4j-sdk by Qi4j.

the class Qi4jServiceAnnotationUtil method isValidServiceAnnotationDeclaration.

/**
     * Validates whether the variable has {@code @Service} annotation declared correctly.
     *
     * @param variable variable to check.
     * @return Look at {@link ServiceAnnotationDeclarationValidationResult}.
     * @since 0.1
     */
@NotNull
public static ServiceAnnotationDeclarationValidationResult isValidServiceAnnotationDeclaration(@NotNull PsiVariable variable) {
    PsiAnnotation serviceAnnotation = getServiceAnnotation(variable);
    if (serviceAnnotation == null) {
        return invalidServiceAnnotationNotDeclared;
    }
    PsiModifierList modifierList = variable.getModifierList();
    if (modifierList != null) {
        if (modifierList.hasModifierProperty(STATIC)) {
            return invalidDeclaredOnStaticVariable;
        }
    }
    // Can't be type that is injected by @Structure
    if (isInjecteableByStructureAnnotation(variable)) {
        return invalidTypeIsInjectedViaStructureAnnotation;
    }
    return valid;
}
Also used : PsiAnnotation(com.intellij.psi.PsiAnnotation) PsiModifierList(com.intellij.psi.PsiModifierList) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with NotNull

use of org.jetbrains.annotations.NotNull in project actor-platform by actorapp.

the class PeerConnectionActor method onOffer.

public void onOffer(final long sessionId, @NotNull String sdp) {
    // Ignore if we are not waiting for handshake
    if (state != PeerConnectionState.WAITING_HANDSHAKE) {
        return;
    }
    // Ignore if we already have session id
    if (this.sessionId != -1) {
        return;
    }
    //
    // Stages
    // 1. Set Remote Description
    // 2. Create Answer
    // 3. Set Local Description
    // 4. Send Answer
    // 5. Enter READY mode
    //
    isReady = false;
    peerConnection.setRemoteDescription(new WebRTCSessionDescription("offer", sdp)).flatMap(description -> {
        return peerConnection.createAnswer();
    }).flatMap(webRTCSessionDescription -> {
        return peerConnection.setLocalDescription(SDPOptimizer.optimize(webRTCSessionDescription));
    }).then(webRTCSessionDescription -> {
        callback.onAnswer(sessionId, webRTCSessionDescription.getSdp());
        PeerConnectionActor.this.sessionId = sessionId;
        onHandShakeCompleted(sessionId);
        onReady();
    }).failure(e -> {
        e.printStackTrace();
        onHandshakeFailure();
    });
}
Also used : ModuleContext(im.actor.core.modules.ModuleContext) WebRTCMediaTrack(im.actor.runtime.webrtc.WebRTCMediaTrack) WebRTC(im.actor.runtime.WebRTC) CountedReference(im.actor.runtime.function.CountedReference) WebRTCSettings(im.actor.runtime.webrtc.WebRTCSettings) ActorCreator(im.actor.runtime.actors.ActorCreator) Void(im.actor.runtime.actors.messages.Void) ApiICEServer(im.actor.core.api.ApiICEServer) Promise(im.actor.runtime.promise.Promise) AskMessage(im.actor.runtime.actors.ask.AskMessage) ManagedList(im.actor.runtime.collections.ManagedList) WebRTCPeerConnection(im.actor.runtime.webrtc.WebRTCPeerConnection) WebRTCPeerConnectionCallback(im.actor.runtime.webrtc.WebRTCPeerConnectionCallback) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) ModuleActor(im.actor.core.modules.ModuleActor) WebRTCSessionDescription(im.actor.runtime.webrtc.WebRTCSessionDescription) Property(com.google.j2objc.annotations.Property) WebRTCIceServer(im.actor.runtime.webrtc.WebRTCIceServer) Log(im.actor.runtime.Log) NotNull(org.jetbrains.annotations.NotNull) WebRTCMediaStream(im.actor.runtime.webrtc.WebRTCMediaStream) WebRTCSessionDescription(im.actor.runtime.webrtc.WebRTCSessionDescription)

Example 10 with NotNull

use of org.jetbrains.annotations.NotNull in project actor-platform by actorapp.

the class ContactContent method create.

@NotNull
public static ContactContent create(@NotNull String name, @NotNull ArrayList<String> phones, @NotNull ArrayList<String> emails, @Nullable String base64photo) {
    try {
        JSONObject obj = new JSONObject();
        obj.put("dataType", "contact");
        JSONObject contact = new JSONObject();
        contact.put("name", name);
        if (base64photo != null) {
            contact.put("photo", base64photo);
        }
        JSONArray phoneArray = new JSONArray();
        for (String phone : phones) {
            phoneArray.put(phone);
        }
        JSONArray emailArray = new JSONArray();
        for (String phone : emails) {
            emailArray.put(phone);
        }
        contact.put("emails", emailArray);
        contact.put("phones", phoneArray);
        JSONObject data = new JSONObject();
        data.put("contact", contact);
        obj.put("data", data);
        return new ContactContent(new ContentRemoteContainer(new ApiJsonMessage(obj.toString())));
    } catch (JSONException e) {
        throw new RuntimeException(e);
    }
}
Also used : JSONObject(im.actor.runtime.json.JSONObject) JSONArray(im.actor.runtime.json.JSONArray) ContentRemoteContainer(im.actor.core.entity.content.internal.ContentRemoteContainer) JSONException(im.actor.runtime.json.JSONException) ApiJsonMessage(im.actor.core.api.ApiJsonMessage) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NotNull (org.jetbrains.annotations.NotNull)6249 VirtualFile (com.intellij.openapi.vfs.VirtualFile)829 ArrayList (java.util.ArrayList)617 Project (com.intellij.openapi.project.Project)540 File (java.io.File)531 PsiElement (com.intellij.psi.PsiElement)461 Nullable (org.jetbrains.annotations.Nullable)391 Module (com.intellij.openapi.module.Module)315 PsiFile (com.intellij.psi.PsiFile)296 List (java.util.List)272 IOException (java.io.IOException)263 TextRange (com.intellij.openapi.util.TextRange)245 ContainerUtil (com.intellij.util.containers.ContainerUtil)170 Document (com.intellij.openapi.editor.Document)158 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)154 ASTNode (com.intellij.lang.ASTNode)145 Pair (com.intellij.openapi.util.Pair)141 StringUtil (com.intellij.openapi.util.text.StringUtil)133 Logger (com.intellij.openapi.diagnostic.Logger)127 Editor (com.intellij.openapi.editor.Editor)120