国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

網(wǎng)站開發(fā)使用的技術(shù)有哪些網(wǎng)絡(luò)營銷推廣方案范文

網(wǎng)站開發(fā)使用的技術(shù)有哪些,網(wǎng)絡(luò)營銷推廣方案范文,網(wǎng)站模板建站教程視頻,協(xié)會網(wǎng)站制作前言:經(jīng)常使用Objects.equals(a,b)方法的同學(xué) 應(yīng)該或多或少都會因為粗心而傳錯參, 例如日常開發(fā)中 我們使用Objects.equals去比較 status(入?yún)?,statusEnum(枚舉), 很容易忘記statusEnum.getCode() 或 statusEnum.getVaule() ,再比…

前言:經(jīng)常使用Objects.equals(a,b)方法的同學(xué) 應(yīng)該或多或少都會因為粗心而傳錯參, 例如日常開發(fā)中 我們使用Objects.equals去比較 status(入?yún)?,statusEnum(枚舉), 很容易忘記statusEnum.getCode() 或 statusEnum.getVaule() ,再比如 我們比較一個訂單code時 orderCode(入?yún)?,orderDTO(其它業(yè)務(wù)對象) 很容易忘記orderDTO.getCode() 因為Objects.equals()兩個參數(shù)都是Object類型,idea默認(rèn)不會提示告警, 如果經(jīng)常使用該方法 你一定很清楚的明白我在說什么。

針對以上痛點,博主編寫了一個idea插件: Equals Inspection , 插件代碼本身很簡單,極其輕量級。難得的是 在目前暫沒發(fā)現(xiàn)有人做了這件事時,而博主想到了可以通過IDE告警方式去解決問題,并且實際行動了。此外,知道該用什么API本身是件不容易的事,而閱讀代碼時,已經(jīng)處于一個上帝視角,則會顯得非常簡單。

Q:為什么是IDE插件層面,而不是在java項目中重寫一個工具類 針對類型判斷呢?
A:
1.效率問題:java項目代碼判斷 說明要執(zhí)行到該方法時才能校驗,很多時候我們編寫完,在測試環(huán)節(jié)被提了bug,我們自己斷點執(zhí)行一遍,才能發(fā)現(xiàn)傳錯了參,插件層面在我們編寫時即可提醒,節(jié)省了大量時間.

2.設(shè)計問題: 很重要的一點,java項目層面的提示,要怎么提示?throw new RuntimeExection? 顯然不太合理吧,例如在設(shè)計一些框架/通用代碼時,類型就是可以不一致 難道拋一個異常阻止程序運(yùn)行嗎?插件盡管會提示報錯,但它歸根結(jié)底都只是一個樣式,并不會阻止程序運(yùn)行。

使用前后效果對比:

使用前沒有告警
在這里插入圖片描述

使用后示例:

在這里插入圖片描述
vo.getStatus(Integer類型)與枚舉比較時,能直接提示我們類型不一致
(正確寫法是StatusEnum.AWAIT.getValue() 與枚舉類型的值進(jìn)行比較)
在這里插入圖片描述

以下就以博主編寫的插件為例 ,寫一篇如何編寫idea插件的教程

注:本文由csdn博主 孟秋與你 編寫,如您在其它地方看到本文,很可能是被其它博主爬蟲/復(fù)制過來的,文章可能會持續(xù)更新,強(qiáng)烈建議您搜索:孟秋與你csdn 找到原文查看

第一步:創(chuàng)建插件項目
tips:
1.需要jdk11
2.以idea2021.1版本為例,不同idea版本可能有所差異

new project ->IntelliJ Platform Plugin-> Project SDK (需要jdk11)

在這里插入圖片描述

第二步:修改plugin.xml文件內(nèi)容及創(chuàng)建java代碼

其中plugin.xml的description節(jié)點,需要40個字符以上,否則插件上傳時會報錯。

編寫插件的核心難點在于,我們不知道idea的api是什么,什么情況用什么api。
以下是可以參考的幾點:

  1. idea官方文檔 https://plugins.jetbrains.com/docs/intellij/welcome.html
  2. github idea 示例項目:https://github.com/JetBrains/intellij-sdk-code-samples
