Search in sources :

Example 6 with SourceAnalysisDVO

use of com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.SourceAnalysisDVO in project Gargoyle by callakrsos.

the class CodeAnalysisJavaTextArea method initialize.

@FXML
public void initialize() {
    choMethod = new ChoiceBox<>();
    choMethod.setConverter(new StringConverter<SourceAnalysisDVO>() {

        @Override
        public String toString(SourceAnalysisDVO d) {
            return d.getMethodName();
        }

        @Override
        public SourceAnalysisDVO fromString(String string) {
            return null;
        }
    });
    // jdk1.8.73이후버젼부터 사용가능
    choMethod.setOnAction(event -> {
        SourceAnalysisDVO selectedItem = choMethod.getSelectionModel().getSelectedItem();
        String methodName = selectedItem.getMethodName();
        int methodBlockStart = selectedItem.getMethodBlockStart();
        int finallyBlockIdx = methodBlockStart - 1;
        String string = newInstance.getReadLines().get(finallyBlockIdx);
        if (!string.contains(methodName)) {
            for (int i = methodBlockStart - 2; i < methodBlockStart + 1; i++) {
                if (i < 0)
                    continue;
                if (i == (methodBlockStart - 1))
                    continue;
                string = newInstance.getReadLines().get(i);
                if (string.contains(methodName)) {
                    finallyBlockIdx = i;
                    break;
                }
            }
        }
        IntStream mapToInt = Stream.of(txtJavaTextArea.getText().split("\n")).limit(finallyBlockIdx).mapToInt(mapper -> {
            return mapper.length() + 1;
        });
        int length = string.split("\t").length - 1;
        int sum = mapToInt.sum() + length;
        System.out.println(string);
        txtJavaTextArea.selectRange(sum, sum + methodName.length());
    });
    this.setTop(new HBox(5, new Label("Method Name : "), choMethod));
}
Also used : HBox(javafx.scene.layout.HBox) Label(javafx.scene.control.Label) IntStream(java.util.stream.IntStream) SourceAnalysisDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.SourceAnalysisDVO) FXML(javafx.fxml.FXML)

Example 7 with SourceAnalysisDVO

use of com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.SourceAnalysisDVO in project Gargoyle by callakrsos.

the class CodeAnalysisJavaTextArea method init.

@FxPostInitialize
public void init() {
    List<SourceAnalysisDVO> methodList = Collections.emptyList();
    try {
        newInstance = new BizFile(javaFile);
        List<String> readLines = newInstance.getReadLines();
        txtJavaTextArea.setContent(readLines);
        // svo = ProgramSpecUtil.doJavaFile("sampleJavaProject",
        // javaFile.getName(), (AbstractJavaProgramSpecFile) newInstance);
        // this.setContent(svo.getFile().getInspectorSourceMeta().getSourceCode());
        SourceCodeAnalysis sa = newInstance.getJavaSourceAnalysis();
        methodList = sa.findStatement();
        choMethod.getItems().addAll(methodList);
    } catch (Exception e) {
        LOGGER.error(ValueUtil.toString(e));
    }
}
Also used : SourceCodeAnalysis(com.kyj.fx.voeditor.visual.words.spec.auto.msword.biz.SourceCodeAnalysis) SourceAnalysisDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.SourceAnalysisDVO) BizFile(com.kyj.fx.voeditor.visual.words.spec.auto.msword.model.BizFile) FxPostInitialize(com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize)

Example 8 with SourceAnalysisDVO

use of com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.SourceAnalysisDVO in project Gargoyle by callakrsos.

the class XframeJsAnalysis method compile.

/**
	 * 2014. 6. 21. Administrator
	 *
	 * @param p
	 * @param data
	 * @return
	 * @처리내용 : 패턴과 일치하는 내용을 찾아 반환
	 */
public void compile(Pattern p) {
    String statement = this.inspectorSourceMeta.getSourceCode();
    Matcher m = p.matcher(statement);
    boolean result = m.find();
    int lineNumberSavePoint = 0;
    int lineNumberCnt = 0;
    while (result) {
        String group = m.group().trim();
        int start = m.start();
        int end = m.end();
        lineNumberCnt += getLineNumberCnt(statement.substring(lineNumberSavePoint, end));
        lineNumberSavePoint = end + 1;
        BlockDVO blockAndDeleteList = getBlockAndDeleteList(lineNumberCnt);
        /* if문이 true인 경우는 함수가 포함된 라인안에 브레이스가 있는경우임 */
        if (blockAndDeleteList == null) {
            lineNumberCnt = lineNumberCnt - 1;
            blockAndDeleteList = getBlockAndDeleteList(lineNumberCnt);
            lineNumberSavePoint = lineNumberSavePoint - 1;
        }
        if (blockAndDeleteList == null) {
            ProgramSpecSourceErrException e = new ProgramSpecSourceErrException(" 코드 블록에 문제가 있거나 , 프로그램 버그 발생. ");
            e.addDetailMsgList("2차 체크 코드 블록 BlockDVO null 주석문제일 가능성이 있음.");
            e.addDetailMsgList("group : ");
            e.addDetailMsgList(group);
            e.addDetailMsgList("start : ");
            e.addDetailMsgList(String.valueOf(start));
            e.addDetailMsgList("end : ");
            e.addDetailMsgList(String.valueOf(end));
            e.addDetailMsgList("lineNumberCnt : ");
            e.addDetailMsgList(String.valueOf(lineNumberCnt));
            e.addDetailMsgList("linkedList : ");
            e.addDetailMsgList(listBlock.toString());
            // BaseUtil.alert( "코드 블록에 문제가 있거나 , 프로그램 버그 발생." );
            // return;
            result = m.find();
            continue;
        }
        int startLine = blockAndDeleteList.getStartindex();
        int endLine = blockAndDeleteList.getEndindex();
        List<String> subList = this.inspectorSourceMeta.getSourceCodeList().subList(startLine - 1, endLine);
        String sourceCode = getString(subList);
        methodList.add(new SourceAnalysisDVO(group.replaceAll("\\{", "").trim(), start, end, startLine, endLine, this.inspectorSourceMeta.getFileName(), sourceCode));
        result = m.find();
    }
}
Also used : Matcher(java.util.regex.Matcher) ProgramSpecSourceErrException(com.kyj.fx.voeditor.visual.exceptions.ProgramSpecSourceErrException) BlockDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.BlockDVO) SourceAnalysisDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.SourceAnalysisDVO)

Aggregations

SourceAnalysisDVO (com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.SourceAnalysisDVO)8 ProgramSpecSourceException (com.kyj.fx.voeditor.visual.exceptions.ProgramSpecSourceException)2 BlockDVO (com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.BlockDVO)2 ImportsDVO (com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.ImportsDVO)2 MethodDVO (com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodDVO)2 ProgramSpecSVO (com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.ProgramSpecSVO)2 UserSourceMetaDVO (com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.UserSourceMetaDVO)2 ArrayList (java.util.ArrayList)2 Matcher (java.util.regex.Matcher)2 ProgramSpecSourceErrException (com.kyj.fx.voeditor.visual.exceptions.ProgramSpecSourceErrException)1 FxPostInitialize (com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize)1 SourceCodeAnalysis (com.kyj.fx.voeditor.visual.words.spec.auto.msword.biz.SourceCodeAnalysis)1 BizFile (com.kyj.fx.voeditor.visual.words.spec.auto.msword.model.BizFile)1 IntStream (java.util.stream.IntStream)1 FXML (javafx.fxml.FXML)1 Label (javafx.scene.control.Label)1 HBox (javafx.scene.layout.HBox)1