private String normalizeEntryRuleName(String entryRuleName) { String antlrEntryRuleName; if (!entryRuleName.startsWith("entryRule")) { if (!entryRuleName.startsWith("rule")) { antlrEntryRuleName = "entryRule" + entryRuleName; } else { antlrEntryRuleName = "entry" + Strings.toFirstUpper(entryRuleName); } } else { antlrEntryRuleName = entryRuleName; } return antlrEntryRuleName; }
public static String getContentAssistRuleName(AbstractRule rule) { String ruleName = getRuleName(rule); if (ruleName.startsWith("rule")) return "rule__" + Strings.toFirstUpper(ruleName.substring(4, ruleName.length())); return ruleName; }
private static String toTestName(File inputFile) { return Strings.toFirstUpper(FileSystem.shortBasename(inputFile).replaceAll("[^a-zA-Z0-9]+", "")); //$NON-NLS-1$ //$NON-NLS-2$ }
private String getAssignedFeature(RuleCall call) { Assignment ass = GrammarUtil.containingAssignment(call); if (ass != null) { String result = ass.getFeature(); if (result.equals(result.toLowerCase())) result = Strings.toFirstUpper(result); return result; } return null; }
private String getAssignedFeature(RuleCall call) { Assignment ass = GrammarUtil.containingAssignment(call); if (ass != null) { String result = ass.getFeature(); if (result.equals(result.toLowerCase())) result = Strings.toFirstUpper(result); return result; } return null; }
@Override public void completeAssignment(Assignment assignment, ContentAssistContext contentAssistContext, ICompletionProposalAcceptor acceptor) { ParserRule parserRule = GrammarUtil.containingParserRule(assignment); String methodName = "complete" + Strings.toFirstUpper(parserRule.getName()) + "_" + Strings.toFirstUpper(assignment.getFeature()); invokeMethod(methodName, acceptor, contentAssistContext.getCurrentModel(), assignment, contentAssistContext); }
/** * @since 2.9 */ public static String getEntryRuleName(ParserRule rule) { RuleWithParameterValues parameterValues = RuleWithParameterValues.findInEmfObject(rule); if (parameterValues != null) { if (parameterValues.getParamValues().isEmpty()) { AbstractRule original = parameterValues.getOriginal(); RuleNames ruleNames = RuleNames.getRuleNames(original); return "entry" + Strings.toFirstUpper(ruleNames.getAntlrRuleName(original)); } return null; } else { RuleNames ruleNames = RuleNames.getRuleNames(rule); return "entry" + Strings.toFirstUpper(ruleNames.getAntlrRuleName(rule)); } }
@Check public void checkGeneratedPackageForNameClashes(GeneratedMetamodel metamodel) { EPackage pack = metamodel.getEPackage(); Multimap<String, ENamedElement> constantNameToElement = HashMultimap.create(); Multimap<String, ENamedElement> accessorNameToElement = HashMultimap.create(); if (pack != null) { for(EClassifier classifier: pack.getEClassifiers()) { String accessorName = classifier.getName(); if ("Class".equals(accessorName) || "Name".equals(accessorName)) accessorName += "_"; accessorNameToElement.put("get" + accessorName, classifier); String classifierConstantName = CodeGenUtil.format(classifier.getName(), '_', null, true, true).toUpperCase(); constantNameToElement.put(classifierConstantName, classifier); if (classifier instanceof EClass) { for(EStructuralFeature feature: ((EClass) classifier).getEAllStructuralFeatures()) { String featureConstantPart = CodeGenUtil.format(feature.getName(), '_', null, false, false).toUpperCase(); String featureConstantName = classifierConstantName + "__" + featureConstantPart; constantNameToElement.put(featureConstantName, feature); String featureAccessorName = "get" + classifier.getName() + "_" + Strings.toFirstUpper(feature.getName()); accessorNameToElement.put(featureAccessorName, feature); } } } } createMessageForNameClashes(constantNameToElement); createMessageForNameClashes(accessorNameToElement); }
ObjectProperty property = (ObjectProperty)ref; if (property.eContainer() instanceof Component) { sb.append("get"+Strings.toFirstUpper(property.getName())+"()"); } else { sb.append(Strings.toFirstLower(property.getName())+".");
/** * @deprecated use {@link CommonServices#getRequestTypeName(TypedRequest)} or * {@link CommonServices#getResponseTypeName(TypedResponse)} instead * @param message typed message * @return generated type name for XSD generator that avoid name clashes */ @Deprecated public static String getMessageTypeName(TypedMessage message) { Method method = (Method) message.eContainer(); String methodName = method.getHttpMethod().getName().toLowerCase() + method.getContainingResourceDefinition().getName(); final Structure type = message.getActualType(); ImmutableList<TypedMessage> list = ImmutableList.copyOf(Iterators.filter( Iterators.filter(method.getContainingResourceDefinition().eAllContents(), TypedMessage.class), new Predicate<TypedMessage>() { @Override public boolean apply(TypedMessage input) { return input.getActualType() == type; } })); String baseName = Strings.toFirstUpper(methodName) + '_' + message.getActualType().getName(); if (list.size() > 1) { return baseName + '_' + (list.indexOf(message) + 1); } return baseName; }
ObjectProperty property = (ObjectProperty)ref; if (property.eContainer() instanceof Component) { sb.append("set"+Strings.toFirstUpper(property.getName())+"("); } else { SimpleType t = property.getType();
private void createStringProposal(ContentAssistContext context, ICompletionProposalAcceptor acceptor, String feature, RuleCall ruleCall) { String proposalText = feature != null ? feature : Strings.toFirstUpper(ruleCall.getRule().getName().toLowerCase()); proposalText = getValueConverter().toString(proposalText, ruleCall.getRule().getName()); String displayText = proposalText; if (feature != null) displayText = displayText + " - " + ruleCall.getRule().getName(); ICompletionProposal proposal = createCompletionProposal(proposalText, displayText, null, context); if (proposal instanceof ConfigurableCompletionProposal) { ConfigurableCompletionProposal configurable = (ConfigurableCompletionProposal) proposal; configurable.setSelectionStart(configurable.getReplacementOffset() + 1); configurable.setSelectionLength(proposalText.length() - 2); configurable.setAutoInsertable(false); configurable.setSimpleLinkedMode(context.getViewer(), proposalText.charAt(0), '\t'); } acceptor.accept(proposal); }
private void createStringProposal(ContentAssistContext context, ICompletionProposalAcceptor acceptor, String feature, RuleCall ruleCall) { String proposalText = feature != null ? feature : Strings.toFirstUpper(ruleCall.getRule().getName().toLowerCase()); proposalText = getValueConverter().toString(proposalText, ruleCall.getRule().getName()); String displayText = proposalText; if (feature != null) displayText = displayText + " - " + ruleCall.getRule().getName(); ICompletionProposal proposal = createCompletionProposal(proposalText, displayText, null, context); if (proposal instanceof ConfigurableCompletionProposal) { ConfigurableCompletionProposal configurable = (ConfigurableCompletionProposal) proposal; configurable.setSelectionStart(configurable.getReplacementOffset() + 1); configurable.setSelectionLength(proposalText.length() - 2); configurable.setAutoInsertable(false); configurable.setSimpleLinkedMode(context.getViewer(), proposalText.charAt(0), '\t'); } acceptor.accept(proposal); }
result.setVisibility(JvmVisibility.PUBLIC); result.setReturnType(references.getTypeForName(Void.TYPE,sourceElement)); result.setSimpleName("set" + Strings.toFirstUpper(propertyName)); result.getParameters().add(toParameter(sourceElement, propertyName, typeRef)); setBody(result, new Procedures.Procedure1<ITreeAppendable>() {
result.setVisibility(JvmVisibility.PUBLIC); String prefix = (isPrimitiveBoolean(typeRef) ? "is" : "get"); result.setSimpleName(prefix + Strings.toFirstUpper(propertyName)); result.setReturnType(cloneWithProxies(typeRef)); setBody(result, new Procedures.Procedure1<ITreeAppendable>() {
ContentAssistContext myContext = context.copy().setMatcher(newMatcher).toContext(); String feature = getAssignedFeature(ruleCall); String proposalText = feature != null ? feature : Strings.toFirstUpper(ruleCall.getRule().getName().toLowerCase()); String displayText = proposalText; if (feature != null)