<idea-plugin><id>csdn-mengqiuyuni</id><name>Equals參數(shù)類型檢查</name><version>0.1.0</version><vendor email="1005738053@qq.com" url="https://blog.csdn.net/qq_36268103"> </vendor><description><![CDATA[<li>check java.lang.Objects equals method params type ,if not match,idea will show the error line</li><br><li>could reduce Objects.equals(a,b) error params type by mistake</li><br><li>notice:this plugin can only inspect your code,it's just reminder java developers,but don't impact code execution,and never change or fix your code.</li>]]></description><change-notes><![CDATA[<li>github:qiuhuanhen,project name :objects-equals-inspect</li><br><li>beta version.csdn:孟秋與你</li><br><li>the first beta version,welcome,update date:2024.01.09</li>]]></change-notes><vendor>qiuhuanhen</vendor><!-- please see https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html for description --><idea-version since-build="173.0"/><!-- please see https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.htmlon how to target different products --><depends>com.intellij.modules.platform</depends><depends>com.intellij.java</depends><depends>com.intellij.modules.java</depends><extensions defaultExtensionNs="com.intellij"><localInspectionlanguage="JAVA"displayName="Title"groupPath="Java"groupBundle="messages.InspectionsBundle"groupKey="group.names.probable.bugs"enabledByDefault="true"level="ERROR"implementationClass="com.qiuhuanhen.ObjectsEqualsInspection"/><!--java類所在路徑--></extensions></idea-plugin>
package com.qiuhuanhen;import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;/*** @author qiuhuanhen*/
public class ObjectsEqualsInspection extends LocalInspectionTool {@NotNull@Overridepublic PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {return new MyVisitor(holder);}private static class MyVisitor extends JavaElementVisitor {private final ProblemsHolder holder;public MyVisitor(ProblemsHolder holder) {this.holder = holder;}@Overridepublic void visitMethodCallExpression(PsiMethodCallExpression expression) {super.visitMethodCallExpression(expression);String methodName = expression.getMethodExpression().getReferenceName();if ("equals".equals(methodName)) {PsiExpressionList argumentList = expression.getArgumentList();PsiExpression[] expressions = argumentList.getExpressions();if (expressions.length == 2) {PsiType arg1Type = expressions[0].getType();PsiType arg2Type = expressions[1].getType();// 都為空 不做提示  注:即使idea會提示 type不為空 ,為防止插件報NPE 還是有大量的非空判斷if (null == arg1Type && null == arg2Type) {return;}// 其一為空 給出錯誤提示if (null == arg1Type || null == arg2Type) {holder.registerProblem(expression, "Objects.equals parameters are not of the same type.", ProblemHighlightType.GENERIC_ERROR_OR_WARNING);return;}// 這是忽視某些通用類,框架 用于比較反射class類型的情況if (arg1Type.getCanonicalText().contains("Class") && arg2Type.getCanonicalText().contains("Class")) {return;}if (isByte(arg1Type) && isByte(arg2Type)) {return;}if (isShort(arg1Type) && isShort(arg2Type)) {return;}if (isInt(arg1Type) && isInt(arg2Type)) {return;}if (isLong(arg1Type) && isLong(arg2Type)) {return;}if (isFloat(arg1Type) && isFloat(arg2Type)) {return;}if (isDouble(arg1Type) && isDouble(arg2Type)) {return;}if (isChar(arg1Type) && isChar(arg2Type)) {return;}if (isBoolean(arg1Type) && isBoolean(arg2Type)) {return;}if (!arg1Type.equals(arg2Type)) {holder.registerProblem(expression, "Objects.equals parameters are not of the same type.", ProblemHighlightType.GENERIC_ERROR_OR_WARNING);}}}}private boolean isInt(PsiType type) {PsiPrimitiveType unboxedType = PsiPrimitiveType.getUnboxedType(type);if (PsiType.INT.equals(unboxedType)) {// 是 int 類型return true;}return PsiType.INT.equals(type) || "java.lang.Integer".equals(type.getCanonicalText());}private boolean isLong(PsiType type) {PsiPrimitiveType unboxedType = PsiPrimitiveType.getUnboxedType(type);if (PsiType.LONG.equals(unboxedType)) {// 是 long 類型return true;}return PsiType.LONG.equals(type) || "java.lang.Long".equals(type.getCanonicalText());}private boolean isDouble(PsiType type) {PsiPrimitiveType unboxedType = PsiPrimitiveType.getUnboxedType(type);if (PsiType.DOUBLE.equals(unboxedType)) {return true;}return PsiType.DOUBLE.equals(type) || "java.lang.Double".equals(type.getCanonicalText());}private boolean isFloat(PsiType type) {PsiPrimitiveType unboxedType = PsiPrimitiveType.getUnboxedType(type);if (PsiType.FLOAT.equals(unboxedType)) {return true;}return PsiType.FLOAT.equals(type) || "java.lang.Float".equals(type.getCanonicalText());}private boolean isBoolean(PsiType type) {PsiPrimitiveType unboxedType = PsiPrimitiveType.getUnboxedType(type);if (PsiType.BOOLEAN.equals(unboxedType)) {return true;}return PsiType.BOOLEAN.equals(type) || "java.lang.Boolean".equals(type.getCanonicalText());}private boolean isByte(PsiType type) {PsiPrimitiveType unboxedType = PsiPrimitiveType.getUnboxedType(type);if (PsiType.BYTE.equals(unboxedType)) {return true;}return PsiType.BYTE.equals(type) || "java.lang.Byte".equals(type.getCanonicalText());}private boolean isChar(PsiType type) {PsiPrimitiveType unboxedType = PsiPrimitiveType.getUnboxedType(type);if (PsiType.CHAR.equals(unboxedType)) {return true;}return PsiType.CHAR.equals(type) || "java.lang.Char".equals(type.getCanonicalText());}private boolean isShort(PsiType type) {PsiPrimitiveType unboxedType = PsiPrimitiveType.getUnboxedType(type);if (PsiType.SHORT.equals(unboxedType)) {return true;}return PsiType.SHORT.equals(type) || "java.lang.Short".equals(type.getCanonicalText());}}
}

第三步:打成jar包
在這里插入圖片描述
沒有main方法則不用選擇main class
在這里插入圖片描述
在這里插入圖片描述

第四步:發(fā)布插件
在這里插入圖片描述

發(fā)布插件沒有什么難點,唯一值得注意的是description非常嚴(yán)格,必須要40個字符以上,且不能有非拉丁字符,博主在反復(fù)修改后發(fā)現(xiàn)不能有任何中文,最后把description里面的中文都改成了英文。

插件項目源碼地址:https://github.com/qiuhuanhen/objects-equals-inspect
下載一:( idea團(tuán)隊給博主發(fā)了郵件 插件最開始的命名不規(guī)范 目前在重新審核 不知道后續(xù)結(jié)果 先在github下載吧)
idea插件商店搜索: Equals Inspection

下載二:github https://github.com/qiuhuanhen/objects-equals-inspect

releases區(qū)
在這里插入圖片描述
安裝方式:1. 直接將jar包拖進(jìn)idea,2.重啟idea

打開項目方式:
在github下載博主的項目,idea打開后 默認(rèn)是常規(guī)項目,這時我們需要稍作處理
在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
最后一步:
在這里插入圖片描述

最后: 原創(chuàng)不易 ,歡迎各位在idea插件商店下載Equals Inspection , 給github項目點上star 非常感謝各位

http://m.aloenet.com.cn/news/32905.html

相關(guān)文章:

