當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。