我正在尝试为typescript反应添加自定义代码段。但是在添加它之后,它不会显示在intellisense或Insert Snippet命令窗口中。我执行了以下步骤:
创建代码段。文件>偏好>用户片段>打字稿反应。我的json:
"React Component": {
"prefix": "myreactc",
"body": [
"import * as React from "react";"
],
"description": "Adds a react component."
}
更新了以下设置:
" editor.tabCompletion":true
创建一个新的空白TSX文件并输入:" myreactc"但没有任何东西出现在intellisense中。
我还重新启动了visual studio代码,但没有运气。
Visual Studio代码详细信息:
版本1.14.2
提交cb82febafda0c8c199b9201ad274e25d9a76874e
日期2017-07-19T23:34:09.706Z
Shell 1.6.6
渲染器56.0.2924.87
节点7.4.0
任何帮助?
答案 0 :(得分:0)
我意识到代码已被注释:)默认模板的代码已注释,我更新了代码但忘记取消注释代码。
答案 1 :(得分:0)
我愚蠢地更改了代码段名称而不是代码段前缀
class ProjectSegmentCategoryGsonSpec extends Specification implements JsonViewTest {
// Define the spy objects needed for the test
def projectsegmentcategory = Spy(ProjectSegmentCategory);
def librarycategory = Spy(LibrarySegmentCategory);
def projectsegmentcategoryvalue = Spy(ProjectSegmentCategoryValue)
Set<ProjectSegmentCategoryValue> projectsegmentcategoryvalues;
def projectsegmentclassification = Spy(ProjectSegmentClassification)
def librarycategoryvalue = Spy(LibrarySegmentCategoryValue)
def setup() {
// Set attributes of the objects for the test
projectsegmentcategory.id = 1;
projectsegmentcategory.hasData = true;
projectsegmentcategory.isClustered = true;
projectsegmentcategory.isUnlockedForBudgetingModule = true;
librarycategory.id = 1;
projectsegmentcategory.librarycategory = librarycategory;
def projectsegmentcategoryvalues_list = [projectsegmentcategoryvalue]
projectsegmentcategory.projectsegmentcategoryvalues = new TreeSet<ProjectSegmentCategoryValue>();
projectsegmentcategory.projectsegmentcategoryvalues.add(Mock(ProjetSegmentCategoryValue))
projectsegmentcategory.projectsegmentcategoryvalues.first().id = 1
projectsegmentcategoryvalue.isClustered = true
projectsegmentcategoryvalue.isUnlockedForBudgetingModule = true
librarycategoryvalue.id = 1
projectsegmentcategoryvalue.projectsegmentcategory = projectsegmentcategory
projectsegmentcategoryvalue.librarycategoryvalue = librarycategoryvalue
projectsegmentclassification.id = 1
projectsegmentcategory.projectsegmentclassification = projectsegmentclassification
}
void "Test ProjectSegmentCategory Gson with default values"() {
when:"A ProjectSegmentCategory gson is rendered"
def renderResult = render(template: "/project/instance/projectSegmentCategory/projectSegmentCategory", model:[projectsegmentcategory: projectsegmentcategory])
then:"The json is correct"
// Mock the method getName as the real method is more complicate and requires a Language object
2 * projectsegmentcategory.getName(_ as String) >> "Test"
2 * projectsegmentcategory.getName() >> "Test"
2 * projectsegmentcategory.toString() >> "Test"
2 * projectsegmentcategoryvalue.getName(_ as String) >> "Test"
1 * projectsegmentcategoryvalue.getTranslationByLanguageId(_ as Long) >> "Test"
1 * projectsegmentcategoryvalue.getId() >> "1"
//1 * ProjectSegmentCategoryValue.getTranslationByLanguageId(_ as Long) >> "Test"
1 * projectsegmentcategory.projectsegmentcategoryvalues.iterator(_) >> projectsegmentcategoryvalue.iterator()
// Tests
renderResult.json.id == 1
renderResult.json.isClustered == true
renderResult.json.isUnlockedForBudgetingModule == true
renderResult.json.librarycategoryvalue.id == 1
renderResult.json.projectsegmentcategory.id == 1
renderResult.json.name == "Test"
}
}