  • seo推廣騙局百度快照優(yōu)化公司
  • 數(shù)商云價格長治seo顧問
  • 網(wǎng)站建設(shè)制作汕頭外貿(mào)網(wǎng)站建設(shè)公司
  • 哪里可以做網(wǎng)站推廣win7優(yōu)化大師好不好
  • 做網(wǎng)站被黑后怎么辦營銷方案怎么寫
  • 代理招商平臺seo網(wǎng)絡(luò)推廣軟件
  • 保安做網(wǎng)站seo排名點擊
  • 張北縣網(wǎng)站建設(shè)外鏈代發(fā)
  • 知名設(shè)計網(wǎng)站公司百度網(wǎng)盤官網(wǎng)登陸入口
  • wordpress 數(shù)據(jù)庫編碼杭州seo網(wǎng)站哪家好
  • 網(wǎng)站建設(shè)時送的ppt方案讓手機(jī)變流暢的軟件下載
  • 桂林網(wǎng)站制作優(yōu)化大師官方
  • 阿里建站系統(tǒng)軟件開發(fā)培訓(xùn)機(jī)構(gòu)去哪個學(xué)校
  • 受歡迎的天津網(wǎng)站建設(shè)百度網(wǎng)盤搜索引擎入口
  • 做長海報的網(wǎng)站外包推廣服務(wù)
  • 煙臺網(wǎng)站建設(shè)搜狗推廣登錄入口
  • 怎么建設(shè)一個網(wǎng)站賺錢seo排名查詢工具
  • 網(wǎng)站可以微信支付是怎么做的百度熱詞
  • 公司網(wǎng)站的seo優(yōu)化怎么做百度網(wǎng)盤人工客服電話多少
  • 不會網(wǎng)站維護(hù)可以做嗎怎么開通百度推廣賬號
  • 北京上海網(wǎng)站建設(shè)公司品牌宣傳推廣文案
  • 網(wǎng)站優(yōu)化的策略鎮(zhèn)江網(wǎng)站建設(shè)企業(yè)
  • 北京電腦培訓(xùn)網(wǎng)站軟文廣告示范
  • 上傳網(wǎng)站到二級域名財經(jīng)新聞最新消息
  • 昆明網(wǎng)上商城網(wǎng)站建設(shè)市場營銷策略
  • 寵物網(wǎng)站開發(fā)與實現(xiàn)軟文推廣做得比較好的推廣平臺
  • 做集團(tuán)網(wǎng)站應(yīng)注意什么谷歌seo優(yōu)化技巧
  • 做家居商城網(wǎng)站鄭州seo推廣
  • 怎么把網(wǎng)站放到空間嗎教育培訓(xùn)機(jī)構(gòu)平臺
  • 公眾號的微網(wǎng)站開發(fā)營銷型網(wǎng)站建設(shè)排名