当前位置: 首页>>代码示例>>Java>>正文


Java JSChangeUtil.getSemicolon方法代码示例

本文整理汇总了Java中com.intellij.lang.javascript.psi.impl.JSChangeUtil.getSemicolon方法的典型用法代码示例。如果您正苦于以下问题:Java JSChangeUtil.getSemicolon方法的具体用法?Java JSChangeUtil.getSemicolon怎么用?Java JSChangeUtil.getSemicolon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.lang.javascript.psi.impl.JSChangeUtil的用法示例。


在下文中一共展示了JSChangeUtil.getSemicolon方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createImportBlock

import com.intellij.lang.javascript.psi.impl.JSChangeUtil; //导入方法依赖的package包/类
public static String createImportBlock(Project project, Collection<String> fqns)
{
	List<String> sorted = new ArrayList<String>(fqns);
	Collections.sort(sorted, new Comparator<String>()
	{
		@Override
		public int compare(final String o1, final String o2)
		{
			return compareImports(o1, o2);
		}
	});

	final String semicolon = JSChangeUtil.getSemicolon(project);
	StringBuilder s = new StringBuilder();
	for(String fqn : sorted)
	{
		s.append("import ").append(fqn).append(semicolon);
	}
	return s.toString();
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:21,代码来源:ImportUtils.java

示例2: addSemicolonSegment

import com.intellij.lang.javascript.psi.impl.JSChangeUtil; //导入方法依赖的package包/类
protected void addSemicolonSegment(final Template template, final PsiFile file)
{
	final String semicolon = JSChangeUtil.getSemicolon(file.getProject());
	if(semicolon.length() > 0)
	{
		template.addTextSegment(semicolon);
	}
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:9,代码来源:BaseCreateFix.java

示例3: buildFunctionBodyText

import com.intellij.lang.javascript.psi.impl.JSChangeUtil; //导入方法依赖的package包/类
@Override
protected String buildFunctionBodyText(final String retType, final JSParameterList parameterList, final JSFunction func)
{
	@NonNls String s = "{\n";
	if(retType != null && !"void".equals(retType))
	{
		s += "return " + defaultValueOfType(retType) + JSChangeUtil.getSemicolon(func.getProject()) + "\n";
	}
	s += "}";
	return s;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:12,代码来源:ImplementMethodsFix.java

示例4: invoke

import com.intellij.lang.javascript.psi.impl.JSChangeUtil; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException
{
	if(!CodeInsightUtilBase.getInstance().prepareFileForWrite(file))
	{
		return;
	}
	Template t = TemplateManager.getInstance(project).createTemplate("", "");
	t.setToReformat(true);

	t.addTextSegment("super(");
	boolean first = true;
	for(JSParameter p : superConstructor.getParameterList().getParameters())
	{
		if(p.isRest())
		{
			break;
		}
		if(!first)
		{
			t.addTextSegment(", ");
		}
		first = false;
		MacroCallNode node = new MacroCallNode(new CompleteMacro());
		t.addVariable(p.getName(), node, node, true);
	}
	t.addTextSegment(")");
	String s = JSChangeUtil.getSemicolon(project);
	if(s.length() > 0)
	{
		t.addTextSegment(s);
	}

	JSFunction fun = PsiTreeUtil.getParentOfType(node, JSFunction.class);
	JSSourceElement[] body = fun != null ? fun.getBody() : JSSourceElement.EMPTY_ARRAY;

	if(body.length > 0 && body[0] instanceof JSBlockStatement)
	{
		PsiElement firstChild = body[0].getFirstChild();
		editor.getCaretModel().moveToOffset(firstChild.getTextRange().getEndOffset());
		TemplateManager.getInstance(project).startTemplate(editor, t);
	}
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:44,代码来源:JSAnnotatingVisitor.java

示例5: getStatementTemplate

import com.intellij.lang.javascript.psi.impl.JSChangeUtil; //导入方法依赖的package包/类
@Override
protected String getStatementTemplate(final Project project, PsiElement context)
{
	return "aaa = function () { }" + JSChangeUtil.getSemicolon(project);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:6,代码来源:JSWithFunctionExpressionSurrounder.java

示例6: buildFunctionBodyText

import com.intellij.lang.javascript.psi.impl.JSChangeUtil; //导入方法依赖的package包/类
@Override
protected String buildFunctionBodyText(final String retType, final JSParameterList parameterList, final JSFunction func)
{
	@NonNls String functionText = "";
	functionText += "{\n";

	if(!"void".equals(retType))
	{
		functionText += "  return";
	}
	else
	{
		functionText += " ";
	}

	functionText += " super." + func.getName();

	if(func.isGetProperty())
	{

	}
	else if(func.isSetProperty())
	{
		functionText += " = " + parameterList.getParameters()[0].getName();
	}
	else
	{
		functionText += "(";
		boolean first = true;
		for(JSParameter param : parameterList.getParameters())
		{
			if(!first)
			{
				functionText += ",";
			}
			first = false;
			functionText += param.getName();
		}
		functionText += ")";
	}

	functionText += JSChangeUtil.getSemicolon(func.getProject()) + "\n}";
	return functionText;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:45,代码来源:OverrideMethodsFix.java

示例7: invoke

import com.intellij.lang.javascript.psi.impl.JSChangeUtil; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException
{
	final JSCodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(project).getCustomSettings(JSCodeStyleSettings.class);
	evalAnchor(editor, file);
	@NonNls String functionText = "public function " + jsClass.getName() + "(";
	@NonNls String initialization = "";
	boolean first = true;
	final String semicolon = JSChangeUtil.getSemicolon(project);

	Set<JSVariable> toProcess = getElementsToProcess();
	Iterator<JSVariable> variableIterator = toProcess.iterator();
	boolean hadSuperClassConstructorInitializationBefore = false;

	while(variableIterator.hasNext())
	{
		JSVariable var = variableIterator.next();
		if(!first)
		{
			functionText += ", ";
		}

		first = false;

		final String name = var.getName();
		String parameterName = transformVarNameToAccessorName(name, codeStyleSettings);

		final String typeString = var.getTypeString();
		functionText += parameterName + (typeString != null ? ":" + typeString : "");

		if(JSResolveUtil.findParent(var) == jsClass)
		{
			if(hadSuperClassConstructorInitializationBefore)
			{
				initialization += ")" + semicolon + "\n";
				hadSuperClassConstructorInitializationBefore = false;
			}
			initialization += (parameterName.equals(name) ? "this." : "") + name + " = " + parameterName + semicolon + "\n";
		}
		else
		{
			if(hadSuperClassConstructorInitializationBefore)
			{
				initialization += ", ";
			}
			else
			{
				initialization += "super(";
			}
			initialization += parameterName;
			hadSuperClassConstructorInitializationBefore = true;
		}
	}

	if(hadSuperClassConstructorInitializationBefore)
	{
		initialization += ")" + semicolon + "\n";
	}
	functionText += ") {\n";
	functionText += initialization;
	functionText += "}";
	doAddOneMethod(project, functionText, anchor);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:64,代码来源:JavaScriptGenerateAccessorHandler.java


注:本文中的com.intellij.lang.javascript.psi.impl.JSChangeUtil.getSemicolon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。