無法解析方法 - Intellij
php小編魚仔為您介紹本文主題:Java程式設計中常見問題解答。今天我們將討論Intellij開發環境中常見的問題之一:無法解析方法。在Java開發過程中,遇到無法解析方法的情況可能會讓人頭疼,但實際上很可能只是一個小問題。接下來,我們將為您詳細解析可能導致此問題的原因,並提供解決方法,幫助您更順利地進行程式設計工作。
問題內容
試圖找出為什麼我在第二種方法中收到「setobservationcode is neverused」錯誤。第二個片段顯示了單元測試的使用位置。透過單元測試,它給我一個“無法解析“resourcehandler”中的方法“setobservationcode”錯誤。我看到一些人說他們通過使緩存無效並重新啟動來解決該錯誤,但這對我來說並不成功。
public class ResourceHandlerTest extends TestCase { FhirContext ctx = null; IParser parser = null; // Other methods... public String getId(Resource resource) { if (resource.getIdElement() != null) { // Use IdType to extract the ID without additional details such as base URL or resource type. IdType idType = resource.getIdElement(); return idType.getIdPart(); } else { // Handle the case where the resource does not have an ID. return null; // Or throw an exception, depending on your requirements. } } public Observation setObservationCode(Observation observation, Coding coding) { if (observation.getCode() == null) { observation.setCode(new CodeableConcept().addCoding(coding)); } else { observation.getCode().addCoding(coding); } return observation; } public Observation setObservationCode(Observation observation, Coding coding) { if (observation.getCode() == null) { observation.setCode(new CodeableConcept().addCoding(coding)); } else { observation.getCode().addCoding(coding); } return observation; } public Observation setObservationCode(Observation observation, String system, String code, String display) { System.out.println("Debug: Observation Before - " + observation); System.out.println("Debug: System - " + system); System.out.println("Debug: Code - " + code); System.out.println("Debug: Display - " + display); Coding coding = new Coding().setSystem(system).setCode(code).setDisplay(display); return setObservationCode(observation, coding); } ----------------------------------------------------------------------------------------------- public void testSetObservationCode() throws Exception { if (ctx == null) ctx = FhirContext.forR4(); if (parser == null) parser = ctx.newJsonParser(); String observationJsonFile = "src/resources/observation.json"; String observationJson = ""; try { observationJson = new String(Files.readAllBytes(Paths.get(observationJsonFile))); } catch (Exception e) { System.err.println("Failed to read observation.json file."); } Observation correctObservation = parser.parseResource(Observation.class, observationJson); ResourceHandler studentResourceHandler = new ResourceHandler(); String expectedSystem = "http://example.com/system"; String expectedCode = "12345"; String expectedDisplay = "Test Code"; Coding coding = new Coding().setSystem(expectedSystem).setCode(expectedCode).setDisplay(expectedDisplay); Observation modifiedObservation = studentResourceHandler.setObservationCode(correctObservation, coding); assertEquals(expectedSystem, modifiedObservation.getCode().getCodingFirstRep().getSystem()); assertEquals(expectedCode, modifiedObservation.getCode().getCodingFirstRep().getCode()); assertEquals(expectedDisplay, modifiedObservation.getCode().getCodingFirstRep().getDisplay()); }
登入後複製
解決方法
您在測試中呼叫了第一個方法,但沒有呼叫第二個方法。
測試中最後一行的第 4 行有 2 個參數,這是第一個參數。因此 intellij 檢測不到第二個的使用。
Observation modifiedObservation = studentResourceHandler.setObservationCode(correctObservation, coding);
登入後複製
查看主程式碼區塊的結構,理想情況下您應該呼叫第二個定義(有 4 個參數),該定義又呼叫另一個定義。
以上是無法解析方法 - Intellij的詳細內容。更多資訊請關注PHP中文網其他相關文章!
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章
R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
4 週前
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
4 週前
By 尊渡假赌尊渡假赌尊渡假赌
刺客信條陰影:貝殼謎語解決方案
2 週前
By DDD
R.E.P.O.如果您聽不到任何人,如何修復音頻
4 週前
By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解鎖Myrise中的所有內容
1 個月前
By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)
