001/*-------------------------------------------------------------------------+ 002| | 003| Copyright (c) 2009-2018 CQSE GmbH | 004| | 005+-------------------------------------------------------------------------*/ 006package eu.cqse.check.framework.core.phase; 007 008/** 009 * Enum specifying which code representation should be retrieved or which code 010 * representation is used as base for finding generation. 011 * 012 * For example, the offsets used when specifying finding locations depend on 013 * whether the code is filtered or not. 014 */ 015public enum ECodeViewOption { 016 /** 017 * unfiltered text, not preprocessed. 018 * 019 * When using this to retrieve ShallowEntities, the resulting ShallowEntities 020 * are based on preprocessed tokens, but the tokens generated by the 021 * preprocessor are removed after parsing. 022 */ 023 UNFILTERED(ETextViewOption.UNFILTERED_CONTENT, ETokenViewOption.RAW), 024 025 /** unfiltered text, preprocessed (only file-local define/macro resolution) */ 026 UNFILTERED_PREPROCESSED(ETextViewOption.UNFILTERED_CONTENT, ETokenViewOption.PREPROCESSED_LOCAL), 027 028 /** 029 * filtered text, not preprocessed. 030 * 031 * When using this to retrieve ShallowEntities, the resulting ShallowEntities 032 * are based on preprocessed tokens, but the tokens generated by the 033 * preprocessor are removed after parsing. 034 */ 035 FILTERED(ETextViewOption.FILTERED_CONTENT, ETokenViewOption.RAW), 036 /** filtered text, preprocessed (global define/macro resolution). */ 037 FILTERED_PREPROCESSED(ETextViewOption.FILTERED_CONTENT, ETokenViewOption.PREPROCESSED); 038 039 /** 040 * Processing which is executed on the file content (plain text) before scanning 041 * (token generation). 042 */ 043 public final ETextViewOption textView; 044 /** 045 * Processing which is executed on the token stream after scanning and before 046 * parsing. 047 */ 048 public final ETokenViewOption tokenView; 049 050 /** private constructor. */ 051 private ECodeViewOption(ETextViewOption textView, ETokenViewOption tokenView) { 052 this.textView = textView; 053 this.tokenView = tokenView; 054 } 055 056 /** 057 * Options for processing which is done on the file content (plain text) before 058 * scanning. 059 */ 060 public static enum ETextViewOption { 061 /** 062 * The initial content (plain text) that is loaded into teamscale from the code 063 * repository. 064 * 065 * If you use offsets, tokens, or shallow entities based on unfiltered content 066 * to generate findings, then pass <code>false</code> to the 067 * <code>filteredContent</code> parameter of the createFindings method. 068 * Otherwise, the finding location will be wrong. 069 */ 070 UNFILTERED_CONTENT, 071 /** the text after filtering content-exclude patterns */ 072 FILTERED_CONTENT 073 } 074 075 /** 076 * Options for processing which is done on the token stream after scanning and 077 * before parsing. 078 */ 079 public static enum ETokenViewOption { 080 /** 081 * The raw tokens are were not preprocessed (after scanning). The input to the 082 * scanner might or might not have been filtered (see {@link ETextViewOption}). 083 */ 084 RAW, 085 /** 086 * The tokens are preprocessed including global information (resolves defines 087 * and macro definitions from e.g., C/C++ headers). 088 */ 089 PREPROCESSED, 090 /** 091 * The tokens are preprocessed without global information (only defines and 092 * macro definitions from the current file are used). 093 */ 094 PREPROCESSED_LOCAL 095 } 096}