本文整理汇总了Java中com.intellij.openapi.util.text.StringUtil类的典型用法代码示例。如果您正苦于以下问题:Java StringUtil类的具体用法?Java StringUtil怎么用?Java StringUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringUtil类属于com.intellij.openapi.util.text包,在下文中一共展示了StringUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseExpression
import com.intellij.openapi.util.text.StringUtil; //导入依赖的package包/类
/**
* If inside tell (only in a tell?) compound statement - first check it's terms
*/
public static boolean parseExpression(PsiBuilder b, int l, String dictionaryTermToken, Parser expression) {
if (!recursion_guard_(b, l, "parseExpression")) return false;
if (!nextTokenIsFast(b, dictionaryTermToken)) return false;
boolean r;
//check application terms first
if (b.getUserData(PARSING_TELL_COMPOUND_STATEMENT) == Boolean.TRUE) {
String toldAppName = peekTargetApplicationName(b);
if (!StringUtil.isEmpty(toldAppName)) {
StringHolder parsedName = new StringHolder();
PsiBuilder.Marker mComName = enter_section_(b, l, _AND_, "<parse Expression>");
r = parseCommandNameForApplication(b, l + 1, parsedName, toldAppName, true);
exit_section_(b, l, mComName, null, r, false, null);
if (r) return false;
if (ParsableScriptSuiteRegistryHelper.isPropertyWithPrefixExist(toldAppName, dictionaryTermToken)) {
return false;
// PsiBuilder.Marker m = enter_section_(b, l, _AND_, null, "<dictionary constant>");
// r = parseDictionaryConstant(b, l + 1);
// exit_section_(b, l, m, r, false, null);
// if (r) return false;
}
}
}
return expression.parse(b, l + 1);
}
示例2: parse
import com.intellij.openapi.util.text.StringUtil; //导入依赖的package包/类
public static void parse(@NotNull XmlFile file, @NotNull ApplicationDictionary parsedDictionary) {
System.out.println("Start parsing xml file --- " + file.toString() + " ---");
LOG.debug("Start parsing xml file --- " + file.toString() + " ---");
if (parsedDictionary.getRootTag() == null) {
parsedDictionary.setRootTag(file.getRootTag());
}
final XmlDocument document = file.getDocument();
if (document != null) {
final XmlTag rootTag = document.getRootTag();
if (rootTag != null) {
XmlAttribute attr = rootTag.getAttribute("title");
if ("dictionary".equals(rootTag.getName()) && attr != null) {
String dicTitle = attr.getValue();
if (!StringUtil.isEmpty(dicTitle)) {
parsedDictionary.setName(dicTitle);
}
}
parseRootTag(parsedDictionary, rootTag);
}
}
System.out.println("parsing completed for file.");
LOG.debug("parsing completed for file.");
}
示例3: getPropertiesFromTags
import com.intellij.openapi.util.text.StringUtil; //导入依赖的package包/类
@NotNull
private static List<AppleScriptPropertyDefinition> getPropertiesFromTags(@NotNull DictionaryComponent classOrRecord,
@NotNull XmlTag[] propertyTags) {
if (!(classOrRecord instanceof AppleScriptClass) && !(classOrRecord instanceof DictionaryRecord))
return new ArrayList<>(0);
List<AppleScriptPropertyDefinition> properties = new ArrayList<>(propertyTags.length);
for (XmlTag propTag : propertyTags) {
AppleScriptPropertyDefinition property;
String pName = propTag.getAttributeValue("name");
String pCode = propTag.getAttributeValue("code");
String pDescription = propTag.getAttributeValue("description");
String pType = propTag.getAttributeValue("type");
if (StringUtil.isEmpty(pType)) {
XmlTag tType = propTag.findFirstSubTag("type");
pType = tType != null ? tType.getAttributeValue("type") : null;
}
String pAccessType = propTag.getAttributeValue("access");
AccessType accessType = "r".equals(pAccessType) ? AccessType.R : AccessType.RW;
if (pName != null && pCode != null && pType != null) {
property = new DictionaryPropertyImpl(classOrRecord, pName, pCode, pType, pDescription, propTag, accessType);
properties.add(property);
}
}
return properties;
}
示例4: DictionaryClass
import com.intellij.openapi.util.text.StringUtil; //导入依赖的package包/类
public DictionaryClass(@NotNull Suite suite, @NotNull String name, @NotNull String code,
@NotNull XmlTag xmlTagClass, @Nullable String parentClassName,
@Nullable List<String> elementNames, @Nullable List<String> respondingCommandNames,
@Nullable String pluralClassName) {
super(suite, name, code, xmlTagClass, null);
this.parentClassName = parentClassName;
this.pluralClassName = StringUtil.isEmpty(pluralClassName) ? name + "s" : pluralClassName;
if (elementNames != null) {
this.elementNames = elementNames;
} else {
this.elementNames = new ArrayList<>();
}
if (respondingCommandNames != null) {
this.respondingCommandNames = respondingCommandNames;
} else {
this.respondingCommandNames = new ArrayList<>();
}
}
示例5: collectNavigationMarkers
import com.intellij.openapi.util.text.StringUtil; //导入依赖的package包/类
@Override
protected void collectNavigationMarkers(@NotNull PsiElement element,
@NotNull Collection<? super RelatedItemLineMarkerInfo> result) {
if (element instanceof AppleScriptApplicationReference) {
PsiElement leafNode = PsiTreeUtil.firstChild(element);
if (leafNode == null) return;
AppleScriptProjectDictionaryService dictionaryService = ServiceManager.getService(element.getProject(),
AppleScriptProjectDictionaryService.class);
AppleScriptApplicationReference appRef = (AppleScriptApplicationReference) element;
String appName = appRef.getApplicationName();
if (dictionaryService == null || StringUtil.isEmpty(appName)) return;
ApplicationDictionary dictionary = dictionaryService.getDictionary(appName);
if (dictionary == null /*|| dictionary.getApplicationBundle() == null*/) return;
NavigationGutterIconBuilder<PsiElement> builder =
NavigationGutterIconBuilder.create(dictionary.getIcon(0)).
setTargets(dictionary).setTooltipText("Navigate to application dictionary file");
result.add(builder.createLineMarkerInfo(leafNode));
}
}
示例6: initDictionariesInfoFromCache
import com.intellij.openapi.util.text.StringUtil; //导入依赖的package包/类
/**
* Fill {@link #dictionaryInfoMap} from saved data
*
* @param systemDictionaryRegistry application component, which saves/loads the data
*/
private void initDictionariesInfoFromCache(@NotNull AppleScriptSystemDictionaryRegistryComponent systemDictionaryRegistry) {
notScriptableApplicationList.addAll(systemDictionaryRegistry.getNotScriptableApplications());
for (DictionaryInfo.State dInfoState : systemDictionaryRegistry.getDictionariesPersistedInfo()) {
String appName = dInfoState.applicationName;
String dictionaryUrl = dInfoState.dictionaryUrl;
String applicationUrl = dInfoState.applicationUrl;
if (!StringUtil.isEmptyOrSpaces(appName) && !StringUtil.isEmptyOrSpaces(dictionaryUrl)) {
File dictionaryFile = !StringUtil.isEmpty(dictionaryUrl) ? new File(dictionaryUrl) : null;
File applicationFile = !StringUtil.isEmpty(applicationUrl) ? new File(applicationUrl) : null;
if (dictionaryFile != null && dictionaryFile.exists()) {
DictionaryInfo dInfo = new DictionaryInfo(appName, dictionaryFile, applicationFile);
addDictionaryInfo(dInfo);
}
}
}
}
示例7: getInitializedInfo
import com.intellij.openapi.util.text.StringUtil; //导入依赖的package包/类
/**
* Initializes dictionary information for given application either from previously generated and saved dictionary
* file or creates new dictionary file for this application and saves it for later use <br> by
* {@link ApplicationDictionary} psi class. Standard folders are checked when searching for application's location
*
* @param applicationName Name of the Mac OS application
* @return {@link DictionaryInfo} of the generated and cached dictionary for the application
*/
@Nullable
public DictionaryInfo getInitializedInfo(@NotNull final String applicationName) {
if (StringUtil.isEmptyOrSpaces(applicationName) || isNotScriptable(applicationName) || isInUnknownList(applicationName)) return null;
final DictionaryInfo savedDictionaryInfo = getDictionaryInfo(applicationName);
if (savedDictionaryInfo != null) {
if (savedDictionaryInfo.isInitialized() || initializeDictionaryFromInfo(savedDictionaryInfo)) {
return savedDictionaryInfo;
}
}
final File appFile = findApplicationBundleFile(applicationName);
if (appFile != null) {
return createAndInitializeInfo(appFile, applicationName);
}
return null;
}
示例8: parseClassElement
import com.intellij.openapi.util.text.StringUtil; //导入依赖的package包/类
private void parseClassElement(@NotNull String applicationName, @NotNull Element classElement, boolean isExtends) {
// if isExtends -> name is always == "application"
String className = isExtends ? classElement.getAttributeValue("extends") : classElement.getAttributeValue("name");
String code = classElement.getAttributeValue("code");
String pluralClassName = classElement.getAttributeValue("plural");
if (className == null || code == null) return;
pluralClassName = !StringUtil.isEmpty(pluralClassName) ? pluralClassName : className + "s";
updateObjectNameSetForApplication(className, applicationName, applicationNameToClassNameSetMap);
updateObjectNameSetForApplication(pluralClassName, applicationName, applicationNameToClassNamePluralSetMap);
if (ApplicationDictionary.SCRIPTING_ADDITIONS_LIBRARY.equals(applicationName)) {
updateApplicationNameSetFor(className, applicationName, stdClassNameToApplicationNameSetMap);
updateApplicationNameSetFor(pluralClassName, applicationName, stdClassNamePluralToApplicationNameSetMap);
}
}
示例9: readExternal
import com.intellij.openapi.util.text.StringUtil; //导入依赖的package包/类
@Override
public void readExternal(Element element) throws InvalidDataException {
super.readExternal(element);
String scriptUrl = element.getAttributeValue(SCRIPT_PATH_URL);
String scriptParams = element.getAttributeValue(SCRIPT_PARAMETERS);
String scriptOptions = element.getAttributeValue(SCRIPT_OPTIONS);
String logEvents = element.getAttributeValue(SCRIPT_SHOW_EVENTS);
if (!StringUtil.isEmpty(scriptUrl)) {
scriptPath = scriptUrl;
}
if (!StringUtil.isEmpty(scriptParams)) {
scriptParameters = scriptParams;
}
if (!StringUtil.isEmpty(scriptOptions)) {
this.scriptOptions = scriptOptions;
}
if (!StringUtil.isEmpty(logEvents)) myShowAppleEvents = "true".equals(logEvents);
}
示例10: resetEditorFrom
import com.intellij.openapi.util.text.StringUtil; //导入依赖的package包/类
@Override
protected void resetEditorFrom(AppleScriptRunConfiguration configuration) {
String scriptPath = configuration.getScriptPath();
String scriptParameters = configuration.getScriptParameters();
String scriptOptions = configuration.getScriptOptions();
boolean showAppleEvents = configuration.isShowAppleEvents();
if (!StringUtil.isEmpty(scriptPath)) {
scriptTextField.setText(scriptPath);
String[] parts = scriptPath.split("/");
if (parts.length > 0) {
runConfiguration.setName(parts[parts.length - 1]);
}
}
if (!StringUtil.isEmpty(scriptParameters)) {
parametersTextField.setText(scriptParameters);
}
if (!StringUtil.isEmpty(scriptOptions)) {
scriptOptionsTextField.setText(scriptOptions);
}
showAppleEventsCheckBox.setSelected(showAppleEvents);
}
示例11: ApplicationDictionaryImpl
import com.intellij.openapi.util.text.StringUtil; //导入依赖的package包/类
public ApplicationDictionaryImpl(@NotNull Project project, @NotNull XmlFile dictionaryXmlFile,
@NotNull String applicationName, @Nullable File applicationBundleFile) {
this.project = project;
this.dictionaryFile = dictionaryXmlFile.getVirtualFile();
readDictionaryFromXmlFile(dictionaryXmlFile);
this.applicationName = applicationName;
if (applicationBundleFile != null) {
this.applicationBundleFile = applicationBundleFile;
setIconFromBundle(applicationBundleFile);
}
if (StringUtil.isEmpty(dictionaryName))
dictionaryName = this.applicationName;
LOG.info("Dictionary [" + dictionaryName + "] for application [" + this.applicationName + "] " +
"initialized In project[" + project.getName() + "] " + " Commands: " + dictionaryCommandMap.size() +
". " + "Classes: " + dictionaryClassMap.size());
}
示例12: getReferencesByElement
import com.intellij.openapi.util.text.StringUtil; //导入依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
if (!(element instanceof XmlElement)) {
return PsiReference.EMPTY_ARRAY;
}
List<PsiReference> psiReferences = new ArrayList<>();
String methodName = StringUtil.unquoteString(element.getText());
PhpClass phpClass = DiIndex.getPhpClassOfServiceMethod((XmlElement) element);
if (phpClass != null) {
Collection<Method> methods = phpClass.getMethods();
methods.removeIf(m -> !m.getName().equalsIgnoreCase(methodName));
psiReferences.add(new PolyVariantReferenceBase(element, methods));
}
return psiReferences.toArray(new PsiReference[psiReferences.size()]);
}
示例13: getReferencesByElement
import com.intellij.openapi.util.text.StringUtil; //导入依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
String value = StringUtil.unquoteString(element.getText());
DiIndex index = DiIndex.getInstance(element.getProject());
Collection<PsiElement> targets = index.getVirtualTypeElements(value, element.getResolveScope());
if (!(targets.size() > 0)) {
return PsiReference.EMPTY_ARRAY;
}
return new PsiReference[] {
new PolyVariantReferenceBase(element, targets)
};
}
示例14: getReferencesByElement
import com.intellij.openapi.util.text.StringUtil; //导入依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
String value = StringUtil.unquoteString(element.getText());
Collection<PsiElement> targets = EventIndex.getInstance(element.getProject())
.getEventElements(
value,
GlobalSearchScope.getScopeRestrictedByFileTypes(
GlobalSearchScope.allScope(element.getProject()),
XmlFileType.INSTANCE
)
);
if (targets.size() > 0) {
return new PsiReference[] {new PolyVariantReferenceBase(element, targets)};
}
return PsiReference.EMPTY_ARRAY;
}
示例15: getReferencesByElement
import com.intellij.openapi.util.text.StringUtil; //导入依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
String value = StringUtil.unquoteString(element.getText());
Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance()
.getContainingFiles(EventNameIndex.KEY, value,
GlobalSearchScope.getScopeRestrictedByFileTypes(
GlobalSearchScope.allScope(element.getProject()),
PhpFileType.INSTANCE
)
);
PsiManager psiManager = PsiManager.getInstance(element.getProject());
for (VirtualFile virtualFile: containingFiles) {
PhpFile phpFile = (PhpFile) psiManager.findFile(virtualFile);
if (phpFile != null) {
List<PsiElement> psiElements = new ArrayList<>();
recursiveFill(psiElements, phpFile, value);
if (psiElements.size() > 0) {
return new PsiReference[] {new PolyVariantReferenceBase(element, psiElements)};
}
}
}
return PsiReference.EMPTY_ARRAY;
}